CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LightPFTrackProducer.cc
Go to the documentation of this file.
1 #include <memory>
12 
13 using namespace std;
14 using namespace edm;
16  pfTransformer_(0)
17 {
18  produces<reco::PFRecTrackCollection>();
19 
21  iConfig.getParameter< vector < InputTag > >("TkColList");
22 
23 
24  useQuality_ = iConfig.getParameter<bool>("UseQuality");
25  trackQuality_=reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
26 
27 }
28 
30 {
31  delete pfTransformer_;
32 }
33 
34 void
36 {
37 
38  //create the empty collections
39  auto_ptr< reco::PFRecTrackCollection >
40  PfTrColl (new reco::PFRecTrackCollection);
41 
42  for (unsigned int istr=0; istr<tracksContainers_.size();istr++){
43 
44  //Track collection
45  Handle<reco::TrackCollection> tkRefCollection;
46  iEvent.getByLabel(tracksContainers_[istr], tkRefCollection);
47  reco::TrackCollection Tk=*(tkRefCollection.product());
48  for(unsigned int i=0;i<Tk.size();i++){
49  if (useQuality_ &&
50  (!(Tk[i].quality(trackQuality_)))) continue;
51  reco::TrackRef trackRef(tkRefCollection, i);
52  reco::PFRecTrack pftrack( trackRef->charge(),
54  i, trackRef );
55  Trajectory FakeTraj;
56  bool mymsgwarning = false;
57  bool valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj, mymsgwarning);
58  if(valid)
59  PfTrColl->push_back(pftrack);
60 
61  }
62  }
63  iEvent.put(PfTrColl);
64 }
65 
66 // ------------ method called once each job just before starting event loop ------------
67 void
69  const EventSetup& iSetup)
70 {
71  ESHandle<MagneticField> magneticField;
72  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
73  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
75 }
76 
77 // ------------ method called once each job just after ending the event loop ------------
78 void
80  delete pfTransformer_;
81 }
T getParameter(std::string const &) const
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
int i
Definition: DBlmapReader.cc:9
LightPFTrackProducer(const edm::ParameterSet &)
Constructor.
virtual void produce(edm::Event &, const edm::EventSetup &)
Produce the PFRecTrack collection.
virtual void beginRun(edm::Run &, const edm::EventSetup &)
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
~LightPFTrackProducer()
Destructor.
std::vector< edm::InputTag > tracksContainers_
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
int iEvent
Definition: GenABIO.cc:243
bool useQuality_
TRACK QUALITY.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
reco::TrackBase::TrackQuality trackQuality_
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
Definition: Run.h:33