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 
20 
23 
32 
42 
46 #include "TMath.h"
47 
48 #include <memory>
49 
50 using namespace reco;
51 using namespace edm;
52 using namespace std;
53 
55 public:
56  enum CMSSWPerigee { aCurv = 0, aTheta, aPhi, aTip, aLip };
57  explicit PFTauTransverseImpactParameters(const edm::ParameterSet& iConfig);
59  void produce(edm::Event&, const edm::EventSetup&) override;
60  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
61 
62 private:
67 };
68 
70  : PFTauToken_(consumes<std::vector<reco::PFTau>>(iConfig.getParameter<edm::InputTag>("PFTauTag"))),
71  PFTauPVAToken_(consumes<edm::AssociationVector<PFTauRefProd, std::vector<reco::VertexRef>>>(
72  iConfig.getParameter<edm::InputTag>("PFTauPVATag"))),
73  PFTauSVAToken_(consumes<edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef>>>>(
74  iConfig.getParameter<edm::InputTag>("PFTauSVATag"))),
75  useFullCalculation_(iConfig.getParameter<bool>("useFullCalculation")) {
76  produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef>>>();
77  produces<PFTauTransverseImpactParameterCollection>("PFTauTIP");
78 }
79 
81 
82 namespace {
83  inline const reco::Track* getTrack(const Candidate& cand) {
84  const PFCandidate* pfCandPtr = dynamic_cast<const PFCandidate*>(&cand);
85  if (pfCandPtr != nullptr) {
86  if (pfCandPtr->trackRef().isNonnull())
87  return pfCandPtr->trackRef().get();
88  else if (pfCandPtr->gsfTrackRef().isNonnull())
89  return pfCandPtr->gsfTrackRef().get();
90  else
91  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 } // namespace
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 =
117  std::make_unique<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef>>>(
118  PFTauRefProd(Tau));
119  auto TIPCollection_out = std::make_unique<PFTauTransverseImpactParameterCollection>();
121  iEvent.getRefBeforePut<reco::PFTauTransverseImpactParameterCollection>("PFTauTIP");
122 
123  // For each Tau Run Algorithim
124  if (Tau.isValid()) {
125  for (reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) {
126  reco::PFTauRef RefPFTau(Tau, iPFTau);
127  const reco::VertexRef PV = PFTauPVA->value(RefPFTau.key());
128  const std::vector<reco::VertexRef> SV = PFTauSVA->value(RefPFTau.key());
129  double dxy(-999), dxy_err(-999);
130  reco::Vertex::Point poca(0, 0, 0);
131  double ip3d(-999), ip3d_err(-999);
132  reco::Vertex::Point ip3d_poca(0, 0, 0);
133  if (RefPFTau->leadChargedHadrCand().isNonnull()) {
134  const reco::Track* track = getTrack(*RefPFTau->leadChargedHadrCand());
135  if (track != nullptr) {
136  if (useFullCalculation_) {
137  reco::TransientTrack transTrk = transTrackBuilder->build(*track);
138  GlobalVector direction(
139  RefPFTau->p4().px(), RefPFTau->p4().py(), RefPFTau->p4().pz()); //To compute sign of IP
140  std::pair<bool, Measurement1D> signed_IP2D =
141  IPTools::signedTransverseImpactParameter(transTrk, direction, (*PV));
142  dxy = signed_IP2D.second.value();
143  dxy_err = signed_IP2D.second.error();
144  std::pair<bool, Measurement1D> signed_IP3D = IPTools::signedImpactParameter3D(transTrk, direction, (*PV));
145  ip3d = signed_IP3D.second.value();
146  ip3d_err = signed_IP3D.second.error();
147  TransverseImpactPointExtrapolator extrapolator(transTrk.field());
148  GlobalPoint pos =
149  extrapolator.extrapolate(transTrk.impactPointState(), RecoVertex::convertPos(PV->position()))
150  .globalPosition();
151  poca = reco::Vertex::Point(pos.x(), pos.y(), pos.z());
152  AnalyticalImpactPointExtrapolator extrapolator3D(transTrk.field());
153  GlobalPoint pos3d =
154  extrapolator3D.extrapolate(transTrk.impactPointState(), RecoVertex::convertPos(PV->position()))
155  .globalPosition();
156  ip3d_poca = reco::Vertex::Point(pos3d.x(), pos3d.y(), pos3d.z());
157  } else {
158  dxy_err = track->d0Error();
159  dxy = track->dxy(PV->position());
160  ip3d_err = track->dzError(); //store dz, ip3d not available
161  ip3d = track->dz(PV->position()); //store dz, ip3d not available
162  }
163  }
164  }
165  if (!SV.empty()) {
167  reco::Vertex::Point v(SV.at(0)->x() - PV->x(), SV.at(0)->y() - PV->y(), SV.at(0)->z() - PV->z());
168  for (int i = 0; i < reco::Vertex::dimension; i++) {
169  for (int j = 0; j < reco::Vertex::dimension; j++) {
170  cov(i, j) = SV.at(0)->covariance(i, j) + PV->covariance(i, j);
171  }
172  }
173  GlobalVector direction(RefPFTau->px(), RefPFTau->py(), RefPFTau->pz());
174  double vSig = SecondaryVertex::computeDist3d(*PV, *SV.at(0), direction, true).significance();
175  reco::PFTauTransverseImpactParameter TIPV(poca, dxy, dxy_err, ip3d_poca, ip3d, ip3d_err, PV, v, vSig, SV.at(0));
177  reco::PFTauTransverseImpactParameterRef(TIPRefProd_out, TIPCollection_out->size());
178  TIPCollection_out->push_back(TIPV);
179  AVPFTauTIP->setValue(iPFTau, TIPVRef);
180  } else {
181  reco::PFTauTransverseImpactParameter TIPV(poca, dxy, dxy_err, ip3d_poca, ip3d, ip3d_err, PV);
183  reco::PFTauTransverseImpactParameterRef(TIPRefProd_out, TIPCollection_out->size());
184  TIPCollection_out->push_back(TIPV);
185  AVPFTauTIP->setValue(iPFTau, TIPVRef);
186  }
187  }
188  }
189  iEvent.put(std::move(TIPCollection_out), "PFTauTIP");
190  iEvent.put(std::move(AVPFTauTIP));
191 }
192 
194  // PFTauTransverseImpactParameters
196  desc.add<edm::InputTag>("PFTauPVATag", edm::InputTag("PFTauPrimaryVertexProducer"));
197  desc.add<bool>("useFullCalculation", false);
198  desc.add<edm::InputTag>("PFTauTag", edm::InputTag("hpsPFTauProducer"));
199  desc.add<edm::InputTag>("PFTauSVATag", edm::InputTag("PFTauSecondaryVertexProducer"));
200  descriptions.add("PFTauTransverseImpactParameters", desc);
201 }
202 
Vector3DBase
Definition: Vector3DBase.h:8
ConfigurationDescriptions.h
reco::PFCandidate::trackRef
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:408
edm::RefProd
Definition: EDProductfwd.h:25
PFTauTransverseImpactParameters::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFTauTransverseImpactParameters.cc:193
RefProd.h
pat::PackedCandidate::hasTrackDetails
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
Definition: PackedCandidate.h:788
PFTauTransverseImpactParameters::CMSSWPerigee
CMSSWPerigee
Definition: PFTauTransverseImpactParameters.cc:56
reco::Vertex::dimension
Definition: Vertex.h:42
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
PFTauFwd.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
MessageLogger.h
AnalyticalImpactPointExtrapolator.h
ESHandle.h
reco::PFTauTransverseImpactParameterRef
edm::Ref< PFTauTransverseImpactParameterCollection > PFTauTransverseImpactParameterRef
presistent reference to a PFTauTransverseImpactParameter
Definition: PFTauTransverseImpactParameterFwd.h:13
edm::EDGetTokenT
Definition: EDGetToken.h:33
L1TRate_Offline_cfi.Tau
Tau
Definition: L1TRate_Offline_cfi.py:43
edm
HLT enums.
Definition: AlignableModifier.h:19
pos
Definition: PixelAliasList.h:18
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
reco::PFTauRefProd
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
Definition: PFTauFwd.h:15
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
SecondaryVertex.h
EDProducer.h
reco::PFTau
Definition: PFTau.h:36
ConvertToFromReco.h
reco::Vertex::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Vertex.h:46
TransverseImpactPointExtrapolator
Definition: TransverseImpactPointExtrapolator.h:26
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
Tau
Definition: Tau.py:1
findQualityFiles.v
v
Definition: findQualityFiles.py:179
Association.h
IPTools::signedTransverseImpactParameter
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:57
edm::Handle
Definition: AssociativeIterator.h:50
nanoDQM_cfi.PV
PV
Definition: nanoDQM_cfi.py:542
edm::Ref< VertexCollection >
MakerMacros.h
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
IPTools::signedImpactParameter3D
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:81
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TransientTrackRecord
Definition: TransientTrackRecord.h:11
reco::Track
Definition: Track.h:27
edm::ESHandle< TransientTrackBuilder >
PFTauTransverseImpactParameters::PFTauToken_
edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
Definition: PFTauTransverseImpactParameters.cc:63
Point3DBase< float, GlobalTag >
ParameterSetDescription.h
PFTauTransverseImpactParameterFwd.h
reco::PFTauTransverseImpactParameter
Definition: PFTauTransverseImpactParameter.h:24
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Vertex.h
PFTauTransverseImpactParameters::PFTauPVAToken_
edm::EDGetTokenT< edm::AssociationVector< PFTauRefProd, std::vector< reco::VertexRef > > > PFTauPVAToken_
Definition: PFTauTransverseImpactParameters.cc:64
PFTauTransverseImpactParameter.h
edm::AssociationVector
Definition: AssociationVector.h:67
pat::PackedCandidate::pseudoTrack
virtual const reco::Track & pseudoTrack() const
Definition: PackedCandidate.h:773
TransientTrackBuilder.h
edm::ParameterSet
Definition: ParameterSet.h:47
reco::PFCandidate::gsfTrackRef
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:440
AnalyticalImpactPointExtrapolator
Definition: AnalyticalImpactPointExtrapolator.h:26
Event.h
pat::PackedCandidate
Definition: PackedCandidate.h:22
PackedCandidate.h
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
cand
Definition: decayParser.h:32
electrons_cff.ip3d
ip3d
Definition: electrons_cff.py:357
reco::TransientTrack::impactPointState
TrajectoryStateOnSurface impactPointState() const
Definition: TransientTrack.h:98
nanoDQM_cfi.SV
SV
Definition: nanoDQM_cfi.py:664
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
PFTauTransverseImpactParameters::useFullCalculation_
bool useFullCalculation_
Definition: PFTauTransverseImpactParameters.cc:66
edm::EventSetup
Definition: EventSetup.h:58
TransientTrackRecord.h
get
#define get
reco::TransientTrack::field
const MagneticField * field() const
Definition: TransientTrack.h:110
reco::Candidate
Definition: Candidate.h:27
VertexFwd.h
getTrack
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
Definition: GhostTrackState.cc:49
TransientVertex.h
PFTauTransverseImpactParameters::PFTauSVAToken_
edm::EDGetTokenT< edm::AssociationVector< PFTauRefProd, std::vector< std::vector< reco::VertexRef > > > > PFTauSVAToken_
Definition: PFTauTransverseImpactParameters.cc:65
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::PFTauTransverseImpactParameterCollection
std::vector< reco::PFTauTransverseImpactParameter > PFTauTransverseImpactParameterCollection
collection of PFTauTransverseImpactParameter objects
Definition: PFTauTransverseImpactParameterFwd.h:9
std
Definition: JetResolutionObject.h:76
IPTools.h
reco::TransientTrack
Definition: TransientTrack.h:19
PVValHelper::dxy
Definition: PVValidationHelpers.h:48
PFTauTransverseImpactParameters_cfi.PFTauTransverseImpactParameters
PFTauTransverseImpactParameters
Definition: PFTauTransverseImpactParameters_cfi.py:3
Frameworkfwd.h
PFTau.h
PFTauTransverseImpactParameters::~PFTauTransverseImpactParameters
~PFTauTransverseImpactParameters() override
Definition: PFTauTransverseImpactParameters.cc:80
EventSetup.h
Exception.h
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
RecoVertex::convertPos
reco::Vertex::Point convertPos(const GlobalPoint &p)
Definition: ConvertToFromReco.h:7
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
AssociationVector.h
PFTauTransverseImpactParameters::PFTauTransverseImpactParameters
PFTauTransverseImpactParameters(const edm::ParameterSet &iConfig)
Definition: PFTauTransverseImpactParameters.cc:69
PFTauTransverseImpactParameters::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: PFTauTransverseImpactParameters.cc:101
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
AnalyticalTrajectoryExtrapolatorToLine.h
PFTauTransverseImpactParameters
Definition: PFTauTransverseImpactParameters.cc:54
met_cff.significance
significance
Definition: met_cff.py:18
simKBmtfDigis_cfi.aPhi
aPhi
Definition: simKBmtfDigis_cfi.py:11