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.

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.

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 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackToken_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
edm::EDGetTokenT< reco::VertexCollection > vtx_h
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
bool useQuality_
TRACK QUALITY.
edm::EDGetTokenT< reco::MuonCollection > muonColl_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
reco::TrackBase::TrackQuality trackQuality_
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.

Member Function Documentation

◆ beginRun()

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

Definition at line 246 of file PFTrackProducer.cc.

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

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 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.

◆ endRun()

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

Definition at line 254 of file PFTrackProducer.cc.

References pfTransformer_.

254 { pfTransformer_.reset(); }
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.

◆ produce()

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

Produce the PFRecTrack collection.

Definition at line 96 of file PFTrackProducer.cc.

References TransientTrackBuilder::build(), runTheMatrix::const, 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_, validateGeometry_cfg::valid, bphysicsOniaDQM_cfi::vertex, HltBtagValidation_cff::Vertex, and vtx_h.

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 }
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:20
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackToken_
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:57
T const * product() const
Definition: Handle.h:70
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:45
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
edm::EDGetTokenT< reco::VertexCollection > vtx_h
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
reco::TransientTrack build(const reco::Track *p) const
U second(std::pair< T, U > const &p)
string quality
bool isValid() const
is this point valid ?
int iEvent
Definition: GenABIO.cc:224
bool useQuality_
TRACK QUALITY.
def pv(vc)
Definition: MetAnalyzer.py:7
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
edm::EDGetTokenT< reco::MuonCollection > muonColl_
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
bool isValid() const
Definition: HandleBase.h:70
reco::TrackBase::TrackQuality trackQuality_
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.

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().