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  produces<reco::PFRecTrackCollection>();
16 
17  std::vector<InputTag> tags = iConfig.getParameter<vector<InputTag> >("TkColList");
18 
19  for (unsigned int i = 0; i < tags.size(); ++i)
20  tracksContainers_.push_back(consumes<reco::TrackCollection>(tags[i]));
21 
22  useQuality_ = iConfig.getParameter<bool>("UseQuality");
24 }
25 
27 
29  //create the empty collections
30  auto PfTrColl = std::make_unique<reco::PFRecTrackCollection>();
31 
32  for (unsigned int istr = 0; istr < tracksContainers_.size(); istr++) {
33  //Track collection
34  Handle<reco::TrackCollection> tkRefCollection;
35  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
36  reco::TrackCollection Tk = *(tkRefCollection.product());
37  for (unsigned int i = 0; i < Tk.size(); i++) {
38  if (useQuality_ && (!(Tk[i].quality(trackQuality_))))
39  continue;
40  reco::TrackRef trackRef(tkRefCollection, i);
41  reco::PFRecTrack pftrack(trackRef->charge(), reco::PFRecTrack::KF, i, trackRef);
42  Trajectory FakeTraj;
43  bool mymsgwarning = false;
44  bool valid = pfTransformer_->addPoints(pftrack, *trackRef, FakeTraj, mymsgwarning);
45  if (valid)
46  PfTrColl->push_back(pftrack);
47  }
48  }
49  iEvent.put(std::move(PfTrColl));
50 }
51 
52 // ------------ method called once each job just before starting event loop ------------
55  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
56  pfTransformer_ = new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0, 0, 0))));
58 }
59 
60 // ------------ method called once each job just after ending the event loop ------------
61 void LightPFTrackProducer::endRun(const edm::Run& run, const EventSetup& iSetup) {
62  delete pfTransformer_;
63  pfTransformer_ = nullptr;
64 }
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:131
LightPFTrackProducer(const edm::ParameterSet &)
Constructor.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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:14
~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:126
T const * product() const
Definition: Handle.h:69
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
void beginRun(const edm::Run &, const edm::EventSetup &) override
HLT enums.
T get() const
Definition: EventSetup.h:73
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
reco::TrackBase::TrackQuality trackQuality_
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45