19 #include "Math/VectorUtil.h"
29 muons_(consumes<edm::
View<pat::
Muon>>(iConfig.getParameter<edm::
InputTag>(
"muons"))),
32 higherPuritySelection_(iConfig.getParameter<std::
string>(
"higherPuritySelection")),
33 lowerPuritySelection_(iConfig.getParameter<std::
string>(
"lowerPuritySelection")),
34 dimuonSelection_(iConfig.existsAs<std::
string>(
"dimuonSelection") ? iConfig.getParameter<std::
string>(
"dimuonSelection") :
""),
35 addCommonVertex_(iConfig.getParameter<bool>(
"addCommonVertex")),
36 addMuonlessPrimaryVertex_(iConfig.getParameter<bool>(
"addMuonlessPrimaryVertex")),
37 resolveAmbiguity_(iConfig.getParameter<bool>(
"resolvePileUpAmbiguity")),
38 addMCTruth_(iConfig.getParameter<bool>(
"addMCTruth"))
40 produces<pat::CompositeCandidateCollection>();
66 vector<double> muMasses;
67 muMasses.push_back( 0.1056583715 );
68 muMasses.push_back( 0.1056583715 );
81 theBeamSpotV =
Vertex(bs.position(), bs.covariance3D());
85 if ( priVtxs->begin() != priVtxs->end() ) {
86 thePrimaryV =
Vertex(*(priVtxs->begin()));
89 thePrimaryV =
Vertex(bs.position(), bs.covariance3D());
111 vector<TransientVertex> pvs;
120 myCand.
setCharge(it->charge()+it2->charge());
126 if (it->track().isNonnull() && it2->track().isNonnull()) {
129 vector<TransientTrack> t_tks;
130 t_tks.push_back(theTTBuilder->build(*it->track()));
131 t_tks.push_back(theTTBuilder->build(*it2->track()));
142 float vProb(TMath::Prob(vChi2,(
int)vNDF));
152 TVector3 pperp(jpsi.px(), jpsi.py(), 0);
157 float minDz = 999999.;
163 GlobalPoint(bs.position().x(), bs.position().y(), bs.position().z()),
166 if (status) extrapZ=ttmd.
points().first.z();
168 for(VertexCollection::const_iterator itv = priVtxs->begin(), itvend = priVtxs->end(); itv != itvend; ++itv){
169 float deltaZ = fabs(extrapZ - itv->position().z()) ;
170 if ( deltaZ < minDz ) {
172 thePrimaryV =
Vertex(*itv);
177 Vertex theOriginalPV = thePrimaryV;
180 muonLess.reserve(thePrimaryV.tracksSize());
187 if( !pvtracks.isValid()) {
std::cout <<
"pvtracks NOT valid " << std::endl; }
192 if (pvbeamspot.
id() != theBeamSpot.
id())
edm::LogWarning(
"Inconsistency") <<
"The BeamSpot used for PV reco is not the same used in this analyzer.";
198 if (rmu1 != 0 && rmu2 != 0 && rmu1->
track().
id() == pvtracks.
id() && rmu2->
track().
id() == pvtracks.
id()) {
202 if( thePrimaryV.hasRefittedTracks() ) {
204 std::vector<reco::Track>::const_iterator itRefittedTrack = thePrimaryV.refittedTracks().
begin();
205 std::vector<reco::Track>::const_iterator refittedTracksEnd = thePrimaryV.refittedTracks().end();
206 for( ; itRefittedTrack != refittedTracksEnd; ++itRefittedTrack ) {
207 if( thePrimaryV.originalTrack(*itRefittedTrack).key() == rmu1->
track().
key() )
continue;
208 if( thePrimaryV.originalTrack(*itRefittedTrack).key() == rmu2->
track().
key() )
continue;
210 muonLess.push_back(*(thePrimaryV.originalTrack(*itRefittedTrack)));
214 std::vector<reco::TrackBaseRef>::const_iterator itPVtrack = thePrimaryV.tracks_begin();
215 for( ; itPVtrack != thePrimaryV.tracks_end(); ++itPVtrack )
if (itPVtrack->isNonnull()) {
216 if( itPVtrack->key() == rmu1->
track().
key() )
continue;
217 if( itPVtrack->key() == rmu2->
track().
key() )
continue;
219 muonLess.push_back(**itPVtrack);
222 if (muonLess.size()>1 && muonLess.size() < thePrimaryV.tracksSize()){
223 pvs = revertex.
makeVertices(muonLess, *pvbeamspot, iSetup) ;
226 thePrimaryV = muonLessPV;
234 double vertexWeight = -1., sumPTPV = -1.;
235 int countTksOfPV = -1;
242 if(track.
pt() < 0.5)
continue;
245 if (!tkPVdist.first)
continue;
246 if (tkPVdist.second.significance()>3)
continue;
247 if (track.
ptError()/track.
pt()>0.1)
continue;
257 sumPTPV += track.
pt();
262 myCand.
addUserInt(
"countTksOfPV", countTksOfPV);
263 myCand.
addUserFloat(
"vertexWeight", (
float) vertexWeight);
284 pvtx.SetXYZ(thePrimaryV.position().x(),thePrimaryV.position().y(),0);
285 TVector3 vdiff = vtx - pvtx;
286 double cosAlpha = vdiff.Dot(pperp)/(vdiff.Perp()*pperp.Perp());
289 double ctauPV = distXY.
value()*cosAlpha * myCand.
mass()/pperp.Perp();
294 double ctauErrPV =
sqrt(ROOT::Math::Similarity(vpperp,vXYe))*myCand.
mass()/(pperp.Perp2());
301 pvtx.SetXYZ(theBeamSpotV.position().x(),theBeamSpotV.position().y(),0);
303 cosAlpha = vdiff.Dot(pperp)/(vdiff.Perp()*pperp.Perp());
306 double ctauBS = distXY.
value()*cosAlpha*myCand.
mass()/pperp.Perp();
311 double ctauErrBS =
sqrt(ROOT::Math::Similarity(vpperp,vXYeB))*myCand.
mass()/(pperp.Perp2());
343 if (genMu1->numberOfMothers()>0 && genMu2->numberOfMothers()>0){
346 if (mom1.
isNonnull() && (mom1 == mom2)) {
359 iEvent.
getByToken(genCands_, theGenParticles);
360 if (theGenParticles.
isValid()){
361 for(
size_t iGenParticle=0; iGenParticle<theGenParticles->size();++iGenParticle) {
362 const Candidate & genCand = (*theGenParticles)[iGenParticle];
363 if (genCand.
pdgId()==443 || genCand.
pdgId()==100443 ||
364 genCand.
pdgId()==553 || genCand.
pdgId()==100553 || genCand.
pdgId()==200553) {
388 oniaOutput->push_back(myCand);
394 iEvent.
put(oniaOutput);
402 if (
abs(pdgID) == 511 ||
abs(pdgID) == 521 ||
abs(pdgID) == 531 ||
abs(pdgID) == 5122)
return true;
410 if ((
abs(pdgID) == 511 &&
abs(momPdgID) == 511 && pdgID*momPdgID < 0) ||
411 (
abs(pdgID) == 531 &&
abs(momPdgID) == 531 && pdgID*momPdgID < 0))
417 std::pair<int, float>
421 float trueLife = -99.;
423 if (genJpsi->numberOfMothers()>0) {
425 TVector3 trueVtx(0.0,0.0,0.0);
426 TVector3 trueP(0.0,0.0,0.0);
427 TVector3 trueVtxMom(0.0,0.0,0.0);
429 trueVtx.SetXYZ(genJpsi->vertex().x(),genJpsi->vertex().y(),genJpsi->vertex().z());
430 trueP.SetXYZ(genJpsi->momentum().x(),genJpsi->momentum().y(),genJpsi->momentum().z());
432 bool aBhadron =
false;
435 std::pair<int, float>
result = std::make_pair(momJpsiID, trueLife);
441 momJpsiID = Jpsigrandmom->pdgId();
442 trueVtxMom.SetXYZ(Jpsigrandmom->vertex().x(),Jpsigrandmom->vertex().y(),Jpsigrandmom->vertex().z());
444 momJpsiID = Jpsimom->pdgId();
445 trueVtxMom.SetXYZ(Jpsimom->vertex().x(),Jpsimom->vertex().y(),Jpsimom->vertex().z());
452 momJpsiID = JpsiGrandgrandmom->pdgId();
453 trueVtxMom.SetXYZ(JpsiGrandgrandmom->vertex().x(),JpsiGrandgrandmom->vertex().y(),JpsiGrandgrandmom->vertex().z());
455 momJpsiID = Jpsigrandmom->pdgId();
456 trueVtxMom.SetXYZ(Jpsigrandmom->vertex().x(),Jpsigrandmom->vertex().y(),Jpsigrandmom->vertex().z());
462 momJpsiID = Jpsimom->pdgId();
463 trueVtxMom.SetXYZ(Jpsimom->vertex().x(),Jpsimom->vertex().y(),Jpsimom->vertex().z());
467 TVector3 vdiff = trueVtx - trueVtxMom;
469 trueLife = vdiff.Perp()*genJpsi->mass()/trueP.Perp();
471 std::pair<int, float>
result = std::make_pair(momJpsiID, trueLife);
Analysis-level particle class.
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
bool isNonnull() const
Checks for non-null.
trackRef_iterator tracks_end() const
last iterator over tracks
StringCutObjectSelector< pat::Muon > higherPuritySelection_
bool isAbHadron(int pdgID)
virtual TrackRef innerTrack() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void setCharge(Charge q)
set electric charge
const FreeTrajectoryState & theState() const
#define DEFINE_FWK_MODULE(type)
Onia2MuMuPAT(const edm::ParameterSet &)
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
float totalChiSquared() const
Global3DPoint GlobalPoint
const AlgebraicSymMatrix33 & matrix() const
std::vector< Track > TrackCollection
collection of Tracks
std::pair< int, float > findJpsiMCInfo(reco::GenParticleRef genJpsi)
virtual TrackRef track() const
reference to a Track
virtual void setP4(const LorentzVector &p4)
set 4-momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
InvariantMassFromVertex massCalculator
key_type key() const
Accessor for product key.
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 &)
virtual double mass() const
mass
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
float degreesOfFreedom() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void addUserFloat(const std::string &label, float data)
Set user-defined float.
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
GlobalPoint position() const
double pt() const
track transverse momentum
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
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.
void addUserInt(const std::string &label, int32_t data)
Set user-defined int.
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 addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
const edm::InputTag & inputTracks() const
Get the InputTag of the TrackCollection used in the VertexProducer.
bool isAMixedbHadron(int pdgID, int momPdgID)
virtual int pdgId() const =0
PDG identifier.
const edm::InputTag & inputBeamSpot() const
Get the InputTag of the BeamSpot used in the VertexProducer.
StringCutObjectSelector< pat::Muon > lowerPuritySelection_
void addUserData(const std::string &label, const T &data, bool transientOnly=false)
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
std::vector< CompositeCandidate > CompositeCandidateCollection
virtual double px() const
x coordinate of momentum vector
edm::EDGetTokenT< reco::BeamSpot > thebeamspot_
virtual double pz() const
z coordinate of momentum vector
bool quality(const TrackQuality) const
Track quality.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
const_iterator begin() const
first daughter const_iterator
edm::EDGetTokenT< reco::VertexCollection > thePVs_
GreaterByVProb< pat::CompositeCandidate > vPComparator_
trackRef_iterator tracks_begin() const
first iterator over tracks
virtual float distance() const
virtual std::pair< GlobalPoint, GlobalPoint > points() const
virtual double py() const
y coordinate of momentum vector
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