CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMuonMatchAndPlot.h
Go to the documentation of this file.
1 #ifndef DQMOffline_Trigger_HLTMuonMatchAndPlot_H
2 #define DQMOffline_Trigger_HLTMuonMatchAndPlot_H
3 
15 // Base Class Headers
16 
30 //#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
34 
36 
39 //#include "CommonTools/Utilities/interface/StringCutObjectSelector.h"
41 
43 
44 #include <vector>
45 #include "TFile.h"
46 #include "TNtuple.h"
47 #include "TString.h"
48 
49 
51 
52 //-----------------------------------------
53 // Add in a struct that gathers together
54 // the selectors and string that form the
55 // definition of each object
56 //-----------------------------------------
57 
59 
60  // constructor is empty, but passes in arguments
62  std::string cl, double pD0cut, double pZ0cut, std::string trackCol, std::vector<std::string> reqTrigs)
63  :recoMuonSelector(rsel), hltMuonSelector(hltsel), customLabel(cl),
64  d0cut(pD0cut), z0cut(pZ0cut), trackCollection(trackCol),
65  requiredTriggers(reqTrigs) {};
66 
69  std::string customLabel;
70 
71 
72  // the track cuts you want to use
73  // note: for future dev, you may want to
74  // also include some way to force use of beamspot
75  // paramters.
76 
77 
78  double d0cut;
79  double z0cut;
80 
81 
82  // the track collection you want to use
83  std::string trackCollection;
84 
85 
86  // included here for completeness, but not
87  // yet fully implemented
88 
89  std::vector<std::string> requiredTriggers;
90 
91  // note... do we want to make a raw selector?
92  // raw trigger events are called trig event with refs
93 
94 };
95 
96 
97 
99 
100 public:
101 
103  HLTMuonMatchAndPlot( const edm::ParameterSet& pset, std::string triggerName,
104  std::vector<std::string> moduleNames, MuonSelectionStruct inputSelection,
105  std::string customName,
106  std::vector<std::string> validTriggers,
107  const edm::Run & currentRun,
108  const edm::EventSetup & currentEventSetup );
109 
110  // Operations
111  virtual void begin ( );
112  virtual void analyze( const edm::Event & iEvent );
113  virtual void finish ( );
114  virtual void endRun (const edm::Run& r, const edm::EventSetup& c);
115  virtual MonitorElement* bookIt ( TString name, TString title, std::vector<double> );
116  virtual MonitorElement* bookIt ( TString name, TString title, int nbins, float* xBinLowEdges);
117 
118  TString calcHistoSuffix (std::string moduleName);
119 
120  // Struct and methods for matching
121 
122  // Big Change from RelVal
123  // Now we store Muons and TriggerObjects
124  // instead of Tracks and 4-vectors
125  struct MatchStruct {
126 
127  // this is the reco muon
129 
130  // this is the cand from the L1 filter
131  // in L1 passthru triggers
132  // that matches the reco muon
133  // (from trigger summary aod)
135 
136  // this is the L1 seed candidate from
137  // HLT trigger paths
138 
140 
141  // this is the raw candidate from
142  // the trigger summary with refs
143  // that matches the reco muon
145 
146  // these are the hlt candidates from
147  // trigger sum AOD that match
148  // the reco muon
149  std::vector<trigger::TriggerObject> hltCands;
150 
151  // these are the hlt candidates from
152  // trigger sum w/ refs that match
153  // the reco muon
154  std::vector<LorentzVector> hltRawCands;
155 
156  };
157 
158  // Structure that holds a Lorentz Vector corresponding
159  // to an HLT object and a bool to indicate whether or
160  // not it is a fake
161  struct HltFakeStruct {
163  bool isAFake;
164  };
165 
166  // store the matches for each event
167  std::vector<MatchStruct> recMatches;
168 
169  std::vector< std::vector<HltFakeStruct> > hltFakeCands;
170 
171  virtual ~HLTMuonMatchAndPlot() {} ;
172 
173  //-------- The fuctions/data below used to be private, but we want to
174  //-------- have other classes inherit them, so we make them public
175 
176 
177 
178  // Functions that are an internal decomposition of the stages of the
179  // public "analyze" function
180 
181  // They need to be public so that other modules can use them?
182 
183  bool virtual selectAndMatchMuons(const edm::Event & iEvent,
184  std::vector<MatchStruct> & myRecMatches,
185  std::vector< std::vector<HltFakeStruct> > & myHltFakeCands
186  );
187 
188  // does this need to be generalized to work for a given trigger too?
189  bool selectAndMatchMuons(const edm::Event & iEvent,
190  std::vector<MatchStruct> & myRecMatches,
191  std::vector< std::vector<HltFakeStruct> > & myHltFakeCands,
193  );
194 
195 
196  void virtual fillPlots(std::vector<MatchStruct> & myRecMatches,
197  std::vector< std::vector<HltFakeStruct> > & myHltFakeCands);
198 
199 protected:
200 
202 
203  const reco::Candidate* findMother( const reco::Candidate* );
204  int findGenMatch( double eta, double phi, double maxDeltaR,
205  std::vector<MatchStruct> matches );
206  int findRecMatch( double eta, double phi, double maxdeltaR,
207  std::vector<MatchStruct> matches );
208 
211 
213 
214  // boolean to turn on/off overflow inclusion
215  // function to do the overflow
217  void moveOverflow (MonitorElement * myElement);
218 
219 
220  // put the code for getting trigger objects into a single module
221  // fills up foundObjects with your matching trigger objects
222  void getAodTriggerObjectsForModule (edm::InputTag collectionTag,
223  edm::Handle<trigger::TriggerEvent> aodTriggerEvent,
225  std::vector<trigger::TriggerObject> & foundObjects,
227 
228  // keep track of the ME's you've booked,
229  // rebin them at job end.
230  std::vector<MonitorElement*> booked1DMonitorElements;
231 
232  // Data members
233 
234  // flag to decide how you want to label output histos
235  // old label scheme kept lots of the trigger name,
236  // but complicated harvesting step
241 
242  unsigned int numL1Cands;
243 
245  float theNtuplePars[100];
246  TNtuple *theNtuple;
247  TFile *theFile;
248 
251 
252 
253  // Input from cfg file
254 
255  std::string theHltProcessName;
256  std::string theTriggerName;
257  std::string theL1CollectionLabel;
258  std::vector<std::string> theHltCollectionLabels;
259  unsigned int theNumberOfObjects;
260 
261  //bool useMuonFromGenerator;
263  //std::string theGenLabel;
264  //std::string theRecoLabel;
265 
270 
271  bool useAod;
272  std::string theAodL1Label;
273  std::string theAodL2Label;
274 
276 
277 
278  std::string matchType;
279 
281 
282  //======= Trigger Selection info ==========
284 
285  std::vector<std::string> selectedValidTriggers;
286 
288 
289  //StringCutObjectSelector<reco::Muon> myMuonSelector;
290  //std::string myCustomName;
291 
292  // constants and a method
293  // to simplify charge plots
294 
295  static const int POS_CHARGE = 1;
296  static const int NEG_CHARGE = -1;
297  int getCharge (int pdgId);
298 
299  // 1-D histogram paramters
300  std::vector<double> theMaxPtParameters;
301  std::vector<double> thePtParameters;
302  std::vector<double> theEtaParameters;
303  std::vector<double> thePhiParameters;
304  std::vector<double> thePhiParameters0Pi;
305  std::vector<double> theD0Parameters;
306  std::vector<double> theZ0Parameters;
307  std::vector<double> theChargeParameters;
308  std::vector<double> theDRParameters;
309  std::vector<double> theChargeFlipParameters;
310 
311  // variable width pt bins
312  // don't allow more than 100
313  float ptBins[100];
315 
316  // 2-D histogram parameters
317  std::vector<double> thePhiEtaParameters2d;
318 
319  // std::vector<double> theMaxPtParameters2d;
320  // std::vector<double> theEtaParameters2d;
321  // std::vector<double> thePhiParameters2d;
322 
323  // std::vector<double> theDeltaPhiVsPhiParameters;
324  // std::vector<double> theDeltaPhiVsZ0Parameters;
325  // std::vector<double> theDeltaPhiVsD0Parameters;
326 
327 
328  // Resolution hisotgram parameters
329  std::vector<double> theResParameters;
330 
331  // isolation parameters
332  std::vector<double> theIsolationParameters;
333 
334 
335 
336  double theMinPtCut;
337  double theMaxEtaCut;
338  double theL1DrCut;
339  double theL2DrCut;
340  double theL3DrCut;
342  std::vector<double> theNSigmas;
343 
344  std::string theNtupleFileName;
345  std::string theNtuplePath;
346 
347  // Book-keeping information
348 
350  unsigned int numHltLabels;
352 
353  // Monitor Elements (Histograms and ints)
354 
356 
358  std::string histoFileName;
359 
360 
361  // std::vector <MonitorElement*> hPassMaxPtGen;
362 // std::vector <MonitorElement*> hPassEtaGen;
363 // std::vector <MonitorElement*> hPassPhiGen;
364  std::vector <MonitorElement*> hPassMaxPtRec;
365  std::vector <MonitorElement*> hPassEtaRec;
366  std::vector <MonitorElement*> hPassPhiRec;
367  std::vector <MonitorElement*> hPassMatchPtRec;
368  std::vector <MonitorElement*> hPassExaclyOneMuonMaxPtRec;
369  //std::vector <MonitorElement*> hPtMatchVsPtRec;
370  //std::vector <MonitorElement*> hEtaMatchVsEtaRec;
371  //std::vector <MonitorElement*> hPhiMatchVsPhiRec;
372  std::vector <MonitorElement*> hPhiVsEtaRec;
373  std::vector <MonitorElement*> hPassPtRec;
374  std::vector <MonitorElement*> hPassPtRecExactlyOne;
375  std::vector <MonitorElement*> hResoPtAodRec;
376  std::vector <MonitorElement*> hResoEtaAodRec;
377  std::vector <MonitorElement*> hResoPhiAodRec;
378  std::vector <MonitorElement*> hPassD0Rec;
379  std::vector <MonitorElement*> hPassZ0Rec;
380  std::vector <MonitorElement*> hPassCharge;
381  std::vector <MonitorElement*> hPassD0BeamRec;
382  std::vector <MonitorElement*> hPassZ0BeamRec;
383  std::vector <MonitorElement*> hBeamSpotZ0Rec;
384 
385  // studies for cosmics
386  std::vector <MonitorElement*> hMatchedDeltaPhi;
387  //std::vector <MonitorElement*> hDeltaPhiVsPhi;
388  //std::vector <MonitorElement*> hDeltaPhiVsZ0;
389  //std::vector <MonitorElement*> hDeltaPhiVsD0;
390 
391 
392 
393  std::vector <MonitorElement*> hDeltaRMatched;
394  std::vector <MonitorElement*> hIsolationRec;
395  std::vector <MonitorElement*> hChargeFlipMatched;
396 
397  std::vector <MonitorElement*> allHltCandPt;
398  std::vector <MonitorElement*> allHltCandEta;
399  std::vector <MonitorElement*> allHltCandPhi;
400  // can't do d0, z0 becuase only have 4 vectors
401  //std::vector <MonitorElement*> allHltCandD0Rec;
402  //std::vector <MonitorElement*> allHltCandZ0Rec;
403 
404  std::vector <MonitorElement*> fakeHltCandPt;
405  std::vector <MonitorElement*> fakeHltCandEta;
406  std::vector <MonitorElement*> fakeHltCandPhi;
407  //std::vector <MonitorElement*> fakeHltCandD0Rec;
408  //std::vector <MonitorElement*> fakeHltCandZ0Rec;
409 
410  //std::vector <MonitorElement*> fakeHltCandEtaPhi;
411  //std::vector <MonitorElement*> fakeHltCandDeltaR;
412 
413  // RAW histograms
414  // L1, L2, L3
415  std::vector <MonitorElement*> rawMatchHltCandPt;
416  std::vector <MonitorElement*> rawMatchHltCandEta;
417  std::vector <MonitorElement*> rawMatchHltCandPhi;
418 
419  //
420  //std::string highPtTrackCollection;
421 
422 
424  //MonitorElement *hNumOrphansGen;
427 
428 };
429 #endif
virtual MonitorElement * bookIt(TString name, TString title, std::vector< double >)
std::vector< MonitorElement * > hPassZ0BeamRec
std::vector< MonitorElement * > fakeHltCandPt
std::vector< MonitorElement * > hPassPtRecExactlyOne
std::vector< double > theDRParameters
static const int POS_CHARGE
std::vector< MonitorElement * > rawMatchHltCandPt
edm::InputTag HltAodInputTag
reco::TrackRef getCandTrackRef(MuonSelectionStruct mySelection, reco::Muon candMuon)
TString calcHistoSuffix(std::string moduleName)
std::vector< std::string > selectedValidTriggers
std::vector< MonitorElement * > hBeamSpotZ0Rec
MonitorElement * hNumOrphansRec
virtual bool applyTriggerSelection(MuonSelectionStruct mySelection, const edm::Event &event)
virtual bool selectAndMatchMuons(const edm::Event &iEvent, std::vector< MatchStruct > &myRecMatches, std::vector< std::vector< HltFakeStruct > > &myHltFakeCands)
const reco::Candidate * findMother(const reco::Candidate *)
std::vector< MonitorElement * > hPassD0Rec
std::vector< MonitorElement * > hPassZ0Rec
edm::InputTag RecoMuonInputTag
std::vector< double > theD0Parameters
std::vector< double > theZ0Parameters
std::vector< MonitorElement * > hResoEtaAodRec
T eta() const
std::vector< MonitorElement * > allHltCandPt
edm::InputTag HltRawInputTag
math::XYZTLorentzVector LorentzVector
Definition: HLTMuonBPAG.h:55
void moveOverflow(MonitorElement *myElement)
virtual void endRun(const edm::Run &r, const edm::EventSetup &c)
MonitorElement * meNumberOfEvents
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:24
std::vector< double > theEtaParameters
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
std::vector< MonitorElement * > booked1DMonitorElements
int findRecMatch(double eta, double phi, double maxdeltaR, std::vector< MatchStruct > matches)
int iEvent
Definition: GenABIO.cc:243
std::vector< double > theChargeFlipParameters
std::vector< MonitorElement * > hPassMatchPtRec
unsigned int theNumberOfObjects
std::string theL1CollectionLabel
std::vector< MonitorElement * > hIsolationRec
MonitorElement * hNumObjects
static const int NEG_CHARGE
std::vector< double > thePtParameters
std::vector< MonitorElement * > hPassMaxPtRec
std::vector< MonitorElement * > hDeltaRMatched
std::vector< double > thePhiEtaParameters2d
std::vector< MonitorElement * > hPassCharge
std::vector< MonitorElement * > fakeHltCandPhi
tuple pset
Definition: CrabTask.py:85
std::vector< double > thePhiParameters
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< MatchStruct > recMatches
virtual void analyze(const edm::Event &iEvent)
std::vector< double > theIsolationParameters
std::vector< MonitorElement * > hPassD0BeamRec
std::vector< MonitorElement * > rawMatchHltCandPhi
HLTMuonMatchAndPlot(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.
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:83
std::vector< MonitorElement * > hPassEtaRec
std::vector< MonitorElement * > allHltCandPhi
std::vector< double > theMaxPtParameters
std::vector< std::vector< HltFakeStruct > > hltFakeCands
std::vector< LorentzVector > hltRawCands
std::vector< double > theNSigmas
std::vector< MonitorElement * > hPassPtRec
std::vector< MonitorElement * > hPassPhiRec
StringCutObjectSelector< trigger::TriggerObject > hltMuonSelector
std::vector< MonitorElement * > fakeHltCandEta
std::vector< MonitorElement * > allHltCandEta
StringCutObjectSelector< reco::Muon > recoMuonSelector
std::vector< std::string > theHltCollectionLabels
std::vector< double > theResParameters
MuonSelectionStruct mySelection
virtual void fillPlots(std::vector< MatchStruct > &myRecMatches, std::vector< std::vector< HltFakeStruct > > &myHltFakeCands)
std::vector< MonitorElement * > hMatchedDeltaPhi
int findGenMatch(double eta, double phi, double maxDeltaR, std::vector< MatchStruct > matches)
std::vector< MonitorElement * > hResoPhiAodRec
MuonSelectionStruct(StringCutObjectSelector< reco::Muon > rsel, StringCutObjectSelector< trigger::TriggerObject > hltsel, std::string cl, double pD0cut, double pZ0cut, std::string trackCol, std::vector< std::string > reqTrigs)
std::vector< trigger::TriggerObject > hltCands
void getAodTriggerObjectsForModule(edm::InputTag collectionTag, edm::Handle< trigger::TriggerEvent > aodTriggerEvent, trigger::TriggerObjectCollection trigObjs, std::vector< trigger::TriggerObject > &foundObjects, MuonSelectionStruct muonSelection)
std::vector< double > thePhiParameters0Pi
std::vector< double > theChargeParameters
virtual bool applyTrackSelection(MuonSelectionStruct mySelection, reco::Muon candMuon)
edm::InputTag BeamSpotInputTag
std::vector< std::string > requiredTriggers
std::vector< MonitorElement * > hResoPtAodRec
std::vector< MonitorElement * > hChargeFlipMatched
std::string theL1SeedModuleForHLTPath
Definition: Run.h:31
math::PtEtaPhiELorentzVectorF LorentzVector
std::vector< MonitorElement * > hPassExaclyOneMuonMaxPtRec
std::vector< MonitorElement * > hPhiVsEtaRec
std::vector< MonitorElement * > rawMatchHltCandEta
edm::InputTag TriggerResultLabel
Definition: DDAxes.h:10