CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTOniaSource.cc
Go to the documentation of this file.
1 /*
2  Description: [one line class summary]
3 
4  Implementation:
5  [Notes on implementation]
6 */
7 // Original Author: Anna Cimmino
8 
9 #include "../interface/HLTOniaSource.h"
10 //FWCore
12 //DataFormats
19 //#include "DataFormats/TrackReco/interface/Track.h"
20 
21 //HLTrigger
24 
26 
27  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Constructor";
28 
29  //HLTrigger Path Names
30  std::vector<std::string> myTriggerPaths;
31  myTriggerPaths.push_back("HLT_Mu0_Track0_Jpsi");
32  myTriggerPaths.push_back("HLT_Mu3_Track0_Jpsi");
33  myTriggerPaths.push_back("HLT_Mu5_Track0_Jpsi");
34  triggerPath_ = pset.getUntrackedParameter<std::vector<std::string> >("TriggerPathNames",myTriggerPaths);
35 
36  //Tag for Onia Muons
37  std::vector<edm::InputTag> myOniaMuonTags;
38 
39  myOniaMuonTags.push_back(edm::InputTag("hltMu0TrackJpsiL3Filtered0", "", "HLT"));
40  myOniaMuonTags.push_back(edm::InputTag("hltMu3TrackJpsiL3Filtered3", "", "HLT"));
41  myOniaMuonTags.push_back(edm::InputTag("hltMu5TrackJpsiL3Filtered5", "", "HLT"));
42  oniaMuonTag_ = pset.getUntrackedParameter<std::vector<edm::InputTag> >("OniaMuonTag",myOniaMuonTags);
43 
44  //Tag for Pixel tracks before Onia filter
45  pixelTag_ = pset.getUntrackedParameter<edm::InputTag>("PixelTag",edm::InputTag("hltPixelTracks", "", "HLT"));
46 
47  //Tag for Tracker tracks before Onia filter
48  trackTag_ = pset.getUntrackedParameter<edm::InputTag>("TrackTag",edm::InputTag("hltMuTrackJpsiCtfTrackCands","", "HLT"));
49 
50  beamSpotTag_ = pset.getUntrackedParameter<edm::InputTag>("BeamSpotTag",edm::InputTag("hltOfflineBeamSpot", "", "HLT"));
51 
52  //Tag Trigger Summary
53  triggerSummaryRAWTag_ = pset.getUntrackedParameter<edm::InputTag>("TriggerSummaryTag",edm::InputTag("hltTriggerSummaryRAW", "", "HLT"));
54  hltProcessName_ = pset.getUntrackedParameter<std::string>("TriggerProcessName","HLT");
55  //Tag for Pixel tracks after Onia filter
56  std::vector<edm::InputTag> pxlTagsAfterFilter;
57  pxlTagsAfterFilter.push_back(edm::InputTag("hltMu0TrackJpsiPixelMassFiltered", "", "HLT"));
58  pxlTagsAfterFilter.push_back(edm::InputTag("hltMu3TrackJpsiPixelMassFiltered", "", "HLT"));
59  pxlTagsAfterFilter.push_back(edm::InputTag("hltMu5TrackJpsiPixelMassFiltered", "", "HLT"));
60  pixelTagsAfterFilter_= pset.getUntrackedParameter< std::vector<edm::InputTag> >("PixelTagAfterFilter",pxlTagsAfterFilter);
61 
62  //Tag for Tracker tracks after Onia filter
63  std::vector<edm::InputTag> trxTagsAfterFilter;
64  trxTagsAfterFilter.push_back(edm::InputTag("hltMu0TrackJpsiTrackMassFiltered", "", "HLT"));
65  trxTagsAfterFilter.push_back(edm::InputTag("hltMu3TrackJpsiTrackMassFiltered", "", "HLT"));
66  trxTagsAfterFilter.push_back(edm::InputTag("hltMu5TrackJpsiTrackMassFiltered", "", "HLT"));
67  trackTagsAfterFilter_ = pset.getUntrackedParameter< std::vector<edm::InputTag> >("TrackTagAfterFilter",trxTagsAfterFilter);
68 
69  //Foldering output
70  subsystemFolder_ = pset.getUntrackedParameter<std::string>("SubSystemFolder","HLT/HLTMonMuon/Onia");
71 
72  //set Token(-s)
73  pixelToken_ = consumes<reco::TrackCollection>(pset.getUntrackedParameter<edm::InputTag>("PixelTag",edm::InputTag("hltPixelTracks", "", "HLT")));
74  trackToken_ = consumes<reco::RecoChargedCandidateCollection>(pset.getUntrackedParameter<edm::InputTag>("TrackTag",edm::InputTag("hltMuTrackJpsiCtfTrackCands","", "HLT")));
75  beamSpotToken_ = consumes<reco::BeamSpot>(pset.getUntrackedParameter<edm::InputTag>("BeamSpotTag",edm::InputTag("hltOfflineBeamSpot", "", "HLT")));
76  triggerSummaryRAWToken_ = consumes<trigger::TriggerEventWithRefs>(pset.getUntrackedParameter<edm::InputTag>("TriggerSummaryTag",edm::InputTag("hltTriggerSummaryRAW", "", "HLT")));
77 }
78 
79 
81 
83 
85  if( !dbe_ ) {
86  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access DQM Store.";
87  return;
88  }
89 }
90 
92 
93  if (!dbe_) return;
94 
95  // Book Pixel Histos
96  if (pixelTag_.label()!= ""){
99  }
100 
101  // Book Track Histos
102  if (trackTag_.label()!= ""){
105  }
106 
107 
108  //Book Onia Histos
109  for (size_t i = 0 ; i<oniaMuonTag_.size() && i<pixelTagsAfterFilter_.size() && i<trackTagsAfterFilter_.size(); i++){
110 
111  if (oniaMuonTag_[i].label()!= "") {
112  dbe_->setCurrentFolder(subsystemFolder_+"/MuonFilters");
114  }
115  if (pixelTagsAfterFilter_[i].label() != ""){
116  dbe_->setCurrentFolder(subsystemFolder_+"/PixelFilters");
118  }
119  if (trackTagsAfterFilter_[i].label() != ""){
120  dbe_->setCurrentFolder(subsystemFolder_+"/TrackFilters");
122  }
123  if (oniaMuonTag_[i].label()!= "" && pixelTag_.label() != ""){
126  }
127  if (oniaMuonTag_[i].label() != "" && trackTag_.label()!= "" ){
130  }
131  if (oniaMuonTag_[i].label()!= "" && pixelTagsAfterFilter_[i].label()!= ""){
132  dbe_->setCurrentFolder(subsystemFolder_+"/PixelFilters");
134  }
135  if (oniaMuonTag_[i].label()!= "" && trackTagsAfterFilter_[i].label()!= ""){
136  dbe_->setCurrentFolder(subsystemFolder_+"/TrackFilters");
138  }
139  }
140 
142 
143 }
144 
145 
146 
148 
149  if(!hltConfigInit_) return;
150 
151  //Get Pixel Tracks
153  iEvent.getByToken(pixelToken_, pixelCands);
154 
155  reco::TrackCollection mypixelCands; //This is needed for the sort!!!!
156  if (pixelCands.isValid()) {
157  mypixelCands = * pixelCands;
158  sort(mypixelCands.begin(), mypixelCands.end(),PtGreater());
159  this->fillOniaTriggerMEs(pixelCands , pixelTag_.label(), pixelME_ );
160  }else {
161  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access pixel collection with tag "<<pixelTag_;
162  }
163 
164  //Get Tracker Tracks
166  iEvent.getByToken(trackToken_, trackCands);
167  reco::RecoChargedCandidateCollection mytrackCands; //This is needed for the sort!!!!
168  if(trackCands.isValid()) {
169  mytrackCands = * trackCands;
170  sort(mytrackCands.begin(),mytrackCands.end(),PtGreater());
171  this->fillOniaTriggerMEs(trackCands , trackTag_.label(), trackME_ );
172  }else {
173  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access track collection with tag "<<trackTag_;
174  }
175 
176  //Get Beamspot
177  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
178  iEvent.getByToken(beamSpotToken_, recoBeamSpotHandle);
179  if (recoBeamSpotHandle.isValid()) {
180  BSPosition_ = recoBeamSpotHandle->position();
181  }else {
182  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access beam spot info with tag "<<beamSpotTag_;
183  }
184 
185 
186  //Get Trigger Summary RA
188  iEvent.getByToken(triggerSummaryRAWToken_, rawTriggerEvent);
189  if( rawTriggerEvent.isValid() ){
190 
191  for(size_t i=0; i<oniaMuonTag_.size(); i++){
192 
193  std::vector<reco::RecoChargedCandidateRef> myMuonFilterCands;
194  std::vector<reco::RecoChargedCandidateRef> myPixelFilterCands;
195  std::vector<reco::RecoChargedCandidateRef> myTrackFilterCands;
196 
197  //Get Onia Muons
198  size_t indexM = rawTriggerEvent->filterIndex(oniaMuonTag_[i]);
199 
200  if ( indexM < rawTriggerEvent->size() ){
201  rawTriggerEvent->getObjects( indexM, trigger::TriggerMuon, myMuonFilterCands );
202  this->fillOniaTriggerMEs( myMuonFilterCands, oniaMuonTag_[i].label(), muonME_ );
203  }else{
204  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Did not find muons with tag "<<oniaMuonTag_[i];
205  }
206  //Get Onia Pixel
207  size_t indexP = rawTriggerEvent->filterIndex(pixelTagsAfterFilter_[i]);
208  if ( indexP < rawTriggerEvent->size() ){
209  rawTriggerEvent->getObjects( indexP, trigger::TriggerTrack , myPixelFilterCands );
210  this->fillOniaTriggerMEs( myPixelFilterCands,pixelTagsAfterFilter_[i].label(), pixelAfterFilterME_);
211  sort(myPixelFilterCands.begin(), myPixelFilterCands.end(),PtGreaterRef());
212  }else{
213  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Did not find pixel with tag "<<pixelTagsAfterFilter_[i];
214  }
215 
216  //Get Onia Tracker Tracks
217  size_t indexT = rawTriggerEvent->filterIndex(trackTagsAfterFilter_[i]);
218  if ( indexT < rawTriggerEvent->size() ){
219  rawTriggerEvent->getObjects( indexT, trigger::TriggerTrack , myTrackFilterCands );
220  this->fillOniaTriggerMEs( myTrackFilterCands,trackTagsAfterFilter_[i].label(), trackAfterFilterME_ );
221  sort(myTrackFilterCands.begin(), myTrackFilterCands.end(),PtGreaterRef());
222  }else{
223  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Did not find tracks with tag "<<trackTagsAfterFilter_[i];
224  }
225 
226  if( myMuonFilterCands.size() > 0){
227  if ( myPixelFilterCands.size() > 0 )this->fillInvariantMass( myMuonFilterCands, myPixelFilterCands ,oniaMuonTag_[i].label(),pixelTagsAfterFilter_[i].label());
228  if ( myTrackFilterCands.size() > 0 )this->fillInvariantMass( myMuonFilterCands, myTrackFilterCands ,oniaMuonTag_[i].label(),trackTagsAfterFilter_[i].label());
229  if (pixelCands.isValid()) this->fillInvariantMass( myMuonFilterCands, mypixelCands , oniaMuonTag_[i].label(), pixelTag_.label());
230  if (trackCands.isValid()) this->fillInvariantMass( myMuonFilterCands, mytrackCands , oniaMuonTag_[i].label(), trackTag_.label());
231  }
232 
233 
234  }//ADD INVARIANT MASSES
235  }else{
236  edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access trigger collection with tag "<<triggerSummaryRAWTag_;
237  }
238 
239 }
240 
241 
243 
244 void HLTOniaSource::bookOniaTriggerMEs( std::map<std::string, MonitorElement *> & myMap, std::string meName){
245 
246  std::stringstream myMeName;
247 
248  //PT
249  myMeName.str("");
250  myMeName<<meName<<"_Pt";
251  myMap[meName+"pt"]=dbe_->book1D(myMeName.str(), myMeName.str(),200, 0.0, 20.0);
252  myMap[meName+"pt"]->setAxisTitle("Pt (GeV)", 1);
253 
254  //P
255  myMeName.str("");
256  myMeName<<meName<<"_P";
257  myMap[meName+"p"]=dbe_->book1D(myMeName.str(), myMeName.str(),250, 0.0, 50.0);
258  myMap[meName+"p"]->setAxisTitle("P (GeV)", 1);
259 
260  //Eta
261  myMeName.str("");
262  myMeName<<meName<<"_Eta";
263  myMap[meName+"eta"]=dbe_->book1D(myMeName.str(), myMeName.str(), 50, -2.5, 2.5 );
264  myMap[meName+"eta"]->setAxisTitle("Eta", 1);
265 
266  //Phi
267  myMeName.str("");
268  myMeName<<meName<<"_Phi";
269  myMap[meName+"phi"]=dbe_->book1D(myMeName.str(), myMeName.str(), 144, -3.1416, 3.1416 );
270  myMap[meName+"phi"]->setAxisTitle("Phi", 1);
271 
272  //Phi
273  myMeName.str("");
274  myMeName<<meName<<"_Phi";
275  myMap[meName+"phi"]=dbe_->book1D(myMeName.str(), myMeName.str(), 144, -3.1416, 3.1416 );
276  myMap[meName+"phi"]->setAxisTitle("Phi", 1);
277 
278  //Charge
279  myMeName.str("");
280  myMeName<<meName<<"_Charge";
281  myMap[meName+"charge"]=dbe_->book1D(myMeName.str(), myMeName.str(), 3, -1.5, 1.5 );
282  myMap[meName+"charge"]->setAxisTitle("charge", 1);
283 
284  //Dz
285  myMeName.str("");
286  myMeName<<meName<<"_Dz";
287  myMap[meName+"dz"]=dbe_->book1D(myMeName.str(), myMeName.str(), 400, -20.0, 20.0 );
288  myMap[meName+"dz"]->setAxisTitle("dz", 1);
289 
290  //Dxy
291  myMeName.str("");
292  myMeName<<meName<<"_Dxy";
293  myMap[meName+"dxy"]=dbe_->book1D(myMeName.str(), myMeName.str(), 100, -0.5, 0.5 );
294  myMap[meName+"dxy"]->setAxisTitle("dxy", 1);
295 
296  //EtaVsPhi
297  myMeName.str("");
298  myMeName<<meName<<"_EtaPhi";
299  myMap[meName+"etaphi"]=dbe_->book2D(myMeName.str(), myMeName.str(), 144, -3.1416, 3.1416 ,50, -2.5, 2.5 );
300  myMap[meName+"etaphi"]->setAxisTitle("Phi", 1);
301  myMap[meName+"etaphi"]->setAxisTitle("Eta", 2);
302 
303  //EtaVsPt
304  myMeName.str("");
305  myMeName<<meName<<"_EtaPt";
306  myMap[meName+"etapt"]=dbe_->book2D(myMeName.str(), myMeName.str(), 100, 0.0, 100.0, 50, -2.5, 2.5 );
307  myMap[meName+"etapt"]->setAxisTitle("Pt (GeV)", 1);
308  myMap[meName+"etapt"]->setAxisTitle("Eta", 2);
309 
310  //ValidHits
311  myMeName.str("");
312  myMeName<<meName<<"_ValidHits";
313  myMap[meName+"validhits"]=dbe_->book1D(myMeName.str(), myMeName.str(), 50, 0.0, 50.0 );
314  myMap[meName+"validhits"]->setAxisTitle("ValidHits", 1);
315 
316  //Norm Chi2
317  myMeName.str("");
318  myMeName<<meName<<"_NormChi2";
319  myMap[meName+"normchi"]=dbe_->book1D(myMeName.str(), myMeName.str(), 300, 0.0, 30.0 );
320  myMap[meName+"normchi"]->setAxisTitle("Normalized Chi2", 1);
321 
322  //Number Of Candi
323  myMeName.str("");
324  myMeName<<meName<<"_NrCandidates";
325  myMap[meName+"nrcand"]=dbe_->book1D(myMeName.str(), myMeName.str(), 50, 0.0, 50.0 );
326  myMap[meName+"nrcand"]->setAxisTitle("Nr per Event", 1);
327  //return true;
328 }
329 
330 
331 void HLTOniaSource::bookOniaTriggerInvariantMassMEs( std::map<std::string, MonitorElement *> & myMap, std::string label1, std::string label2 ){
332 
333  std::stringstream meName;
334  //Same charge
335  meName.str("");
336  meName<<label1<<"_"<<label2<<"_SameCharge_InvariantMass";
337  massME_[label1+label2+"same"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
338  massME_[label1+label2+"same"]->setAxisTitle("mass (GeV)", 1);
339 
340  //Opposite charge
341  meName.str("");
342  meName<<label1<<"_"<<label2<<"_OppositeCharge_InvariantMass";
343  massME_[label1+label2+"opposite"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
344  massME_[label1+label2+"opposite"]->setAxisTitle("mass (GeV)", 1);
345 
346  //Same charge Highest PT
347  meName.str("");
348  meName<<label1<<"_"<<label2<<"_SameCharge_HighestPT_InvariantMass";
349  massME_[label1+label2+"same"+"highestpt"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
350  massME_[label1+label2+"same"+"highestpt"]->setAxisTitle("mass (GeV)", 1);
351 
352  //Opposite charge Highest PT
353  meName.str("");
354  meName<<label1<<"_"<<label2<<"_OppositeCharge_HighestPT_InvariantMass";
355  massME_[label1+label2+"opposite"+"highestpt"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
356  massME_[label1+label2+"opposite"+"highestpt"]->setAxisTitle("mass (GeV)", 1);
357 
358 
359 
360  // Same Charge Deltaz Muon - Track Highest PT
361  meName.str("");
362  meName<<label1<<"_"<<label2<<"_SameCharge_HighestPT_MaxDzMuonTrack";
363  massME_[label1+label2+"same"+"highestpt"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
364  massME_[label1+label2+"same"+"highestpt"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);
365  // Same Charge Deltaz Muon - Track
366  meName.str("");
367  meName<<label1<<"_"<<label2<<"_SameCharge_MaxDzMuonTrack";
368  massME_[label1+label2+"same"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
369  massME_[label1+label2+"same"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);
370  // Opposite charge Deltaz Muon - Track Highest PT
371  meName.str("");
372  meName<<label1<<"_"<<label2<<"_OppositeCharge_HighestPT_MaxDzMuonTrack";
373  massME_[label1+label2+"opposite"+"highestpt"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
374  massME_[label1+label2+"opposite"+"highestpt"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);
375  // Opposite charge Deltaz Muon - Track
376  meName.str("");
377  meName<<label1<<"_"<<label2<<"_OppositeCharge_MaxDzMuonTrack";
378  massME_[label1+label2+"opposite"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
379  massME_[label1+label2+"opposite"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);
380 }
381 
382 
383 void HLTOniaSource::fillOniaTriggerMEs( edm::Handle<reco::TrackCollection> & collection, std::string collectionLabel, std::map<std::string, MonitorElement *> & mapME ){
384  // cout << "[HLTOniaSource]: fillOniaTriggerMEs " << collectionLabel << endl;
385 
386  reco::TrackCollection myCollection;
387  if (collection.isValid()) {
388  myCollection = * collection;
389 
390  // int nCollection= myCollection.size();
391 
392  typedef reco::TrackCollection::const_iterator cand;
393  int num = 0;
394  for (cand tk=myCollection.begin(); tk!=myCollection.end(); tk++) {
395  num++;
396  //Fill MEs
397  if(mapME[collectionLabel+"pt"]){ mapME[collectionLabel+"pt"]->Fill(tk->pt()); }
398  if(mapME[collectionLabel+"p"]) { mapME[collectionLabel+"p"]->Fill(tk->p()); }
399  if(mapME[collectionLabel+"eta"]) { mapME[collectionLabel+"eta"]->Fill(tk->eta()); }
400  if(mapME[collectionLabel+"phi"]) { mapME[collectionLabel+"phi"]->Fill(tk->phi()); }
401  if(mapME[collectionLabel+"etaphi"]){ mapME[collectionLabel+"etaphi"]->Fill(tk->phi(),tk->eta()); }
402  if(mapME[collectionLabel+"etapt"]){ mapME[collectionLabel+"etapt"]->Fill(tk->pt(),tk->eta()); }
403  if(mapME[collectionLabel+"charge"]){ mapME[collectionLabel+"charge"]->Fill(tk->charge()); }
404 
405  // if(mapME[collectionLabel+"dxy"]){ mapME[collectionLabel+"dxy"]->Fill(tk->dxy(BSPosition_)); }
406 // if(mapME[collectionLabel+"dz"]){ mapME[collectionLabel+"dz"]->Fill(tk->dz(BSPosition_)); }
407 
408 // if(mapME[collectionLabel+"validhits"]) { mapME[collectionLabel+"validhits"]->Fill(tk->numberOfValidHits()); }
409 // if(mapME[collectionLabel+"normchi"]){ mapME[collectionLabel+"normchi"]->Fill(tk->normalizedChi2()); }
410  }
411  if(mapME[collectionLabel+"nrcand"]){ mapME[collectionLabel+"nrcand"]->Fill(num);}
412 
413  }
414 }
415 
416 
417 void HLTOniaSource::fillOniaTriggerMEs(std::vector<reco::RecoChargedCandidateRef> & candidateVector, std::string collectionLabel, std::map<std::string, MonitorElement *> & mapME ){
418 
419  for (unsigned int i=0; i!=candidateVector.size(); i++) {
420  reco::RecoChargedCandidate tk = (*candidateVector[i]);
421 
422  //Fill MEs
423  if(mapME[collectionLabel+"pt"]){ mapME[collectionLabel+"pt"]->Fill(tk.pt()); }
424  if(mapME[collectionLabel+"p"]) { mapME[collectionLabel+"p"]->Fill(tk.p()); }
425  if(mapME[collectionLabel+"eta"]) { mapME[collectionLabel+"eta"]->Fill(tk.eta()); }
426  if(mapME[collectionLabel+"phi"]) { mapME[collectionLabel+"phi"]->Fill(tk.phi()); }
427  if(mapME[collectionLabel+"etaphi"]){ mapME[collectionLabel+"etaphi"]->Fill(tk.phi(),tk.eta()); }
428  if(mapME[collectionLabel+"etapt"]){ mapME[collectionLabel+"etapt"]->Fill(tk.pt(),tk.eta()); }
429  if(mapME[collectionLabel+"charge"]){ mapME[collectionLabel+"charge"]->Fill(tk.charge()); }
430 
431  // if(mapME[collectionLabel+"dxy"]){ mapME[collectionLabel+"dxy"]->Fill(tk.dxy(BSPosition_)); }
432 // if(mapME[collectionLabel+"dz"]){ mapME[collectionLabel+"dz"]->Fill(tk.dz(BSPosition_)); }
433 
434 // if(mapME[collectionLabel+"validhits"]) { mapME[collectionLabel+"validhits"]->Fill(tk.numberOfValidHits()); }
435 // if(mapME[collectionLabel+"normchi"]){ mapME[collectionLabel+"normchi"]->Fill(tk.normalizedChi2()); }
436  }
437 
438  if(mapME[collectionLabel+"nrcand"]){ mapME[collectionLabel+"nrcand"]->Fill( candidateVector.size());}
439 }
440 
441 
442 void HLTOniaSource::fillOniaTriggerMEs( edm::Handle<reco::RecoChargedCandidateCollection> & collection, std::string collectionLabel, std::map<std::string, MonitorElement *> & mapME ){
443 
445  if (collection.isValid()) {
446  myCollection = * collection;
447 
448  // int nCollection= myCollection.size();
449  int num = 0;
450  typedef reco::RecoChargedCandidateCollection::const_iterator cand;
451  for (cand i=myCollection.begin(); i!=myCollection.end(); i++) {
452  reco::RecoChargedCandidate tk = (*i);
453 
454  num++;
455  //Fill MEs
456  if(mapME[collectionLabel+"pt"]){ mapME[collectionLabel+"pt"]->Fill(tk.pt()); }
457  if(mapME[collectionLabel+"p"]) { mapME[collectionLabel+"p"]->Fill(tk.p()); }
458  if(mapME[collectionLabel+"eta"]) { mapME[collectionLabel+"eta"]->Fill(tk.eta()); }
459  if(mapME[collectionLabel+"phi"]) { mapME[collectionLabel+"phi"]->Fill(tk.phi()); }
460  if(mapME[collectionLabel+"etaphi"]){ mapME[collectionLabel+"etaphi"]->Fill(tk.phi(),tk.eta()); }
461  if(mapME[collectionLabel+"etapt"]){ mapME[collectionLabel+"etapt"]->Fill(tk.pt(),tk.eta()); }
462  if(mapME[collectionLabel+"charge"]){ mapME[collectionLabel+"charge"]->Fill(tk.charge()); }
463 
464  // if(mapME[collectionLabel+"dxy"]){ mapME[collectionLabel+"dxy"]->Fill(tk.dxy(BSPosition_)); }
465 // if(mapME[collectionLabel+"dz"]){ mapME[collectionLabel+"dz"]->Fill(tk.dz(BSPosition_)); }
466 
467 // if(mapME[collectionLabel+"validhits"]) { mapME[collectionLabel+"validhits"]->Fill(tk.numberOfValidHits()); }
468 // if(mapME[collectionLabel+"normchi"]){ mapME[collectionLabel+"normchi"]->Fill(tk.normalizedChi2()); }
469  }
470  if(mapME[collectionLabel+"nrcand"]){ mapME[collectionLabel+"nrcand"]->Fill(num);}
471  }
472 }
473 
474 
475 void HLTOniaSource::fillInvariantMass(std::vector<reco::RecoChargedCandidateRef> & cand1, std::vector<reco::RecoChargedCandidateRef> & cand2, std::string cand1Label, std::string cand2Label){
476 
477  //Loop on collection to calculate invariate mass
478  for(size_t i = 0 ; i< cand1.size(); i++) {
479 
480  //Highest PT
481  std::string chargeLabel = "same";
482 
483  //Check relative charge
484  if(cand1[i]->charge() * cand2[0]->charge() < 0) chargeLabel = "opposite";
485  if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]){
486  massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]->Fill((cand1[i]->p4()+cand2[0]->p4()).mass());
487  }
488  if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]){
489  reco::RecoChargedCandidate tk1 = (*cand1[i]);
490  reco::RecoChargedCandidate tk2 = (*cand2[0]);
491  // TrackRef tk1 = cand1[i]->get<TrackRef>();
492  // massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
493  }
494 
495 
496  for (size_t j= 0; j< cand2.size(); j++) {
497 
498  if(cand2[j]->p() < 3) continue; //Check if momentum is greater than 3GeV.
499  std::string chargeLabel = "same";
500  //Check relative charge
501  if(cand1[i]->charge() * cand2[j]->charge() < 0) chargeLabel = "opposite";
502  if(massME_[cand1Label+cand2Label+chargeLabel]){
503  massME_[cand1Label+cand2Label+chargeLabel]->Fill((cand1[i]->p4()+cand2[j]->p4()).mass());
504  }
505  if(massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]){
506  reco::RecoChargedCandidate tk1 = (*cand1[i]);
507  reco::RecoChargedCandidate tk2 = (*cand2[j]);
508  // massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
509  }
510  }
511  }
512 }
513 
514 
515 
516 void HLTOniaSource::fillInvariantMass(std::vector<reco::RecoChargedCandidateRef> & cand1, reco::RecoChargedCandidateCollection & cand2, std::string cand1Label, std::string cand2Label){
517 
518  typedef reco::RecoChargedCandidateCollection::const_iterator cand;
519  //Loop on collection to calculate invariate mass
520  for(size_t i = 0 ; i< cand1.size(); i++) {
521  //Highest PT
522  if(cand2.begin() != cand2.end() && cand2.begin()->p()>3) {
523  cand candItr = cand2.begin();
524  std::string chargeLabel = "same";
525  //Check relative charge
526  if(cand1[i]->charge() * candItr->charge() < 0) chargeLabel = "opposite";
527  if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]){
528  massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]->Fill((cand1[i]->p4()+candItr->p4()).mass());
529  }
530 
531  if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]){
532  reco::RecoChargedCandidate tk1 = (*cand1[i]);
533  reco::RecoChargedCandidate tk2 = (*candItr);
534  // massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
535  }
536  }
537 
538  for (cand candItr2= cand2.begin(); candItr2!=cand2.end(); candItr2++) {
539  if(candItr2->p() < 3) continue; //Check if momentum is greater than 3GeV.
540  std::string chargeLabel = "same";
541  //Check relative charge
542  if(cand1[i]->charge() * candItr2->charge() < 0) chargeLabel = "opposite";
543  if(massME_[cand1Label+cand2Label+chargeLabel]){
544  massME_[cand1Label+cand2Label+chargeLabel]->Fill((cand1[i]->p4()+candItr2->p4()).mass());
545  }
546  if(massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]){
547  reco::RecoChargedCandidate tk1 = (*cand1[i]);
548  reco::RecoChargedCandidate tk2 = (*candItr2);
549  // massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
550  }
551  }
552  }
553 }
554 
555 
556 
557 void HLTOniaSource::fillInvariantMass(std::vector<reco::RecoChargedCandidateRef> & cand1, reco::TrackCollection & cand2, std::string cand1Label, std::string cand2Label){
558 
559  typedef reco::TrackCollection::const_iterator cand;
560 
561  //Loop on collection to calculate invariate mass
562  for(size_t i = 0 ; i< cand1.size(); i++) {
563  //Highest PT
564  if(cand2.begin() != cand2.end() && cand2.begin()->p()>3) {
565  cand candItr = cand2.begin();
566  math::PtEtaPhiMLorentzVector bestPtCandLVector(candItr->pt(), candItr->eta(), candItr->phi(), 1.056);
567 
568  std::string chargeLabel = "same";
569 
570  //Check relative charge
571  if(cand1[i]->charge() * candItr->charge() < 0) chargeLabel = "opposite";
572  if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]){
573  massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]->Fill((cand1[i]->p4()+bestPtCandLVector).mass());
574  }
575 
576  if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]){
577  reco::RecoChargedCandidate tk1 = (*cand1[i]);
578  // massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]->Fill(fabs(tk->dz(BSPosition_) - candItr->dz(BSPosition_)));
579  }
580  }
581 
582  for (cand candIter= cand2.begin(); candIter!=cand2.end(); candIter++) {
583 
584  if(candIter->p() < 3) continue; //Check if momentum is greater than 3GeV.
585 
586  math::PtEtaPhiMLorentzVector candLVector(candIter->pt(), candIter->eta(), candIter->phi(), 1.056);
587 
588  std::string chargeLabel = "same";
589  //Check relative charge
590  if(cand1[i]->charge() * candIter->charge() < 0) chargeLabel = "opposite";
591  if(massME_[cand1Label+cand2Label+chargeLabel]){
592  massME_[cand1Label+cand2Label+chargeLabel]->Fill((cand1[i]->p4()+candLVector).mass());
593  }
594  if(massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]){
595  reco::RecoChargedCandidate tk1 = (*cand1[i]);
596  // massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]->Fill(fabs(tk->dz(BSPosition_) - candIter->dz(BSPosition_)));
597  }
598  }
599  }
600 }
601 
603 
605  bool changed(false);
606  if(hltConfig.init(run , setup, triggerProcessName, changed)){
607  edm::LogVerbatim("hltoniasource") << "Successfully initialized HLTConfigProvider with process name: "<<triggerProcessName;
608 
609  std::stringstream os;
610  std::vector<std::string> triggerNames = hltConfig.triggerNames();
611 
612  for( size_t i = 0; i < triggerNames.size(); i++) {
613  if (find(triggerPath_.begin(), triggerPath_.end(), triggerNames[i]) == triggerPath_.end()) continue;
614  edm::LogVerbatim("hltoniasource") << "[HLTOniaSource]: Trigger Path: "<<triggerNames[i];
615  std::vector<std::string> moduleNames = hltConfig.moduleLabels( triggerNames[i] );
616  for( size_t j = 0; j < moduleNames.size(); j++) {
617  TString name = moduleNames[j];
618  edm::LogVerbatim("hltoniasource") << "\t Fliter Name: "<<moduleNames[j];
619  }
620  }
621 
622  return true;
623 
624  }else{
625  edm::LogVerbatim("hltoniasource") << "Could not initialize HLTConfigProvider with process name: "<<triggerProcessName;
626  return false;
627  }
628  return true;
629 }
virtual void endJob() override
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::InputTag triggerSummaryRAWTag_
Definition: HLTOniaSource.h:62
edm::InputTag trackTag_
Definition: HLTOniaSource.h:65
std::map< std::string, MonitorElement * > pixelAfterFilterME_
Definition: HLTOniaSource.h:67
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
virtual double p() const GCC11_FINAL
magnitude of momentum vector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::map< std::string, MonitorElement * > pixelME_
Definition: HLTOniaSource.h:69
std::vector< edm::InputTag > pixelTagsAfterFilter_
Definition: HLTOniaSource.h:60
void bookOniaTriggerMEs(std::map< std::string, MonitorElement * > &, std::string)
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::vector< edm::InputTag > oniaMuonTag_
Definition: HLTOniaSource.h:59
std::map< std::string, MonitorElement * > trackME_
Definition: HLTOniaSource.h:71
std::map< std::string, MonitorElement * > massME_
Definition: HLTOniaSource.h:72
void fillInvariantMass(std::vector< reco::RecoChargedCandidateRef > &, reco::RecoChargedCandidateCollection &, std::string, std::string)
std::vector< edm::InputTag > trackTagsAfterFilter_
Definition: HLTOniaSource.h:61
std::map< std::string, MonitorElement * > trackAfterFilterME_
Definition: HLTOniaSource.h:68
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
double charge(const std::vector< uint8_t > &Ampls)
HLTOniaSource(const edm::ParameterSet &)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
edm::InputTag beamSpotTag_
Definition: HLTOniaSource.h:64
int iEvent
Definition: GenABIO.cc:243
std::vector< std::string > triggerPath_
Definition: HLTOniaSource.h:58
double p4[4]
Definition: TauolaWrapper.h:92
int j
Definition: DBlmapReader.cc:9
edm::InputTag pixelTag_
Definition: HLTOniaSource.h:63
reco::BeamSpot::Point BSPosition_
Definition: HLTOniaSource.h:41
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
bool isValid() const
Definition: HandleBase.h:76
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
edm::EDGetTokenT< reco::TrackCollection > pixelToken_
Definition: HLTOniaSource.h:76
void bookOniaTriggerInvariantMassMEs(std::map< std::string, MonitorElement * > &, std::string, std::string)
virtual int charge() const GCC11_FINAL
electric charge
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Definition: HLTOniaSource.h:78
std::string hltProcessName_
Definition: HLTOniaSource.h:56
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > trackToken_
Definition: HLTOniaSource.h:77
virtual void beginJob() override
std::string const & label() const
Definition: InputTag.h:42
std::string subsystemFolder_
Definition: HLTOniaSource.h:55
std::map< std::string, MonitorElement * > muonME_
Definition: HLTOniaSource.h:70
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
DQMStore * dbe_
Definition: HLTOniaSource.h:66
void fillOniaTriggerMEs(edm::Handle< reco::RecoChargedCandidateCollection > &, std::string, std::map< std::string, MonitorElement * > &)
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:1000
virtual float pt() const GCC11_FINAL
transverse momentum
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerSummaryRAWToken_
Definition: HLTOniaSource.h:79
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41
bool checkHLTConfiguration(const edm::Run &, const edm::EventSetup &, std::string)