CMS 3D CMS Logo

PFNuclearProducer.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::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 pfNuclearColl = std::make_unique<reco::PFNuclearInteractionCollection>();
38  auto pfNuclearRecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
39 
41  int hid=0;
42 
43  // loop on the nuclear interaction collections
44  for (unsigned int istr=0; istr<nuclearContainers_.size();istr++){
45 
47  iEvent.getByToken(nuclearContainers_[istr], nuclCollH);
48  const reco::NuclearInteractionCollection& nuclColl = *(nuclCollH.product());
49 
50  // loop on all NuclearInteraction
51  for( unsigned int icoll=0; icoll < nuclColl.size(); icoll++) {
52 
53  if( nuclColl[icoll].likelihood() < likelihoodCut_) continue;
54 
55  reco::PFRecTrackRefVector pfRecTkcoll;
56 
57  // convert the secondary tracks
58  for(trackRef_iterator it = nuclColl[icoll].secondaryTracks_begin(); it!=nuclColl[icoll].secondaryTracks_end(); it++){
59  reco::PFRecTrack pftrack( (*it)->charge(),
61  it->key(), (reco::TrackRef)((*it).castTo<reco::TrackRef>()) );
62  Trajectory FakeTraj;
63  bool valid = pfTransformer_->addPoints( pftrack, **it, FakeTraj);
64  if(valid) {
65  pfRecTkcoll.push_back(reco::PFRecTrackRef( pfTrackRefProd, hid++ ));
66  pfNuclearRecTrackColl->push_back(pftrack);
67  }
68  }
69  reco::NuclearInteractionRef niRef(nuclCollH, icoll);
70  pfNuclearColl->push_back( reco::PFNuclearInteraction( niRef, pfRecTkcoll ));
71  }
72  }
73  iEvent.put(std::move(pfNuclearRecTrackColl));
74  iEvent.put(std::move(pfNuclearColl));
75 }
76 
77 // ------------ method called once each job just before starting event loop ------------
78 void
80  const EventSetup& iSetup)
81 {
83  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
86 }
87 
88 // ------------ method called once each job just after ending the event loop ------------
89 void
91  const EventSetup& iSetup) {
92  delete pfTransformer_;
93  pfTransformer_=nullptr;
94 }
T getParameter(std::string const &) const
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:136
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:519
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
std::vector< edm::EDGetTokenT< reco::NuclearInteractionCollection > > nuclearContainers_
int iEvent
Definition: GenABIO.cc:230
std::vector< NuclearInteraction > NuclearInteractionCollection
collection of NuclearInteractions
reco::Vertex::trackRef_iterator trackRef_iterator
~PFNuclearProducer() override
Destructor.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
RefProd< PROD > getRefBeforePut()
Definition: Event.h:156
T const * product() const
Definition: Handle.h:81
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:58
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
void endRun(const edm::Run &, const edm::EventSetup &) override
HLT enums.
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
PFNuclearProducer(const edm::ParameterSet &)
Constructor.
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
void beginRun(const edm::Run &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:43
int icoll
Definition: AMPTWrapper.h:136