CMS 3D CMS Logo

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 <array>
24 
25 #include <TString.h>
26 #include <TH1.h>
27 #include <TH2.h>
28 
29 class TH1;
30 class TH2;
31 class TDirectory;
32 class Trajectory;
33 
34 class TrackerTopology;
35 
36 namespace reco {
37  class Track;
38 }
39 
40 class Alignable;
43 
44 /***************************************
45 ****************************************/
46 class MillePedeMonitor {
47 public:
48  // book histograms in constructor
49  MillePedeMonitor(const TrackerTopology *tTopo, const char *rootFile = "trackMonitor.root");
50  MillePedeMonitor(TDirectory *rootDir, const TrackerTopology *tTopo);
51  // writes histograms in destructor
52  ~MillePedeMonitor(); // non-virtual destructor: not intended to be parent class
53 
54  void fillTrack(const reco::Track *track); //, const Trajectory *traj);
55  void fillUsedTrack(const reco::Track *track, unsigned int nHitX, unsigned int nHitY); //, const Trajectory *traj);
58  const float *localDerivs,
59  unsigned int nLocal,
60  const float *globalDerivs,
61  unsigned int nGlobal,
62  const int *labels);
64  const TrajectoryStateOnSurface &tsos,
65  unsigned int nHit,
66  float residuum,
67  float sigma,
68  bool isY);
69  void fillFrameToFrame(const AlignableDetOrUnitPtr &aliDet, const Alignable *ali);
70 
72 
73  void fillPxbSurveyHistsChi2(const float &chi2);
74  void fillPxbSurveyHistsLocalPars(const float &a0, const float &a1, const float &S, const float &phi);
75 
76 private:
77  bool init(TDirectory *directory);
78  bool equidistLogBins(double *bins, int nBins, double first, double last) const;
79  void fillResidualHists(const std::vector<TH1 *> &hists, float phiSensToNorm, float residuum, float sigma);
81  const std::vector<TH1 *> &hists, float angle, float residuum, float sigma, unsigned int nHit);
82  void fillTrack(const reco::Track *track, std::vector<TH1 *> &trackHists1D, std::vector<TH2 *> &trackHists2D);
83 
84  template <class OBJECT_TYPE>
85  int GetIndex(const std::vector<OBJECT_TYPE *> &vec, const TString &name);
86  template <class OBJECT_TYPE>
87  std::vector<OBJECT_TYPE *> cloneHists(const std::vector<OBJECT_TYPE *> &orgs,
88  const TString &namAd,
89  const TString &titAd) const;
90  template <class OBJECT_TYPE>
91  void addToDirectory(const std::vector<OBJECT_TYPE *> &objs, TDirectory *dir) const;
92  template <typename T, size_t SIZE>
93  std::array<int, SIZE> indexArray1D(const std::vector<T *> &hists, const char *title);
94  template <typename T, size_t SIZE>
95  std::array<std::array<int, SIZE>, SIZE> indexArray2D(const std::vector<T *> &hists, const char *title);
96 
97  TDirectory *myRootDir;
98  bool myDeleteDir;
99 
100  std::vector<TH1 *> myTrackHists1D; // all input tracks
101  std::vector<TH2 *> myTrackHists2D;
102  std::vector<TH1 *> myUsedTrackHists1D; // tracks used, i.e. tranferred to pede
103  std::vector<TH2 *> myUsedTrackHists2D;
104  std::vector<TH1 *> myTrajectoryHists1D;
105  std::vector<TH2 *> myTrajectoryHists2D;
106  std::vector<TH2 *> myDerivHists2D;
107  std::vector<TH2 *> myResidHists2D;
108  std::vector<std::vector<TH1 *> > myResidHistsVec1DX;
109  std::vector<std::vector<TH1 *> > myResidHistsVec1DY;
110  std::vector<TH1 *> myResidHitHists1DX;
111  std::vector<TH1 *> myResidHitHists1DY;
112  std::vector<TH2 *> myFrame2FrameHists2D;
113  std::vector<TH1 *> myCorrHists; // correlations
114  std::vector<TH1 *> myPxbSurveyHists; // correlations
115 
117 };
118 
119 template <class OBJECT_TYPE>
120 int MillePedeMonitor::GetIndex(const std::vector<OBJECT_TYPE *> &vec, const TString &name) {
121  int result = 0;
122  for (typename std::vector<OBJECT_TYPE *>::const_iterator iter = vec.begin(), iterEnd = vec.end(); iter != iterEnd;
123  ++iter, ++result) {
124  if (*iter && (*iter)->GetName() == name)
125  return result;
126  }
127  edm::LogError("Alignment") << "@SUB=MillePedeMonitor::GetIndex"
128  << " could not find " << name;
129  return -1;
130 }
131 
132 template <class OBJECT_TYPE>
133 std::vector<OBJECT_TYPE *> MillePedeMonitor::cloneHists(const std::vector<OBJECT_TYPE *> &orgs,
134  const TString &namAd,
135  const TString &titAd) const {
136  // OBJECT_TYPE required to have methods Clone(const char*), GetName(), SetTitle(const char*) and GetTitle()
137  std::vector<OBJECT_TYPE *> result;
138  for (typename std::vector<OBJECT_TYPE *>::const_iterator iter = orgs.begin(), iterEnd = orgs.end(); iter != iterEnd;
139  ++iter) {
140  if (!(*iter))
141  continue;
142  result.push_back(static_cast<OBJECT_TYPE *>((*iter)->Clone(namAd + (*iter)->GetName())));
143  if (result.back())
144  result.back()->SetTitle((*iter)->GetTitle() + titAd);
145  else
146  edm::LogError("Alignment") << "@SUB=MillePedeMonitor::cloneHists"
147  << "out of memory?";
148  }
149 
150  return result;
151 }
152 
153 template <class OBJECT_TYPE>
154 void MillePedeMonitor::addToDirectory(const std::vector<OBJECT_TYPE *> &obs, TDirectory *dir) const {
155  // OBJECT_TYPE is required to have method SetDirectory(TDirectory *dir)
156  for (typename std::vector<OBJECT_TYPE *>::const_iterator iter = obs.begin(), iterEnd = obs.end(); iter != iterEnd;
157  ++iter) {
158  if (*iter)
159  (*iter)->SetDirectory(dir);
160  }
161 }
162 
163 template <typename T, size_t SIZE>
164 std::array<int, SIZE> MillePedeMonitor::indexArray1D(const std::vector<T *> &hists, const char *title) {
165  std::array<int, SIZE> result{};
166  for (size_t i = 0; i < SIZE; ++i) {
167  result[i] = this->GetIndex(hists, Form(title, i));
168  }
169  return result;
170 }
171 
172 template <typename T, size_t SIZE>
173 std::array<std::array<int, SIZE>, SIZE> MillePedeMonitor::indexArray2D(const std::vector<T *> &hists,
174  const char *title) {
175  std::array<std::array<int, SIZE>, SIZE> result{};
176  for (size_t i = 0; i < SIZE; ++i) {
177  for (size_t j = 0; j < SIZE; ++j) {
178  result[i][j] = this->GetIndex(hists, Form(title, i, j));
179  }
180  }
181  return result;
182 }
183 
184 #endif
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
MillePedeMonitor::~MillePedeMonitor
~MillePedeMonitor()
Definition: MillePedeMonitor.cc:65
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
MessageLogger.h
MillePedeMonitor::fillUsedTrack
void fillUsedTrack(const reco::Track *track, unsigned int nHitX, unsigned int nHitY)
Definition: MillePedeMonitor.cc:575
AlgebraicObjects.h
MillePedeMonitor::myTrajectoryHists1D
std::vector< TH1 * > myTrajectoryHists1D
Definition: MillePedeMonitor.h:103
MillePedeMonitor::myRootDir
TDirectory * myRootDir
Definition: MillePedeMonitor.h:96
TrackerTopology
Definition: TrackerTopology.h:16
Alignable
Definition: Alignable.h:27
MillePedeMonitor::fillTrack
void fillTrack(const reco::Track *track)
Definition: MillePedeMonitor.cc:572
MillePedeMonitor::myFrame2FrameHists2D
std::vector< TH2 * > myFrame2FrameHists2D
Definition: MillePedeMonitor.h:111
ntupleEnum.SIZE
SIZE
Definition: ntupleEnum.py:87
MillePedeMonitor::myTrajectoryHists2D
std::vector< TH2 * > myTrajectoryHists2D
Definition: MillePedeMonitor.h:104
MillePedeMonitor::init
bool init(TDirectory *directory)
Definition: MillePedeMonitor.cc:72
TransientTrackingRecHit.h
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
compare.hists
hists
Definition: compare.py:319
MillePedeMonitor::myDeleteDir
bool myDeleteDir
Definition: MillePedeMonitor.h:97
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
MillePedeMonitor::myResidHitHists1DY
std::vector< TH1 * > myResidHitHists1DY
Definition: MillePedeMonitor.h:110
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
MillePedeMonitor::fillResidualHists
void fillResidualHists(const std::vector< TH1 * > &hists, float phiSensToNorm, float residuum, float sigma)
Definition: MillePedeMonitor.cc:998
AlignableDetOrUnitPtr
Definition: AlignableDetOrUnitPtr.h:30
MillePedeMonitor::addToDirectory
void addToDirectory(const std::vector< OBJECT_TYPE * > &objs, TDirectory *dir) const
Definition: MillePedeMonitor.h:153
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
MillePedeMonitor::fillRefTrajectory
void fillRefTrajectory(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr)
Definition: MillePedeMonitor.cc:759
ReferenceTrajectoryBase.h
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
dqmdumpme.last
last
Definition: dqmdumpme.py:56
MillePedeMonitor::indexArray2D
std::array< std::array< int, SIZE >, SIZE > indexArray2D(const std::vector< T * > &hists, const char *title)
Definition: MillePedeMonitor.h:172
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
indexGen.rootFile
rootFile
Definition: indexGen.py:92
MillePedeMonitor::myTrackHists1D
std::vector< TH1 * > myTrackHists1D
Definition: MillePedeMonitor.h:99
reco::Track
Definition: Track.h:27
MillePedeMonitor::equidistLogBins
bool equidistLogBins(double *bins, int nBins, double first, double last) const
Definition: MillePedeMonitor.cc:551
MillePedeMonitor::myResidHistsVec1DY
std::vector< std::vector< TH1 * > > myResidHistsVec1DY
[0]=all [1]=TPB [2]=TPE [3]=TIB [4]=TID [5]=TOB [6]=TEC
Definition: MillePedeMonitor.h:108
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition: seedmultiplicitymonitor_newtracking_cfi.py:8
MillePedeMonitor::GetIndex
int GetIndex(const std::vector< OBJECT_TYPE * > &vec, const TString &name)
Definition: MillePedeMonitor.h:119
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
MillePedeMonitor::fillCorrelations2D
void fillCorrelations2D(float corr, const TransientTrackingRecHit::ConstRecHitPointer &hit)
Definition: MillePedeMonitor.cc:1096
MillePedeMonitor::myUsedTrackHists1D
std::vector< TH1 * > myUsedTrackHists1D
Definition: MillePedeMonitor.h:101
MillePedeMonitor::fillDerivatives
void fillDerivatives(const TransientTrackingRecHit::ConstRecHitPointer &recHit, const float *localDerivs, unsigned int nLocal, const float *globalDerivs, unsigned int nGlobal, const int *labels)
Definition: MillePedeMonitor.cc:881
MillePedeMonitor::myResidHistsVec1DX
std::vector< std::vector< TH1 * > > myResidHistsVec1DX
Definition: MillePedeMonitor.h:107
MillePedeMonitor::fillPxbSurveyHistsLocalPars
void fillPxbSurveyHistsLocalPars(const float &a0, const float &a1, const float &S, const float &phi)
Definition: MillePedeMonitor.cc:1123
MillePedeMonitor::myPxbSurveyHists
std::vector< TH1 * > myPxbSurveyHists
Definition: MillePedeMonitor.h:113
MillePedeMonitor::myCorrHists
std::vector< TH1 * > myCorrHists
Definition: MillePedeMonitor.h:112
MillePedeMonitor::cloneHists
std::vector< OBJECT_TYPE * > cloneHists(const std::vector< OBJECT_TYPE * > &orgs, const TString &namAd, const TString &titAd) const
Definition: MillePedeMonitor.h:132
MillePedeMonitor::fillResidualHitHists
void fillResidualHitHists(const std::vector< TH1 * > &hists, float angle, float residuum, float sigma, unsigned int nHit)
Definition: MillePedeMonitor.cc:1043
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
MillePedeMonitor::myResidHists2D
std::vector< TH2 * > myResidHists2D
Definition: MillePedeMonitor.h:106
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
MillePedeMonitor::fillPxbSurveyHistsChi2
void fillPxbSurveyHistsChi2(const float &chi2)
Definition: MillePedeMonitor.cc:1111
DDAxes::phi
StopReason::SIZE
MillePedeMonitor
Definition: MillePedeMonitor.h:45
MillePedeMonitor::myDerivHists2D
std::vector< TH2 * > myDerivHists2D
Definition: MillePedeMonitor.h:105
MillePedeMonitor::fillResiduals
void fillResiduals(const TransientTrackingRecHit::ConstRecHitPointer &recHit, const TrajectoryStateOnSurface &tsos, unsigned int nHit, float residuum, float sigma, bool isY)
Definition: MillePedeMonitor.cc:920
MillePedeMonitor::fillFrameToFrame
void fillFrameToFrame(const AlignableDetOrUnitPtr &aliDet, const Alignable *ali)
Definition: MillePedeMonitor.cc:1066
Trajectory
Definition: Trajectory.h:38
MillePedeMonitor::MillePedeMonitor
MillePedeMonitor(const TrackerTopology *tTopo, const char *rootFile="trackMonitor.root")
Definition: MillePedeMonitor.cc:45
createBeamHaloJobs.directory
string directory
Definition: createBeamHaloJobs.py:211
MillePedeMonitor::trackerTopology
const TrackerTopology * trackerTopology
Definition: MillePedeMonitor.h:115
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MillePedeMonitor::myTrackHists2D
std::vector< TH2 * > myTrackHists2D
Definition: MillePedeMonitor.h:100
S
Definition: CSCDBL1TPParametersExtended.h:16
HLTEGTnPMonitor_cfi.objs
objs
Definition: HLTEGTnPMonitor_cfi.py:1018
MillePedeMonitor::myResidHitHists1DX
std::vector< TH1 * > myResidHitHists1DX
[0]=all [1]=TPB [2]=TPE [3]=TIB [4]=TID [5]=TOB [6]=TEC
Definition: MillePedeMonitor.h:109
mps_fire.result
result
Definition: mps_fire.py:311
trigObjTnPSource_cfi.bins
bins
Definition: trigObjTnPSource_cfi.py:20
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
a0
static constexpr float a0
Definition: L1EGammaCrystalsEmulatorProducer.cc:82
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeMonitor::indexArray1D
std::array< int, SIZE > indexArray1D(const std::vector< T * > &hists, const char *title)
Definition: MillePedeMonitor.h:163
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
MillePedeMonitor::myUsedTrackHists2D
std::vector< TH2 * > myUsedTrackHists2D
Definition: MillePedeMonitor.h:102