CMS 3D CMS Logo

PFV0Producer.cc
Go to the documentation of this file.
1 #include <memory>
9 
10 using namespace std;
11 using namespace edm;
12 using namespace reco;
14  : pfTransformer_(nullptr), magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()) {
15  produces<reco::PFV0Collection>();
16  produces<reco::PFRecTrackCollection>();
17 
18  std::vector<edm::InputTag> tags = iConfig.getParameter<vector<InputTag> >("V0List");
19 
20  for (unsigned int i = 0; i < tags.size(); ++i)
21  V0list_.push_back(consumes<reco::VertexCompositeCandidateCollection>(tags[i]));
22 }
23 
25 
27  LogDebug("PFV0Producer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
28  //create the empty collections
29  auto pfV0Coll = std::make_unique<PFV0Collection>();
30 
31  auto pfV0RecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
32 
33  reco::PFRecTrackRefProd pfTrackRefProd = iEvent.getRefBeforePut<reco::PFRecTrackCollection>();
34  int idx = 0;
35 
36  for (unsigned int il = 0; il < V0list_.size(); il++) {
38  iEvent.getByToken(V0list_[il], V0coll);
39  LogDebug("PFV0Producer") << "V0list_[" << il << "] contains " << V0coll->size() << " V0 candidates ";
40  for (unsigned int iv = 0; iv < V0coll->size(); iv++) {
41  VertexCompositeCandidateRef V0(V0coll, iv);
42  vector<TrackRef> Tracks;
43  vector<PFRecTrackRef> PFTracks;
44  for (unsigned int ndx = 0; ndx < V0->numberOfDaughters(); ndx++) {
45  Tracks.push_back((dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track());
46  TrackRef trackRef = (dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track();
47 
48  reco::PFRecTrack pfRecTrack(trackRef->charge(), reco::PFRecTrack::KF, trackRef.key(), trackRef);
49 
50  Trajectory FakeTraj;
51  bool valid = pfTransformer_->addPoints(pfRecTrack, *trackRef, FakeTraj);
52  if (valid) {
53  PFTracks.push_back(reco::PFRecTrackRef(pfTrackRefProd, idx++));
54  pfV0RecTrackColl->push_back(pfRecTrack);
55  }
56  }
57  if ((PFTracks.size() == 2) && (Tracks.size() == 2)) {
58  pfV0Coll->push_back(PFV0(V0, PFTracks, Tracks));
59  }
60  }
61  }
62 
63  iEvent.put(std::move(pfV0Coll));
64  iEvent.put(std::move(pfV0RecTrackColl));
65 }
66 
67 // ------------ method called once each job just before starting event loop ------------
68 void PFV0Producer::beginRun(const edm::Run& run, const EventSetup& iSetup) {
69  auto const& magneticField = &iSetup.getData(magneticFieldToken_);
72 }
73 
74 // ------------ method called once each job just after ending the event loop ------------
75 void PFV0Producer::endRun(const edm::Run& run, const EventSetup& iSetup) {
76  delete pfTransformer_;
77  pfTransformer_ = nullptr;
78 }
edm::RefProd
Definition: EDProductfwd.h:25
mps_fire.i
i
Definition: mps_fire.py:428
PFV0Producer.h
ESHandle.h
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
reco::PFRecTrack::KF
Definition: PFRecTrack.h:25
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
PFTrackTransformer.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< VertexCompositeCandidateCollection >
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
PFV0Producer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: PFV0Producer.cc:68
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
Point3DBase< float, GlobalTag >
PFV0Producer::pfTransformer_
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
Definition: PFV0Producer.h:31
pfTrackElec_cfi.PFV0
PFV0
Definition: pfTrackElec_cfi.py:27
PFV0Producer::PFV0Producer
PFV0Producer(const edm::ParameterSet &)
Constructor.
Definition: PFV0Producer.cc:13
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
PFV0Producer::~PFV0Producer
~PFV0Producer() override
Destructor.
Definition: PFV0Producer.cc:24
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
edm::EventSetup
Definition: EventSetup.h:58
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
PFV0.h
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:75
RecoChargedCandidate.h
reco::PFRecTrack
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:20
Trajectory
Definition: Trajectory.h:38
PFTrackTransformer::OnlyProp
void OnlyProp()
Definition: PFTrackTransformer.h:54
edm::Transition::BeginRun
PFV0Producer::V0list_
std::vector< edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > > V0list_
Definition: PFV0Producer.h:32
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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:26
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
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
PFTrackTransformer
Definition: PFTrackTransformer.h:34
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
PFV0Producer::magneticFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: PFV0Producer.h:34