CMS 3D CMS Logo

PFV0Producer.cc
Go to the documentation of this file.
1 #include <memory>
11 
12 using namespace std;
13 using namespace edm;
14 using namespace reco;
15 PFV0Producer::PFV0Producer(const ParameterSet& iConfig) : pfTransformer_(nullptr) {
16  produces<reco::PFV0Collection>();
17  produces<reco::PFRecTrackCollection>();
18 
19  std::vector<edm::InputTag> tags = iConfig.getParameter<vector<InputTag> >("V0List");
20 
21  for (unsigned int i = 0; i < tags.size(); ++i)
22  V0list_.push_back(consumes<reco::VertexCompositeCandidateCollection>(tags[i]));
23 }
24 
26 
28  LogDebug("PFV0Producer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
29  //create the empty collections
30  auto pfV0Coll = std::make_unique<PFV0Collection>();
31 
32  auto pfV0RecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
33 
34  reco::PFRecTrackRefProd pfTrackRefProd = iEvent.getRefBeforePut<reco::PFRecTrackCollection>();
35  int idx = 0;
36 
37  for (unsigned int il = 0; il < V0list_.size(); il++) {
39  iEvent.getByToken(V0list_[il], V0coll);
40  LogDebug("PFV0Producer") << "V0list_[" << il << "] contains " << V0coll->size() << " V0 candidates ";
41  for (unsigned int iv = 0; iv < V0coll->size(); iv++) {
42  VertexCompositeCandidateRef V0(V0coll, iv);
43  vector<TrackRef> Tracks;
44  vector<PFRecTrackRef> PFTracks;
45  for (unsigned int ndx = 0; ndx < V0->numberOfDaughters(); ndx++) {
46  Tracks.push_back((dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track());
47  TrackRef trackRef = (dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track();
48 
49  reco::PFRecTrack pfRecTrack(trackRef->charge(), reco::PFRecTrack::KF, trackRef.key(), trackRef);
50 
51  Trajectory FakeTraj;
52  bool valid = pfTransformer_->addPoints(pfRecTrack, *trackRef, FakeTraj);
53  if (valid) {
54  PFTracks.push_back(reco::PFRecTrackRef(pfTrackRefProd, idx++));
55  pfV0RecTrackColl->push_back(pfRecTrack);
56  }
57  }
58  if ((PFTracks.size() == 2) && (Tracks.size() == 2)) {
59  pfV0Coll->push_back(PFV0(V0, PFTracks, Tracks));
60  }
61  }
62  }
63 
64  iEvent.put(std::move(pfV0Coll));
65  iEvent.put(std::move(pfV0RecTrackColl));
66 }
67 
68 // ------------ method called once each job just before starting event loop ------------
69 void PFV0Producer::beginRun(const edm::Run& run, const EventSetup& iSetup) {
74 }
75 
76 // ------------ method called once each job just after ending the event loop ------------
77 void PFV0Producer::endRun(const edm::Run& run, const EventSetup& iSetup) {
78  delete pfTransformer_;
79  pfTransformer_ = nullptr;
80 }
edm::RefProd
Definition: EDProductfwd.h:25
mps_fire.i
i
Definition: mps_fire.py:355
PFV0Producer.h
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
charmTagsComputerCvsB_cfi.idx
idx
Definition: charmTagsComputerCvsB_cfi.py:108
reco::PFRecTrack::KF
Definition: PFRecTrack.h:27
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PFTrackTransformer.h
edm::Handle
Definition: AssociativeIterator.h:50
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
edm::Ref< VertexCompositeCandidateCollection >
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
PFV0Producer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: PFV0Producer.cc:69
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
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
Point3DBase< float, GlobalTag >
PFV0Producer::pfTransformer_
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
Definition: PFV0Producer.h:29
pfTrackElec_cfi.PFV0
PFV0
Definition: pfTrackElec_cfi.py:27
PFV0Producer::PFV0Producer
PFV0Producer(const edm::ParameterSet &)
Constructor.
Definition: PFV0Producer.cc:15
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
PFV0Producer::~PFV0Producer
~PFV0Producer() override
Destructor.
Definition: PFV0Producer.cc:25
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
gather_cfg.Tracks
Tracks
Definition: gather_cfg.py:251
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
PFV0.h
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
PFV0Producer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: PFV0Producer.cc:77
RecoChargedCandidate.h
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
PFV0Producer::V0list_
std::vector< edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > > V0list_
Definition: PFV0Producer.h:30
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
PFRecTrackFwd.h
PFV0Producer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
Definition: PFV0Producer.cc:27
reco::PFRecTrackCollection
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
PFTrackTransformer
Definition: PFTrackTransformer.h:34
edm::Event
Definition: Event.h:73