9 #include <arich/modules/arichDigitizer/ARICHDigitizerModule.h>
12 #include <arich/dataobjects/ARICHSimHit.h>
13 #include <arich/dataobjects/ARICHDigit.h>
16 #include <framework/datastore/DataStore.h>
19 #include <framework/logging/Logger.h>
22 #include <framework/geometry/BFieldManager.h>
24 #include <framework/dataobjects/BackgroundInfo.h>
32 using namespace boost;
51 ARICHDigitizerModule::ARICHDigitizerModule() :
Module(),
56 setDescription(
"This module creates ARICHDigits from ARICHSimHits. Here spatial digitization is done, channel-by-channel QE is applied, and readout time window cut is applied.");
63 addParam(
"TimeWindowStart",
m_timeWindowStart,
"Shift of the readout time window with respect to the global zero in ns", -50.0);
64 addParam(
"BackgroundHits",
m_bkgLevel,
"Number of background hits per hapd per readout (electronics noise)", 0.066);
65 addParam(
"MagneticFieldDistorsion",
m_bdistort,
"Apply image distortion due to non-perp. magnetic field", 0);
104 std::map<std::pair<int, int>,
int> photoElectrons;
105 std::map<std::pair<int, int>,
int> chipHits;
115 TVector2 locpos(aSimHit.getLocalPosition().X(), aSimHit.getLocalPosition().Y());
118 int moduleID = aSimHit.getModuleID();
123 if (!
m_modInfo->isActive(moduleID))
continue;
127 m_geoPar->getHAPDGeometry().getXYChannel(locpos.X(), locpos.Y(), chX, chY);
129 if (chX < 0 && chY < 0)
continue;
142 if (qe_scale > 1.) B2ERROR(
"Channel QE is higher than QE applied in SensitiveDetector");
143 if (gRandom->Uniform(1.) > qe_scale)
continue;
146 chipHits[std::make_pair(moduleID,
asicChannel / 36)] += 1;
147 photoElectrons[std::make_pair(moduleID,
asicChannel)] += 1;
154 for (std::map<std::pair<int, int>,
int>::iterator it = photoElectrons.begin(); it != photoElectrons.end(); ++it) {
156 std::pair<int, int> modch = it->first;
157 double npe = double(it->second);
160 npe /= (1.0 +
m_simPar->getChipNegativeCrosstalk() * (double(chipHits[std::make_pair(modch.first, modch.second / 36)]) - 1.0));
161 if (npe < 1.0 && gRandom->Uniform(1) > npe)
continue;
166 for (
int i = 0; i < npe; i++) {
179 unsigned nSlots =
m_geoPar->getDetectorPlane().getNSlots();
180 for (
unsigned id = 1;
id < nSlots + 1;
id++) {
183 for (
int i = 0; i < nbkg; i++) {
194 double phi =
m_geoPar->getDetectorPlane().getSlotPhi(copyno);
195 double r =
m_geoPar->getDetectorPlane().getSlotR(copyno);
196 double z =
m_geoPar->getDetectorZPosition() +
m_geoPar->getHAPDGeometry().getWinThickness();
197 hitGlob.SetMagPhi(r, phi);
198 TVector2 shift = hit;
199 hitGlob += shift.Rotate(phi);
201 hitGlob.X(), hitGlob.Y(), z))));
202 double cc =
m_geoPar->getHAPDGeometry().getPhotocathodeApdDistance() / abs(Bfield.Z());
203 shift.SetX(cc * Bfield.X());
204 shift.SetY(cc * Bfield.Y());
205 shift = shift.Rotate(-phi);
206 hit.SetX(hit.X() + shift.X());
207 hit.SetY(hit.Y() + shift.Y());
double m_maxQE
QE at 400nm (from QE curve applied in SensitveDetector)
double m_bkgLevel
Number of background hits ped hapd per readout (electronics noise)
DBObjPtr< ARICHSimulationPar > m_simPar
simulation parameters from the DB
StoreArray< ARICHSimHit > m_ARICHSimHits
StoreArray containing the ARICHSimHits.
DBObjPtr< ARICHModulesInfo > m_modInfo
information on installed modules from the DB (QEs etc.)
DBObjPtr< ARICHGeometryConfig > m_geoPar
geometry configuration parameters from the DB
bool m_bgOverlay
True if BG overlay detected.
double m_timeWindow
Readout time window width in ns.
StoreArray< ARICHDigit > m_ARICHDigits
StoreArray containing the ARICHDigits.
int m_bdistort
apply distorsion due to magnetic field
DBObjPtr< ARICHChannelMapping > m_chnMap
HAPD (x,y) to asic channel mapping.
double m_timeWindowStart
Readout time window shift w.r.t.
Class ARICHSimHit - Geant4 simulated hit for ARICH.
@ c_Persistent
Object is available during entire execution time.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual ~ARICHDigitizerModule()
Destructor.
virtual void beginRun() override
Called when entering a new run.
void magFieldDistorsion(TVector2 &hit, int copyno)
Apply correction to hit position due to non-perpendicular component of magnetic field.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Abstract base class for different kinds of events.
record to be used to store ASIC info