CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTopPlotter.cc
Go to the documentation of this file.
1 
17 
18 
19 
20 
22 
32 
33 
34 // For storing calorimeter isolation info in the ntuple
37 
39 
40 #include "TPRegexp.h"
41 #include <iostream>
42 
43 using namespace std;
44 using namespace edm;
45 using namespace reco;
46 using namespace trigger;
47 using namespace l1extra;
48 
49 //using HLTMuonMatchAndPlot::MatchStruct;
50 
51 typedef std::vector< edm::ParameterSet > Parameters;
52 typedef std::vector<reco::Muon> MuonCollection;
53 
54 // const int numCones = 3;
55 // const int numMinPtCuts = 1;
56 // double coneSizes[] = { 0.20, 0.24, 0.30 };
57 // double minPtCuts[] = { 0. };
58 
59 
62 ( const ParameterSet& pset, string triggerName, vector<string> moduleNames,
63  MuonSelectionStruct inputSelection, string customName,
64  vector<string> validTriggers,
65  const edm::Run & currentRun,
66  const edm::EventSetup & currentEventSetup)
67  : HLTMuonMatchAndPlot(pset, triggerName, moduleNames, inputSelection, customName, validTriggers, currentRun, currentEventSetup)
68 
69 {
70 
71  CaloJetInputTag = pset.getParameter<edm::InputTag>("CaloJetInputTag");
72  EtaCut_ = pset.getUntrackedParameter<double>("EtaCut");
73  PtCut_ = pset.getUntrackedParameter<double>("PtCut");
74  NJets_ = pset.getUntrackedParameter<int>("NJets");
75  theJetMParameters = pset.getUntrackedParameter< vector<double> >("JetMParameters");
76 
77 
78  LogTrace ("HLTMuonVal") << "\n\n Inside HLTTopPlotter Constructor";
79  LogTrace ("HLTMuonVal") << "The trigger name is " << triggerName
80  << "and we've done all the other intitializations";
81 
82  LogTrace ("HLTMuonVal") << "exiting constructor\n\n";
83 
84 }
85 
86 
87 
89 {
90 
91  // you could do something else in here
92  // but for now, just do what the base class
93  // would have done
94 
96 }
97 
98 
99 
101 {
102 
103  LogTrace ("HLTMuonVal") << "Inside of TopPlotter analyze method!"
104  << "calling my match and plot module's analyze..."
105  << endl;
106 
107  // Make sure you are valid before proceeding
108 
109 
110  // Do some top specific selection, then call the muon matching
111  // if the event looks top-like
112 
113  LogTrace ("HLTMuonVal") << "Do top-specific selection" << endl;
114 
115 
116  // get calo jet collection
117  Handle<CaloJetCollection> jetsHandle;
118  iEvent.getByLabel(CaloJetInputTag, jetsHandle);
119 
120  int n_jets_20 = 0;
121  CaloJetCollection selectedJets;
122 
123  if (jetsHandle.isValid()) {
124  LogTrace ("HLTMuonVal") << "Looking in jet collection" << endl;
125  //Jet Collection to use
126 
127  // Raw jets
128  const CaloJetCollection *jets = jetsHandle.product();
129  CaloJetCollection::const_iterator jet;
130 
131  //int n_jets_20=0;
132 
133  // The parameters for the n jets should be
134 
135 
136  for (jet = jets->begin(); jet != jets->end(); jet++){
137  // if (fabs(jet->eta()) <2.4 && jet->et() > 20) n_jets_20++;
138  if (fabs(jet->eta()) <EtaCut_ && jet->et() > PtCut_) {
139  n_jets_20++;
140  selectedJets.push_back((*jet));
141  }
142 
143  }
144 
145  }
146 
147 
148 
149  // sort the result
150  sortJets(selectedJets);
151 
152 
153 
154  LogTrace ("HLTMuonVal") << "Number of jets in this event = "
155  << n_jets_20
156  << endl;
157 
158  // if (n_jets_20 <= 1 ) {
159  if (n_jets_20 < NJets_ ) {
160  LogTrace ("HLTMuonVal") << "Not enought jets in this event, skipping it"
161  << endl;
162 
163  return;
164  }
165 
166 
167 
169  //
170  // Call the other analyze method
171  //
173 
174 
175 
176  LogTrace("HLTMuonVal") << "Calling analyze for muon ana" << endl;
178 
179 
180  LogTrace ("HLTMuonVal") << "TOPPLOT: returned from muon ana, now in top module"
181  << endl
182  << "muon ana stored size rec muons = "
183  //<< myMuonAna->recMatches.size()
184  << endl;
185 
186  vector<HLTMuonMatchAndPlot::MatchStruct>::const_iterator iRecMuon;
187 
188  int numCands = 0;
189  for ( unsigned int i = 0;
190  i < recMatches.size();
191  i++ ) {
192 
193 
194  LogTrace ("HLTMuonVal") << "Cand " << numCands
195  << ", Pt = "
196  << recMatches[i].recCand->pt()
197  << ", eta = "
198  << recMatches[i].recCand->eta()
199  << ", phi = "
200  << recMatches[i].recCand->phi()
201  << endl;
202 
203 
204  double deltaRLeadJetLep = reco::deltaR (recMatches[i].recCand->eta(), recMatches[i].recCand->phi(),
205  selectedJets[0].eta(), selectedJets[0].phi());
206 
208  //
209  // Fill Plots for All
210  //
212 
213  hDeltaRMaxJetLep[0]->Fill(deltaRLeadJetLep);
214  hJetMultip[0]->Fill(n_jets_20);
215 
216 
218  //
219  // Fill Plots for L1
220  //
222 
223 
224  if ( (recMatches[i].l1Cand.pt() > 0) && ((useFullDebugInformation) || (isL1Path)) ) {
225  hDeltaRMaxJetLep[1]->Fill(deltaRLeadJetLep);
226  hJetMultip[1]->Fill(n_jets_20);
227  }
228 
230  //
231  // Fill Plots for HLT
232  //
234 
235  for ( size_t j = 0; j < recMatches[i].hltCands.size(); j++ ) {
236  if ( recMatches[i].hltCands[j].pt() > 0 ) {
237  // you've found it!
238  hDeltaRMaxJetLep[j+HLT_PLOT_OFFSET]->Fill(deltaRLeadJetLep);
239  hJetMultip[j+HLT_PLOT_OFFSET]->Fill(n_jets_20);
240 
241  }
242  }
243 
244 
245 
246  numCands++;
247  }
248 
249 
250  LogTrace ("HLTMuonVal") << "-----End of top plotter analyze method-----" << endl;
251 } // Done filling histograms
252 
253 
254 
255 
257 {
258 
259  TString myLabel, newFolder;
260  vector<TH1F*> h;
261 
262  LogTrace ("HLTMuonVal") << "Inside begin for top analyzer" << endl;
263 
264 
265  LogTrace ("HLTMuonVal") << "Calling begin for muon analyzer" << endl;
267 
268  LogTrace ("HLTMuonVal") << "Continuing with top analyzer begin" << endl;
269 
270  if ( dbe_ ) {
271  dbe_->cd();
272  dbe_->setCurrentFolder("HLT/Muon");
273 
274 
275  // JMS I think this is trimming all L1 names to
276  // to be L1Filtered
277  myLabel = theL1CollectionLabel;
278  myLabel = myLabel(myLabel.Index("L1"),myLabel.Length());
279  myLabel = myLabel(0,myLabel.Index("Filtered")+8);
280 
281 
282  // JMS Old way of doing things
283  //newFolder = "HLT/Muon/Distributions/" + theTriggerName;
284  newFolder = "HLT/Muon/Distributions/" + theTriggerName + "/" + mySelection.customLabel;
285 
286 
287 
288  dbe_->setCurrentFolder( newFolder.Data() );
289 
290  vector<string> binLabels;
291  binLabels.push_back( theL1CollectionLabel.c_str() );
292  for ( size_t i = 0; i < theHltCollectionLabels.size(); i++ )
293  binLabels.push_back( theHltCollectionLabels[i].c_str() );
294 
295 
296  //------- Define labels for plots -------
297 
298  if (useOldLabels) {
299  myLabel = theL1CollectionLabel;
300  myLabel = myLabel(myLabel.Index("L1"),myLabel.Length());
301  myLabel = myLabel(0,myLabel.Index("Filtered")+8);
302  } else {
303  myLabel = "L1Filtered";
304  }
305 
306  //------ Definte the plots themselves------------------------
307 
308 
310  //
311  // ALL + L1 plots
312  //
314 
315  hDeltaRMaxJetLep.push_back (bookIt("topDeltaRMaxJetLep_All", "delta R between muon and highest pt jet", theDRParameters));
316  if (useFullDebugInformation || isL1Path) hDeltaRMaxJetLep.push_back (bookIt("topDeltaRMaxJetLep_" + myLabel, "delta R between muon and highest pt jet", theDRParameters));
317 
318  hJetMultip.push_back (bookIt("topJetMultip_All", "Jet multiplicity", theJetMParameters));
319  if (useFullDebugInformation || isL1Path) hJetMultip.push_back(bookIt("topJetMultip_" + myLabel, "Jet multiplicity", theJetMParameters));
320 
321 
323  //
324  // ALL + L1 plots
325  //
327 
328 
329  // we won't enter this loop if we don't have an hlt label
330  // we won't have an hlt label is this is a l1 path
331  for ( unsigned int i = 0; i < theHltCollectionLabels.size(); i++ ) {
332 
333  if (useOldLabels) {
334  myLabel = theHltCollectionLabels[i];
335  TString level = ( myLabel.Contains("L2") ) ? "L2" : "L3";
336  myLabel = myLabel(myLabel.Index(level),myLabel.Length());
337  myLabel = myLabel(0,myLabel.Index("Filtered")+8);
338  } else {
339  TString tempString = theHltCollectionLabels[i];
340  TString level = ( tempString.Contains("L2") ) ? "L2" : "L3";
341  myLabel = level + "Filtered";
342  } // end if useOldLabels
343 
344 
345  // Book for L2, L3
346  hDeltaRMaxJetLep.push_back (bookIt("topDeltaRMaxJetLep_" + myLabel, "delta R between muon and highest pt jet", theDRParameters)) ;
347  hJetMultip.push_back (bookIt("topJetMultip_" + myLabel, "Jet Multiplicity", theJetMParameters)) ;
348 
349 
350 
351  }// end for each collection label
352 
353  }// end if dbe_ exists
354 
355 }// end begin method
356 
357 
358 
360 //
361 // Extra methods
362 //
364 
365 
366 
367 // --------------- Sort a collection of Jets -----------
368 
369 
371 
372 
373  LogTrace ("HLTMuonVal") << "Sorting Jets" << endl;
374 
375  // bubble sort jets
376 
377  for ( unsigned int iJet = 0;
378  iJet < theJets.size();
379  iJet ++) {
380 
381  for ( unsigned int jJet = iJet;
382  jJet < theJets.size();
383  jJet ++ ){
384 
385  if ( theJets[jJet].et() > theJets[iJet].et() ) {
386  reco::CaloJet tmpJet = theJets[iJet];
387  theJets[iJet] = theJets[jJet];
388  theJets[jJet] = tmpJet;
389  }
390 
391  }// end for each jJet
392 
393  }// end for each iJet
394 
395  for ( unsigned int iJet = 0;
396  iJet != theJets.size();
397  iJet ++ ) {
398 
399  LogTrace ("HLTMuonVal") << "Jet # " << iJet
400  << " Et = " << theJets[iJet].et()
401  << endl;
402 
403  }
404 
405 }
406 
407 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
Jets made from CaloTowers.
Definition: CaloJet.h:30
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:214
void sortJets(reco::CaloJetCollection &theJets)
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
int iEvent
Definition: GenABIO.cc:243
HLTTopPlotter(const edm::ParameterSet &pset, std::string triggerName, std::vector< std::string > moduleNames, MuonSelectionStruct inputSelection, std::string customName, std::vector< std::string > validTriggers, const edm::Run &currentRun, const edm::EventSetup &currentEventSetup)
Constructor.
int j
Definition: DBlmapReader.cc:9
tuple pset
Definition: CrabTask.py:85
void analyze(const edm::Event &iEvent)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
#define LogTrace(id)
virtual void analyze(const edm::Event &iEvent)
DQMStore * dbe_
T const * product() const
Definition: Handle.h:74
std::vector< AlignmentParameters * > Parameters
Definition: Utilities.h:29
tuple level
Definition: testEve_cfg.py:34
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects