CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFTrackProducer (const edm::ParameterSet &)
 Constructor. More...
 
 ~PFTrackProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginRun (const edm::Run &, const edm::EventSetup &) override
 
virtual void endRun (const edm::Run &, const edm::EventSetup &) override
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 Produce the PFRecTrack collection. More...
 

Private Attributes

bool gsfinev_
 
edm::EDGetTokenT
< reco::GsfTrackCollection
gsfTrackLabel_
 
edm::EDGetTokenT
< reco::MuonCollection
muonColl_
 
PFTrackTransformerpfTransformer_
 PFTrackTransformer. More...
 
reco::TrackBase::TrackQuality trackQuality_
 
std::vector< edm::EDGetTokenT
< reco::TrackCollection > > 
tracksContainers_
 
bool trajinev_
 
bool useQuality_
 TRACK QUALITY. More...
 
edm::EDGetTokenT
< reco::VertexCollection
vtx_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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 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_, i, muonColl_, reco::TrackBase::qualityByName(), AlCaHLTBitMon_QueryRunRegistry::string, o2o::tags, trackQuality_, tracksContainers_, trajinev_, useQuality_, and vtx_h.

23  :
25 {
26  produces<reco::PFRecTrackCollection>();
27 
28 
29  std::vector<InputTag> tags=iConfig.getParameter< vector < InputTag > >("TkColList");
30  for( unsigned int i=0;i<tags.size();++i)
31  tracksContainers_.push_back(consumes<reco::TrackCollection>(tags[i]));
32 
33  useQuality_ = iConfig.getParameter<bool>("UseQuality");
34 
35  gsfTrackLabel_ = consumes<reco::GsfTrackCollection>(iConfig.getParameter<InputTag>
36  ("GsfTrackModuleLabel"));
37 
39 
40  muonColl_ = consumes<reco::MuonCollection>(iConfig.getParameter< InputTag >("MuColl"));
41 
42  trajinev_ = iConfig.getParameter<bool>("TrajInEvents");
43 
44  gsfinev_ = iConfig.getParameter<bool>("GsfTracksInEvents");
45  vtx_h=consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("PrimaryVertexLabel"));
46 
47 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
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_
tuple tags
Definition: o2o.py:248
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
reco::TrackBase::TrackQuality trackQuality_
PFTrackProducer::~PFTrackProducer ( )

Destructor.

Definition at line 49 of file PFTrackProducer.cc.

References pfTransformer_.

50 {
51  delete pfTransformer_;
52 }
PFTrackTransformer * pfTransformer_
PFTrackTransformer.

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 221 of file PFTrackProducer.cc.

References edm::EventSetup::get(), PFTrackTransformer::OnlyProp(), pfTransformer_, and trajinev_.

223 {
224  ESHandle<MagneticField> magneticField;
225  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
226  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
227  if(!trajinev_)
229 }
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
const T & get() const
Definition: EventSetup.h:55
void PFTrackProducer::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 233 of file PFTrackProducer.cc.

References pfTransformer_.

234  {
235  delete pfTransformer_;
236  pfTransformer_=nullptr;
237 }
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
void PFTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Produce the PFRecTrack collection.

Implements edm::stream::EDProducerBase.

Definition at line 55 of file PFTrackProducer.cc.

References PFTrackTransformer::addPoints(), TransientTrackBuilder::build(), alignCSCRings::e, reco::PFTrajectoryPoint::ECALEntrance, edm::EventSetup::get(), edm::Event::getByToken(), gsfinev_, gsfTrackLabel_, i, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), edm::HandleBase::isValid(), reco::PFTrajectoryPoint::isValid(), j, reco::PFRecTrack::KF, reco::PFRecTrack::KF_ELCAND, muonColl_, AlCaHLTBitMon_ParallelJobs::p, pfTransformer_, edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), shift_rpc_layout::quality, edm::second(), IPTools::signedTransverseImpactParameter(), trackQuality_, tracksContainers_, trajinev_, useQuality_, TrackValidation_HighPurity_cff::valid, and vtx_h.

56 {
57 
58  //create the empty collections
59  auto_ptr< reco::PFRecTrackCollection >
60  PfTrColl (new reco::PFRecTrackCollection);
61 
62  //read track collection
63  Handle<GsfTrackCollection> gsftrackcoll;
64  bool foundgsf = iEvent.getByToken(gsfTrackLabel_,gsftrackcoll);
65  GsfTrackCollection gsftracks;
66  //Get PV for STIP calculation, if there is none then take the dummy
68  iEvent.getByToken(vtx_h, vertex);
69  reco::Vertex dummy;
70  const reco::Vertex* pv=&dummy;
71  if (vertex.isValid())
72  {
73  pv = &*vertex->begin();
74  }
75  else
76  { // create a dummy PV
78  e(0, 0) = 0.0015 * 0.0015;
79  e(1, 1) = 0.0015 * 0.0015;
80  e(2, 2) = 15. * 15.;
81  reco::Vertex::Point p(0, 0, 0);
82  dummy = reco::Vertex(p, e, 0, 0, 0);
83  }
84 
86  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
87  TransientTrackBuilder thebuilder = *(builder.product());
88 
89 
90  if(gsfinev_) {
91  if(foundgsf )
92  gsftracks = *(gsftrackcoll.product());
93  }
94 
95  // read muon collection
97  iEvent.getByToken(muonColl_, recMuons);
98 
99 
100  for (unsigned int istr=0; istr<tracksContainers_.size();istr++){
101 
102  //Track collection
103  Handle<reco::TrackCollection> tkRefCollection;
104  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
105  reco::TrackCollection Tk=*(tkRefCollection.product());
106 
107  vector<Trajectory> Tj(0);
108  if(trajinev_) {
109  //Trajectory collection
110  Handle<vector<Trajectory> > tjCollection;
111  iEvent.getByToken(tracksContainers_[istr], tjCollection);
112 
113  Tj =*(tjCollection.product());
114  }
115 
116 
117  for(unsigned int i=0;i<Tk.size();i++){
118 
119  reco::TrackRef trackRef(tkRefCollection, i);
120 
121  if (useQuality_ &&
122  (!(Tk[i].quality(trackQuality_)))){
123 
124  bool isMuCandidate = false;
125 
126  //TrackRef trackRef(tkRefCollection, i);
127 
128  if(recMuons.isValid() ) {
129  for(unsigned j=0;j<recMuons->size(); j++) {
130  reco::MuonRef muonref( recMuons, j );
131  if (muonref->track().isNonnull())
132  if( muonref->track() == trackRef && muonref->isGlobalMuon()){
133  isMuCandidate=true;
134  //cout<<" SAVING TRACK "<<endl;
135  break;
136  }
137  }
138  }
139  if(!isMuCandidate)
140  {
141  continue;
142  }
143 
144  }
145 
146  // find the pre-id kf track
147  bool preId = false;
148  if(foundgsf) {
149  for (unsigned int igsf=0; igsf<gsftracks.size();igsf++) {
150  GsfTrackRef gsfTrackRef(gsftrackcoll, igsf);
151  if (gsfTrackRef->seedRef().isNull()) continue;
152  ElectronSeedRef ElSeedRef= gsfTrackRef->extra()->seedRef().castTo<ElectronSeedRef>();
153  if (ElSeedRef->ctfTrack().isNonnull()) {
154  if(ElSeedRef->ctfTrack() == trackRef) preId = true;
155  }
156  }
157  }
158  if(preId) {
159  // Set PFRecTrack of type KF_ElCAND
160  reco::PFRecTrack pftrack( trackRef->charge(),
162  i, trackRef );
163 
164  bool valid = false;
165  if(trajinev_) {
166  valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]);
167  }
168  else {
169  Trajectory FakeTraj;
170  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
171  }
172  if(valid) {
173  //calculate STIP
174  double stip=-999;
175  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
176  if(atECAL.isValid()) //if track extrapolates to ECAL
177  {
178  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
179  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
180  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
181  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
182  }
183  pftrack.setSTIP(stip);
184  PfTrColl->push_back(pftrack);
185  }
186  }
187  else {
188  reco::PFRecTrack pftrack( trackRef->charge(),
190  i, trackRef );
191  bool valid = false;
192  if(trajinev_) {
193  valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]);
194  }
195  else {
196  Trajectory FakeTraj;
197  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
198  }
199 
200  if(valid) {
201  double stip=-999;
202  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
203  if(atECAL.isValid())
204  {
205  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
206  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
207  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
208  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
209  }
210  pftrack.setSTIP(stip);
211  PfTrColl->push_back(pftrack);
212  }
213  }
214  }
215  }
216  iEvent.put(PfTrColl);
217 }
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
bool addPoints(reco::PFRecTrack &pftrack, const reco::Track &track, const Trajectory &traj, bool msgwarning=true) const
Add points to a PFTrack. return false if a TSOS is invalid.
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
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 isNonnull() const
Checks for non-null.
Definition: Ref.h:250
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool useQuality_
TRACK QUALITY.
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
int j
Definition: DBlmapReader.cc:9
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
edm::EDGetTokenT< reco::MuonCollection > muonColl_
bool isValid() const
Definition: HandleBase.h:76
bool isValid() const
is this point valid ?
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
reco::TrackBase::TrackQuality trackQuality_
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9

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

PFTrackTransformer* PFTrackProducer::pfTransformer_
private

PFTrackTransformer.

Definition at line 43 of file PFTrackProducer.h.

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

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