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  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23 private:
24  void beginRun(const edm::Run&, const edm::EventSetup&) override;
25  void endRun(const edm::Run&, const edm::EventSetup&) override;
26 
28  void produce(edm::Event&, const edm::EventSetup&) override;
29 
32  std::vector<edm::EDGetTokenT<reco::VertexCompositeCandidateCollection>> V0list_;
33 
35 };
36 
39 
42  desc.add<std::vector<edm::InputTag>>(
43  "V0List", {edm::InputTag("generalV0Candidates", "Kshort"), edm::InputTag("generalV0Candidates", "Lambda")});
44  descriptions.add("pfV0", desc);
45 }
46 
47 using namespace std;
48 using namespace edm;
49 using namespace reco;
51  : pfTransformer_(nullptr), magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()) {
52  produces<reco::PFV0Collection>();
53  produces<reco::PFRecTrackCollection>();
54 
55  std::vector<edm::InputTag> tags = iConfig.getParameter<vector<InputTag>>("V0List");
56 
57  for (unsigned int i = 0; i < tags.size(); ++i)
58  V0list_.push_back(consumes<reco::VertexCompositeCandidateCollection>(tags[i]));
59 }
60 
62 
64  LogDebug("PFV0Producer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
65  //create the empty collections
66  auto pfV0Coll = std::make_unique<PFV0Collection>();
67 
68  auto pfV0RecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
69 
70  reco::PFRecTrackRefProd pfTrackRefProd = iEvent.getRefBeforePut<reco::PFRecTrackCollection>();
71  int idx = 0;
72 
73  for (unsigned int il = 0; il < V0list_.size(); il++) {
75  iEvent.getByToken(V0list_[il], V0coll);
76  LogDebug("PFV0Producer") << "V0list_[" << il << "] contains " << V0coll->size() << " V0 candidates ";
77  for (unsigned int iv = 0; iv < V0coll->size(); iv++) {
78  VertexCompositeCandidateRef V0(V0coll, iv);
79  vector<TrackRef> Tracks;
80  vector<PFRecTrackRef> PFTracks;
81  for (unsigned int ndx = 0; ndx < V0->numberOfDaughters(); ndx++) {
82  Tracks.push_back((dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track());
83  TrackRef trackRef = (dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track();
84 
85  reco::PFRecTrack pfRecTrack(trackRef->charge(), reco::PFRecTrack::KF, trackRef.key(), trackRef);
86 
87  Trajectory FakeTraj;
88  bool valid = pfTransformer_->addPoints(pfRecTrack, *trackRef, FakeTraj);
89  if (valid) {
90  PFTracks.push_back(reco::PFRecTrackRef(pfTrackRefProd, idx++));
91  pfV0RecTrackColl->push_back(pfRecTrack);
92  }
93  }
94  if ((PFTracks.size() == 2) && (Tracks.size() == 2)) {
95  pfV0Coll->push_back(PFV0(V0, PFTracks, Tracks));
96  }
97  }
98  }
99 
100  iEvent.put(std::move(pfV0Coll));
101  iEvent.put(std::move(pfV0RecTrackColl));
102 }
103 
104 // ------------ method called once each job just before starting event loop ------------
105 void PFV0Producer::beginRun(const edm::Run& run, const EventSetup& iSetup) {
106  auto const& magneticField = &iSetup.getData(magneticFieldToken_);
109 }
110 
111 // ------------ method called once each job just after ending the event loop ------------
112 void PFV0Producer::endRun(const edm::Run& run, const EventSetup& iSetup) {
113  delete pfTransformer_;
114  pfTransformer_ = nullptr;
115 }
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
PFV0Producer(const edm::ParameterSet &)
Constructor.
Definition: PFV0Producer.cc:50
void beginRun(const edm::Run &, const edm::EventSetup &) override
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
Definition: PFV0Producer.cc:63
key_type key() const
Accessor for product key.
Definition: Ref.h:244
std::vector< edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > > V0list_
Definition: PFV0Producer.cc:32
~PFV0Producer() override
Destructor.
Definition: PFV0Producer.cc:61
int iEvent
Definition: GenABIO.cc:224
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: PFV0Producer.cc:34
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFV0Producer.cc:40
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: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)
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)