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 23 of file HeavyFlavorHarvesting.cc.

Constructor & Destructor Documentation

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

Definition at line 40 of file HeavyFlavorHarvesting.cc.

40  :
41  myDQMrootFolder( pset.getUntrackedParameter<string>("MyDQMrootFolder") ),
42  efficiencies( pset.getUntrackedParameter<VParameterSet>("Efficiencies") )
43 {
44 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
const VParameterSet efficiencies
HeavyFlavorHarvesting::~HeavyFlavorHarvesting ( )
override

Definition at line 173 of file HeavyFlavorHarvesting.cc.

References DEFINE_FWK_MODULE.

173  {
174 }

Member Function Documentation

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

Definition at line 52 of file HeavyFlavorHarvesting.cc.

References calculateEfficiency1D(), calculateEfficiency2D(), SiPixelPhase1DigisV_cfi::dimensions, DQMStore::IGetter::get(), MonitorElement::getTH1(), edm::ParameterSet::getUntrackedParameter(), LogDebug, myDQMrootFolder, pileupDistInMC::num, and DQMStore::IBooker::setCurrentFolder().

Referenced by dqmEndJob().

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

Definition at line 104 of file HeavyFlavorHarvesting.cc.

References DQMStore::IBooker::bookProfile(), MillePedeFileConverter_cfg::e, mps_fire::i, and mathSSE::sqrt().

Referenced by calculateEfficiency().

104  {
105  TProfile* eff;
106  if(num->GetXaxis()->GetXbins()->GetSize()==0){
107  eff = new TProfile(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXmin(),num->GetXaxis()->GetXmax());
108  }else{
109  eff = new TProfile(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXbins()->GetArray());
110  }
111  eff->SetTitle(effName.c_str());
112  eff->SetXTitle( num->GetXaxis()->GetTitle() );
113  eff->SetYTitle("Efficiency");
114  eff->SetOption("PE");
115  eff->SetLineColor(2);
116  eff->SetLineWidth(2);
117  eff->SetMarkerStyle(20);
118  eff->SetMarkerSize(0.8);
119  eff->GetYaxis()->SetRangeUser(-0.001,1.001);
120  eff->SetStats(kFALSE);
121  for(int i=1;i<=num->GetNbinsX();i++){
122  double e, low, high;
123  if (int(den->GetBinContent(i))>0.) e= double(num->GetBinContent(i))/double(den->GetBinContent(i));
124  else e=0.;
125  low=TEfficiency::Wilson((double)den->GetBinContent(i),(double)num->GetBinContent(i),0.683,false);
126  high=TEfficiency::Wilson((double)den->GetBinContent(i),(double)num->GetBinContent(i),0.683,true);
127 
128  double err = e-low>high-e ? e-low : high-e;
129  //here is the trick to store info in TProfile:
130  eff->SetBinContent( i, e );
131  eff->SetBinEntries( i, 1 );
132  eff->SetBinError( i, sqrt(e*e+err*err) );
133  }
134  ibooker_.bookProfile(effName,eff);
135  delete eff;
136 }
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
T sqrt(T t)
Definition: SSEVec.h:18
void HeavyFlavorHarvesting::calculateEfficiency2D ( TH2F *  num,
TH2F *  den,
string  name,
DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
private

Definition at line 138 of file HeavyFlavorHarvesting.cc.

References DQMStore::IBooker::bookProfile2D(), MillePedeFileConverter_cfg::e, mps_fire::i, and mathSSE::sqrt().

Referenced by calculateEfficiency().

138  {
139  TProfile2D* eff;
140  if(num->GetXaxis()->GetXbins()->GetSize()==0 && num->GetYaxis()->GetXbins()->GetSize()==0){
141  eff = new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXmin(),num->GetXaxis()->GetXmax(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXmin(),num->GetYaxis()->GetXmax());
142  }else if(num->GetXaxis()->GetXbins()->GetSize()!=0 && num->GetYaxis()->GetXbins()->GetSize()==0){
143  eff = new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXbins()->GetArray(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXmin(),num->GetYaxis()->GetXmax());
144  }else if(num->GetXaxis()->GetXbins()->GetSize()==0 && num->GetYaxis()->GetXbins()->GetSize()!=0){
145  eff = new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXmin(),num->GetXaxis()->GetXmax(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXbins()->GetArray());
146  }else{
147  eff = new TProfile2D(effName.c_str(),effName.c_str(),num->GetXaxis()->GetNbins(),num->GetXaxis()->GetXbins()->GetArray(),num->GetYaxis()->GetNbins(),num->GetYaxis()->GetXbins()->GetArray());
148  }
149  eff->SetTitle(effName.c_str());
150  eff->SetXTitle( num->GetXaxis()->GetTitle() );
151  eff->SetYTitle( num->GetYaxis()->GetTitle() );
152  eff->SetZTitle("Efficiency");
153  eff->SetOption("colztexte");
154  eff->GetZaxis()->SetRangeUser(-0.001,1.001);
155  eff->SetStats(kFALSE);
156  for(int i=0;i<num->GetSize();i++){
157  double e, low, high;
158  if (int(den->GetBinContent(i))>0.) e= double(num->GetBinContent(i))/double(den->GetBinContent(i));
159  else e=0.;
160  low=TEfficiency::Wilson((double)den->GetBinContent(i),(double)num->GetBinContent(i),0.683,false);
161  high=TEfficiency::Wilson((double)den->GetBinContent(i),(double)num->GetBinContent(i),0.683,true);
162 
163  double err = e-low>high-e ? e-low : high-e;
164  //here is the trick to store info in TProfile:
165  eff->SetBinContent( i, e );
166  eff->SetBinEntries( i, 1 );
167  eff->SetBinError( i, sqrt(e*e+err*err) );
168  }
169  ibooker_.bookProfile2D(effName,eff);
170  delete eff;
171 }
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:166
T sqrt(T t)
Definition: SSEVec.h:18
void HeavyFlavorHarvesting::dqmEndJob ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
overrideprotected

Definition at line 46 of file HeavyFlavorHarvesting.cc.

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

46  {
47  for(VParameterSet::const_iterator pset = efficiencies.begin(); pset!=efficiencies.end(); pset++){
48  calculateEfficiency(*pset, ibooker_, igetter_);
49  }
50 }
const VParameterSet efficiencies
void calculateEfficiency(const ParameterSet &pset, DQMStore::IBooker &, DQMStore::IGetter &)

Member Data Documentation

const VParameterSet HeavyFlavorHarvesting::efficiencies
private

Definition at line 35 of file HeavyFlavorHarvesting.cc.

Referenced by dqmEndJob().

string HeavyFlavorHarvesting::myDQMrootFolder
private

Definition at line 34 of file HeavyFlavorHarvesting.cc.

Referenced by calculateEfficiency().