All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
icaruscode/icaruscode/CRT/CRTUtils/CRTDetSimAlg.h
Go to the documentation of this file.
1 #ifndef IC_CRTDETSIMALG_H
2 #define IC_CRTDETSIMALG_H
3 
4 //art includes
5 #include "art/Framework/Principal/Handle.h"
6 #include "fhiclcpp/ParameterSet.h"
7 #include "nurandom/RandomUtils/NuRandomService.h"
8 
9 //larsoft includes
17 
18 //CLHEP includes
19 #include "CLHEP/Random/RandomEngine.h"
20 #include "CLHEP/Random/RandFlat.h"
21 #include "CLHEP/Random/RandGauss.h"
22 #include "CLHEP/Random/RandPoisson.h"
23 
24 //C++ includes
25 #include <cmath>
26 #include <map>
27 #include <set>
28 #include <vector>
29 #include <string>
30 #include <utility>
31 
32 //ROOT includes
33 #include "TGeoManager.h"
34 #include "TGeoNode.h"
35 
36 //CRT includes
39 
40 using std::vector;
41 using std::pair;
42 using std::map;
43 using std::set;
44 using std::string;
45 using sim::AuxDetIDE;
46 
47 namespace icarus {
48  namespace crt {
49  class CRTDetSimAlg;
50  }
51 }
52 
53 struct ChanData {
54  int channel;
55  uint16_t adc;
56  uint64_t ts;
57 };//ChanData
58 
59 struct Tagger {
60  char type;
61  int modid;
62  string reg; //crt region where FEB is located
63  set<int> layerid; //keep track of layers hit accross whole event window
64  map<int,int> chanlayer; //map chan # to layer
65  vector<pair<ChanData,AuxDetIDE>> data; //time and charge info for each channel > thresh
66 };//Tagger
67 
68 
70 
71  public:
72 
73  CRTDetSimAlg(fhicl::ParameterSet const & p, CLHEP::HepRandomEngine& fRandEngine);
74  void reconfigure(fhicl::ParameterSet const & p);
75 
76  void ClearTaggers();
77  //given a vector of AuxDetIDEs, fill a map of tagger objects with intermediate ChannelData + aux info
78  void FillTaggers(detinfo::DetectorClocksData const& clockData,
79  const uint32_t adid, const uint32_t adsid, const vector<AuxDetIDE>& ides);
80  vector<pair<CRTData, vector<AuxDetIDE>>> CreateData();
81 
82 
83  private:
84 
85  //fhicl configurable vars
86  bool fVerbose;
88  double fGlobalT0Offset; //!< Time delay fit: Gaussian normalization
89  double fTDelayNorm; //!< Time delay fit: Gaussian normalization
90  double fTDelayShift; //!< Time delay fit: Gaussian x shift
91  double fTDelaySigma; //!< Time delay fit: Gaussian width
92  double fTDelayOffset; //!< Time delay fit: Gaussian baseline offset
93  double fTDelayRMSGausNorm; //!< Time delay RMS fit: Gaussian normalization
94  double fTDelayRMSGausShift;//!< Time delay RMS fit: Gaussian x shift
95  double fTDelayRMSGausSigma;//!< Time delay RMS fit: Gaussian width
96  double fTDelayRMSExpNorm; //!< Time delay RMS fit: Exponential normalization
97  double fTDelayRMSExpShift; //!< Time delay RMS fit: Exponential x shift
98  double fTDelayRMSExpScale; //!< Time delay RMS fit: Exponential scale
99  double fQ0; //!< Average energy deposited for mips in 1cm for charge scaling [GeV]
100  double fQPed; //!< ADC offset for the single-peak peak mean [ADC]
101  double fQSlope; //!< Slope in mean ADC / Npe [ADC]
102  double fQRMS; //!< ADC single-pe spectrum width [ADC]
103  uint16_t fQMax; //!< ADC saturation value [ADC]
104  uint16_t fQThresholdC; //!< ADC charge threshold for CERN system [ADC]
105  uint16_t fQThresholdM; //!< ADC charge threshold for MINOS system [ADC]
106  uint16_t fQThresholdD; //!< ADC charge threshold for DC system [ADC]
107  double fTResInterpolator; //!< Interpolator time resolution [ns]
108  double fPropDelay; //!< Delay in pulse arrival time [ns/m]
109  double fPropDelayError; //!< Delay in pulse arrival time, uncertainty [ns/m]
110  double fStripCoincidenceWindow; //!< Time window for two-fiber coincidence [ns]
111  bool fApplyStripCoinC; //!< Whether or not to apply coincence between fibers in a strip (c modules only)
112  bool fApplyCoincidenceC; //!< Whether or not to apply coincidence between hits in adjacent layers
113  bool fApplyCoincidenceM; //!< Whether or not to apply coincidence between hits in adjacent layers
114  bool fApplyCoincidenceD; //!< Whether or not to apply coincidence between hits in adjacent layers
115  double fLayerCoincidenceWindowC; //!< Time window for two layer coincidence in a CERN module [ns]
116  double fLayerCoincidenceWindowM; //!< Time window for two layer coincidence between MINOS modules [ns]
117  double fLayerCoincidenceWindowD; //!< Time window for two layer coincidence in a DC module [ns]
118  bool fUseEdep; //!< Use the true G4 energy deposited, assume mip if false.
119  double fDeadTime; //!< Dead Time inherent in the front-end electronics
120  double fBiasTime; //!< Hard cut off for follow-up hits after primary trigger to bias ADC level
121  bool fUseBirks; //!< Whether or not to apply Birks' quenching to light output
122  double fKbirks; //!< Birks' constant [cm/MeV]
123 
124  //bookkeeping / stats vars
125  int fNsim_m, fNsim_d, fNsim_c; //number of strips in each subsystem with deposited energy
126  int fNchandat_m, fNchandat_d, fNchandat_c; //number of SiPM channel signals above threshold
127  int fNmissthr_c, fNmissthr_d, fNmissthr_m; //number of channel signals below threshold
128  int fNmiss_strcoin_c; //number of channel signals missed due to no fiber-fiber coincidence in a cern strip
129  int fNdual_m; //number of energy deposits producing signals above threshold at both ends of a minos strip
131 
132  map<int,int> fRegCounts;
133  set<int> fRegions;
134 
136  CLHEP::HepRandomEngine& fRandEngine;
137 
138  // A list of hit taggers, before any coincidence requirement (mac5 -> tagger)
139  map<uint8_t, Tagger> fTaggers;
140 
141  pair<double,double> GetTransAtten(const double pos); //only applies to CERN modules
142  double GetLongAtten(const double dist); //MINOS model applied to all modules for now
143 
144  /**
145  * Get the channel trigger time relative to the start of the MC event.
146  *
147  * @param engine The random number generator engine
148  * @param clock The clock to count ticks on
149  * @param t0 The starting time (which delay is added to)
150  * @param npe Number of observed photoelectrons
151  * @param r Distance between the energy deposit and strip readout end [mm]
152  * @return Trigger clock ticks at this true hit time
153  */
155  double t0, float npeMean, float r);
156 
157  CRTData FillCRTData(uint8_t mac, uint32_t entry, uint64_t t0, uint64_t ts1, uint16_t adc[32]);
158  ChanData FillChanData(int channel, uint16_t adc, uint64_t ts);
159  void FillAdcArr(const vector<ChanData>& data, uint16_t arr[32]);
160 };
161 
162 #endif
double fTDelayRMSGausSigma
Time delay RMS fit: Gaussian width.
Functions to help with numbers.
double fTDelayNorm
Time delay fit: Gaussian normalization.
double fLayerCoincidenceWindowM
Time window for two layer coincidence between MINOS modules [ns].
pair< double, double > GetTransAtten(const double pos)
double fLayerCoincidenceWindowC
Time window for two layer coincidence in a CERN module [ns].
bool fApplyCoincidenceM
Whether or not to apply coincidence between hits in adjacent layers.
double fDeadTime
Dead Time inherent in the front-end electronics.
void FillAdcArr(const vector< ChanData > &data, uint16_t arr[32])
vector< pair< ChanData, AuxDetIDE > > data
uint16_t fQThresholdC
ADC charge threshold for CERN system [ADC].
double fStripCoincidenceWindow
Time window for two-fiber coincidence [ns].
uint16_t fQThresholdD
ADC charge threshold for DC system [ADC].
double fQPed
ADC offset for the single-peak peak mean [ADC].
pdgs p
Definition: selectors.fcl:22
uint16_t fQThresholdM
ADC charge threshold for MINOS system [ADC].
double fQ0
Average energy deposited for mips in 1cm for charge scaling [GeV].
double fPropDelayError
Delay in pulse arrival time, uncertainty [ns/m].
ChanData FillChanData(int channel, uint16_t adc, uint64_t ts)
double fTDelayOffset
Time delay fit: Gaussian baseline offset.
double fTResInterpolator
Interpolator time resolution [ns].
double fTDelayRMSExpScale
Time delay RMS fit: Exponential scale.
double fTDelaySigma
Time delay fit: Gaussian width.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
double fBiasTime
Hard cut off for follow-up hits after primary trigger to bias ADC level.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
bool fApplyCoincidenceC
Whether or not to apply coincidence between hits in adjacent layers.
bool fUseBirks
Whether or not to apply Birks&#39; quenching to light output.
vector< pair< CRTData, vector< AuxDetIDE > > > CreateData()
Definition: CRTDetSimAlg.cc:77
CRTDetSimAlg(fhicl::ParameterSet const &p, CLHEP::HepRandomEngine &fRandEngine)
Definition: CRTDetSimAlg.cc:16
art framework interface to geometry description for auxiliary detectors
double fQRMS
ADC single-pe spectrum width [ADC].
double fGlobalT0Offset
Time delay fit: Gaussian normalization.
Single hit (self trigger) of a CRT board.
CRTData FillCRTData(uint8_t mac, uint32_t entry, uint64_t t0, uint64_t ts1, uint16_t adc[32])
double fPropDelay
Delay in pulse arrival time [ns/m].
bool fApplyStripCoinC
Whether or not to apply coincence between fibers in a strip (c modules only)
double fTDelayRMSGausShift
Time delay RMS fit: Gaussian x shift.
double fTDelayShift
Time delay fit: Gaussian x shift.
double fTDelayRMSGausNorm
Time delay RMS fit: Gaussian normalization.
Encapsulate the geometry of an auxiliary detector.
double fTDelayRMSExpShift
Time delay RMS fit: Exponential x shift.
double fTDelayRMSExpNorm
Time delay RMS fit: Exponential normalization.
void FillTaggers(detinfo::DetectorClocksData const &clockData, const uint32_t adid, const uint32_t adsid, const vector< AuxDetIDE > &ides)
Contains all timing reference information for the detector.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
void reconfigure(fhicl::ParameterSet const &p)
Definition: CRTDetSimAlg.cc:30
MC truth information to make RawDigits and do back tracking.
Class def header for a class ElecClock.
double GetLongAtten(const double dist)
bool fUseEdep
Use the true G4 energy deposited, assume mip if false.
Class representing the time measured by an electronics clock.
Definition: ElecClock.h:91
process_name crt
double fLayerCoincidenceWindowD
Time window for two layer coincidence in a DC module [ns].
esac echo uname r
uint64_t GetChannelTriggerTicks(detinfo::ElecClock &clock, double t0, float npeMean, float r)
art framework interface to geometry description
bool fApplyCoincidenceD
Whether or not to apply coincidence between hits in adjacent layers.