CMS 3D CMS Logo

PFDisplacedTrackerVertexProducer.cc
Go to the documentation of this file.
10 
12 public:
15 
18 
19 private:
20  void beginRun(const edm::Run&, const edm::EventSetup&) override;
21  void endRun(const edm::Run&, const edm::EventSetup&) override;
22 
24  void produce(edm::Event&, const edm::EventSetup&) override;
25 
30 
32 };
33 
36 
37 using namespace std;
38 using namespace edm;
40  : pfTransformer_(nullptr), magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()) {
41  produces<reco::PFRecTrackCollection>();
42  produces<reco::PFDisplacedTrackerVertexCollection>();
43 
45  consumes<reco::PFDisplacedVertexCollection>(iConfig.getParameter<InputTag>("displacedTrackerVertexColl"));
46 
47  pfTrackContainer_ = consumes<reco::TrackCollection>(iConfig.getParameter<InputTag>("trackColl"));
48 }
49 
51 
53  //create the empty collections
54  auto pfDisplacedTrackerVertexColl = std::make_unique<reco::PFDisplacedTrackerVertexCollection>();
55  auto pfRecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
56 
57  reco::PFRecTrackRefProd pfTrackRefProd = iEvent.getRefBeforePut<reco::PFRecTrackCollection>();
58 
60  iEvent.getByToken(pfDisplacedVertexContainer_, nuclCollH);
61  const reco::PFDisplacedVertexCollection& nuclColl = *(nuclCollH.product());
62 
64  iEvent.getByToken(pfTrackContainer_, trackColl);
65 
66  int idx = 0;
67 
68  // cout << "Size of Displaced Vertices "
69  // << nuclColl.size() << endl;
70 
71  // loop on all NuclearInteraction
72  for (unsigned int icoll = 0; icoll < nuclColl.size(); icoll++) {
73  reco::PFRecTrackRefVector pfRecTkcoll;
74 
75  std::vector<reco::Track> refittedTracks = nuclColl[icoll].refittedTracks();
76 
77  // convert the secondary tracks
78  for (unsigned it = 0; it < refittedTracks.size(); it++) {
79  reco::TrackBaseRef trackBaseRef = nuclColl[icoll].originalTrack(refittedTracks[it]);
80 
81  // cout << "track base pt = " << trackBaseRef->pt() << endl;
82 
83  reco::TrackRef trackRef(trackColl, trackBaseRef.key());
84 
85  // cout << "track pt = " << trackRef->pt() << endl;
86 
87  reco::PFRecTrack pfRecTrack(trackBaseRef->charge(), reco::PFRecTrack::KF, trackBaseRef.key(), trackRef);
88 
89  // cout << pfRecTrack << endl;
90 
91  Trajectory FakeTraj;
92  bool valid = pfTransformer_->addPoints(pfRecTrack, *trackBaseRef, FakeTraj);
93  if (valid) {
94  pfRecTkcoll.push_back(reco::PFRecTrackRef(pfTrackRefProd, idx++));
95  pfRecTrackColl->push_back(pfRecTrack);
96  // cout << "after "<< pfRecTrack << endl;
97  }
98  }
99  reco::PFDisplacedVertexRef niRef(nuclCollH, icoll);
100  pfDisplacedTrackerVertexColl->push_back(reco::PFDisplacedTrackerVertex(niRef, pfRecTkcoll));
101  }
102 
103  iEvent.put(std::move(pfRecTrackColl));
104  iEvent.put(std::move(pfDisplacedTrackerVertexColl));
105 }
106 
107 // ------------ method called once each job just before starting event loop ------------
109  auto const& magneticField = &iSetup.getData(magneticFieldToken_);
112 }
113 
114 // ------------ method called once each job just after ending the event loop ------------
116  delete pfTransformer_;
117  pfTransformer_ = nullptr;
118 }
edm::EDGetTokenT< reco::TrackCollection > pfTrackContainer_
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:20
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
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
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
PFDisplacedTrackerVertexProducer(const edm::ParameterSet &)
Constructor.
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > pfDisplacedVertexContainer_
void beginRun(const edm::Run &, const edm::EventSetup &) override
int charge() const
track electric charge
Definition: TrackBase.h:596
int iEvent
Definition: GenABIO.cc:224
void endRun(const edm::Run &, const edm::EventSetup &) override
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
size_t key() const
Definition: RefToBase.h:221
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h: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.
HLT enums.
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
int icoll
Definition: AMPTWrapper.h:146