CMS 3D CMS Logo

PFV0Producer.cc
Go to the documentation of this file.
1 #include <memory>
11 
12 using namespace std;
13 using namespace edm;
14 using namespace reco;
16  pfTransformer_(0)
17 {
18 
19  produces<reco::PFV0Collection>();
20  produces<reco::PFRecTrackCollection>();
21 
22  std::vector<edm::InputTag> tags = iConfig.getParameter< vector < InputTag > >("V0List");
23 
24  for (unsigned int i=0;i<tags.size();++i)
25  V0list_.push_back(consumes<reco::VertexCompositeCandidateCollection>(tags[i]));
26 }
27 
29 {
30  delete pfTransformer_;
31 }
32 
33 void
35 {
36  LogDebug("PFV0Producer")<<"START event: "<<iEvent.id().event()
37  <<" in run "<<iEvent.id().run();
38  //create the empty collections
39  auto pfV0Coll = std::make_unique<PFV0Collection>();
40 
41  auto pfV0RecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
42 
43 
45  int idx = 0;
46 
47  for (unsigned int il=0; il<V0list_.size(); il++){
49  iEvent.getByToken(V0list_[il],V0coll);
50  LogDebug("PFV0Producer")<< "V0list_[" << il <<"] contains "<<V0coll->size()<<" V0 candidates ";
51  for (unsigned int iv=0;iv<V0coll->size();iv++){
52  VertexCompositeCandidateRef V0(V0coll, iv);
53  vector<TrackRef> Tracks;
54  vector<PFRecTrackRef> PFTracks;
55  for( unsigned int ndx = 0; ndx < V0->numberOfDaughters(); ndx++ ) {
56 
57  Tracks.push_back( (dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track() );
58  TrackRef trackRef = (dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track();
59 
60  reco::PFRecTrack pfRecTrack( trackRef->charge(),
62  trackRef.key(),
63  trackRef );
64 
65 
66  Trajectory FakeTraj;
67  bool valid = pfTransformer_->addPoints( pfRecTrack, *trackRef, FakeTraj);
68  if(valid) {
69  PFTracks.push_back(reco::PFRecTrackRef( pfTrackRefProd, idx++));
70  pfV0RecTrackColl->push_back(pfRecTrack);
71 
72  }
73  }
74  if ((PFTracks.size()==2)&&(Tracks.size()==2)){
75  pfV0Coll->push_back(PFV0(V0,PFTracks,Tracks));
76  }
77 
78 
79 
80  }
81  }
82 
83 
84  iEvent.put(std::move(pfV0Coll));
85  iEvent.put(std::move(pfV0RecTrackColl));
86 }
87 
88 // ------------ method called once each job just before starting event loop ------------
89 void
91  const EventSetup& iSetup)
92 {
94  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
97 }
98 
99 
100 // ------------ method called once each job just after ending the event loop ------------
101 void
103  const EventSetup& iSetup) {
104  delete pfTransformer_;
105  pfTransformer_=nullptr;
106 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
PFV0Producer(const edm::ParameterSet &)
Constructor.
Definition: PFV0Producer.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: PFV0Producer.cc:90
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.
~PFV0Producer()
Destructor.
Definition: PFV0Producer.cc:28
std::vector< edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > > V0list_
Definition: PFV0Producer.h:32
key_type key() const
Accessor for product key.
Definition: Ref.h:264
virtual void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
Definition: PFV0Producer.cc:34
int iEvent
Definition: GenABIO.cc:230
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
Definition: PFV0Producer.h:31
const T & get() const
Definition: EventSetup.h:56
edm::EventID id() const
Definition: EventBase.h:60
fixed size matrix
HLT enums.
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
def move(src, dest)
Definition: eostools.py:510
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: Run.h:42