CMS 3D CMS Logo

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

Abstract. More...

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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Abstract.

Author
Daniele Benedetti
Date
November 2010 PFTrackTransformer transforms all the tracks in the PFRecTracks. NOTE the PFRecTrack collection is transient.

Definition at line 28 of file PFTrackProducer.cc.

Constructor & Destructor Documentation

◆ PFTrackProducer()

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

Constructor.

Definition at line 63 of file PFTrackProducer.cc.

64  : transientTrackToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
65  magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()),
66  pfTransformer_() {
67  produces<reco::PFRecTrackCollection>();
68 
69  std::vector<InputTag> tags = iConfig.getParameter<vector<InputTag>>("TkColList");
70  trajinev_ = iConfig.getParameter<bool>("TrajInEvents");
71  tracksContainers_.reserve(tags.size());
72  if (trajinev_) {
73  trajContainers_.reserve(tags.size());
74  }
75  for (auto const& tag : tags) {
76  tracksContainers_.push_back(consumes<reco::TrackCollection>(tag));
77  if (trajinev_) {
78  trajContainers_.push_back(consumes<std::vector<Trajectory>>(tag));
79  }
80  }
81 
82  useQuality_ = iConfig.getParameter<bool>("UseQuality");
83 
84  gsfinev_ = iConfig.getParameter<bool>("GsfTracksInEvents");
85  if (gsfinev_) {
86  gsfTrackLabel_ = consumes<reco::GsfTrackCollection>(iConfig.getParameter<InputTag>("GsfTrackModuleLabel"));
87  }
88 
90 
91  muonColl_ = consumes<reco::MuonCollection>(iConfig.getParameter<InputTag>("MuColl"));
92 
93  vtx_h = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("PrimaryVertexLabel"));
94 }

References edm::BeginRun, edm::ParameterSet::getParameter(), gsfinev_, gsfTrackLabel_, muonColl_, reco::TrackBase::qualityByName(), AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::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 246 of file PFTrackProducer.cc.

246  {
247  auto const& magneticField = iSetup.getData(magneticFieldToken_);
248  pfTransformer_ = std::make_unique<PFTrackTransformer>(math::XYZVector(magneticField.inTesla(GlobalPoint(0, 0, 0))));
249  if (!trajinev_)
250  pfTransformer_->OnlyProp();
251 }

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 254 of file PFTrackProducer.cc.

254 { pfTransformer_.reset(); }

References pfTransformer_.

◆ produce()

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

Produce the PFRecTrack collection.

Definition at line 96 of file PFTrackProducer.cc.

96  {
97  //create the empty collections
98  auto PfTrColl = std::make_unique<reco::PFRecTrackCollection>();
99 
100  //read track collection
101  Handle<GsfTrackCollection> gsftrackcoll;
102  bool foundgsf = false;
103  if (gsfinev_) {
104  foundgsf = iEvent.getByToken(gsfTrackLabel_, gsftrackcoll);
105  }
106 
107  //Get PV for STIP calculation, if there is none then take the dummy
109  iEvent.getByToken(vtx_h, vertex);
111  const reco::Vertex* pv = &dummy;
112  if (vertex.isValid()) {
113  pv = &*vertex->begin();
114  } else { // create a dummy PV
116  e(0, 0) = 0.0015 * 0.0015;
117  e(1, 1) = 0.0015 * 0.0015;
118  e(2, 2) = 15. * 15.;
119  reco::Vertex::Point p(0, 0, 0);
120  dummy = reco::Vertex(p, e, 0, 0, 0);
121  }
122 
123  //setup transient track builder
124  TransientTrackBuilder const& thebuilder = iSetup.getData(transientTrackToken_);
125 
126  // read muon collection
128  iEvent.getByToken(muonColl_, recMuons);
129 
130  //default value for when trajinev_ is false
131  const vector<Trajectory> dummyTj(0);
132 
133  for (unsigned int istr = 0; istr < tracksContainers_.size(); istr++) {
134  //Track collection
135  Handle<reco::TrackCollection> tkRefCollection;
136  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
137  reco::TrackCollection Tk = *(tkRefCollection.product());
138 
139  //Use a pointer to aoid unnecessary copying of the collection
140  const vector<Trajectory>* Tj = &dummyTj;
141  if (trajinev_) {
142  //Trajectory collection
143  Handle<vector<Trajectory>> tjCollection;
144  iEvent.getByToken(trajContainers_[istr], tjCollection);
145 
146  Tj = tjCollection.product();
147  }
148 
149  for (unsigned int i = 0; i < Tk.size(); i++) {
150  reco::TrackRef trackRef(tkRefCollection, i);
151 
152  if (useQuality_ && (!(Tk[i].quality(trackQuality_)))) {
153  bool isMuCandidate = false;
154 
155  //TrackRef trackRef(tkRefCollection, i);
156 
157  if (recMuons.isValid()) {
158  for (unsigned j = 0; j < recMuons->size(); j++) {
159  reco::MuonRef muonref(recMuons, j);
160  if (muonref->track().isNonnull())
161  if (muonref->track() == trackRef && muonref->isGlobalMuon()) {
162  isMuCandidate = true;
163  //cout<<" SAVING TRACK "<<endl;
164  break;
165  }
166  }
167  }
168  if (!isMuCandidate) {
169  continue;
170  }
171  }
172 
173  // find the pre-id kf track
174  bool preId = false;
175  if (foundgsf) {
176  //NOTE: foundgsf is only true if gsftrackcoll is valid
177  for (auto const& gsfTrack : *gsftrackcoll) {
178  if (gsfTrack.seedRef().isNull())
179  continue;
180  auto const& seed = *(gsfTrack.extra()->seedRef());
181  auto const& ElSeed = dynamic_cast<ElectronSeed const&>(seed);
182  if (ElSeed.ctfTrack().isNonnull()) {
183  if (ElSeed.ctfTrack() == trackRef) {
184  preId = true;
185  break;
186  }
187  }
188  }
189  }
190  if (preId) {
191  // Set PFRecTrack of type KF_ElCAND
192  reco::PFRecTrack pftrack(trackRef->charge(), reco::PFRecTrack::KF_ELCAND, i, trackRef);
193 
194  bool valid = false;
195  if (trajinev_) {
196  valid = pfTransformer_->addPoints(pftrack, *trackRef, (*Tj)[i]);
197  } else {
198  Trajectory FakeTraj;
199  valid = pfTransformer_->addPoints(pftrack, *trackRef, FakeTraj);
200  }
201  if (valid) {
202  //calculate STIP
203  double stip = -999;
204  const reco::PFTrajectoryPoint& atECAL = pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
205  if (atECAL.isValid()) //if track extrapolates to ECAL
206  {
207  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
208  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
209  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
210  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv)
211  .second.significance();
212  }
213  pftrack.setSTIP(stip);
214  PfTrColl->push_back(pftrack);
215  }
216  } else {
217  reco::PFRecTrack pftrack(trackRef->charge(), reco::PFRecTrack::KF, i, trackRef);
218  bool valid = false;
219  if (trajinev_) {
220  valid = pfTransformer_->addPoints(pftrack, *trackRef, (*Tj)[i]);
221  } else {
222  Trajectory FakeTraj;
223  valid = pfTransformer_->addPoints(pftrack, *trackRef, FakeTraj);
224  }
225 
226  if (valid) {
227  double stip = -999;
228  const reco::PFTrajectoryPoint& atECAL = pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
229  if (atECAL.isValid()) {
230  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
231  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
232  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
233  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv)
234  .second.significance();
235  }
236  pftrack.setSTIP(stip);
237  PfTrColl->push_back(pftrack);
238  }
239  }
240  }
241  }
242  iEvent.put(std::move(PfTrColl));
243 }

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 54 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ gsfTrackLabel_

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

Definition at line 47 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ magneticFieldToken_

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

Definition at line 41 of file PFTrackProducer.cc.

Referenced by beginRun().

◆ muonColl_

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

Definition at line 48 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ pfTransformer_

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

PFTrackTransformer.

Definition at line 44 of file PFTrackProducer.cc.

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

◆ trackQuality_

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

Definition at line 52 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ tracksContainers_

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

Definition at line 45 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ trajContainers_

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

Definition at line 46 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ trajinev_

bool PFTrackProducer::trajinev_
private

Definition at line 53 of file PFTrackProducer.cc.

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

◆ transientTrackToken_

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

Definition at line 40 of file PFTrackProducer.cc.

Referenced by produce().

◆ useQuality_

bool PFTrackProducer::useQuality_
private

TRACK QUALITY.

Definition at line 51 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ vtx_h

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

Definition at line 49 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

Vector3DBase
Definition: Vector3DBase.h:8
PFTrackProducer::muonColl_
edm::EDGetTokenT< reco::MuonCollection > muonColl_
Definition: PFTrackProducer.cc:48
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.cc:44
PFTrackProducer::gsfTrackLabel_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
Definition: PFTrackProducer.cc:47
PFTrackProducer::transientTrackToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackToken_
Definition: PFTrackProducer.cc:40
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
PFTrackProducer::tracksContainers_
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
Definition: PFTrackProducer.cc:45
PFTrackProducer::trajinev_
bool trajinev_
Definition: PFTrackProducer.cc:53
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:122
fileCollector.seed
seed
Definition: fileCollector.py:127
PFTrackProducer::trajContainers_
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
Definition: PFTrackProducer.cc:46
Point3DBase< float, GlobalTag >
reco::PFRecTrack::KF_ELCAND
Definition: PFRecTrack.h:27
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
PFTrackProducer::useQuality_
bool useQuality_
TRACK QUALITY.
Definition: PFTrackProducer.cc:51
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
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.cc:52
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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.cc:41
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.cc:49
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.cc:54
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37