CMS 3D CMS Logo

NuclearSeedsEDProducer.cc
Go to the documentation of this file.
3 
6 
10 
13 
14 using namespace edm;
15 using namespace std;
16 using namespace reco;
17 
18 //
19 // constructors and destructor
20 //
22  : config_(),
23  improveSeeds(iConfig.getParameter<bool>("improveSeeds")),
24  producer_(consumes<TrajectoryCollection>(iConfig.getParameter<std::string>("producer"))),
25  mteToken_(consumes<MeasurementTrackerEvent>(edm::InputTag("MeasurementTrackerEvents"))) {
26  produces<TrajectorySeedCollection>();
27  produces<TrajectoryToSeedsMap>();
28 
29  trackerGeomToken_ = esConsumes<edm::Transition::BeginRun>();
30  propagatorToken_ = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "PropagatorWithMaterial"));
31  estimatorToken_ = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "Chi2"));
32 
33  std::string measurementTrackerName = iConfig.getParameter<std::string>("MeasurementTrackerName");
34  measurementTrackerToken_ = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", measurementTrackerName));
35  geomSearchTrackerToken_ = esConsumes<edm::Transition::BeginRun>();
36 
37  auto navigationSchoolName = iConfig.getParameter<std::string>("NavigationSchool");
38  navigationToken_ = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", navigationSchoolName));
39 
40  config_.maxHits = iConfig.getParameter<int>("maxHits");
41  config_.rescaleErrorFactor = iConfig.getParameter<double>("rescaleErrorFactor");
42  config_.checkCompletedTrack = iConfig.getParameter<bool>("checkCompletedTrack");
43  config_.ptMin = iConfig.getParameter<double>("ptMin");
44 }
45 
47 
48 //
49 // member functions
50 //
51 
52 // ------------ method called to produce the data ------------
54  typedef TrajectoryMeasurement TM;
55 
56  edm::Handle<TrajectoryCollection> m_TrajectoryCollection;
57  iEvent.getByToken(producer_, m_TrajectoryCollection);
58 
59  LogDebug("NuclearSeedGenerator") << "Number of trajectory in event :" << m_TrajectoryCollection->size() << "\n";
60 
61  auto output = std::make_unique<TrajectorySeedCollection>();
62  auto outAssoc = std::make_unique<TrajectoryToSeedsMap>();
63 
65  iEvent.getByToken(mteToken_, data);
66 
67  // NavigationSetter setter( *(theNuclearInteractionFinder->nav()) ); why???
68 
69  std::vector<std::pair<int, int> > assocPair;
70  int i = 0;
71 
72  for (std::vector<Trajectory>::const_iterator iTraj = m_TrajectoryCollection->begin();
73  iTraj != m_TrajectoryCollection->end();
74  iTraj++, i++) {
75  // run the finder
76  theNuclearInteractionFinder->run(*iTraj, *data);
77 
78  // improve seeds
79  if (improveSeeds == true)
80  theNuclearInteractionFinder->improveSeeds(*data);
81 
82  // push back the new persistent seeds in output
83  std::unique_ptr<TrajectorySeedCollection> newSeeds(theNuclearInteractionFinder->getPersistentSeeds());
84  output->insert(output->end(), newSeeds->begin(), newSeeds->end());
85 
86  // fill the id of the Trajectory and the if of the seed in assocPair
87  for (unsigned int j = 0; j < newSeeds->size(); j++) {
88  assocPair.push_back(std::make_pair(i, output->size() - newSeeds->size() + j));
89  }
90  }
91 
92  const edm::OrphanHandle<TrajectorySeedCollection> refprodTrajSeedColl = iEvent.put(std::move(output));
93 
94  for (std::vector<std::pair<int, int> >::const_iterator iVecP = assocPair.begin(); iVecP != assocPair.end(); iVecP++) {
95  outAssoc->insert(edm::Ref<TrajectoryCollection>(m_TrajectoryCollection, iVecP->first),
96  edm::Ref<TrajectorySeedCollection>(refprodTrajSeedColl, iVecP->second));
97  }
98  iEvent.put(std::move(outAssoc));
99 }
100 
101 // ------------ method called once each job just before starting event loop ------------
103  theNuclearInteractionFinder = std::make_unique<NuclearInteractionFinder>(config_,
110 }
111 
NuclearSeedsEDProducer(const edm::ParameterSet &)
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void beginRun(edm::Run const &run, const edm::EventSetup &) override
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::unique_ptr< NuclearInteractionFinder > theNuclearInteractionFinder
edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measurementTrackerToken_
edm::EDGetTokenT< TrajectoryCollection > producer_
NuclearInteractionFinder::Config config_
int iEvent
Definition: GenABIO.cc:224
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeomToken_
edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > estimatorToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< GeometricSearchTracker, TrackerRecoGeometryRecord > geomSearchTrackerToken_
fixed size matrix
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void produce(edm::Event &, const edm::EventSetup &) override
edm::ESGetToken< NavigationSchool, NavigationSchoolRecord > navigationToken_
std::vector< Trajectory > TrajectoryCollection
edm::EDGetTokenT< MeasurementTrackerEvent > mteToken_
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
#define LogDebug(id)