CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFV0Producer.cc
Go to the documentation of this file.
1 #include <memory>
13 
14 using namespace std;
15 using namespace edm;
16 using namespace reco;
18  pfTransformer_(0)
19 {
20 
21  produces<reco::PFV0Collection>();
22  produces<reco::PFRecTrackCollection>();
23 
24  V0list_ =
25  iConfig.getParameter< vector < InputTag > >("V0List");
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_ptr< PFV0Collection > pfV0Coll (new PFV0Collection);
40 
41  auto_ptr<reco::PFRecTrackCollection> pfV0RecTrackColl(new reco::PFRecTrackCollection);
42 
43 
45  int idx = 0;
46 
47  for (unsigned int il=0; il<V0list_.size(); il++){
49  iEvent.getByLabel(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(pfV0Coll);
85  iEvent.put(pfV0RecTrackColl);
86 }
87 
88 // ------------ method called once each job just before starting event loop ------------
89 void
91  const EventSetup& iSetup)
92 {
93  ESHandle<MagneticField> magneticField;
94  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
95  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
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:42
std::vector< edm::InputTag > V0list_
Definition: PFV0Producer.h:30
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
PFV0Producer(const edm::ParameterSet &)
Constructor.
Definition: PFV0Producer.cc:17
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
virtual void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
Definition: PFV0Producer.cc:34
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< PFV0 > PFV0Collection
collection of PFV0 objects
Definition: PFV0Fwd.h:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
RefProd< PROD > getRefBeforePut()
Definition: Event.h:128
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
Definition: PFV0Producer.h:29
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const T & get() const
Definition: EventSetup.h:55
key_type key() const
Accessor for product key.
Definition: Ref.h:266
edm::EventID id() const
Definition: EventBase.h:56
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: Run.h:41