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...
 
- 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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_
 
std::unique_ptr
< PFTrackTransformer
pfTransformer_
 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::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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 29 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::EDConsumerBase::consumes(), edm::ParameterSet::getParameter(), gsfinev_, gsfTrackLabel_, muonColl_, reco::TrackBase::qualityByName(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, o2o::tags, 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_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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: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 
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 228 of file PFTrackProducer.cc.

References edm::EventSetup::get(), HLT_FULL_cff::magneticField, pfTransformer_, and trajinev_.

230 {
232  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
233  pfTransformer_.reset( new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0)))) );
234  if(!trajinev_)
235  pfTransformer_->OnlyProp();
236 }
tuple magneticField
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
const T & get() const
Definition: EventSetup.h:56
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
void PFTrackProducer::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 240 of file PFTrackProducer.cc.

References pfTransformer_.

241  {
242  pfTransformer_.reset();
243 }
std::unique_ptr< 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 58 of file PFTrackProducer.cc.

References TransientTrackBuilder::build(), compareJSON::const, alignCSCRings::e, reco::PFTrajectoryPoint::ECALEntrance, edm::EventSetup::get(), edm::Event::getByToken(), gsfinev_, gsfTrackLabel_, i, edm::Ref< C, T, F >::isNonnull(), 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(), MetAnalyzer::pv(), HLT_FULL_cff::quality, edm::second(), fileCollector::seed, IPTools::signedTransverseImpactParameter(), trackQuality_, tracksContainers_, trajContainers_, trajinev_, useQuality_, and vtx_h.

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

Member Data Documentation

bool PFTrackProducer::gsfinev_
private

Definition at line 53 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 46 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 47 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

PFTrackTransformer.

Definition at line 43 of file PFTrackProducer.h.

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

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

Definition at line 51 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().

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

Definition at line 45 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

bool PFTrackProducer::trajinev_
private

Definition at line 52 of file PFTrackProducer.h.

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

bool PFTrackProducer::useQuality_
private

TRACK QUALITY.

Definition at line 50 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

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

Definition at line 48 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().