test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MillePedeMonitor.h
Go to the documentation of this file.
1 #ifndef MILLEPEDEMONITOR_H
2 #define MILLEPEDEMONITOR_H
3 
13 
15 
17 
19 
21 
22 #include <vector>
23 #include <TString.h>
24 #include <TH1.h>
25 #include <TH2.h>
26 
27 class TH1;
28 class TH2;
29 class TDirectory;
30 class Trajectory;
31 
32 class TrackerTopology;
33 
34 namespace reco {
35  class Track;
36 }
37 
38 class Alignable;
41 
42 /***************************************
43 ****************************************/
45 {
46  public:
47  // book histograms in constructor
48  MillePedeMonitor(const TrackerTopology* tTopo,const char *rootFile = "trackMonitor.root");
49  MillePedeMonitor(TDirectory *rootDir, const TrackerTopology* tTopo);
50  // writes histograms in destructor
51  ~MillePedeMonitor(); // non-virtual destructor: not intended to be parent class
52 
53  void fillTrack(const reco::Track *track);//, const Trajectory *traj);
54  void fillUsedTrack(const reco::Track *track, unsigned int nHitX, unsigned int nHitY);//, const Trajectory *traj);
57  const float *localDerivs, unsigned int nLocal,
58  const float *globalDerivs, unsigned int nGlobal, const int *labels);
60  const TrajectoryStateOnSurface &tsos, unsigned int nHit,
61  float residuum, float sigma, bool isY);
62  void fillFrameToFrame(const AlignableDetOrUnitPtr &aliDet, const Alignable *ali);
63 
65 
66  void fillPxbSurveyHistsChi2(const float &chi2);
67  void fillPxbSurveyHistsLocalPars(const float &a0, const float &a1, const float &S, const float &phi);
68 
69  private:
70  bool init(TDirectory *directory);
71  bool equidistLogBins(double* bins, int nBins, double first, double last) const;
72  void fillResidualHists(const std::vector<TH1*> &hists, float phiSensToNorm,
73  float residuum, float sigma);
74  void fillResidualHitHists(const std::vector<TH1*> &hists, float angle,
75  float residuum, float sigma, unsigned int nHit);
76  void fillTrack(const reco::Track *track, std::vector<TH1*> &trackHists1D,
77  std::vector<TH2*> &trackHists2D);
78 
79  template <class OBJECT_TYPE>
80  int GetIndex(const std::vector<OBJECT_TYPE*> &vec, const TString &name);
81  template <class OBJECT_TYPE>
82  std::vector<OBJECT_TYPE*> cloneHists(const std::vector<OBJECT_TYPE*> &orgs,
83  const TString &namAd, const TString &titAd) const;
84  template <class OBJECT_TYPE>
85  void addToDirectory(const std::vector<OBJECT_TYPE*> &objs, TDirectory *dir) const;
86 
87  TDirectory *myRootDir;
88  bool myDeleteDir;
89 
90  std::vector<TH1*> myTrackHists1D; // all input tracks
91  std::vector<TH2*> myTrackHists2D;
92  std::vector<TH1*> myUsedTrackHists1D; // tracks used, i.e. tranferred to pede
93  std::vector<TH2*> myUsedTrackHists2D;
94  std::vector<TH1*> myTrajectoryHists1D;
95  std::vector<TH2*> myTrajectoryHists2D;
96  std::vector<TH2*> myDerivHists2D;
97  std::vector<TH2*> myResidHists2D;
98  std::vector<std::vector<TH1*> > myResidHistsVec1DX;
99  std::vector<std::vector<TH1*> > myResidHistsVec1DY;
100  std::vector<TH1*> myResidHitHists1DX;
101  std::vector<TH1*> myResidHitHists1DY;
102  std::vector<TH2*> myFrame2FrameHists2D;
103  std::vector<TH1*> myCorrHists; // correlations
104  std::vector<TH1*> myPxbSurveyHists; // correlations
105 
107 };
108 
109 template <class OBJECT_TYPE>
110 int MillePedeMonitor::GetIndex(const std::vector<OBJECT_TYPE*> &vec, const TString &name)
111 {
112  int result = 0;
113  for (typename std::vector<OBJECT_TYPE*>::const_iterator iter = vec.begin(), iterEnd = vec.end();
114  iter != iterEnd; ++iter, ++result) {
115  if (*iter && (*iter)->GetName() == name) return result;
116  }
117  edm::LogError("Alignment") << "@SUB=MillePedeMonitor::GetIndex" << " could not find " << name;
118  return -1;
119 }
120 
121 template <class OBJECT_TYPE>
122 std::vector<OBJECT_TYPE*> MillePedeMonitor::cloneHists(const std::vector<OBJECT_TYPE*> &orgs,
123  const TString &namAd,
124  const TString &titAd) const
125 {
126  // OBJECT_TYPE required to have methods Clone(const char*), GetName(), SetTitle(const char*) and GetTitle()
127  std::vector<OBJECT_TYPE*> result;
128  for (typename std::vector<OBJECT_TYPE*>::const_iterator iter = orgs.begin(), iterEnd = orgs.end();
129  iter != iterEnd; ++iter) {
130  if (!(*iter)) continue;
131  result.push_back(static_cast<OBJECT_TYPE*>((*iter)->Clone(namAd + (*iter)->GetName())));
132  if (result.back()) result.back()->SetTitle((*iter)->GetTitle() + titAd);
133  else edm::LogError("Alignment") <<"@SUB=MillePedeMonitor::cloneHists"
134  << "out of memory?";
135  }
136 
137  return result;
138 }
139 
140 
141 template <class OBJECT_TYPE>
142 void MillePedeMonitor::addToDirectory(const std::vector<OBJECT_TYPE*> &obs,
143  TDirectory *dir) const
144 {
145  // OBJECT_TYPE is required to have method SetDirectory(TDirectory *dir)
146  for (typename std::vector<OBJECT_TYPE*>::const_iterator iter = obs.begin(), iterEnd = obs.end();
147  iter != iterEnd; ++iter) {
148  if (*iter) (*iter)->SetDirectory(dir);
149  }
150 }
151 
152 #endif
std::vector< TH1 * > myTrackHists1D
int GetIndex(const std::vector< OBJECT_TYPE * > &vec, const TString &name)
void fillCorrelations2D(float corr, const TransientTrackingRecHit::ConstRecHitPointer &hit)
std::vector< TH2 * > myDerivHists2D
std::vector< std::vector< TH1 * > > myResidHistsVec1DX
void fillFrameToFrame(const AlignableDetOrUnitPtr &aliDet, const Alignable *ali)
void fillPxbSurveyHistsLocalPars(const float &a0, const float &a1, const float &S, const float &phi)
std::vector< TH1 * > myTrajectoryHists1D
const TrackerTopology * trackerTopology
std::vector< TH1 * > myResidHitHists1DY
std::vector< OBJECT_TYPE * > cloneHists(const std::vector< OBJECT_TYPE * > &orgs, const TString &namAd, const TString &titAd) const
MillePedeMonitor(const TrackerTopology *tTopo, const char *rootFile="trackMonitor.root")
void fillResiduals(const TransientTrackingRecHit::ConstRecHitPointer &recHit, const TrajectoryStateOnSurface &tsos, unsigned int nHit, float residuum, float sigma, bool isY)
void fillPxbSurveyHistsChi2(const float &chi2)
tuple result
Definition: mps_fire.py:83
void addToDirectory(const std::vector< OBJECT_TYPE * > &objs, TDirectory *dir) const
std::vector< TH2 * > myTrackHists2D
std::vector< TH2 * > myResidHists2D
void fillUsedTrack(const reco::Track *track, unsigned int nHitX, unsigned int nHitY)
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
std::vector< TH1 * > myCorrHists
std::vector< TH1 * > myPxbSurveyHists
TDirectory * myRootDir
std::vector< TH1 * > myUsedTrackHists1D
bool init(TDirectory *directory)
JetCorrectorParameters corr
Definition: classes.h:5
std::vector< TH2 * > myTrajectoryHists2D
std::vector< std::vector< TH1 * > > myResidHistsVec1DY
[0]=all [1]=TPB [2]=TPE [3]=TIB [4]=TID [5]=TOB [6]=TEC
bool equidistLogBins(double *bins, int nBins, double first, double last) const
void fillResidualHists(const std::vector< TH1 * > &hists, float phiSensToNorm, float residuum, float sigma)
void fillTrack(const reco::Track *track)
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
std::vector< TH1 * > myResidHitHists1DX
[0]=all [1]=TPB [2]=TPE [3]=TIB [4]=TID [5]=TOB [6]=TEC
std::vector< TH2 * > myUsedTrackHists2D
void fillRefTrajectory(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr)
void fillDerivatives(const TransientTrackingRecHit::ConstRecHitPointer &recHit, const float *localDerivs, unsigned int nLocal, const float *globalDerivs, unsigned int nGlobal, const int *labels)
dbl *** dir
Definition: mlp_gen.cc:35
std::vector< TH2 * > myFrame2FrameHists2D
void fillResidualHitHists(const std::vector< TH1 * > &hists, float angle, float residuum, float sigma, unsigned int nHit)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11