test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
HeavyFlavorHarvesting Class Reference
Inheritance diagram for HeavyFlavorHarvesting:
DQMEDHarvester edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 HeavyFlavorHarvesting (const edm::ParameterSet &pset)
 
virtual ~HeavyFlavorHarvesting ()
 
- Public Member Functions inherited from DQMEDHarvester
virtual void analyze (edm::Event const &, edm::EventSetup const &) final
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDHarvester (void)
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endJob () final
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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 ( )
virtual

Definition at line 173 of file HeavyFlavorHarvesting.cc.

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(), 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==0 || numME==0){
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:304
void calculateEfficiency1D(TH1 *num, TH1 *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
uint16_t size_type
TH1 * getTH1(void) const
void calculateEfficiency2D(TH2F *num, TH2F *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
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(), alignCSCRings::e, 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 }
int i
Definition: DBlmapReader.cc:9
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
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(), alignCSCRings::e, 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 }
int i
Definition: DBlmapReader.cc:9
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:163
T sqrt(T t)
Definition: SSEVec.h:18
void HeavyFlavorHarvesting::dqmEndJob ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
overrideprotectedvirtual

Implements DQMEDHarvester.

Definition at line 46 of file HeavyFlavorHarvesting.cc.

References calculateEfficiency(), efficiencies, and TrackValidation_cff::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().