17 #include "Math/VectorUtil.h" 33 higherPuritySelection_(iConfig.getParameter<
std::
string>(
"higherPuritySelection")),
34 lowerPuritySelection_(iConfig.getParameter<
std::
string>(
"lowerPuritySelection")),
35 dimuonSelection_(iConfig.getParameter<
std::
string>(
"dimuonSelection")),
36 addCommonVertex_(iConfig.getParameter<
bool>(
"addCommonVertex")),
37 addMuonlessPrimaryVertex_(iConfig.getParameter<
bool>(
"addMuonlessPrimaryVertex")),
38 resolveAmbiguity_(iConfig.getParameter<
bool>(
"resolvePileUpAmbiguity")),
39 addMCTruth_(iConfig.getParameter<
bool>(
"addMCTruth")) {
43 produces<pat::CompositeCandidateCollection>();
57 vector<double> muMasses;
58 muMasses.push_back(0.1056583715);
59 muMasses.push_back(0.1056583715);
71 theBeamSpotV =
Vertex(
bs.position(),
bs.covariance3D());
75 if (priVtxs->begin() != priVtxs->end()) {
76 thePrimaryV =
Vertex(*(priVtxs->begin()));
78 thePrimaryV =
Vertex(
bs.position(),
bs.covariance3D());
102 vector<TransientVertex>
pvs;
118 if (
it->track().isNonnull() && it2->track().isNonnull()) {
120 vector<TransientTrack> t_tks;
121 t_tks.push_back(theTTBuilder->
build(
123 t_tks.push_back(theTTBuilder->
build(*it2->track()));
140 float vProb(TMath::Prob(vChi2, (
int)vNDF));
150 TVector3 pperp(jpsi.px(), jpsi.py(), 0);
154 float minDz = 999999.;
166 float extrapZ = -9E20;
168 extrapZ = ttmd.
points().first.z();
170 for (VertexCollection::const_iterator itv = priVtxs->begin(), itvend = priVtxs->end(); itv != itvend;
172 float deltaZ = fabs(extrapZ - itv->position().z());
175 thePrimaryV =
Vertex(*itv);
180 Vertex theOriginalPV = thePrimaryV;
190 std::cout <<
"pvtracks NOT valid " << std::endl;
194 if (pvbeamspot.
id() != theBeamSpot.
id())
196 <<
"The BeamSpot used for PV reco is not the same used in this analyzer.";
202 if (rmu1 !=
nullptr && rmu2 !=
nullptr && rmu1->
track().
id() == pvtracks.
id() &&
209 std::vector<reco::Track>::const_iterator itRefittedTrack = thePrimaryV.
refittedTracks().begin();
210 std::vector<reco::Track>::const_iterator refittedTracksEnd = thePrimaryV.
refittedTracks().end();
211 for (; itRefittedTrack != refittedTracksEnd; ++itRefittedTrack) {
217 muonLess.push_back(*(thePrimaryV.
originalTrack(*itRefittedTrack)));
220 std::vector<reco::TrackBaseRef>::const_iterator itPVtrack = thePrimaryV.
tracks_begin();
221 for (; itPVtrack != thePrimaryV.
tracks_end(); ++itPVtrack)
222 if (itPVtrack->isNonnull()) {
223 if (itPVtrack->key() == rmu1->
track().
key())
225 if (itPVtrack->key() == rmu2->
track().
key())
228 muonLess.push_back(**itPVtrack);
231 if (muonLess.size() > 1 && muonLess.size() < thePrimaryV.
tracksSize()) {
235 thePrimaryV = muonLessPV;
243 double vertexWeight = -1., sumPTPV = -1.;
244 int countTksOfPV = -1;
251 if (itVtx->isNonnull()) {
255 if (
track.pt() < 0.5)
261 if (tkPVdist.second.significance() > 3)
266 if (rmu1 !=
nullptr && rmu1->
innerTrack().
key() == itVtx->key())
268 if (rmu2 !=
nullptr && rmu2->
innerTrack().
key() == itVtx->key())
274 sumPTPV +=
track.pt();
278 std::cout <<
" muon Selection%G�%@failed " << std::endl;
282 myCand.
addUserInt(
"countTksOfPV", countTksOfPV);
283 myCand.
addUserFloat(
"vertexWeight", (
float)vertexWeight);
306 TVector3 vdiff =
vtx - pvtx;
307 double cosAlpha = vdiff.Dot(pperp) / (vdiff.Perp() * pperp.Perp());
310 double ctauPV = distXY.
value() * cosAlpha * myCand.
mass() / pperp.Perp();
315 double ctauErrPV =
sqrt(ROOT::Math::Similarity(vpperp, vXYe)) * myCand.
mass() / (pperp.Perp2());
324 cosAlpha = vdiff.Dot(pperp) / (vdiff.Perp() * pperp.Perp());
327 double ctauBS = distXY.
value() * cosAlpha * myCand.
mass() / pperp.Perp();
332 double ctauErrBS =
sqrt(ROOT::Math::Similarity(vpperp, vXYeB)) * myCand.
mass() / (pperp.Perp2());
365 if (genMu1->numberOfMothers() > 0 && genMu2->numberOfMothers() > 0) {
368 if (mom1.
isNonnull() && (mom1 == mom2)) {
381 consumes<reco::GenParticleCollection>((
edm::InputTag)
"genParticles");
382 iEvent.getByToken(genCands_, theGenParticles);
383 if (theGenParticles.
isValid()) {
384 for (
size_t iGenParticle = 0; iGenParticle < theGenParticles->size(); ++iGenParticle) {
385 const Candidate &genCand = (*theGenParticles)[iGenParticle];
386 if (genCand.
pdgId() == 443 || genCand.
pdgId() == 100443 || genCand.
pdgId() == 553 ||
387 genCand.
pdgId() == 100553 || genCand.
pdgId() == 200553) {
408 oniaOutput->push_back(myCand);
418 if (
abs(pdgID) == 511 ||
abs(pdgID) == 521 ||
abs(pdgID) == 531 ||
abs(pdgID) == 5122)
424 if ((
abs(pdgID) == 511 &&
abs(momPdgID) == 511 && pdgID * momPdgID < 0) ||
425 (
abs(pdgID) == 531 &&
abs(momPdgID) == 531 && pdgID * momPdgID < 0))
432 float trueLife = -99.;
434 if (genJpsi->numberOfMothers() > 0) {
435 TVector3 trueVtx(0.0, 0.0, 0.0);
436 TVector3 trueP(0.0, 0.0, 0.0);
437 TVector3 trueVtxMom(0.0, 0.0, 0.0);
439 trueVtx.SetXYZ(genJpsi->vertex().x(), genJpsi->vertex().y(), genJpsi->vertex().z());
440 trueP.SetXYZ(genJpsi->momentum().x(), genJpsi->momentum().y(), genJpsi->momentum().z());
442 bool aBhadron =
false;
445 std::pair<int, float>
result = std::make_pair(momJpsiID, trueLife);
451 momJpsiID = Jpsigrandmom->pdgId();
452 trueVtxMom.SetXYZ(Jpsigrandmom->vertex().x(), Jpsigrandmom->vertex().y(), Jpsigrandmom->vertex().z());
454 momJpsiID = Jpsimom->pdgId();
455 trueVtxMom.SetXYZ(Jpsimom->vertex().x(), Jpsimom->vertex().y(), Jpsimom->vertex().z());
462 momJpsiID = JpsiGrandgrandmom->pdgId();
464 JpsiGrandgrandmom->vertex().x(), JpsiGrandgrandmom->vertex().y(), JpsiGrandgrandmom->vertex().z());
466 momJpsiID = Jpsigrandmom->pdgId();
467 trueVtxMom.SetXYZ(Jpsigrandmom->vertex().x(), Jpsigrandmom->vertex().y(), Jpsigrandmom->vertex().z());
473 momJpsiID = Jpsimom->pdgId();
474 trueVtxMom.SetXYZ(Jpsimom->vertex().x(), Jpsimom->vertex().y(), Jpsimom->vertex().z());
478 TVector3 vdiff = trueVtx - trueVtxMom;
480 trueLife = vdiff.Perp() * genJpsi->mass() / trueP.Perp();
482 std::pair<int, float>
result = std::make_pair(momJpsiID, trueLife);
494 desc.add<
bool>(
"addCommonVertex");
495 desc.add<
bool>(
"addMuonlessPrimaryVertex");
496 desc.add<
bool>(
"resolvePileUpAmbiguity");
497 desc.add<
bool>(
"addMCTruth");
Analysis-level particle class.
float totalChiSquared() const
double pz() const final
z coordinate of momentum vector
ProductID id() const
Accessor for product ID.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
GlobalPoint position() const
float distance() const override
StringCutObjectSelector< pat::Muon > higherPuritySelection_
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
const Point & position() const
position
Onia2MuMuPAT(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &)
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
bool isNonnull() const
Checks for non-null.
InvariantMassFromVertex massCalculator
std::pair< int, float > findJpsiMCInfo(reco::GenParticleRef genJpsi) const
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
void produce(edm::Event &, const edm::EventSetup &) override
TrackRef track() const override
reference to a Track
std::vector< Vertex > VertexCollection
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
float degreesOfFreedom() const
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
void reserve(int size, bool refitAsWell=false)
reserve space for the tracks
trackRef_iterator tracks_end() const
last iterator over tracks
key_type key() const
Accessor for product key.
size_t tracksSize() const
number of tracks
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
reco::TransientTrack build(const reco::Track *p) const
void setCharge(Charge q) final
set electric charge
Error error() const
return SMatrix
double px() const final
x coordinate of momentum vector
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::BeamSpot > revtxbs_
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > theTTBuilderToken_
StringCutObjectSelector< reco::Candidate, true > dimuonSelection_
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Measurement1D invariantMass(const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< reco::TrackCollection > revtxtrks_
std::vector< TransientVertex > makeVertices(const reco::TrackCollection &tracks, const reco::BeamSpot &bs, const TransientTrackBuilder &theB) const
Make the vertices.
math::XYZTLorentzVector LorentzVector
trackRef_iterator tracks_begin() const
first iterator over tracks
bool isAbHadron(int pdgID) const
#define DEFINE_FWK_MODULE(type)
const AlgebraicSymMatrix33 matrix() const
bool addMuonlessPrimaryVertex_
std::pair< GlobalPoint, GlobalPoint > points() const override
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
virtual TrackRef innerTrack() const
double py() const final
y coordinate of momentum vector
bool isNull() const
Checks for null.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void addUserInt(const std::string &label, int32_t data, const bool overwrite=false)
Set user-defined int.
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
virtual int pdgId() const =0
PDG identifier.
StringCutObjectSelector< pat::Muon > lowerPuritySelection_
std::vector< CompositeCandidate > CompositeCandidateCollection
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
const FreeTrajectoryState & theState() const
edm::EDGetTokenT< reco::BeamSpot > thebeamspot_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
double mass() const final
mass
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
ROOT::Math::SVector< double, 3 > AlgebraicVector3
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
edm::EDGetTokenT< reco::VertexCollection > thePVs_
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
int nominalValue() const
The nominal field value for this map in kGauss.
GreaterByVProb< pat::CompositeCandidate > vPComparator_
void setP4(const LorentzVector &p4) final
set 4-momentum
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
bool status() const override
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
TrackBaseRef originalTrack(const Track &refTrack) const
edm::EDGetTokenT< edm::View< pat::Muon > > muons_
math::PtEtaPhiELorentzVectorF LorentzVector
Global3DVector GlobalVector
bool isAMixedbHadron(int pdgID, int momPdgID) const