CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackIPHistograms.h
Go to the documentation of this file.
1 #ifndef DQMOffline_RecoB_TrackIPHistograms_h
2 #define DQMOffline_RecoB_TrackIPHistograms_h
3 
4 #include <string>
5 
8 
9 template<class T>
11 {
12  public:
13 
14  TrackIPHistograms(const std::string& baseNameTitle_ , const std::string& baseNameDescription_,
15  const int& nBins_, const double& lowerBound_, const double& upperBound_,
16  const bool& statistics, const bool& plotLog_, const bool& plotNormalized_,
17  const std::string& plotFirst_, const bool& update, const std::string& folder, const unsigned int& mc, const bool& quality);
18 
19  virtual ~TrackIPHistograms(){};
20 
21  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack) const;
22  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack, const T & w) const;
23 
24  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack) const;
25  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack, const T & w) const;
26 
27  void settitle(const char* title);
28 
29  protected:
30 
31  void fillVariable ( const reco::TrackBase::TrackQuality& qual, const T & var, const bool& hasTrack) const;
32  void fillVariable ( const reco::TrackBase::TrackQuality& qual, const T & var, const bool& hasTrack, const T & w) const;
33 
34  bool quality_;
35 
40 
41  private:
43 };
44 
45 template <class T>
46 TrackIPHistograms<T>::TrackIPHistograms (const std::string& baseNameTitle_, const std::string& baseNameDescription_,
47  const int& nBins_, const double& lowerBound_, const double& upperBound_,
48  const bool& statistics_, const bool& plotLog_, const bool& plotNormalized_,
49  const std::string& plotFirst_, const bool& update, const std::string& folder, const unsigned int& mc, const bool& quality) :
50  FlavourHistograms<T>(baseNameTitle_, baseNameDescription_, nBins_, lowerBound_, upperBound_, statistics_, plotLog_, plotNormalized_,
51  plotFirst_, update, folder, mc), quality_(quality)
52 {
53  if(quality_) {
54  if(!update) {
55  HistoProviderDQM prov("Btag",folder);
56  theQual_undefined = prov.book1D( baseNameTitle_ + "QualUnDef" , baseNameDescription_ + " Undefined Quality", nBins_, lowerBound_, upperBound_);
57  theQual_loose = prov.book1D( baseNameTitle_ + "QualLoose" , baseNameDescription_ + " Loose Quality", nBins_, lowerBound_, upperBound_);
58  theQual_tight = prov.book1D( baseNameTitle_ + "QualTight" , baseNameDescription_ + " Tight Quality", nBins_, lowerBound_, upperBound_);
59  theQual_highpur = prov.book1D( baseNameTitle_ + "QualHighPur" , baseNameDescription_ + " High Purity Quality", nBins_, lowerBound_, upperBound_);
60 
61  if( statistics_ ) {
62  theQual_undefined->getTH1F()->Sumw2();
63  theQual_loose->getTH1F()->Sumw2();
64  theQual_tight->getTH1F()->Sumw2();
65  theQual_highpur->getTH1F()->Sumw2();
66  }
67  } else {
68  HistoProviderDQM prov("Btag",folder);
69  theQual_undefined = prov.access(baseNameTitle_ + "QualUnDef");
70  theQual_loose = prov.access(baseNameTitle_ + "QualLoose");
71  theQual_tight = prov.access(baseNameTitle_ + "QualTight");
72  theQual_highpur = prov.access(baseNameTitle_ + "QualHighPur");
73  }
74  }
75 }
76 
77 template <class T>
78 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack) const
79 {
80  FlavourHistograms<T>::fill(flavour, variable);
81  if(quality_)
82  fillVariable(quality, variable, hasTrack);
83 }
84 
85 template <class T>
86 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack, const T & w) const
87 {
88  FlavourHistograms<T>::fill(flavour, variable , w);
89  if(quality_)
90  fillVariable(quality, variable, hasTrack, w);
91 }
92 
93 template <class T>
94 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack) const
95 {
96  const int* theArrayDimension = FlavourHistograms<T>::arrayDimension();
97  const int& theMaxDimension = FlavourHistograms<T>::maxDimension();
98  const int& theIndexToPlot = FlavourHistograms<T>::indexToPlot();
99 
100  FlavourHistograms<T>::fill(flavour, variable);
101  if( theArrayDimension == 0 && quality_) {
102  fillVariable( quality, *variable);
103  } else {
104  int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
105  for(int i = 0; i != iMax; ++i) {
106  if( quality_ && (( theIndexToPlot < 0) || ( i == theIndexToPlot)) ) {
107  fillVariable ( flavour , *(variable + i), hasTrack);
108  }
109  }
110 
111  if(theIndexToPlot >= iMax && quality_) {
112  const T& theZero = static_cast<T> (0.0);
113  fillVariable ( quality, theZero, hasTrack);
114  }
115  }
116 }
117 
118 template <class T>
119 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack, const T & w) const
120 {
121  const int* theArrayDimension = FlavourHistograms<T>::arrayDimension();
122  const int& theMaxDimension = FlavourHistograms<T>::maxDimension();
123  const int& theIndexToPlot = FlavourHistograms<T>::indexToPlot();
124 
125  FlavourHistograms<T>::fill(flavour, variable ,w);
126  if( theArrayDimension == 0 && quality_) {
127  fillVariable( quality, *variable,w);
128  } else {
129  int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
130  for(int i = 0; i != iMax; ++i) {
131  if( quality_ && (( theIndexToPlot < 0) || ( i == theIndexToPlot)) ) {
132  fillVariable ( flavour , *(variable + i), hasTrack,w);
133  }
134  }
135 
136  if(theIndexToPlot >= iMax && quality_) {
137  const T& theZero = static_cast<T> (0.0);
138  fillVariable ( quality, theZero, hasTrack,w);
139  }
140  }
141 }
142 
143 template <class T>
145 {
147  theQual_undefined->setAxisTitle(title);
148  theQual_loose->setAxisTitle(title);
149  theQual_tight->setAxisTitle(title);
150  theQual_highpur->setAxisTitle(title);
151 }
152 
153 template<class T>
154 void TrackIPHistograms<T>::fillVariable( const reco::TrackBase::TrackQuality& qual, const T& var, const bool& hasTrack) const
155 {
156  if(!hasTrack || !quality_) return;
157 
158  switch(qual) {
160  theQual_loose->Fill(var);
161  break;
163  theQual_tight->Fill(var);
164  break;
166  theQual_highpur->Fill(var);
167  break;
168  default:
169  theQual_undefined->Fill(var);
170  break;
171  }
172 }
173 
174 template<class T>
175 void TrackIPHistograms<T>::fillVariable( const reco::TrackBase::TrackQuality& qual, const T& var, const bool& hasTrack, const T & w) const
176 {
177  if(!hasTrack || !quality_) return;
178 
179  switch(qual) {
181  theQual_loose->Fill(var,w);
182  break;
184  theQual_tight->Fill(var,w);
185  break;
187  theQual_highpur->Fill(var,w);
188  break;
189  default:
190  theQual_undefined->Fill(var,w);
191  break;
192  }
193 }
194 
195 #endif
int i
Definition: DBlmapReader.cc:9
MonitorElement * theQual_tight
TrackQuality
track quality
Definition: TrackBase.h:93
int maxDimension() const
void fill(const int &flavour, const T &variable) const
virtual MonitorElement * book1D(const std::string &name, const std::string &title, const int &nchX, const double &lowX, const double &highX)
void fill(const int &flavour, const reco::TrackBase::TrackQuality &quality, const T &variable, const bool &hasTrack) const
MonitorElement * theQual_loose
void settitle(const char *title)
int * arrayDimension() const
MonitorElement * theQual_highpur
TH1F * getTH1F(void) const
MonitorElement * theQual_undefined
int indexToPlot() const
virtual ~TrackIPHistograms()
#define update(a, b)
virtual MonitorElement * access(const std::string &name)
T w() const
void settitle(const char *title)
bool statistics() const
long double T
int flavour(const Candidate &part)
Definition: pdgIdUtils.h:31
void fillVariable(const reco::TrackBase::TrackQuality &qual, const T &var, const bool &hasTrack) const