CMS 3D CMS Logo

PFDisplacedTrackerVertexProducer.cc
Go to the documentation of this file.
1 #include <memory>
8 using namespace std;
9 using namespace edm;
11  pfTransformer_(nullptr)
12 {
13  produces<reco::PFRecTrackCollection>();
14  produces<reco::PFDisplacedTrackerVertexCollection>();
15 
16  pfDisplacedVertexContainer_ = consumes<reco::PFDisplacedVertexCollection>( iConfig.getParameter< InputTag >("displacedTrackerVertexColl"));
17 
18 
19  pfTrackContainer_ =consumes<reco::TrackCollection>(
20  iConfig.getParameter< InputTag >("trackColl"));
21 
22 }
23 
25 {
26  delete pfTransformer_;
27 }
28 
29 void
31 {
32 
33  //create the empty collections
34  auto pfDisplacedTrackerVertexColl = std::make_unique<reco::PFDisplacedTrackerVertexCollection>();
35  auto pfRecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
36 
38 
39 
40 
42  iEvent.getByToken(pfDisplacedVertexContainer_, nuclCollH);
43  const reco::PFDisplacedVertexCollection& nuclColl = *(nuclCollH.product());
44 
46  iEvent.getByToken(pfTrackContainer_, trackColl);
47 
48  int idx = 0;
49 
50  // cout << "Size of Displaced Vertices "
51  // << nuclColl.size() << endl;
52 
53  // loop on all NuclearInteraction
54  for( unsigned int icoll=0; icoll < nuclColl.size(); icoll++) {
55 
56  reco::PFRecTrackRefVector pfRecTkcoll;
57 
58  std::vector<reco::Track> refittedTracks = nuclColl[icoll].refittedTracks();
59 
60  // convert the secondary tracks
61  for(unsigned it = 0; it < refittedTracks.size(); it++){
62 
63  reco::TrackBaseRef trackBaseRef = nuclColl[icoll].originalTrack(refittedTracks[it]);
64 
65  // cout << "track base pt = " << trackBaseRef->pt() << endl;
66 
67  reco::TrackRef trackRef(trackColl, trackBaseRef.key());
68 
69  // cout << "track pt = " << trackRef->pt() << endl;
70 
71 
72  reco::PFRecTrack pfRecTrack( trackBaseRef->charge(),
74  trackBaseRef.key(),
75  trackRef );
76 
77  // cout << pfRecTrack << endl;
78 
79  Trajectory FakeTraj;
80  bool valid = pfTransformer_->addPoints( pfRecTrack, *trackBaseRef, FakeTraj);
81  if(valid) {
82  pfRecTkcoll.push_back(reco::PFRecTrackRef( pfTrackRefProd, idx++));
83  pfRecTrackColl->push_back(pfRecTrack);
84  // cout << "after "<< pfRecTrack << endl;
85 
86  }
87  }
88  reco::PFDisplacedVertexRef niRef(nuclCollH, icoll);
89  pfDisplacedTrackerVertexColl->push_back( reco::PFDisplacedTrackerVertex( niRef, pfRecTkcoll ));
90  }
91 
92  iEvent.put(std::move(pfRecTrackColl));
93  iEvent.put(std::move(pfDisplacedTrackerVertexColl));
94 }
95 
96 // ------------ method called once each job just before starting event loop ------------
97 void
99  const EventSetup& iSetup)
100 {
102  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
105 }
106 
107 // ------------ method called once each job just after ending the event loop ------------
108 void
110  const EventSetup& iSetup) {
111  delete pfTransformer_;
112  pfTransformer_=nullptr;
113 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > pfTrackContainer_
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
PFDisplacedTrackerVertexProducer(const edm::ParameterSet &)
Constructor.
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.
#define nullptr
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > pfDisplacedVertexContainer_
void beginRun(const edm::Run &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
size_t key() const
Definition: RefToBase.h:250
void endRun(const edm::Run &, const edm::EventSetup &) override
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
HLT enums.
T get() const
Definition: EventSetup.h:71
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
int charge() const
track electric charge
Definition: TrackBase.h:606
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:136