37 #include "TLorentzVector.h" 138 static constexpr
float mumass2 = 0.105658367 * 0.105658367;
148 : useReco_(iConfig.getParameter<
bool>(
"useReco")),
149 pTthresholds_(iConfig.getParameter<
std::
vector<double>>(
"pTThresholds")),
150 maxSVdist_(iConfig.getParameter<double>(
"maxSVdist")),
151 CosPhiConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"CosPhiConfig")),
152 CosPhi3DConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"CosPhi3DConfig")),
153 VtxProbConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxProbConfig")),
154 VtxDistConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDistConfig")),
155 VtxDist3DConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDist3DConfig")),
156 VtxDistSigConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDistSigConfig")),
157 VtxDist3DSigConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDist3DSigConfig")),
158 DiMuMassConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"DiMuMassConfig")),
175 edm::LogInfo(
"DiMuonVertexValidation") <<
" Threshold: " << thr <<
" ";
193 std::vector<const reco::Track*> myTracks;
198 std::vector<const reco::Muon*> myGoodMuonVector;
203 if (
t->chi2() /
t->ndof() <= 2.5 &&
t->numberOfValidHits() >= 5 &&
205 myGoodMuonVector.emplace_back(&
muon);
210 LogDebug(
"DiMuonVertexValidation") <<
"myGoodMuonVector size: " << myGoodMuonVector.size() << std::endl;
212 return lhs->
pt() > rhs->pt();
216 for (
const auto&
muon : myGoodMuonVector) {
217 LogDebug(
"DiMuonVertexValidation") <<
"pT: " <<
muon->pt() <<
" ";
219 LogDebug(
"DiMuonVertexValidation") << std::endl;
222 if (myGoodMuonVector.size() < 2)
233 if (myGoodMuonVector[0]->
charge() * myGoodMuonVector[1]->charge() > 0)
236 const auto& m1 = myGoodMuonVector[1]->p4();
237 const auto& m0 = myGoodMuonVector[0]->p4();
238 const auto& mother = m0 + m1;
240 float invMass = mother.M();
244 std::vector<const reco::Muon*> theZMuonVector;
245 theZMuonVector.reserve(2);
246 theZMuonVector.emplace_back(myGoodMuonVector[1]);
247 theZMuonVector.emplace_back(myGoodMuonVector[0]);
251 for (
const auto&
muon : theZMuonVector) {
262 LogDebug(
"DiMuonVertexValidation") <<
"pushing new track: " <<
i << std::endl;
263 myTracks.emplace_back(theMatch);
268 myTracks.emplace_back(&
muon);
272 LogDebug(
"DiMuonVertexValidation") <<
"selected tracks: " << myTracks.size() << std::endl;
276 std::vector<reco::TransientTrack> tks;
278 if (myTracks.size() != 2)
281 const auto&
t1 = myTracks[1]->momentum();
282 const auto&
t0 = myTracks[0]->momentum();
283 const auto& ditrack =
t1 +
t0;
285 const auto& tplus = myTracks[0]->charge() > 0 ? myTracks[0] : myTracks[1];
286 const auto& tminus = myTracks[0]->charge() < 0 ? myTracks[0] : myTracks[1];
288 TLorentzVector p4_tplus(tplus->px(), tplus->py(), tplus->pz(),
sqrt((tplus->p() * tplus->p()) +
mumass2));
289 TLorentzVector p4_tminus(tminus->px(), tminus->py(), tminus->pz(),
sqrt((tminus->p() * tminus->p()) +
mumass2));
291 const auto& Zp4 = p4_tplus + p4_tminus;
292 float track_invMass = Zp4.M();
296 std::pair<TLorentzVector, TLorentzVector> tktk_p4 = std::make_pair(p4_tplus, p4_tminus);
304 for (
const auto&
track : myTracks) {
306 tks.push_back(trajectory);
310 aTransientVertex = kalman.
vertex(tks);
314 LogDebug(
"DiMuonVertexValidation") <<
" vertex prob: " << SVProb << std::endl;
318 if (!aTransientVertex.
isValid())
334 if ((*vertices).at(0).isValid()) {
335 auto theMainVtx = (*vertices).at(0);
336 MainVertex.SetXYZ(theMainVtx.position().x(), theMainVtx.position().y(), theMainVtx.position().z());
343 MainVertex.x() - myVertex.x(), MainVertex.y() - myVertex.y(), MainVertex.z() - myVertex.z());
350 double dist_err = vertTool.
distance(aTransientVertex, TheMainVertex).
error();
364 double distance3D = vertTool3D.
distance(aTransientVertex, TheMainVertex).
value();
365 double dist3D_err = vertTool3D.
distance(aTransientVertex, TheMainVertex).
error();
376 LogDebug(
"DiMuonVertexValidation") <<
"distance: " <<
distance <<
"+/-" << dist_err << std::endl;
381 double cosphi = (ZpT.x() * deltaVtx.x() + ZpT.y() * deltaVtx.y()) /
382 (
sqrt(ZpT.x() * ZpT.x() + ZpT.y() * ZpT.y()) *
383 sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y()));
385 double cosphi3D = (Zp.x() * deltaVtx.x() + Zp.y() * deltaVtx.y() + Zp.z() * deltaVtx.z()) /
386 (
sqrt(Zp.x() * Zp.x() + Zp.y() * Zp.y() + Zp.z() * Zp.z()) *
387 sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y() + deltaVtx.z() * deltaVtx.z()));
389 LogDebug(
"DiMuonVertexValidation") <<
"cos(phi) = " << cosphi << std::endl;
408 TH1F::SetDefaultSumw2(kTRUE);
409 hSVProb_ =
fs->make<TH1F>(
"VtxProb",
";ZV vertex probability;N(#mu#mu pairs)", 100, 0., 1.);
411 hSVDist_ =
fs->make<TH1F>(
"VtxDist",
";PV-ZV xy distance [#mum];N(#mu#mu pairs)", 100, 0., 300.);
412 hSVDistSig_ =
fs->make<TH1F>(
"VtxDistSig",
";PV-ZV xy distance signficance;N(#mu#mu pairs)", 100, 0., 5.);
414 hSVDist3D_ =
fs->make<TH1F>(
"VtxDist3D",
";PV-ZV 3D distance [#mum];N(#mu#mu pairs)", 100, 0., 300.);
415 hSVDist3DSig_ =
fs->make<TH1F>(
"VtxDist3DSig",
";PV-ZV 3D distance signficance;N(#mu#mu pairs)", 100, 0., 5.);
417 hInvMass_ =
fs->make<TH1F>(
"InvMass",
";M(#mu#mu) [GeV];N(#mu#mu pairs)", 70., 50., 120.);
418 hTrackInvMass_ =
fs->make<TH1F>(
"TkTkInvMass",
";M(tk,tk) [GeV];N(tk tk pairs)", 70., 50., 120.);
420 hCosPhi_ =
fs->make<TH1F>(
"CosPhi",
";cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
421 hCosPhi3D_ =
fs->make<TH1F>(
"CosPhi3D",
";cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
423 hCosPhiInv_ =
fs->make<TH1F>(
"CosPhiInv",
";inverted cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
424 hCosPhiInv3D_ =
fs->make<TH1F>(
"CosPhiInv3D",
";inverted cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
455 hCutFlow_ =
fs->make<TH1F>(
"hCutFlow",
"cut flow;cut step;events left", 6, -0.5, 5.5);
456 std::string names[6] = {
"Total",
"Mult.",
">pT",
"<eta",
"hasVtx",
"VtxDist"};
457 for (
unsigned int i = 0;
i < 6;
i++) {
475 TH1F::SetDefaultSumw2(kTRUE);
476 const unsigned int nBinsX =
hCosPhi_->GetNbinsX();
477 for (
unsigned int i = 1;
i <= nBinsX;
i++) {
479 float invertedBinContent =
hCosPhi_->GetBinContent(nBinsX + 1 -
i);
480 float invertedBinError =
hCosPhi_->GetBinError(nBinsX + 1 -
i);
485 float invertedBinContent3D =
hCosPhi3D_->GetBinContent(nBinsX + 1 -
i);
486 float invertedBinError3D =
hCosPhi3D_->GetBinError(nBinsX + 1 -
i);
499 ->setComment(
"If useReco is true need to specify the muon tracks, otherwise take the ALCARECO Inner tracks");
505 desc.add<std::vector<double>>(
"pTThresholds", {30., 10.});
506 desc.add<
double>(
"maxSVdist", 50.);
513 psDiMuMass.
add<
int>(
"NxBins", 24);
514 psDiMuMass.
add<
int>(
"NyBins", 50);
515 psDiMuMass.
add<
double>(
"ymin", 70.);
516 psDiMuMass.
add<
double>(
"ymax", 120.);
524 psCosPhi.
add<
int>(
"NxBins", 50);
525 psCosPhi.
add<
int>(
"NyBins", 50);
526 psCosPhi.
add<
double>(
"ymin", -1.);
527 psCosPhi.
add<
double>(
"ymax", 1.);
535 psCosPhi3D.
add<
int>(
"NxBins", 50);
536 psCosPhi3D.
add<
int>(
"NyBins", 50);
537 psCosPhi3D.
add<
double>(
"ymin", -1.);
538 psCosPhi3D.
add<
double>(
"ymax", 1.);
546 psVtxProb.
add<
int>(
"NxBins", 50);
547 psVtxProb.
add<
int>(
"NyBins", 50);
548 psVtxProb.
add<
double>(
"ymin", 0);
549 psVtxProb.
add<
double>(
"ymax", 1.);
557 psVtxDist.
add<
int>(
"NxBins", 50);
558 psVtxDist.
add<
int>(
"NyBins", 100);
559 psVtxDist.
add<
double>(
"ymin", 0);
560 psVtxDist.
add<
double>(
"ymax", 300.);
568 psVtxDist3D.
add<
int>(
"NxBins", 50);
569 psVtxDist3D.
add<
int>(
"NyBins", 250);
570 psVtxDist3D.
add<
double>(
"ymin", 0);
571 psVtxDist3D.
add<
double>(
"ymax", 500.);
577 psVtxDistSig.
add<
std::string>(
"title",
"d_{xy}(PV,SV)/#sigma_{dxy}(PV,SV)");
579 psVtxDistSig.
add<
int>(
"NxBins", 50);
580 psVtxDistSig.
add<
int>(
"NyBins", 100);
581 psVtxDistSig.
add<
double>(
"ymin", 0);
582 psVtxDistSig.
add<
double>(
"ymax", 5.);
588 psVtxDist3DSig.
add<
std::string>(
"title",
"d_{3D}(PV,SV)/#sigma_{d3D}(PV,SV)");
590 psVtxDist3DSig.
add<
int>(
"NxBins", 50);
591 psVtxDist3DSig.
add<
int>(
"NyBins", 100);
592 psVtxDist3DSig.
add<
double>(
"ymin", 0);
593 psVtxDist3DSig.
add<
double>(
"ymax", 5.);
DiMuonVertexValidation(const edm::ParameterSet &)
static const std::string kSharedResource
~DiMuonVertexValidation() override
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
float totalChiSquared() const
edm::ParameterSet VtxProbConfiguration_
unsigned int eventsAfterVtx
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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
void analyze(const edm::Event &, const edm::EventSetup &) override
static constexpr float mumass2
T const * product() const
DiLeptonHelp::PlotsVsKinematics CosPhiPlots
std::vector< Track > TrackCollection
collection of Tracks
edm::ParameterSet DiMuMassConfiguration_
unsigned int eventsAfterDist
std::vector< Vertex > VertexCollection
collection of Vertex objects
edm::ParameterSet VtxDist3DConfiguration_
DiLeptonHelp::PlotsVsKinematics VtxDist3DPlots
edm::ParameterSet VtxDistConfiguration_
std::vector< Vertex > VertexCollection
float degreesOfFreedom() const
const std::string names[nVars_]
DiLeptonHelp::PlotsVsKinematics VtxDist3DSigPlots
unsigned int eventsAfterEta
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
reco::TransientTrack build(const reco::Track *p) const
edm::ParameterSet VtxDist3DSigConfiguration_
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
static constexpr float cmToum
edm::EDGetTokenT< reco::MuonCollection > muonsToken_
#define DEFINE_FWK_MODULE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttbESToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
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
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::ParameterSet VtxDistSigConfiguration_
DiLeptonHelp::PlotsVsKinematics VtxProbPlots
edm::ParameterSet CosPhiConfiguration_
DiLeptonHelp::PlotsVsKinematics CosPhi3DPlots
edm::ParameterSet CosPhi3DConfiguration_
unsigned int eventsAfterPt
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)
DiLeptonHelp::PlotsVsKinematics ZMassPlots
edm::EDGetTokenT< reco::TrackCollection > alcaRecoToken_
unsigned int eventsAfterMult
bool isValid() const
Tells whether the vertex is valid.