CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopElectronHLTOfflineClient.cc
Go to the documentation of this file.
2 
3 
8 
10 
13 
14 
16 {
18 
19  if (!dbe_)
20  {
21  edm::LogError("TopElectronHLTOfflineClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
22  }
23 
24  if(iConfig.getUntrackedParameter<bool>("DQMStore", false))
25  {
26  if (dbe_) dbe_->setVerbose(0);
27  }
28 
29  dirName_=iConfig.getParameter<std::string>("DQMDirName");
30 
31  if (dbe_)
33 
34  hltTag_ = iConfig.getParameter<std::string>("hltTag");
35 
36  electronIdNames_ = iConfig.getParameter<std::vector<std::string> >("electronIdNames");
37  superTriggerNames_ = iConfig.getParameter<std::vector<std::string> >("superTriggerNames");
38  electronTriggerNames_ = iConfig.getParameter<std::vector<std::string> >("electronTriggerNames");
39  addExtraId_ = iConfig.getParameter<bool>("addExtraId");
40 
41  runClientEndLumiBlock_ = iConfig.getParameter<bool>("runClientEndLumiBlock");
42  runClientEndRun_ = iConfig.getParameter<bool>("runClientEndRun");
43  runClientEndJob_ = iConfig.getParameter<bool>("runClientEndJob");
44 
45 }
46 
47 
49 {
50 }
51 
53 {
54  //compose the ME names we need
55 
56  // Eta regions
57  std::vector<std::string> regions;
58  regions.push_back("EB");
59  regions.push_back("EE");
60 
61  // Electron IDs, including own extra ID
62  std::vector<std::string> eleIdNames;
63  for (size_t i = 0; i < electronIdNames_.size(); ++i)
64  {
65  eleIdNames.push_back(electronIdNames_[i]);
66  if (addExtraId_)
67  eleIdNames.push_back(electronIdNames_[i]+"extraId");
68  }
69 
70  std::vector<std::string> vars;
71  vars.push_back("_et");
72  vars.push_back("_eta");
73  vars.push_back("_phi");
74  vars.push_back("_isolEm");
75  vars.push_back("_isolHad");
76  vars.push_back("_minDeltaR");
77  vars.push_back("_global_n30jets");
78  vars.push_back("_global_sumEt");
79  vars.push_back("_gsftrack_etaError");
80  vars.push_back("_gsftrack_phiError");
81  vars.push_back("_gsftrack_numberOfValidHits");
82  vars.push_back("_gsftrack_dzPV");
83 
84 
85  for (size_t i = 0; i < eleIdNames.size(); ++i)
86  for (size_t j = 0; j < regions.size(); ++j)
87  for (size_t k = 0; k < vars.size(); ++k)
88  for (size_t l = 0; l < superTriggerNames_.size(); ++l)
89  {
90  superMeNames_.push_back("ele_"+superTriggerNames_[l]+"_"+regions[j]+"_"+eleIdNames[i]+vars[k] );
91  for (size_t m = 0; m < electronTriggerNames_.size(); ++m)
92  {
93  eleMeNames_.push_back("ele_"+superTriggerNames_[l]+"_"+electronTriggerNames_[m] +"_"+regions[j]+"_"+eleIdNames[i]+vars[k]);
94  }
95  }
96 
97 
98 
99 }
100 
102 {
103  if(runClientEndJob_)
104  runClient_();
105 }
106 
108 {
109 }
110 
111 
113 {
114  if(runClientEndRun_)
115  runClient_();
116 }
117 
118 //dummy analysis function
120 {
121 }
122 
124 {
126  runClient_();
127 }
128 
130 {
131  if (!dbe_) return; //we dont have the DQMStore so we cant do anything
133 
134  size_t k = 0;
135  for (size_t i = 0; i < superMeNames_.size(); ++i)
136  {
137  for (size_t j = 0; j < electronTriggerNames_.size(); ++j)
138  {
139  if (k >= eleMeNames_.size())
140  continue;
142  ++k;
143  }
144  }
145  superTriggerNames_.size();
146  electronTriggerNames_.size();
147 
148 
149 }
150 
151 void TopElectronHLTOfflineClient::createSingleEffHists(const std::string& denomName, const std::string& nomName, const std::string& effName)
152 {
153  MonitorElement* denom = dbe_->get(dirName_+"/"+denomName);
154 
155  MonitorElement* nom = dbe_->get(dirName_+"/"+nomName);
156  if(nom!=NULL && denom!=NULL)
157  {
158 
159  makeEffMonElemFromPassAndAll(effName, nom, denom);
160  }
161 }
162 
163 
165 {
166  TH1F* passHist = pass->getTH1F();
167  if(passHist->GetSumw2N()==0)
168  passHist->Sumw2();
169  TH1F* allHist = all->getTH1F();
170  if(allHist->GetSumw2N()==0)
171  allHist->Sumw2();
172 
173  TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
174  effHist->Divide(passHist,allHist,1,1,"B");
175 
176  MonitorElement* eff = dbe_->get(dirName_+"/"+name);
177  if(eff==NULL)
178  {
179  eff= dbe_->book1D(name,effHist);
180  }
181  else
182  { //I was having problems with collating the histograms, hence why I'm just reseting the histogram value
183  *eff->getTH1F()=*effHist;
184  delete effHist;
185  }
186  return eff;
187 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
std::vector< std::string > superMeNames_
TopElectronHLTOfflineClient(const TopElectronHLTOfflineClient &rhs)
#define NULL
Definition: scimark2.h:8
virtual void endRun(const edm::Run &run, const edm::EventSetup &c)
std::vector< std::string > electronIdNames_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * makeEffMonElemFromPassAndAll(const std::string &name, const MonitorElement *pass, const MonitorElement *fail)
int iEvent
Definition: GenABIO.cc:230
std::vector< std::string > electronTriggerNames_
int j
Definition: DBlmapReader.cc:9
void setVerbose(unsigned level)
Definition: DQMStore.cc:631
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1708
DQMStore * dbe_
int k[5][pyjets_maxn]
void createSingleEffHists(const std::string &, const std::string &, const std::string &)
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
std::vector< std::string > superTriggerNames_
TH1F * getTH1F(void) const
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
std::vector< std::string > eleMeNames_
Definition: Run.h:41