CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NuclearSeedsEDProducer.cc
Go to the documentation of this file.
3 
6 
9 
10 using namespace edm;
11 using namespace std;
12 using namespace reco;
13 
14 //
15 // constructors and destructor
16 //
18  : conf_(iConfig),
19  improveSeeds(iConfig.getParameter<bool>("improveSeeds")),
20  producer_(consumes<TrajectoryCollection>(iConfig.getParameter<std::string>("producer"))),
21  mteToken_(consumes<MeasurementTrackerEvent>(edm::InputTag("MeasurementTrackerEvents"))) {
22  produces<TrajectorySeedCollection>();
23  produces<TrajectoryToSeedsMap>();
24 }
25 
27 
28 //
29 // member functions
30 //
31 
32 // ------------ method called to produce the data ------------
34  typedef TrajectoryMeasurement TM;
35 
36  edm::Handle<TrajectoryCollection> m_TrajectoryCollection;
37  iEvent.getByToken(producer_, m_TrajectoryCollection);
38 
39  LogDebug("NuclearSeedGenerator") << "Number of trajectory in event :" << m_TrajectoryCollection->size() << "\n";
40 
41  auto output = std::make_unique<TrajectorySeedCollection>();
42  auto outAssoc = std::make_unique<TrajectoryToSeedsMap>();
43 
45  iEvent.getByToken(mteToken_, data);
46 
47  // NavigationSetter setter( *(theNuclearInteractionFinder->nav()) ); why???
48 
49  std::vector<std::pair<int, int> > assocPair;
50  int i = 0;
51 
52  for (std::vector<Trajectory>::const_iterator iTraj = m_TrajectoryCollection->begin();
53  iTraj != m_TrajectoryCollection->end();
54  iTraj++, i++) {
55  // run the finder
56  theNuclearInteractionFinder->run(*iTraj, *data);
57 
58  // improve seeds
59  if (improveSeeds == true)
60  theNuclearInteractionFinder->improveSeeds(*data);
61 
62  // push back the new persistent seeds in output
63  std::unique_ptr<TrajectorySeedCollection> newSeeds(theNuclearInteractionFinder->getPersistentSeeds());
64  output->insert(output->end(), newSeeds->begin(), newSeeds->end());
65 
66  // fill the id of the Trajectory and the if of the seed in assocPair
67  for (unsigned int j = 0; j < newSeeds->size(); j++) {
68  assocPair.push_back(std::make_pair(i, output->size() - newSeeds->size() + j));
69  }
70  }
71 
72  const edm::OrphanHandle<TrajectorySeedCollection> refprodTrajSeedColl = iEvent.put(std::move(output));
73 
74  for (std::vector<std::pair<int, int> >::const_iterator iVecP = assocPair.begin(); iVecP != assocPair.end(); iVecP++) {
75  outAssoc->insert(edm::Ref<TrajectoryCollection>(m_TrajectoryCollection, iVecP->first),
76  edm::Ref<TrajectorySeedCollection>(refprodTrajSeedColl, iVecP->second));
77  }
78  iEvent.put(std::move(outAssoc));
79 }
80 
81 // ------------ method called once each job just before starting event loop ------------
83  theNuclearInteractionFinder = std::make_unique<NuclearInteractionFinder>(es, conf_);
84 }
85 
NuclearSeedsEDProducer(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void beginRun(edm::Run const &run, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::unique_ptr< NuclearInteractionFinder > theNuclearInteractionFinder
edm::EDGetTokenT< TrajectoryCollection > producer_
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
std::vector< Trajectory > TrajectoryCollection
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void produce(edm::Event &, const edm::EventSetup &) override
tuple MeasurementTrackerEvent
edm::EDGetTokenT< MeasurementTrackerEvent > mteToken_
Definition: Run.h:45
#define LogDebug(id)