CMS 3D CMS Logo

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 public:
14 
15  TrackIPHistograms(const std::string& baseNameTitle_,
16  const std::string& baseNameDescription_,
17  const int& nBins_,
18  const double& lowerBound_,
19  const double& upperBound_,
20  const std::string& plotFirst_,
21  const std::string& folder,
22  const unsigned int& mc,
23  const bool& quality,
24  DQMStore::IGetter& iget);
25 
26  TrackIPHistograms(const std::string& baseNameTitle_,
27  const std::string& baseNameDescription_,
28  const int& nBins_,
29  const double& lowerBound_,
30  const double& upperBound_,
31  const bool& statistics,
32  const bool& plotLog_,
33  const bool& plotNormalized_,
34  const std::string& plotFirst_,
35  const std::string& folder,
36  const unsigned int& mc,
37  const bool& quality,
38  DQMStore::IBooker& ibook);
39 
40  ~TrackIPHistograms() override{};
41 
42  void fill(const int& flavour,
44  const T& variable,
45  const bool& hasTrack) const;
46  void fill(const int& flavour,
48  const T& variable,
49  const bool& hasTrack,
50  const T& w) const;
51 
52  void fill(const int& flavour,
54  const T* variable,
55  const bool& hasTrack) const;
56  void fill(const int& flavour,
58  const T* variable,
59  const bool& hasTrack,
60  const T& w) const;
61 
62  void settitle(const char* title);
63 
64 protected:
65  void fillVariable(const reco::TrackBase::TrackQuality& qual, const T& var, const bool& hasTrack) const;
66  void fillVariable(const reco::TrackBase::TrackQuality& qual, const T& var, const bool& hasTrack, const T& w) const;
67 
68  bool quality_;
69 
74 
75 private:
77 };
78 
79 template <class T>
81  const std::string& baseNameDescription_,
82  const int& nBins_,
83  const double& lowerBound_,
84  const double& upperBound_,
85  const bool& statistics_,
86  const bool& plotLog_,
87  const bool& plotNormalized_,
88  const std::string& plotFirst_,
89  const std::string& folder,
90  const unsigned int& mc,
91  const bool& quality,
92  DQMStore::IBooker& ibook)
93  : FlavourHistograms<T>(baseNameTitle_,
94  baseNameDescription_,
95  nBins_,
96  lowerBound_,
97  upperBound_,
98  statistics_,
99  plotLog_,
100  plotNormalized_,
101  plotFirst_,
102  folder,
103  mc,
104  ibook),
105  quality_(quality) {
106  if (quality_) {
107  HistoProviderDQM prov("Btag", folder, ibook);
108  theQual_undefined = prov.book1D(
109  baseNameTitle_ + "QualUnDef", baseNameDescription_ + " Undefined Quality", nBins_, lowerBound_, upperBound_);
110  theQual_loose = prov.book1D(
111  baseNameTitle_ + "QualLoose", baseNameDescription_ + " Loose Quality", nBins_, lowerBound_, upperBound_);
112  theQual_tight = prov.book1D(
113  baseNameTitle_ + "QualTight", baseNameDescription_ + " Tight Quality", nBins_, lowerBound_, upperBound_);
114  theQual_highpur = prov.book1D(
115  baseNameTitle_ + "QualHighPur", baseNameDescription_ + " High Purity Quality", nBins_, lowerBound_, upperBound_);
116 
117  if (statistics_) {
122  }
123  }
124 }
125 template <class T>
127  const std::string& baseNameDescription_,
128  const int& nBins_,
129  const double& lowerBound_,
130  const double& upperBound_,
131  const std::string& plotFirst_,
132  const std::string& folder,
133  const unsigned int& mc,
134  const bool& quality,
135  DQMStore::IGetter& iget)
136  : FlavourHistograms<T>(
137  baseNameTitle_, baseNameDescription_, nBins_, lowerBound_, upperBound_, plotFirst_, folder, mc, iget),
138  quality_(quality) {
139  if (quality_) {
140  theQual_undefined = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualUnDef");
141  theQual_loose = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualLoose");
142  theQual_tight = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualTight");
143  theQual_highpur = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualHighPur");
144  }
145 }
146 
147 template <class T>
150  const T& variable,
151  const bool& hasTrack) const {
153  if (quality_)
154  fillVariable(quality, variable, hasTrack);
155 }
156 
157 template <class T>
160  const T& variable,
161  const bool& hasTrack,
162  const T& w) const {
164  if (quality_)
165  fillVariable(quality, variable, hasTrack, w);
166 }
167 
168 template <class T>
171  const T* variable,
172  const bool& hasTrack) const {
173  const int* theArrayDimension = FlavourHistograms<T>::arrayDimension();
174  const int& theMaxDimension = FlavourHistograms<T>::maxDimension();
175  const int& theIndexToPlot = FlavourHistograms<T>::indexToPlot();
176 
178  if (theArrayDimension == nullptr && quality_) {
179  fillVariable(quality, *variable);
180  } else {
181  int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension;
182  for (int i = 0; i != iMax; ++i) {
183  if (quality_ && ((theIndexToPlot < 0) || (i == theIndexToPlot))) {
184  fillVariable(flavour, *(variable + i), hasTrack);
185  }
186  }
187 
188  if (theIndexToPlot >= iMax && quality_) {
189  const T& theZero = static_cast<T>(0.0);
190  fillVariable(quality, theZero, hasTrack);
191  }
192  }
193 }
194 
195 template <class T>
198  const T* variable,
199  const bool& hasTrack,
200  const T& w) const {
201  const int* theArrayDimension = FlavourHistograms<T>::arrayDimension();
202  const int& theMaxDimension = FlavourHistograms<T>::maxDimension();
203  const int& theIndexToPlot = FlavourHistograms<T>::indexToPlot();
204 
206  if (theArrayDimension == nullptr && quality_) {
207  fillVariable(quality, *variable, w);
208  } else {
209  int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension;
210  for (int i = 0; i != iMax; ++i) {
211  if (quality_ && ((theIndexToPlot < 0) || (i == theIndexToPlot))) {
212  fillVariable(flavour, *(variable + i), hasTrack, w);
213  }
214  }
215 
216  if (theIndexToPlot >= iMax && quality_) {
217  const T& theZero = static_cast<T>(0.0);
218  fillVariable(quality, theZero, hasTrack, w);
219  }
220  }
221 }
222 
223 template <class T>
226  theQual_undefined->setAxisTitle(title);
227  theQual_loose->setAxisTitle(title);
228  theQual_tight->setAxisTitle(title);
229  theQual_highpur->setAxisTitle(title);
230 }
231 
232 template <class T>
234  const T& var,
235  const bool& hasTrack) const {
236  if (!hasTrack || !quality_)
237  return;
238 
239  switch (qual) {
241  theQual_loose->Fill(var);
242  break;
244  theQual_tight->Fill(var);
245  break;
247  theQual_highpur->Fill(var);
248  break;
249  default:
250  theQual_undefined->Fill(var);
251  break;
252  }
253 }
254 
255 template <class T>
257  const T& var,
258  const bool& hasTrack,
259  const T& w) const {
260  if (!hasTrack || !quality_)
261  return;
262 
263  switch (qual) {
265  theQual_loose->Fill(var, w);
266  break;
268  theQual_tight->Fill(var, w);
269  break;
271  theQual_highpur->Fill(var, w);
272  break;
273  default:
274  theQual_undefined->Fill(var, w);
275  break;
276  }
277 }
278 
279 #endif
MonitorElement * theQual_tight
T w() const
TrackQuality
track quality
Definition: TrackBase.h:150
~TrackIPHistograms() override
void fillVariable(const reco::TrackBase::TrackQuality &qual, const T &var, const bool &hasTrack) const
void fill(const int &flavour, const T &variable) const
int maxDimension() const
MonitorElement * theQual_loose
void fill(const int &flavour, const reco::TrackBase::TrackQuality &quality, const T &variable, const bool &hasTrack) const
void settitle(const char *title)
MonitorElement * theQual_highpur
bool statistics() const
MonitorElement * theQual_undefined
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
virtual MonitorElement * book1D(const std::string &name, const std::string &title, const int &nchX, const double &lowX, const double &highX)
dqm::legacy::DQMStore DQMStore
int * arrayDimension() const
dqm::legacy::MonitorElement MonitorElement
string quality
void settitle(const char *title)
long double T