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 mainVtxPos.x() - myVertex.x(), mainVtxPos.y() - myVertex.y(), mainVtxPos.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 auto extractRangeValues = [](
const edm::ParameterSet& PSetConfiguration_) -> std::pair<double, double> {
463 double min = PSetConfiguration_.getParameter<
double>(
"ymin");
464 double max = PSetConfiguration_.getParameter<
double>(
"ymax");
470 hSVDist_ =
fs->make<TH1F>(
"VtxDist",
";PV-#mu^{+}#mu^{-} vertex xy distance [#mum];N(#mu#mu pairs)", 100, svDistRng.first, svDistRng.second);
474 hSVDistSig_ =
fs->make<TH1F>(
"VtxDistSig",
";PV-#mu^{+}#mu^{-} vertex xy distance signficance;N(#mu#mu pairs)", 100, svDistSigRng.first, svDistSigRng.second);
478 hSVDist3D_ =
fs->make<TH1F>(
"VtxDist3D",
";PV-#mu^{+}#mu^{-} vertex 3D distance [#mum];N(#mu#mu pairs)", 100, svDist3DRng.first, svDist3DRng.second);
482 hSVDist3DSig_ =
fs->make<TH1F>(
"VtxDist3DSig",
";PV-#mu^{+}#mu^{-} vertex 3D distance signficance;N(#mu#mu pairs)", 100, svDist3DSigRng.first, svDist3DSigRng.second);
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);
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.);
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.);
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++) {
552 TH1F::SetDefaultSumw2(kTRUE);
553 const unsigned int nBinsX =
hCosPhi_->GetNbinsX();
554 for (
unsigned int i = 1;
i <= nBinsX;
i++) {
556 float invertedBinContent =
hCosPhi_->GetBinContent(nBinsX + 1 -
i);
557 float invertedBinError =
hCosPhi_->GetBinError(nBinsX + 1 -
i);
562 float invertedBinContent3D =
hCosPhi3D_->GetBinContent(nBinsX + 1 -
i);
563 float invertedBinError3D =
hCosPhi3D_->GetBinError(nBinsX + 1 -
i);
580 int closestVtxIndex = 0;
591 if ((*vertices).at(closestVtxIndex).isValid()) {
592 return &(
vertices->at(closestVtxIndex));
605 ->setComment(
"If useReco is true need to specify the muon tracks, otherwise take the ALCARECO Inner tracks");
611 desc.add<std::vector<double>>(
"pTThresholds", {30., 10.});
612 desc.add<
bool>(
"useClosestVertex",
true);
613 desc.add<
double>(
"maxSVdist", 50.);
620 psDiMuMass.
add<
int>(
"NxBins", 24);
621 psDiMuMass.
add<
int>(
"NyBins", 50);
622 psDiMuMass.
add<
double>(
"ymin", 70.);
623 psDiMuMass.
add<
double>(
"ymax", 120.);
631 psCosPhi.
add<
int>(
"NxBins", 50);
632 psCosPhi.
add<
int>(
"NyBins", 50);
633 psCosPhi.
add<
double>(
"ymin", -1.);
634 psCosPhi.
add<
double>(
"ymax", 1.);
642 psCosPhi3D.
add<
int>(
"NxBins", 50);
643 psCosPhi3D.
add<
int>(
"NyBins", 50);
644 psCosPhi3D.
add<
double>(
"ymin", -1.);
645 psCosPhi3D.
add<
double>(
"ymax", 1.);
653 psVtxProb.
add<
int>(
"NxBins", 50);
654 psVtxProb.
add<
int>(
"NyBins", 50);
655 psVtxProb.
add<
double>(
"ymin", 0);
656 psVtxProb.
add<
double>(
"ymax", 1.);
664 psVtxDist.
add<
int>(
"NxBins", 50);
665 psVtxDist.
add<
int>(
"NyBins", 100);
666 psVtxDist.
add<
double>(
"ymin", 0);
667 psVtxDist.
add<
double>(
"ymax", 300.);
675 psVtxDist3D.
add<
int>(
"NxBins", 50);
676 psVtxDist3D.
add<
int>(
"NyBins", 250);
677 psVtxDist3D.
add<
double>(
"ymin", 0);
678 psVtxDist3D.
add<
double>(
"ymax", 500.);
684 psVtxDistSig.
add<
std::string>(
"title",
"d_{xy}(PV,SV)/#sigma_{dxy}(PV,SV)");
686 psVtxDistSig.
add<
int>(
"NxBins", 50);
687 psVtxDistSig.
add<
int>(
"NyBins", 100);
688 psVtxDistSig.
add<
double>(
"ymin", 0);
689 psVtxDistSig.
add<
double>(
"ymax", 5.);
695 psVtxDist3DSig.
add<
std::string>(
"title",
"d_{3D}(PV,SV)/#sigma_{d3D}(PV,SV)");
697 psVtxDist3DSig.
add<
int>(
"NxBins", 50);
698 psVtxDist3DSig.
add<
int>(
"NyBins", 100);
699 psVtxDist3DSig.
add<
double>(
"ymin", 0);
700 psVtxDist3DSig.
add<
double>(
"ymax", 5.);
DiMuonVertexValidation(const edm::ParameterSet &)
static const std::string kSharedResource
const edm::ParameterSet VtxProbConfiguration_
Log< level::Info, true > LogVerbatim
const edm::ParameterSet DiMuMassConfiguration_
~DiMuonVertexValidation() override
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
float totalChiSquared() const
unsigned int eventsAfterVtx
const edm::ParameterSet CosPhi3DConfiguration_
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
const edm::ParameterSet CosPhiConfiguration_
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
const edm::ParameterSet VtxDist3DConfiguration_
unsigned int eventsAfterDist
std::vector< Vertex > VertexCollection
collection of Vertex objects
DiLeptonHelp::PlotsVsKinematics VtxDist3DPlots
const edm::ParameterSet VtxDist3DSigConfiguration_
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
void bookSet(const TFileDirectory &fs, const TH1 *histo)
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
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)
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
DiLeptonHelp::PlotsVsKinematics VtxProbPlots
const edm::ParameterSet VtxDistConfiguration_
const reco::Vertex * findClosestVertex(const TransientVertex aTransVtx, const reco::VertexCollection *vertices) const
DiLeptonHelp::PlotsVsKinematics CosPhi3DPlots
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_
const edm::EDGetTokenT< reco::VertexCollection > vertexToken_
unsigned int eventsAfterMult
bool isValid() const
Tells whether the vertex is valid.