All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
SiTracker_dEdxProcessor.h
Go to the documentation of this file.
1 #ifndef SiTracker_dEdxProcessor_h
2 #define SiTracker_dEdxProcessor_h 1
3 
4 #include <string>
5 #include <chrono>
6 
7 #include "marlin/Processor.h"
8 #include "MarlinTrk/Factory.h"
9 
10 #include "lcio.h"
11 #include <TTree.h>
12 #include <TFile.h>
13 
14 #include <DDRec/SurfaceManager.h>
15 #include <DDRec/DetectorData.h>
16 #include <LayerFinder.h>
17 
18 using namespace lcio ;
19 using namespace marlin ;
20 
21 
22 
23 /** SiTracker_dEdxProcessor for Marlin.
24  *
25  * Calculates dEdx for planar silicon trackers and stores the information
26  * with the tracks in the lcio file.
27  *
28  * S. Lukic, Vinca, Belgrade
29  * Dec 2016 - Jan 2018
30  */
31 
32 
33 struct dEdxPoint{
34 public:
35  dEdxPoint(const double _dE, const double _dx);
36  dEdxPoint(const dEdxPoint&);
37 
38  double Get_dE() const { return dE; }
39  double Get_dx() const { return dx; }
40  double Get_dEdx() const { return dEdx; }
41 
42 private:
43  double dE;
44  double dx;
45  double dEdx;
46 } ;
47 
48 
49 class SiTracker_dEdxProcessor : public Processor {
50 
51  public:
52  virtual Processor* newProcessor() { return new SiTracker_dEdxProcessor ; }
53 
56 
57  virtual ~SiTracker_dEdxProcessor() ;
58 
59  SiTracker_dEdxProcessor & operator = (const SiTracker_dEdxProcessor &) = delete;
60 
61  /** Called at the begin of the job before anything is read.
62  * Use to initialize the processor, e.g. book histograms.
63  */
64  virtual void init() ;
65 
66  /** Called at the end of every run.
67  */
68  virtual void processRunHeader( LCRunHeader* run ) ;
69 
70  /** Called for every event - the working horse.
71  */
72  virtual void processEvent( LCEvent * evt ) ;
73 
74  virtual void check( LCEvent * evt ) ;
75 
76  /** Called after data processing for clean up.
77  */
78  virtual void end() ;
79 
80  // Evaluation methods for dE/dx
81  typedef std::vector<dEdxPoint> dEdxVec;
82  static bool dEdxOrder(dEdxPoint p1, dEdxPoint p2) { return p1.Get_dEdx() < p2.Get_dEdx() ; }
83  static double truncFractionUp;
84  static double truncFractionLo;
85  static double dEdxGeneralTruncMean(dEdxVec, double &dEdxError,
86  const double truncLo=0,
87  const double truncHi=0);
88  static double dEdxMean(dEdxVec, double &dEdxError);
89  static double dEdxMedian(dEdxVec, double &dEdxError);
90  static double dEdxTruncMean(dEdxVec, double &dEdxError);
91  static double dEdxHarmonic(dEdxVec, double &dEdxError);
92  static double dEdxHarmonic2(dEdxVec, double &dEdxError);
93  static double dEdxWgtHarmonic(dEdxVec, double &dEdxError);
94  static double dEdxWgtHarmonic2(dEdxVec, double &dEdxError);
95 
96 
97  typedef double (*evalChoice)(dEdxVec, double &dEdxError);
98 
99  protected:
100 
101  evalChoice dEdxEval{};
102 
103  /*** Steerable parameters ***/
104  // Name of the track collection
105  std::string m_trackCollName{};
106  /* Tracker hit collection names.
107  * Must be in the same order as tracker detector elements in LCDD.
108  * (Check the order of tracker hit collections in the input LCIO file.)
109  */
110  StringVec m_trkHitCollNames{};
111 
112  // Shall we cheat the sensitive thicknesses?
113  bool m_cheatSensorThicknesses{};
114  // Cheat values for sensitive thicknesses. Default = -1. (no cheating)
115  FloatVec m_sensThicknessCheatVals{};
116 
117  // Choice of estimator for dEdx
118  std::string m_dEdxEstimator{};
119 
120  /*** Detector-related objects ***/
121  const dd4hep::rec::SurfaceMap *surfMap;
122  MarlinTrk::IMarlinTrkSystem *trkSystem;
123 
124  double _bField{};
125 
126  LayerFinder *layerFinder{};
127 
128  int lastRunHeaderProcessed{};
129 
130  unsigned nTimers = 8;
131  std::vector<std::chrono::duration<double>> timers;
132  std::chrono::high_resolution_clock::time_point lastTP;
133  std::chrono::high_resolution_clock::time_point newTP;
134  void addTime(int i) {
135  newTP = std::chrono::high_resolution_clock::now();
136  timers.at(i) += std::chrono::duration_cast<std::chrono::duration<double>>(newTP - lastTP);
137  lastTP = newTP;
138  }
139 
140 } ;
141 
142 #endif
143 
144 
145 
const dd4hep::rec::SurfaceMap * surfMap
std::chrono::high_resolution_clock::time_point newTP
virtual Processor * newProcessor()
double Get_dx() const
std::vector< std::chrono::duration< double > > timers
double Get_dEdx() const
MarlinTrk::IMarlinTrkSystem * trkSystem
SiTracker_dEdxProcessor for Marlin.
std::vector< dEdxPoint > dEdxVec
double Get_dE() const
std::chrono::high_resolution_clock::time_point lastTP
static bool dEdxOrder(dEdxPoint p1, dEdxPoint p2)
std::vector< std::string > StringVec
Definition: SiStripClus.h:56