6 #include <fmt/printf.h> 22 #include "TLorentzVector.h" 26 constexpr
float mumass2 = 0.105658367 * 0.105658367;
33 motherName_(iConfig.getParameter<
std::
string>(
"decayMotherName")),
34 MEFolderName_(iConfig.getParameter<
std::
string>(
"FolderName")),
35 useClosestVertex_(iConfig.getParameter<
bool>(
"useClosestVertex")),
36 maxSVdist_(iConfig.getParameter<double>(
"maxSVdist")),
37 CosPhi3DConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"CosPhi3DConfig")),
38 SVDistConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"SVDistConfig")),
39 SVDistSigConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"SVDistSigConfig")),
40 SVDist3DConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"SVDist3DConfig")),
41 SVDist3DSigConfiguration_(iConfig.getParameter<
edm::
ParameterSet>(
"SVDist3DSigConfig")) {
44 }
else if (
motherName_.find(
"J/#psi") != std::string::npos) {
46 }
else if (
motherName_.find(
"#Upsilon") != std::string::npos) {
50 <<
" setting the default for the Z->mm (50.,120.)" << std::endl;
63 ts = fmt::sprintf(
"#chi^{2} of the %s vertex; #chi^{2} of the %s vertex; %s",
motherName_,
motherName_, ps);
66 ts = fmt::sprintf(
"#chi^{2}/ndf of the %s vertex; #chi^{2}/ndf of %s vertex; %s",
motherName_,
motherName_, ps);
70 ts = fmt::sprintf(
"%s;PV- %sV xy distance [#mum];%s", histTit,
motherName_, ps);
73 ts = fmt::sprintf(
"%s;PV-%sV xy distance error [#mum];%s", histTit,
motherName_, ps);
76 ts = fmt::sprintf(
"%s;PV-%sV xy distance signficance;%s", histTit,
motherName_, ps);
79 ts = fmt::sprintf(
"compatibility of %s vertex; compatibility of %s vertex; %s",
motherName_,
motherName_, ps);
82 ts = fmt::sprintf(
"%s;PV-%sV 3D distance [#mum];%s", histTit,
motherName_, ps);
85 ts = fmt::sprintf(
"%s;PV-%sV 3D distance error [#mum];%s", histTit,
motherName_, ps);
88 ts = fmt::sprintf(
"%s;PV-%sV 3D distance signficance;%s", histTit,
motherName_, ps);
91 ts = fmt::sprintf(
"3D compatibility of %s vertex;3D compatibility of %s vertex; %s",
motherName_,
motherName_, ps);
95 hCosPhi_ = iBooker.
book1D(
"CosPhi", fmt::sprintf(
"%s;cos(#phi_{xy});%s", histTit, ps), 50, -1., 1.);
96 hCosPhi3D_ = iBooker.
book1D(
"CosPhi3D", fmt::sprintf(
"%s;cos(#phi_{3D});%s", histTit, ps), 50, -1., 1.);
97 hCosPhiInv_ = iBooker.
book1D(
"CosPhiInv", fmt::sprintf(
"%s;inverted cos(#phi_{xy});%s", histTit, ps), 50, -1., 1.);
98 hCosPhiInv3D_ = iBooker.
book1D(
"CosPhiInv3D", fmt::sprintf(
"%s;inverted cos(#phi_{3D});%s", histTit, ps), 50, -1., 1.);
99 hCosPhiUnbalance_ = iBooker.
book1D(
"CosPhiUnbalance", fmt::sprintf(
"%s;cos(#phi_{xy}) unbalance;#Delta%s", histTit, ps), 50, -1.,1.);
100 hCosPhi3DUnbalance_ = iBooker.
book1D(
"CosPhi3DUnbalance", fmt::sprintf(
"%s;cos(#phi_{3D}) unbalance;#Delta%s", histTit, ps), 50, -1., 1.);
102 hdxy_ = iBooker.
book1D(
"dxy", fmt::sprintf(
"%s;muon track d_{xy}(PV) [#mum];muon tracks", histTit), 150, -300, 300);
103 hdz_ = iBooker.
book1D(
"dz", fmt::sprintf(
"%s;muon track d_{z}(PV) [#mum];muon tracks", histTit), 150, -300, 300);
104 hdxyErr_ = iBooker.
book1D(
"dxyErr", fmt::sprintf(
"%s;muon track err_{dxy} [#mum];muon tracks", histTit), 250, 0., 500.);
105 hdzErr_ = iBooker.
book1D(
"dzErr", fmt::sprintf(
"%s;muon track err_{dz} [#mum];muon tracks", histTit), 250, 0., 500.);
106 hIP2d_ = iBooker.
book1D(
"IP2d", fmt::sprintf(
"%s;muon track IP_{2D} [#mum];muon tracks", histTit), 150, -300, 300);
107 hIP3d_ = iBooker.
book1D(
"IP3d", fmt::sprintf(
"%s;muon track IP_{3D} [#mum];muon tracks", histTit), 150, -300, 300);
108 hIP2dsig_ = iBooker.
book1D(
"IP2Dsig", fmt::sprintf(
"%s;muon track IP_{2D} significance;muon tracks", histTit), 100, 0., 5.);
109 hIP3dsig_ = iBooker.
book1D(
"IP3Dsig", fmt::sprintf(
"%s;muon track IP_{3D} significance;muon tracks", histTit), 100, 0., 5.);
134 std::vector<const reco::Track*> myTracks;
136 if (!trackHandle.isValid()) {
137 edm::LogError(
"DiMuonVertexMonitor") <<
"invalid track collection encountered!";
141 for (
const auto& muonTrk : *trackHandle) {
142 myTracks.emplace_back(&muonTrk);
146 for (
const auto&
track : myTracks) {
148 <<
" , pT error: " <<
track->ptError() <<
" GeV" 149 <<
" , eta: " <<
track->eta() <<
" , phi: " <<
track->phi() << std::endl;
155 std::vector<reco::TransientTrack> tks;
157 if (myTracks.size() != 2) {
158 edm::LogWarning(
"DiMuonVertexMonitor") <<
"There are not enough tracks to monitor!";
162 const auto&
t1 = myTracks[1]->momentum();
163 const auto&
t0 = myTracks[0]->momentum();
164 const auto& ditrack =
t1 +
t0;
166 const auto& tplus = myTracks[0]->charge() > 0 ? myTracks[0] : myTracks[1];
167 const auto& tminus = myTracks[0]->charge() < 0 ? myTracks[0] : myTracks[1];
169 TLorentzVector p4_tplus(tplus->px(), tplus->py(), tplus->pz(),
sqrt((tplus->p() * tplus->p()) +
mumass2));
170 TLorentzVector p4_tminus(tminus->px(), tminus->py(), tminus->pz(),
sqrt((tminus->p() * tminus->p()) +
mumass2));
174 auto tLorentzVectorToString = [](
const TLorentzVector&
vector) {
179 edm::LogVerbatim(
"DiMuonVertexMonitor") <<
"mu+" << tLorentzVectorToString(p4_tplus) << std::endl;
180 edm::LogVerbatim(
"DiMuonVertexMonitor") <<
"mu-" << tLorentzVectorToString(p4_tminus) << std::endl;
183 const auto& Zp4 = p4_tplus + p4_tminus;
184 float track_invMass = Zp4.M();
188 std::pair<TLorentzVector, TLorentzVector> tktk_p4 = std::make_pair(p4_tplus, p4_tminus);
193 for (
const auto&
track : myTracks) {
195 tks.push_back(trajectory);
199 mumuTransientVtx = kalman.
vertex(tks);
206 if (!mumuTransientVtx.
isValid())
216 edm::LogWarning(
"DiMuonVertexMonitor") <<
"invalid vertex collection encountered Skipping event!";
223 theMainVtx = vertexHandle.
product()->front();
225 theMainVtx = *theClosestVertex;
232 theMainVtxPos.x() - myVertex.x(), theMainVtxPos.y() - myVertex.y(), theMainVtxPos.z() - myVertex.z());
244 for (
const auto&
track : myTracks) {
264 double dist_err = vertTool.
distance(mumuTransientVtx, theMainVtx).
error();
265 float compatibility = 0.;
268 compatibility = vertTool.
compatibility(mumuTransientVtx, theMainVtx);
270 LogTrace(
"DiMuonVertexMonitor") <<
"caught std::exception " << er.
what() << std::endl;
280 double distance3D = vertTool3D.
distance(mumuTransientVtx, theMainVtx).
value();
281 double dist3D_err = vertTool3D.
distance(mumuTransientVtx, theMainVtx).
error();
282 float compatibility3D = 0.;
285 compatibility3D = vertTool3D.
compatibility(mumuTransientVtx, theMainVtx);
287 LogTrace(
"DiMuonVertexMonitor") <<
"caught std::exception " << er.
what() << std::endl;
296 std::pair<TLorentzVector, TLorentzVector> tktk_p4 = std::make_pair(p4_tplus, p4_tminus);
305 double cosphi = (ZpT.x() * deltaVtx.x() + ZpT.y() * deltaVtx.y()) /
306 (
sqrt(ZpT.x() * ZpT.x() + ZpT.y() * ZpT.y()) *
307 sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y()));
309 double cosphi3D = (Zp.x() * deltaVtx.x() + Zp.y() * deltaVtx.y() + Zp.z() * deltaVtx.z()) /
310 (
sqrt(Zp.x() * Zp.x() + Zp.y() * Zp.y() + Zp.z() * Zp.z()) *
311 sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y() + deltaVtx.z() * deltaVtx.z()));
321 <<
"distance " <<
distance *
cmToum <<
" cosphi3D:" << cosphi3D << std::endl;
334 edm::LogWarning(
"DiMuonVertexMonitor") <<
"hardest primary vertex in the event is not valid!";
349 int closestVtxIndex = 0;
360 if ((*vertices).at(closestVtxIndex).isValid()) {
361 return &(
vertices->at(closestVtxIndex));
373 desc.add<
bool>(
"useClosestVertex",
true);
374 desc.add<
double>(
"maxSVdist", 50.);
381 psCosPhi3D.
add<
int>(
"NxBins", 24);
382 psCosPhi3D.
add<
int>(
"NyBins", 50);
383 psCosPhi3D.
add<
double>(
"ymin", -1.);
384 psCosPhi3D.
add<
double>(
"ymax", 1.);
385 psCosPhi3D.
add<
double>(
"maxDeltaEta", 3.7);
394 psSVDist.
add<
int>(
"NxBins", 24);
395 psSVDist.
add<
int>(
"NyBins", 100);
396 psSVDist.
add<
double>(
"ymin", 0.);
397 psSVDist.
add<
double>(
"ymax", 300.);
398 psSVDist.
add<
double>(
"maxDeltaEta", 3.7);
405 psSVDistSig.
add<
std::string>(
"title",
"PV-SV distance significance");
407 psSVDistSig.
add<
int>(
"NxBins", 24);
408 psSVDistSig.
add<
int>(
"NyBins", 100);
409 psSVDistSig.
add<
double>(
"ymin", 0.);
410 psSVDistSig.
add<
double>(
"ymax", 5.);
411 psSVDistSig.
add<
double>(
"maxDeltaEta", 3.7);
420 psSVDist3D.
add<
int>(
"NxBins", 24);
421 psSVDist3D.
add<
int>(
"NyBins", 100);
422 psSVDist3D.
add<
double>(
"ymin", 0.);
423 psSVDist3D.
add<
double>(
"ymax", 300.);
424 psSVDist3D.
add<
double>(
"maxDeltaEta", 3.7);
431 psSVDist3DSig.
add<
std::string>(
"title",
"PV-SV 3D distance significance");
433 psSVDist3DSig.
add<
int>(
"NxBins", 24);
434 psSVDist3DSig.
add<
int>(
"NyBins", 100);
435 psSVDist3DSig.
add<
double>(
"ymin", 0.);
436 psSVDist3DSig.
add<
double>(
"ymax", 5.);
437 psSVDist3DSig.
add<
double>(
"maxDeltaEta", 3.7);
MonitorElement * hdxyErr_
const std::string MEFolderName_
Log< level::Info, true > LogVerbatim
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const bool useClosestVertex_
float totalChiSquared() const
MonitorElement * hCosPhiInv_
std::pair< float, float > massLimits_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
GlobalPoint position() const
MonitorElement * hSVDist3DErr_
virtual void setCurrentFolder(std::string const &fullpath)
MonitorElement * hIP2dsig_
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
MonitorElement * hSVProb_
static constexpr float mumass2
const Point & position() const
position
T const * product() const
std::vector< Track > TrackCollection
collection of Tracks
DiLepPlotHelp::PlotsVsKinematics SVDistSigPlots_
DiLepPlotHelp::PlotsVsKinematics SVDistPlots_
MonitorElement * hCosPhi_
MonitorElement * hSVCompatibility_
std::vector< Vertex > VertexCollection
collection of Vertex objects
edm::ParameterSet SVDist3DConfiguration_
Log< level::Error, false > LogError
std::vector< Vertex > VertexCollection
float degreesOfFreedom() const
MonitorElement * hIP3dsig_
const std::string motherName_
MonitorElement * hSVNormChi2_
static std::string to_string(const XMLCh *ch)
DiLepPlotHelp::PlotsVsKinematics SVDist3DPlots_
MonitorElement * hCosPhi3DUnbalance_
MonitorElement * hCosPhiUnbalance_
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
MonitorElement * hCosPhiInv3D_
reco::TransientTrack build(const reco::Track *p) const
MonitorElement * hSVDist3D_
MonitorElement * hSVDist3DSig_
DiMuonVertexMonitor(const edm::ParameterSet &)
MonitorElement * hSVChi2_
void fillPlots(const float val, const std::pair< TLorentzVector, TLorentzVector > &momenta)
const reco::Vertex * findClosestVertex(const TransientVertex aTransVtx, const reco::VertexCollection *vertices) const
DiLepPlotHelp::PlotsVsKinematics SVDist3DSigPlots_
const edm::EDGetTokenT< reco::TrackCollection > tracksToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
MonitorElement * hSVDistSig_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::ParameterSet SVDistSigConfiguration_
edm::ParameterSet CosPhi3DConfiguration_
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
void analyze(const edm::Event &, const edm::EventSetup &) override
XYZPointD XYZPoint
point in space with cartesian internal representation
MonitorElement * hSVDist_
float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
MonitorElement * hSVCompatibility3D_
void bookFromPSet(dqm::reco::DQMStore::IBooker &iBooker, const edm::ParameterSet &hpar)
const edm::EDGetTokenT< reco::VertexCollection > vertexToken_
static std::atomic< unsigned int > counter
MonitorElement * hSVDistErr_
edm::ParameterSet SVDistConfiguration_
edm::ParameterSet SVDist3DSigConfiguration_
MonitorElement * hCosPhi3D_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
char const * what() const noexcept override
static constexpr float cmToum
DiLepPlotHelp::PlotsVsKinematics CosPhi3DPlots_
bool isValid() const
Tells whether the vertex is valid.
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttbESToken_
MonitorElement * hInvMass_
float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)