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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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_
 
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_
 
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 28 of file PFTrackProducer.h.

Constructor & Destructor Documentation

◆ PFTrackProducer()

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

Constructor.

Definition at line 23 of file PFTrackProducer.cc.

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

References 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

◆ endRun()

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

Definition at line 213 of file PFTrackProducer.cc.

213 { pfTransformer_.reset(); }

References pfTransformer_.

◆ produce()

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

Produce the PFRecTrack collection.

Definition at line 53 of file PFTrackProducer.cc.

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

References TransientTrackBuilder::build(), MillePedeFileConverter_cfg::e, reco::PFTrajectoryPoint::ECALEntrance, edm::EventSetup::get(), get, 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(), edm::ESHandle< T >::product(), MetAnalyzer::pv(), qcdUeDQM_cfi::quality, edm::second(), SurveyInfoScenario_cff::seed, IPTools::signedTransverseImpactParameter(), trackQuality_, tracksContainers_, trajContainers_, trajinev_, useQuality_, validateGeometry_cfg::valid, bphysicsOniaDQM_cfi::vertex, HltBtagValidation_cff::Vertex, and vtx_h.

Member Data Documentation

◆ gsfinev_

bool PFTrackProducer::gsfinev_
private

Definition at line 51 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ gsfTrackLabel_

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

Definition at line 44 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ muonColl_

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

Definition at line 45 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ pfTransformer_

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

PFTrackTransformer.

Definition at line 41 of file PFTrackProducer.h.

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

◆ trackQuality_

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

Definition at line 49 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ tracksContainers_

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

Definition at line 42 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ trajContainers_

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

Definition at line 43 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ trajinev_

bool PFTrackProducer::trajinev_
private

Definition at line 50 of file PFTrackProducer.h.

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

◆ useQuality_

bool PFTrackProducer::useQuality_
private

TRACK QUALITY.

Definition at line 48 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

◆ vtx_h

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

Definition at line 46 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

Vector3DBase
Definition: Vector3DBase.h:8
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
PFTrackProducer::muonColl_
edm::EDGetTokenT< reco::MuonCollection > muonColl_
Definition: PFTrackProducer.h:45
mps_fire.i
i
Definition: mps_fire.py:355
edm::Handle::product
T const * product() const
Definition: Handle.h:70
PFTrackProducer::pfTransformer_
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
Definition: PFTrackProducer.h:41
PFTrackProducer::gsfTrackLabel_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
Definition: PFTrackProducer.h:44
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
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:42
PFTrackProducer::trajinev_
bool trajinev_
Definition: PFTrackProducer.h:50
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
reco::PFRecTrack::KF
Definition: PFRecTrack.h:27
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
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
edm::Ref< TrackCollection >
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
TransientTrackRecord
Definition: TransientTrackRecord.h:11
edm::ESHandle< MagneticField >
PFTrackProducer::trajContainers_
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
Definition: PFTrackProducer.h:43
Point3DBase< float, GlobalTag >
reco::PFRecTrack::KF_ELCAND
Definition: PFRecTrack.h:29
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:48
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
get
#define get
PFTrackProducer::trackQuality_
reco::TrackBase::TrackQuality trackQuality_
Definition: PFTrackProducer.h:49
reco::PFTrajectoryPoint::isValid
bool isValid() const
is this point valid ?
Definition: PFTrajectoryPoint.h:84
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
reco::PFRecTrack
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
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
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
PFTrackProducer::vtx_h
edm::EDGetTokenT< reco::VertexCollection > vtx_h
Definition: PFTrackProducer.h:46
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
dummy
Definition: DummySelector.h:38
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PFTrackTransformer
Definition: PFTrackTransformer.h:34
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
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:51
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37