CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFNuclearProducer.cc
Go to the documentation of this file.
10 
12 public:
14  explicit PFNuclearProducer(const edm::ParameterSet&);
15 
17  ~PFNuclearProducer() override;
18 
19 private:
20  void beginRun(const edm::Run&, const edm::EventSetup&) override;
21  void endRun(const edm::Run&, const edm::EventSetup&) override;
22 
24  void produce(edm::Event&, const edm::EventSetup&) override;
25 
29  std::vector<edm::EDGetTokenT<reco::NuclearInteractionCollection> > nuclearContainers_;
30 
32 };
33 
36 
37 using namespace std;
38 using namespace edm;
40  : pfTransformer_(nullptr), magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()) {
41  produces<reco::PFRecTrackCollection>();
42  produces<reco::PFNuclearInteractionCollection>();
43 
44  std::vector<edm::InputTag> tags = iConfig.getParameter<vector<InputTag> >("nuclearColList");
45 
46  for (unsigned int i = 0; i < tags.size(); ++i)
47  nuclearContainers_.push_back(consumes<reco::NuclearInteractionCollection>(tags[i]));
48 
49  likelihoodCut_ = iConfig.getParameter<double>("likelihoodCut");
50 }
51 
53 
55  typedef reco::NuclearInteraction::trackRef_iterator trackRef_iterator;
56 
57  //create the empty collections
58  auto pfNuclearColl = std::make_unique<reco::PFNuclearInteractionCollection>();
59  auto pfNuclearRecTrackColl = std::make_unique<reco::PFRecTrackCollection>();
60 
62  int hid = 0;
63 
64  // loop on the nuclear interaction collections
65  for (unsigned int istr = 0; istr < nuclearContainers_.size(); istr++) {
67  iEvent.getByToken(nuclearContainers_[istr], nuclCollH);
68  const reco::NuclearInteractionCollection& nuclColl = *(nuclCollH.product());
69 
70  // loop on all NuclearInteraction
71  for (unsigned int icoll = 0; icoll < nuclColl.size(); icoll++) {
72  if (nuclColl[icoll].likelihood() < likelihoodCut_)
73  continue;
74 
75  reco::PFRecTrackRefVector pfRecTkcoll;
76 
77  // convert the secondary tracks
78  for (trackRef_iterator it = nuclColl[icoll].secondaryTracks_begin(); it != nuclColl[icoll].secondaryTracks_end();
79  it++) {
80  reco::PFRecTrack pftrack(
81  (*it)->charge(), reco::PFRecTrack::KF, it->key(), (reco::TrackRef)((*it).castTo<reco::TrackRef>()));
82  Trajectory FakeTraj;
83  bool valid = pfTransformer_->addPoints(pftrack, **it, FakeTraj);
84  if (valid) {
85  pfRecTkcoll.push_back(reco::PFRecTrackRef(pfTrackRefProd, hid++));
86  pfNuclearRecTrackColl->push_back(pftrack);
87  }
88  }
89  reco::NuclearInteractionRef niRef(nuclCollH, icoll);
90  pfNuclearColl->push_back(reco::PFNuclearInteraction(niRef, pfRecTkcoll));
91  }
92  }
93  iEvent.put(std::move(pfNuclearRecTrackColl));
94  iEvent.put(std::move(pfNuclearColl));
95 }
96 
97 // ------------ method called once each job just before starting event loop ------------
98 void PFNuclearProducer::beginRun(const edm::Run& run, const EventSetup& iSetup) {
99  auto const& magneticField = &iSetup.getData(magneticFieldToken_);
102 }
103 
104 // ------------ method called once each job just after ending the event loop ------------
105 void PFNuclearProducer::endRun(const edm::Run& run, const EventSetup& iSetup) {
106  delete pfTransformer_;
107  pfTransformer_ = nullptr;
108 }
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:20
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
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:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
tuple magneticField
std::vector< edm::EDGetTokenT< reco::NuclearInteractionCollection > > nuclearContainers_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
std::vector< NuclearInteraction > NuclearInteractionCollection
collection of NuclearInteractions
reco::Vertex::trackRef_iterator trackRef_iterator
~PFNuclearProducer() override
Destructor.
Transition
Definition: Transition.h:12
RefProd< PROD > getRefBeforePut()
Definition: Event.h:158
T const * product() const
Definition: Handle.h:70
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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:67
PFNuclearProducer(const edm::ParameterSet &)
Constructor.
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: Run.h:45
int icoll
Definition: AMPTWrapper.h:146