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>
9 using namespace std;
10 using namespace edm;
12  pfTransformer_(0)
13 {
14  produces<reco::PFRecTrackCollection>();
15  produces<reco::PFNuclearInteractionCollection>();
16 
18  iConfig.getParameter< vector < InputTag > >("nuclearColList");
20  = iConfig.getParameter<double>("likelihoodCut");
21 }
22 
24 {
25  delete pfTransformer_;
26 }
27 
28 void
30 {
31  typedef reco::NuclearInteraction::trackRef_iterator trackRef_iterator;
32 
33  //create the empty collections
34  auto_ptr< reco::PFNuclearInteractionCollection >
35  pfNuclearColl (new reco::PFNuclearInteractionCollection);
36  auto_ptr< reco::PFRecTrackCollection >
37  pfNuclearRecTrackColl (new reco::PFRecTrackCollection);
38 
40  int hid=0;
41 
42  // loop on the nuclear interaction collections
43  for (unsigned int istr=0; istr<nuclearContainers_.size();istr++){
44 
46  iEvent.getByLabel(nuclearContainers_[istr], nuclCollH);
47  const reco::NuclearInteractionCollection& nuclColl = *(nuclCollH.product());
48 
49  // loop on all NuclearInteraction
50  for( unsigned int icoll=0; icoll < nuclColl.size(); icoll++) {
51 
52  if( nuclColl[icoll].likelihood() < likelihoodCut_) continue;
53 
54  reco::PFRecTrackRefVector pfRecTkcoll;
55 
56  // convert the secondary tracks
57  for(trackRef_iterator it = nuclColl[icoll].secondaryTracks_begin(); it!=nuclColl[icoll].secondaryTracks_end(); it++){
58  reco::PFRecTrack pftrack( (*it)->charge(),
60  it->key(), (reco::TrackRef)((*it).castTo<reco::TrackRef>()) );
61  Trajectory FakeTraj;
62  bool valid = pfTransformer_->addPoints( pftrack, **it, FakeTraj);
63  if(valid) {
64  pfRecTkcoll.push_back(reco::PFRecTrackRef( pfTrackRefProd, hid++ ));
65  pfNuclearRecTrackColl->push_back(pftrack);
66  }
67  }
68  reco::NuclearInteractionRef niRef(nuclCollH, icoll);
69  pfNuclearColl->push_back( reco::PFNuclearInteraction( niRef, pfRecTkcoll ));
70  }
71  }
72  iEvent.put(pfNuclearRecTrackColl);
73  iEvent.put(pfNuclearColl);
74 }
75 
76 // ------------ method called once each job just before starting event loop ------------
77 void
79  const EventSetup& iSetup)
80 {
81  ESHandle<MagneticField> magneticField;
82  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
83  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
85 }
86 
87 // ------------ method called once each job just after ending the event loop ------------
88 void
90  delete pfTransformer_;
91 }
T getParameter(std::string const &) const
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
virtual void produce(edm::Event &, const edm::EventSetup &)
Produce the PFRecTrack collection.
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
void likelihood(int &npar, double *grad, double &fval, double *xval, int flag)
virtual void endRun()
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.
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< PFNuclearInteraction > PFNuclearInteractionCollection
collection of NuclearInteractions
~PFNuclearProducer()
Destructor.
std::vector< NuclearInteraction > NuclearInteractionCollection
collection of NuclearInteractions
reco::Vertex::trackRef_iterator trackRef_iterator
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
RefProd< PROD > getRefBeforePut()
Definition: Event.h:97
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const T & get() const
Definition: EventSetup.h:55
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
T const * product() const
Definition: Handle.h:74
virtual void beginRun(edm::Run &, const edm::EventSetup &)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
std::vector< edm::InputTag > nuclearContainers_
PFNuclearProducer(const edm::ParameterSet &)
Constructor.
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
Definition: Run.h:33
int icoll
Definition: AMPTWrapper.h:136