All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Compute_dEdxProcessor2021.hh
Go to the documentation of this file.
1 #ifndef Compute_dEdxProcessor2021_hh
2 #define Compute_dEdxProcessor2021_hh 1
3 
4 
5 #include <string>
6 #include <vector>
7 #include <random>
8 #include <marlin/Processor.h>
9 #include <EVENT/LCCollection.h>
10 #include <TH2.h>
11 
12 using namespace lcio ;
13 using namespace marlin ;
14 
15 /** Compute dE/dx Processor2021 <br>
16  * This processor calculates the dE/dx for every track.<br>
17  * <h4>Input collections and prerequisites</h4>
18  * The processor requires a collection of tracks that contains the corresponding track hits.<br>
19  * Every track hit that lies within the boundaries of the TPC is used.<br>
20  * dE is the deposited energy of the hit.<br>
21  * dx is the distance between the hits and can be calculated in 3 different ways.<br>
22  * A truncation of the hits with the lowest and highest dE7Dx values is performed.<br>
23  * Then the mean is calculated (truncation-mean method).<br>
24  * The dEdx is smeared according to test beam results .<br>
25  * Finally, the dEdx is corrected for angular effects (in the previous versions of this processor, before 2021, this was performed before smearing..<br>
26  * <h4>Output</h4>
27  * The calculated dE/dx is attached to the track.<br>
28  * This is only possible if the the track collection allows write access.<br>
29  * Bethe-Bloch histograms (root TH2D) can be generated for every dx strategy.<br>
30  * Both outputs are optional.<br>
31  * @param _LDCTrackCollection - name of the input track collection <br>
32  * default: MarlinTrkTracks
33  * @param _writedEdx - flag indicating if calculated dE/dx should be attached to track<br>
34  * If fully reconstructed tracks are used as input collection this can be switched off to only generate histograms.<br>
35  * default: true<br>
36  * @param _energyLossErrorTPC - the dE/dx resolution<br>
37  * default: 0.054 (5.4%)<br>
38  * @param _lowerTrunFrac - lower truncation fraction for truncated-mean method<br>
39  * The hits with the lowest <_lowerTrunFrac> dE/dx values are rejected.<br>
40  * default: 0.08 (8%; ALEPH: 8%)<br>
41  * @param _upperTrunFrac - upper truncation fraction for truncated-mean method<br>
42  * The hits with the highest <_upperTrunFrac> dE/dx values are rejected.<br>
43  * default: 0.3 (30%; ALEPH: 40%)<br>
44  * @param _isSmearing - flag indicating if additional smearing should be applied<br>
45  * This compensates for a 'too good' processor outcome, compared to test beam results.<br>
46  * default: false<br>
47  * @param _smearingFactor - width of the Gaussian function used for the additional smearing<br>
48  * default: 0.035 (3.5%)<br>
49  * @param _errexp - scaling exponents of the dE/dx error for path length and number of hits, respectively<br>
50  * default: {-0.34, -0.45}<br>
51  * @param _dxStrategy - ID specifying which strategy for calculating dx should be used<br>
52  * Strategy 1: hit-to-hit distance<br>
53  * Strategy 2: hit-to-hit path length of projected hits (do not use at the moment)<br>
54  * Strategy 3: path over hit row<br>
55  * default: 1<br>
56  * If none of the above is chosen, the processor defaults to 1.<br>
57  * @param _StratCompHist - flag indicating if Bethe-Bloch histograms for each dx strategy should created.<br>
58  * default: false<br>
59  * @param _StratCompHistWeight - flag indicating if Bethe-Bloch histograms (if chosen) should be filled with a sqrt(number-of-track-hits) weighting.<br>
60  * default: false (-> weight for each track = 1)<br>
61  * @param _StratCompHistFiles - file names of the generated dx strategy comparison histograms (if chosen).<br>
62  * The respective strategy number and '.png' is added.<br>
63  * default: dEdx_Histo_Strategy (-> "dEdx_Histo_Strategy1.png", etc.)<br>
64  * @param _angularcorrdEdx - flag indicating if the dEdx will be corrected for angular correction
65  * default=true
66  * @param _par{} - floats indication the parametrization of the correction: f3 = 1 / (_par[0] + _par[1] * lambda + _par[2] * pow(lambda,2) + _par[3] * pow(lambda,3) )
67  * @author M. Kurata, KEK
68  * adapted by U. Einhaus, DESY
69  * readapted by A. Irles, IFIC
70  * @version $Id$
71  */
72 
73 class Compute_dEdxProcessor2021 : public Processor{
74 public:
75  virtual Processor* newProcessor() { return new Compute_dEdxProcessor2021 ; }
77  virtual void init() ;
78  virtual void processRunHeader( LCRunHeader* run);
79  virtual void processEvent( LCEvent * evt );
80  virtual void check( LCEvent * evt );
81  virtual void end();
82 
83 private:
85  Compute_dEdxProcessor2021& operator=(const Compute_dEdxProcessor2021&) = delete;
86 
87  std::pair<double,double> CalculateEnergyLoss(TrackerHitVec& hitVec, Track* trk);
88  // double getNormalization(double dedx, float hit, double trkcos);
89  double getSmearing(double dEdx);
90 
91 
92  std::string _description = "";
93  std::string _LDCTrackCollection = "";
94  LCCollection* _LDCCol = NULL;
95  bool _writedEdx = true;
96 
97  float _energyLossErrorTPC = 0;
98  float _lowerTrunFrac = 0;
99  float _upperTrunFrac = 0;
100  std::vector<float> _errexp = {};
101  int _dxStrategy = 0;
102  bool _StratCompHist = false;
103  bool _StratCompHistWeight = false;
104  std::string _StratCompHistFiles = "";
105 
106  // smearing
107  std::random_device seed_gen{};
108  std::default_random_engine *engine = NULL;
109  std::uniform_real_distribution<> dist{};
110  bool _isSmearing = 0;
111  float _smearingFactor = 0;
112 
113  // geometry
114  float _TPC_inner = 0;
115  float _TPC_outer = 0;
116  float _TPC_padHeight = 0;
117  float _bField = 0;
118 
119  // root histograms for dx strategy comparison
120  TH2* _BBHist_Strategy1{};
121  TH2* _BBHist_Strategy2{};
122  TH2* _BBHist_Strategy3{};
123 
124  // angular correction
125  bool _angularcorrdEdx = false;
126  std::vector<float> _par{};
127  double get_Corrected_dEdx(float dedx, float trklambda);
128 };
129 
130 #endif
Compute dE/dx Processor2021 This processor calculates the dE/dx for every track.