CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMonElectron.cc
Go to the documentation of this file.
5 
23 
24 using namespace edm;
25 
27 {
28 
29  LogDebug("HLTMonElectron") << "constructor...." ;
30 
31  logFile_.open("HLTMonElectron.log");
32 
33  dbe = NULL;
34  if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
35  dbe = Service < DQMStore > ().operator->();
36  dbe->setVerbose(0);
37  }
38 
39  outputFile_ =
40  iConfig.getUntrackedParameter < std::string > ("outputFile", "");
41  if (outputFile_.size() != 0) {
42  LogInfo("HLTMonElectron") << "L1T Monitoring histograms will be saved to "
43  << outputFile_ ;
44  }
45  else {
46  outputFile_ = "L1TDQM.root";
47  }
48 
49  bool disable =
50  iConfig.getUntrackedParameter < bool > ("disableROOToutput", false);
51  if (disable) {
52  outputFile_ = "";
53  }
54 
55  dirname_="HLT/HLTMonElectron/"+iConfig.getParameter<std::string>("@module_label");
56 
57  if (dbe != NULL) {
58  dbe->setCurrentFolder(dirname_);
59  }
60 
61 
62  //plotting paramters
63  thePtMin = iConfig.getUntrackedParameter<double>("PtMin",0.);
64  thePtMax = iConfig.getUntrackedParameter<double>("PtMax",1000.);
65  theNbins = iConfig.getUntrackedParameter<unsigned int>("Nbins",40);
66 
67  //info for each filter-step
68  reqNum = iConfig.getParameter<unsigned int>("reqNum");
69  std::vector<edm::ParameterSet> filters = iConfig.getParameter<std::vector<edm::ParameterSet> >("filters");
70 
71  for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++){
72  theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
73  theHLTOutputTypes.push_back(filterconf->getParameter<unsigned int>("theHLTOutputTypes"));
74  std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
75  assert(bounds.size() == 2);
76  plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
77  isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
78  assert(isoNames.back().size()>0);
79  if (isoNames.back().at(0).label()=="none")
80  plotiso.push_back(false);
81  else{
82  plotiso.push_back(true);
83  }
84  }
85 
86 }
87 
88 
90 {
91 
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 
95 }
96 
97 
98 //
99 // member functions
100 //
101 
102 // ------------ method called to for each event ------------
103 void
105 {
106  using namespace edm;
107  using namespace trigger;
108  nev_++;
109  LogDebug("HLTMonElectron")<< "HLTMonElectron: analyze...." ;
110 
111 
113  iEvent.getByLabel("hltTriggerSummaryRAW",triggerObj);
114  if(!triggerObj.isValid()) {
115  edm::LogWarning("HLTMonElectron") << "RAW-type HLT results not found, skipping event";
116  return;
117  }
118 
119  // total event number
120  total->Fill(theHLTCollectionLabels.size()+0.5);
121 
122 
123  for(unsigned int n=0; n < theHLTCollectionLabels.size() ; n++) { //loop over filter modules
124  switch(theHLTOutputTypes[n]){
125  case 82: // non-iso L1
126  fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
127  case 83: // iso L1
128  fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
129  case 91: //photon
130  fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
131  case 92: //electron
132  fillHistos<reco::ElectronCollection>(triggerObj,iEvent,n);break;
133  case 100: // TriggerCluster
134  fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
135  default: throw(cms::Exception("Release Validation Error")<< "HLT output type not implemented: theHLTOutputTypes[n]" );
136  }
137  }
138 }
139 
140 template <class T> void HLTMonElectron::fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& triggerObj,const edm::Event& iEvent ,unsigned int n){
141 
142  std::vector<edm::Ref<T> > recoecalcands;
143  if (!( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if availabel
144 
145  // retrieve saved filter objects
146  triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[n],recoecalcands);
147  //Danger: special case, L1 non-isolated
148  // needs to be merged with L1 iso
149  if(theHLTOutputTypes[n]==82){
150  std::vector<edm::Ref<T> > isocands;
151  triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),83,isocands);
152  if(isocands.size()>0)
153  for(unsigned int i=0; i < isocands.size(); i++)
154  recoecalcands.push_back(isocands[i]);
155  }
156 
157 
158  //fill filter objects into histos
159  if (recoecalcands.size()!=0){
160  if(recoecalcands.size() >= reqNum )
161  total->Fill(n+0.5);
162  for (unsigned int i=0; i<recoecalcands.size(); i++) {
163  //unmatched
164  ethist[n]->Fill(recoecalcands[i]->et() );
165  phihist[n]->Fill(recoecalcands[i]->phi() );
166  etahist[n]->Fill(recoecalcands[i]->eta() );
167 
168 
169  //plot isolation variables (show not yet cut iso, i.e. associated to next filter)
170  if(n+1 < theHLTCollectionLabels.size()){ // can't plot beyond last
171  if(plotiso[n+1]){
172  for(unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
174  iEvent.getByLabel(isoNames[n+1].at(j).label(),depMap);
175  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
176  if(mapi!=depMap->end()){ // found candidate in isolation map!
177  etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
178  phihistiso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
179  ethistiso[n+1]->Fill(recoecalcands[i]->et(),mapi->val);
180  break; // to avoid multiple filling we only look until we found the candidate once.
181  }
182  }
183  }
184  }
185  }
186  }
187  }
188 }
189 // ------------ method called once each job just before starting event loop ------------
190 void
192 {
193  nev_ = 0;
194  DQMStore *dbe = 0;
195  dbe = Service < DQMStore > ().operator->();
196 
197  if (dbe) {
198  dbe->setCurrentFolder(dirname_);
199  dbe->rmdir(dirname_);
200  }
201 
202 
203  if (dbe) {
204  dbe->setCurrentFolder(dirname_);
205 
206  std::string histoname="total eff";
207  MonitorElement* tmphisto;
208 
209 
210  total = dbe->book1D(histoname.c_str(),histoname.c_str(),theHLTCollectionLabels.size()+1,0,theHLTCollectionLabels.size()+1);
211  total->setBinLabel(theHLTCollectionLabels.size()+1,"Total",1);
212  for (unsigned int u=0; u<theHLTCollectionLabels.size(); u++){total->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
213 
214 
215  for(unsigned int i = 0; i< theHLTCollectionLabels.size() ; i++){
216  histoname = theHLTCollectionLabels[i].label()+"et";
217  tmphisto = dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax);
218  ethist.push_back(tmphisto);
219 
220  histoname = theHLTCollectionLabels[i].label()+"eta";
221  tmphisto = dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7);
222  etahist.push_back(tmphisto);
223 
224  histoname = theHLTCollectionLabels[i].label()+"phi";
225  tmphisto = dbe->book1D(histoname.c_str(),histoname.c_str(),theNbins,-3.2,3.2);
226  phihist.push_back(tmphisto);
227 
228  if(plotiso[i]){
229  histoname = theHLTCollectionLabels[i].label()+"eta isolation";
230  tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7,theNbins,plotBounds[i].first,plotBounds[i].second);
231  }
232  else{
233  tmphisto = NULL;
234  }
235  etahistiso.push_back(tmphisto);
236 
237  if(plotiso[i]){
238  histoname = theHLTCollectionLabels[i].label()+"phi isolation";
239  tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-3.2,3.2,theNbins,plotBounds[i].first,plotBounds[i].second);
240  }
241  else{
242  tmphisto = NULL;
243  }
244  phihistiso.push_back(tmphisto);
245 
246  if(plotiso[i]){
247  histoname = theHLTCollectionLabels[i].label()+"et isolation";
248  tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax,theNbins,plotBounds[i].first,plotBounds[i].second);
249  }
250  else{
251  tmphisto = NULL;
252  }
253  ethistiso.push_back(tmphisto);
254 
255 
256  }
257  } // end "if(dbe)"
258 }
259 
260 // ------------ method called once each job just after ending the event loop ------------
261 void
263 
264 // std::cout << "HLTMonElectron: end job...." << std::endl;
265  LogInfo("HLTMonElectron") << "analyzed " << nev_ << " events";
266 
267  if (outputFile_.size() != 0 && dbe)
268  dbe->save(outputFile_);
269 
270  return;
271 }
272 
273 //DEFINE_FWK_MODULE(HLTMonElectron);
#define LogDebug(id)
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:722
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2535
#define NULL
Definition: scimark2.h:8
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T eta() const
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
int iEvent
Definition: GenABIO.cc:243
HLTMonElectron(const edm::ParameterSet &)
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual void beginJob()
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int)
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:850
virtual void endJob()
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
list at
Definition: asciidump.py:428
Definition: DDAxes.h:10