CMS 3D CMS Logo

PFTauTransverseImpactParameters.cc
Go to the documentation of this file.
1 /* class PFTauTransverseImpactParamters
2  * EDProducer of the
3  * authors: Ian M. Nugent
4  * This work is based on the impact parameter work by Rosamaria Venditti and reconstructing the 3 prong taus.
5  * The idea of the fully reconstructing the tau using a kinematic fit comes from
6  * Lars Perchalla and Philip Sauerland Theses under Achim Stahl supervision. This
7  * work was continued by Ian M. Nugent and Vladimir Cherepanov.
8  * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions.
9  */
10 
11 
21 
24 
33 
43 
47 #include "TMath.h"
48 
49 #include <memory>
50 
51 using namespace reco;
52 using namespace edm;
53 using namespace std;
54 
56  public:
57  enum CMSSWPerigee{aCurv=0,aTheta,aPhi,aTip,aLip};
58  explicit PFTauTransverseImpactParameters(const edm::ParameterSet& iConfig);
60  void produce(edm::Event&,const edm::EventSetup&) override;
61  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
62 
63  private:
68 };
69 
71  PFTauToken_(consumes<std::vector<reco::PFTau> >(iConfig.getParameter<edm::InputTag>("PFTauTag"))),
72  PFTauPVAToken_(consumes<edm::AssociationVector<PFTauRefProd, std::vector<reco::VertexRef> > >(iConfig.getParameter<edm::InputTag>("PFTauPVATag"))),
73  PFTauSVAToken_(consumes<edm::AssociationVector<PFTauRefProd,std::vector<std::vector<reco::VertexRef> > > >(iConfig.getParameter<edm::InputTag>("PFTauSVATag"))),
74  useFullCalculation_(iConfig.getParameter<bool>("useFullCalculation"))
75 {
76  produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef> > >();
77  produces<PFTauTransverseImpactParameterCollection>("PFTauTIP");
78 }
79 
81 
82 }
83 
84 namespace {
85  inline const reco::Track* getTrack(const Candidate& cand)
86  {
87  const PFCandidate* pfCandPtr = dynamic_cast<const PFCandidate*>(&cand);
88  if (pfCandPtr != nullptr) {
89  if ( pfCandPtr->trackRef().isNonnull() ) return pfCandPtr->trackRef().get();
90  else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return pfCandPtr->gsfTrackRef().get();
91  else return nullptr;
92  }
93  const pat::PackedCandidate* packedCand = dynamic_cast<const pat::PackedCandidate*>(&cand);
94  if (packedCand != nullptr && packedCand->hasTrackDetails())
95  return &packedCand->pseudoTrack();
96 
97  return nullptr;
98  }
99 }
100 
102  // Obtain Collections
103  edm::ESHandle<TransientTrackBuilder> transTrackBuilder;
104  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",transTrackBuilder);
105 
107  iEvent.getByToken(PFTauToken_,Tau);
108 
110  iEvent.getByToken(PFTauPVAToken_,PFTauPVA);
111 
113  iEvent.getByToken(PFTauSVAToken_,PFTauSVA);
114 
115  // Set Association Map
116  auto AVPFTauTIP = std::make_unique< edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef>>>(PFTauRefProd(Tau));
117  auto TIPCollection_out = std::make_unique<PFTauTransverseImpactParameterCollection>();
119 
120  // For each Tau Run Algorithim
121  if(Tau.isValid()) {
122  for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) {
123  reco::PFTauRef RefPFTau(Tau, iPFTau);
124  const reco::VertexRef PV=PFTauPVA->value(RefPFTau.key());
125  const std::vector<reco::VertexRef> SV=PFTauSVA->value(RefPFTau.key());
126  double dxy(-999), dxy_err(-999);
127  reco::Vertex::Point poca(0,0,0);
128  double ip3d(-999), ip3d_err(-999);
129  reco::Vertex::Point ip3d_poca(0,0,0);
130  if(RefPFTau->leadChargedHadrCand().isNonnull()){
131  const reco::Track* track = getTrack(*RefPFTau->leadChargedHadrCand());
132  if(track != nullptr){
134  reco::TransientTrack transTrk=transTrackBuilder->build(*track);
135  GlobalVector direction(RefPFTau->p4().px(), RefPFTau->p4().py(), RefPFTau->p4().pz()); //To compute sign of IP
136  std::pair<bool,Measurement1D> signed_IP2D = IPTools::signedTransverseImpactParameter(transTrk, direction, (*PV));
137  dxy=signed_IP2D.second.value();
138  dxy_err=signed_IP2D.second.error();
139  std::pair<bool,Measurement1D> signed_IP3D = IPTools::signedImpactParameter3D(transTrk, direction, (*PV));
140  ip3d=signed_IP3D.second.value();
141  ip3d_err=signed_IP3D.second.error();
142  TransverseImpactPointExtrapolator extrapolator(transTrk.field());
143  GlobalPoint pos = extrapolator.extrapolate(transTrk.impactPointState(), RecoVertex::convertPos(PV->position())).globalPosition();
144  poca=reco::Vertex::Point(pos.x(),pos.y(),pos.z());
145  AnalyticalImpactPointExtrapolator extrapolator3D(transTrk.field());
146  GlobalPoint pos3d = extrapolator3D.extrapolate(transTrk.impactPointState(),RecoVertex::convertPos(PV->position())).globalPosition();
147  ip3d_poca=reco::Vertex::Point(pos3d.x(),pos3d.y(),pos3d.z());
148  }
149  else{
150  dxy_err=track->d0Error();
151  dxy=track->dxy(PV->position());
152  ip3d_err=track->dzError(); //store dz, ip3d not available
153  ip3d=track->dz(PV->position()); //store dz, ip3d not available
154  }
155  }
156  }
157  if(!SV.empty()){
159  reco::Vertex::Point v(SV.at(0)->x()-PV->x(),SV.at(0)->y()-PV->y(),SV.at(0)->z()-PV->z());
160  for(int i=0;i<reco::Vertex::dimension;i++){
161  for(int j=0;j<reco::Vertex::dimension;j++){
162  cov(i,j)=SV.at(0)->covariance(i,j)+PV->covariance(i,j);
163  }
164  }
165  GlobalVector direction(RefPFTau->px(),RefPFTau->py(),RefPFTau->pz());
166  double vSig = SecondaryVertex::computeDist3d(*PV,*SV.at(0),direction,true).significance();
167  reco::PFTauTransverseImpactParameter TIPV(poca,dxy,dxy_err,ip3d_poca,ip3d,ip3d_err,PV,v,vSig,SV.at(0));
168  reco::PFTauTransverseImpactParameterRef TIPVRef=reco::PFTauTransverseImpactParameterRef(TIPRefProd_out,TIPCollection_out->size());
169  TIPCollection_out->push_back(TIPV);
170  AVPFTauTIP->setValue(iPFTau,TIPVRef);
171  }
172  else{
173  reco::PFTauTransverseImpactParameter TIPV(poca,dxy,dxy_err,ip3d_poca,ip3d,ip3d_err,PV);
174  reco::PFTauTransverseImpactParameterRef TIPVRef=reco::PFTauTransverseImpactParameterRef(TIPRefProd_out,TIPCollection_out->size());
175  TIPCollection_out->push_back(TIPV);
176  AVPFTauTIP->setValue(iPFTau,TIPVRef);
177  }
178  }
179  }
180  iEvent.put(std::move(TIPCollection_out),"PFTauTIP");
181  iEvent.put(std::move(AVPFTauTIP));
182 }
183 
184 void
186  // PFTauTransverseImpactParameters
188  desc.add<edm::InputTag>("PFTauPVATag", edm::InputTag("PFTauPrimaryVertexProducer"));
189  desc.add<bool>("useFullCalculation", false);
190  desc.add<edm::InputTag>("PFTauTag", edm::InputTag("hpsPFTauProducer"));
191  desc.add<edm::InputTag>("PFTauSVATag", edm::InputTag("PFTauSecondaryVertexProducer"));
192  descriptions.add("PFTauTransverseImpactParameters", desc);
193 }
194 
reco::Vertex::Point convertPos(const GlobalPoint &p)
double d0Error() const
error on d0
Definition: TrackBase.h:853
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
reco::TransientTrack build(const reco::Track *p) const
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
const MagneticField * field() const
key_type key() const
Accessor for product key.
Definition: Ref.h:263
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
Definition: PFTauFwd.h:15
uint16_t size_type
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Vertex.h:45
edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
edm::EDGetTokenT< edm::AssociationVector< PFTauRefProd, std::vector< std::vector< reco::VertexRef > > > > PFTauSVAToken_
edm::EDGetTokenT< edm::AssociationVector< PFTauRefProd, std::vector< reco::VertexRef > > > PFTauPVAToken_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual const reco::Track & pseudoTrack() const
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:648
double dzError() const
error on dz
Definition: TrackBase.h:865
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::Ref< PFTauTransverseImpactParameterCollection > PFTauTransverseImpactParameterRef
presistent reference to a PFTauTransverseImpactParameter
significance
Definition: met_cff.py:19
PFTauTransverseImpactParameters(const edm::ParameterSet &iConfig)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:480
TrajectoryStateOnSurface impactPointState() const
std::vector< reco::PFTauTransverseImpactParameter > PFTauTransverseImpactParameterCollection
collection of PFTauTransverseImpactParameter objects
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:630
def move(src, dest)
Definition: eostools.py:511
void produce(edm::Event &, const edm::EventSetup &) override