19 #include "Math/VectorUtil.h" 30 muons_(consumes<
edm::
View<
pat::
Muon>>(iConfig.getParameter<
edm::InputTag>(
"muons"))),
31 thebeamspot_(consumes<
reco::
BeamSpot>(iConfig.getParameter<
edm::InputTag>(
"beamSpotTag"))),
33 higherPuritySelection_(iConfig.getParameter<
std::
string>(
"higherPuritySelection")),
34 lowerPuritySelection_(iConfig.getParameter<
std::
string>(
"lowerPuritySelection")),
35 dimuonSelection_(iConfig.existsAs<
std::
string>(
"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>();
69 vector<double> muMasses;
70 muMasses.push_back( 0.1056583715 );
71 muMasses.push_back( 0.1056583715 );
85 theBeamSpotV =
Vertex(bs.position(), bs.covariance3D());
89 if ( priVtxs->begin() != priVtxs->end() ) {
90 thePrimaryV =
Vertex(*(priVtxs->begin()));
93 thePrimaryV =
Vertex(bs.position(), bs.covariance3D());
115 vector<TransientVertex> pvs;
122 LorentzVector
jpsi = it->p4() + it2->p4();
124 myCand.
setCharge(it->charge()+it2->charge());
130 if (it->track().isNonnull() && it2->track().isNonnull()) {
133 vector<TransientTrack> t_tks;
134 t_tks.push_back(theTTBuilder->
build(*it->track()));
135 t_tks.push_back(theTTBuilder->
build(*it2->track()));
152 float vProb(TMath::Prob(vChi2,(
int)vNDF));
162 TVector3 pperp(jpsi.px(), jpsi.py(), 0);
167 float minDz = 999999.;
173 GlobalPoint(bs.position().x(), bs.position().y(), bs.position().z()),
176 if (status) extrapZ=ttmd.
points().first.z();
178 for(VertexCollection::const_iterator itv = priVtxs->begin(), itvend = priVtxs->end(); itv != itvend; ++itv){
179 float deltaZ = fabs(extrapZ - itv->position().z()) ;
180 if ( deltaZ < minDz ) {
182 thePrimaryV =
Vertex(*itv);
187 Vertex theOriginalPV = thePrimaryV;
196 if( !pvtracks.
isValid()) {
std::cout <<
"pvtracks NOT valid " << std::endl; }
200 if (pvbeamspot.
id() != theBeamSpot.
id())
edm::LogWarning(
"Inconsistency") <<
"The BeamSpot used for PV reco is not the same used in this analyzer.";
206 if (rmu1 != 0 && rmu2 != 0 && rmu1->
track().
id() == pvtracks.
id() && rmu2->
track().
id() == pvtracks.
id()) {
212 std::vector<reco::Track>::const_iterator itRefittedTrack = thePrimaryV.
refittedTracks().begin();
213 std::vector<reco::Track>::const_iterator refittedTracksEnd = thePrimaryV.
refittedTracks().end();
214 for( ; itRefittedTrack != refittedTracksEnd; ++itRefittedTrack ) {
218 muonLess.push_back(*(thePrimaryV.
originalTrack(*itRefittedTrack)));
222 std::vector<reco::TrackBaseRef>::const_iterator itPVtrack = thePrimaryV.
tracks_begin();
223 for( ; itPVtrack != thePrimaryV.
tracks_end(); ++itPVtrack )
if (itPVtrack->isNonnull()) {
224 if( itPVtrack->key() == rmu1->
track().
key() )
continue;
225 if( itPVtrack->key() == rmu2->
track().
key() )
continue;
227 muonLess.push_back(**itPVtrack);
230 if (muonLess.size()>1 && muonLess.size() < thePrimaryV.
tracksSize()){
231 pvs = revertex.
makeVertices(muonLess, *pvbeamspot, iSetup) ;
234 thePrimaryV = muonLessPV;
242 double vertexWeight = -1., sumPTPV = -1.;
243 int countTksOfPV = -1;
250 if(track.
pt() < 0.5)
continue;
253 if (!tkPVdist.first)
continue;
254 if (tkPVdist.second.significance()>3)
continue;
255 if (track.
ptError()/track.
pt()>0.1)
continue;
265 sumPTPV += track.
pt();
270 myCand.
addUserInt(
"countTksOfPV", countTksOfPV);
271 myCand.
addUserFloat(
"vertexWeight", (
float) vertexWeight);
293 TVector3 vdiff = vtx - pvtx;
294 double cosAlpha = vdiff.Dot(pperp)/(vdiff.Perp()*pperp.Perp());
297 double ctauPV = distXY.
value()*cosAlpha * myCand.
mass()/pperp.Perp();
302 double ctauErrPV =
sqrt(ROOT::Math::Similarity(vpperp,vXYe))*myCand.
mass()/(pperp.Perp2());
311 cosAlpha = vdiff.Dot(pperp)/(vdiff.Perp()*pperp.Perp());
314 double ctauBS = distXY.
value()*cosAlpha*myCand.
mass()/pperp.Perp();
319 double ctauErrBS =
sqrt(ROOT::Math::Similarity(vpperp,vXYeB))*myCand.
mass()/(pperp.Perp2());
352 if (genMu1->numberOfMothers()>0 && genMu2->numberOfMothers()>0){
355 if (mom1.
isNonnull() && (mom1 == mom2)) {
368 iEvent.
getByToken(genCands_, theGenParticles);
369 if (theGenParticles.
isValid()){
370 for(
size_t iGenParticle=0; iGenParticle<theGenParticles->size();++iGenParticle) {
371 const Candidate & genCand = (*theGenParticles)[iGenParticle];
372 if (genCand.
pdgId()==443 || genCand.
pdgId()==100443 ||
373 genCand.
pdgId()==553 || genCand.
pdgId()==100553 || genCand.
pdgId()==200553) {
397 oniaOutput->push_back(myCand);
401 std::sort(oniaOutput->begin(),oniaOutput->end(),
vPComparator_);
411 if (
abs(pdgID) == 511 ||
abs(pdgID) == 521 ||
abs(pdgID) == 531 ||
abs(pdgID) == 5122)
return true;
419 if ((
abs(pdgID) == 511 &&
abs(momPdgID) == 511 && pdgID*momPdgID < 0) ||
420 (
abs(pdgID) == 531 &&
abs(momPdgID) == 531 && pdgID*momPdgID < 0))
426 std::pair<int, float>
430 float trueLife = -99.;
432 if (genJpsi->numberOfMothers()>0) {
434 TVector3 trueVtx(0.0,0.0,0.0);
435 TVector3 trueP(0.0,0.0,0.0);
436 TVector3 trueVtxMom(0.0,0.0,0.0);
438 trueVtx.SetXYZ(genJpsi->vertex().x(),genJpsi->vertex().y(),genJpsi->vertex().z());
439 trueP.SetXYZ(genJpsi->momentum().x(),genJpsi->momentum().y(),genJpsi->momentum().z());
441 bool aBhadron =
false;
444 std::pair<int, float>
result = std::make_pair(momJpsiID, trueLife);
450 momJpsiID = Jpsigrandmom->pdgId();
451 trueVtxMom.SetXYZ(Jpsigrandmom->vertex().x(),Jpsigrandmom->vertex().y(),Jpsigrandmom->vertex().z());
453 momJpsiID = Jpsimom->pdgId();
454 trueVtxMom.SetXYZ(Jpsimom->vertex().x(),Jpsimom->vertex().y(),Jpsimom->vertex().z());
461 momJpsiID = JpsiGrandgrandmom->pdgId();
462 trueVtxMom.SetXYZ(JpsiGrandgrandmom->vertex().x(),JpsiGrandgrandmom->vertex().y(),JpsiGrandgrandmom->vertex().z());
464 momJpsiID = Jpsigrandmom->pdgId();
465 trueVtxMom.SetXYZ(Jpsigrandmom->vertex().x(),Jpsigrandmom->vertex().y(),Jpsigrandmom->vertex().z());
471 momJpsiID = Jpsimom->pdgId();
472 trueVtxMom.SetXYZ(Jpsimom->vertex().x(),Jpsimom->vertex().y(),Jpsimom->vertex().z());
476 TVector3 vdiff = trueVtx - trueVtxMom;
478 trueLife = vdiff.Perp()*genJpsi->mass()/trueP.Perp();
480 std::pair<int, float>
result = std::make_pair(momJpsiID, trueLife);
Analysis-level particle class.
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
virtual double mass() const final
mass
trackRef_iterator tracks_end() const
last iterator over tracks
StringCutObjectSelector< pat::Muon > higherPuritySelection_
bool isAbHadron(int pdgID)
virtual TrackRef innerTrack() const
int nominalValue() const
The nominal field value for this map in kGauss.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackBaseRef originalTrack(const Track &refTrack) const
const FreeTrajectoryState & theState() const
#define DEFINE_FWK_MODULE(type)
const AlgebraicSymMatrix33 matrix() const
Onia2MuMuPAT(const edm::ParameterSet &)
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
float totalChiSquared() const
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
reco::TransientTrack build(const reco::Track *p) const
std::pair< int, float > findJpsiMCInfo(reco::GenParticleRef genJpsi)
virtual TrackRef track() const
reference to a Track
std::vector< Vertex > VertexCollection
collection of Vertex objects
InvariantMassFromVertex massCalculator
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
key_type key() const
Accessor for product key.
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
const Point & position() const
position
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
ProductID id() const
Accessor for product ID.
virtual void produce(edm::Event &, const edm::EventSetup &)
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
edm::EDGetTokenT< reco::BeamSpot > revtxbs_
float degreesOfFreedom() const
virtual int pdgId() const =0
PDG identifier.
virtual double px() const final
x coordinate of momentum vector
GlobalPoint position() const
double pt() const
track transverse momentum
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
virtual void setCharge(Charge q) final
set electric charge
StringCutObjectSelector< reco::Candidate, true > dimuonSelection_
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Abs< T >::type abs(const T &t)
std::vector< TransientVertex > makeVertices(const reco::TrackCollection &tracks, const reco::BeamSpot &bs, const edm::EventSetup &iSetup) const
Make the vertices.
edm::EDGetTokenT< reco::TrackCollection > revtxtrks_
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
bool addMuonlessPrimaryVertex_
virtual Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
bool isNull() const
Checks for null.
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
bool isAMixedbHadron(int pdgID, int momPdgID)
virtual double pz() const final
z coordinate of momentum vector
StringCutObjectSelector< pat::Muon > lowerPuritySelection_
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
std::vector< CompositeCandidate > CompositeCandidateCollection
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
Error error() const
return SMatrix
edm::EDGetTokenT< reco::BeamSpot > thebeamspot_
bool quality(const TrackQuality) const
Track quality.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
return(e1-e2)*(e1-e2)+dp *dp
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
edm::EDGetTokenT< reco::VertexCollection > thePVs_
GreaterByVProb< pat::CompositeCandidate > vPComparator_
trackRef_iterator tracks_begin() const
first iterator over tracks
virtual float distance() const
T const * product() const
virtual std::pair< GlobalPoint, GlobalPoint > points() const
virtual double py() const final
y coordinate of momentum vector
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
size_t tracksSize() const
number of tracks
virtual bool status() const
Measurement1D invariantMass(const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
edm::EDGetTokenT< edm::View< pat::Muon > > muons_
math::PtEtaPhiELorentzVectorF LorentzVector
Global3DVector GlobalVector