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 std::string& plotFirst_, const std::string& folder,
17  const unsigned int& mc, const bool& quality, DQMStore::IGetter & iget);
18 
19  TrackIPHistograms(const std::string& baseNameTitle_ , const std::string& baseNameDescription_,
20  const int& nBins_, const double& lowerBound_, const double& upperBound_,
21  const bool& statistics, const bool& plotLog_, const bool& plotNormalized_,
22  const std::string& plotFirst_, const std::string& folder,
23  const unsigned int& mc, const bool& quality, DQMStore::IBooker & ibook);
24 
25  virtual ~TrackIPHistograms(){};
26 
27  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack) const;
28  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack, const T & w) const;
29 
30  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack) const;
31  void fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack, const T & w) const;
32 
33  void settitle(const char* title);
34 
35  protected:
36 
37  void fillVariable ( const reco::TrackBase::TrackQuality& qual, const T & var, const bool& hasTrack) const;
38  void fillVariable ( const reco::TrackBase::TrackQuality& qual, const T & var, const bool& hasTrack, const T & w) const;
39 
40  bool quality_;
41 
46 
47  private:
49 };
50 
51 template <class T>
52 TrackIPHistograms<T>::TrackIPHistograms (const std::string& baseNameTitle_, const std::string& baseNameDescription_,
53  const int& nBins_, const double& lowerBound_, const double& upperBound_,
54  const bool& statistics_, const bool& plotLog_, const bool& plotNormalized_,
55  const std::string& plotFirst_, const std::string& folder,
56  const unsigned int& mc, const bool& quality, DQMStore::IBooker & ibook) :
57  FlavourHistograms<T>(baseNameTitle_, baseNameDescription_, nBins_, lowerBound_, upperBound_, statistics_, plotLog_, plotNormalized_,
58  plotFirst_, folder, mc, ibook), quality_(quality)
59 {
60  if(quality_) {
61  HistoProviderDQM prov("Btag",folder,ibook);
62  theQual_undefined = prov.book1D( baseNameTitle_ + "QualUnDef" , baseNameDescription_ + " Undefined Quality", nBins_, lowerBound_, upperBound_);
63  theQual_loose = prov.book1D( baseNameTitle_ + "QualLoose" , baseNameDescription_ + " Loose Quality", nBins_, lowerBound_, upperBound_);
64  theQual_tight = prov.book1D( baseNameTitle_ + "QualTight" , baseNameDescription_ + " Tight Quality", nBins_, lowerBound_, upperBound_);
65  theQual_highpur = prov.book1D( baseNameTitle_ + "QualHighPur" , baseNameDescription_ + " High Purity Quality", nBins_, lowerBound_, upperBound_);
66 
67  if( statistics_ ) {
68  theQual_undefined->getTH1F()->Sumw2();
69  theQual_loose->getTH1F()->Sumw2();
70  theQual_tight->getTH1F()->Sumw2();
71  theQual_highpur->getTH1F()->Sumw2();
72  }
73  }
74 }
75 template <class T>
76 TrackIPHistograms<T>::TrackIPHistograms (const std::string& baseNameTitle_, const std::string& baseNameDescription_,
77  const int& nBins_, const double& lowerBound_, const double& upperBound_,
78  const std::string& plotFirst_, const std::string& folder,
79  const unsigned int& mc, const bool& quality, DQMStore::IGetter & iget) :
80 FlavourHistograms<T>(baseNameTitle_, baseNameDescription_, nBins_, lowerBound_, upperBound_,
81  plotFirst_, folder, mc, iget), quality_(quality)
82 {
83  if(quality_) {
84  theQual_undefined = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualUnDef");
85  theQual_loose = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualLoose");
86  theQual_tight = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualTight");
87  theQual_highpur = iget.get("Btag/" + folder + "/" + baseNameTitle_ + "QualHighPur");
88  }
89 }
90 
91 template <class T>
92 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack) const
93 {
94  FlavourHistograms<T>::fill(flavour, variable);
95  if(quality_)
96  fillVariable(quality, variable, hasTrack);
97 }
98 
99 template <class T>
100 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T& variable, const bool& hasTrack, const T & w) const
101 {
102  FlavourHistograms<T>::fill(flavour, variable , w);
103  if(quality_)
104  fillVariable(quality, variable, hasTrack, w);
105 }
106 
107 template <class T>
108 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack) const
109 {
110  const int* theArrayDimension = FlavourHistograms<T>::arrayDimension();
111  const int& theMaxDimension = FlavourHistograms<T>::maxDimension();
112  const int& theIndexToPlot = FlavourHistograms<T>::indexToPlot();
113 
114  FlavourHistograms<T>::fill(flavour, variable);
115  if( theArrayDimension == 0 && quality_) {
116  fillVariable( quality, *variable);
117  } else {
118  int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
119  for(int i = 0; i != iMax; ++i) {
120  if( quality_ && (( theIndexToPlot < 0) || ( i == theIndexToPlot)) ) {
121  fillVariable ( flavour , *(variable + i), hasTrack);
122  }
123  }
124 
125  if(theIndexToPlot >= iMax && quality_) {
126  const T& theZero = static_cast<T> (0.0);
127  fillVariable ( quality, theZero, hasTrack);
128  }
129  }
130 }
131 
132 template <class T>
133 void TrackIPHistograms<T>::fill(const int& flavour, const reco::TrackBase::TrackQuality& quality, const T* variable, const bool& hasTrack, const T & w) const
134 {
135  const int* theArrayDimension = FlavourHistograms<T>::arrayDimension();
136  const int& theMaxDimension = FlavourHistograms<T>::maxDimension();
137  const int& theIndexToPlot = FlavourHistograms<T>::indexToPlot();
138 
139  FlavourHistograms<T>::fill(flavour, variable ,w);
140  if( theArrayDimension == 0 && quality_) {
141  fillVariable( quality, *variable,w);
142  } else {
143  int iMax = (*theArrayDimension > theMaxDimension) ? theMaxDimension : *theArrayDimension ;
144  for(int i = 0; i != iMax; ++i) {
145  if( quality_ && (( theIndexToPlot < 0) || ( i == theIndexToPlot)) ) {
146  fillVariable ( flavour , *(variable + i), hasTrack,w);
147  }
148  }
149 
150  if(theIndexToPlot >= iMax && quality_) {
151  const T& theZero = static_cast<T> (0.0);
152  fillVariable ( quality, theZero, hasTrack,w);
153  }
154  }
155 }
156 
157 template <class T>
159 {
161  theQual_undefined->setAxisTitle(title);
162  theQual_loose->setAxisTitle(title);
163  theQual_tight->setAxisTitle(title);
164  theQual_highpur->setAxisTitle(title);
165 }
166 
167 template<class T>
168 void TrackIPHistograms<T>::fillVariable( const reco::TrackBase::TrackQuality& qual, const T& var, const bool& hasTrack) const
169 {
170  if(!hasTrack || !quality_) return;
171 
172  switch(qual) {
174  theQual_loose->Fill(var);
175  break;
177  theQual_tight->Fill(var);
178  break;
180  theQual_highpur->Fill(var);
181  break;
182  default:
183  theQual_undefined->Fill(var);
184  break;
185  }
186 }
187 
188 template<class T>
189 void TrackIPHistograms<T>::fillVariable( const reco::TrackBase::TrackQuality& qual, const T& var, const bool& hasTrack, const T & w) const
190 {
191  if(!hasTrack || !quality_) return;
192 
193  switch(qual) {
195  theQual_loose->Fill(var,w);
196  break;
198  theQual_tight->Fill(var,w);
199  break;
201  theQual_highpur->Fill(var,w);
202  break;
203  default:
204  theQual_undefined->Fill(var,w);
205  break;
206  }
207 }
208 
209 #endif
int i
Definition: DBlmapReader.cc:9
MonitorElement * theQual_tight
const double w
Definition: UKUtility.cc:23
TrackQuality
track quality
Definition: TrackBase.h:149
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
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()
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