CMS 3D CMS Logo

LightPFTrackProducer.cc
Go to the documentation of this file.
1 #include <memory>
11 
12 using namespace std;
13 using namespace edm;
15  pfTransformer_(nullptr)
16 {
17  produces<reco::PFRecTrackCollection>();
18 
19 
20 
21  std::vector<InputTag> tags =
22  iConfig.getParameter< vector < InputTag > >("TkColList");
23 
24  for (unsigned int i=0;i<tags.size();++i)
25  tracksContainers_.push_back(consumes<reco::TrackCollection>(tags[i]));
26 
27  useQuality_ = iConfig.getParameter<bool>("UseQuality");
29 
30 }
31 
33 {
34  delete pfTransformer_;
35 }
36 
37 void
39 {
40 
41  //create the empty collections
42  auto PfTrColl = std::make_unique<reco::PFRecTrackCollection>();
43 
44  for (unsigned int istr=0; istr<tracksContainers_.size();istr++){
45 
46  //Track collection
47  Handle<reco::TrackCollection> tkRefCollection;
48  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
49  reco::TrackCollection Tk=*(tkRefCollection.product());
50  for(unsigned int i=0;i<Tk.size();i++){
51  if (useQuality_ &&
52  (!(Tk[i].quality(trackQuality_)))) continue;
53  reco::TrackRef trackRef(tkRefCollection, i);
54  reco::PFRecTrack pftrack( trackRef->charge(),
56  i, trackRef );
57  Trajectory FakeTraj;
58  bool mymsgwarning = false;
59  bool valid = pfTransformer_->addPoints( pftrack, *trackRef, FakeTraj, mymsgwarning);
60  if(valid)
61  PfTrColl->push_back(pftrack);
62 
63  }
64  }
65  iEvent.put(std::move(PfTrColl));
66 }
67 
68 // ------------ method called once each job just before starting event loop ------------
69 void
71  const EventSetup& iSetup)
72 {
74  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
77 }
78 
79 // ------------ method called once each job just after ending the event loop ------------
80 void
82  const EventSetup& iSetup) {
83  delete pfTransformer_;
84  pfTransformer_=nullptr;
85 }
T getParameter(std::string const &) const
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
LightPFTrackProducer(const edm::ParameterSet &)
Constructor.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
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.
#define nullptr
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
~LightPFTrackProducer() override
Destructor.
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
int iEvent
Definition: GenABIO.cc:224
bool useQuality_
TRACK QUALITY.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
void endRun(const edm::Run &, const edm::EventSetup &) override
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:134
T const * product() const
Definition: Handle.h:74
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void beginRun(const edm::Run &, const edm::EventSetup &) override
HLT enums.
T get() const
Definition: EventSetup.h:71
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
reco::TrackBase::TrackQuality trackQuality_
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45