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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFTrackProducer (const edm::ParameterSet &)
 Constructor. More...
 
 ~PFTrackProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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
 
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::InputTag gsfTrackLabel_
 
edm::InputTag muonColl_
 
PFTrackTransformerpfTransformer_
 PFTrackTransformer. More...
 
reco::TrackBase::TrackQuality trackQuality_
 
std::vector< edm::InputTagtracksContainers_
 
bool trajinev_
 
bool useQuality_
 TRACK QUALITY. More...
 
edm::InputTag vtx_h
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
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 20 of file PFTrackProducer.h.

Constructor & Destructor Documentation

PFTrackProducer::PFTrackProducer ( const edm::ParameterSet iConfig)
explicit

Constructor.

Definition at line 27 of file PFTrackProducer.cc.

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

27  :
29 {
30  produces<reco::PFRecTrackCollection>();
31 
33  iConfig.getParameter< vector < InputTag > >("TkColList");
34 
35  useQuality_ = iConfig.getParameter<bool>("UseQuality");
36 
38  ("GsfTrackModuleLabel");
39 
41 
42  muonColl_ = iConfig.getParameter< InputTag >("MuColl");
43 
44  trajinev_ = iConfig.getParameter<bool>("TrajInEvents");
45 
46  gsfinev_ = iConfig.getParameter<bool>("GsfTracksInEvents");
47  vtx_h=iConfig.getParameter<edm::InputTag>("PrimaryVertexLabel");
48 }
T getParameter(std::string const &) const
edm::InputTag muonColl_
edm::InputTag vtx_h
std::vector< edm::InputTag > tracksContainers_
bool useQuality_
TRACK QUALITY.
edm::InputTag gsfTrackLabel_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
reco::TrackBase::TrackQuality trackQuality_
PFTrackProducer::~PFTrackProducer ( )

Destructor.

Definition at line 50 of file PFTrackProducer.cc.

References pfTransformer_.

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

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 235 of file PFTrackProducer.cc.

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

237 {
238  ESHandle<MagneticField> magneticField;
239  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
240  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
241  if(!trajinev_)
243 }
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::EDProducer.

Definition at line 247 of file PFTrackProducer.cc.

References pfTransformer_.

248  {
249  delete pfTransformer_;
250  pfTransformer_=nullptr;
251 }
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
void PFTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Produce the PFRecTrack collection.

Implements edm::EDProducer.

Definition at line 56 of file PFTrackProducer.cc.

References PFTrackTransformer::addPoints(), TransientTrackBuilder::build(), alignCSCRings::e, reco::PFTrajectoryPoint::ECALEntrance, newFWLiteAna::found, edm::EventSetup::get(), edm::Event::getByLabel(), 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(), edm::second(), IPTools::signedTransverseImpactParameter(), trackQuality_, tracksContainers_, trajinev_, useQuality_, TrackValidation_HighPurity_cff::valid, and vtx_h.

57 {
58 
59  //create the empty collections
60  auto_ptr< reco::PFRecTrackCollection >
61  PfTrColl (new reco::PFRecTrackCollection);
62 
63  //read track collection
64  Handle<GsfTrackCollection> gsftrackcoll;
65  bool foundgsf = iEvent.getByLabel(gsfTrackLabel_,gsftrackcoll);
66  GsfTrackCollection gsftracks;
67  //Get PV for STIP calculation, if there is none then take the dummy
69  iEvent.getByLabel(vtx_h, vertex);
70  reco::Vertex dummy;
71  const reco::Vertex* pv=&dummy;
72  if (vertex.isValid())
73  {
74  pv = &*vertex->begin();
75  }
76  else
77  { // create a dummy PV
79  e(0, 0) = 0.0015 * 0.0015;
80  e(1, 1) = 0.0015 * 0.0015;
81  e(2, 2) = 15. * 15.;
82  reco::Vertex::Point p(0, 0, 0);
83  dummy = reco::Vertex(p, e, 0, 0, 0);
84  }
85 
87  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
88  TransientTrackBuilder thebuilder = *(builder.product());
89 
90 
91  if(gsfinev_) {
92  if(!foundgsf )
93  LogError("PFTrackProducer")
94  <<" cannot get GsfTracks (probably in HI events): "
95  << " please set GsfTracksInEvents = False in RecoParticleFlow/PFTracking/python/pfTrack_cfi.py" << endl;
96  else
97  gsftracks = *(gsftrackcoll.product());
98  }
99 
100  // read muon collection
102  iEvent.getByLabel(muonColl_, recMuons);
103 
104 
105  for (unsigned int istr=0; istr<tracksContainers_.size();istr++){
106 
107  //Track collection
108  Handle<reco::TrackCollection> tkRefCollection;
109  iEvent.getByLabel(tracksContainers_[istr], tkRefCollection);
110  reco::TrackCollection Tk=*(tkRefCollection.product());
111 
112  vector<Trajectory> Tj(0);
113  if(trajinev_) {
114  //Trajectory collection
115  Handle<vector<Trajectory> > tjCollection;
116  bool found = iEvent.getByLabel(tracksContainers_[istr], tjCollection);
117  if(!found )
118  LogError("PFTrackProducer")
119  <<" cannot get Trajectories of: "
120  << tracksContainers_[istr]
121  << " please set TrajInEvents = False in RecoParticleFlow/PFTracking/python/pfTrack_cfi.py" << endl;
122 
123  Tj =*(tjCollection.product());
124  }
125 
126 
127  for(unsigned int i=0;i<Tk.size();i++){
128 
129  reco::TrackRef trackRef(tkRefCollection, i);
130 
131  if (useQuality_ &&
132  (!(Tk[i].quality(trackQuality_)))){
133 
134  bool isMuCandidate = false;
135 
136  //TrackRef trackRef(tkRefCollection, i);
137 
138  if(recMuons.isValid() ) {
139  for(unsigned j=0;j<recMuons->size(); j++) {
140  reco::MuonRef muonref( recMuons, j );
141  if (muonref->track().isNonnull())
142  if( muonref->track() == trackRef && muonref->isGlobalMuon()){
143  isMuCandidate=true;
144  //cout<<" SAVING TRACK "<<endl;
145  break;
146  }
147  }
148  }
149  else{
150  edm::LogError("MissingInput")<<"there is no valide:"<<muonColl_<<" to be used.";
151  }
152 
153  if(!isMuCandidate)
154  {
155  continue;
156  }
157 
158  }
159 
160  // find the pre-id kf track
161  bool preId = false;
162  if(foundgsf) {
163  for (unsigned int igsf=0; igsf<gsftracks.size();igsf++) {
164  GsfTrackRef gsfTrackRef(gsftrackcoll, igsf);
165  if (gsfTrackRef->seedRef().isNull()) continue;
166  ElectronSeedRef ElSeedRef= gsfTrackRef->extra()->seedRef().castTo<ElectronSeedRef>();
167  if (ElSeedRef->ctfTrack().isNonnull()) {
168  if(ElSeedRef->ctfTrack() == trackRef) preId = true;
169  }
170  }
171  }
172  if(preId) {
173  // Set PFRecTrack of type KF_ElCAND
174  reco::PFRecTrack pftrack( trackRef->charge(),
176  i, trackRef );
177 
178  bool valid = false;
179  if(trajinev_) {
180  valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]);
181  }
182  else {
183  Trajectory FakeTraj;
184  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
185  }
186  if(valid) {
187  //calculate STIP
188  double stip=-999;
189  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
190  if(atECAL.isValid()) //if track extrapolates to ECAL
191  {
192  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
193  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
194  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
195  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
196  }
197  pftrack.setSTIP(stip);
198  PfTrColl->push_back(pftrack);
199  }
200  }
201  else {
202  reco::PFRecTrack pftrack( trackRef->charge(),
204  i, trackRef );
205  bool valid = false;
206  if(trajinev_) {
207  valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]);
208  }
209  else {
210  Trajectory FakeTraj;
211  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
212  }
213 
214  if(valid) {
215  double stip=-999;
216  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
217  if(atECAL.isValid())
218  {
219  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
220  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
221  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
222  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
223  }
224  pftrack.setSTIP(stip);
225  PfTrColl->push_back(pftrack);
226  }
227  }
228  }
229  }
230  iEvent.put(PfTrColl);
231 }
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
int i
Definition: DBlmapReader.cc:9
edm::InputTag muonColl_
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.
edm::InputTag vtx_h
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
std::vector< edm::InputTag > 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
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::InputTag gsfTrackLabel_
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 46 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

edm::InputTag PFTrackProducer::gsfTrackLabel_
private

Definition at line 39 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

edm::InputTag PFTrackProducer::muonColl_
private

Definition at line 40 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

PFTrackTransformer* PFTrackProducer::pfTransformer_
private

PFTrackTransformer.

Definition at line 37 of file PFTrackProducer.h.

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

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

Definition at line 44 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

std::vector<edm::InputTag> PFTrackProducer::tracksContainers_
private

Definition at line 38 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

bool PFTrackProducer::trajinev_
private

Definition at line 45 of file PFTrackProducer.h.

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

bool PFTrackProducer::useQuality_
private

TRACK QUALITY.

Definition at line 43 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().

edm::InputTag PFTrackProducer::vtx_h
private

Definition at line 41 of file PFTrackProducer.h.

Referenced by PFTrackProducer(), and produce().