test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFNuclearProducer.cc
Go to the documentation of this file.
1 #include <memory>
8 using namespace std;
9 using namespace edm;
11  pfTransformer_(0)
12 {
13  produces<reco::PFRecTrackCollection>();
14  produces<reco::PFNuclearInteractionCollection>();
15 
16  std::vector<edm::InputTag> tags=
17  iConfig.getParameter< vector < InputTag > >("nuclearColList");
18 
19  for (unsigned int i=0;i<tags.size();++i)
20  nuclearContainers_.push_back(consumes<reco::NuclearInteractionCollection>(tags[i]));
21 
23  = iConfig.getParameter<double>("likelihoodCut");
24 }
25 
27 {
28  delete pfTransformer_;
29 }
30 
31 void
33 {
34  typedef reco::NuclearInteraction::trackRef_iterator trackRef_iterator;
35 
36  //create the empty collections
37  auto_ptr< reco::PFNuclearInteractionCollection >
38  pfNuclearColl (new reco::PFNuclearInteractionCollection);
39  auto_ptr< reco::PFRecTrackCollection >
40  pfNuclearRecTrackColl (new reco::PFRecTrackCollection);
41 
43  int hid=0;
44 
45  // loop on the nuclear interaction collections
46  for (unsigned int istr=0; istr<nuclearContainers_.size();istr++){
47 
49  iEvent.getByToken(nuclearContainers_[istr], nuclCollH);
50  const reco::NuclearInteractionCollection& nuclColl = *(nuclCollH.product());
51 
52  // loop on all NuclearInteraction
53  for( unsigned int icoll=0; icoll < nuclColl.size(); icoll++) {
54 
55  if( nuclColl[icoll].likelihood() < likelihoodCut_) continue;
56 
57  reco::PFRecTrackRefVector pfRecTkcoll;
58 
59  // convert the secondary tracks
60  for(trackRef_iterator it = nuclColl[icoll].secondaryTracks_begin(); it!=nuclColl[icoll].secondaryTracks_end(); it++){
61  reco::PFRecTrack pftrack( (*it)->charge(),
63  it->key(), (reco::TrackRef)((*it).castTo<reco::TrackRef>()) );
64  Trajectory FakeTraj;
65  bool valid = pfTransformer_->addPoints( pftrack, **it, FakeTraj);
66  if(valid) {
67  pfRecTkcoll.push_back(reco::PFRecTrackRef( pfTrackRefProd, hid++ ));
68  pfNuclearRecTrackColl->push_back(pftrack);
69  }
70  }
71  reco::NuclearInteractionRef niRef(nuclCollH, icoll);
72  pfNuclearColl->push_back( reco::PFNuclearInteraction( niRef, pfRecTkcoll ));
73  }
74  }
75  iEvent.put(pfNuclearRecTrackColl);
76  iEvent.put(pfNuclearColl);
77 }
78 
79 // ------------ method called once each job just before starting event loop ------------
80 void
82  const EventSetup& iSetup)
83 {
85  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
86  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
88 }
89 
90 // ------------ method called once each job just after ending the event loop ------------
91 void
93  const EventSetup& iSetup) {
94  delete pfTransformer_;
95  pfTransformer_=nullptr;
96 }
T getParameter(std::string const &) const
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
int i
Definition: DBlmapReader.cc:9
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
void likelihood(int &npar, double *grad, double &fval, double *xval, int flag)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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.
std::vector< edm::EDGetTokenT< reco::NuclearInteractionCollection > > nuclearContainers_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< PFNuclearInteraction > PFNuclearInteractionCollection
collection of NuclearInteractions
~PFNuclearProducer()
Destructor.
std::vector< NuclearInteraction > NuclearInteractionCollection
collection of NuclearInteractions
reco::Vertex::trackRef_iterator trackRef_iterator
RefProd< PROD > getRefBeforePut()
Definition: Event.h:141
tuple tags
Definition: o2o.py:248
T const * product() const
Definition: Handle.h:81
virtual void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
const T & get() const
Definition: EventSetup.h:56
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:69
PFNuclearProducer(const edm::ParameterSet &)
Constructor.
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: Run.h:43
int icoll
Definition: AMPTWrapper.h:136