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_(iConfig.getParameter<std::string>("producer"))
21 {
22  produces<TrajectorySeedCollection>();
23  produces<TrajectoryToSeedsMap>();
24 
25 
26 }
27 
28 
30 {
31 }
32 
33 
34 //
35 // member functions
36 //
37 
38 // ------------ method called to produce the data ------------
39 void
41 {
42  typedef TrajectoryMeasurement TM;
43 
44  edm::Handle< TrajectoryCollection > m_TrajectoryCollection;
45  iEvent.getByLabel( producer_, m_TrajectoryCollection );
46 
47  LogDebug("NuclearSeedGenerator") << "Number of trajectory in event :" << m_TrajectoryCollection->size() << "\n";
48 
49  std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection);
50  std::auto_ptr<TrajectoryToSeedsMap> outAssoc(new TrajectoryToSeedsMap);
51 
52  // Update the measurement
53  theNuclearInteractionFinder->setEvent(iEvent);
55 
56  std::vector<std::pair<int, int> > assocPair;
57  int i=0;
58 
59  for(std::vector<Trajectory>::const_iterator iTraj = m_TrajectoryCollection->begin(); iTraj != m_TrajectoryCollection->end(); iTraj++,i++) {
60 
61  // run the finder
62  theNuclearInteractionFinder->run( *iTraj );
63 
64  // improve seeds
65  if( improveSeeds == true ) theNuclearInteractionFinder->improveSeeds();
66 
67  // push back the new persistent seeds in output
68  std::auto_ptr<TrajectorySeedCollection> newSeeds(theNuclearInteractionFinder->getPersistentSeeds());
69  output->insert(output->end(), newSeeds->begin(), newSeeds->end());
70 
71  // fill the id of the Trajectory and the if of the seed in assocPair
72  for(unsigned int j=0; j<newSeeds->size(); j++) {
73  assocPair.push_back( std::make_pair( i, output->size()-newSeeds->size()+j ) );
74  }
75 
76  }
77 
78  const edm::OrphanHandle<TrajectorySeedCollection> refprodTrajSeedColl = iEvent.put(output);
79 
80  for(std::vector<std::pair<int, int> >::const_iterator iVecP = assocPair.begin(); iVecP != assocPair.end(); iVecP++) {
81  outAssoc->insert(edm::Ref<TrajectoryCollection>(m_TrajectoryCollection,iVecP->first), edm::Ref<TrajectorySeedCollection>(refprodTrajSeedColl, iVecP->second));
82  }
83  iEvent.put(outAssoc);
84 
85 }
86 
87 // ------------ method called once each job just before starting event loop ------------
88 void
90 {
91  theNuclearInteractionFinder = std::auto_ptr<NuclearInteractionFinder>(new NuclearInteractionFinder(es, conf_));
92 
93 }
94 
96 
97 
#define LogDebug(id)
NuclearSeedsEDProducer(const edm::ParameterSet &)
int i
Definition: DBlmapReader.cc:9
virtual void beginRun(edm::Run const &run, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:243
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
Class used to obtain vector of all compatible TMs associated to a trajectory to be used by the Nuclea...
std::auto_ptr< NuclearInteractionFinder > theNuclearInteractionFinder
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition: Run.h:36