CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
HeavyFlavorHarvesting Class Reference
Inheritance diagram for HeavyFlavorHarvesting:

Public Member Functions

 HeavyFlavorHarvesting (const edm::ParameterSet &pset)
 
 ~HeavyFlavorHarvesting () override
 

Protected Member Functions

void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 

Private Member Functions

void calculateEfficiency (const ParameterSet &pset, DQMStore::IBooker &, DQMStore::IGetter &)
 
void calculateEfficiency1D (TH1 *num, TH1 *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
 
void calculateEfficiency2D (TH2F *num, TH2F *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
 

Private Attributes

const VParameterSet efficiencies
 
string myDQMrootFolder
 

Detailed Description

Definition at line 22 of file HeavyFlavorHarvesting.cc.

Constructor & Destructor Documentation

◆ HeavyFlavorHarvesting()

HeavyFlavorHarvesting::HeavyFlavorHarvesting ( const edm::ParameterSet pset)

Definition at line 39 of file HeavyFlavorHarvesting.cc.

40  : myDQMrootFolder(pset.getUntrackedParameter<string>("MyDQMrootFolder")),
41  efficiencies(pset.getUntrackedParameter<VParameterSet>("Efficiencies")) {}

◆ ~HeavyFlavorHarvesting()

HeavyFlavorHarvesting::~HeavyFlavorHarvesting ( )
override

Definition at line 209 of file HeavyFlavorHarvesting.cc.

209 {}

Member Function Documentation

◆ calculateEfficiency()

void HeavyFlavorHarvesting::calculateEfficiency ( const ParameterSet pset,
DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
private

Definition at line 49 of file HeavyFlavorHarvesting.cc.

51  {
52  //get hold of numerator and denominator histograms
53  vector<string> numDenEffMEnames = pset.getUntrackedParameter<vector<string> >("NumDenEffMEnames");
54  if (numDenEffMEnames.size() != 3) {
55  LogDebug("HLTriggerOfflineHeavyFlavor") << "NumDenEffMEnames must have three names" << endl;
56  return;
57  }
58  string denMEname = myDQMrootFolder + "/" + numDenEffMEnames[1];
59  string numMEname = myDQMrootFolder + "/" + numDenEffMEnames[0];
60  MonitorElement* denME = igetter_.get(denMEname);
61  MonitorElement* numME = igetter_.get(numMEname);
62  if (denME == nullptr || numME == nullptr) {
63  LogDebug("HLTriggerOfflineHeavyFlavor") << "Could not find MEs: " << denMEname << " or " << numMEname << endl;
64  return;
65  }
66  TH1* den = denME->getTH1();
67  TH1* num = numME->getTH1();
68  //check compatibility of the histograms
69  if (den->GetNbinsX() != num->GetNbinsX() || den->GetNbinsY() != num->GetNbinsY() ||
70  den->GetNbinsZ() != num->GetNbinsZ()) {
71  LogDebug("HLTriggerOfflineHeavyFlavor")
72  << "Monitoring elements " << numMEname << " and " << denMEname << "are incompatible" << endl;
73  return;
74  }
75  //figure out the directory and efficiency name
76  string effName = numDenEffMEnames[2];
77  string effDir = myDQMrootFolder;
78  string::size_type slashPos = effName.rfind('/');
79  if (string::npos != slashPos) {
80  effDir += "/" + effName.substr(0, slashPos);
81  effName.erase(0, slashPos + 1);
82  }
83  ibooker_.setCurrentFolder(effDir);
84  //calculate the efficiencies
85  int dimensions = num->GetDimension();
86  if (dimensions == 1) {
87  calculateEfficiency1D(num, den, effName, ibooker_, igetter_);
88  } else if (dimensions == 2) {
89  calculateEfficiency2D((TH2F*)num, (TH2F*)den, effName, ibooker_, igetter_);
90  TH1D* numX = ((TH2F*)num)->ProjectionX();
91  TH1D* denX = ((TH2F*)den)->ProjectionX();
92  calculateEfficiency1D(numX, denX, effName + "X", ibooker_, igetter_);
93  delete numX;
94  delete denX;
95  TH1D* numY = ((TH2F*)num)->ProjectionY();
96  TH1D* denY = ((TH2F*)den)->ProjectionY();
97  calculateEfficiency1D(numY, denY, effName + "Y", ibooker_, igetter_);
98  delete numY;
99  delete denY;
100  } else {
101  return;
102  }
103 }

References calculateEfficiency1D(), calculateEfficiency2D(), HistogramManager_cfi::dimensions, dqm::implementation::IGetter::get(), dqm::legacy::MonitorElement::getTH1(), LogDebug, myDQMrootFolder, EgammaValidation_cff::num, muonDTDigis_cfi::pset, and dqm::implementation::NavigatorBase::setCurrentFolder().

Referenced by dqmEndJob().

◆ calculateEfficiency1D()

void HeavyFlavorHarvesting::calculateEfficiency1D ( TH1 *  num,
TH1 *  den,
string  name,
DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
private

Definition at line 105 of file HeavyFlavorHarvesting.cc.

106  {
107  TProfile* eff;
108  if (num->GetXaxis()->GetXbins()->GetSize() == 0) {
109  eff = new TProfile(effName.c_str(),
110  effName.c_str(),
111  num->GetXaxis()->GetNbins(),
112  num->GetXaxis()->GetXmin(),
113  num->GetXaxis()->GetXmax());
114  } else {
115  eff = new TProfile(
116  effName.c_str(), effName.c_str(), num->GetXaxis()->GetNbins(), num->GetXaxis()->GetXbins()->GetArray());
117  }
118  eff->SetTitle(effName.c_str());
119  eff->SetXTitle(num->GetXaxis()->GetTitle());
120  eff->SetYTitle("Efficiency");
121  eff->SetOption("PE");
122  eff->SetLineColor(2);
123  eff->SetLineWidth(2);
124  eff->SetMarkerStyle(20);
125  eff->SetMarkerSize(0.8);
126  eff->GetYaxis()->SetRangeUser(-0.001, 1.001);
127  eff->SetStats(kFALSE);
128  for (int i = 1; i <= num->GetNbinsX(); i++) {
129  double e, low, high;
130  if (int(den->GetBinContent(i)) > 0.)
131  e = double(num->GetBinContent(i)) / double(den->GetBinContent(i));
132  else
133  e = 0.;
134  low = TEfficiency::Wilson((double)den->GetBinContent(i), (double)num->GetBinContent(i), 0.683, false);
135  high = TEfficiency::Wilson((double)den->GetBinContent(i), (double)num->GetBinContent(i), 0.683, true);
136 
137  double err = e - low > high - e ? e - low : high - e;
138  //here is the trick to store info in TProfile:
139  eff->SetBinContent(i, e);
140  eff->SetBinEntries(i, 1);
141  eff->SetBinError(i, sqrt(e * e + err * err));
142  }
143  ibooker_.bookProfile(effName, eff);
144  delete eff;
145 }

References dqm::implementation::IBooker::bookProfile(), MillePedeFileConverter_cfg::e, submitPVResolutionJobs::err, LaserClient_cfi::high, mps_fire::i, LaserClient_cfi::low, EgammaValidation_cff::num, and mathSSE::sqrt().

Referenced by calculateEfficiency().

◆ calculateEfficiency2D()

void HeavyFlavorHarvesting::calculateEfficiency2D ( TH2F *  num,
TH2F *  den,
string  name,
DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
private

Definition at line 147 of file HeavyFlavorHarvesting.cc.

148  {
149  TProfile2D* eff;
150  if (num->GetXaxis()->GetXbins()->GetSize() == 0 && num->GetYaxis()->GetXbins()->GetSize() == 0) {
151  eff = new TProfile2D(effName.c_str(),
152  effName.c_str(),
153  num->GetXaxis()->GetNbins(),
154  num->GetXaxis()->GetXmin(),
155  num->GetXaxis()->GetXmax(),
156  num->GetYaxis()->GetNbins(),
157  num->GetYaxis()->GetXmin(),
158  num->GetYaxis()->GetXmax());
159  } else if (num->GetXaxis()->GetXbins()->GetSize() != 0 && num->GetYaxis()->GetXbins()->GetSize() == 0) {
160  eff = new TProfile2D(effName.c_str(),
161  effName.c_str(),
162  num->GetXaxis()->GetNbins(),
163  num->GetXaxis()->GetXbins()->GetArray(),
164  num->GetYaxis()->GetNbins(),
165  num->GetYaxis()->GetXmin(),
166  num->GetYaxis()->GetXmax());
167  } else if (num->GetXaxis()->GetXbins()->GetSize() == 0 && num->GetYaxis()->GetXbins()->GetSize() != 0) {
168  eff = new TProfile2D(effName.c_str(),
169  effName.c_str(),
170  num->GetXaxis()->GetNbins(),
171  num->GetXaxis()->GetXmin(),
172  num->GetXaxis()->GetXmax(),
173  num->GetYaxis()->GetNbins(),
174  num->GetYaxis()->GetXbins()->GetArray());
175  } else {
176  eff = new TProfile2D(effName.c_str(),
177  effName.c_str(),
178  num->GetXaxis()->GetNbins(),
179  num->GetXaxis()->GetXbins()->GetArray(),
180  num->GetYaxis()->GetNbins(),
181  num->GetYaxis()->GetXbins()->GetArray());
182  }
183  eff->SetTitle(effName.c_str());
184  eff->SetXTitle(num->GetXaxis()->GetTitle());
185  eff->SetYTitle(num->GetYaxis()->GetTitle());
186  eff->SetZTitle("Efficiency");
187  eff->SetOption("colztexte");
188  eff->GetZaxis()->SetRangeUser(-0.001, 1.001);
189  eff->SetStats(kFALSE);
190  for (int i = 0; i < num->GetSize(); i++) {
191  double e, low, high;
192  if (int(den->GetBinContent(i)) > 0.)
193  e = double(num->GetBinContent(i)) / double(den->GetBinContent(i));
194  else
195  e = 0.;
196  low = TEfficiency::Wilson((double)den->GetBinContent(i), (double)num->GetBinContent(i), 0.683, false);
197  high = TEfficiency::Wilson((double)den->GetBinContent(i), (double)num->GetBinContent(i), 0.683, true);
198 
199  double err = e - low > high - e ? e - low : high - e;
200  //here is the trick to store info in TProfile:
201  eff->SetBinContent(i, e);
202  eff->SetBinEntries(i, 1);
203  eff->SetBinError(i, sqrt(e * e + err * err));
204  }
205  ibooker_.bookProfile2D(effName, eff);
206  delete eff;
207 }

References dqm::implementation::IBooker::bookProfile2D(), MillePedeFileConverter_cfg::e, submitPVResolutionJobs::err, LaserClient_cfi::high, mps_fire::i, LaserClient_cfi::low, EgammaValidation_cff::num, and mathSSE::sqrt().

Referenced by calculateEfficiency().

◆ dqmEndJob()

void HeavyFlavorHarvesting::dqmEndJob ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
overrideprotected

Definition at line 43 of file HeavyFlavorHarvesting.cc.

43  {
44  for (VParameterSet::const_iterator pset = efficiencies.begin(); pset != efficiencies.end(); pset++) {
45  calculateEfficiency(*pset, ibooker_, igetter_);
46  }
47 }

References calculateEfficiency(), efficiencies, and muonDTDigis_cfi::pset.

Member Data Documentation

◆ efficiencies

const VParameterSet HeavyFlavorHarvesting::efficiencies
private

Definition at line 33 of file HeavyFlavorHarvesting.cc.

Referenced by dqmEndJob().

◆ myDQMrootFolder

string HeavyFlavorHarvesting::myDQMrootFolder
private

Definition at line 32 of file HeavyFlavorHarvesting.cc.

Referenced by calculateEfficiency().

mps_fire.i
i
Definition: mps_fire.py:428
dqm::implementation::IBooker::bookProfile2D
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
HeavyFlavorHarvesting::calculateEfficiency
void calculateEfficiency(const ParameterSet &pset, DQMStore::IBooker &, DQMStore::IGetter &)
Definition: HeavyFlavorHarvesting.cc:49
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
HistogramManager_cfi.dimensions
dimensions
Definition: HistogramManager_cfi.py:74
HeavyFlavorHarvesting::efficiencies
const VParameterSet efficiencies
Definition: HeavyFlavorHarvesting.cc:33
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:475
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
HeavyFlavorHarvesting::myDQMrootFolder
string myDQMrootFolder
Definition: HeavyFlavorHarvesting.cc:32
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
HeavyFlavorHarvesting::calculateEfficiency2D
void calculateEfficiency2D(TH2F *num, TH2F *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
Definition: HeavyFlavorHarvesting.cc:147
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
HeavyFlavorHarvesting::calculateEfficiency1D
void calculateEfficiency1D(TH1 *num, TH1 *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
Definition: HeavyFlavorHarvesting.cc:105
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37