CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetMETDQMOfflineClient.cc
Go to the documentation of this file.
2 
7 
10 
12 {
13 
15  if (!dbe_) {
16  edm::LogError("JetMETDQMOfflineClient")
17  << "unable to get DQMStore service, upshot is no client histograms will be made";
18  }
19  if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
20  if(dbe_) dbe_->setVerbose(0);
21  }
22 
23  verbose_ = conf_.getUntrackedParameter<int>("Verbose");
24 
25  dirName_=iConfig.getUntrackedParameter<std::string>("DQMDirName");
26  if(dbe_) dbe_->setCurrentFolder(dirName_);
27 
28  dirNameJet_=iConfig.getUntrackedParameter<std::string>("DQMJetDirName");
29  dirNameMET_=iConfig.getUntrackedParameter<std::string>("DQMMETDirName");
30 
31 }
32 
33 
35 {
36 
37 }
38 
40 {
41 
42 
43 }
44 
46 {
47 
48 }
49 
51 {
52 
53 }
54 
55 
57 {
58  runClient_();
59 }
60 
61 //dummy analysis function
63 {
64 
65 }
66 
68 {
69 
70 }
71 
73 {
74 
75  if(!dbe_) return; //we dont have the DQMStore so we cant do anything
76 
77  LogDebug("JetMETDQMOfflineClient") << "runClient" << std::endl;
78  if (verbose_) std::cout << "runClient" << std::endl;
79 
80  std::vector<MonitorElement*> MEs;
81 
83  // Total number of lumi sections and time for this run
85 
86  TH1F* tlumisec;
87  MonitorElement *meLumiSec = dbe_->get("JetMET/lumisec");
88 
89  int totlsec=0;
90  double totltime=0;
91 
92  if ( meLumiSec->getRootObject() ){
93 
94  tlumisec = meLumiSec->getTH1F();
95  for (int i=0; i<500; i++){
96  if (tlumisec->GetBinContent(i+1)) totlsec++;
97  }
98 
99  }
100  totltime = totlsec * 90.;
101 
103  // MET
105 
107 
108  MonitorElement *me;
109  TH1F *tMET;
110  TH1F *tMETRate;
111  MonitorElement *hMETRate;
112 
113  //
114  // --- Producing MET rate plots
115  //
116 
117  // Look at all folders (JetMET/MET/CaloMET, JetMET/MET/CaloMETNoHF, etc)
118  std::vector<std::string> fullPathDQMFolders = dbe_->getSubdirs();
119  for(unsigned int i=0;i<fullPathDQMFolders.size();i++) {
120 
121  if (verbose_) std::cout << fullPathDQMFolders[i] << std::endl;
122  dbe_->setCurrentFolder(fullPathDQMFolders[i]);
123 
124  // Look at all subfolders (JetMET/MET/CaloMET/{All,Cleaup,BeamHaloIDLoosePass, etc})
125  std::vector<std::string> fullPathDQMSubFolders = dbe_->getSubdirs();
126  for(unsigned int j=0;j<fullPathDQMSubFolders.size();j++) {
127 
128  if (verbose_) std::cout << fullPathDQMSubFolders[j] << std::endl;
129  dbe_->setCurrentFolder(fullPathDQMSubFolders[j]);
130  if (verbose_) std::cout << "setCurrentFolder done" << std::endl;
131 
132  // Look at all MonitorElements in this folder
133  std::string METMEName="METTask_CaloMET";
134  if ( dbe_->get(fullPathDQMSubFolders[j]+"/"+"METTask_MET") ) METMEName="METTask_MET";
135  if ( dbe_->get(fullPathDQMSubFolders[j]+"/"+"METTask_PfMET")) METMEName="METTask_PfMET";
136 
137  me = dbe_->get(fullPathDQMSubFolders[j]+"/"+METMEName);
138  if (verbose_) std::cout << "get done" << std::endl;
139 
140  if ( me ) {
141  if (verbose_) std::cout << "me true" << std::endl;
142  if ( me->getRootObject() ) {
143  if (verbose_) std::cout << "me getRootObject true" << std::endl;
144 
145  MonitorElement *metest = dbe_->get(fullPathDQMSubFolders[j]+"/"+METMEName+"Rate");
146  if (metest) dbe_->removeElement(METMEName+"Rate");
147 
148  if (verbose_) std::cout << "metest done" << std::endl;
149 
150  tMET = me->getTH1F();
151  if (verbose_) std::cout << "getTH1F done" << std::endl;
152 
153  // Integral plot
154  tMETRate = (TH1F*) tMET->Clone((METMEName+"Rate").c_str());
155  for (int i = tMETRate->GetNbinsX()-1; i>=0; i--){
156  tMETRate->SetBinContent(i+1,tMETRate->GetBinContent(i+2)+tMET->GetBinContent(i+1));
157  }
158  if (verbose_) std::cout << "making integral plot done" << std::endl;
159 
160  // Convert number of events to Rate (Hz)
161  if (totltime){
162  for (int i=tMETRate->GetNbinsX()-1;i>=0;i--){
163  tMETRate->SetBinContent(i+1,tMETRate->GetBinContent(i+1)/double(totltime));
164  }
165  }
166  if (verbose_) std::cout << "making rate plot done" << std::endl;
167 
168  hMETRate = dbe_->book1D(METMEName+"Rate",tMETRate);
169  hMETRate->setTitle(METMEName+" Rate");
170  hMETRate->setAxisTitle("MET Threshold [GeV]",1);
171  if (verbose_) std::cout << "booking rate plot ME done" << std::endl;
172 
173  } // me->getRootObject()
174  } // me
175  if (verbose_) std::cout << "end of subfolder loop" << std::endl;
176  } // fullPathDQMSubFolders-loop - All, Cleanup, ...
177  if (verbose_) std::cout << "end of folder loop" << std::endl;
178  } // fullPathDQMFolders-loop - CaloMET, CaloMETNoHF, ...
179 
181  // Jet
183 
185 
186  // Look at all folders (JetMET/Jet/AntiKtJets,JetMET/Jet/CleanedAntiKtJets, etc)
187  fullPathDQMFolders.clear();
188  fullPathDQMFolders = dbe_->getSubdirs();
189  for(unsigned int i=0;i<fullPathDQMFolders.size();i++) {
190 
191  if (verbose_) std::cout << fullPathDQMFolders[i] << std::endl;
192  dbe_->setCurrentFolder(fullPathDQMFolders[i]);
193 
194  std::vector<std::string> getMEs = dbe_->getMEs();
195 
196  std::vector<std::string>::const_iterator cii;
197  for(cii=getMEs.begin(); cii!=getMEs.end(); cii++) {
198  if ((*cii).find("_binom")!=std::string::npos) continue;
199  if ((*cii).find("JIDPassFractionVS")!=std::string::npos){ // Look for MEs with "JIDPassFractionVS"
200  me = dbe_->get(fullPathDQMFolders[i]+"/"+(*cii));
201 
202  if ( me ) {
203  if ( me->getRootObject() ) {
204  TProfile *tpro = (TProfile*) me->getRootObject();
205  TH1F *tPassFraction = new TH1F(((*cii)+"_binom").c_str(),((*cii)+"_binom").c_str(),
206  tpro->GetNbinsX(),tpro->GetBinLowEdge(1),tpro->GetBinLowEdge(tpro->GetNbinsX()+1));
207  for (int ibin=0; ibin<tpro->GetNbinsX(); ibin++){
208  double nentries = tpro->GetBinEntries(ibin+1);
209  double epsilon = tpro->GetBinContent(ibin+1);
210  if (epsilon>1. || epsilon<0.) continue;
211  tPassFraction->SetBinContent(ibin+1,epsilon); //
212  if(nentries>0) tPassFraction->SetBinError(ibin+1,pow(epsilon*(1.-epsilon)/nentries,0.5));
213  }
214  } // me->getRootObject()
215  } // me
216  } // if find
217  } // cii-loop
218 
219  } // i-loop
220 
221 }
222 
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1424
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
int iEvent
Definition: GenABIO.cc:243
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
int j
Definition: DBlmapReader.cc:9
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void setVerbose(unsigned level)
Definition: DQMStore.cc:398
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
virtual void endRun(const edm::Run &run, const edm::EventSetup &c)
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
TObject * getRootObject(void) const
TH1F * getTH1F(void) const
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1447
JetMETDQMOfflineClient(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
tuple cout
Definition: gather_cfg.py:121
const double epsilon
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36