All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Compute_dEdxProcessor.hh
Go to the documentation of this file.
1 #ifndef Compute_dEdxProcessor_hh
2 #define Compute_dEdxProcessor_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 Processor <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  * <h4>Output</h4>
25  * The calculated dE/dx is attached to the track.<br>
26  * This is only possible if the the track collection allows write access.<br>
27  * Bethe-Bloch histograms (root TH2D) can be generated for every dx strategy.<br>
28  * Both outputs are optional.<br>
29  * @param _LDCTrackCollection - name of the input track collection <br>
30  * default: MarlinTrkTracks
31  * @param _writedEdx - flag indicating if calculated dE/dx should be attached to track<br>
32  * If fully reconstructed tracks are used as input collection this can be switched off to only generate histograms.<br>
33  * default: true<br>
34  * @param _energyLossErrorTPC - the dE/dx resolution<br>
35  * default: 0.054 (5.4%)<br>
36  * @param _lowerTrunFrac - lower truncation fraction for truncated-mean method<br>
37  * The hits with the lowest <_lowerTrunFrac> dE/dx values are rejected.<br>
38  * default: 0.08 (8%; ALEPH: 8%)<br>
39  * @param _upperTrunFrac - upper truncation fraction for truncated-mean method<br>
40  * The hits with the highest <_upperTrunFrac> dE/dx values are rejected.<br>
41  * default: 0.3 (30%; ALEPH: 40%)<br>
42  * @param _isSmearing - flag indicating if additional smearing should be applied<br>
43  * This compensates for a 'too good' processor outcome, compared to test beam results.<br>
44  * default: false<br>
45  * @param _smearingFactor - width of the Gaussian function used for the additional smearing<br>
46  * default: 0.035 (3.5%)<br>
47  * @param _ncorrpar - parameter for number-of-hits correction<br>
48  * default: 1.468<br>
49  * @param _acorrpar - parameters for angular correction<br>
50  * default: {0.635762, -0.0573237}<br>
51  * @param _errexp - scaling exponents of the dE/dx error for path length and number of hits, respectively<br>
52  * default: {-0.34, -0.45}<br>
53  * @param _dxStrategy - ID specifying which strategy for calculating dx should be used<br>
54  * Strategy 1: hit-to-hit distance<br>
55  * Strategy 2: hit-to-hit path length of projected hits (do not use at the moment)<br>
56  * Strategy 3: path over hit row<br>
57  * default: 1<br>
58  * If none of the above is chosen, the processor defaults to 1.<br>
59  * @param _StratCompHist - flag indicating if Bethe-Bloch histograms for each dx strategy should created.<br>
60  * default: false<br>
61  * @param _StratCompHistWeight - flag indicating if Bethe-Bloch histograms (if chosen) should be filled with a sqrt(number-of-track-hits) weighting.<br>
62  * default: false (-> weight for each track = 1)<br>
63  * @param _StratCompHistFiles - file names of the generated dx strategy comparison histograms (if chosen).<br>
64  * The respective strategy number and '.png' is added.<br>
65  * default: dEdx_Histo_Strategy (-> "dEdx_Histo_Strategy1.png", etc.)<br>
66  * @author M. Kurata, KEK
67  * adapted by U. Einhaus, DESY
68  * @version $Id$
69  */
70 
71 class Compute_dEdxProcessor : public Processor{
72 public:
73  virtual Processor* newProcessor() { return new Compute_dEdxProcessor ; }
75  virtual void init() ;
76  virtual void processRunHeader( LCRunHeader* run);
77  virtual void processEvent( LCEvent * evt );
78  virtual void check( LCEvent * evt );
79  virtual void end();
80 
81 private:
83  Compute_dEdxProcessor& operator=(const Compute_dEdxProcessor&) = delete;
84 
85  std::pair<double,double> CalculateEnergyLoss(TrackerHitVec& hitVec, Track* trk);
86  double getNormalization(double dedx, float hit, double trkcos);
87  double getSmearing(double dEdx);
88 
89 
90  std::string _description = "";
91  std::string _LDCTrackCollection = "";
92  LCCollection* _LDCCol = NULL;
93  bool _writedEdx = true;
94 
95  float _energyLossErrorTPC = 0;
96  float _lowerTrunFrac = 0;
97  float _upperTrunFrac = 0;
98  float _ncorrpar = 0;
99  std::vector<float> _acorrpar = {};
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 
125 #endif
virtual Processor * newProcessor()
Compute dE/dx Processor This processor calculates the dE/dx for every track.