CMS 3D CMS Logo

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