CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMon.cc
Go to the documentation of this file.
5 
23 //copied mostly from HLTMuonDQMSource.cc
42 
46 
48 {
49 
50  LogDebug("HLTMon") << "constructor...." ;
51 
52  logFile_.open("HLTMon.log");
53 
54  dbe = NULL;
55  if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
57  dbe->setVerbose(0);
58  }
59 
60  outputFile_ =
61  iConfig.getUntrackedParameter < std::string > ("outputFile", "");
62  if (outputFile_.size() != 0) {
63  edm::LogInfo("HLTMon") << "L1T Monitoring histograms will be saved to "
64  << outputFile_ ;
65  }
66  else {
67  outputFile_ = "L1TDQM.root";
68  }
69 
70  bool disable =
71  iConfig.getUntrackedParameter < bool > ("disableROOToutput", false);
72  if (disable) {
73  outputFile_ = "";
74  }
75 
76  dirname_="HLT/HLTMon"+iConfig.getParameter<std::string>("@module_label");
77 
78  if (dbe != NULL) {
80  }
81 
82 
83  //plotting paramters
84  thePtMin = iConfig.getUntrackedParameter<double>("PtMin",0.);
85  thePtMax = iConfig.getUntrackedParameter<double>("PtMax",300.);
86  theNbins = iConfig.getUntrackedParameter<unsigned int>("Nbins",40);
87 
88  //info for each filter-step
89  reqNum = iConfig.getParameter<unsigned int>("reqNum");
90  std::vector<edm::ParameterSet> filters = iConfig.getParameter<std::vector<edm::ParameterSet> >("filters");
91 
92  for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++){
93  theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
94  theHLTOutputTypes.push_back(filterconf->getParameter<unsigned int>("theHLTOutputTypes"));
95  std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
96  assert(bounds.size() == 2);
97  plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
98  isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
99  assert(isoNames.back().size()>0);
100  if (isoNames.back().at(0).label()=="none")
101  plotiso.push_back(false);
102  else{
103  plotiso.push_back(true);
104  }
105  }
106 
107 }
108 
109 
111 {
112 
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 
116 }
117 
118 
119 //
120 // member functions
121 //
122 
123 // ------------ method called to for each event ------------
124 void
126 {
127 
128  nev_++;
129  LogDebug("HLTMon")<< "HLTMon: analyze...." ;
130 
132  iEvent.getByLabel("hltTriggerSummaryRAW",triggerObj); //Gets the data product which holds
133  if(!triggerObj.isValid()) { //all of the information.
134  edm::LogWarning("HLTMon") << "RAW-type HLT results not found, skipping event";
135  return;
136  }
137 
138  // total event number
139  total->Fill(theHLTCollectionLabels.size()+0.5);
140 
141  //Each individual "Collection Label" has a numbered category that can be found on doxygen
142  for(unsigned int n=0; n < theHLTCollectionLabels.size() ; n++) { //loop over filter modules
143  switch(theHLTOutputTypes[n]){
144  case 81: //L1 Muons
145  fillHistos<l1extra::L1MuonParticleCollection>(triggerObj,iEvent,n);break;
146  case 82: // non-iso L1
147  fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
148  case 83: // iso L1http://slashdot.org/
149  fillHistos<l1extra::L1EmParticleCollection>(triggerObj,iEvent,n);break;
150  case 84: //
151  fillHistos<l1extra::L1JetParticleCollection>(triggerObj,iEvent,n);break;
152  case 85: //
153  fillHistos<l1extra::L1JetParticleCollection>(triggerObj,iEvent,n);break;
154  case 91: //photon
155  fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
156  case 92: //electron
157  fillHistos<reco::ElectronCollection>(triggerObj,iEvent,n);break;
158  case 93: //Muon
159  fillHistos<reco::RecoChargedCandidateCollection>(triggerObj,iEvent,n);break;
160  case 95: //Jet
161  fillHistos<reco::CaloJetCollection>(triggerObj,iEvent,n);break;
162  case 97: //MET
163  fillHistos<reco::CaloMETCollection>(triggerObj,iEvent,n);break;
164  case 100: // TriggerCluster
165  fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,iEvent,n);break;
166  default: throw(cms::Exception("Release Validation Error")<< "HLT output type not implemented: theHLTOutputTypes[n]" );
167  }
168  }
169 }
170 
171 template <class T> void HLTMon::fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& triggerObj,const edm::Event& iEvent ,unsigned int n){
172 
173 
174  std::vector<edm::Ref<T> > particlecands;
175  // To keep track of what particlecands have passed a filter in TriggerEventWithRefs
176  // it adds the name to a list of filter names. To check whether a filter got passed,
177  // one just looks at its index in the list...if it is not there it (for some reason)
178  // returns the size of the list.
179  if (!( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if availabel
180  // retrieve saved filter objects
181  triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[n],particlecands);
182  //Danger: special case, L1 non-isolated
183  // needs to be merged with L1 iso
184  if(theHLTOutputTypes[n]==82){
185  std::vector<edm::Ref<T> > isocands;
186  triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),83,isocands);
187  if(isocands.size()>0)
188  for(unsigned int i=0; i < isocands.size(); i++)
189  particlecands.push_back(isocands[i]);
190  }
191 
192  //fill filter objects into histos
193  if (particlecands.size()!=0){
194  if(particlecands.size() >= reqNum )
195  total->Fill(n+0.5);
196  for (unsigned int i=0; i<particlecands.size() && particlecands[i].isAvailable(); i++) {
197  //unmatched
198  ethist[n]->Fill(particlecands[i]->et() );
199  etahist[n]->Fill(particlecands[i]->eta() );
200  phihist[n]->Fill(particlecands[i]->phi() );
201  eta_phihist[n]->Fill(particlecands[i]->eta(), particlecands[i]->phi() );
202 
203  //plot isolation variables (show not yet cut iso, i.e. associated to next filter)
204  if(n+1 < theHLTCollectionLabels.size()){ // can't plot beyond last
205  if(plotiso[n+1]){
206  for(unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
208  iEvent.getByLabel(isoNames[n+1].at(j).label(),depMap);
209  if(depMap.isValid()) {
210  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(particlecands[i]);
211  if(mapi!=depMap->end()){ // found candidate in isolation map!
212  etahistiso[n+1]->Fill(particlecands[i]->eta(),mapi->val);
213  ethistiso[n+1]->Fill(particlecands[i]->et(),mapi->val);
214  phihistiso[n+1]->Fill(particlecands[i]->phi(),mapi->val);
215  break; // to avoid multiple filling we only look until we found the candidate once.
216  }
217  } else {
218  edm::LogWarning("HLTMon") << "IsoName collection not found";
219  }
220  }
221  }
222  }
223  }
224  }
225  }
226 }
227 // ------------ method called once each job just before starting event loop ------------
228 void
230 {
231  nev_ = 0;
232  DQMStore *dbe = 0;
233  dbe = edm::Service < DQMStore > ().operator->();
234 
235  if (dbe) {
237  dbe->rmdir(dirname_);
238  }
239 
240 
241  if (dbe) {
243 
244  std::string histoname="total eff";
245  MonitorElement* tmphisto;
246 
247 
248  total = dbe->book1D(histoname.c_str(),histoname.c_str(),theHLTCollectionLabels.size()+1,0,theHLTCollectionLabels.size()+1);
249  total->setBinLabel(theHLTCollectionLabels.size()+1,"Total",1);
250  for (unsigned int u=0; u<theHLTCollectionLabels.size(); u++){total->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
251 
252  for(unsigned int i = 0; i< theHLTCollectionLabels.size() ; i++){
253  histoname = theHLTCollectionLabels[i].label()+"et";
254  //ability to customize histograms
255 /*
256  if(theHLTCollectionLabels[i].label() == "hltL1seedRelaxedSingleEt8")
257  {
258  thePtMinTemp = thePtMin;
259  thePtMaxTemp = thePtMax;
260  }
261  else if(theHLTCollectionLabels[i].label() == "hltL1NonIsoHLTNonIsoSingleElectronLWEt12L1MatchFilterRegional")
262  {
263  thePtMinTemp = thePtMin;
264  thePtMaxTemp = thePtMax;
265  }
266  else if(theHLTCollectionLabels[i].label() == "hltL1NonIsoHLTNonIsoSingleElectronLWEt12EtFilter")
267  {
268  thePtMinTemp = thePtMin;
269  thePtMaxTemp = thePtMax;
270  }
271  else if(theHLTCollectionLabels[i].label() == "hltL1NonIsoHLTNonIsoSingleElectronLWEt12HOneOEMinusOneOPFilter")
272  {
273  thePtMinTemp = thePtMin;
274  thePtMaxTemp = thePtMax;
275  }
276  else if(theHLTCollectionLabels[i].label() == "hltZMML2Filtered")
277  {
278  thePtMinTemp = thePtMin;
279  thePtMaxTemp = thePtMax;
280  }
281  else if(theHLTCollectionLabels[i].label() == "hltEMuL1MuonFilter")
282  {
283  thePtMinTemp = thePtMin;
284  thePtMaxTemp = thePtMax;
285  }
286  else
287  { */
290  //}
291  // Formatting of various plots.
292  histoTitle = theHLTCollectionLabels[i].label() + " Et";
293  tmphisto = dbe->book1D(histoname.c_str(),histoTitle.c_str(),theNbins,thePtMinTemp,thePtMaxTemp);
294  tmphisto->setAxisTitle("Number of Events", 2);
295  tmphisto->setAxisTitle("p_{T}", 1);
296  ethist.push_back(tmphisto);
297 
298  histoname = theHLTCollectionLabels[i].label()+"eta";
299  histoTitle = theHLTCollectionLabels[i].label() + " #eta";
300  tmphisto = dbe->book1D(histoname.c_str(),histoTitle.c_str(),theNbins,-2.7,2.7);
301  tmphisto->setAxisTitle("Number of Events", 2);
302  tmphisto->setAxisTitle("#eta", 1);
303  etahist.push_back(tmphisto);
304 
305  histoname = theHLTCollectionLabels[i].label()+"phi";
306  histoTitle = theHLTCollectionLabels[i].label() + " #phi";
307  tmphisto = dbe->book1D(histoname.c_str(),histoTitle.c_str(),theNbins,-3.14,3.14);
308  tmphisto->setAxisTitle("Number of Events", 2);
309  tmphisto->setAxisTitle("#phi", 1);
310  phihist.push_back(tmphisto);
311 
312  histoname = theHLTCollectionLabels[i].label()+"eta_phi";
313  histoTitle = theHLTCollectionLabels[i].label() + " #eta vs. #phi";
314  tmphisto = dbe->book2D(histoname.c_str(),histoTitle.c_str(),theNbins,-2.7,2.7, theNbins,
315  -3.14, 3.14);
316  tmphisto->setAxisTitle("#phi", 2);
317  tmphisto->setAxisTitle("#eta", 1);
318  eta_phihist.push_back(tmphisto);
319 
320  if(plotiso[i]){
321  histoname = theHLTCollectionLabels[i].label()+"eta isolation";
322  tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-2.7,2.7,theNbins,plotBounds[i].first,plotBounds[i].second);
323  }
324  else{
325  tmphisto = NULL;
326  }
327  etahistiso.push_back(tmphisto);
328 
329  if(plotiso[i]){
330  histoname = theHLTCollectionLabels[i].label()+"et isolation";
331  tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,thePtMin,thePtMax,theNbins,plotBounds[i].first,plotBounds[i].second);
332  }
333  else{
334  tmphisto = NULL;
335  }
336  ethistiso.push_back(tmphisto);
337 
338 
339  if(plotiso[i]){
340  histoname = theHLTCollectionLabels[i].label()+"phi isolation";
341  tmphisto = dbe->book2D(histoname.c_str(),histoname.c_str(),theNbins,-3.14,3.14,theNbins,plotBounds[i].first,plotBounds[i].second);
342  }
343  else{
344  tmphisto = NULL;
345  }
346  phihistiso.push_back(tmphisto);
347 
348 
349  }
350  } // end "if(dbe)"
351 }
352 
353 // ------------ method called once each job just after ending the event loop ------------
354 void
356 
357 // std::cout << "HLTMonElectron: end job...." << std::endl;
358  edm::LogInfo("HLTMon") << "analyzed " << nev_ << " events";
359 
360  if (outputFile_.size() != 0 && dbe)
361  dbe->save(outputFile_);
362 
363  return;
364 }
365 
366 //DEFINE_FWK_MODULE(HLTMonElectron);
#define LogDebug(id)
std::vector< std::pair< double, double > > plotBounds
Definition: HLTMon.h:79
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > eta_phihist
Definition: HLTMon.h:70
std::vector< MonitorElement * > etahistiso
Definition: HLTMon.h:71
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
double thePtMaxTemp
Definition: HLTMon.h:85
unsigned int reqNum
Definition: HLTMon.h:80
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::vector< MonitorElement * > phihist
Definition: HLTMon.h:69
#define NULL
Definition: scimark2.h:8
T eta() const
std::string outputFile_
Definition: HLTMon.h:92
double thePtMin
Definition: HLTMon.h:82
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
std::string dirname_
Definition: HLTMon.h:88
void Fill(long long x)
MonitorElement * total
Definition: HLTMon.h:74
std::string histoTitle
Definition: HLTMon.h:94
int iEvent
Definition: GenABIO.cc:243
virtual void endJob()
Definition: HLTMon.cc:355
~HLTMon()
Definition: HLTMon.cc:110
std::vector< MonitorElement * > phihistiso
Definition: HLTMon.h:73
std::vector< bool > plotiso
Definition: HLTMon.h:77
virtual void beginJob()
Definition: HLTMon.cc:229
int j
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > etahist
Definition: HLTMon.h:67
std::vector< MonitorElement * > ethistiso
Definition: HLTMon.h:72
DQMStore * dbe
Definition: HLTMon.h:66
void setVerbose(unsigned level)
Definition: DQMStore.cc:393
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< MonitorElement * > ethist
Definition: HLTMon.h:68
double thePtMax
Definition: HLTMon.h:83
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int)
Definition: HLTMon.cc:171
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: HLTMon.cc:125
HLTMon(const edm::ParameterSet &)
Definition: HLTMon.cc:47
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: HLTMon.h:75
std::vector< int > theHLTOutputTypes
Definition: HLTMon.h:76
double thePtMinTemp
Definition: HLTMon.h:84
int nev_
Definition: HLTMon.h:65
ofstream logFile_
Definition: HLTMon.h:90
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 setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
std::vector< std::vector< edm::InputTag > > isoNames
Definition: HLTMon.h:78
unsigned int theNbins
Definition: HLTMon.h:86
list at
Definition: asciidump.py:428
Definition: DDAxes.h:10