15#define BOOST_TEST_MODULE Test MCHSimulation Digitization
16#define BOOST_TEST_DYN_LINK
18#include <boost/test/unit_test.hpp>
32#include "TGeoManager.h"
33#include "TGeoGlobalMagField.h"
34#include "boost/format.hpp"
35#include <boost/test/data/test_case.hpp>
36#include <boost/property_tree/ptree.hpp>
38#include <unordered_map>
58 if (TGeoGlobalMagField::Instance()->GetField()) {
64 "A-A",
"$(O2_ROOT)/share/Common/maps/mfchebKGI_sym.root");
65 TGeoGlobalMagField::Instance()->SetField(field);
66 TGeoGlobalMagField::Instance()->Lock();
71short detElemId1 = 101;
74short detElemId2 = 1012;
77short detElemId3 = 1012;
86 BOOST_FAIL(
" digit-pad not belonging to hit det-element-ID ");
97 t.MasterToLocal(
pos, lpos);
101 BOOST_CHECK(std::abs(lpos.x() - padposX) < padsizeX * 10);
102 BOOST_CHECK(std::abs(lpos.y() - padposY) < padsizeY * 10);
111BOOST_FIXTURE_TEST_SUITE(digitization,
GEOMETRY)
124 IR collisionTime1(3, 1);
125 IR collisionTime2(5, 1);
131 std::vector<o2::mch::Hit> hits1(2);
132 hits1.at(0) =
o2::mch::Hit(trackId1, detElemId1, entrancePoint1, exitPoint1, eloss,
length, tof, energ);
133 hits1.at(1) =
o2::mch::Hit(trackId2, detElemId2, entrancePoint2, exitPoint2, eloss,
length, tof, energ);
135 std::vector<o2::mch::Hit> hits2(1);
136 hits2.at(0) =
o2::mch::Hit(trackId3, detElemId3, entrancePoint3, exitPoint3, eloss,
length, tof, energ);
138 digitizer.
processHits(hits1, collisionTime1, 0, 0);
139 digitizer.
processHits(hits2, collisionTime2, 0, 0);
142 auto lastIR = collisionTime2 + 100;
143 digitizer.
addNoise(firstIR, lastIR);
145 std::vector<ROFRecord> rofs{};
146 std::vector<Digit>
digits{};
152 int digitcounter1 = 0;
153 int digitcounter2 = 0;
154 int digitcounter3 = 0;
155 int64_t previousROFtime = -1;
156 std::unordered_map<int, Digit> digitsMap{};
158 for (
const auto& rof : rofs) {
161 if (rof.getBCData().bc % 4 != 0) {
162 BOOST_FAIL(
" ROF IR not aligned on 4 BC ");
166 auto rofTime = rof.getBCData().toLong();
167 if (rofTime < previousROFtime) {
168 BOOST_FAIL(
" ROF not ordered in ascending IR ");
169 }
else if (rofTime == previousROFtime) {
170 BOOST_FAIL(
" 2 ROFs with the same IR ");
172 previousROFtime = rofTime;
174 for (
int iDigit = rof.getFirstIdx(); iDigit <= rof.getLastIdx(); ++iDigit) {
175 const auto& digit =
digits[iDigit];
178 for (
const auto&
label : labels.getLabels(iDigit)) {
179 int trackID =
label.getTrackID();
180 if (trackID == trackId1) {
182 }
else if (trackID == trackId2) {
184 }
else if (trackID == trackId3) {
186 }
else if (!
label.isNoise()) {
187 BOOST_FAIL(
" MC-labels not matching between hit and digit ");
192 auto itDigit = digitsMap.emplace((digit.
getDetID() << 16) + digit.
getPadID(), digit);
193 if (!itDigit.second &&
194 digit.
getTime() - itDigit.first->second.getTime() < 4 * (itDigit.first->second.getNofSamples() + 2)) {
195 BOOST_FAIL(
" same pad has multiple digits in overlapping readout windows ");
207BOOST_AUTO_TEST_SUITE_END()
o2::mch::mapping::CathodeSegmentation seg
Definition of a container to keep Monte Carlo truth external to simulation objects.
Interface for MCH geometry creation.
Definition of the MagF class.
static void setValue(std::string const &mainkey, std::string const &subkey, T x)
static MagneticField * createFieldMap(float l3Current=-30000., float diCurrent=-6000., Int_t convention=0, Bool_t uniform=kFALSE, float beamenergy=7000, const Char_t *btype="pp", const std::string path=std::string(gSystem->Getenv("VMCWORKDIR"))+std::string("/Common/maps/mfchebKGI_sym.root"))
MCH digit implementation.
void addNoise(const InteractionRecord &firstIR, const InteractionRecord &lastIR)
void processHits(gsl::span< const Hit > hits, const InteractionRecord &collisionTime, int evID, int srcID)
size_t digitize(std::vector< ROFRecord > &rofs, std::vector< Digit > &digits, dataformats::MCLabelContainer &labels)
double padSizeY(int catPadIndex) const
double padSizeX(int catPadIndex) const
double padPositionY(int catPadIndex) const
double padPositionX(int catPadIndex) const
bool isValid(int catPadIndex) const
Not every integer is a valid catPadIndex. This method will tell if catPadIndex is a valid one.
A Segmentation lets you find pads of a detection element and then inspect those pads.
GLuint GLsizei GLsizei * length
GLuint GLsizei const GLchar * label
void check(const std::vector< std::string > &arguments, const std::vector< ConfigParamSpec > &workflowOptions, const std::vector< DeviceSpec > &deviceSpecs, CheckMatrix &matrix)
TransformationCreator transformationFromTGeoManager(const TGeoManager &geo)
std::function< o2::math_utils::Transform3D(int detElemId)> TransformationCreator
void createStandaloneGeometry()
static InteractionRecord long2IR(int64_t l)
BOOST_AUTO_TEST_CASE(DigitizerTest)
Test of the Digitization A couple of values are filled into Hits and we check whether we get reproduc...
void initField(float l3Current, float dipoleCurrent)
BOOST_TEST(digits==digitsD, boost::test_tools::per_element())
std::vector< Digit > digits