CMS 3D CMS Logo

PlotCombiner.cc
Go to the documentation of this file.
12 
13 #include "TH1F.h"
14 #include "TH2F.h"
15 
16 using namespace edm;
17 using namespace std;
18 
20  public:
22  ~PlotCombiner() override;
23  private:
24  void makePlot(const ParameterSet& pset, DQMStore::IBooker &, DQMStore::IGetter &);
25 
28  protected:
29  void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override; //performed in the endJob
30 
31 };
32 
34  myDQMrootFolder( pset.getUntrackedParameter<string>("MyDQMrootFolder") ),
35  plots( pset.getUntrackedParameter<VParameterSet>("Plots") )
36 {
37 }
38 
40  for(VParameterSet::const_iterator pset = plots.begin(); pset!=plots.end(); pset++){
41  makePlot(*pset, ibooker_, igetter_);
42  }
43 }
44 
46 //get hold of MEs
47  vector<string> inputMEnames = pset.getUntrackedParameter<vector<string> >("InputMEnames");
48  vector<string> inputLabels = pset.getUntrackedParameter<vector<string> >("InputLabels");
49  if( inputMEnames.size() != inputLabels.size() ){
50  LogDebug("HLTriggerOfflineHeavyFlavor") << "Number of labels must match the histos[0]ber of InputMEnames"<<endl;
51  return;
52  }
53  vector<TH1*> histos;
54  vector<TString> labels;
55  for(size_t i=0; i<inputMEnames.size(); i++){
56  string MEname = myDQMrootFolder+"/"+inputMEnames[i];
57  MonitorElement *ME = igetter_.get(MEname);
58  if(ME==nullptr){
59  LogDebug("HLTriggerOfflineHeavyFlavor") << "Could not find ME: "<<MEname<<endl;
60  continue;
61  }
62  histos.push_back( ME->getTH1() );
63  labels.push_back( inputLabels[i] );
64  }
65  if(histos.empty()){
66  return;
67  }
68  //figure out the output directory name
69  string outputMEname = pset.getUntrackedParameter<string>("OutputMEname");;
70  string outputDir = myDQMrootFolder;
71  string::size_type slashPos = outputMEname.rfind('/');
72  if ( string::npos != slashPos ) {
73  outputDir += "/"+outputMEname.substr(0, slashPos);
74  outputMEname.erase(0, slashPos+1);
75  }
76  ibooker_.setCurrentFolder(outputDir);
77  //create output ME
78  TH2F * output;
79  if(histos[0]->GetXaxis()->GetXbins()->GetSize()==0){
80  output = new TH2F(outputMEname.c_str(),outputMEname.c_str(),histos[0]->GetXaxis()->GetNbins(),histos[0]->GetXaxis()->GetXmin(),histos[0]->GetXaxis()->GetXmax(),histos.size(),0,histos.size());
81  }else{
82  output = new TH2F(outputMEname.c_str(),outputMEname.c_str(),histos[0]->GetXaxis()->GetNbins(),histos[0]->GetXaxis()->GetXbins()->GetArray(),histos.size(),0,histos.size());
83  }
84  output->SetTitle(outputMEname.c_str());
85  output->SetXTitle( histos[0]->GetXaxis()->GetTitle() );
86  output->SetStats(kFALSE);
87  output->SetOption("colztexte");
88  for(size_t i=0; i<histos.size(); i++){
89  for(int j=1; j<=histos[0]->GetNbinsX(); j++){
90  output->SetBinContent(j,i+1,histos[i]->GetBinContent(j));
91  output->SetBinError(j,i+1,histos[i]->GetBinError(j));
92  }
93  output->GetYaxis()->SetBinLabel(i+1,labels[i]);
94  }
95  ibooker_.book2D(outputMEname,output);
96  delete output;
97 }
98 
100 }
101 
102 //define this as a plug-in
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
void PlotCombiner()
string myDQMrootFolder
Definition: PlotCombiner.cc:26
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
TH1 * getTH1() const
~PlotCombiner() override
Definition: PlotCombiner.cc:99
uint16_t size_type
Definition: ME.h:11
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: PlotCombiner.cc:39
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
const VParameterSet plots
Definition: PlotCombiner.cc:27
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
HLT enums.
void makePlot(const ParameterSet &pset, DQMStore::IBooker &, DQMStore::IGetter &)
Definition: PlotCombiner.cc:45
PlotCombiner(const edm::ParameterSet &pset)
Definition: PlotCombiner.cc:33