37 #include "TLorentzVector.h" 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")),
182 edm::LogInfo(
"DiMuonVertexValidation") <<
" Threshold: " << thr <<
" ";
200 std::vector<const reco::Track*> myTracks;
205 std::vector<const reco::Muon*> myGoodMuonVector;
210 if (
t->chi2() /
t->ndof() <= 2.5 &&
t->numberOfValidHits() >= 5 &&
212 myGoodMuonVector.emplace_back(&
muon);
217 LogDebug(
"DiMuonVertexValidation") <<
"myGoodMuonVector size: " << myGoodMuonVector.size() << std::endl;
219 return lhs->
pt() > rhs->pt();
223 for (
const auto&
muon : myGoodMuonVector) {
224 LogDebug(
"DiMuonVertexValidation") <<
"pT: " <<
muon->pt() <<
" ";
226 LogDebug(
"DiMuonVertexValidation") << std::endl;
229 if (myGoodMuonVector.size() < 2)
240 if (myGoodMuonVector[0]->
charge() * myGoodMuonVector[1]->charge() > 0)
243 const auto& m1 = myGoodMuonVector[1]->p4();
244 const auto& m0 = myGoodMuonVector[0]->p4();
245 const auto& mother = m0 + m1;
247 float invMass = mother.M();
251 std::vector<const reco::Muon*> theZMuonVector;
252 theZMuonVector.reserve(2);
253 theZMuonVector.emplace_back(myGoodMuonVector[1]);
254 theZMuonVector.emplace_back(myGoodMuonVector[0]);
258 for (
const auto&
muon : theZMuonVector) {
269 LogDebug(
"DiMuonVertexValidation") <<
"pushing new track: " <<
i << std::endl;
270 myTracks.emplace_back(theMatch);
275 myTracks.emplace_back(&
muon);
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;
287 LogDebug(
"DiMuonVertexValidation") <<
"selected tracks: " << myTracks.size() << std::endl;
291 std::vector<reco::TransientTrack> tks;
293 if (myTracks.size() != 2)
296 const auto&
t1 = myTracks[1]->momentum();
297 const auto&
t0 = myTracks[0]->momentum();
298 const auto& ditrack =
t1 +
t0;
300 const auto& tplus = myTracks[0]->charge() > 0 ? myTracks[0] : myTracks[1];
301 const auto& tminus = myTracks[0]->charge() < 0 ? myTracks[0] : myTracks[1];
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));
308 auto tLorentzVectorToString = [](
const TLorentzVector&
vector) {
313 edm::LogVerbatim(
"DiMuonVertexValidation") <<
"mu+" << tLorentzVectorToString(p4_tplus) << std::endl;
314 edm::LogVerbatim(
"DiMuonVertexValidation") <<
"mu-" << tLorentzVectorToString(p4_tminus) << std::endl;
317 const auto& Zp4 = p4_tplus + p4_tminus;
318 float track_invMass = Zp4.M();
322 std::pair<TLorentzVector, TLorentzVector> tktk_p4 = std::make_pair(p4_tplus, p4_tminus);
331 for (
const auto&
track : myTracks) {
333 tks.push_back(trajectory);
337 aTransientVertex = kalman.
vertex(tks);
341 LogDebug(
"DiMuonVertexValidation") <<
" vertex prob: " << SVProb << std::endl;
345 if (!aTransientVertex.
isValid())
361 edm::LogWarning(
"DiMuonVertexMonitor") <<
"invalid vertex collection encountered Skipping event!";
368 TheMainVertex = vertexHandle.
product()->front();
370 TheMainVertex = *theClosestVertex;
377 MainVertex.x() - myVertex.x(), MainVertex.y() - myVertex.y(), MainVertex.z() - myVertex.z());
381 <<
"mm vertex position:" << aTransientVertex.
position().
x() <<
"," << aTransientVertex.
position().
y() <<
"," 393 double dist_err = vertTool.
distance(aTransientVertex, TheMainVertex).
error();
407 double distance3D = vertTool3D.
distance(aTransientVertex, TheMainVertex).
value();
408 double dist3D_err = vertTool3D.
distance(aTransientVertex, TheMainVertex).
error();
419 LogDebug(
"DiMuonVertexValidation") <<
"distance: " <<
distance <<
"+/-" << dist_err << std::endl;
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()));
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()));
432 LogDebug(
"DiMuonVertexValidation") <<
"cos(phi) = " << cosphi << std::endl;
439 <<
"distance " <<
distance *
cmToum <<
" cosphi3D:" << cosphi3D << std::endl;
459 TH1F::SetDefaultSumw2(kTRUE);
460 hSVProb_ =
fs->make<TH1F>(
"VtxProb",
";#mu^{+}#mu^{-} vertex probability;N(#mu#mu pairs)", 100, 0., 1.);
462 hSVDist_ =
fs->make<TH1F>(
"VtxDist",
";PV-#mu^{+}#mu^{-} vertex xy distance [#mum];N(#mu#mu pairs)", 100, 0., 300.);
463 hSVDistSig_ =
fs->make<TH1F>(
"VtxDistSig",
";PV-#mu^{+}#mu^{-} vertex xy distance signficance;N(#mu#mu pairs)", 100, 0., 5.);
465 hSVDist3D_ =
fs->make<TH1F>(
"VtxDist3D",
";PV-#mu^{+}#mu^{-} vertex 3D distance [#mum];N(#mu#mu pairs)", 100, 0., 300.);
466 hSVDist3DSig_ =
fs->make<TH1F>(
"VtxDist3DSig",
";PV-#mu^{+}#mu^{-} vertex 3D distance signficance;N(#mu#mu pairs)", 100, 0., 5.);
468 hInvMass_ =
fs->make<TH1F>(
"InvMass",
";M(#mu#mu) [GeV];N(#mu#mu pairs)", 70., 50., 120.);
469 hTrackInvMass_ =
fs->make<TH1F>(
"TkTkInvMass",
";M(tk,tk) [GeV];N(tk tk pairs)", 70., 50., 120.);
471 hCosPhi_ =
fs->make<TH1F>(
"CosPhi",
";cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
472 hCosPhi3D_ =
fs->make<TH1F>(
"CosPhi3D",
";cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
474 hCosPhiInv_ =
fs->make<TH1F>(
"CosPhiInv",
";inverted cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
475 hCosPhiInv3D_ =
fs->make<TH1F>(
"CosPhiInv3D",
";inverted cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
514 hCutFlow_ =
fs->make<TH1F>(
"hCutFlow",
"cut flow;cut step;events left", 6, -0.5, 5.5);
515 std::string names[6] = {
"Total",
"Mult.",
">pT",
"<eta",
"hasVtx",
"VtxDist"};
516 for (
unsigned int i = 0;
i < 6;
i++) {
534 TH1F::SetDefaultSumw2(kTRUE);
535 const unsigned int nBinsX =
hCosPhi_->GetNbinsX();
536 for (
unsigned int i = 1;
i <= nBinsX;
i++) {
538 float invertedBinContent =
hCosPhi_->GetBinContent(nBinsX + 1 -
i);
539 float invertedBinError =
hCosPhi_->GetBinError(nBinsX + 1 -
i);
544 float invertedBinContent3D =
hCosPhi3D_->GetBinContent(nBinsX + 1 -
i);
545 float invertedBinError3D =
hCosPhi3D_->GetBinError(nBinsX + 1 -
i);
562 int closestVtxIndex = 0;
573 if ((*vertices).at(closestVtxIndex).isValid()) {
574 return &(
vertices->at(closestVtxIndex));
587 ->setComment(
"If useReco is true need to specify the muon tracks, otherwise take the ALCARECO Inner tracks");
593 desc.add<std::vector<double>>(
"pTThresholds", {30., 10.});
594 desc.add<
bool>(
"useClosestVertex",
true);
595 desc.add<
double>(
"maxSVdist", 50.);
602 psDiMuMass.
add<
int>(
"NxBins", 24);
603 psDiMuMass.
add<
int>(
"NyBins", 50);
604 psDiMuMass.
add<
double>(
"ymin", 70.);
605 psDiMuMass.
add<
double>(
"ymax", 120.);
613 psCosPhi.
add<
int>(
"NxBins", 50);
614 psCosPhi.
add<
int>(
"NyBins", 50);
615 psCosPhi.
add<
double>(
"ymin", -1.);
616 psCosPhi.
add<
double>(
"ymax", 1.);
624 psCosPhi3D.
add<
int>(
"NxBins", 50);
625 psCosPhi3D.
add<
int>(
"NyBins", 50);
626 psCosPhi3D.
add<
double>(
"ymin", -1.);
627 psCosPhi3D.
add<
double>(
"ymax", 1.);
635 psVtxProb.
add<
int>(
"NxBins", 50);
636 psVtxProb.
add<
int>(
"NyBins", 50);
637 psVtxProb.
add<
double>(
"ymin", 0);
638 psVtxProb.
add<
double>(
"ymax", 1.);
646 psVtxDist.
add<
int>(
"NxBins", 50);
647 psVtxDist.
add<
int>(
"NyBins", 100);
648 psVtxDist.
add<
double>(
"ymin", 0);
649 psVtxDist.
add<
double>(
"ymax", 300.);
657 psVtxDist3D.
add<
int>(
"NxBins", 50);
658 psVtxDist3D.
add<
int>(
"NyBins", 250);
659 psVtxDist3D.
add<
double>(
"ymin", 0);
660 psVtxDist3D.
add<
double>(
"ymax", 500.);
666 psVtxDistSig.
add<
std::string>(
"title",
"d_{xy}(PV,SV)/#sigma_{dxy}(PV,SV)");
668 psVtxDistSig.
add<
int>(
"NxBins", 50);
669 psVtxDistSig.
add<
int>(
"NyBins", 100);
670 psVtxDistSig.
add<
double>(
"ymin", 0);
671 psVtxDistSig.
add<
double>(
"ymax", 5.);
677 psVtxDist3DSig.
add<
std::string>(
"title",
"d_{3D}(PV,SV)/#sigma_{d3D}(PV,SV)");
679 psVtxDist3DSig.
add<
int>(
"NxBins", 50);
680 psVtxDist3DSig.
add<
int>(
"NyBins", 100);
681 psVtxDist3DSig.
add<
double>(
"ymin", 0);
682 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
DiLeptonHelp::PlotsVsDiLeptonRegion InvMassInEtaBins
static constexpr float mumass2
const Point & position() const
position
void fillTH1Plots(const float val, const std::pair< TLorentzVector, TLorentzVector > &momenta)
T const * product() const
DiLeptonHelp::PlotsVsKinematics CosPhiPlots
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_
void bookSet(const TFileDirectory &fs, const TH1 *histo)
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::PlotsVsDiLeptonRegion CosPhi3DInEtaBins
DiLeptonHelp::PlotsVsKinematics ZMassPlots
edm::EDGetTokenT< reco::TrackCollection > alcaRecoToken_
unsigned int eventsAfterMult
bool isValid() const
Tells whether the vertex is valid.