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;
14 LightPFTrackProducer::LightPFTrackProducer(const ParameterSet& iConfig) : pfTransformer_(nullptr) {
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 ------------
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 }
mps_fire.i
i
Definition: mps_fire.py:355
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
LightPFTrackProducer::trackQuality_
reco::TrackBase::TrackQuality trackQuality_
Definition: LightPFTrackProducer.h:33
LightPFTrackProducer::tracksContainers_
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
Definition: LightPFTrackProducer.h:30
reco::PFRecTrack::KF
Definition: PFRecTrack.h:27
PFTrackTransformer.h
edm::Handle< reco::TrackCollection >
LightPFTrackProducer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: LightPFTrackProducer.cc:61
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
edm::Ref< TrackCollection >
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
PFTrackTransformer::addPoints
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.
Definition: PFTrackTransformer.cc:40
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
LightPFTrackProducer::useQuality_
bool useQuality_
TRACK QUALITY.
Definition: LightPFTrackProducer.h:32
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
LightPFTrackProducer::pfTransformer_
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
Definition: LightPFTrackProducer.h:29
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LightPFTrackProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
Definition: LightPFTrackProducer.cc:28
edm::ParameterSet
Definition: ParameterSet.h:36
LightPFTrackProducer::LightPFTrackProducer
LightPFTrackProducer(const edm::ParameterSet &)
Constructor.
Definition: LightPFTrackProducer.cc:14
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
PFRecTrack.h
LightPFTrackProducer::~LightPFTrackProducer
~LightPFTrackProducer() override
Destructor.
Definition: LightPFTrackProducer.cc:26
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Trajectory.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
LightPFTrackProducer.h
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
reco::PFRecTrack
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
Trajectory
Definition: Trajectory.h:38
PFTrackTransformer::OnlyProp
void OnlyProp()
Definition: PFTrackTransformer.h:54
LightPFTrackProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: LightPFTrackProducer.cc:53
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
PFRecTrackFwd.h
PFTrackTransformer
Definition: PFTrackTransformer.h:34
edm::Event
Definition: Event.h:73
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14