CMS 3D CMS Logo

List of all members | Public Member Functions | Static 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
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

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 78 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.

79  : transientTrackToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
80  magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()),
81  pfTransformer_() {
82  produces<reco::PFRecTrackCollection>();
83 
84  std::vector<InputTag> tags = iConfig.getParameter<vector<InputTag>>("TkColList");
85  trajinev_ = iConfig.getParameter<bool>("TrajInEvents");
86  tracksContainers_.reserve(tags.size());
87  if (trajinev_) {
88  trajContainers_.reserve(tags.size());
89  }
90  for (auto const& tag : tags) {
91  tracksContainers_.push_back(consumes<reco::TrackCollection>(tag));
92  if (trajinev_) {
93  trajContainers_.push_back(consumes<std::vector<Trajectory>>(tag));
94  }
95  }
96 
97  useQuality_ = iConfig.getParameter<bool>("UseQuality");
98 
99  gsfinev_ = iConfig.getParameter<bool>("GsfTracksInEvents");
100  if (gsfinev_) {
101  gsfTrackLabel_ = consumes<reco::GsfTrackCollection>(iConfig.getParameter<InputTag>("GsfTrackModuleLabel"));
102  }
103 
105 
106  muonColl_ = consumes<reco::MuonCollection>(iConfig.getParameter<InputTag>("MuColl"));
107 
108  vtx_h = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("PrimaryVertexLabel"));
109 }
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 261 of file PFTrackProducer.cc.

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

261  {
262  auto const& magneticField = iSetup.getData(magneticFieldToken_);
263  pfTransformer_ = std::make_unique<PFTrackTransformer>(math::XYZVector(magneticField.inTesla(GlobalPoint(0, 0, 0))));
264  if (!trajinev_)
265  pfTransformer_->OnlyProp();
266 }
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 269 of file PFTrackProducer.cc.

References pfTransformer_.

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

◆ fillDescriptions()

void PFTrackProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 62 of file PFTrackProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

62  {
64  desc.add<std::string>("TrackQuality", "highPurity");
65  desc.add<bool>("UseQuality", true);
66  desc.add<edm::InputTag>("GsfTrackModuleLabel", {"electronGsfTracks"});
67  desc.add<std::vector<edm::InputTag>>("TkColList", {edm::InputTag("generalTracks")});
68  desc.add<edm::InputTag>("PrimaryVertexLabel", {"offlinePrimaryVertices"});
69  desc.add<edm::InputTag>("MuColl", {"muons1stStep"});
70  desc.add<bool>("TrajInEvents", false);
71  desc.add<bool>("GsfTracksInEvents", true);
72  descriptions.add("pfTrack", desc);
73 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Produce the PFRecTrack collection.

Definition at line 111 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.

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

Referenced by PFTrackProducer(), and produce().

◆ gsfTrackLabel_

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

Definition at line 49 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ magneticFieldToken_

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

Definition at line 43 of file PFTrackProducer.cc.

Referenced by beginRun().

◆ muonColl_

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

Definition at line 50 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ pfTransformer_

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

PFTrackTransformer.

Definition at line 46 of file PFTrackProducer.cc.

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

◆ trackQuality_

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

Definition at line 54 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ tracksContainers_

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

Definition at line 47 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ trajContainers_

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

Definition at line 48 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ trajinev_

bool PFTrackProducer::trajinev_
private

Definition at line 55 of file PFTrackProducer.cc.

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

◆ transientTrackToken_

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

Definition at line 42 of file PFTrackProducer.cc.

Referenced by produce().

◆ useQuality_

bool PFTrackProducer::useQuality_
private

TRACK QUALITY.

Definition at line 53 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().

◆ vtx_h

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

Definition at line 51 of file PFTrackProducer.cc.

Referenced by PFTrackProducer(), and produce().