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