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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 ( const edm::ParameterSet iConfig)
explicit

Constructor.

Definition at line 23 of file PFTrackProducer.cc.

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

23  :
25 {
26  produces<reco::PFRecTrackCollection>();
27 
28 
29  std::vector<InputTag> tags=iConfig.getParameter< vector < InputTag > >("TkColList");
30  trajinev_ = iConfig.getParameter<bool>("TrajInEvents");
31  tracksContainers_.reserve(tags.size());
32  if(trajinev_) { trajContainers_.reserve(tags.size()); }
33  for( auto const& tag: tags) {
34  tracksContainers_.push_back(consumes<reco::TrackCollection>(tag));
35  if(trajinev_) {
36  trajContainers_.push_back(consumes<std::vector<Trajectory> >(tag));
37  }
38  }
39 
40  useQuality_ = iConfig.getParameter<bool>("UseQuality");
41 
42  gsfinev_ = iConfig.getParameter<bool>("GsfTracksInEvents");
43  if(gsfinev_) {
44  gsfTrackLabel_ = consumes<reco::GsfTrackCollection>(iConfig.getParameter<InputTag>
45  ("GsfTrackModuleLabel"));
46  }
47 
49 
50  muonColl_ = consumes<reco::MuonCollection>(iConfig.getParameter< InputTag >("MuColl"));
51 
52 
53  vtx_h=consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("PrimaryVertexLabel"));
54 
55 }
T getParameter(std::string const &) const
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_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
reco::TrackBase::TrackQuality trackQuality_
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.

Member Function Documentation

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

Definition at line 227 of file PFTrackProducer.cc.

References edm::EventSetup::get(), MagneticField::inTesla(), seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, pfTransformer_, and trajinev_.

229 {
231  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
232  pfTransformer_.reset( new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0)))) );
233  if(!trajinev_)
234  pfTransformer_->OnlyProp();
235 }
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T get() const
Definition: EventSetup.h:63
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
void PFTrackProducer::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 239 of file PFTrackProducer.cc.

References pfTransformer_.

240  {
241  pfTransformer_.reset();
242 }
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
void PFTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Produce the PFRecTrack collection.

Definition at line 58 of file PFTrackProducer.cc.

References TransientTrackBuilder::build(), MillePedeFileConverter_cfg::e, reco::PFTrajectoryPoint::ECALEntrance, edm::EventSetup::get(), edm::Event::getByToken(), gsfinev_, gsfTrackLabel_, mps_fire::i, edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), reco::PFTrajectoryPoint::isValid(), reco::PFRecTrack::KF, reco::PFRecTrack::KF_ELCAND, eostools::move(), muonColl_, AlCaHLTBitMon_ParallelJobs::p, pfTransformer_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), MetAnalyzer::pv(), jets_cff::quality, edm::second(), SurveyInfoScenario_cff::seed, IPTools::signedTransverseImpactParameter(), trackQuality_, tracksContainers_, trajContainers_, trajinev_, useQuality_, and vtx_h.

59 {
60 
61  //create the empty collections
62  auto PfTrColl = std::make_unique<reco::PFRecTrackCollection>();
63 
64  //read track collection
65  Handle<GsfTrackCollection> gsftrackcoll;
66  bool foundgsf = false;
67  if(gsfinev_) {
68  foundgsf = iEvent.getByToken(gsfTrackLabel_,gsftrackcoll);
69  }
70 
71  //Get PV for STIP calculation, if there is none then take the dummy
73  iEvent.getByToken(vtx_h, vertex);
75  const reco::Vertex* pv=&dummy;
76  if (vertex.isValid())
77  {
78  pv = &*vertex->begin();
79  }
80  else
81  { // create a dummy PV
83  e(0, 0) = 0.0015 * 0.0015;
84  e(1, 1) = 0.0015 * 0.0015;
85  e(2, 2) = 15. * 15.;
86  reco::Vertex::Point p(0, 0, 0);
87  dummy = reco::Vertex(p, e, 0, 0, 0);
88  }
89 
91  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
92  TransientTrackBuilder thebuilder = *(builder.product());
93 
94  // read muon collection
96  iEvent.getByToken(muonColl_, recMuons);
97 
98  //default value for when trajinev_ is false
99  const vector<Trajectory> dummyTj(0);
100 
101  for (unsigned int istr=0; istr<tracksContainers_.size();istr++){
102 
103  //Track collection
104  Handle<reco::TrackCollection> tkRefCollection;
105  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
106  reco::TrackCollection Tk=*(tkRefCollection.product());
107 
108  //Use a pointer to aoid unnecessary copying of the collection
109  const vector<Trajectory>* Tj = &dummyTj;
110  if(trajinev_) {
111  //Trajectory collection
112  Handle<vector<Trajectory> > tjCollection;
113  iEvent.getByToken(trajContainers_[istr], tjCollection);
114 
115  Tj =tjCollection.product();
116  }
117 
118 
119  for(unsigned int i=0;i<Tk.size();i++){
120 
121  reco::TrackRef trackRef(tkRefCollection, i);
122 
123  if (useQuality_ &&
124  (!(Tk[i].quality(trackQuality_)))){
125 
126  bool isMuCandidate = false;
127 
128  //TrackRef trackRef(tkRefCollection, i);
129 
130  if(recMuons.isValid() ) {
131  for(unsigned j=0;j<recMuons->size(); j++) {
132  reco::MuonRef muonref( recMuons, j );
133  if (muonref->track().isNonnull())
134  if( muonref->track() == trackRef && muonref->isGlobalMuon()){
135  isMuCandidate=true;
136  //cout<<" SAVING TRACK "<<endl;
137  break;
138  }
139  }
140  }
141  if(!isMuCandidate)
142  {
143  continue;
144  }
145 
146  }
147 
148  // find the pre-id kf track
149  bool preId = false;
150  if(foundgsf) {
151  //NOTE: foundgsf is only true if gsftrackcoll is valid
152  for (auto const& gsfTrack: *gsftrackcoll) {
153  if (gsfTrack.seedRef().isNull()) continue;
154  auto const& seed = *(gsfTrack.extra()->seedRef());
155  auto const& ElSeed = dynamic_cast<ElectronSeed const&>(seed);
156  if (ElSeed.ctfTrack().isNonnull()) {
157  if(ElSeed.ctfTrack() == trackRef) {
158  preId = true;
159  break;
160  }
161  }
162  }
163  }
164  if(preId) {
165  // Set PFRecTrack of type KF_ElCAND
166  reco::PFRecTrack pftrack( trackRef->charge(),
168  i, trackRef );
169 
170  bool valid = false;
171  if(trajinev_) {
172  valid = pfTransformer_->addPoints( pftrack, *trackRef, (*Tj)[i]);
173  }
174  else {
175  Trajectory FakeTraj;
176  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
177  }
178  if(valid) {
179  //calculate STIP
180  double stip=-999;
181  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
182  if(atECAL.isValid()) //if track extrapolates to ECAL
183  {
184  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
185  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
186  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
187  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
188  }
189  pftrack.setSTIP(stip);
190  PfTrColl->push_back(pftrack);
191  }
192  }
193  else {
194  reco::PFRecTrack pftrack( trackRef->charge(),
196  i, trackRef );
197  bool valid = false;
198  if(trajinev_) {
199  valid = pfTransformer_->addPoints( pftrack, *trackRef, (*Tj)[i]);
200  }
201  else {
202  Trajectory FakeTraj;
203  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
204  }
205 
206  if(valid) {
207  double stip=-999;
208  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
209  if(atECAL.isValid())
210  {
211  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
212  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
213  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
214  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
215  }
216  pftrack.setSTIP(stip);
217  PfTrColl->push_back(pftrack);
218  }
219  }
220  }
221  }
222  iEvent.put(std::move(PfTrColl));
223 }
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
reco::TransientTrack build(const reco::Track *p) const
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
edm::EDGetTokenT< reco::VertexCollection > vtx_h
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
U second(std::pair< T, U > const &p)
bool useQuality_
TRACK QUALITY.
def pv(vc)
Definition: MetAnalyzer.py:6
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
edm::EDGetTokenT< reco::MuonCollection > muonColl_
bool isValid() const
Definition: HandleBase.h:74
bool isValid() const
is this point valid ?
T const * product() const
Definition: Handle.h:81
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
T get() const
Definition: EventSetup.h:63
reco::TrackBase::TrackQuality trackQuality_
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.

Member Data Documentation

bool PFTrackProducer::gsfinev_
private

Definition at line 52 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 45 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 46 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

PFTrackTransformer.

Definition at line 42 of file PFTrackProducer.h.

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

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

Definition at line 50 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 43 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 44 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

bool PFTrackProducer::trajinev_
private

Definition at line 51 of file PFTrackProducer.h.

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

bool PFTrackProducer::useQuality_
private

TRACK QUALITY.

Definition at line 49 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 47 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().