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 <cdc/dbobjects/CDCDedxRunGain.h>
26#include <cdc/dbobjects/CDCDedxScaleFactor.h>
27#include <cdc/dbobjects/CDCDedxWireGain.h>
28//#include <cdc/dbobjects/CDCEDepToADCConversions.h>
29#include <cdc/dbobjects/CDCCrossTalkLibrary.h>
30#include <cdc/dbobjects/CDCCorrToThresholds.h>
31#include <cdc/dbobjects/CDCAlphaScaleFactorForAsymmetry.h>
32
33//C++/C standard lib elements.
34#include <string>
35//#include <queue>
36#include <limits>
37
38namespace Belle2 {
43
55 class CDCDigitizerModule : public Module {
56
57 public:
60
62 void initialize() override;
63
68 void event() override;
69
71 void terminate() override
72 {
74 // if (m_eDepToADCConversionsFromDB) delete m_eDepToADCConversionsFromDB;
76 if (m_gain0FromDB) delete m_gain0FromDB;
78 if (m_xTalkFromDB) delete m_xTalkFromDB;
80 };
81
82 private:
89 double smearDriftLength(double driftLength, double dDdt);
90
91
101 double getdDdt(double driftLength);
102
103
115 double getDriftTime(double driftLength, bool addTof, bool addDelay);
116
117
128 void makeSignalsAfterShapers(const WireID& wid, double edep, double dx, double costh, unsigned short& adcCount,
129 double& convFactorForThreshold);
130
132 double getPositiveT0(const WireID&);
133
135 void setFEElectronics();
136
141 double Polya(double xmax = 10);
142
144 void setSemiTotalGain();
145
147
152 double getSemiTotalGain(int clayer, int cell) const
153 {
154 return m_semiTotalGain[clayer][cell];
155 }
156
158
162 double getSemiTotalGain(const WireID& wireID) const
163 {
164 return m_semiTotalGain[wireID.getICLayer()][wireID.getIWire()];
165 }
166
168 void addXTalk();
169
171 // void setEDepToADCConversions();
172
177
181
184
187
189 //--- Parameters for simple digitization -------------------------------------------------------------------------------------
190 double m_fraction;
191 double m_mean1;
193 double m_mean2;
199 double m_tMin;
200 double m_tMaxOuter;
201 double m_tMaxInner;
202 // unsigned short m_tdcOffset; /**< Offset of TDC count (in ns)*/
204
209 unsigned short m_posFlag;
210 unsigned short m_boardID = 0;
217
220 double m_tdcResol;
221 double m_driftV;
222 double m_driftVInv;
224
229
231 double m_totalFudgeFactor = 1.;
232
233 bool m_gasGainSmearing = true;
234 double m_effWForGasGainSmearing = 0.0266;
235 double m_thetaOfPolya = 0.5;
236 bool m_extraADCSmearing = false;
237 // double m_sigmaForExtraADCSmearing = 0.3; /**< Gaussian sigma for extra ADC smearing */
238 double m_runGain = 1.;
239 float m_semiTotalGain[c_maxNSenseLayers][c_maxNDriftCells] = {{}};
242 //--- Parameters for alpha correction -------------------------------------------------------------------------------------
246 //--- Universal digitization parameters -------------------------------------------------------------------------------------
255 bool m_align;
260// float m_eventTime; /**< It is a timing of event, which includes a time jitter due to the trigger system */
261
264 float m_lowEdgeOfTimeWindow[c_nBoards] = {0};
265 float m_uprEdgeOfTimeWindow[c_nBoards] = {0};
266 float m_tdcThresh [c_nBoards] = {0};
267 float m_adcThresh [c_nBoards] = {0};
268 unsigned short m_widthOfTimeWindowInCount [c_nBoards] = {0};
269
273
277 // DBObjPtr<CDCEDepToADCConversions>* m_eDepToADCConversionsFromDB = nullptr; /*!< Pointer to edep-to-ADC conv. params. from DB. */
278 // float m_eDepToADCParams[c_maxNSenseLayers][4]; /*!< edep-to-ADC conv. params. */
279
287
289 bool m_synchronization = true;
290 bool m_randomization = true;
291 int m_tSimMode = 0;
295 unsigned short m_trgDelayInCount[c_nBoards] = {0};
296
298 struct SignalInfo {
300 SignalInfo(int simHitIndex = 0, float driftTime = 0, float charge = 0, float maxDriftL = 0, float minDriftL = 0,
301 int simHitIndex2 = -1,
302 float driftTime2 = std::numeric_limits<float>::max(), int simHitIndex3 = -1, float driftTime3 = std::numeric_limits<float>::max()) :
303 m_simHitIndex(simHitIndex), m_driftTime(driftTime), m_charge(charge), m_maxDriftL(maxDriftL), m_minDriftL(minDriftL),
304 m_simHitIndex2(simHitIndex2), m_driftTime2(driftTime2),
305 m_simHitIndex3(simHitIndex3), m_driftTime3(driftTime3) {}
308 float m_charge;
315 };
316
318 struct XTalkInfo {
320 XTalkInfo(unsigned short tdc, unsigned short adc, unsigned short tot, unsigned short status) :
321 m_tdc(tdc), m_adc(adc), m_tot(tot), m_status(status) {}
322 unsigned short m_tdc;
323 unsigned short m_adc;
324 unsigned short m_tot;
325 unsigned short m_status;
326 };
327 };
328
330} // end of Belle2 namespace
bool m_alphaCorrection
Switch for alpha correction.
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.
OptionalDBObjPtr< CDCAlphaScaleFactorForAsymmetry > m_alphaScaleFactorsFromDB
the ratio of data to MC, for eff(alpha<0)/eff(alpha>0).
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
Module()
Constructor.
Definition Module.cc:30
Optional DBObjPtr: This class behaves the same as the DBObjPtr except that it will not raise errors w...
Definition DBObjPtr.h:48
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
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition B2Vector3.h:516
Abstract base class for different kinds of events.
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.
XTalkInfo(unsigned short tdc, unsigned short adc, unsigned short tot, unsigned short status)
Constructor that initializes all members.