10 #include <arich/modules/arichFillHits/ARICHFillHitsModule.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/dataobjects/EventMetaData.h>
17 #include <framework/logging/Logger.h>
20 #include <arich/dataobjects/ARICHDigit.h>
21 #include <arich/dataobjects/ARICHHit.h>
23 #include <framework/geometry/BFieldManager.h>
46 setDescription(
"Fills ARICHHits collection from ARICHDigits");
47 setPropertyFlags(c_ParallelProcessingCertified);
48 addParam(
"bitMask", m_bitMask,
"hit bit mask (8 bits/channel)", (uint8_t)0xFF);
49 addParam(
"maxApdHits" , m_maxApdHits ,
"Remove hits with more than MaxApdHits per APD chip", (uint8_t)18);
50 addParam(
"maxHapdHits", m_maxHapdHits,
"Remove hits with more than MaxHapdHits per HAPD", (uint8_t)100);
51 addParam(
"MagFieldCorrection", m_bcorrect,
"Apply hit position correction due to non-perp. mag. field", 0);
52 addParam(
"fillAll", m_fillall,
"Make hits for all active channels (useful for likelihood PDF studies)", 0);
55 ARICHFillHitsModule::~ARICHFillHitsModule()
59 void ARICHFillHitsModule::initialize()
66 arichHits.registerInDataStore();
68 arichHits.registerRelationTo(digits);
71 void ARICHFillHitsModule::beginRun()
75 void ARICHFillHitsModule::event()
83 std::vector<uint8_t> apdHits(420 * 4, 0);
84 std::vector<uint8_t> hapdHits(420, 0);
85 for (
const auto& digit : digits) {
86 uint8_t bits = digit.getBitmap();
87 if (!(bits & m_bitMask))
continue;
89 int moduleID = digit.getModuleID();
90 if (moduleID > 420 || moduleID < 1)
continue;
92 int channelID = digit.getChannelID();
93 if (channelID > 143 || channelID < 0)
continue;
94 int chipID = moduleID * 4 + channelID / 36;
100 for (
const auto& digit : digits) {
101 int asicCh = digit.getChannelID();
102 int modID = digit.getModuleID();
103 if (modID > 420 || modID < 1)
continue;
104 if (asicCh > 143 || asicCh < 0)
continue;
105 uint8_t hitBitmap = digit.getBitmap();
106 if (!(hitBitmap & m_bitMask))
continue;
109 if (!m_chnMask->isActive(modID, asicCh))
continue;
111 int chipID = (modID - 1) * 4 + asicCh / 36;
113 if (apdHits[chipID] > m_maxApdHits)
continue;
114 if (hapdHits[modID - 1] > m_maxHapdHits)
continue;
118 if (not m_chnMap->getXYFromAsic(asicCh, xCh, yCh)) {
119 B2ERROR(
"Invalid ARICH hit! This hit will be ignored.");
123 TVector2 hitpos2D = m_geoPar->getChannelPosition(modID, xCh, yCh);
124 TVector3 hitpos3D(hitpos2D.X(), hitpos2D.Y(), m_geoPar->getDetectorZPosition() + m_geoPar->getHAPDGeometry().getWinThickness());
125 hitpos3D = m_geoPar->getMasterVolume().pointToGlobal(hitpos3D);
127 if (m_bcorrect) magFieldCorrection(hitpos3D);
128 ARICHHit* hh = arichHits.appendNew(hitpos3D, modID, asicCh);
132 for (
int imod = 1; imod < 421; imod++) {
133 for (
int ichn = 0; ichn < 144; ichn++) {
136 if (!m_chnMask->isActive(imod, ichn))
continue;
137 int chipID = (imod - 1) * 4 + ichn / 36;
139 if (apdHits[chipID] > m_maxApdHits)
continue;
140 if (hapdHits[imod - 1] > m_maxHapdHits)
continue;
143 if (not m_chnMap->getXYFromAsic(ichn, xCh, yCh)) {
144 B2ERROR(
"Invalid ARICH hit! This hit will be ignored.");
148 TVector2 hitpos2D = m_geoPar->getChannelPosition(imod, xCh, yCh);
149 TVector3 hitpos3D(hitpos2D.X(), hitpos2D.Y(), m_geoPar->getDetectorZPosition() + m_geoPar->getHAPDGeometry().getWinThickness());
150 hitpos3D = m_geoPar->getMasterVolume().pointToGlobal(hitpos3D);
151 if (m_bcorrect) magFieldCorrection(hitpos3D);
152 arichHits.appendNew(hitpos3D, imod, ichn);
159 void ARICHFillHitsModule::magFieldCorrection(TVector3& hitpos)
161 TVector3 Bfield = BFieldManager::getField(hitpos);
162 TVector3 shift = m_geoPar->getHAPDGeometry().getPhotocathodeApdDistance() / abs(Bfield.Z()) * Bfield;
163 hitpos.SetX(hitpos.X() - shift.X());
164 hitpos.SetY(hitpos.Y() - shift.Y());
167 void ARICHFillHitsModule::endRun()
171 void ARICHFillHitsModule::terminate()
Fill ARICHHit collection from ARICHDigits.
Datastore class that holds photon hits. Input to the reconstruction.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.