WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimWCDigitizer.hh
Go to the documentation of this file.
1 #ifndef WCSimWCDigitizer_h
2 #define WCSimWCDigitizer_h 1
3 
4 #include "WCSimRootOptions.hh"
6 #include "WCSimWCDAQMessenger.hh"
8 #include "WCSimEnumerations.hh"
9 #include "G4VDigitizerModule.hh"
10 #include "WCSimWCDigi.hh"
11 #include "WCSimWCHit.hh"
12 #include "globals.hh"
13 #include "Randomize.hh"
14 #include <map>
15 #include <vector>
16 #include <limits>
17 
18 
19 // *******************************************
20 // BASE CLASS
21 // *******************************************
22 
23 class WCSimWCDigitizerBase : public G4VDigitizerModule
24 {
25 public:
26 
28  virtual ~WCSimWCDigitizerBase();
29 
30  bool AddNewDigit(int tube, int gate, double digihittime, double peSmeared, std::vector<int> digi_comp);
31  virtual void DigitizeHits(WCSimWCDigitsCollection* WCHCPMT) = 0;
32  void DigitizeGate(WCSimWCDigitsCollection* WCHC,G4int G);
33  void Digitize();
34 
35  //.mac file option setting methods
36  void SetDigitizerDeadTime (int deadtime) { DigitizerDeadTime = deadtime; };
37  void SetDigitizerIntegrationWindow(int inttime ) { DigitizerIntegrationWindow = inttime; };
38  void SetDigitizerTimingPrecision (double precision) { DigitizerTimingPrecision = precision; };
39  void SetDigitizerPEPrecision (double precision) { DigitizerPEPrecision = precision; };
40 
41  double Truncate(double value, double precision) {
42  if(precision < 1E-10) return value;
43  double ratio=value / precision;
44  // Result of cast is undefined if value is outside range of int. Just do nothing in that case.
45  if(ratio>std::numeric_limits<int64_t>::max() || ratio<std::numeric_limits<int64_t>::min() ) return value;
46  return precision * (int64_t)(value / precision);
47  }
48 
51 
52 protected:
53  void ReInitialize() { DigiStoreHitMap.clear(); }
54 
55  G4double peSmeared;
56 
59 
61  std::map<int,int> DigiStoreHitMap;
62 
63  //generic digitizer properties. Defaults set with the GetDefault*() methods. Overidden by .mac options
64  G4String DigitizerClassName;
69 
71 
72  virtual int GetDefaultDeadTime() = 0;
73  virtual int GetDefaultIntegrationWindow() = 0;
74  virtual double GetDefaultTimingPrecision() = 0;
75  virtual double GetDefaultPEPrecision() = 0;
76 
77  void GetVariables();
78 
79  G4String detectorElement;
80 };
81 
82 
83 
84 // *******************************************
85 // DERIVED CLASSES
86 // *******************************************
87 
88 
89 // SKI-based digitizer class
91 {
92 public:
93 
96 
98 
99 private:
100  int GetDefaultDeadTime() { return 0; }
101  int GetDefaultIntegrationWindow() { return 200; }
102  double GetDefaultTimingPrecision() { return 0.4; }
103  double GetDefaultPEPrecision() { return 0; }
104 
105  static void Threshold(double& pe,int& iflag){
106  // CLHEP::HepRandom::setTheSeed(pe+2014);
107  double x = pe+0.1; iflag=0;
108  double thr; double RDUMMY,err;
109  if ( x<1.1) {
110  thr = std::min(1.0,
111  -0.06374+x*(3.748+x*(-63.23+x*(452.0+x*(-1449.0+x*(2513.0
112  +x*(-2529.+x*(1472.0+x*(-452.2+x*(51.34+x*2.370))))))))));
113  } else {
114  thr = 1.0;
115  }
116  RDUMMY = G4UniformRand();
117  if (thr < RDUMMY) {
118  pe = 0.0;
119  iflag = 1;
120  }
121  else {
122  err = G4RandGauss::shoot(0.0,0.03);
124  pe = pe+err;
125  }
126  }
127 };
128 
129 
130 #endif //WCSimWCDigitizer_h
WCSimDetectorConstruction * myDetector
Get the geometry information.
WCSimWCDAQMessenger * DAQMessenger
Get the /DAQ/ .mac options.
double DigitizerPEPrecision
Digitizer charge precision (p.e.)
double Truncate(double value, double precision)
Override the default digitizer charge resolution (p.e.)
DigitizerType_t DigitizerType
Enumeration to say which digitizer we&#39;ve constructed.
virtual double GetDefaultPEPrecision()=0
Set the default digitizer-specific charge resolution (in p.e.) (overridden by .mac) ...
double GetDefaultTimingPrecision()
SKI digitizer timing precision is 0.4 ns (SK NIM Sec 5.1)
static void Threshold(double &pe, int &iflag)
WCSimWCDigitizerBase(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, DigitizerType_t, G4String detectorElement)
void DigitizeGate(WCSimWCDigitsCollection *WCHC, G4int G)
virtual int GetDefaultIntegrationWindow()=0
Set the default digitizer-specific integration window (in ns) (overridden by .mac) ...
int GetDefaultDeadTime()
SKI digitizer deadtime is 0 ns.
bool AddNewDigit(int tube, int gate, double digihittime, double peSmeared, std::vector< int > digi_comp)
WCSimWCDigitsCollection * DigiStore
G4TDigiCollection< WCSimWCDigi > WCSimWCDigitsCollection
Definition: WCSimWCDigi.hh:214
enum EDigitizerType DigitizerType_t
void SetDigitizerPEPrecision(double precision)
Override the default digitizer timing resolution (ns)
virtual double GetDefaultTimingPrecision()=0
Set the default digitizer-specific timing resolution (in ns) (overridden by .mac) ...
double DigitizerTimingPrecision
Digitizer time precision (ns)
double GetDefaultPEPrecision()
SKI digitizer charge precision is 0.2 pC (SK NIM Sec 5.1), but conversion to PE not specified...
virtual int GetDefaultDeadTime()=0
Set the default digitizer-specific deadtime (in ns) (overridden by .mac)
std::map< int, int > DigiStoreHitMap
Used to check if a digit has already been created on a PMT.
int DigitizerIntegrationWindow
Digitizer integration window (ns)
void SaveOptionsToOutput(WCSimRootOptions *wcopt)
Save current values of options.
int DigitizerDeadTime
Digitizer deadtime (ns)
void SetDigitizerIntegrationWindow(int inttime)
Override the default digitizer deadtime (ns)
void GetVariables()
Get the default deadtime, etc. from the derived class, and override with read from the ...
void SetDigitizerTimingPrecision(double precision)
Override the default digitizer integration window (ns)
G4String DigitizerClassName
Name of the digitizer class being run.
virtual void DigitizeHits(WCSimWCDigitsCollection *WCHCPMT)=0
WCSimWCDigitizerSKI(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, G4String detectorElement)
int GetDefaultIntegrationWindow()
Set the default digitizer-specific integration window (in ns) (overridden by .mac) ...
void DigitizeHits(WCSimWCDigitsCollection *WCHCPMT)
void SetDigitizerDeadTime(int deadtime)