CMS 3D CMS Logo

PFV0Producer.cc
Go to the documentation of this file.
12 
14 public:
16  explicit PFV0Producer(const edm::ParameterSet&);
17 
19  ~PFV0Producer() override;
20 
21 private:
22  void beginRun(const edm::Run&, const edm::EventSetup&) override;
23  void endRun(const edm::Run&, const edm::EventSetup&) override;
24 
26  void produce(edm::Event&, const edm::EventSetup&) override;
27 
30  std::vector<edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> > V0list_;
31 
33 };
34 
37 
38 using namespace std;
39 using namespace edm;
40 using namespace reco;
42  : pfTransformer_(nullptr), magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()) {
43  produces<reco::PFV0Collection>();
44  produces<reco::PFRecTrackCollection>();
45 
46  std::vector<edm::InputTag> tags = iConfig.getParameter<vector<InputTag> >("V0List");
47 
48  for (unsigned int i = 0; i < tags.size(); ++i)
49  V0list_.push_back(consumes<reco::VertexCompositeCandidateCollection>(tags[i]));
50 }
51 
53 
55  LogDebug("PFV0Producer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
56  //create the empty collections
57  auto pfV0Coll = std::make_unique<PFV0Collection>();
58 
59  auto pfV0RecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
60 
61  reco::PFRecTrackRefProd pfTrackRefProd = iEvent.getRefBeforePut<reco::PFRecTrackCollection>();
62  int idx = 0;
63 
64  for (unsigned int il = 0; il < V0list_.size(); il++) {
66  iEvent.getByToken(V0list_[il], V0coll);
67  LogDebug("PFV0Producer") << "V0list_[" << il << "] contains " << V0coll->size() << " V0 candidates ";
68  for (unsigned int iv = 0; iv < V0coll->size(); iv++) {
69  VertexCompositeCandidateRef V0(V0coll, iv);
70  vector<TrackRef> Tracks;
71  vector<PFRecTrackRef> PFTracks;
72  for (unsigned int ndx = 0; ndx < V0->numberOfDaughters(); ndx++) {
73  Tracks.push_back((dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track());
74  TrackRef trackRef = (dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track();
75 
76  reco::PFRecTrack pfRecTrack(trackRef->charge(), reco::PFRecTrack::KF, trackRef.key(), trackRef);
77 
78  Trajectory FakeTraj;
79  bool valid = pfTransformer_->addPoints(pfRecTrack, *trackRef, FakeTraj);
80  if (valid) {
81  PFTracks.push_back(reco::PFRecTrackRef(pfTrackRefProd, idx++));
82  pfV0RecTrackColl->push_back(pfRecTrack);
83  }
84  }
85  if ((PFTracks.size() == 2) && (Tracks.size() == 2)) {
86  pfV0Coll->push_back(PFV0(V0, PFTracks, Tracks));
87  }
88  }
89  }
90 
91  iEvent.put(std::move(pfV0Coll));
92  iEvent.put(std::move(pfV0RecTrackColl));
93 }
94 
95 // ------------ method called once each job just before starting event loop ------------
96 void PFV0Producer::beginRun(const edm::Run& run, const EventSetup& iSetup) {
97  auto const& magneticField = &iSetup.getData(magneticFieldToken_);
100 }
101 
102 // ------------ method called once each job just after ending the event loop ------------
103 void PFV0Producer::endRun(const edm::Run& run, const EventSetup& iSetup) {
104  delete pfTransformer_;
105  pfTransformer_ = nullptr;
106 }
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
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
int32_t *__restrict__ iv
PFV0Producer(const edm::ParameterSet &)
Constructor.
Definition: PFV0Producer.cc:41
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: PFV0Producer.cc:96
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
Definition: PFV0Producer.cc:54
key_type key() const
Accessor for product key.
Definition: Ref.h:250
std::vector< edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > > V0list_
Definition: PFV0Producer.cc:30
~PFV0Producer() override
Destructor.
Definition: PFV0Producer.cc:52
int iEvent
Definition: GenABIO.cc:224
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: PFV0Producer.cc:32
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
Definition: PFV0Producer.cc:29
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.
fixed size matrix
HLT enums.
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
def move(src, dest)
Definition: eostools.py:511
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: Run.h:45
#define LogDebug(id)