CMS 3D CMS Logo

BPHMonitor.cc
Go to the documentation of this file.
2 
4 
6 
7 
8 // -----------------------------
9 // constructors and destructor
10 // -----------------------------
11 
13  folderName_ ( iConfig.getParameter<std::string>("FolderName") )
14  , muoToken_ ( mayConsume<reco::MuonCollection> (iConfig.getParameter<edm::InputTag>("muons") ) )
15  , bsToken_ ( mayConsume<reco::BeamSpot> (iConfig.getParameter<edm::InputTag>("beamSpot")))
16  , trToken_ ( mayConsume<reco::TrackCollection> (iConfig.getParameter<edm::InputTag>("tracks")))
17  , phToken_ ( mayConsume<reco::PhotonCollection> (iConfig.getParameter<edm::InputTag>("photons")))
18  , phi_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("phiPSet") ) )
19  , pt_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("ptPSet") ) )
20  , eta_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("etaPSet") ) )
21  , d0_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("d0PSet") ) )
22  , z0_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("z0PSet") ) )
23  , dR_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("dRPSet") ) )
24  , mass_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("massPSet") ) )
25  , dca_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("dcaPSet") ) )
26  , ds_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("dsPSet") ) )
27  , cos_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("cosPSet") ) )
28  , prob_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("probPSet") ) )
29  , num_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"),consumesCollector(), *this))
30  , den_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"),consumesCollector(), *this))
31  , prescaleWeightProvider_( new PrescaleWeightProvider( iConfig.getParameter<edm::ParameterSet>("PrescaleTriggerEventPSet"),consumesCollector(), *this))
32  , muoSelection_ ( iConfig.getParameter<std::string>("muoSelection") )
33  , muoSelection_ref ( iConfig.getParameter<std::string>("muoSelection_ref") )
34  , muoSelection_tag ( iConfig.getParameter<std::string>("muoSelection_tag") )
35  , muoSelection_probe ( iConfig.getParameter<std::string>("muoSelection_probe") )
36  , nmuons_ ( iConfig.getParameter<int>("nmuons" ) )
37  , tnp_ ( iConfig.getParameter<bool>("tnp" ) )
38  , L3_ ( iConfig.getParameter<int>("L3" ) )
39  , trOrMu_ ( iConfig.getParameter<int>("trOrMu" ) )
40  , Jpsi_ ( iConfig.getParameter<int>("Jpsi" ) )
41  , Upsilon_ ( iConfig.getParameter<int>("Upsilon" ) )//if ==1 path with Upsilon constraint
42  , enum_ ( iConfig.getParameter<int>("enum" ) )
43  , seagull_ ( iConfig.getParameter<int>("seagull" ) )
44  , maxmass_ ( iConfig.getParameter<double>("maxmass" ) )
45  , minmass_ ( iConfig.getParameter<double>("minmass" ) )
46  , maxmassJpsi ( iConfig.getParameter<double>("maxmassJpsi" ) )
47  , minmassJpsi ( iConfig.getParameter<double>("minmassJpsi" ) )
48  , maxmassUpsilon ( iConfig.getParameter<double>("maxmassUpsilon" ) )
49  , minmassUpsilon ( iConfig.getParameter<double>("minmassUpsilon" ) )
50  , maxmassJpsiTk ( iConfig.getParameter<double>("maxmassJpsiTk" ) )
51  , minmassJpsiTk ( iConfig.getParameter<double>("minmassJpsiTk" ) )
52  , kaon_mass ( iConfig.getParameter<double>("kaon_mass" ) )
53  , mu_mass ( iConfig.getParameter<double>("mu_mass" ) )
54  , min_dR ( iConfig.getParameter<double>("min_dR" ) )
55  , minprob ( iConfig.getParameter<double>("minprob" ) )
56  , mincos ( iConfig.getParameter<double>("mincos" ) )
57  , minDS ( iConfig.getParameter<double>("minDS" ) )
58  , hltTrigResTag_ (mayConsume<edm::TriggerResults>( iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet").getParameter<edm::InputTag>("hltInputTag")))
59  , hltInputTag_ (mayConsume<trigger::TriggerEvent>( iConfig.getParameter<edm::InputTag>("hltTriggerSummaryAOD")))
60  , hltpaths_num ( iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet").getParameter<std::vector<std::string>>("hltPaths"))
61  , hltpaths_den ( iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet").getParameter<std::vector<std::string>>("hltPaths"))
62  , trSelection_ ( iConfig.getParameter<std::string>("muoSelection") )
63  , trSelection_ref ( iConfig.getParameter<std::string>("trSelection_ref") )
64  , DMSelection_ref ( iConfig.getParameter<std::string>("DMSelection_ref") )
65 {
66 
67  muPhi_.numerator = nullptr;
68  muPhi_.denominator = nullptr;
69  muEta_.numerator = nullptr;
70  muEta_.denominator = nullptr;
71  muPt_.numerator = nullptr;
72  muPt_.denominator = nullptr;
73  mud0_.numerator = nullptr;
74  mud0_.denominator = nullptr;
75  muz0_.numerator = nullptr;
76  muz0_.denominator = nullptr;
77 
78  mu1Phi_.numerator = nullptr;
79  mu1Phi_.denominator = nullptr;
80  mu1Eta_.numerator = nullptr;
81  mu1Eta_.denominator = nullptr;
82  mu1Pt_.numerator = nullptr;
83  mu1Pt_.denominator = nullptr;
84 
85  mu2Phi_.numerator = nullptr;
86  mu2Phi_.denominator = nullptr;
87  mu2Eta_.numerator = nullptr;
88  mu2Eta_.denominator = nullptr;
89  mu2Pt_.numerator = nullptr;
90  mu2Pt_.denominator = nullptr;
91 
92  mu3Phi_.numerator = nullptr;
93  mu3Phi_.denominator = nullptr;
94  mu3Eta_.numerator = nullptr;
95  mu3Eta_.denominator = nullptr;
96  mu3Pt_.numerator = nullptr;
97  mu3Pt_.denominator = nullptr;
98 
99  phPhi_.numerator = nullptr;
100  phPhi_.denominator = nullptr;
101  phEta_.numerator = nullptr;
102  phEta_.denominator = nullptr;
103  phPt_.numerator = nullptr;
104  phPt_.denominator = nullptr;
105 
106 
107  DiMuPhi_.numerator = nullptr;
108  DiMuPhi_.denominator = nullptr;
109  DiMuEta_.numerator = nullptr;
110  DiMuEta_.denominator = nullptr;
111  DiMuPt_.numerator = nullptr;
112  DiMuPt_.denominator = nullptr;
113  DiMuPVcos_.numerator = nullptr;
114  DiMuPVcos_.denominator = nullptr;
115  DiMuProb_.numerator = nullptr;
116  DiMuProb_.denominator = nullptr;
117  DiMuDS_.numerator = nullptr;
118  DiMuDS_.denominator = nullptr;
119  DiMuDCA_.numerator = nullptr;
120  DiMuDCA_.denominator = nullptr;
121  DiMuMass_.numerator = nullptr;
122  DiMuMass_.denominator = nullptr;
123  DiMudR_.numerator = nullptr;
124  DiMudR_.denominator = nullptr;
125 
126 
127 }
128 
130 {
134 }
135 
137 {
138  // Due to the setup of the fillDescription only one of the
139  // two cases is possible at this point.
140  if (pset.existsAs<std::vector<double>>("edges")) {
141  return MEbinning{pset.getParameter<std::vector<double>>("edges")};
142  }
143 
144  return MEbinning{
145  pset.getParameter<int32_t>("nbins"),
146  pset.getParameter<double>("xmin"),
147  pset.getParameter<double>("xmax"),
148  };
149 }
150 
151 // MEbinning BPHMonitor::getHistoLSPSet(edm::ParameterSet pset)
152 // {
153 // return MEbinning{
154 // pset.getParameter<int32_t>("nbins"),
155 // 0.,
156 // double(pset.getParameter<int32_t>("nbins"))
157 // };
158 // }
159 
161 {
162  me.numerator->setAxisTitle(titleX,1);
163  me.numerator->setAxisTitle(titleY,2);
164  me.denominator->setAxisTitle(titleX,1);
165  me.denominator->setAxisTitle(titleY,2);
166 
167 }
168 
169 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, int& nbins, double& min, double& max)
170 {
171  me.numerator = ibooker.book1D(histname+"_numerator", histtitle+" (numerator)", nbins, min, max);
172  me.denominator = ibooker.book1D(histname+"_denominator", histtitle+" (denominator)", nbins, min, max);
173 }
174 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, std::vector<double> binning)
175 {
176  int nbins = binning.size()-1;
177  std::vector<float> fbinning(binning.begin(),binning.end());
178  float* arr = &fbinning[0];
179  me.numerator = ibooker.book1D(histname+"_numerator", histtitle+" (numerator)", nbins, arr);
180  me.denominator = ibooker.book1D(histname+"_denominator", histtitle+" (denominator)", nbins, arr);
181 }
182 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, int& nbinsX, double& xmin, double& xmax, double& ymin, double& ymax)
183 {
184  me.numerator = ibooker.bookProfile(histname+"_numerator", histtitle+" (numerator)", nbinsX, xmin, xmax, ymin, ymax);
185  me.denominator = ibooker.bookProfile(histname+"_denominator", histtitle+" (denominator)", nbinsX, xmin, xmax, ymin, ymax);
186 }
187 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, int& nbinsX, double& xmin, double& xmax, int& nbinsY, double& ymin, double& ymax)
188 {
189  me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax);
190  me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax);
191 }
192 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, std::vector<double> binningX, std::vector<double> binningY)
193 {
194  int nbinsX = binningX.size()-1;
195  std::vector<float> fbinningX(binningX.begin(),binningX.end());
196  float* arrX = &fbinningX[0];
197  int nbinsY = binningY.size()-1;
198  std::vector<float> fbinningY(binningY.begin(),binningY.end());
199  float* arrY = &fbinningY[0];
200 
201  me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, arrX, nbinsY, arrY);
202  me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, arrX, nbinsY, arrY);
203 }
204 
205 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME &me, std::string &histname, std::string &histtitle, /*const*/ MEbinning& binning)
206 {
207  // If the vector in the binning is filled use the bins defined there
208  // otherwise use a linear binning between min and max
209  if (binning.edges.empty()) {
210  this->bookME(ibooker, me, histname, histtitle, binning.nbins, binning.xmin, binning.xmax);
211  } else {
212  this->bookME(ibooker, me, histname, histtitle, binning.edges);
213  }
214 }
215 
216 
218  edm::Run const & iRun,
219  edm::EventSetup const & iSetup)
220 {
221 
222  std::string histname, histtitle, istnp, trMuPh;
223  bool Ph_; if (enum_==7) Ph_ = true;
224  if (tnp_) istnp = "Tag_and_Probe/"; else istnp = "";
225  std::string currentFolder = folderName_ + istnp;
226  ibooker.setCurrentFolder(currentFolder);
227  if (trOrMu_) trMuPh = "tr";else if (Ph_) trMuPh = "ph";else trMuPh = "mu";
228 
229  if (enum_==7 || enum_==1 || enum_==9 || enum_==10){
230  histname = trMuPh+"Pt"; histtitle = trMuPh+"_P_{t}";
231  bookME(ibooker,muPt_,histname,histtitle, pt_binning_);
232  setMETitle(muPt_,trMuPh+"_Pt[GeV]","events/1GeV");
233 
234  histname =trMuPh+"Phi"; histtitle =trMuPh+"Phi";
235  bookME(ibooker,muPhi_,histname,histtitle, phi_binning_);
236  setMETitle(muPhi_,trMuPh+"_#phi","events / 0.1 rad");
237 
238  histname =trMuPh+"Eta"; histtitle = trMuPh+"_Eta";
239  bookME(ibooker,muEta_,histname,histtitle, eta_binning_);
240  setMETitle(muEta_,trMuPh+"_#eta","events/ ");
241  }
242  else if(enum_==11){
243  trMuPh = "tr";
244  histname = trMuPh+"1Pt"; histtitle = trMuPh+"1_P_{t}";
245  bookME(ibooker,mu1Pt_,histname,histtitle, pt_binning_);
246  setMETitle(mu1Pt_,trMuPh+"_Pt[GeV]","events/1GeV");
247 
248  histname =trMuPh+"1Phi"; histtitle =trMuPh+"1Phi";
249  bookME(ibooker,mu1Phi_,histname,histtitle, phi_binning_);
250  setMETitle(mu1Phi_,trMuPh+"_#phi","events / 0.1 rad");
251 
252  histname =trMuPh+"1Eta"; histtitle = trMuPh+"1_Eta";
253  bookME(ibooker,mu1Eta_,histname,histtitle, eta_binning_);
254  setMETitle(mu1Eta_,trMuPh+"_#eta","events/ ");
255 
256  histname = trMuPh+"2Pt"; histtitle = trMuPh+"2_P_{t}";
257  bookME(ibooker,mu2Pt_,histname,histtitle, pt_binning_);
258  setMETitle(mu2Pt_,trMuPh+"_Pt[GeV]","events/1GeV");
259 
260  histname =trMuPh+"2Phi"; histtitle =trMuPh+"2Phi";
261  bookME(ibooker,mu2Phi_,histname,histtitle, phi_binning_);
262  setMETitle(mu2Phi_,trMuPh+"_#phi","events / 0.1 rad");
263 
264  histname =trMuPh+"2Eta"; histtitle = trMuPh+"2_Eta";
265  bookME(ibooker,mu2Eta_,histname,histtitle, eta_binning_);
266  setMETitle(mu2Eta_,trMuPh+"_#eta","events/ ");
267 
268  }
269 
270  else{
271  histname ="mu1Eta"; histtitle = "mu1Eta";
272  bookME(ibooker,mu1Eta_,histname,histtitle, eta_binning_);
273  setMETitle(mu1Eta_,"mu1#eta","events/ ");
274 
275  histname = "mu1Pt"; histtitle = "mu1_P_{t}";
276  bookME(ibooker,mu1Pt_,histname,histtitle, pt_binning_);
277  setMETitle(mu1Pt_,"mu1_Pt[GeV]","events/1GeV");
278 
279  histname ="mu1Phi"; histtitle ="mu1Phi";
280  bookME(ibooker,mu1Phi_,histname,histtitle, phi_binning_);
281  setMETitle(mu1Phi_,"mu1_#phi","events / 0.1 rad");
282 
283  histname ="mu2Eta"; histtitle = "mu2Eta";
284  bookME(ibooker,mu2Eta_,histname,histtitle, eta_binning_);
285  setMETitle(mu2Eta_,"mu2#eta","events/ ");
286 
287  histname = "mu2Pt"; histtitle = "mu2_P_{t}";
288  bookME(ibooker,mu2Pt_,histname,histtitle, pt_binning_);
289  setMETitle(mu2Pt_,"mu2_Pt[GeV]","events/1GeV");
290 
291  histname ="mu2Phi"; histtitle ="mu2Phi";
292  bookME(ibooker,mu2Phi_,histname,histtitle, phi_binning_);
293  setMETitle(mu2Phi_,"mu2_#phi","events / 0.1 rad");
294 
295  histname ="mu3Eta"; histtitle = "mu3Eta";
296  bookME(ibooker,mu3Eta_,histname,histtitle, eta_binning_);
297  setMETitle(mu3Eta_,"mu3#eta","events/ ");
298 
299  histname = "mu3Pt"; histtitle = "mu3_P_{t}";
300  bookME(ibooker,mu3Pt_,histname,histtitle, pt_binning_);
301  setMETitle(mu3Pt_,"mu3_Pt[GeV]","events/1GeV");
302 
303  histname ="mu3Phi"; histtitle ="mu3Phi";
304  bookME(ibooker,mu3Phi_,histname,histtitle, phi_binning_);
305  setMETitle(mu3Phi_,"mu3_#phi","events / 0.1 rad");
306 
307  histname ="DiMuEta"; histtitle = "DiMuEta";
308  bookME(ibooker,DiMuEta_,histname,histtitle, eta_binning_);
309  setMETitle(DiMuEta_,"DiMu#eta","events/ ");
310 
311  histname = "DiMuPt"; histtitle = "DiMu_P_{t}";
312  bookME(ibooker,DiMuPt_,histname,histtitle, pt_binning_);
313  setMETitle(DiMuPt_,"DiMu_Pt[GeV]","events/1GeV");
314 
315  histname ="DiMuPhi"; histtitle ="DiMuPhi";
316  bookME(ibooker,DiMuPhi_,histname,histtitle, phi_binning_);
317  setMETitle(DiMuPhi_,"DiMu_#phi","events / 0.1 rad");
318 
319  histname ="DiMuPVcos"; histtitle ="DiMuPVcos";
320  bookME(ibooker,DiMuPVcos_,histname,histtitle, cos_binning_);
321  setMETitle(DiMuPVcos_,"DiMu_#cosPV","events / ");
322 
323  histname ="DiMuProb"; histtitle ="DiMuProb";
324  bookME(ibooker,DiMuProb_,histname,histtitle, prob_binning_);
325  setMETitle(DiMuProb_,"DiMu_#prob","events / ");
326 
327  histname ="DiMuDS"; histtitle ="DiMuDS";
328  bookME(ibooker,DiMuDS_,histname,histtitle, ds_binning_);
329  setMETitle(DiMuDS_,"DiMu_#ds","events / ");
330 
331 
332  histname ="DiMuDCA"; histtitle ="DiMuDCA";
333  bookME(ibooker,DiMuDCA_,histname,histtitle, dca_binning_);
334  setMETitle(DiMuDCA_,"DiMu_#dca","events / ");
335 
336  histname ="DiMuMass"; histtitle ="DiMuMass";
337  bookME(ibooker,DiMuMass_,histname,histtitle, mass_binning_);
338  setMETitle(DiMuMass_,"DiMu_#mass","events / ");
339 
340  histname ="DiMudR"; histtitle ="DiMudR";
341  bookME(ibooker,DiMudR_,histname,histtitle, dR_binning_);
342  setMETitle(DiMudR_,"DiMu_#dR","events / ");
343 
344  }
345 
346  if (trOrMu_) {
347  histname =trMuPh+ "_d0"; histtitle =trMuPh+ "_d0";
348  bookME(ibooker,mud0_,histname,histtitle, d0_binning_);
349  setMETitle(mud0_,trMuPh+"_d0","events/bin ");
350 
351  histname = trMuPh+"_z0"; histtitle =trMuPh+"_z0";
352  bookME(ibooker,muz0_,histname,histtitle, z0_binning_);
353  setMETitle(muz0_,trMuPh+"_z0","events/bin ");
354  }
355 
356  // Initialize the GenericTriggerEventFlag
359  prescaleWeightProvider_->initRun( iRun, iSetup );
360 }
361 
366 #include "TLorentzVector.h"
368 
370  iEvent.getByToken( bsToken_, beamSpot);
371 
373  iEvent.getByToken( muoToken_, muoHandle );
374 
376  iEvent.getByToken( trToken_, trHandle );
377 
379  iEvent.getByToken( phToken_, phHandle );
380 
381 
382  edm::Handle<edm::TriggerResults> handleTriggerTrigRes;
383 
384  edm::Handle<trigger::TriggerEvent> handleTriggerEvent;
385  edm::ESHandle<MagneticField> bFieldHandle;
386  // Filter out events if Trigger Filtering is requested
387  double PrescaleWeight = prescaleWeightProvider_->prescaleWeight( iEvent, iSetup );
388 
389  if (tnp_>0) {//TnP method
390  if (den_genTriggerEventFlag_->on() && ! den_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
391  iEvent.getByToken( hltInputTag_, handleTriggerEvent);
392  if (handleTriggerEvent->sizeFilters()== 0)return;
393  const std::string & hltpath = hltpaths_num[0];
394  std::vector<reco::Muon> tagMuons;
395  for ( auto const & m : *muoHandle ) {//applying tag selection
396  if(false && !matchToTrigger(hltpath,m, handleTriggerEvent)) continue;
397  if ( muoSelection_ref( m ) ) tagMuons.push_back(m);
398  }
399  for (int i = 0; i<int(tagMuons.size());i++){
400  for ( auto const & m : *muoHandle ) {
401  if(false && !matchToTrigger(hltpath,m, handleTriggerEvent)) continue;
402  if ((tagMuons[i].pt() == m.pt()))continue;//not the same
403  if ((tagMuons[i].p4()+m.p4()).M() >minmass_&& (tagMuons[i].p4()+m.p4()).M() <maxmass_){//near to J/psi mass
404  muPhi_.denominator->Fill(m.phi());
405  muEta_.denominator->Fill(m.eta());
406  muPt_.denominator ->Fill(m.pt());
407  if (muoSelection_( m )){
408  muPhi_.numerator->Fill(m.phi(),PrescaleWeight);
409  muEta_.numerator->Fill(m.eta(),PrescaleWeight);
410  muPt_.numerator ->Fill(m.pt(),PrescaleWeight);
411  }
412  }
413  }
414 
415  }
416 
417 
418  }
419  else{//reference method
420  if (den_genTriggerEventFlag_->on() && ! den_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
421  iEvent.getByToken( hltInputTag_, handleTriggerEvent);
422  if (handleTriggerEvent->sizeFilters()== 0)return;
423  const std::string & hltpath = hltpaths_den[0];
424  for (auto const & m : *muoHandle ) {
425  if(false && !matchToTrigger(hltpath,m, handleTriggerEvent)) continue;
426  if(!muoSelection_ref(m))continue;
427  for (auto const & m1 : *muoHandle ) {
428  if (m1.pt() == m.pt())continue;
429  if(!muoSelection_ref(m1))continue;
430  if(false && !matchToTrigger(hltpath,m1, handleTriggerEvent)) continue;
431  if (enum_<10){
432  if (!DMSelection_ref(m1.p4() + m.p4()))continue;
433  if (m.charge()*m1.charge()>0 )continue;
434  }
435  iSetup.get<IdealMagneticFieldRecord>().get(bFieldHandle);
436  const reco::BeamSpot& vertexBeamSpot = *beamSpot;
437  std::vector<reco::TransientTrack> j_tks;
438  reco::TransientTrack mu1TT(m.track(), &(*bFieldHandle));
439  reco::TransientTrack mu2TT(m1.track(), &(*bFieldHandle));
440  j_tks.push_back(mu1TT);
441  j_tks.push_back(mu2TT);
442  KalmanVertexFitter jkvf;
443  TransientVertex jtv = jkvf.vertex(j_tks);
444  if (!jtv.isValid()) continue;
445  reco::Vertex jpsivertex = jtv;
446  float dimuonCL = 0;
447  if( (jpsivertex.chi2()>=0) && (jpsivertex.ndof()>0) )//I think these values are "unphysical"(no one will need to change them ever)so the can be fixed
448  dimuonCL = TMath::Prob(jpsivertex.chi2(), jpsivertex.ndof() );
449  math::XYZVector jpperp(m.px() + m1.px() ,
450  m.py() + m1.py() ,
451  0.);
452  GlobalPoint jVertex = jtv.position();
453  GlobalError jerr = jtv.positionError();
454  GlobalPoint displacementFromBeamspotJpsi( -1*((vertexBeamSpot.x0() - jVertex.x()) + (jVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
455  -1*((vertexBeamSpot.y0() - jVertex.y()) + (jVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
456  0);
457  reco::Vertex::Point vperpj(displacementFromBeamspotJpsi.x(), displacementFromBeamspotJpsi.y(), 0.);
458  float jpsi_cos = vperpj.Dot(jpperp)/(vperpj.R()*jpperp.R());
459  TrajectoryStateClosestToPoint mu1TS = mu1TT.impactPointTSCP();
460  TrajectoryStateClosestToPoint mu2TS = mu2TT.impactPointTSCP();
462  if (mu1TS.isValid() && mu2TS.isValid()) {
463  cApp.calculate(mu1TS.theState(), mu2TS.theState());
464  }
465  double DiMuMass = (m1.p4()+m.p4()).M();
466  switch(enum_){//enum_ = 1...9, represents different sets of variables for different paths, we want to have different hists for different paths
467  case 1: tnp_=true;//already filled hists for tnp method
468  case 2:
469  if ((Jpsi_) && (!Upsilon_)){
470  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
471  }
472  if ((!Jpsi_) && (Upsilon_)){
473  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
474  }
475  if (dimuonCL<minprob)continue;
476  mu1Phi_.denominator->Fill(m.phi());
477  mu1Eta_.denominator->Fill(m.eta());
478  mu1Pt_.denominator ->Fill(m.pt());
479  mu2Phi_.denominator->Fill(m1.phi());
480  mu2Eta_.denominator->Fill(m1.eta());
481  mu2Pt_.denominator ->Fill(m1.pt());
482  DiMuPt_.denominator ->Fill((m1.p4()+m.p4()).Pt() );
483  DiMuEta_.denominator ->Fill((m1.p4()+m.p4()).Eta() );
484  DiMuPhi_.denominator ->Fill((m1.p4()+m.p4()).Phi());
485  break;
486  case 3:
487  if ((Jpsi_) && (!Upsilon_)){
488  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
489  }
490  if ((!Jpsi_) && (Upsilon_)){
491  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
492  }
493  if (dimuonCL<minprob)continue;
494  mu1Eta_.denominator->Fill(m.eta());
495  mu1Pt_.denominator ->Fill(m.pt());
496  mu2Eta_.denominator->Fill(m1.eta());
497  mu2Pt_.denominator ->Fill(m1.pt());
498  break;
499  case 4:
500  if (dimuonCL<minprob)continue;
501  DiMuMass_.denominator ->Fill(DiMuMass);
502  if ((Jpsi_) && (!Upsilon_)){
503  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
504  }
505  if ((!Jpsi_) && (Upsilon_)){
506  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
507  }
508  mu1Phi_.denominator->Fill(m.phi());
509  mu1Eta_.denominator->Fill(m.eta());
510  mu1Pt_.denominator ->Fill(m.pt());
511  mu2Phi_.denominator->Fill(m1.phi());
512  mu2Eta_.denominator->Fill(m1.eta());
513  mu2Pt_.denominator ->Fill(m1.pt());
514  DiMuPt_.denominator ->Fill((m1.p4()+m.p4()).Pt() );
515  DiMuEta_.denominator ->Fill((m1.p4()+m.p4()).Eta() );
516  DiMuPhi_.denominator ->Fill((m1.p4()+m.p4()).Phi());
518  break;
519  case 5:
520  if (dimuonCL<minprob)continue;
521  if ((Jpsi_) && (!Upsilon_)){
522  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
523  }
524 
525  if ((!Jpsi_) && (Upsilon_)){
526  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
527  }
528  mu1Phi_.denominator->Fill(m.phi());
529  mu1Eta_.denominator->Fill(m.eta());
530  mu1Pt_.denominator ->Fill(m.pt());
531  mu2Phi_.denominator->Fill(m1.phi());
532  mu2Eta_.denominator->Fill(m1.eta());
533  mu2Pt_.denominator ->Fill(m1.pt());
534  DiMuPt_.denominator ->Fill((m1.p4()+m.p4()).Pt() );
535  DiMuEta_.denominator ->Fill((m1.p4()+m.p4()).Eta() );
536  DiMuPhi_.denominator ->Fill((m1.p4()+m.p4()).Phi());
538  break;
539  case 6:
540  if (dimuonCL<minprob)continue;
541  if ((Jpsi_) && (!Upsilon_)){
542  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
543  }
544  if ((!Jpsi_) && (Upsilon_)){
545  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
546  }
547  for (auto const & m2 : *muoHandle) {//triple muon paths
548  if(false && !matchToTrigger(hltpath,m2, handleTriggerEvent)) continue;
549  if (m2.pt() == m.pt())continue;
550  mu1Phi_.denominator->Fill(m.phi());
551  mu1Eta_.denominator->Fill(m.eta());
552  mu1Pt_.denominator ->Fill(m.pt());
553  mu2Phi_.denominator->Fill(m1.phi());
554  mu2Eta_.denominator->Fill(m1.eta());
555  mu2Pt_.denominator ->Fill(m1.pt());
556  mu3Phi_.denominator->Fill(m2.phi());
557  mu3Eta_.denominator->Fill(m2.eta());
558  mu3Pt_.denominator ->Fill(m2.pt());
559  }
560  break;
561 
562  case 7:// the hists for photon monitoring will be filled on 515 line
563  tnp_=false;
564  break;
565 
566  case 8://vtx monitoring, filling probability, DS, DCA, cos of pointing angle to the PV, eta, pT of dimuon
567  if ((Jpsi_) && (!Upsilon_)){
568  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
569  }
570 
571  if ((!Jpsi_) && (Upsilon_)){
572  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
573  }
574 
575  DiMuProb_.denominator ->Fill( dimuonCL);
576  if (dimuonCL<minprob)continue;
577  DiMuDS_.denominator ->Fill( displacementFromBeamspotJpsi.perp()/sqrt(jerr.rerr(displacementFromBeamspotJpsi)));
578  DiMuPVcos_.denominator ->Fill(jpsi_cos );
579  DiMuPt_.denominator ->Fill((m1.p4()+m.p4()).Pt() );
580  DiMuEta_.denominator ->Fill((m1.p4()+m.p4()).Eta() );
581  DiMuDCA_.denominator ->Fill( cApp.distance());
582  break;
583  case 9:
584  if (dimuonCL<minprob)continue;
585  if (fabs(jpsi_cos)<mincos)continue;
586  if ((displacementFromBeamspotJpsi.perp()/sqrt(jerr.rerr(displacementFromBeamspotJpsi)))<minDS)continue;
587 
588  if (trHandle.isValid()){
590 
591  for (auto const & t : *trHandle) {
592 
593  if(!trSelection_ref(t))continue;
594  if(false && !matchToTrigger(hltpath,t, handleTriggerEvent)) continue;
595  const reco::Track& itrk1 = t ;
596 
597  if((reco::deltaR(t,m1) <= min_dR))continue;//checking overlaping
598  if((reco::deltaR(t,m) <= min_dR)) continue;
599 
600  if (! itrk1.quality(reco::TrackBase::highPurity)) continue;
601 
603  double trackMass2 = kaon_mass * kaon_mass;
604  double MuMass2 = mu_mass * mu_mass;//0.1056583745 *0.1056583745;
605  double e1 = sqrt(m.momentum().Mag2() + MuMass2 );
606  double e2 = sqrt(m1.momentum().Mag2() + MuMass2 );
607  double e3 = sqrt(itrk1.momentum().Mag2() + trackMass2 );
608 
609  p1 = reco::Particle::LorentzVector(m.px() , m.py() , m.pz() , e1 );
610  p2 = reco::Particle::LorentzVector(m1.px() , m1.py() , m1.pz() , e2 );
611  p3 = reco::Particle::LorentzVector(itrk1.px(), itrk1.py(), itrk1.pz(), e3 );
612  pB = p1 + p2 + p3;
613  if( pB.mass()> maxmassJpsiTk || pB.mass()< minmassJpsiTk)continue;
614  reco::TransientTrack trTT(itrk1, &(*bFieldHandle));
615 
616  std::vector<reco::TransientTrack> t_tks;
617  t_tks.push_back(mu1TT);
618  t_tks.push_back(mu2TT);
619  t_tks.push_back(trTT);
620 
621  KalmanVertexFitter kvf;
622  TransientVertex tv = kvf.vertex(t_tks);
623  reco::Vertex vertex = tv;
624  if (!tv.isValid()) continue;
625  float JpsiTkCL = 0;
626  if ((vertex.chi2()>=0.0) && (vertex.ndof()>0) )
627  JpsiTkCL = TMath::Prob(vertex.chi2(), vertex.ndof() );
628  math::XYZVector pperp(m.px() + m1.px() + itrk1.px(),
629  m.py() + m1.py() + itrk1.py(),
630  0.);
631  GlobalPoint secondaryVertex = tv.position();
632  GlobalError err = tv.positionError();
633  GlobalPoint displacementFromBeamspot( -1*((vertexBeamSpot.x0() - secondaryVertex.x()) +
634  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
635  -1*((vertexBeamSpot.y0() - secondaryVertex.y()) +
636  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
637  0);
638  reco::Vertex::Point vperp(displacementFromBeamspot.x(),displacementFromBeamspot.y(),0.);
639  float jpsiKcos = vperp.Dot(pperp)/(vperp.R()*pperp.R());
640  if (JpsiTkCL<minprob)continue;
641  if (fabs(jpsiKcos)<mincos)continue;
642  if ((displacementFromBeamspot.perp()/sqrt(err.rerr(displacementFromBeamspot)))<minDS)continue;
643  muPhi_.denominator->Fill(t.phi());
644  muEta_.denominator->Fill(t.eta());
645  muPt_.denominator ->Fill(t.pt());
646 
648  }
649  }
650  break;
651  case 10:
652  if (trHandle.isValid()){
653  for (auto const & t : *trHandle) {
654  if(!trSelection_ref(t))continue;
655  if(false && !matchToTrigger(hltpath,t, handleTriggerEvent)) continue;
656  const reco::Track& itrk1 = t ;
657  if((reco::deltaR(t,m1) <= min_dR))continue;//checking overlaping
658  if((reco::deltaR(t,m) <= min_dR)) continue;
659  if (! itrk1.quality(reco::TrackBase::highPurity)) continue;
661  double trackMass2 = kaon_mass * kaon_mass;
662  double MuMass2 = mu_mass * mu_mass;//0.1056583745 *0.1056583745;
663  double e2 = sqrt(m1.momentum().Mag2() + MuMass2 );
664  double e3 = sqrt(itrk1.momentum().Mag2() + trackMass2 );
665  p2 = reco::Particle::LorentzVector(m1.px() , m1.py() , m1.pz() , e2 );
666  p3 = reco::Particle::LorentzVector(itrk1.px(), itrk1.py(), itrk1.pz(), e3 );
667  pB = p2 + p3;
668  if( pB.mass()> maxmassJpsiTk || pB.mass()< minmassJpsiTk)continue;
669  reco::TransientTrack trTT(itrk1, &(*bFieldHandle));
670  std::vector<reco::TransientTrack> t_tks;
671  t_tks.push_back(mu2TT);
672  t_tks.push_back(trTT);
673  KalmanVertexFitter kvf;
674  TransientVertex tv = kvf.vertex(t_tks);
675  reco::Vertex vertex = tv;
676  if (!tv.isValid()) continue;
677  float JpsiTkCL = 0;
678  if ((vertex.chi2()>=0.0) && (vertex.ndof()>0) )
679  JpsiTkCL = TMath::Prob(vertex.chi2(), vertex.ndof() );
680  math::XYZVector pperp(m1.px() + itrk1.px(),
681  m1.py() + itrk1.py(),
682  0.);
683  GlobalPoint secondaryVertex = tv.position();
684  GlobalError err = tv.positionError();
685  GlobalPoint displacementFromBeamspot( -1*((vertexBeamSpot.x0() - secondaryVertex.x()) +
686  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
687  -1*((vertexBeamSpot.y0() - secondaryVertex.y()) +
688  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
689  0);
690  reco::Vertex::Point vperp(displacementFromBeamspot.x(),displacementFromBeamspot.y(),0.);
691  if (JpsiTkCL<minprob)continue;
692  muPhi_.denominator->Fill(m1.phi());
693  muEta_.denominator->Fill(m1.eta());
694  muPt_.denominator ->Fill(m1.pt());
695  }
696  }
697  break;
698  case 11:
699  if (dimuonCL<minprob)continue;
700  if (fabs(jpsi_cos)<mincos)continue;
701  if ((displacementFromBeamspotJpsi.perp()/sqrt(jerr.rerr(displacementFromBeamspotJpsi)))<minDS)continue;
702  if (trHandle.isValid()){
704  for (auto const & t : *trHandle) {
705  if(!trSelection_ref(t))continue;
706  if(false && !matchToTrigger(hltpath,t, handleTriggerEvent)) continue;
707  for (auto const & t1 : *trHandle) {
708  if(!trSelection_ref(t1))continue;
709  if(false && !matchToTrigger(hltpath,t1, handleTriggerEvent)) continue;
710  const reco::Track& itrk1 = t ;
711  const reco::Track& itrk2 = t1 ;
712  if((reco::deltaR(t,m1) <= min_dR))continue;//checking overlaping
713  if((reco::deltaR(t,t1) <= min_dR))continue;//checking overlaping
714  if((reco::deltaR(t,m) <= min_dR)) continue;
715  if (! itrk1.quality(reco::TrackBase::highPurity)) continue;
716  if (! itrk2.quality(reco::TrackBase::highPurity)) continue;
718  double trackMass2 = kaon_mass * kaon_mass;
719  double MuMass2 = mu_mass * mu_mass;//0.1056583745 *0.1056583745;
720  double e1 = sqrt(m.momentum().Mag2() + MuMass2 );
721  double e2 = sqrt(m1.momentum().Mag2() + MuMass2 );
722  double e3 = sqrt(itrk1.momentum().Mag2() + trackMass2 );
723  double e4 = sqrt(itrk2.momentum().Mag2() + trackMass2 );
724  p1 = reco::Particle::LorentzVector(m.px() , m.py() , m.pz() , e1 );
725  p2 = reco::Particle::LorentzVector(m1.px() , m1.py() , m1.pz() , e2 );
726  p3 = reco::Particle::LorentzVector(itrk1.px(), itrk1.py(), itrk1.pz(), e3 );
727  p4 = reco::Particle::LorentzVector(itrk2.px(), itrk2.py(), itrk2.pz(), e4 );
728  pB = p1 + p2 + p3 + p4;
729  if( pB.mass()> maxmassJpsiTk || pB.mass()< minmassJpsiTk)continue;
730  reco::TransientTrack trTT(itrk1, &(*bFieldHandle));
731  reco::TransientTrack tr1TT(itrk2, &(*bFieldHandle));
732  std::vector<reco::TransientTrack> t_tks;
733  t_tks.push_back(mu1TT);
734  t_tks.push_back(mu2TT);
735  t_tks.push_back(trTT);
736  t_tks.push_back(tr1TT);
737  KalmanVertexFitter kvf;
738  TransientVertex tv = kvf.vertex(t_tks);
739  reco::Vertex vertex = tv;
740  if (!tv.isValid()) continue;
741  float JpsiTkCL = 0;
742  if ((vertex.chi2()>=0.0) && (vertex.ndof()>0) )
743  JpsiTkCL = TMath::Prob(vertex.chi2(), vertex.ndof() );
744  math::XYZVector pperp(m.px() + m1.px() + itrk1.px() + itrk2.px(),
745  m.py() + m1.py() + itrk1.py() + itrk2.py(),
746  0.);
747  GlobalPoint secondaryVertex = tv.position();
748  GlobalError err = tv.positionError();
749  GlobalPoint displacementFromBeamspot( -1*((vertexBeamSpot.x0() - secondaryVertex.x()) +
750  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
751  -1*((vertexBeamSpot.y0() - secondaryVertex.y()) +
752  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
753  0);
754  reco::Vertex::Point vperp(displacementFromBeamspot.x(),displacementFromBeamspot.y(),0.);
755  float jpsiKcos = vperp.Dot(pperp)/(vperp.R()*pperp.R());
756  if (JpsiTkCL<minprob)continue;
757  if (fabs(jpsiKcos)<mincos)continue;
758  if ((displacementFromBeamspot.perp()/sqrt(err.rerr(displacementFromBeamspot)))<minDS)continue;
759  mu1Phi_.denominator->Fill(t.phi());
760  mu1Eta_.denominator->Fill(t.eta());
761  mu1Pt_.denominator ->Fill(t.pt());
762  mu2Phi_.denominator->Fill(t1.phi());
763  mu2Eta_.denominator->Fill(t1.eta());
764  mu2Pt_.denominator ->Fill(t1.pt());
765  }
767  }
768  }
769  break;
770  }
771  }
772  }
773 
774 
775  if (enum_ == 7){//photons
776  const std::string & hltpath = hltpaths_den[0];
777  for (auto const & p : *phHandle) {
778  if(false && !matchToTrigger(hltpath,p, handleTriggerEvent)) continue;
779  phPhi_.denominator->Fill(p.phi());
780  phEta_.denominator->Fill(p.eta());
781  phPt_.denominator ->Fill(p.pt());
782  }
783 
784  }
785  //
787  //filling numerator hists
788  if (num_genTriggerEventFlag_->on() && ! num_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
789  iEvent.getByToken( hltInputTag_, handleTriggerEvent);
790  if (handleTriggerEvent->sizeFilters()== 0)return;
791  const std::string & hltpath1 = hltpaths_num[0];
792  for (auto const & m : *muoHandle ) {
793  if(false && !matchToTrigger(hltpath1,m, handleTriggerEvent)) continue;
794  if(!muoSelection_ref(m))continue;
795  for (auto const & m1 : *muoHandle ) {
796  if (seagull_ && ((m.charge()* deltaPhi(m.phi(), m1.phi())) > 0.) )continue;
797  if (m.charge()*m1.charge()>0 )continue;
798  if (m1.pt() == m.pt())continue;
799  if(!muoSelection_ref(m1))continue;
800  if(false && !matchToTrigger(hltpath1,m1, handleTriggerEvent)) continue;
801  if (!DMSelection_ref(m1.p4() + m.p4()))continue;
802  iSetup.get<IdealMagneticFieldRecord>().get(bFieldHandle);
803  const reco::BeamSpot& vertexBeamSpot = *beamSpot;
804  std::vector<reco::TransientTrack> j_tks;
805  reco::TransientTrack mu1TT(m.track(), &(*bFieldHandle));
806  reco::TransientTrack mu2TT(m1.track(), &(*bFieldHandle));
807  j_tks.push_back(mu1TT);
808  j_tks.push_back(mu2TT);
809  KalmanVertexFitter jkvf;
810  TransientVertex jtv = jkvf.vertex(j_tks);
811  if (!jtv.isValid()) continue;
812  reco::Vertex jpsivertex = jtv;
813  float dimuonCL = 0;
814  if( (jpsivertex.chi2()>=0) && (jpsivertex.ndof()>0) )//I think these values are "unphysical"(no one will need to change them ever)so the can be fixed
815  dimuonCL = TMath::Prob(jpsivertex.chi2(), jpsivertex.ndof() );
816  math::XYZVector jpperp(m.px() + m1.px() ,
817  m.py() + m1.py() ,
818  0.);
819  GlobalPoint jVertex = jtv.position();
820  GlobalError jerr = jtv.positionError();
821  GlobalPoint displacementFromBeamspotJpsi( -1*((vertexBeamSpot.x0() - jVertex.x()) + (jVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
822  -1*((vertexBeamSpot.y0() - jVertex.y()) + (jVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
823  0);
824  reco::Vertex::Point vperpj(displacementFromBeamspotJpsi.x(), displacementFromBeamspotJpsi.y(), 0.);
825  float jpsi_cos = vperpj.Dot(jpperp)/(vperpj.R()*jpperp.R());
826  TrajectoryStateClosestToPoint mu1TS = mu1TT.impactPointTSCP();
827  TrajectoryStateClosestToPoint mu2TS = mu2TT.impactPointTSCP();
829  if (mu1TS.isValid() && mu2TS.isValid()) {
830  cApp.calculate(mu1TS.theState(), mu2TS.theState());
831  }
832  double DiMuMass = (m1.p4()+m.p4()).M();
833  switch(enum_){//enum_ = 1...9, represents different sets of variables for different paths, we want to have different hists for different paths
834  case 1: tnp_=true;//already filled hists for tnp method
835  case 2:
836  if ((Jpsi_) && (!Upsilon_)){
837  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
838  }
839  if ((!Jpsi_) && (Upsilon_)){
840  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
841  }
842  if (dimuonCL<minprob)continue;
843  mu1Phi_.numerator->Fill(m.phi(),PrescaleWeight);
844  mu1Eta_.numerator->Fill(m.eta(),PrescaleWeight);
845  mu1Pt_.numerator ->Fill(m.pt(),PrescaleWeight);
846  mu2Phi_.numerator->Fill(m1.phi(),PrescaleWeight);
847  mu2Eta_.numerator->Fill(m1.eta(),PrescaleWeight);
848  mu2Pt_.numerator ->Fill(m1.pt(),PrescaleWeight);
849  DiMuPt_.numerator ->Fill((m1.p4()+m.p4()).Pt() ,PrescaleWeight);
850  DiMuEta_.numerator ->Fill((m1.p4()+m.p4()).Eta() ,PrescaleWeight);
851  DiMuPhi_.numerator ->Fill((m1.p4()+m.p4()).Phi(),PrescaleWeight);
852  break;
853  case 3:
854  if ((Jpsi_) && (!Upsilon_)){
855  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
856  }
857 
858  if ((!Jpsi_) && (Upsilon_)){
859  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
860  }
861  if (dimuonCL<minprob)continue;
862  mu1Eta_.numerator->Fill(m.eta(),PrescaleWeight);
863  mu1Pt_.numerator ->Fill(m.pt(),PrescaleWeight);
864  mu2Eta_.numerator->Fill(m1.eta(),PrescaleWeight);
865  mu2Pt_.numerator ->Fill(m1.pt(),PrescaleWeight);
866  break;
867  case 4:
868  if (dimuonCL<minprob)continue;
869  DiMuMass_.numerator ->Fill(DiMuMass);
870  if ((Jpsi_) && (!Upsilon_)){
871  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
872  }
873  if ((!Jpsi_) && (Upsilon_)){
874  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
875  }
876  mu1Phi_.numerator->Fill(m.phi(),PrescaleWeight);
877  mu1Eta_.numerator->Fill(m.eta(),PrescaleWeight);
878  mu1Pt_.numerator ->Fill(m.pt(),PrescaleWeight);
879  mu2Phi_.numerator->Fill(m1.phi(),PrescaleWeight);
880  mu2Eta_.numerator->Fill(m1.eta(),PrescaleWeight);
881  mu2Pt_.numerator ->Fill(m1.pt(),PrescaleWeight);
882  DiMuPt_.numerator ->Fill((m1.p4()+m.p4()).Pt() ,PrescaleWeight);
883  DiMuEta_.numerator ->Fill((m1.p4()+m.p4()).Eta() ,PrescaleWeight);
884  DiMuPhi_.numerator ->Fill((m1.p4()+m.p4()).Phi(),PrescaleWeight);
885  DiMudR_.numerator ->Fill(reco::deltaR(m,m1),PrescaleWeight);
886  break;
887  case 5:
888  if (dimuonCL<minprob)continue;
889  if ((Jpsi_) && (!Upsilon_)){
890  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
891  }
892  if ((!Jpsi_) && (Upsilon_)){
893  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
894  }
895  mu1Phi_.numerator->Fill(m.phi(),PrescaleWeight);
896  mu1Eta_.numerator->Fill(m.eta(),PrescaleWeight);
897  mu1Pt_.numerator ->Fill(m.pt(),PrescaleWeight);
898  mu2Phi_.numerator->Fill(m1.phi(),PrescaleWeight);
899  mu2Eta_.numerator->Fill(m1.eta(),PrescaleWeight);
900  mu2Pt_.numerator ->Fill(m1.pt(),PrescaleWeight);
901  DiMuPt_.numerator ->Fill((m1.p4()+m.p4()).Pt() ,PrescaleWeight);
902  DiMuEta_.numerator ->Fill((m1.p4()+m.p4()).Eta() ,PrescaleWeight);
903  DiMuPhi_.numerator ->Fill((m1.p4()+m.p4()).Phi(),PrescaleWeight);
904  DiMudR_.numerator ->Fill(reco::deltaR(m,m1),PrescaleWeight);
905  break;
906  case 6:
907  if (dimuonCL<minprob)continue;
908  if ((Jpsi_) && (!Upsilon_)){
909  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
910  }
911  if ((!Jpsi_) && (Upsilon_)){
912  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
913  }
914  for (auto const & m2 : *muoHandle) {//triple muon paths
915  if(false && !matchToTrigger(hltpath1,m2, handleTriggerEvent)) continue;
916  if (m2.pt() == m.pt())continue;
917  mu1Phi_.numerator->Fill(m.phi(),PrescaleWeight);
918  mu1Eta_.numerator->Fill(m.eta(),PrescaleWeight);
919  mu1Pt_.numerator ->Fill(m.pt(),PrescaleWeight);
920  mu2Phi_.numerator->Fill(m1.phi(),PrescaleWeight);
921  mu2Eta_.numerator->Fill(m1.eta(),PrescaleWeight);
922  mu2Pt_.numerator ->Fill(m1.pt(),PrescaleWeight);
923  mu3Phi_.numerator->Fill(m2.phi(),PrescaleWeight);
924  mu3Eta_.numerator->Fill(m2.eta(),PrescaleWeight);
925  mu3Pt_.numerator ->Fill(m2.pt(),PrescaleWeight);
926  }
927  break;
928  case 7:// the hists for photon monitoring will be filled on 515 line
929  tnp_=false;
930  break;
931  case 8://vtx monitoring, filling probability, DS, DCA, cos of pointing angle to the PV, eta, pT of dimuon
932  if ((Jpsi_) && (!Upsilon_)){
933  if (DiMuMass> maxmassJpsi || DiMuMass< minmassJpsi)continue;
934  }
935  if ((!Jpsi_) && (Upsilon_)){
936  if (DiMuMass> maxmassUpsilon || DiMuMass< minmassUpsilon)continue;
937  }
938  DiMuProb_.numerator ->Fill( dimuonCL,PrescaleWeight);
939  if (dimuonCL<minprob)continue;
940  DiMuDS_.numerator ->Fill( displacementFromBeamspotJpsi.perp()/sqrt(jerr.rerr(displacementFromBeamspotJpsi)),PrescaleWeight);
941  DiMuPVcos_.numerator ->Fill(jpsi_cos ,PrescaleWeight);
942  DiMuPt_.numerator ->Fill((m1.p4()+m.p4()).Pt() ,PrescaleWeight);
943  DiMuEta_.numerator ->Fill((m1.p4()+m.p4()).Eta() ,PrescaleWeight);
944  DiMuDCA_.numerator ->Fill( cApp.distance(),PrescaleWeight);
945  break;
946  case 9:
947  if (dimuonCL<minprob)continue;
948  if (fabs(jpsi_cos)<mincos)continue;
949  if ((displacementFromBeamspotJpsi.perp()/sqrt(jerr.rerr(displacementFromBeamspotJpsi)))<minDS)continue;
950  if (trHandle.isValid()){
951  for (auto const & t : *trHandle) {
952  if(!trSelection_ref(t))continue;
953  if(false && !matchToTrigger(hltpath1,t, handleTriggerEvent)) continue;
954  const reco::Track& itrk1 = t ;
955  if((reco::deltaR(t,m1) <= min_dR))continue;//checking overlaping
956  if((reco::deltaR(t,m) <= min_dR)) continue;
957  if (! itrk1.quality(reco::TrackBase::highPurity)) continue;
959  double trackMass2 = kaon_mass * kaon_mass;
960  double MuMass2 = mu_mass * mu_mass;//0.1056583745 *0.1056583745;
961  double e1 = sqrt(m.momentum().Mag2() + MuMass2 );
962  double e2 = sqrt(m1.momentum().Mag2() + MuMass2 );
963  double e3 = sqrt(itrk1.momentum().Mag2() + trackMass2 );
964  p1 = reco::Particle::LorentzVector(m.px() , m.py() , m.pz() , e1 );
965  p2 = reco::Particle::LorentzVector(m1.px() , m1.py() , m1.pz() , e2 );
966  p3 = reco::Particle::LorentzVector(itrk1.px(), itrk1.py(), itrk1.pz(), e3 );
967  pB = p1 + p2 + p3;
968  if( pB.mass()> maxmassJpsiTk || pB.mass()< minmassJpsiTk)continue;
969  reco::TransientTrack trTT(itrk1, &(*bFieldHandle));
970  std::vector<reco::TransientTrack> t_tks;
971  t_tks.push_back(mu1TT);
972  t_tks.push_back(mu2TT);
973  t_tks.push_back(trTT);
974  KalmanVertexFitter kvf;
975  TransientVertex tv = kvf.vertex(t_tks);
976  reco::Vertex vertex = tv;
977  if (!tv.isValid()) continue;
978  float JpsiTkCL = 0;
979  if ((vertex.chi2()>=0.0) && (vertex.ndof()>0) )
980  JpsiTkCL = TMath::Prob(vertex.chi2(), vertex.ndof() );
981  math::XYZVector pperp(m.px() + m1.px() + itrk1.px(),
982  m.py() + m1.py() + itrk1.py(),
983  0.);
984  GlobalPoint secondaryVertex = tv.position();
985  GlobalError err = tv.positionError();
986  GlobalPoint displacementFromBeamspot( -1*((vertexBeamSpot.x0() - secondaryVertex.x()) +
987  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
988  -1*((vertexBeamSpot.y0() - secondaryVertex.y()) +
989  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
990  0);
991  reco::Vertex::Point vperp(displacementFromBeamspot.x(),displacementFromBeamspot.y(),0.);
992  float jpsiKcos = vperp.Dot(pperp)/(vperp.R()*pperp.R());
993  if (JpsiTkCL<minprob)continue;
994  if (fabs(jpsiKcos)<mincos)continue;
995  if ((displacementFromBeamspot.perp()/sqrt(err.rerr(displacementFromBeamspot)))<minDS)continue;
996  muPhi_.numerator->Fill(t.phi(),PrescaleWeight);
997  muEta_.numerator->Fill(t.eta(),PrescaleWeight);
998  muPt_.numerator ->Fill(t.pt(),PrescaleWeight);
999  }
1000  }
1001  break;
1002 
1003  case 10:
1004  if (trHandle.isValid()){
1005  for (auto const & t : *trHandle) {
1006  if(!trSelection_ref(t))continue;
1007  if(false && !matchToTrigger(hltpath1,t, handleTriggerEvent)) continue;
1008  const reco::Track& itrk1 = t ;
1009  if((reco::deltaR(t,m1) <= min_dR))continue;//checking overlaping
1010  if((reco::deltaR(t,m) <= min_dR)) continue;
1011  if (! itrk1.quality(reco::TrackBase::highPurity)) continue;
1013  double trackMass2 = kaon_mass * kaon_mass;
1014  double MuMass2 = mu_mass * mu_mass;//0.1056583745 *0.1056583745;
1015  double e2 = sqrt(m1.momentum().Mag2() + MuMass2 );
1016  double e3 = sqrt(itrk1.momentum().Mag2() + trackMass2 );
1017  p2 = reco::Particle::LorentzVector(m1.px() , m1.py() , m1.pz() , e2 );
1018  p3 = reco::Particle::LorentzVector(itrk1.px(), itrk1.py(), itrk1.pz(), e3 );
1019  pB = p2 + p3;
1020  if( pB.mass()> maxmassJpsiTk || pB.mass()< minmassJpsiTk)continue;
1021  reco::TransientTrack trTT(itrk1, &(*bFieldHandle));
1022  std::vector<reco::TransientTrack> t_tks;
1023  t_tks.push_back(mu2TT);
1024  t_tks.push_back(trTT);
1025  if (t_tks.size()!=2) continue;
1026  KalmanVertexFitter kvf;
1027  TransientVertex tv = kvf.vertex(t_tks);
1028  reco::Vertex vertex = tv;
1029  if (!tv.isValid()) continue;
1030  float JpsiTkCL = 0;
1031  if ((vertex.chi2()>=0.0) && (vertex.ndof()>0) )
1032  JpsiTkCL = TMath::Prob(vertex.chi2(), vertex.ndof() );
1033  math::XYZVector pperp(m1.px() + itrk1.px(),
1034  m1.py() + itrk1.py(),
1035  0.);
1036  GlobalPoint secondaryVertex = tv.position();
1037  GlobalError err = tv.positionError();
1038  GlobalPoint displacementFromBeamspot( -1*((vertexBeamSpot.x0() - secondaryVertex.x()) +
1039  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
1040  -1*((vertexBeamSpot.y0() - secondaryVertex.y()) +
1041  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
1042  0);
1043  reco::Vertex::Point vperp(displacementFromBeamspot.x(),displacementFromBeamspot.y(),0.);
1044  if (JpsiTkCL<minprob)continue;
1045  muPhi_.numerator->Fill(m1.phi(),PrescaleWeight);
1046  muEta_.numerator->Fill(m1.eta(),PrescaleWeight);
1047  muPt_.numerator ->Fill(m1.pt(),PrescaleWeight);
1048  }
1049  }
1050  break;
1051  case 11:
1052  if (dimuonCL<minprob)continue;
1053  if (fabs(jpsi_cos)<mincos)continue;
1054  if ((displacementFromBeamspotJpsi.perp()/sqrt(jerr.rerr(displacementFromBeamspotJpsi)))<minDS)continue;
1055  if (trHandle.isValid()){
1056  for (auto const & t : *trHandle) {
1057  if(!trSelection_ref(t))continue;
1058  if(false && !matchToTrigger(hltpath1,t, handleTriggerEvent)) continue;
1059  for (auto const & t1 : *trHandle) {
1060  if(!trSelection_ref(t1))continue;
1061  if(false && !matchToTrigger(hltpath1,t1, handleTriggerEvent)) continue;
1062  const reco::Track& itrk1 = t ;
1063  const reco::Track& itrk2 = t1 ;
1064  if((reco::deltaR(t,m1) <= min_dR))continue;//checking overlaping
1065  if((reco::deltaR(t,t1) <= min_dR))continue;//checking overlaping
1066  if((reco::deltaR(t,m) <= min_dR)) continue;
1067  if (! itrk1.quality(reco::TrackBase::highPurity)) continue;
1068  if (! itrk2.quality(reco::TrackBase::highPurity)) continue;
1069 
1071  double trackMass2 = kaon_mass * kaon_mass;
1072  double MuMass2 = mu_mass * mu_mass;//0.1056583745 *0.1056583745;
1073  double e1 = sqrt(m.momentum().Mag2() + MuMass2 );
1074  double e2 = sqrt(m1.momentum().Mag2() + MuMass2 );
1075  double e3 = sqrt(itrk1.momentum().Mag2() + trackMass2 );
1076  double e4 = sqrt(itrk2.momentum().Mag2() + trackMass2 );
1077  p1 = reco::Particle::LorentzVector(m.px() , m.py() , m.pz() , e1 );
1078  p2 = reco::Particle::LorentzVector(m1.px() , m1.py() , m1.pz() , e2 );
1079  p3 = reco::Particle::LorentzVector(itrk1.px(), itrk1.py(), itrk1.pz(), e3 );
1080  p4 = reco::Particle::LorentzVector(itrk2.px(), itrk2.py(), itrk2.pz(), e4 );
1081  pB = p1 + p2 + p3 + p4;
1082  if( pB.mass()> maxmassJpsiTk || pB.mass()< minmassJpsiTk)continue;
1083  reco::TransientTrack trTT(itrk1, &(*bFieldHandle));
1084  reco::TransientTrack tr1TT(itrk2, &(*bFieldHandle));
1085  std::vector<reco::TransientTrack> t_tks;
1086  t_tks.push_back(mu1TT);
1087  t_tks.push_back(mu2TT);
1088  t_tks.push_back(trTT);
1089  t_tks.push_back(tr1TT);
1090  KalmanVertexFitter kvf;
1091  TransientVertex tv = kvf.vertex(t_tks);
1092  reco::Vertex vertex = tv;
1093  if (!tv.isValid()) continue;
1094  float JpsiTkCL = 0;
1095  if ((vertex.chi2()>=0.0) && (vertex.ndof()>0) )
1096  JpsiTkCL = TMath::Prob(vertex.chi2(), vertex.ndof() );
1097  math::XYZVector pperp(m.px() + m1.px() + itrk1.px() + itrk2.px(),
1098  m.py() + m1.py() + itrk1.py() + itrk2.py(),
1099  0.);
1100  GlobalPoint secondaryVertex = tv.position();
1101  GlobalError err = tv.positionError();
1102  GlobalPoint displacementFromBeamspot( -1*((vertexBeamSpot.x0() - secondaryVertex.x()) +
1103  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dxdz()),
1104  -1*((vertexBeamSpot.y0() - secondaryVertex.y()) +
1105  (secondaryVertex.z() - vertexBeamSpot.z0()) * vertexBeamSpot.dydz()),
1106  0);
1107  reco::Vertex::Point vperp(displacementFromBeamspot.x(),displacementFromBeamspot.y(),0.);
1108  float jpsiKcos = vperp.Dot(pperp)/(vperp.R()*pperp.R());
1109  if (JpsiTkCL<minprob)continue;
1110  if (fabs(jpsiKcos)<mincos)continue;
1111  if ((displacementFromBeamspot.perp()/sqrt(err.rerr(displacementFromBeamspot)))<minDS)continue;
1112  mu1Phi_.numerator->Fill(t.phi(),PrescaleWeight);
1113  mu1Eta_.numerator->Fill(t.eta(),PrescaleWeight);
1114  mu1Pt_.numerator ->Fill(t.pt(),PrescaleWeight);
1115  mu2Phi_.numerator->Fill(t1.phi(),PrescaleWeight);
1116  mu2Eta_.numerator->Fill(t1.eta(),PrescaleWeight);
1117  mu2Pt_.numerator ->Fill(t1.pt(),PrescaleWeight);
1118  }
1120  }
1121  }
1122  break;
1123  }
1124  }
1125  }
1126  if (enum_ == 7){//photons
1127  const std::string &hltpath = hltpaths_num[0];
1128  for (auto const & p : *phHandle) {
1129  if(false && !matchToTrigger(hltpath,p, handleTriggerEvent)) continue;
1130  phPhi_.numerator->Fill(p.phi(),PrescaleWeight);
1131  phEta_.numerator->Fill(p.eta(),PrescaleWeight);
1132  phPt_.numerator ->Fill(p.pt(),PrescaleWeight);
1133  }
1134  }
1135  }
1136 }
1137 
1138 
1139 
1140 
1142 {
1143  pset.addNode((edm::ParameterDescription<int>("nbins", true) and
1144  edm::ParameterDescription<double>("xmin", true) and
1145  edm::ParameterDescription<double>("xmax", true)) xor
1146  edm::ParameterDescription<std::vector<double>>("edges", true));
1147 }
1148 
1150 {
1151  pset.add<int> ( "nbins", 2500);
1152 }
1153 
1155 {
1157  desc.add<std::string> ( "FolderName", "HLT/BPH/" );
1158  desc.add<edm::InputTag>( "tracks", edm::InputTag("generalTracks") );
1159  desc.add<edm::InputTag>( "photons", edm::InputTag("photons") );
1160  desc.add<edm::InputTag>( "offlinePVs", edm::InputTag("offlinePrimaryVertices") );
1161  desc.add<edm::InputTag>( "beamSpot",edm::InputTag("offlineBeamSpot") );
1162  desc.add<edm::InputTag>( "muons", edm::InputTag("muons") );
1163  desc.add<edm::InputTag>( "hltTriggerSummaryAOD", edm::InputTag("hltTriggerSummaryAOD","","HLT") );
1164  desc.add<std::string>("muoSelection", "abs(eta)<1.4 & isPFMuon & isGlobalMuon & innerTrack.hitPattern.trackerLayersWithMeasurement>5 & innerTrack.hitPattern.numberOfValidPixelHits>0");
1165  desc.add<std::string>("muoSelection_ref", "isPFMuon & isGlobalMuon & innerTrack.hitPattern.trackerLayersWithMeasurement>5 & innerTrack.hitPattern.numberOfValidPixelHits>0");
1166  desc.add<std::string>("muoSelection_tag", "isGlobalMuon && isPFMuon && isTrackerMuon && abs(eta) < 2.4 && innerTrack.hitPattern.numberOfValidPixelHits > 0 && innerTrack.hitPattern.trackerLayersWithMeasurement > 5 && globalTrack.hitPattern.numberOfValidMuonHits > 0 && globalTrack.normalizedChi2 < 10");//tight selection for tag muon
1167  desc.add<std::string>("muoSelection_probe", "isPFMuon & isGlobalMuon & innerTrack.hitPattern.trackerLayersWithMeasurement>5 & innerTrack.hitPattern.numberOfValidPixelHits>0");
1168  desc.add<std::string>("trSelection_ref", "");
1169  desc.add<std::string>("DMSelection_ref", "Pt>4 & abs(eta)");
1170 
1171  desc.add<int>("nmuons", 1);
1172  desc.add<bool>( "tnp", false );
1173  desc.add<int>( "L3", 0 );
1174  desc.add<int>( "trOrMu", 0 );//if =0, track param monitoring
1175  desc.add<int>( "Jpsi", 0 );
1176  desc.add<int>( "Upsilon", 0 );
1177  desc.add<int>( "enum", 1 );//1...9, 9 sets of variables to be filled, depends on the hlt path
1178  desc.add<int>( "seagull", 1 );//1...9, 9 sets of variables to be filled, depends on the hlt path
1179  desc.add<double>( "maxmass", 3.596 );
1180  desc.add<double>( "minmass", 2.596 );
1181  desc.add<double>( "maxmassJpsi", 3.2 );
1182  desc.add<double>( "minmassJpsi", 3. );
1183  desc.add<double>( "maxmassUpsilon", 8.1 );
1184  desc.add<double>( "minmassUpsilon", 8. );
1185  desc.add<double>( "maxmassJpsiTk", 5.46 );
1186  desc.add<double>( "minmassJpsiTk", 5.1 );
1187  desc.add<double>( "kaon_mass", 0.493677 );
1188  desc.add<double>( "mu_mass", 0.1056583745);
1189  desc.add<double>( "min_dR", 0.001);
1190  desc.add<double>( "minprob", 0.005 );
1191  desc.add<double>( "mincos", 0.95 );
1192  desc.add<double>( "minDS", 3. );
1193 
1194  edm::ParameterSetDescription genericTriggerEventPSet;
1195  genericTriggerEventPSet.add<bool>("andOr");
1196  genericTriggerEventPSet.add<edm::InputTag>("dcsInputTag", edm::InputTag("scalersRawToDigi") );
1197  genericTriggerEventPSet.add<edm::InputTag>("hltInputTag", edm::InputTag("TriggerResults::HLT") );
1198  genericTriggerEventPSet.add<std::vector<int> >("dcsPartitions",{});
1199  genericTriggerEventPSet.add<bool>("andOrDcs", false);
1200  genericTriggerEventPSet.add<bool>("errorReplyDcs", true);
1201  genericTriggerEventPSet.add<std::string>("dbLabel","");
1202  genericTriggerEventPSet.add<bool>("andOrHlt", true);
1203  genericTriggerEventPSet.add<bool>("andOrL1", true);
1204  genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths",{});
1205  genericTriggerEventPSet.add<std::vector<std::string> >("l1Algorithms",{});
1206  genericTriggerEventPSet.add<std::string>("hltDBKey","");
1207  genericTriggerEventPSet.add<bool>("errorReplyHlt",false);
1208  genericTriggerEventPSet.add<bool>("errorReplyL1",true);
1209  genericTriggerEventPSet.add<bool>("l1BeforeMask",true);
1210  genericTriggerEventPSet.add<unsigned int>("verbosityLevel",0);
1211  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
1212  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
1213 
1214  edm::ParameterSetDescription PrescaleTriggerEventPSet;
1215  PrescaleTriggerEventPSet.add<unsigned int>("prescaleWeightVerbosityLevel",0);
1216  PrescaleTriggerEventPSet.add<edm::InputTag>("prescaleWeightTriggerResults",edm::InputTag("TriggerResults::HLT"));
1217  PrescaleTriggerEventPSet.add<edm::InputTag>("prescaleWeightL1GtTriggerMenuLite",edm::InputTag("l1GtTriggerMenuLite"));
1218  PrescaleTriggerEventPSet.add<std::vector<std::string>>("prescaleWeightHltPaths",{});
1219  desc.add<edm::ParameterSetDescription>("PrescaleTriggerEventPSet", PrescaleTriggerEventPSet);
1220 
1221  edm::ParameterSetDescription histoPSet;
1233  fillHistoPSetDescription(phiPSet);
1234  fillHistoPSetDescription(ptPSet);
1235  fillHistoPSetDescription(etaPSet);
1236  fillHistoPSetDescription(z0PSet);
1237  fillHistoPSetDescription(d0PSet);
1238  fillHistoPSetDescription(dRPSet);
1239  fillHistoPSetDescription(massPSet);
1240  fillHistoPSetDescription(dcaPSet);
1241  fillHistoPSetDescription(dsPSet);
1242  fillHistoPSetDescription(cosPSet);
1243  fillHistoPSetDescription(probPSet);
1244  histoPSet.add<edm::ParameterSetDescription>("d0PSet", d0PSet);
1245  histoPSet.add<edm::ParameterSetDescription>("etaPSet", etaPSet);
1246  histoPSet.add<edm::ParameterSetDescription>("phiPSet", phiPSet);
1247  histoPSet.add<edm::ParameterSetDescription>("ptPSet", ptPSet);
1248  histoPSet.add<edm::ParameterSetDescription>("z0PSet", z0PSet);
1249  histoPSet.add<edm::ParameterSetDescription>("dRPSet", dRPSet);
1250  histoPSet.add<edm::ParameterSetDescription>("massPSet", massPSet);
1251  histoPSet.add<edm::ParameterSetDescription>("dcaPSet", dcaPSet);
1252  histoPSet.add<edm::ParameterSetDescription>("dsPSet", dsPSet);
1253  histoPSet.add<edm::ParameterSetDescription>("cosPSet", cosPSet);
1254  histoPSet.add<edm::ParameterSetDescription>("probPSet", probPSet);
1255  desc.add<edm::ParameterSetDescription>("histoPSet",histoPSet);
1256 
1257  descriptions.add("bphMonitoring", desc);
1258 }
1259 template <typename T>
1260 bool BPHMonitor::matchToTrigger(const std::string &theTriggerName , T t, edm::Handle<trigger::TriggerEvent> handleTriggerEvent){
1261  //bool BPHMonitor::matchToTrigger(std::string theTriggerName,T t, edm::Handle<trigger::TriggerEventWithRefs> handleTriggerEvent){
1262 
1263  bool matchedToTrigger = false;
1264  if (handleTriggerEvent->sizeFilters() >0){
1265  const trigger::TriggerObjectCollection & toc(handleTriggerEvent->getObjects());//Handle< trigger::TriggerEvent > handleTriggerEvent;
1266  for ( size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ ia) {
1267  std::string fullname = handleTriggerEvent->filterTag(ia).encode();
1268  std::string name;
1269  size_t p = fullname.find_first_of(':');
1270  if ( p != std::string::npos) {name = fullname.substr(0, p);}
1271  else {name = fullname;}
1272  const trigger::Keys & k = handleTriggerEvent->filterKeys(ia);
1273  for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
1274  reco::Particle theTriggerParticle = toc[*ki].particle();
1275  if(name.find(theTriggerName) != string::npos){
1276  if((reco::deltaR(t.eta(), t.phi(),theTriggerParticle.eta(),theTriggerParticle.phi()) <= 0.2)){
1277  matchedToTrigger = true;
1278  }
1279  }
1280  }
1281  }
1282 
1283  return matchedToTrigger;
1284  }
1285  else {cout<<theTriggerName<<"\t\tNo HLT filters"<<endl; return false;}
1286 }
1287 
1288 
1289 
1290 
1291 // Define this as a plug-in
GlobalError positionError() const
MEbinning z0_binning_
Definition: BPHMonitor.h:111
int seagull_
Definition: BPHMonitor.h:173
MonitorElement * numerator
Definition: BPHMonitor.h:60
T getParameter(std::string const &) const
double z0() const
z coordinate
Definition: BeamSpot.h:68
METME mu2Phi_
Definition: BPHMonitor.h:130
int Upsilon_
Definition: BPHMonitor.h:171
METME DiMuDCA_
Definition: BPHMonitor.h:152
float distance() const override
METME phEta_
Definition: BPHMonitor.h:144
METME phPt_
Definition: BPHMonitor.h:145
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
StringCutObjectSelector< reco::Candidate::LorentzVector, true > DMSelection_ref
Definition: BPHMonitor.h:195
T perp() const
Definition: PV3DBase.h:72
double maxmassJpsiTk
Definition: BPHMonitor.h:180
double kaon_mass
Definition: BPHMonitor.h:182
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
METME mu2Pt_
Definition: BPHMonitor.h:132
METME muPt_
Definition: BPHMonitor.h:121
int prescaleWeight(const edm::Event &event, const edm::EventSetup &setup)
METME mu1Eta_
Definition: BPHMonitor.h:126
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
METME phPhi_
Definition: BPHMonitor.h:143
const FreeTrajectoryState & theState() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< reco::MuonCollection > muoToken_
Definition: BPHMonitor.h:102
void bookME(DQMStore::IBooker &, METME &me, std::string &histname, std::string &histtitle, int &nbins, double &xmin, double &xmax)
Definition: BPHMonitor.cc:169
std::string folderName_
Definition: BPHMonitor.h:99
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
T y() const
Definition: PV3DBase.h:63
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
Definition: BPHMonitor.cc:1149
METME mu2Eta_
Definition: BPHMonitor.h:131
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
METME DiMuPhi_
Definition: BPHMonitor.h:146
METME mu3Pt_
Definition: BPHMonitor.h:137
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
std::vector< double > edges
Definition: BPHMonitor.h:56
PrescaleWeightProvider * prescaleWeightProvider_
Definition: BPHMonitor.h:161
MEbinning eta_binning_
Definition: BPHMonitor.h:109
bool matchToTrigger(const std::string &theTriggerName, T t, edm::Handle< trigger::TriggerEvent > handleTriggerEvent)
Definition: BPHMonitor.cc:1260
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:627
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:675
edm::EDGetTokenT< trigger::TriggerEvent > hltInputTag_
Definition: BPHMonitor.h:190
std::string encode() const
Definition: InputTag.cc:166
edm::EDGetTokenT< reco::TrackCollection > trToken_
Definition: BPHMonitor.h:104
double minmass_
Definition: BPHMonitor.h:175
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
double minprob
Definition: BPHMonitor.h:186
void Fill(long long x)
METME mu1Phi_
Definition: BPHMonitor.h:125
METME DiMuEta_
Definition: BPHMonitor.h:147
double dydz() const
dydz slope
Definition: BeamSpot.h:84
MEbinning dca_binning_
Definition: BPHMonitor.h:114
int iEvent
Definition: GenABIO.cc:230
void setMETitle(METME &me, std::string titleX, std::string titleY)
Definition: BPHMonitor.cc:160
MEbinning pt_binning_
Definition: BPHMonitor.h:108
double phi() const
momentum azimuthal angle
Definition: Particle.h:106
double mincos
Definition: BPHMonitor.h:187
double maxmassJpsi
Definition: BPHMonitor.h:176
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
MEbinning dR_binning_
Definition: BPHMonitor.h:112
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
GlobalPoint position() const
double xmin
Definition: LumiMonitor.h:30
T z() const
Definition: PV3DBase.h:64
double mu_mass
Definition: BPHMonitor.h:183
GenericTriggerEventFlag * den_genTriggerEventFlag_
Definition: BPHMonitor.h:160
BPHMonitor(const edm::ParameterSet &)
Definition: BPHMonitor.cc:12
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
double chi2() const
chi-squares
Definition: Vertex.h:98
MonitorElement * denominator
Definition: BPHMonitor.h:61
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
METME DiMuDS_
Definition: BPHMonitor.h:151
void initRun(const edm::Run &run, const edm::EventSetup &setup)
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
MEbinning phi_binning_
Definition: BPHMonitor.h:107
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
Definition: BPHMonitor.cc:1141
T min(T a, T b)
Definition: MathUtil.h:58
MEbinning ds_binning_
Definition: BPHMonitor.h:115
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
double p2[4]
Definition: TauolaWrapper.h:90
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
Definition: BPHMonitor.cc:367
double maxmass_
Definition: BPHMonitor.h:174
MEbinning prob_binning_
Definition: BPHMonitor.h:117
MEbinning cos_binning_
Definition: BPHMonitor.h:116
double dxdz() const
dxdz slope
Definition: BeamSpot.h:82
double ndof() const
Definition: Vertex.h:105
std::vector< std::string > hltpaths_den
Definition: BPHMonitor.h:192
StringCutObjectSelector< reco::Muon, true > muoSelection_
Definition: BPHMonitor.h:162
METME muz0_
Definition: BPHMonitor.h:123
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:639
METME DiMuProb_
Definition: BPHMonitor.h:150
MEbinning d0_binning_
Definition: BPHMonitor.h:110
int k[5][pyjets_maxn]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: BPHMonitor.cc:217
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
double minmassJpsiTk
Definition: BPHMonitor.h:181
Float e1
Definition: deltaR.h:20
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:103
edm::EDGetTokenT< reco::PhotonCollection > phToken_
Definition: BPHMonitor.h:105
edm::EDGetTokenT< reco::BeamSpot > bsToken_
Definition: BPHMonitor.h:103
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: BPHMonitor.cc:1154
~BPHMonitor() override
Definition: BPHMonitor.cc:129
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
double minDS
Definition: BPHMonitor.h:188
StringCutObjectSelector< reco::Muon, true > muoSelection_ref
Definition: BPHMonitor.h:163
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
This class takes a vector of HLT paths and returns a weight based on their HLT and L1 prescales...
std::vector< size_type > Keys
T rerr(const GlobalPoint &aPoint) const
double minmassUpsilon
Definition: BPHMonitor.h:179
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
const T & get() const
Definition: EventSetup.h:55
static MEbinning getHistoPSet(edm::ParameterSet pset)
Definition: BPHMonitor.cc:136
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double maxmassUpsilon
Definition: BPHMonitor.h:178
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:510
Float e2
Definition: deltaR.h:21
fixed size matrix
METME muEta_
Definition: BPHMonitor.h:120
HLT enums.
double p1[4]
Definition: TauolaWrapper.h:89
METME DiMuMass_
Definition: BPHMonitor.h:153
METME DiMuPt_
Definition: BPHMonitor.h:148
MEbinning mass_binning_
Definition: BPHMonitor.h:113
METME mud0_
Definition: BPHMonitor.h:122
double y0() const
y coordinate
Definition: BeamSpot.h:66
METME mu1Pt_
Definition: BPHMonitor.h:127
METME mu3Phi_
Definition: BPHMonitor.h:135
std::vector< std::string > hltpaths_num
Definition: BPHMonitor.h:191
METME mu3Eta_
Definition: BPHMonitor.h:136
double minmassJpsi
Definition: BPHMonitor.h:177
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
METME DiMuPVcos_
Definition: BPHMonitor.h:149
long double T
METME DiMudR_
Definition: BPHMonitor.h:154
T x() const
Definition: PV3DBase.h:62
double eta() const
momentum pseudorapidity
Definition: Particle.h:110
GenericTriggerEventFlag * num_genTriggerEventFlag_
Definition: BPHMonitor.h:159
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
bool isValid() const
METME muPhi_
Definition: BPHMonitor.h:119
StringCutObjectSelector< reco::Track, true > trSelection_ref
Definition: BPHMonitor.h:194
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:633
Definition: Run.h:43
double xmax
Definition: LumiMonitor.h:31
double p3[4]
Definition: TauolaWrapper.h:91
double x0() const
x coordinate
Definition: BeamSpot.h:64
double min_dR
Definition: BPHMonitor.h:184