CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
JetMETDQMOfflineClient Class Reference

#include <JetMETDQMOfflineClient.h>

Inheritance diagram for JetMETDQMOfflineClient:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob (void)
 
virtual void beginRun (const edm::Run &run, const edm::EventSetup &c)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
 
virtual void endRun (const edm::Run &run, const edm::EventSetup &c)
 
 JetMETDQMOfflineClient (const edm::ParameterSet &)
 
virtual void runClient_ ()
 
virtual ~JetMETDQMOfflineClient ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

edm::ParameterSet conf_
 
DQMStoredbe_
 
std::string dirName_
 
std::string dirNameJet_
 
std::string dirNameMET_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 48 of file JetMETDQMOfflineClient.h.

Constructor & Destructor Documentation

JetMETDQMOfflineClient::JetMETDQMOfflineClient ( const edm::ParameterSet iConfig)
explicit

Definition at line 11 of file JetMETDQMOfflineClient.cc.

References conf_, dbe_, dirName_, dirNameJet_, dirNameMET_, edm::ParameterSet::getUntrackedParameter(), cmsCodeRules.cppFunctionSkipper::operator, DQMStore::setCurrentFolder(), DQMStore::setVerbose(), and verbose_.

11  :conf_(iConfig)
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 }
T getUntrackedParameter(std::string const &, T const &) const
void setVerbose(unsigned level)
Definition: DQMStore.cc:201
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
JetMETDQMOfflineClient::~JetMETDQMOfflineClient ( )
virtual

Definition at line 34 of file JetMETDQMOfflineClient.cc.

35 {
36 
37 }

Member Function Documentation

void JetMETDQMOfflineClient::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 62 of file JetMETDQMOfflineClient.cc.

63 {
64 
65 }
void JetMETDQMOfflineClient::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file JetMETDQMOfflineClient.cc.

40 {
41 
42 
43 }
void JetMETDQMOfflineClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file JetMETDQMOfflineClient.cc.

51 {
52 
53 }
void JetMETDQMOfflineClient::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 45 of file JetMETDQMOfflineClient.cc.

46 {
47 
48 }
void JetMETDQMOfflineClient::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file JetMETDQMOfflineClient.cc.

68 {
69 
70 }
void JetMETDQMOfflineClient::endRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file JetMETDQMOfflineClient.cc.

References runClient_().

57 {
58  runClient_();
59 }
void JetMETDQMOfflineClient::runClient_ ( )
virtual

Definition at line 72 of file JetMETDQMOfflineClient.cc.

References DQMStore::book1D(), gather_cfg::cout, dbe_, dirName_, dirNameJet_, dirNameMET_, epsilon, DQMStore::get(), DQMStore::getMEs(), MonitorElement::getRootObject(), DQMStore::getSubdirs(), MonitorElement::getTH1F(), i, j, LogDebug, funct::pow(), DQMStore::removeElement(), MonitorElement::setAxisTitle(), DQMStore::setCurrentFolder(), MonitorElement::setTitle(), and verbose_.

Referenced by endRun().

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  MonitorElement *hPassFraction;
187 
188  // Look at all folders (JetMET/Jet/AntiKtJets,JetMET/Jet/CleanedAntiKtJets, etc)
189  fullPathDQMFolders.clear();
190  fullPathDQMFolders = dbe_->getSubdirs();
191  for(unsigned int i=0;i<fullPathDQMFolders.size();i++) {
192 
193  if (verbose_) std::cout << fullPathDQMFolders[i] << std::endl;
194  dbe_->setCurrentFolder(fullPathDQMFolders[i]);
195 
196  std::vector<std::string> getMEs = dbe_->getMEs();
197 
198  std::vector<std::string>::const_iterator cii;
199  for(cii=getMEs.begin(); cii!=getMEs.end(); cii++) {
200  if ((*cii).find("_binom")!=std::string::npos) continue;
201  if ((*cii).find("JIDPassFractionVS")!=std::string::npos){ // Look for MEs with "JIDPassFractionVS"
202  me = dbe_->get(fullPathDQMFolders[i]+"/"+(*cii));
203 
204  if ( me ) {
205  if ( me->getRootObject() ) {
206  TProfile *tpro = (TProfile*) me->getRootObject();
207  TH1F *tPassFraction = new TH1F(((*cii)+"_binom").c_str(),((*cii)+"_binom").c_str(),
208  tpro->GetNbinsX(),tpro->GetBinLowEdge(1),tpro->GetBinLowEdge(tpro->GetNbinsX()+1));
209  for (int ibin=0; ibin<tpro->GetNbinsX(); ibin++){
210  double nentries = tpro->GetBinEntries(ibin+1);
211  double epsilon = tpro->GetBinContent(ibin+1);
212  if (epsilon>1. || epsilon<0.) continue;
213  tPassFraction->SetBinContent(ibin+1,epsilon); //
214  if(nentries>0) tPassFraction->SetBinError(ibin+1,pow(epsilon*(1.-epsilon)/nentries,0.5));
215  }
216  hPassFraction = dbe_->book1D(tPassFraction->GetName(),tPassFraction);
217  delete tPassFraction;
218  } // me->getRootObject()
219  } // me
220  } // if find
221  } // cii-loop
222 
223  } // i-loop
224 
225 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1221
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
void removeElement(const std::string &name)
Definition: DQMStore.cc:2338
int j
Definition: DBlmapReader.cc:9
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1270
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:1244
tuple cout
Definition: gather_cfg.py:41
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:237

Member Data Documentation

edm::ParameterSet JetMETDQMOfflineClient::conf_
private

Definition at line 53 of file JetMETDQMOfflineClient.h.

Referenced by JetMETDQMOfflineClient().

DQMStore* JetMETDQMOfflineClient::dbe_
private

Definition at line 51 of file JetMETDQMOfflineClient.h.

Referenced by JetMETDQMOfflineClient(), and runClient_().

std::string JetMETDQMOfflineClient::dirName_
private

Definition at line 57 of file JetMETDQMOfflineClient.h.

Referenced by JetMETDQMOfflineClient(), and runClient_().

std::string JetMETDQMOfflineClient::dirNameJet_
private

Definition at line 58 of file JetMETDQMOfflineClient.h.

Referenced by JetMETDQMOfflineClient(), and runClient_().

std::string JetMETDQMOfflineClient::dirNameMET_
private

Definition at line 59 of file JetMETDQMOfflineClient.h.

Referenced by JetMETDQMOfflineClient(), and runClient_().

bool JetMETDQMOfflineClient::verbose_
private

Definition at line 55 of file JetMETDQMOfflineClient.h.

Referenced by JetMETDQMOfflineClient(), and runClient_().