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::ProductRegistryHelper

Public Member Functions

 PFTrackProducer (const edm::ParameterSet &)
 Constructor. More...
 
 ~PFTrackProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginRun (edm::Run &, const edm::EventSetup &)
 
virtual void endRun ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 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
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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(), 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 
40  trackQuality_=reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
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 ( edm::Run run,
const edm::EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 232 of file PFTrackProducer.cc.

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

234 {
235  ESHandle<MagneticField> magneticField;
236  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
237  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
238  if(!trajinev_)
240 }
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
const T & get() const
Definition: EventSetup.h:55
void PFTrackProducer::endRun ( void  )
privatevirtual

Definition at line 244 of file PFTrackProducer.cc.

References pfTransformer_.

244  {
245  delete pfTransformer_;
246 }
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
void PFTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Produce the PFRecTrack collection.

Implements edm::EDProducer.

Definition at line 56 of file PFTrackProducer.cc.

References PFTrackTransformer::addPoints(), TransientTrackBuilder::build(), 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_, L1TEmulatorMonitor_cff::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 
150  if(!isMuCandidate)
151  {
152  continue;
153  }
154 
155  }
156 
157  // find the pre-id kf track
158  bool preId = false;
159  if(foundgsf) {
160  for (unsigned int igsf=0; igsf<gsftracks.size();igsf++) {
161  GsfTrackRef gsfTrackRef(gsftrackcoll, igsf);
162  if (gsfTrackRef->seedRef().isNull()) continue;
163  ElectronSeedRef ElSeedRef= gsfTrackRef->extra()->seedRef().castTo<ElectronSeedRef>();
164  if (ElSeedRef->ctfTrack().isNonnull()) {
165  if(ElSeedRef->ctfTrack() == trackRef) preId = true;
166  }
167  }
168  }
169  if(preId) {
170  // Set PFRecTrack of type KF_ElCAND
171  reco::PFRecTrack pftrack( trackRef->charge(),
173  i, trackRef );
174 
175  bool valid = false;
176  if(trajinev_) {
177  valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]);
178  }
179  else {
180  Trajectory FakeTraj;
181  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
182  }
183  if(valid) {
184  //calculate STIP
185  double stip=-999;
186  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
187  if(atECAL.isValid()) //if track extrapolates to ECAL
188  {
189  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
190  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
191  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
192  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
193  }
194  pftrack.setSTIP(stip);
195  PfTrColl->push_back(pftrack);
196  }
197  }
198  else {
199  reco::PFRecTrack pftrack( trackRef->charge(),
201  i, trackRef );
202  bool valid = false;
203  if(trajinev_) {
204  valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i]);
205  }
206  else {
207  Trajectory FakeTraj;
208  valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj);
209  }
210 
211  if(valid) {
212  double stip=-999;
213  const reco::PFTrajectoryPoint& atECAL=pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance);
214  if(atECAL.isValid())
215  {
216  GlobalVector direction(pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().x(),
217  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().y(),
218  pftrack.extrapolatedPoint(reco::PFTrajectoryPoint::ECALEntrance).position().z());
219  stip = IPTools::signedTransverseImpactParameter(thebuilder.build(*trackRef), direction, *pv).second.significance();
220  }
221  pftrack.setSTIP(stip);
222  PfTrColl->push_back(pftrack);
223  }
224  }
225  }
226  }
227  iEvent.put(PfTrColl);
228 }
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
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:44
std::vector< edm::InputTag > tracksContainers_
U second(std::pair< T, U > const &p)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:249
bool addPoints(reco::PFRecTrack &pftrack, const reco::Track &track, const Trajectory &traj) const
Add points to a PFTrack. return false if a TSOS is invalid.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
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:40
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
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:74
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().