MarlinTPC  1.2.0
BiasCalculatorProcessor.h
1 #ifndef BIASCALCULATORPROCESSOR_H
2 #define BIASCALCULATORPROCESSOR_H
3 
4 #include <marlin/Processor.h>
5 #include <lcio.h>
6 #include <EVENT/Track.h>
7 #include <EVENT/TrackerHit.h>
8 
9 #include <TProfile.h>
10 #include <TDirectoryFile.h>
11 #include <TGraphErrors.h>
12 #include <TNtuple.h>
13 
14 namespace marlintpc
15 {
16  /* Processor to output bias data (i.e., residuals as a function of hit-position on pad).
17  *
18  * Parameters:
19  *
20  * TrackInputCollectionName = Input track collection [string]
21  * BiasOutputFileName_RPhi = R-Phi output file name [string]
22  * BiasOutputFileName_Z = Z output file name [string]
23  * RootOutput = Whether or not to save the TProfiles to file [boolean]
24  * SingleTrack = Restrict to single-track events [boolean]
25  * SmallAngle = Restrict to hits with a local track angle between -5 and 5 degrees [boolean]
26  * SeparateDistortions = Whether or not to remove the mean of the bias distributions (i.e., the distortions) [boolean]
27  * RelativeBias = Whether or not to use x_relative (i.e. (x_hit - x_pad) / pad_width ) [boolean]
28  * NPulses = Restrict to hits with this many pulses [integer]
29  *
30  * Author: P. Hayman, Carleton University
31  */
32 
33  class BiasCalculatorProcessor : public marlin::Processor
34  {
35 
36  public:
37 
38  virtual Processor* newProcessor() { return new BiasCalculatorProcessor; }
39 
41 
42  virtual void init();
43 
44  virtual void processRunHeader(lcio::LCRunHeader* run);
45 
46  virtual void processEvent(lcio::LCEvent* evt);
47 
48  virtual void check(lcio::LCEvent* evt);
49 
50  virtual void end();
51 
52  protected:
53  std::string _inputTracks;
54 
55  private:
56 
57  //Class Variables
58  int _nPulses;
59  bool _rootOutput;
60  bool _singleTrack;
61  bool _smallAngle;
62  bool _selectPulses;
63  bool _separateDistortions;
64  bool _relative;
65 
66  TDirectoryFile * _dir_rphi;
67  TDirectoryFile * _dir_z;
68 
69  std::string _biasOutputFileName_rphi;
70  std::string _biasOutputFileName_z;
71  std::map< std::pair<int,int>, TProfile*> _histograms_rphi;
72  std::map< std::pair<int,int>, TProfile*> _histograms_z;
73 
74  TGraphErrors * _rphiGr;
75  TGraphErrors * _zGr;
76  TNtuple * _biasTuple; //This stores some statistical information about the bias
77 
78  //Private Functions
79  std::pair<double, double> calculateBias_rphi(const EVENT::TrackerHit *, const EVENT::Track *);
80  std::pair<double, double> calculateBias_z(const EVENT::TrackerHit *, const EVENT::Track *);
81  void writeBias();
82  void calculateAverageBias();
83  void writeBiasOutput(std::string filename, std::map< std::pair<int,int>, std::pair<double,double> > results);
84 
85  };//End BiasCalculatorProcessor class
86 
87 }//End namespace marlintpc
88 
89 #endif //BIASCALCULATORPROCESSOR_H
std::string _inputTracks
Name of the input track collection.
Definition: BiasCalculatorProcessor.h:53
Definition: BiasCalculatorProcessor.h:33