CMS 3D CMS Logo

LightPFTrackProducer.cc
Go to the documentation of this file.
11 
13 public:
15  explicit LightPFTrackProducer(const edm::ParameterSet&);
16 
18  ~LightPFTrackProducer() override;
19 
20  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
21 
22 private:
23  void beginRun(const edm::Run&, const edm::EventSetup&) override;
24  void endRun(const edm::Run&, const edm::EventSetup&) override;
25 
27  void produce(edm::Event&, const edm::EventSetup&) override;
28 
31  std::vector<edm::EDGetTokenT<reco::TrackCollection>> tracksContainers_;
32 
37 };
38 
41 
44  desc.add<std::string>("TrackQuality", "highPurity");
45  desc.add<bool>("UseQuality", true);
46  desc.add<std::vector<edm::InputTag>>(
47  "TkColList", {edm::InputTag("generalTracks"), edm::InputTag("secStep"), edm::InputTag("thStep")});
48  descriptions.add("lightpftrack", desc);
49 }
50 
51 using namespace std;
52 using namespace edm;
54  : pfTransformer_(nullptr), magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()) {
55  produces<reco::PFRecTrackCollection>();
56 
57  std::vector<InputTag> tags = iConfig.getParameter<vector<InputTag>>("TkColList");
58 
59  for (unsigned int i = 0; i < tags.size(); ++i)
60  tracksContainers_.push_back(consumes<reco::TrackCollection>(tags[i]));
61 
62  useQuality_ = iConfig.getParameter<bool>("UseQuality");
64 }
65 
67 
69  //create the empty collections
70  auto PfTrColl = std::make_unique<reco::PFRecTrackCollection>();
71 
72  for (unsigned int istr = 0; istr < tracksContainers_.size(); istr++) {
73  //Track collection
74  Handle<reco::TrackCollection> tkRefCollection;
75  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
76  reco::TrackCollection Tk = *(tkRefCollection.product());
77  for (unsigned int i = 0; i < Tk.size(); i++) {
78  if (useQuality_ && (!(Tk[i].quality(trackQuality_))))
79  continue;
80  reco::TrackRef trackRef(tkRefCollection, i);
81  reco::PFRecTrack pftrack(trackRef->charge(), reco::PFRecTrack::KF, i, trackRef);
82  Trajectory FakeTraj;
83  bool mymsgwarning = false;
84  bool valid = pfTransformer_->addPoints(pftrack, *trackRef, FakeTraj, mymsgwarning);
85  if (valid)
86  PfTrColl->push_back(pftrack);
87  }
88  }
89  iEvent.put(std::move(PfTrColl));
90 }
91 
92 // ------------ method called once each job just before starting event loop ------------
94  auto const& magneticField = &iSetup.getData(magneticFieldToken_);
97 }
98 
99 // ------------ method called once each job just after ending the event loop ------------
101  delete pfTransformer_;
102  pfTransformer_ = nullptr;
103 }
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:20
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
LightPFTrackProducer(const edm::ParameterSet &)
Constructor.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
TrackQuality
track quality
Definition: TrackBase.h:150
T const * product() const
Definition: Handle.h:70
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.
string quality
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
int iEvent
Definition: GenABIO.cc:224
bool useQuality_
TRACK QUALITY.
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void endRun(const edm::Run &, const edm::EventSetup &) override
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
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.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(const edm::Run &, const edm::EventSetup &) override
HLT enums.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
reco::TrackBase::TrackQuality trackQuality_
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45