CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PFTrackProducer Class Reference

#include <PFTrackProducer.h>

Inheritance diagram for PFTrackProducer:
edm::stream::EDProducer<>

Public Member Functions

 PFTrackProducer (const edm::ParameterSet &)
 Constructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 Produce the PFRecTrack collection. More...
 

Private Attributes

bool gsfinev_
 
edm::EDGetTokenT< reco::GsfTrackCollectiongsfTrackLabel_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
edm::EDGetTokenT< reco::MuonCollectionmuonColl_
 
std::unique_ptr< PFTrackTransformerpfTransformer_
 PFTrackTransformer. More...
 
reco::TrackBase::TrackQuality trackQuality_
 
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
 
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
 
bool trajinev_
 
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecordtransientTrackToken_
 
bool useQuality_
 TRACK QUALITY. More...
 
edm::EDGetTokenT< reco::VertexCollectionvtx_h
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 32 of file PFTrackProducer.h.

Constructor & Destructor Documentation

◆ PFTrackProducer()

PFTrackProducer::PFTrackProducer ( const edm::ParameterSet iConfig)
explicit

Constructor.

Definition at line 19 of file PFTrackProducer.cc.

20  : transientTrackToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
21  magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()),
22  pfTransformer_() {
23  produces<reco::PFRecTrackCollection>();
24 
25  std::vector<InputTag> tags = iConfig.getParameter<vector<InputTag> >("TkColList");
26  trajinev_ = iConfig.getParameter<bool>("TrajInEvents");
27  tracksContainers_.reserve(tags.size());
28  if (trajinev_) {
29  trajContainers_.reserve(tags.size());
30  }
31  for (auto const& tag : tags) {
32  tracksContainers_.push_back(consumes<reco::TrackCollection>(tag));
33  if (trajinev_) {
34  trajContainers_.push_back(consumes<std::vector<Trajectory> >(tag));
35  }
36  }
37 
38  useQuality_ = iConfig.getParameter<bool>("UseQuality");
39 
40  gsfinev_ = iConfig.getParameter<bool>("GsfTracksInEvents");
41  if (gsfinev_) {
42  gsfTrackLabel_ = consumes<reco::GsfTrackCollection>(iConfig.getParameter<InputTag>("GsfTrackModuleLabel"));
43  }
44 
46 
47  muonColl_ = consumes<reco::MuonCollection>(iConfig.getParameter<InputTag>("MuColl"));
48 
49  vtx_h = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("PrimaryVertexLabel"));
50 }

References edm::BeginRun, edm::ParameterSet::getParameter(), gsfinev_, gsfTrackLabel_, muonColl_, reco::TrackBase::qualityByName(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, triggerMatcherToHLTDebug_cfi::tags, trackQuality_, tracksContainers_, trajContainers_, trajinev_, useQuality_, and vtx_h.

Member Function Documentation

◆ beginRun()

void PFTrackProducer::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 202 of file PFTrackProducer.cc.

202  {
203  auto const& magneticField = iSetup.getData(magneticFieldToken_);
204  pfTransformer_ = std::make_unique<PFTrackTransformer>(math::XYZVector(magneticField.inTesla(GlobalPoint(0, 0, 0))));
205  if (!trajinev_)
206  pfTransformer_->OnlyProp();
207 }

References edm::EventSetup::getData(), HLT_FULL_cff::magneticField, magneticFieldToken_, pfTransformer_, and trajinev_.

◆ endRun()

void PFTrackProducer::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 210 of file PFTrackProducer.cc.

210 { pfTransformer_.reset(); }

References pfTransformer_.

◆ produce()

void PFTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Produce the PFRecTrack collection.

Definition at line 52 of file PFTrackProducer.cc.

52  {
53  //create the empty collections
54  auto PfTrColl = std::make_unique<reco::PFRecTrackCollection>();
55 
56  //read track collection
57  Handle<GsfTrackCollection> gsftrackcoll;
58  bool foundgsf = false;
59  if (gsfinev_) {
60  foundgsf = iEvent.getByToken(gsfTrackLabel_, gsftrackcoll);
61  }
62 
63  //Get PV for STIP calculation, if there is none then take the dummy
65  iEvent.getByToken(vtx_h, vertex);
67  const reco::Vertex* pv = &dummy;
68  if (vertex.isValid()) {
69  pv = &*vertex->begin();
70  } else { // create a dummy PV
72  e(0, 0) = 0.0015 * 0.0015;
73  e(1, 1) = 0.0015 * 0.0015;
74  e(2, 2) = 15. * 15.;
75  reco::Vertex::Point p(0, 0, 0);
76  dummy = reco::Vertex(p, e, 0, 0, 0);
77  }
78 
79  //setup transient track builder
80  TransientTrackBuilder const& thebuilder = iSetup.getData(transientTrackToken_);
81 
82  // read muon collection
84  iEvent.getByToken(muonColl_, recMuons);
85 
86  //default value for when trajinev_ is false
87  const vector<Trajectory> dummyTj(0);
88 
89  for (unsigned int istr = 0; istr < tracksContainers_.size(); istr++) {
90  //Track collection
91  Handle<reco::TrackCollection> tkRefCollection;
92  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
93  reco::TrackCollection Tk = *(tkRefCollection.product());
94 
95  //Use a pointer to aoid unnecessary copying of the collection
96  const vector<Trajectory>* Tj = &dummyTj;
97  if (trajinev_) {
98  //Trajectory collection
99  Handle<vector<Trajectory> > tjCollection;
100  iEvent.getByToken(trajContainers_[istr], tjCollection);
101 
102  Tj = tjCollection.product();
103  }
104 
105  for (unsigned int i = 0; i < Tk.size(); i++) {
106  reco::TrackRef trackRef(tkRefCollection, i);
107 
108  if (useQuality_ && (!(Tk[i].quality(trackQuality_)))) {
109  bool isMuCandidate = false;
110 
111  //TrackRef trackRef(tkRefCollection, i);
112 
113  if (recMuons.isValid()) {
114  for (unsigned j = 0; j < recMuons->size(); j++) {
115  reco::MuonRef muonref(recMuons, j);
116  if (muonref->track().isNonnull())
117  if (muonref->track() == trackRef && muonref->isGlobalMuon()) {
118  isMuCandidate = true;
119  //cout<<" SAVING TRACK "<<endl;
120  break;
121  }
122  }
123  }
124  if (!isMuCandidate) {
125  continue;
126  }
127  }
128 
129  // find the pre-id kf track
130  bool preId = false;
131  if (foundgsf) {
132  //NOTE: foundgsf is only true if gsftrackcoll is valid
133  for (auto const& gsfTrack : *gsftrackcoll) {
134  if (gsfTrack.seedRef().isNull())
135  continue;
136  auto const& seed = *(gsfTrack.extra()->seedRef());
137  auto const& ElSeed = dynamic_cast<ElectronSeed const&>(seed);
138  if (ElSeed.ctfTrack().isNonnull()) {
139  if (ElSeed.ctfTrack() == trackRef) {
140  preId = true;
141  break;
142  }
143  }
144  }
145  }
146  if (preId) {
147  // Set PFRecTrack of type KF_ElCAND
148  reco::PFRecTrack pftrack(trackRef->charge(), reco::PFRecTrack::KF_ELCAND, i, trackRef);
149 
150  bool valid = false;
151  if (trajinev_) {
152  valid = pfTransformer_->addPoints(pftrack, *trackRef, (*Tj)[i]);
153  } else {
154  Trajectory FakeTraj;
155  valid = pfTransformer_->addPoints(pftrack, *trackRef, FakeTraj);
156  }
157  if (valid) {
158  //calculate STIP
159  double stip = -999;
160  const reco::PFTrajectoryPoint& atECAL = pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
161  if (atECAL.isValid()) //if track extrapolates to ECAL
162  {
163  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
164  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
165  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
166  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv)
167  .second.significance();
168  }
169  pftrack.setSTIP(stip);
170  PfTrColl->push_back(pftrack);
171  }
172  } else {
173  reco::PFRecTrack pftrack(trackRef->charge(), reco::PFRecTrack::KF, i, trackRef);
174  bool valid = false;
175  if (trajinev_) {
176  valid = pfTransformer_->addPoints(pftrack, *trackRef, (*Tj)[i]);
177  } else {
178  Trajectory FakeTraj;
179  valid = pfTransformer_->addPoints(pftrack, *trackRef, FakeTraj);
180  }
181 
182  if (valid) {
183  double stip = -999;
184  const reco::PFTrajectoryPoint& atECAL = pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
185  if (atECAL.isValid()) {
186  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
187  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
188  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
189  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv)
190  .second.significance();
191  }
192  pftrack.setSTIP(stip);
193  PfTrColl->push_back(pftrack);
194  }
195  }
196  }
197  }
198  iEvent.put(std::move(PfTrColl));
199 }

References TransientTrackBuilder::build(), MillePedeFileConverter_cfg::e, reco::PFTrajectoryPoint::ECALEntrance, edm::EventSetup::getData(), gsfinev_, gsfTrackLabel_, mps_fire::i, iEvent, edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), reco::PFTrajectoryPoint::isValid(), dqmiolumiharvest::j, reco::PFRecTrack::KF, reco::PFRecTrack::KF_ELCAND, eostools::move(), muonColl_, AlCaHLTBitMon_ParallelJobs::p, pfTransformer_, edm::Handle< T >::product(), MetAnalyzer::pv(), quality, edm::second(), fileCollector::seed, IPTools::signedTransverseImpactParameter(), trackQuality_, tracksContainers_, trajContainers_, trajinev_, transientTrackToken_, useQuality_, RunInfoPI::valid, bphysicsOniaDQM_cfi::vertex, HltBtagValidation_cff::Vertex, and vtx_h.

Member Data Documentation

◆ gsfinev_

bool PFTrackProducer::gsfinev_
private

Definition at line 58 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ gsfTrackLabel_

edm::EDGetTokenT<reco::GsfTrackCollection> PFTrackProducer::gsfTrackLabel_
private

Definition at line 51 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ magneticFieldToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> PFTrackProducer::magneticFieldToken_
private

Definition at line 45 of file PFTrackProducer.h.

Referenced by beginRun().

◆ muonColl_

edm::EDGetTokenT<reco::MuonCollection> PFTrackProducer::muonColl_
private

Definition at line 52 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ pfTransformer_

std::unique_ptr<PFTrackTransformer> PFTrackProducer::pfTransformer_
private

PFTrackTransformer.

Definition at line 48 of file PFTrackProducer.h.

Referenced by beginRun(), endRun(), and produce().

◆ trackQuality_

reco::TrackBase::TrackQuality PFTrackProducer::trackQuality_
private

Definition at line 56 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ tracksContainers_

std::vector<edm::EDGetTokenT<reco::TrackCollection> > PFTrackProducer::tracksContainers_
private

Definition at line 49 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ trajContainers_

std::vector<edm::EDGetTokenT<std::vector<Trajectory> > > PFTrackProducer::trajContainers_
private

Definition at line 50 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ trajinev_

bool PFTrackProducer::trajinev_
private

Definition at line 57 of file PFTrackProducer.h.

Referenced by beginRun(), PFTrackProducer(), and produce().

◆ transientTrackToken_

const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> PFTrackProducer::transientTrackToken_
private

Definition at line 44 of file PFTrackProducer.h.

Referenced by produce().

◆ useQuality_

bool PFTrackProducer::useQuality_
private

TRACK QUALITY.

Definition at line 55 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ vtx_h

edm::EDGetTokenT<reco::VertexCollection> PFTrackProducer::vtx_h
private

Definition at line 53 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

Vector3DBase
Definition: Vector3DBase.h:8
PFTrackProducer::muonColl_
edm::EDGetTokenT< reco::MuonCollection > muonColl_
Definition: PFTrackProducer.h:52
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
edm::Handle::product
T const * product() const
Definition: Handle.h:70
PFTrackProducer::pfTransformer_
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
Definition: PFTrackProducer.h:48
PFTrackProducer::gsfTrackLabel_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
Definition: PFTrackProducer.h:51
PFTrackProducer::transientTrackToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackToken_
Definition: PFTrackProducer.h:44
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PFTrackProducer::tracksContainers_
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
Definition: PFTrackProducer.h:49
PFTrackProducer::trajinev_
bool trajinev_
Definition: PFTrackProducer.h:57
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
reco::PFRecTrack::KF
Definition: PFRecTrack.h:25
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
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
edm::Ref< TrackCollection >
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
fileCollector.seed
seed
Definition: fileCollector.py:127
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
PFTrackProducer::trajContainers_
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
Definition: PFTrackProducer.h:50
Point3DBase< float, GlobalTag >
reco::PFRecTrack::KF_ELCAND
Definition: PFRecTrack.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
PFTrackProducer::useQuality_
bool useQuality_
TRACK QUALITY.
Definition: PFTrackProducer.h:55
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
TransientTrackBuilder
Definition: TransientTrackBuilder.h:16
PFTrackProducer::trackQuality_
reco::TrackBase::TrackQuality trackQuality_
Definition: PFTrackProducer.h:56
reco::PFTrajectoryPoint::isValid
bool isValid() const
is this point valid ?
Definition: PFTrajectoryPoint.h:84
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
reco::PFTrajectoryPoint::ECALEntrance
ECAL front face.
Definition: PFTrajectoryPoint.h:43
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
PFTrackProducer::magneticFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: PFTrackProducer.h:45
reco::PFRecTrack
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:20
Trajectory
Definition: Trajectory.h:38
reco::PFTrajectoryPoint
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
Definition: PFTrajectoryPoint.h:26
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
PFTrackProducer::vtx_h
edm::EDGetTokenT< reco::VertexCollection > vtx_h
Definition: PFTrackProducer.h:53
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
dummy
Definition: DummySelector.h:38
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
reco::Vertex
Definition: Vertex.h:35
PFTrackProducer::gsfinev_
bool gsfinev_
Definition: PFTrackProducer.h:58
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37