CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PlotCombiner.cc
Go to the documentation of this file.
11 
12 #include "TH1F.h"
13 #include "TH2F.h"
14 
15 using namespace edm;
16 using namespace std;
17 
19  public:
20  PlotCombiner(const edm::ParameterSet& pset);
21  virtual ~PlotCombiner();
22  virtual void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {};
23  virtual void endRun(const edm::Run &, const edm::EventSetup &);
24  private:
25  void makePlot(const ParameterSet& pset);
29 };
30 
32  myDQMrootFolder( pset.getUntrackedParameter<string>("MyDQMrootFolder") ),
33  plots( pset.getUntrackedParameter<VParameterSet>("Plots") )
34 {
35 }
36 
39  if( !dqmStore ){
40  LogError("HLTriggerOfflineHeavyFlavor") << "Could not find DQMStore service\n";
41  return;
42  }
43  for(VParameterSet::const_iterator pset = plots.begin(); pset!=plots.end(); pset++){
44  makePlot(*pset);
45  }
46 }
47 
49 //get hold of MEs
50  vector<string> inputMEnames = pset.getUntrackedParameter<vector<string> >("InputMEnames");
51  vector<string> inputLabels = pset.getUntrackedParameter<vector<string> >("InputLabels");
52  if( inputMEnames.size() != inputLabels.size() ){
53  LogDebug("HLTriggerOfflineHeavyFlavor") << "Number of labels must match the histos[0]ber of InputMEnames"<<endl;
54  return;
55  }
56  vector<TH1*> histos;
57  vector<TString> labels;
58  for(size_t i=0; i<inputMEnames.size(); i++){
59  string MEname = myDQMrootFolder+"/"+inputMEnames[i];
60  MonitorElement *ME = dqmStore->get(MEname);
61  if(ME==0){
62  LogDebug("HLTriggerOfflineHeavyFlavor") << "Could not find ME: "<<MEname<<endl;
63  continue;
64  }
65  histos.push_back( ME->getTH1() );
66  labels.push_back( inputLabels[i] );
67  }
68  if(histos.size()==0){
69  return;
70  }
71  //figure out the output directory name
72  string outputMEname = pset.getUntrackedParameter<string>("OutputMEname");;
73  string outputDir = myDQMrootFolder;
74  string::size_type slashPos = outputMEname.rfind('/');
75  if ( string::npos != slashPos ) {
76  outputDir += "/"+outputMEname.substr(0, slashPos);
77  outputMEname.erase(0, slashPos+1);
78  }
79  dqmStore->setCurrentFolder(outputDir);
80  //create output ME
81  TH2F * output;
82  if(histos[0]->GetXaxis()->GetXbins()->GetSize()==0){
83  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());
84  }else{
85  output = new TH2F(outputMEname.c_str(),outputMEname.c_str(),histos[0]->GetXaxis()->GetNbins(),histos[0]->GetXaxis()->GetXbins()->GetArray(),histos.size(),0,histos.size());
86  }
87  output->SetTitle(outputMEname.c_str());
88  output->SetXTitle( histos[0]->GetXaxis()->GetTitle() );
89  output->SetStats(kFALSE);
90  output->SetOption("colztexte");
91  for(size_t i=0; i<histos.size(); i++){
92  for(int j=1; j<=histos[0]->GetNbinsX(); j++){
93  output->SetBinContent(j,i+1,histos[i]->GetBinContent(j));
94  output->SetBinError(j,i+1,histos[i]->GetBinError(j));
95  }
96  output->GetYaxis()->SetBinLabel(i+1,labels[i]);
97  }
98  dqmStore->book2D(outputMEname,output);
99  delete output;
100 }
101 
103 }
104 
105 //define this as a plug-in
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void PlotCombiner()
virtual void endRun(const edm::Run &, const edm::EventSetup &)
Definition: PlotCombiner.cc:37
string myDQMrootFolder
Definition: PlotCombiner.cc:27
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
virtual ~PlotCombiner()
uint16_t size_type
void makePlot(const ParameterSet &pset)
Definition: PlotCombiner.cc:48
Definition: ME.h:11
int j
Definition: DBlmapReader.cc:9
TH1 * getTH1(void) const
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const VParameterSet plots
Definition: PlotCombiner.cc:28
DQMStore * dqmStore
Definition: PlotCombiner.cc:26
virtual void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
Definition: PlotCombiner.cc:22
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
PlotCombiner(const edm::ParameterSet &pset)
Definition: PlotCombiner.cc:31