CMS 3D CMS Logo

DiMuonVertexValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Alignment/OfflineValidation
4 // Class: DiMuonVertexValidation
5 //
11 //
12 // Original Author: Marco Musich
13 // Created: Wed, 21 Apr 2021 09:06:25 GMT
14 //
15 //
16 
17 // system include files
18 #include <memory>
19 #include <utility>
20 
21 // user include files
28 
29 // muons
33 
34 // utils
37 #include "TLorentzVector.h"
38 
39 // tracks
46 
47 // vertices
52 
53 // ROOT
54 #include "TH1F.h"
55 #include "TH2F.h"
56 
57 //#define LogDebug(X) std::cout << X <<
58 
59 //
60 // class declaration
61 //
62 
63 class DiMuonVertexValidation : public edm::one::EDAnalyzer<edm::one::SharedResources> {
64 public:
66  ~DiMuonVertexValidation() override;
67 
68  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
69 
70 private:
71  void beginJob() override;
72  void analyze(const edm::Event&, const edm::EventSetup&) override;
74  void endJob() override;
75 
76  // ----------member data ---------------------------
78 
79  const bool useReco_;
80  const bool useClosestVertex_;
81  std::vector<double> pTthresholds_;
82  const float maxSVdist_;
83 
84  // plot configurations
93 
94  // control plots
95 
96  TH1F* hSVProb_;
97  TH1F* hSVDist_;
98  TH1F* hSVDistSig_;
99  TH1F* hSVDist3D_;
101 
102  TH1F* hCosPhi_;
103  TH1F* hCosPhi3D_;
104  TH1F* hCosPhiInv_;
106 
107  TH1F* hInvMass_;
109 
110  TH1F* hCutFlow_;
111 
112  // 2D maps
113 
122 
123  // plots vs region
126 
128 
129  //used to select what tracks to read from configuration file
131  //used to select what vertices to read from configuration file
133 
134  // either on or the other!
135  edm::EDGetTokenT<reco::MuonCollection> muonsToken_; // used to select tracks to read from configuration file
136  edm::EDGetTokenT<reco::TrackCollection> alcaRecoToken_; //used to select muon tracks to read from configuration file
137 };
138 
139 //
140 // constants, enums and typedefs
141 //
142 
143 static constexpr float cmToum = 10e4;
144 static constexpr float mumass2 = 0.105658367 * 0.105658367; //mu mass squared (GeV^2/c^4)
145 
146 //
147 // static data member definitions
148 //
149 
150 //
151 // constructors and destructor
152 //
154  : useReco_(iConfig.getParameter<bool>("useReco")),
155  useClosestVertex_(iConfig.getParameter<bool>("useClosestVertex")),
156  pTthresholds_(iConfig.getParameter<std::vector<double>>("pTThresholds")),
157  maxSVdist_(iConfig.getParameter<double>("maxSVdist")),
158  CosPhiConfiguration_(iConfig.getParameter<edm::ParameterSet>("CosPhiConfig")),
159  CosPhi3DConfiguration_(iConfig.getParameter<edm::ParameterSet>("CosPhi3DConfig")),
160  VtxProbConfiguration_(iConfig.getParameter<edm::ParameterSet>("VtxProbConfig")),
161  VtxDistConfiguration_(iConfig.getParameter<edm::ParameterSet>("VtxDistConfig")),
162  VtxDist3DConfiguration_(iConfig.getParameter<edm::ParameterSet>("VtxDist3DConfig")),
163  VtxDistSigConfiguration_(iConfig.getParameter<edm::ParameterSet>("VtxDistSigConfig")),
164  VtxDist3DSigConfiguration_(iConfig.getParameter<edm::ParameterSet>("VtxDist3DSigConfig")),
165  DiMuMassConfiguration_(iConfig.getParameter<edm::ParameterSet>("DiMuMassConfig")),
166  ttbESToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
167  vertexToken_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))) {
168  if (useReco_) {
169  tracksToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
170  muonsToken_ = consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muons"));
171  } else {
172  alcaRecoToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("muonTracks"));
173  }
174 
175  usesResource(TFileService::kSharedResource);
176 
177  // sort the vector of thresholds
178  std::sort(pTthresholds_.begin(), pTthresholds_.end(), [](const double& lhs, const double& rhs) { return lhs > rhs; });
179 
180  edm::LogInfo("DiMuonVertexValidation") << __FUNCTION__;
181  for (const auto& thr : pTthresholds_) {
182  edm::LogInfo("DiMuonVertexValidation") << " Threshold: " << thr << " ";
183  }
184  edm::LogInfo("DiMuonVertexValidation") << "Max SV distance: " << maxSVdist_ << " ";
185 }
186 
188 
189 //
190 // member functions
191 //
192 
193 // ------------ method called for each event ------------
195  using namespace edm;
196 
198 
199  // the di-muon tracks
200  std::vector<const reco::Track*> myTracks;
201 
202  // if we have to start from scratch from RECO data-tier
203  if (useReco_) {
204  // select the good muons
205  std::vector<const reco::Muon*> myGoodMuonVector;
206  for (const auto& muon : iEvent.get(muonsToken_)) {
207  const reco::TrackRef t = muon.innerTrack();
208  if (!t.isNull()) {
209  if (t->quality(reco::TrackBase::highPurity)) {
210  if (t->chi2() / t->ndof() <= 2.5 && t->numberOfValidHits() >= 5 &&
211  t->hitPattern().numberOfValidPixelHits() >= 2 && t->quality(reco::TrackBase::highPurity))
212  myGoodMuonVector.emplace_back(&muon);
213  }
214  }
215  }
216 
217  LogDebug("DiMuonVertexValidation") << "myGoodMuonVector size: " << myGoodMuonVector.size() << std::endl;
218  std::sort(myGoodMuonVector.begin(), myGoodMuonVector.end(), [](const reco::Muon*& lhs, const reco::Muon*& rhs) {
219  return lhs->pt() > rhs->pt();
220  });
221 
222  // just check the ordering
223  for (const auto& muon : myGoodMuonVector) {
224  LogDebug("DiMuonVertexValidation") << "pT: " << muon->pt() << " ";
225  }
226  LogDebug("DiMuonVertexValidation") << std::endl;
227 
228  // reject if there's no Z
229  if (myGoodMuonVector.size() < 2)
230  return;
231 
233 
234  if ((myGoodMuonVector[0]->pt()) < pTthresholds_[0] || (myGoodMuonVector[1]->pt() < pTthresholds_[1]))
235  return;
236 
239 
240  if (myGoodMuonVector[0]->charge() * myGoodMuonVector[1]->charge() > 0)
241  return;
242 
243  const auto& m1 = myGoodMuonVector[1]->p4();
244  const auto& m0 = myGoodMuonVector[0]->p4();
245  const auto& mother = m0 + m1;
246 
247  float invMass = mother.M();
248  hInvMass_->Fill(invMass);
249 
250  // just copy the top two muons
251  std::vector<const reco::Muon*> theZMuonVector;
252  theZMuonVector.reserve(2);
253  theZMuonVector.emplace_back(myGoodMuonVector[1]);
254  theZMuonVector.emplace_back(myGoodMuonVector[0]);
255 
256  // do the matching of Z muons with inner tracks
257  unsigned int i = 0;
258  for (const auto& muon : theZMuonVector) {
259  i++;
260  float minD = 1000.;
261  const reco::Track* theMatch = nullptr;
262  for (const auto& track : iEvent.get(tracksToken_)) {
263  float D = ::deltaR(muon->eta(), muon->phi(), track.eta(), track.phi());
264  if (D < minD) {
265  minD = D;
266  theMatch = &track;
267  }
268  }
269  LogDebug("DiMuonVertexValidation") << "pushing new track: " << i << std::endl;
270  myTracks.emplace_back(theMatch);
271  }
272  } else {
273  // we start directly with the pre-selected ALCARECO tracks
274  for (const auto& muon : iEvent.get(alcaRecoToken_)) {
275  myTracks.emplace_back(&muon);
276  }
277  }
278 
279 #ifdef EDM_ML_DEBUG
280  for (const auto& track : myTracks) {
281  edm::LogVerbatim("DiMuonVertexValidation") << __PRETTY_FUNCTION__ << " pT: " << track->pt() << " GeV"
282  << " , pT error: " << track->ptError() << " GeV"
283  << " , eta: " << track->eta() << " , phi: " << track->phi() << std::endl;
284  }
285 #endif
286 
287  LogDebug("DiMuonVertexValidation") << "selected tracks: " << myTracks.size() << std::endl;
288 
289  const TransientTrackBuilder* theB = &iSetup.getData(ttbESToken_);
290  TransientVertex aTransientVertex;
291  std::vector<reco::TransientTrack> tks;
292 
293  if (myTracks.size() != 2)
294  return;
295 
296  const auto& t1 = myTracks[1]->momentum();
297  const auto& t0 = myTracks[0]->momentum();
298  const auto& ditrack = t1 + t0;
299 
300  const auto& tplus = myTracks[0]->charge() > 0 ? myTracks[0] : myTracks[1];
301  const auto& tminus = myTracks[0]->charge() < 0 ? myTracks[0] : myTracks[1];
302 
303  TLorentzVector p4_tplus(tplus->px(), tplus->py(), tplus->pz(), sqrt((tplus->p() * tplus->p()) + mumass2));
304  TLorentzVector p4_tminus(tminus->px(), tminus->py(), tminus->pz(), sqrt((tminus->p() * tminus->p()) + mumass2));
305 
306 #ifdef EDM_ML_DEBUG
307  // Define a lambda function to convert TLorentzVector to a string
308  auto tLorentzVectorToString = [](const TLorentzVector& vector) {
309  return std::to_string(vector.Px()) + " " + std::to_string(vector.Py()) + " " + std::to_string(vector.Pz()) + " " +
310  std::to_string(vector.E());
311  };
312 
313  edm::LogVerbatim("DiMuonVertexValidation") << "mu+" << tLorentzVectorToString(p4_tplus) << std::endl;
314  edm::LogVerbatim("DiMuonVertexValidation") << "mu-" << tLorentzVectorToString(p4_tminus) << std::endl;
315 #endif
316 
317  const auto& Zp4 = p4_tplus + p4_tminus;
318  float track_invMass = Zp4.M();
319  hTrackInvMass_->Fill(track_invMass);
320 
321  // creat the pair of TLorentVectors used to make the plos
322  std::pair<TLorentzVector, TLorentzVector> tktk_p4 = std::make_pair(p4_tplus, p4_tminus);
323 
324  // fill the z->mm mass plots
325  ZMassPlots.fillPlots(track_invMass, tktk_p4);
326  InvMassInEtaBins.fillTH1Plots(track_invMass, tktk_p4);
327 
328  math::XYZPoint ZpT(ditrack.x(), ditrack.y(), 0);
329  math::XYZPoint Zp(ditrack.x(), ditrack.y(), ditrack.z());
330 
331  for (const auto& track : myTracks) {
332  reco::TransientTrack trajectory = theB->build(track);
333  tks.push_back(trajectory);
334  }
335 
336  KalmanVertexFitter kalman(true);
337  aTransientVertex = kalman.vertex(tks);
338 
339  double SVProb = TMath::Prob(aTransientVertex.totalChiSquared(), (int)aTransientVertex.degreesOfFreedom());
340 
341  LogDebug("DiMuonVertexValidation") << " vertex prob: " << SVProb << std::endl;
342 
343  hSVProb_->Fill(SVProb);
344 
345  if (!aTransientVertex.isValid())
346  return;
347 
349 
350  // fill the VtxProb plots
351  VtxProbPlots.fillPlots(SVProb, tktk_p4);
352 
353  math::XYZPoint mainVtxPos(0, 0, 0);
354  const reco::Vertex* theClosestVertex = nullptr;
355  // get collection of reconstructed vertices from event
356  edm::Handle<reco::VertexCollection> vertexHandle = iEvent.getHandle(vertexToken_);
357  if (vertexHandle.isValid()) {
358  const reco::VertexCollection* vertices = vertexHandle.product();
359  theClosestVertex = this->findClosestVertex(aTransientVertex, vertices);
360  } else {
361  edm::LogWarning("DiMuonVertexMonitor") << "invalid vertex collection encountered Skipping event!";
362  return;
363  }
364 
365  reco::Vertex theMainVertex;
366  if (!useClosestVertex_ || theClosestVertex == nullptr) {
367  // if the closest vertex is not available, or explicitly not chosen
368  theMainVertex = vertexHandle.product()->front();
369  } else {
370  theMainVertex = *theClosestVertex;
371  }
372 
373  mainVtxPos.SetXYZ(theMainVertex.position().x(), theMainVertex.position().y(), theMainVertex.position().z());
374  const math::XYZPoint myVertex(
375  aTransientVertex.position().x(), aTransientVertex.position().y(), aTransientVertex.position().z());
376  const math::XYZPoint deltaVtx(
377  mainVtxPos.x() - myVertex.x(), mainVtxPos.y() - myVertex.y(), mainVtxPos.z() - myVertex.z());
378 
379 #ifdef EDM_ML_DEBUG
380  edm::LogVerbatim("DiMuonVertexValidation")
381  << "mm vertex position:" << aTransientVertex.position().x() << "," << aTransientVertex.position().y() << ","
382  << aTransientVertex.position().z();
383 
384  edm::LogVerbatim("DiMuonVertexValidation") << "main vertex position:" << theMainVertex.position().x() << ","
385  << theMainVertex.position().y() << "," << theMainVertex.position().z();
386 #endif
387 
388  if (theMainVertex.isValid()) {
389  // Z Vertex distance in the xy plane
390 
391  VertexDistanceXY vertTool;
392  double distance = vertTool.distance(aTransientVertex, theMainVertex).value();
393  double dist_err = vertTool.distance(aTransientVertex, theMainVertex).error();
394 
395  hSVDist_->Fill(distance * cmToum);
396  hSVDistSig_->Fill(distance / dist_err);
397 
398  // fill the VtxDist plots
400 
401  // fill the VtxDisSig plots
402  VtxDistSigPlots.fillPlots(distance / dist_err, tktk_p4);
403 
404  // Z Vertex distance in 3D
405 
406  VertexDistance3D vertTool3D;
407  double distance3D = vertTool3D.distance(aTransientVertex, theMainVertex).value();
408  double dist3D_err = vertTool3D.distance(aTransientVertex, theMainVertex).error();
409 
410  hSVDist3D_->Fill(distance3D * cmToum);
411  hSVDist3DSig_->Fill(distance3D / dist3D_err);
412 
413  // fill the VtxDist3D plots
414  VtxDist3DPlots.fillPlots(distance3D * cmToum, tktk_p4);
415 
416  // fill the VtxDisSig plots
417  VtxDist3DSigPlots.fillPlots(distance3D / dist3D_err, tktk_p4);
418 
419  LogDebug("DiMuonVertexValidation") << "distance: " << distance << "+/-" << dist_err << std::endl;
420  // cut on the PV - SV distance
421  if (distance * cmToum < maxSVdist_) {
423 
424  double cosphi = (ZpT.x() * deltaVtx.x() + ZpT.y() * deltaVtx.y()) /
425  (sqrt(ZpT.x() * ZpT.x() + ZpT.y() * ZpT.y()) *
426  sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y()));
427 
428  double cosphi3D = (Zp.x() * deltaVtx.x() + Zp.y() * deltaVtx.y() + Zp.z() * deltaVtx.z()) /
429  (sqrt(Zp.x() * Zp.x() + Zp.y() * Zp.y() + Zp.z() * Zp.z()) *
430  sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y() + deltaVtx.z() * deltaVtx.z()));
431 
432  LogDebug("DiMuonVertexValidation") << "cos(phi) = " << cosphi << std::endl;
433 
434  hCosPhi_->Fill(cosphi);
435  hCosPhi3D_->Fill(cosphi3D);
436 
437 #ifdef EDM_ML_DEBUG
438  edm::LogVerbatim("DiMuonVertexValidation")
439  << "distance " << distance * cmToum << " cosphi3D:" << cosphi3D << std::endl;
440 #endif
441 
442  // fill the cosphi plots
443  CosPhiPlots.fillPlots(cosphi, tktk_p4);
444 
445  // fill the cosphi3D plots
446  CosPhi3DPlots.fillPlots(cosphi3D, tktk_p4);
447 
448  // fill the cosphi3D plots in eta bins
449  CosPhi3DInEtaBins.fillTH1Plots(cosphi3D, tktk_p4);
450  }
451  }
452 }
453 
454 // ------------ method called once each job just before starting event loop ------------
457 
458  // clang-format off
459  TH1F::SetDefaultSumw2(kTRUE);
460  hSVProb_ = fs->make<TH1F>("VtxProb", ";#mu^{+}#mu^{-} vertex probability;N(#mu#mu pairs)", 100, 0., 1.);
461 
462  auto extractRangeValues = [](const edm::ParameterSet& PSetConfiguration_) -> std::pair<double, double> {
463  double min = PSetConfiguration_.getParameter<double>("ymin");
464  double max = PSetConfiguration_.getParameter<double>("ymax");
465  return {min, max};
466  };
467 
468  // take the range from the 2D histograms
469  const auto& svDistRng = extractRangeValues(VtxDistConfiguration_);
470  hSVDist_ = fs->make<TH1F>("VtxDist", ";PV-#mu^{+}#mu^{-} vertex xy distance [#mum];N(#mu#mu pairs)", 100, svDistRng.first, svDistRng.second);
471 
472  // take the range from the 2D histograms
473  const auto& svDistSigRng = extractRangeValues(VtxDistSigConfiguration_);
474  hSVDistSig_ = fs->make<TH1F>("VtxDistSig", ";PV-#mu^{+}#mu^{-} vertex xy distance signficance;N(#mu#mu pairs)", 100, svDistSigRng.first, svDistRng.second);
475 
476  // take the range from the 2D histograms
477  const auto& svDist3DRng = extractRangeValues(VtxDist3DConfiguration_);
478  hSVDist3D_ = fs->make<TH1F>("VtxDist3D", ";PV-#mu^{+}#mu^{-} vertex 3D distance [#mum];N(#mu#mu pairs)", 100, svDist3DRng.first, svDist3DRng.second);
479 
480  // take the range from the 2D histograms
481  const auto& svDist3DSigRng = extractRangeValues(VtxDist3DSigConfiguration_);
482  hSVDist3DSig_ = fs->make<TH1F>("VtxDist3DSig", ";PV-#mu^{+}#mu^{-} vertex 3D distance signficance;N(#mu#mu pairs)", 100, svDist3DSigRng.first, svDist3DSigRng.second);
483 
484  // take the range from the 2D histograms
485  const auto& massRng = extractRangeValues(DiMuMassConfiguration_);
486  hInvMass_ = fs->make<TH1F>("InvMass", ";M(#mu#mu) [GeV];N(#mu#mu pairs)", 70., massRng.first, massRng.second);
487  hTrackInvMass_ = fs->make<TH1F>("TkTkInvMass", ";M(tk,tk) [GeV];N(tk tk pairs)", 70., massRng.first, massRng.second);
488 
489  hCosPhi_ = fs->make<TH1F>("CosPhi", ";cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
490  hCosPhi3D_ = fs->make<TH1F>("CosPhi3D", ";cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
491 
492  hCosPhiInv_ = fs->make<TH1F>("CosPhiInv", ";inverted cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
493  hCosPhiInv3D_ = fs->make<TH1F>("CosPhiInv3D", ";inverted cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
494  // clang-format on
495 
496  // 2D Maps
497 
498  TFileDirectory dirCosPhi = fs->mkdir("CosPhiPlots");
500 
501  TFileDirectory dirCosPhi3D = fs->mkdir("CosPhi3DPlots");
503 
504  TFileDirectory dirVtxProb = fs->mkdir("VtxProbPlots");
506 
507  TFileDirectory dirVtxDist = fs->mkdir("VtxDistPlots");
509 
510  TFileDirectory dirVtxDist3D = fs->mkdir("VtxDist3DPlots");
512 
513  TFileDirectory dirVtxDistSig = fs->mkdir("VtxDistSigPlots");
515 
516  TFileDirectory dirVtxDist3DSig = fs->mkdir("VtxDist3DSigPlots");
518 
519  TFileDirectory dirInvariantMass = fs->mkdir("InvariantMassPlots");
521 
522  // CosPhi3D in eta bins
523  TFileDirectory dirCosphi3DEta = fs->mkdir("CosPhi3DInEtaBins");
524  CosPhi3DInEtaBins.bookSet(dirCosphi3DEta, hCosPhi3D_);
525 
526  // Z-> mm mass in eta bins
527  TFileDirectory dirResMassEta = fs->mkdir("TkTkMassInEtaBins");
528  InvMassInEtaBins.bookSet(dirResMassEta, hTrackInvMass_);
529 
530  // cut flow
531 
532  hCutFlow_ = fs->make<TH1F>("hCutFlow", "cut flow;cut step;events left", 6, -0.5, 5.5);
533  std::string names[6] = {"Total", "Mult.", ">pT", "<eta", "hasVtx", "VtxDist"};
534  for (unsigned int i = 0; i < 6; i++) {
535  hCutFlow_->GetXaxis()->SetBinLabel(i + 1, names[i].c_str());
536  }
537 
538  myCounts.zeroAll();
539 }
540 
541 // ------------ method called once each job just after ending the event loop ------------
544 
545  hCutFlow_->SetBinContent(1, myCounts.eventsTotal);
546  hCutFlow_->SetBinContent(2, myCounts.eventsAfterMult);
547  hCutFlow_->SetBinContent(3, myCounts.eventsAfterPt);
548  hCutFlow_->SetBinContent(4, myCounts.eventsAfterEta);
549  hCutFlow_->SetBinContent(5, myCounts.eventsAfterVtx);
550  hCutFlow_->SetBinContent(6, myCounts.eventsAfterDist);
551 
552  TH1F::SetDefaultSumw2(kTRUE);
553  const unsigned int nBinsX = hCosPhi_->GetNbinsX();
554  for (unsigned int i = 1; i <= nBinsX; i++) {
555  //float binContent = hCosPhi_->GetBinContent(i);
556  float invertedBinContent = hCosPhi_->GetBinContent(nBinsX + 1 - i);
557  float invertedBinError = hCosPhi_->GetBinError(nBinsX + 1 - i);
558  hCosPhiInv_->SetBinContent(i, invertedBinContent);
559  hCosPhiInv_->SetBinError(i, invertedBinError);
560 
561  //float binContent3D = hCosPhi3D_->GetBinContent(i);
562  float invertedBinContent3D = hCosPhi3D_->GetBinContent(nBinsX + 1 - i);
563  float invertedBinError3D = hCosPhi3D_->GetBinError(nBinsX + 1 - i);
564  hCosPhiInv3D_->SetBinContent(i, invertedBinContent3D);
565  hCosPhiInv3D_->SetBinError(i, invertedBinError3D);
566  }
567 }
568 
569 // compute the closest vertex to di-lepton ------------------------------------
571  const reco::VertexCollection* vertices) const {
572  reco::Vertex* defaultVtx = nullptr;
573 
574  if (!aTransVtx.isValid())
575  return defaultVtx;
576 
577  // find the closest vertex to the secondary vertex in 3D
578  VertexDistance3D vertTool3D;
579  float minD = 9999.;
580  int closestVtxIndex = 0;
581  int counter = 0;
582  for (const auto& vtx : *vertices) {
583  double dist3D = vertTool3D.distance(aTransVtx, vtx).value();
584  if (dist3D < minD) {
585  minD = dist3D;
586  closestVtxIndex = counter;
587  }
588  counter++;
589  }
590 
591  if ((*vertices).at(closestVtxIndex).isValid()) {
592  return &(vertices->at(closestVtxIndex));
593  } else {
594  return defaultVtx;
595  }
596 }
597 
598 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
601  desc.ifValue(edm::ParameterDescription<bool>("useReco", true, true),
602  true >> edm::ParameterDescription<edm::InputTag>("muons", edm::InputTag("muons"), true) or
604  "muonTracks", edm::InputTag("ALCARECOTkAlDiMuon"), true))
605  ->setComment("If useReco is true need to specify the muon tracks, otherwise take the ALCARECO Inner tracks");
606  //desc.add<bool>("useReco",true);
607  //desc.add<edm::InputTag>("muons", edm::InputTag("muons"));
608  //desc.add<edm::InputTag>("muonTracks", edm::InputTag("ALCARECOTkAlDiMuon"));
609  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
610  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
611  desc.add<std::vector<double>>("pTThresholds", {30., 10.});
612  desc.add<bool>("useClosestVertex", true);
613  desc.add<double>("maxSVdist", 50.);
614 
615  {
616  edm::ParameterSetDescription psDiMuMass;
617  psDiMuMass.add<std::string>("name", "DiMuMass");
618  psDiMuMass.add<std::string>("title", "M(#mu#mu)");
619  psDiMuMass.add<std::string>("yUnits", "[GeV]");
620  psDiMuMass.add<int>("NxBins", 24);
621  psDiMuMass.add<int>("NyBins", 50);
622  psDiMuMass.add<double>("ymin", 70.);
623  psDiMuMass.add<double>("ymax", 120.);
624  desc.add<edm::ParameterSetDescription>("DiMuMassConfig", psDiMuMass);
625  }
626  {
628  psCosPhi.add<std::string>("name", "CosPhi");
629  psCosPhi.add<std::string>("title", "cos(#phi_{xy})");
630  psCosPhi.add<std::string>("yUnits", "");
631  psCosPhi.add<int>("NxBins", 50);
632  psCosPhi.add<int>("NyBins", 50);
633  psCosPhi.add<double>("ymin", -1.);
634  psCosPhi.add<double>("ymax", 1.);
635  desc.add<edm::ParameterSetDescription>("CosPhiConfig", psCosPhi);
636  }
637  {
638  edm::ParameterSetDescription psCosPhi3D;
639  psCosPhi3D.add<std::string>("name", "CosPhi3D");
640  psCosPhi3D.add<std::string>("title", "cos(#phi_{3D})");
641  psCosPhi3D.add<std::string>("yUnits", "");
642  psCosPhi3D.add<int>("NxBins", 50);
643  psCosPhi3D.add<int>("NyBins", 50);
644  psCosPhi3D.add<double>("ymin", -1.);
645  psCosPhi3D.add<double>("ymax", 1.);
646  desc.add<edm::ParameterSetDescription>("CosPhi3DConfig", psCosPhi3D);
647  }
648  {
650  psVtxProb.add<std::string>("name", "VtxProb");
651  psVtxProb.add<std::string>("title", "Prob(#chi^{2}_{SV})");
652  psVtxProb.add<std::string>("yUnits", "");
653  psVtxProb.add<int>("NxBins", 50);
654  psVtxProb.add<int>("NyBins", 50);
655  psVtxProb.add<double>("ymin", 0);
656  psVtxProb.add<double>("ymax", 1.);
657  desc.add<edm::ParameterSetDescription>("VtxProbConfig", psVtxProb);
658  }
659  {
661  psVtxDist.add<std::string>("name", "VtxDist");
662  psVtxDist.add<std::string>("title", "d_{xy}(PV,SV)");
663  psVtxDist.add<std::string>("yUnits", "[#mum]");
664  psVtxDist.add<int>("NxBins", 50);
665  psVtxDist.add<int>("NyBins", 100);
666  psVtxDist.add<double>("ymin", 0);
667  psVtxDist.add<double>("ymax", 300.);
668  desc.add<edm::ParameterSetDescription>("VtxDistConfig", psVtxDist);
669  }
670  {
671  edm::ParameterSetDescription psVtxDist3D;
672  psVtxDist3D.add<std::string>("name", "VtxDist3D");
673  psVtxDist3D.add<std::string>("title", "d_{3D}(PV,SV)");
674  psVtxDist3D.add<std::string>("yUnits", "[#mum]");
675  psVtxDist3D.add<int>("NxBins", 50);
676  psVtxDist3D.add<int>("NyBins", 250);
677  psVtxDist3D.add<double>("ymin", 0);
678  psVtxDist3D.add<double>("ymax", 500.);
679  desc.add<edm::ParameterSetDescription>("VtxDist3DConfig", psVtxDist3D);
680  }
681  {
682  edm::ParameterSetDescription psVtxDistSig;
683  psVtxDistSig.add<std::string>("name", "VtxDistSig");
684  psVtxDistSig.add<std::string>("title", "d_{xy}(PV,SV)/#sigma_{dxy}(PV,SV)");
685  psVtxDistSig.add<std::string>("yUnits", "");
686  psVtxDistSig.add<int>("NxBins", 50);
687  psVtxDistSig.add<int>("NyBins", 100);
688  psVtxDistSig.add<double>("ymin", 0);
689  psVtxDistSig.add<double>("ymax", 5.);
690  desc.add<edm::ParameterSetDescription>("VtxDistSigConfig", psVtxDistSig);
691  }
692  {
693  edm::ParameterSetDescription psVtxDist3DSig;
694  psVtxDist3DSig.add<std::string>("name", "VtxDist3DSig");
695  psVtxDist3DSig.add<std::string>("title", "d_{3D}(PV,SV)/#sigma_{d3D}(PV,SV)");
696  psVtxDist3DSig.add<std::string>("yUnits", "");
697  psVtxDist3DSig.add<int>("NxBins", 50);
698  psVtxDist3DSig.add<int>("NyBins", 100);
699  psVtxDist3DSig.add<double>("ymin", 0);
700  psVtxDist3DSig.add<double>("ymax", 5.);
701  desc.add<edm::ParameterSetDescription>("VtxDist3DSigConfig", psVtxDist3DSig);
702  }
703 
704  descriptions.addWithDefaultLabel(desc);
705 }
706 
707 //define this as a plug-in
DiMuonVertexValidation(const edm::ParameterSet &)
static const std::string kSharedResource
Definition: TFileService.h:76
const edm::ParameterSet VtxProbConfiguration_
Log< level::Info, true > LogVerbatim
const edm::ParameterSet DiMuMassConfiguration_
~DiMuonVertexValidation() override
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
float totalChiSquared() const
const edm::ParameterSet CosPhi3DConfiguration_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double pt() const final
transverse momentum
GlobalPoint position() const
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
DiLeptonHelp::Counts myCounts
const edm::ParameterSet CosPhiConfiguration_
T z() const
Definition: PV3DBase.h:61
void analyze(const edm::Event &, const edm::EventSetup &) override
DiLeptonHelp::PlotsVsDiLeptonRegion InvMassInEtaBins
static constexpr float mumass2
const Point & position() const
position
Definition: Vertex.h:128
void fillTH1Plots(const float val, const std::pair< TLorentzVector, TLorentzVector > &momenta)
T const * product() const
Definition: Handle.h:70
DiLeptonHelp::PlotsVsKinematics CosPhiPlots
const edm::ParameterSet VtxDist3DConfiguration_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
DiLeptonHelp::PlotsVsKinematics VtxDist3DPlots
const edm::ParameterSet VtxDist3DSigConfiguration_
std::vector< Vertex > VertexCollection
Definition: Vertex.h:31
float degreesOfFreedom() const
const std::string names[nVars_]
DiLeptonHelp::PlotsVsKinematics VtxDist3DSigPlots
static std::string to_string(const XMLCh *ch)
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
reco::TransientTrack build(const reco::Track *p) const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
void bookSet(const TFileDirectory &fs, const TH1 *histo)
bool isValid() const
T sqrt(T t)
Definition: SSEVec.h:19
const edm::ParameterSet VtxDistSigConfiguration_
DiLeptonHelp::PlotsVsKinematics VtxDistSigPlots
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
static constexpr float cmToum
edm::EDGetTokenT< reco::MuonCollection > muonsToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttbESToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
Log< level::Info, false > LogInfo
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
DiLeptonHelp::PlotsVsKinematics VtxProbPlots
bool isValid() const
Definition: HandleBase.h:70
double value() const
Definition: Measurement1D.h:25
const edm::ParameterSet VtxDistConfiguration_
const reco::Vertex * findClosestVertex(const TransientVertex aTransVtx, const reco::VertexCollection *vertices) const
DiLeptonHelp::PlotsVsKinematics CosPhi3DPlots
fixed size matrix
HLT enums.
static std::atomic< unsigned int > counter
double error() const
Definition: Measurement1D.h:27
std::vector< double > pTthresholds_
DiLeptonHelp::PlotsVsKinematics VtxDistPlots
void fillPlots(const float val, const std::pair< TLorentzVector, TLorentzVector > &momenta)
void bookFromPSet(const TFileDirectory &fs, const edm::ParameterSet &hpar)
Log< level::Warning, false > LogWarning
DiLeptonHelp::PlotsVsDiLeptonRegion CosPhi3DInEtaBins
DiLeptonHelp::PlotsVsKinematics ZMassPlots
edm::EDGetTokenT< reco::TrackCollection > alcaRecoToken_
const edm::EDGetTokenT< reco::VertexCollection > vertexToken_
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:73
#define LogDebug(id)