37 #include "TLorentzVector.h" 140 static constexpr
float mumass2 = 0.105658367 * 0.105658367;
150 : useReco_(iConfig.getParameter<
bool>(
"useReco")),
151 useClosestVertex_(iConfig.getParameter<
bool>(
"useClosestVertex")),
152 pTthresholds_(iConfig.getParameter<
std::
vector<double>>(
"pTThresholds")),
153 maxSVdist_(iConfig.getParameter<double>(
"maxSVdist")),
154 CosPhiConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"CosPhiConfig")),
155 CosPhi3DConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"CosPhi3DConfig")),
156 VtxProbConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxProbConfig")),
157 VtxDistConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDistConfig")),
158 VtxDist3DConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDist3DConfig")),
159 VtxDistSigConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDistSigConfig")),
160 VtxDist3DSigConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"VtxDist3DSigConfig")),
161 DiMuMassConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"DiMuMassConfig")),
178 edm::LogInfo(
"DiMuonVertexValidation") <<
" Threshold: " << thr <<
" ";
196 std::vector<const reco::Track*> myTracks;
201 std::vector<const reco::Muon*> myGoodMuonVector;
206 if (
t->chi2() /
t->ndof() <= 2.5 &&
t->numberOfValidHits() >= 5 &&
208 myGoodMuonVector.emplace_back(&
muon);
213 LogDebug(
"DiMuonVertexValidation") <<
"myGoodMuonVector size: " << myGoodMuonVector.size() << std::endl;
215 return lhs->
pt() > rhs->pt();
219 for (
const auto&
muon : myGoodMuonVector) {
220 LogDebug(
"DiMuonVertexValidation") <<
"pT: " <<
muon->pt() <<
" ";
222 LogDebug(
"DiMuonVertexValidation") << std::endl;
225 if (myGoodMuonVector.size() < 2)
236 if (myGoodMuonVector[0]->
charge() * myGoodMuonVector[1]->charge() > 0)
239 const auto& m1 = myGoodMuonVector[1]->p4();
240 const auto& m0 = myGoodMuonVector[0]->p4();
241 const auto& mother = m0 + m1;
243 float invMass = mother.M();
247 std::vector<const reco::Muon*> theZMuonVector;
248 theZMuonVector.reserve(2);
249 theZMuonVector.emplace_back(myGoodMuonVector[1]);
250 theZMuonVector.emplace_back(myGoodMuonVector[0]);
254 for (
const auto&
muon : theZMuonVector) {
265 LogDebug(
"DiMuonVertexValidation") <<
"pushing new track: " <<
i << std::endl;
266 myTracks.emplace_back(theMatch);
271 myTracks.emplace_back(&
muon);
276 for (
const auto&
track : myTracks) {
277 edm::LogVerbatim(
"DiMuonVertexValidation") << __PRETTY_FUNCTION__ <<
" pT: " <<
track->pt() <<
" GeV" 278 <<
" , pT error: " <<
track->ptError() <<
" GeV" 279 <<
" , eta: " <<
track->eta() <<
" , phi: " <<
track->phi() << std::endl;
283 LogDebug(
"DiMuonVertexValidation") <<
"selected tracks: " << myTracks.size() << std::endl;
287 std::vector<reco::TransientTrack> tks;
289 if (myTracks.size() != 2)
292 const auto&
t1 = myTracks[1]->momentum();
293 const auto&
t0 = myTracks[0]->momentum();
294 const auto& ditrack =
t1 +
t0;
296 const auto& tplus = myTracks[0]->charge() > 0 ? myTracks[0] : myTracks[1];
297 const auto& tminus = myTracks[0]->charge() < 0 ? myTracks[0] : myTracks[1];
299 TLorentzVector p4_tplus(tplus->px(), tplus->py(), tplus->pz(),
sqrt((tplus->p() * tplus->p()) +
mumass2));
300 TLorentzVector p4_tminus(tminus->px(), tminus->py(), tminus->pz(),
sqrt((tminus->p() * tminus->p()) +
mumass2));
304 auto tLorentzVectorToString = [](
const TLorentzVector&
vector) {
309 edm::LogVerbatim(
"DiMuonVertexValidation") <<
"mu+" << tLorentzVectorToString(p4_tplus) << std::endl;
310 edm::LogVerbatim(
"DiMuonVertexValidation") <<
"mu-" << tLorentzVectorToString(p4_tminus) << std::endl;
313 const auto& Zp4 = p4_tplus + p4_tminus;
314 float track_invMass = Zp4.M();
318 std::pair<TLorentzVector, TLorentzVector> tktk_p4 = std::make_pair(p4_tplus, p4_tminus);
326 for (
const auto&
track : myTracks) {
328 tks.push_back(trajectory);
332 aTransientVertex = kalman.
vertex(tks);
336 LogDebug(
"DiMuonVertexValidation") <<
" vertex prob: " << SVProb << std::endl;
340 if (!aTransientVertex.
isValid())
356 edm::LogWarning(
"DiMuonVertexMonitor") <<
"invalid vertex collection encountered Skipping event!";
363 TheMainVertex = vertexHandle.
product()->front();
365 TheMainVertex = *theClosestVertex;
372 MainVertex.x() - myVertex.x(), MainVertex.y() - myVertex.y(), MainVertex.z() - myVertex.z());
376 <<
"mm vertex position:" << aTransientVertex.
position().
x() <<
"," << aTransientVertex.
position().
y() <<
"," 388 double dist_err = vertTool.
distance(aTransientVertex, TheMainVertex).
error();
402 double distance3D = vertTool3D.
distance(aTransientVertex, TheMainVertex).
value();
403 double dist3D_err = vertTool3D.
distance(aTransientVertex, TheMainVertex).
error();
414 LogDebug(
"DiMuonVertexValidation") <<
"distance: " <<
distance <<
"+/-" << dist_err << std::endl;
419 double cosphi = (ZpT.x() * deltaVtx.x() + ZpT.y() * deltaVtx.y()) /
420 (
sqrt(ZpT.x() * ZpT.x() + ZpT.y() * ZpT.y()) *
421 sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y()));
423 double cosphi3D = (Zp.x() * deltaVtx.x() + Zp.y() * deltaVtx.y() + Zp.z() * deltaVtx.z()) /
424 (
sqrt(Zp.x() * Zp.x() + Zp.y() * Zp.y() + Zp.z() * Zp.z()) *
425 sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y() + deltaVtx.z() * deltaVtx.z()));
427 LogDebug(
"DiMuonVertexValidation") <<
"cos(phi) = " << cosphi << std::endl;
434 <<
"distance " <<
distance *
cmToum <<
" cosphi3D:" << cosphi3D << std::endl;
451 TH1F::SetDefaultSumw2(kTRUE);
452 hSVProb_ =
fs->make<TH1F>(
"VtxProb",
";ZV vertex probability;N(#mu#mu pairs)", 100, 0., 1.);
454 hSVDist_ =
fs->make<TH1F>(
"VtxDist",
";PV-ZV xy distance [#mum];N(#mu#mu pairs)", 100, 0., 300.);
455 hSVDistSig_ =
fs->make<TH1F>(
"VtxDistSig",
";PV-ZV xy distance signficance;N(#mu#mu pairs)", 100, 0., 5.);
457 hSVDist3D_ =
fs->make<TH1F>(
"VtxDist3D",
";PV-ZV 3D distance [#mum];N(#mu#mu pairs)", 100, 0., 300.);
458 hSVDist3DSig_ =
fs->make<TH1F>(
"VtxDist3DSig",
";PV-ZV 3D distance signficance;N(#mu#mu pairs)", 100, 0., 5.);
460 hInvMass_ =
fs->make<TH1F>(
"InvMass",
";M(#mu#mu) [GeV];N(#mu#mu pairs)", 70., 50., 120.);
461 hTrackInvMass_ =
fs->make<TH1F>(
"TkTkInvMass",
";M(tk,tk) [GeV];N(tk tk pairs)", 70., 50., 120.);
463 hCosPhi_ =
fs->make<TH1F>(
"CosPhi",
";cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
464 hCosPhi3D_ =
fs->make<TH1F>(
"CosPhi3D",
";cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
466 hCosPhiInv_ =
fs->make<TH1F>(
"CosPhiInv",
";inverted cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
467 hCosPhiInv3D_ =
fs->make<TH1F>(
"CosPhiInv3D",
";inverted cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
498 hCutFlow_ =
fs->make<TH1F>(
"hCutFlow",
"cut flow;cut step;events left", 6, -0.5, 5.5);
499 std::string names[6] = {
"Total",
"Mult.",
">pT",
"<eta",
"hasVtx",
"VtxDist"};
500 for (
unsigned int i = 0;
i < 6;
i++) {
518 TH1F::SetDefaultSumw2(kTRUE);
519 const unsigned int nBinsX =
hCosPhi_->GetNbinsX();
520 for (
unsigned int i = 1;
i <= nBinsX;
i++) {
522 float invertedBinContent =
hCosPhi_->GetBinContent(nBinsX + 1 -
i);
523 float invertedBinError =
hCosPhi_->GetBinError(nBinsX + 1 -
i);
528 float invertedBinContent3D =
hCosPhi3D_->GetBinContent(nBinsX + 1 -
i);
529 float invertedBinError3D =
hCosPhi3D_->GetBinError(nBinsX + 1 -
i);
546 int closestVtxIndex = 0;
557 if ((*vertices).at(closestVtxIndex).isValid()) {
558 return &(
vertices->at(closestVtxIndex));
571 ->setComment(
"If useReco is true need to specify the muon tracks, otherwise take the ALCARECO Inner tracks");
577 desc.add<std::vector<double>>(
"pTThresholds", {30., 10.});
578 desc.add<
bool>(
"useClosestVertex",
true);
579 desc.add<
double>(
"maxSVdist", 50.);
586 psDiMuMass.
add<
int>(
"NxBins", 24);
587 psDiMuMass.
add<
int>(
"NyBins", 50);
588 psDiMuMass.
add<
double>(
"ymin", 70.);
589 psDiMuMass.
add<
double>(
"ymax", 120.);
597 psCosPhi.
add<
int>(
"NxBins", 50);
598 psCosPhi.
add<
int>(
"NyBins", 50);
599 psCosPhi.
add<
double>(
"ymin", -1.);
600 psCosPhi.
add<
double>(
"ymax", 1.);
608 psCosPhi3D.
add<
int>(
"NxBins", 50);
609 psCosPhi3D.
add<
int>(
"NyBins", 50);
610 psCosPhi3D.
add<
double>(
"ymin", -1.);
611 psCosPhi3D.
add<
double>(
"ymax", 1.);
619 psVtxProb.
add<
int>(
"NxBins", 50);
620 psVtxProb.
add<
int>(
"NyBins", 50);
621 psVtxProb.
add<
double>(
"ymin", 0);
622 psVtxProb.
add<
double>(
"ymax", 1.);
630 psVtxDist.
add<
int>(
"NxBins", 50);
631 psVtxDist.
add<
int>(
"NyBins", 100);
632 psVtxDist.
add<
double>(
"ymin", 0);
633 psVtxDist.
add<
double>(
"ymax", 300.);
641 psVtxDist3D.
add<
int>(
"NxBins", 50);
642 psVtxDist3D.
add<
int>(
"NyBins", 250);
643 psVtxDist3D.
add<
double>(
"ymin", 0);
644 psVtxDist3D.
add<
double>(
"ymax", 500.);
650 psVtxDistSig.
add<
std::string>(
"title",
"d_{xy}(PV,SV)/#sigma_{dxy}(PV,SV)");
652 psVtxDistSig.
add<
int>(
"NxBins", 50);
653 psVtxDistSig.
add<
int>(
"NyBins", 100);
654 psVtxDistSig.
add<
double>(
"ymin", 0);
655 psVtxDistSig.
add<
double>(
"ymax", 5.);
661 psVtxDist3DSig.
add<
std::string>(
"title",
"d_{3D}(PV,SV)/#sigma_{d3D}(PV,SV)");
663 psVtxDist3DSig.
add<
int>(
"NxBins", 50);
664 psVtxDist3DSig.
add<
int>(
"NyBins", 100);
665 psVtxDist3DSig.
add<
double>(
"ymin", 0);
666 psVtxDist3DSig.
add<
double>(
"ymax", 5.);
DiMuonVertexValidation(const edm::ParameterSet &)
static const std::string kSharedResource
Log< level::Info, true > LogVerbatim
~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
const Point & position() const
position
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
static std::string to_string(const XMLCh *ch)
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_
const bool useClosestVertex_
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
const reco::Vertex * findClosestVertex(const TransientVertex aTransVtx, const reco::VertexCollection *vertices) const
edm::ParameterSet CosPhiConfiguration_
DiLeptonHelp::PlotsVsKinematics CosPhi3DPlots
edm::ParameterSet CosPhi3DConfiguration_
static std::atomic< unsigned int > counter
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)
Log< level::Warning, false > LogWarning
DiLeptonHelp::PlotsVsKinematics ZMassPlots
edm::EDGetTokenT< reco::TrackCollection > alcaRecoToken_
unsigned int eventsAfterMult
bool isValid() const
Tells whether the vertex is valid.