CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
27 
41 
45 #include "TMath.h"
46 
47 #include <memory>
48 
49 using namespace reco;
50 using namespace edm;
51 using namespace std;
52 
54  public:
55  enum Alg{useInputPV=0, useFont};
56  enum CMSSWPerigee{aCurv=0,aTheta,aPhi,aTip,aLip};
57  explicit PFTauTransverseImpactParameters(const edm::ParameterSet& iConfig);
59  virtual void produce(edm::Event&,const edm::EventSetup&);
60  private:
65 };
66 
68  PFTauToken_(consumes<std::vector<reco::PFTau> >(iConfig.getParameter<edm::InputTag>("PFTauTag"))),
69  PFTauPVAToken_(consumes<edm::AssociationVector<PFTauRefProd, std::vector<reco::VertexRef> > >(iConfig.getParameter<edm::InputTag>("PFTauPVATag"))),
70  PFTauSVAToken_(consumes<edm::AssociationVector<PFTauRefProd,std::vector<std::vector<reco::VertexRef> > > >(iConfig.getParameter<edm::InputTag>("PFTauSVATag"))),
71  useFullCalculation_(iConfig.getParameter<bool>("useFullCalculation"))
72 {
73  produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef> > >();
74  produces<PFTauTransverseImpactParameterCollection>("PFTauTIP");
75 }
76 
78 
79 }
80 
82  // Obtain Collections
83  edm::ESHandle<TransientTrackBuilder> transTrackBuilder;
84  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",transTrackBuilder);
85 
87  iEvent.getByToken(PFTauToken_,Tau);
88 
90  iEvent.getByToken(PFTauPVAToken_,PFTauPVA);
91 
93  iEvent.getByToken(PFTauSVAToken_,PFTauSVA);
94 
95  // Set Association Map
96  auto_ptr<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef> > > AVPFTauTIP(new edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef> >(PFTauRefProd(Tau)));
97  std::auto_ptr<PFTauTransverseImpactParameterCollection> TIPCollection_out= std::auto_ptr<PFTauTransverseImpactParameterCollection>(new PFTauTransverseImpactParameterCollection());
99 
100 
101  // For each Tau Run Algorithim
102  if(Tau.isValid()) {
103  for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) {
104  reco::PFTauRef RefPFTau(Tau, iPFTau);
105  const reco::VertexRef PV=PFTauPVA->value(RefPFTau.key());
106  const std::vector<reco::VertexRef> SV=PFTauSVA->value(RefPFTau.key());
107  double dxy(-999), dxy_err(-999);
108  reco::Vertex::Point poca(0,0,0);
109  if(RefPFTau->leadPFChargedHadrCand().isNonnull()){
110  if(RefPFTau->leadPFChargedHadrCand()->trackRef().isNonnull()){
112  reco::TransientTrack transTrk=transTrackBuilder->build(RefPFTau->leadPFChargedHadrCand()->trackRef());
113  GlobalPoint pv(PV->position().x(),PV->position().y(),PV->position().z());
117  poca=reco::Vertex::Point(pos.x(),pos.y(),pos.z());
118  }
119  else{
120  dxy_err=RefPFTau->leadPFChargedHadrCand()->trackRef()->d0Error();
121  dxy=RefPFTau->leadPFChargedHadrCand()->trackRef()->dxy(PV->position());
122  }
123  }
124  }
125  if(SV.size()>0){
127  reco::Vertex::Point v(SV.at(0)->x()-PV->x(),SV.at(0)->y()-PV->y(),SV.at(0)->z()-PV->z());
128  for(int i=0;i<reco::Vertex::dimension;i++){
129  for(int j=0;j<reco::Vertex::dimension;j++){
130  cov(i,j)=SV.at(0)->covariance(i,j)+PV->covariance(i,j);
131  }
132  }
133  GlobalVector direction(RefPFTau->px(),RefPFTau->py(),RefPFTau->pz());
134  double vSig = SecondaryVertex::computeDist3d(*PV,*SV.at(0),direction,true).significance();
135  reco::PFTauTransverseImpactParameter TIPV(poca,dxy,dxy_err,PV,v,vSig,SV.at(0));
136  reco::PFTauTransverseImpactParameterRef TIPVRef=reco::PFTauTransverseImpactParameterRef(TIPRefProd_out,TIPCollection_out->size());
137  TIPCollection_out->push_back(TIPV);
138  AVPFTauTIP->setValue(iPFTau,TIPVRef);
139  }
140  else{
141  reco::PFTauTransverseImpactParameter TIPV(poca,dxy,dxy_err,PV);
142  reco::PFTauTransverseImpactParameterRef TIPVRef=reco::PFTauTransverseImpactParameterRef(TIPRefProd_out,TIPCollection_out->size());
143  TIPCollection_out->push_back(TIPV);
144  AVPFTauTIP->setValue(iPFTau,TIPVRef);
145  }
146  }
147  }
148  iEvent.put(TIPCollection_out,"PFTauTIP");
149  iEvent.put(AVPFTauTIP);
150 }
151 
const AlgebraicVector5 & vector() const
int i
Definition: DBlmapReader.cc:9
const PerigeeTrajectoryError & perigeeError() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T y() const
Definition: PV3DBase.h:63
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_
edm::EDGetTokenT< edm::AssociationVector< PFTauRefProd, std::vector< std::vector< reco::VertexRef > > > > PFTauSVAToken_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
edm::EDGetTokenT< edm::AssociationVector< PFTauRefProd, std::vector< reco::VertexRef > > > PFTauPVAToken_
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
const PerigeeTrajectoryParameters & perigeeParameters() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
T z() const
Definition: PV3DBase.h:64
int j
Definition: DBlmapReader.cc:9
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
bool isValid() const
Definition: HandleBase.h:76
RefProd< PROD > getRefBeforePut()
Definition: Event.h:128
const AlgebraicSymMatrix55 & covarianceMatrix() const
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
const T & get() const
Definition: EventSetup.h:55
key_type key() const
Accessor for product key.
Definition: Ref.h:266
edm::Ref< PFTauTransverseImpactParameterCollection > PFTauTransverseImpactParameterRef
presistent reference to a PFTauTransverseImpactParameter
PFTauTransverseImpactParameters(const edm::ParameterSet &iConfig)
std::vector< reco::PFTauTransverseImpactParameter > PFTauTransverseImpactParameterCollection
collection of PFTauTransverseImpactParameter objects
T x() const
Definition: PV3DBase.h:62