All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
ILDCaloDigi.h
Go to the documentation of this file.
1 #ifndef DIGITIZER_ILDCCALODIGI_H
2 #define DIGITIZER_ILDCCALODIGI_H 1
3 
4 #include "marlin/Processor.h"
5 #include <IMPL/CalorimeterHitImpl.h>
6 #include <IMPL/LCFlagImpl.h>
7 #include "CalorimeterHitType.h"
8 #include "lcio.h"
9 #include <string>
10 #include <vector>
11 #include "TFile.h"
12 #include "TH1.h"
13 #include "TH2.h"
14 #include "ScintillatorPpdDigi.h"
15 #include "CLHEP/Random/MTwistEngine.h"
16 
17 using namespace lcio ;
18 using namespace marlin ;
19 
20 const int MAX_LAYERS = 200;
21 const int MAX_STAVES = 16;
22 
23 /**
24 \addtogroup CaloDigi CaloDigi
25 @{
26 
27 \addtogroup ILDCaloDigi ILDCaloDigi
28 @{
29 Simple calorimeter digitizer Processor.
30 === ILDCaloDigi Processor === <br>
31  * Simple calorimeter digitizer Processor. <br>
32  * Takes SimCalorimeterHit Collections and <br>
33  * produces CalorimeterHit Collections. <br>
34  * Simulated energy depositions in active <br>
35  * layers of calorimeters are <br>
36  * converted into physical energy. This is done <br>
37  * taking into account sampling fractions of <br>
38  * ECAL and HCAL. <br>
39  * User has to specify ECAL and HCAL SimCalorimeterHit <br>
40  * collections with processor parameters <br>
41  * HCALCollections and ECALCollections. <br>
42  * The names of the output CalorimeterHit Collections <br>
43  * are specified with processor parameters <br>
44  * ECALOutputCollection and HCALOutputCollection. <br>
45  * Conversion factors for ECAL and HCAL <br>
46  * are specified via processor parameters <br>
47  * CalibrECAL and CalibrHCAL. <br>
48  * It should be noted that ECAL and HCAL may consist <br>
49  * of several sections with different sampling fractions. <br>
50  * To handle this situation, calibration coefficients for <br>
51  * ECAL and HCAL are passed as arrays of floats with each element <br>
52  * in this array corresponding to certain section with <br>
53  * a given sampling fraction. <br>
54  * List of layer numbers terminating each section are given through <br>
55  * processor parameters ECALLayers and HCALLayers <br>
56  * There is an option to perform digitization of <br>
57  * both ECAL and HCAL in a digital mode. <br>
58  * Digital mode is activated by <br>
59  * setting processor parameters <br>
60  * IfDigitalEcal / IfDigitalHcal to 1. <br>
61  * In this case CalibrECAL / CalibrHCAL will <br>
62  * convert the number of hits into physical energy. <br>
63  * Thresholds on hit energies in ECAL and HCAL <br>
64  * are set with processor parameters <br>
65  * ECALThreshold and HCALThreshold. <br>
66  * Relations between CalorimeterHits and SimCalorimeterHits <br>
67  * are held in the corresponding relation collection. <br>
68  * The name of this relation collection is specified <br>
69  * via processor parameter RelationOutputCollection. <br>
70  * <h4>Input collections and prerequisites</h4>
71  * SimCalorimeterHit collections <br>
72  * <h4>Output</h4>
73  * CalorimeterHit collections for ECal and HCal. <br>
74  * Collection of relations <br>
75  * between CalorimeterHits and SimCalorimeterHits. <br>
76  * For ECal Calorimeter hits the variable type is set to 0, <br>
77  * whereas for HCal Calorimeter hits the type is set to 1 <br>
78  * @author A. Raspereza (DESY) <br>
79  * @author M. Thomson (DESY) <br>
80  * @version $Id$ <br>
81  */
82 class ILDCaloDigi : public Processor {
83 
84  public:
85 
86  ILDCaloDigi(const ILDCaloDigi&) = delete;
87  ILDCaloDigi& operator=(const ILDCaloDigi&) = delete;
88 
89  virtual Processor* newProcessor() { return new ILDCaloDigi ; }
90 
91 
92  ILDCaloDigi() ;
93 
94  virtual void init() ;
95 
96  virtual void processRunHeader( LCRunHeader* run ) ;
97 
98  virtual void processEvent( LCEvent * evt ) ;
99 
100  virtual void check( LCEvent * evt ) ;
101 
102  virtual void end() ;
103 
104  virtual void fillECALGaps() ;
105 
106  float digitalHcalCalibCoeff(CHT::Layout,float energy );
107 
108  float analogueHcalCalibCoeff(CHT::Layout, int layer );
109 
110  float digitalEcalCalibCoeff(int layer );
111 
112  float analogueEcalCalibCoeff(int layer );
113 
114  protected:
115 
116  float ecalEnergyDigi(float energy, int id0, int id1);
117  float ahcalEnergyDigi(float energy, int id0, int id1);
118 
119  float siliconDigi(float energy);
120  float scintillatorDigi(float energy, bool isEcal);
121  LCCollection* combineVirtualStripCells(LCCollection* col, bool isBarrel, int orientation );
122 
123  int getNumberOfVirtualCells();
124  std::vector < std::pair <int, int> > & getLayerConfig();
125  void checkConsistency(std::string colName, int layer);
126  std::pair < int, int > getLayerProperties( std::string colName, int layer );
127  int getStripOrientationFromColName( std::string colName );
128 
129 
130  int _nRun{};
131  int _nEvt{};
132 
133  LCFlagImpl _flag{};
134 
135  std::vector<std::string> _ecalCollections{};
136  std::vector<std::string> _hcalCollections{};
137  std::vector<std::string> _outputEcalCollections{};
138  std::vector<std::string> _outputHcalCollections{};
139 
140  std::string _outputRelCollection{};
141 
142  float _thresholdEcal{};
143  std::string _unitThresholdEcal{};
144  std::vector<float> _thresholdHcal{};
145  std::string _unitThresholdHcal{};
146 
147  int _digitalEcal{};
148  int _mapsEcalCorrection{};
149  int _digitalHcal{};
150 
151  bool _ECAL_stripHits{};
152 
153  std::vector<float> _calibrCoeffEcal{};
154  std::vector<float> _calibrCoeffHcalBarrel{};
155  std::vector<float> _calibrCoeffHcalEndCap{};
156  std::vector<float> _calibrCoeffHcalOther{};
157 
158  std::vector<int> _ecalLayers{};
159  std::vector<int> _hcalLayers{};
160 
161  int _ecalGapCorrection{};
162  float _ecalGapCorrectionFactor{};
163  float _ecalModuleGapCorrectionFactor{};
164  float _ecalEndcapCorrectionFactor{};
165  float _hcalEndcapCorrectionFactor{};
166  int _hcalGapCorrection{};
167  float _hcalModuleGapCorrectionFactor{};
168 
169  std::vector<CalorimeterHitImpl*> _calHitsByStaveLayer[MAX_STAVES][MAX_LAYERS];
170  std::vector<int> _calHitsByStaveLayerModule[MAX_STAVES][MAX_LAYERS];
171 
172  float _zOfEcalEndcap{};
173  float _barrelPixelSizeT[MAX_LAYERS]{};
174  float _barrelPixelSizeZ[MAX_LAYERS]{};
175  float _endcapPixelSizeX[MAX_LAYERS]{};
176  float _endcapPixelSizeY[MAX_LAYERS]{};
177  float _barrelStaveDir[MAX_STAVES][2]{};
178 
179  int _histograms{};
180 
181  // timing
182  int _useEcalTiming{};
183  int _ecalCorrectTimesForPropagation{};
184  float _ecalTimeWindowMin{};
185  float _ecalBarrelTimeWindowMax{};
186  float _ecalEndcapTimeWindowMax{};
187  float _ecalDeltaTimeHitResolution{};
188  float _ecalTimeResolution{};
189  bool _ecalSimpleTimingCut{};
190 
191  int _useHcalTiming{};
192  int _hcalCorrectTimesForPropagation{};
193  float _hcalTimeWindowMin{};
194  float _hcalBarrelTimeWindowMax{};
195  float _hcalEndcapTimeWindowMax{};
196  float _hcalDeltaTimeHitResolution{};
197  float _hcalTimeResolution{};
198  bool _hcalSimpleTimingCut{};
199 
200  ScintillatorPpdDigi* _scEcalDigi{};
201  ScintillatorPpdDigi* _scHcalDigi{};
202 
203 
204  // parameters for extra ECAL digitization effects
205  float _calibEcalMip{}; // MIP calibration factor
206  int _applyEcalDigi{}; // which realistic calib to apply
207  float _ecal_PPD_pe_per_mip{}; // # photoelectrons/MIP for MPPC
208  int _ecal_PPD_n_pixels{}; // # pixels in MPPC
209  float _ehEnergy{}; // energy to create e-h pair in silicon
210  float _ecal_misCalibNpix{}; // miscalibration of # MPPC pixels
211 
212  float _misCalibEcal_uncorrel{}; // general ECAL miscalibration (uncorrelated between channels)
213  bool _misCalibEcal_uncorrel_keep{}; // if true, use the same ECAL cell miscalibs in each event (requires more memory)
214  float _misCalibEcal_correl{}; // general ECAL miscalibration (100% uncorrelated between channels)
215 
216  float _deadCellFractionEcal{}; // fraction of random dead channels
217  bool _deadCellEcal_keep{}; // keep same cells dead between events?
218 
219  float _strip_abs_length{}; // absorption length along strip for non-uniformity modeling
220  float _ecal_pixSpread{}; // relative spread of MPPC pixel signal
221  float _ecal_elec_noise{}; // electronics noise (as fraction of MIP)
222  float _ecalMaxDynMip{}; // electronics dynamic range (in terms of MIPs)
223  int _ecalStrip_default_nVirt{}; // # virtual cells used in Mokka simulation of strips (if available, this is taken from gear file)
224  std::string _ecal_deafult_layer_config{}; // ECAL layer configuration (if available, this is taken from gear file)
225 
226  // parameters for extra AHCAL digitization effects
227  float _calibHcalMip{}; // MIP calibration factor
228  int _applyHcalDigi{}; // which realistic calib to apply
229  float _hcal_PPD_pe_per_mip{}; // # photoelectrons/MIP for MPPC
230  int _hcal_PPD_n_pixels{}; // # pixels in MPPC
231  float _hcal_misCalibNpix{}; // miscalibration of # MPPC pixels
232 
233  float _misCalibHcal_uncorrel{}; // general ECAL miscalibration (uncorrelated between channels)
234  bool _misCalibHcal_uncorrel_keep{}; // if true, use the same AHCAL cell miscalibs in each event (requires more memory)
235  float _misCalibHcal_correl{}; // general ECAL miscalibration (100% uncorrelated between channels)
236 
237  float _deadCellFractionHcal{}; // fraction of random dead channels
238  bool _deadCellHcal_keep{}; // keep same cells dead between events?
239  float _hcal_pixSpread{}; // relative spread of MPPC pixel signal
240  float _hcal_elec_noise{}; // electronics noise (as fraction of MIP)
241  float _hcalMaxDynMip{}; // electronics dynamic range (in terms of MIPs)
242 
243 
244 
245  // internal variables
246  std::vector < std::pair <int, int> > _layerTypes{};
247  int _strip_virt_cells{};
248  int _countWarnings{};
249  std::string _ecalLayout{};
250 
251  float _event_correl_miscalib_ecal{};
252  float _event_correl_miscalib_hcal{};
253 
254  CLHEP::MTwistEngine *_randomEngineDeadCellEcal{};
255  CLHEP::MTwistEngine *_randomEngineDeadCellHcal{};
256 
257  std::map < std::pair <int, int> , float > _ECAL_cell_miscalibs{};
258  std::map < std::pair <int, int> , bool > _ECAL_cell_dead{};
259  std::map < std::pair <int, int> , float > _HCAL_cell_miscalibs{};
260  std::map < std::pair <int, int> , bool > _HCAL_cell_dead{};
261 
262  enum {
266  SIECAL=0,
267  SCECAL
268  };
269 
270  std::string _cellIDLayerString{};
271  std::string _cellIDModuleString{};
272  std::string _cellIDStaveString{};
273  std::string _cellIDIndexIString{};
274  std::string _cellIDIndexJString{};
275 
276  TH1F* fEcal{};
277  TH1F* fHcal{};
278  TH1F* fEcalC{};
279  TH1F* fHcalC{};
280  TH1F* fEcalC1{};
281  TH1F* fHcalC1{};
282  TH1F* fEcalC2{};
283  TH1F* fHcalC2{};
284  TH2F* fHcalCvsE{};
285  TH2F* fHcalLayer1{};
286  TH2F* fHcalLayer11{};
287  TH2F* fHcalLayer21{};
288  TH2F* fHcalLayer31{};
289  TH2F* fHcalLayer41{};
290  TH2F* fHcalLayer51{};
291  TH2F* fHcalLayer61{};
292  TH2F* fHcalLayer71{};
293  TH1F* fHcalRLayer1{};
294  TH1F* fHcalRLayer11{};
295  TH1F* fHcalRLayer21{};
296  TH1F* fHcalRLayer31{};
297  TH1F* fHcalRLayer41{};
298  TH1F* fHcalRLayer51{};
299  TH1F* fHcalRLayer61{};
300  TH1F* fHcalRLayer71{};
301  TH1F* fHcalRLayerNorm{};
302 
303  TH1F* fEcalRLayerNorm{};
304  TH2F* fEcalLayer1{};
305  TH2F* fEcalLayer11{};
306  TH2F* fEcalLayer21{};
307  TH1F* fEcalRLayer1{};
308  TH1F* fEcalRLayer11{};
309  TH1F* fEcalRLayer21{};
310 
311 } ;
312 
313 /**@} @}*/
314 
315 #endif
const int MAX_STAVES
Definition: ILDCaloDigi.h:21
virtual Processor * newProcessor()
Definition: ILDCaloDigi.h:89
const int MAX_LAYERS
Definition: ILDCaloDigi.h:20