MarlinTPC  1.2.0
MMScatterProcessor.h
1 #ifndef MMSCATTERPROCESSOR_H
2 #define MMSCATTERPROCESSOR_H
3 
4 #include <marlin/Processor.h>
5 #include <lcio.h>
6 #include <string>
7 #include <map>
8 #include <vector>
9 
10 #include "MMPadResponseFunction.h"
11 
12 //LCIO
13 #include "lcio.h"
14 #include "EVENT/LCCollection.h"
15 #include "IMPL/LCCollectionVec.h"
16 #include "EVENT/TrackerPulse.h"
17 
18 //Aida
19 #include <AIDA/AIDA.h>
20 #include <marlin/AIDAProcessor.h>
21 #include <AIDA/ITupleFactory.h>
22 #include <AIDA/ITuple.h>
23 #include <AIDA/IHistogramFactory.h>
24 #include <AIDA/IHistogram1D.h>
25 #include <AIDA/IHistogram2D.h>
26 
27 //LCIO
28 #include <EVENT/LCFloatVec.h>
29 #include <IMPL/TrackerDataImpl.h>
30 #include <IMPL/TrackerPulseImpl.h>
31 #include <IMPL/TrackerHitImpl.h>
32 #include <IMPL/TrackImpl.h>
33 
34 // GEAR
35 #include <gear/TPCParameters.h>
36 #include <gear/TPCModule.h>
37 #include <gearimpl/GlobalPadIndex.h>
38 
39 //MARLIN
40 #include <marlin/Global.h>
41 
42 //ROOT
43 #include <Minuit2/MnUserParameters.h>
44 #include <Minuit2/MnMigrad.h>
45 #include <Minuit2/FunctionMinimum.h>
46 #include <Minuit2/Minuit2Minimizer.h>
47 
48 #include "Math/Minimizer.h"
49 #include "Math/Functor.h"
50 #include <TMath.h>
51 #include <TTree.h>
52 #include <TH1.h>
53 #include <TF1.h>
54 
55 
56 
57 namespace marlintpc
58 {
90  class MMScatterProcessor : public marlin::Processor
91  {
92  public:
93 
94  //Mid-calibration parameters for use by the MMHitFinderProcessor
95  static std::vector<double> CALIB_PARAMS;
96 
97  virtual Processor* newProcessor() { return new MMScatterProcessor; }
98 
100 
101  virtual void init();
102 
103  virtual void processRunHeader(EVENT::LCRunHeader* run);
104 
105  virtual void processEvent(EVENT::LCEvent* evt);
106 
107  virtual void check(EVENT::LCEvent* evt);
108 
109  virtual void end();
110 
111  static std::pair<double, double> calculateTrackPosition ( const gear::TPCParameters&, const IMPL::TrackImpl*, int mod, int row );
112  static std::pair<double, double> calculateTrackPosition ( const gear::TPCParameters&, double d0, double phi0, double omega, const float * ref, int mod, int row );
113  static std::pair<double, double> calculateStraightTrackPosition ( const gear::TPCParameters&, double d0, double phi0, const float * ref, int mod, int row );
114 
115  protected:
116  typedef std::map<int, std::map<int, std::vector<TrackerPulse*> > > SortedPulseMap;
117  typedef std::map<std::pair<int, int>, std::vector<std::pair<double, float> > > PointsMap;
118 
119  lcio::StringVec _inputColNames; // Name of the input collection
120  bool _fitPRF; //Choose whether or not to fit the PRF to the scatter-plot
121  bool _rowDep; //Choose whether or not to store the scatter-plot for each row
122  bool _moduleDep; //Choose whether or not to store the scatter-plot for each row
123  bool _singleTrack;
124  bool _smallAngle;
125  bool _profile;
126  int _curEvt; //Keep track of the current event.
127  int _normType;
128  int _nPar;
129  double * _parArray;
130  std::string _output_path;
131  std::string _prfType;
132  std::vector<float> _parVec;
133  std::vector<int> _moduleList;
134  std::map<int, int> _moduleMap;
135  PointsMap _scatterMap;
136 
137  std::vector<std::vector<double> > _iterationPar; //Store the fit parameters for each run
138  std::vector<double> _iterationNumbers; //Store the iteration numbers
139  int _nEvt;
140  int _nIterations;
141  int _calibIter;
142  bool _calibRun;
143  bool _calibPad;
144 
145  //A Histogram to hold the collective scatterplot.
146  std::map<std::pair<int,int>, TH1*> _scatterPlots;
147 
148  //Histograms and a tuple to hold the result of fitting the PRF
149  AIDA::ITuple* fitData;
150 
151  /************************************************************************************************/
152  // helper functions:
153 
154  // Sorts pulses into collection corresponding to modules and rows.
155  // i.e a pulse on row 5 of module 1 is put in the same container as the other pulses
156  // from that row and module.
157  void _sortPulses ( const EVENT::TrackerHitVec&, const gear::TPCParameters&, SortedPulseMap& );
158 
159  // Fills the data points
160  void _fillData ( const SortedPulseMap&, const gear::TPCParameters&, const IMPL::TrackImpl*, PointsMap& );
161 
162  void calibrate();
163 
164  //Make a small, private class to use to fit the PRF to the scatter plots
165  class PRFFcn
166  {
167 
168  public:
169 
170  PRFFcn(std::string prfType, int nPar)
171  {
172  _prf = MMPadResponseFunction(prfType);
173  _nPar = nPar;
174  }
175 
176  double operator()(const double * x, const double * par) const
177  {
178 
179  return par[_nPar]*_prf.prf(x[0] - par[_nPar+1], par);
180  }
181 
182  private:
184  int _nPar;
185  };
186 
187  };//End MMScatterProcessor class
188 
189 }//End namespace marlintpc
190 
191 #endif // MMSCATTERPROCESSOR_H
virtual void init()
Definition: MMScatterProcessor.cc:125
void _sortPulses(const EVENT::TrackerHitVec &, const gear::TPCParameters &, SortedPulseMap &)
Definition: MMScatterProcessor.cc:595
Definition: MMPadResponseFunction.h:18
Definition: MMScatterProcessor.h:165
Basic overview:
Definition: MMScatterProcessor.h:90