Belle II Software development
CDCDigitizerModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11//basf2 framework headers
12#include <framework/core/Module.h>
13#include <framework/datastore/StoreArray.h>
14
15#include <simulation/dataobjects/SimClockState.h>
16
17//cdc package headers
18#include <mdst/dataobjects/MCParticle.h>
19#include <cdc/dataobjects/CDCSimHit.h>
20#include <cdc/dataobjects/CDCHit.h>
21#include <cdc/dataobjects/WireID.h>
22#include <cdc/geometry/CDCGeometryPar.h>
23#include <cdc/geometry/CDCGeoControlPar.h>
24#include <cdc/dbobjects/CDCFEElectronics.h>
25#include <reconstruction/dbobjects/CDCDedxRunGain.h>
26#include <reconstruction/dbobjects/CDCDedxScaleFactor.h>
27#include <reconstruction/dbobjects/CDCDedxWireGain.h>
28//#include <cdc/dbobjects/CDCEDepToADCConversions.h>
29#include <cdc/dbobjects/CDCCrossTalkLibrary.h>
30#include <cdc/dbobjects/CDCCorrToThresholds.h>
31
32//C++/C standard lib elements.
33#include <string>
34//#include <queue>
35#include <limits>
36
37namespace Belle2 {
54 class CDCDigitizerModule : public Module {
55
56 public:
59
61 void initialize() override;
62
67 void event() override;
68
70 void terminate() override
71 {
73 // if (m_eDepToADCConversionsFromDB) delete m_eDepToADCConversionsFromDB;
75 if (m_gain0FromDB) delete m_gain0FromDB;
77 if (m_xTalkFromDB) delete m_xTalkFromDB;
79 };
80
81 private:
88 double smearDriftLength(double driftLength, double dDdt);
89
90
100 double getdDdt(double driftLength);
101
102
114 double getDriftTime(double driftLength, bool addTof, bool addDelay);
115
116
127 void makeSignalsAfterShapers(const WireID& wid, double edep, double dx, double costh, unsigned short& adcCount,
128 double& convFactorForThreshold);
129
131 double getPositiveT0(const WireID&);
132
134 void setFEElectronics();
135
140 double Polya(double xmax = 10);
141
143 void setSemiTotalGain();
144
146
151 double getSemiTotalGain(int clayer, int cell) const
152 {
153 return m_semiTotalGain[clayer][cell];
154 }
155
157
161 double getSemiTotalGain(const WireID& wireID) const
162 {
163 return m_semiTotalGain[wireID.getICLayer()][wireID.getIWire()];
164 }
165
167 void addXTalk();
168
170 // void setEDepToADCConversions();
171
188 //--- Parameters for simple digitization -------------------------------------------------------------------------------------
189 double m_fraction;
190 double m_mean1;
192 double m_mean2;
198 double m_tMin;
199 double m_tMaxOuter;
200 double m_tMaxInner;
201 // unsigned short m_tdcOffset; /**< Offset of TDC count (in ns)*/
208 unsigned short m_posFlag;
209 unsigned short m_boardID = 0;
219 double m_tdcResol;
220 double m_driftV;
221 double m_driftVInv;
230 double m_totalFudgeFactor = 1.;
232 bool m_gasGainSmearing = true;
233 double m_effWForGasGainSmearing = 0.0266;
234 double m_thetaOfPolya = 0.5;
235 bool m_extraADCSmearing = false;
236 // double m_sigmaForExtraADCSmearing = 0.3; /**< Gaussian sigma for extra ADC smearing */
237 double m_runGain = 1.;
238 float m_semiTotalGain[c_maxNSenseLayers][c_maxNDriftCells] = {{}};
241 //--- Universal digitization parameters -------------------------------------------------------------------------------------
250 bool m_align;
255// float m_eventTime; /**< It is a timing of event, which includes a time jitter due to the trigger system */
256
259 float m_lowEdgeOfTimeWindow[c_nBoards] = {0};
260 float m_uprEdgeOfTimeWindow[c_nBoards] = {0};
261 float m_tdcThresh [c_nBoards] = {0};
262 float m_adcThresh [c_nBoards] = {0};
263 unsigned short m_widthOfTimeWindowInCount [c_nBoards] = {0};
272 // DBObjPtr<CDCEDepToADCConversions>* m_eDepToADCConversionsFromDB = nullptr; /*!< Pointer to edep-to-ADC conv. params. from DB. */
273 // float m_eDepToADCParams[c_maxNSenseLayers][4]; /*!< edep-to-ADC conv. params. */
274
284 bool m_synchronization = true;
285 bool m_randomization = true;
286 int m_tSimMode = 0;
290 unsigned short m_trgDelayInCount[c_nBoards] = {0};
293 struct SignalInfo {
295 SignalInfo(int simHitIndex = 0, float driftTime = 0, float charge = 0, float maxDriftL = 0, float minDriftL = 0,
296 int simHitIndex2 = -1,
297 float driftTime2 = std::numeric_limits<float>::max(), int simHitIndex3 = -1, float driftTime3 = std::numeric_limits<float>::max()) :
298 m_simHitIndex(simHitIndex), m_driftTime(driftTime), m_charge(charge), m_maxDriftL(maxDriftL), m_minDriftL(minDriftL),
299 m_simHitIndex2(simHitIndex2), m_driftTime2(driftTime2),
300 m_simHitIndex3(simHitIndex3), m_driftTime3(driftTime3) {}
303 float m_charge;
310 };
311
313 struct XTalkInfo {
315 XTalkInfo(unsigned short tdc, unsigned short adc, unsigned short tot, unsigned short status) :
316 m_tdc(tdc), m_adc(adc), m_tot(tot), m_status(status) {}
317 unsigned short m_tdc;
318 unsigned short m_adc;
319 unsigned short m_tot;
320 unsigned short m_status;
321 };
322 };
323
325} // end of Belle2 namespace
The Class for Detailed Digitization of CDC.
double m_tdcThreshold4Inner
TDC threshold for inner layers in unit of eV.
double m_driftV
Nominal drift velocity (in cm/ns)
double Polya(double xmax=10)
Generate random number according to Polya distribution.
unsigned short m_boardID
FEE board ID.
int m_eDepInGasMode
Mode for extracting dE(gas) from dE(gas+wire)
double m_tMaxInner
Upper edge of time window in ns for the inner layers.
double getdDdt(double driftLength)
The method to get dD/dt.
bool m_outputNegativeDriftTime
A switch to output negative drift time to CDCHit.
unsigned short m_widthOfTimeWindowInCount[c_nBoards]
Width of time window.
bool m_extraADCSmearing
Switch for extra ADC smearing.
bool m_includeEarlyXTalks
Flag to switch on/off xtalks earlier than the hit.
void makeSignalsAfterShapers(const WireID &wid, double edep, double dx, double costh, unsigned short &adcCount, double &convFactorForThreshold)
Function to write ADC-count and conversion factor for threshold.
int m_trgTimingOffsetInCount
Trigger timing offset in unit of count.
bool m_addInWirePropagationDelay4Bg
A switch used to control adding propagation delay into the total drift time or not for beam bg.
double getSemiTotalGain(int clayer, int cell) const
Return semi-total gain of the specified wire.
bool m_useDB4RunGain
Fetch run gain from DB.
DBObjPtr< CDCCrossTalkLibrary > * m_xTalkFromDB
Pointer to cross-talk from DB.
double m_analogGain
analog gain (V/pC)
double m_tdcBinWidthInv
m_tdcBinWidth^-1 (in ns^-1)
float m_uprEdgeOfTimeWindow[c_nBoards]
Upper edge of time-window.
double m_tMin
Lower edge of time window in ns.
bool m_output2ndHit
A switch to output 2nd hit.
int m_adcThreshold
Threshold for ADC in unit of count.
double m_resolution2
Resolution of the second Gaussian used to smear drift length.
bool m_addTimeOfFlight
A switch used to control adding time of flight into the total drift time or not.
double m_trigTimeJitter
Magnitude of trigger timing jitter (ns).
void initialize() override
Initialize variables, print info, and start CPU clock.
double smearDriftLength(double driftLength, double dDdt)
Method used to smear the drift length.
std::string m_MCParticlesToSimHitsName
Relation for origin of incoming SimHits.
double m_digitalGain
digital gain (V/pC)
double m_totalFudgeFactor
total fudge factor for space resol.
std::string m_OptionalAllMCParticlesToHitsName
Relation name for optional matching of all MCParticles.
bool m_addInWirePropagationDelay
A switch used to control adding propagation delay into the total drift time or not.
bool m_align
A switch to control alignment.
void event() override
Actual digitization of all hits in the CDC.
unsigned short m_trgDelayInCount[c_nBoards]
Trigger delay in frontend electronics in count.
double m_globalTime
global time of this hit
bool m_doSmearing
A switch to control drift length smearing.
std::string m_inputCDCSimHitsName
Input array name.
DBObjPtr< CDCDedxWireGain > * m_wireGainFromDB
Pointer to wire gain from DB.
B2Vector3D m_posWire
wire position of this hit
bool m_addTimeOfFlight4Bg
A switch used to control adding time of flight into the total drift time or not for beam bg.
bool m_addXTalk
Flag to switch on/off crosstalk.
bool m_addTimeWalk
A switch used to control adding time-walk delay into the total drift time or not.
bool m_treatNegT0WiresAsGood
A switch for negative-t0 wires.
void terminate() override
Terminate func.
double m_addFudgeFactorForSigma
additional fudge factor for space resol.
bool m_matchAllMCParticles
A switch to match all particles to a hit, regardless whether they produced a hit or not.
bool m_useDB4EDepToADC
Fetch edep-to-ADC conversion params.
std::string m_SimHitsTOCDCHitsName
Relation for outgoing CDCHits.
int m_offsetForTriggerBin
Input to getCDCTriggerBin(offset)
void setSemiTotalGain()
Set semi-total gain (from DB)
double m_driftLength
drift length of this hit
double m_tdcResol
TDC resolution (in ns)
int m_tSimMode
Timing simulation mode.
bool m_useDB4FEE
Fetch FEE params from DB.
double m_adcBinWidth
ADC bin width (mV)
double m_thetaOfPolya
theta of Polya function for gas gain smearing
bool m_matchFirstMCParticles
A switch to match first three MCParticles, not just the one with smallest drift time.
bool m_spaceChargeEffect
Space charge effect.
double m_driftVInv
m_driftV^-1 (in ns/cm)
StoreArray< CDCSimHit > m_simHits
CDCSimHit array.
DBObjPtr< CDCCorrToThresholds > * m_corrToThresholdFromDB
Pointer to threshold correction from DB.
std::string m_OptionalFirstMCParticlesToHitsName
Relation name for optional matching of up to first three MCParticles.
StoreArray< CDCHit > m_cdcHits4Trg
CDCHit4trg array.
float m_semiTotalGain[c_maxNSenseLayers][c_maxNDriftCells]
total gain per wire
DBObjPtr< CDCDedxRunGain > * m_runGainFromDB
Pointer to run gain from DB.
double m_degOfSPEOnThreshold
Degree of space charge effect on timing threshold.
bool m_randomization
Flag to switch on/off timing randomization.
CDCSimHit * m_aCDCSimHit
Pointer to CDCSimHit.
WireID m_wireID
WireID of this hit.
double getSemiTotalGain(const WireID &wireID) const
Return semi-total gain of the specified wire.
DBObjPtr< CDCDedxScaleFactor > * m_gain0FromDB
Pointer to overall gain factor from DB.
double m_effWForGasGainSmearing
Effective energy (keV) for one electron prod.
bool m_issue2ndHitWarning
Flag to switch on/off a warning on the 2nd TDC hit.
double getPositiveT0(const WireID &)
Modify t0 for negative-t0 case.
double m_tdcThreshold4Outer
TDC threshold for outer layers in unit of eV.
double m_tdcThresholdOffset
Offset for TDC(digital) threshold (mV)
double m_fraction
Fraction of the first Gaussian used to smear drift length.
int m_debugLevel4XTalk
Debug level for crosstalk.
int m_shiftOfTimeWindowIn32Count
Shift of time window for synchronization in 32count.
unsigned short m_posFlag
left or right flag of this hit
std::string m_outputCDCHitsName4Trg
Output array name for trigger.
StoreArray< CDCHit > m_cdcHits
CDCHit array.
double m_mean1
Mean value of the first Gaussian used to smear drift length.
bool m_synchronization
Flag to switch on/off timing synchronization.
float m_lowEdgeOfTimeWindow[c_nBoards]
Lower edge of time-window.
double getDriftTime(double driftLength, bool addTof, bool addDelay)
The method to get drift time based on drift length.
std::string m_outputCDCHitsName
Output array name.
float m_tdcThresh[c_nBoards]
Threshold for timing-signal.
B2Vector3D m_momentum
3-momentum of this hit
StoreArray< MCParticle > m_mcParticles
Set edep-to-ADC conversion params.
bool m_gasGainSmearing
Switch for gas gain smearing.
double m_tMaxOuter
Upper edge of time window in ns for the outer layers.
DBArray< CDCFEElectronics > * m_fEElectronicsFromDB
Pointer to FE electronics params.
double m_resolution1
Resolution of the first Gaussian used to smear drift length.
B2Vector3D m_posTrack
track position of this hit
bool m_useSimpleDigitization
Use float Gaussian Smearing instead of proper digitization.
CDC::CDCGeometryPar * m_cdcgp
Cached Pointer to CDCGeometryPar.
double m_overallGainFactor
Overall gain factor.
void setFEElectronics()
Set FEE parameters (from DB)
double m_mean2
Mean value of the second Gaussian used to smear drift length.
double m_tdcBinWidth
Width of a TDC bin (in ns)
CDC::CDCGeoControlPar * m_gcp
Cached pointer to CDCGeoControlPar.
bool m_correctForWireSag
A switch to control wire sag.
StoreObjPtr< SimClockState > m_simClockState
generated hardware clock state
double m_flightTime
flight time of this hit
float m_adcThresh[c_nBoards]
Threshold for FADC.
Example Detector.
Definition: CDCSimHit.h:21
The Class for CDC Geometry Control Parameters.
The Class for CDC Geometry Parameters.
Class for accessing arrays of objects in the database.
Definition: DBArray.h:26
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getICLayer() const
Getter for continuous layer numbering.
Definition: WireID.cc:24
unsigned short getIWire() const
Getter for wire within the layer.
Definition: WireID.h:145
Abstract base class for different kinds of events.
Structure for saving the signal information.
float m_driftTime2
2nd-shortest drift time in the cell.
int m_simHitIndex2
SimHit index for 2nd drift time.
int m_simHitIndex3
SimHit index for 3rd drift time.
float m_charge
Sum of charge for all SimHits in the cell.
float m_driftTime
Shortest drift time of any SimHit in the cell.
float m_driftTime3
3rd-shortest drift time in the cell.
SignalInfo(int simHitIndex=0, float driftTime=0, float charge=0, float maxDriftL=0, float minDriftL=0, int simHitIndex2=-1, float driftTime2=std::numeric_limits< float >::max(), int simHitIndex3=-1, float driftTime3=std::numeric_limits< float >::max())
Constructor that initializes all members.
Structure for saving the x-talk information.
XTalkInfo(unsigned short tdc, unsigned short adc, unsigned short tot, unsigned short status)
Constructor that initializes all members.