CMS 3D CMS Logo

DAFTrackProducer.cc
Go to the documentation of this file.
1 #include <memory>
2 
16 
19 
21  : KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"), false), theAlgo(iConfig) {
22  setConf(iConfig);
23  setSrc(consumes<TrackCandidateCollection>(iConfig.getParameter<edm::InputTag>("src")),
24  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot")),
25  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent")));
26  srcTT_ = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("src"));
27  setAlias(iConfig.getParameter<std::string>("@module_label"));
28 
29  //register your products
30  produces<reco::TrackCollection>().setBranchAlias(alias_ + "Tracks");
31  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
32  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
33  produces<std::vector<Trajectory> >();
34  produces<TrajTrackAssociationCollection>();
35  produces<TrajAnnealingCollection>().setBranchAlias(alias_ + "TrajectoryAnnealing");
36  produces<reco::TrackCollection>("beforeDAF").setBranchAlias(alias_ + "TracksBeforeDAF");
37  produces<reco::TrackExtraCollection>("beforeDAF").setBranchAlias(alias_ + "TrackExtrasBeforeDAF");
38  produces<reco::TrackCollection>("afterDAF").setBranchAlias(alias_ + "TracksAfterDAF");
39  produces<reco::TrackExtraCollection>("afterDAF").setBranchAlias(alias_ + "TrackExtrasAfterDAF");
40 
41  TrajAnnSaving_ = iConfig.getParameter<bool>("TrajAnnealingSaving");
42 }
43 
45  edm::LogInfo("DAFTrackProducer") << "Analyzing event number: " << theEvent.id() << "\n";
46 
47  //empty output collections
48  std::unique_ptr<TrackingRecHitCollection> outputRHColl(new TrackingRecHitCollection);
49  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
50  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
51  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
52  std::unique_ptr<TrajAnnealingCollection> outputTrajAnnColl(new TrajAnnealingCollection);
53  std::unique_ptr<std::vector<int> > outputIndecesInputColl(new std::vector<int>);
54 
55  //new tracks collections (changes before and after DAF)
56  std::unique_ptr<TrackingRecHitCollection> outputRHCollBeforeDAF(new TrackingRecHitCollection);
57  std::unique_ptr<reco::TrackCollection> outputTCollBeforeDAF(new reco::TrackCollection);
58  std::unique_ptr<reco::TrackExtraCollection> outputTECollBeforeDAF(new reco::TrackExtraCollection);
59  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryCollBeforeDAF(new std::vector<Trajectory>);
60  std::unique_ptr<std::vector<int> > outputIndecesInputCollBeforeDAF(new std::vector<int>);
61  //----
62  std::unique_ptr<TrackingRecHitCollection> outputRHCollAfterDAF(new TrackingRecHitCollection);
63  std::unique_ptr<reco::TrackCollection> outputTCollAfterDAF(new reco::TrackCollection);
64  std::unique_ptr<reco::TrackExtraCollection> outputTECollAfterDAF(new reco::TrackExtraCollection);
65  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryCollAfterDAF(new std::vector<Trajectory>);
66  std::unique_ptr<std::vector<int> > outputIndecesInputCollAfterDAF(new std::vector<int>);
67 
68  //declare and get stuff to be retrieved from ES
72  edm::ESHandle<Propagator> thePropagator;
75  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
76 
78  setup.get<TrackerTopologyRcd>().get(httopo);
79 
80  //get additional es_modules needed by the DAF
81  edm::ESHandle<MultiRecHitCollector> measurementCollectorHandle;
82  std::string measurementCollectorName = getConf().getParameter<std::string>("MeasurementCollector");
83  setup.get<MultiRecHitRecord>().get(measurementCollectorName, measurementCollectorHandle);
85  std::string updatorName = getConf().getParameter<std::string>("UpdatorName");
86  setup.get<MultiRecHitRecord>().get(updatorName, updatorHandle);
87 
88  //get MeasurementTrackerEvent
90  theEvent.getByToken(mteSrc_, mte);
91 
92  //declare and get TrackCollection
93  AlgoProductCollection algoResults;
95  TrajAnnealingCollection trajannResults;
96 
97  //declare and get new tracks collections
98  AlgoProductCollection algoResultsBeforeDAF;
99  AlgoProductCollection algoResultsAfterDAF;
100  try {
101  edm::Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
102  getFromEvt(theEvent, trajTrackAssociationHandle, bs);
103 
104  //run the algorithm
105  LogDebug("DAFTrackProducer") << "run the DAF algorithm"
106  << "\n";
108  theMF.product(),
109  *trajTrackAssociationHandle,
110  &*mte,
111  theFitter.product(),
112  theBuilder.product(),
113  measurementCollectorHandle.product(),
114  updatorHandle.product(),
115  bs,
116  algoResults,
117  trajannResults,
119  algoResultsBeforeDAF,
120  algoResultsAfterDAF);
121 
122  } catch (cms::Exception& e) {
123  edm::LogInfo("DAFTrackProducer") << "cms::Exception caught!!!"
124  << "\n"
125  << e << "\n";
126  throw;
127  }
128 
129  //put everything in the event
130  putInEvt(theEvent,
131  thePropagator.product(),
132  theMeasTk.product(),
133  outputRHColl,
134  outputTColl,
135  outputTEColl,
136  outputTrajectoryColl,
137  outputIndecesInputColl,
138  algoResults,
139  theBuilder.product(),
140  httopo.product());
141  putInEvtTrajAnn(theEvent, trajannResults, outputTrajAnnColl);
142 
143  //put in theEvent before and after DAF tracks collections
144  putInEvt(theEvent,
145  thePropagator.product(),
146  theMeasTk.product(),
147  outputRHCollBeforeDAF,
148  outputTCollBeforeDAF,
149  outputTECollBeforeDAF,
150  outputTrajectoryCollBeforeDAF,
151  outputIndecesInputCollBeforeDAF,
152  algoResultsBeforeDAF,
153  theBuilder.product(),
154  httopo.product(),
155  1);
156  putInEvt(theEvent,
157  thePropagator.product(),
158  theMeasTk.product(),
159  outputRHCollAfterDAF,
160  outputTCollAfterDAF,
161  outputTECollAfterDAF,
162  outputTrajectoryCollAfterDAF,
163  outputIndecesInputCollAfterDAF,
164  algoResultsAfterDAF,
165  theBuilder.product(),
166  httopo.product(),
167  2);
168 
169  LogDebug("DAFTrackProducer") << "end the DAF algorithm."
170  << "\n";
171 }
172 //----------------------------------------------------------------------------------------------------------//
174  edm::Handle<TrajTrackAssociationCollection>& trajTrackAssociationHandle,
175  reco::BeamSpot& bs) {
176  //get the TrajTrackMap from the event
177  //WARNING: src has always to be redefined in cfg file
178  theEvent.getByToken(srcTT_, trajTrackAssociationHandle);
179 
180  //get the BeamSpot
181  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
182  theEvent.getByToken(bsSrc_, recoBeamSpotHandle);
183  bs = *recoBeamSpotHandle;
184 }
185 //----------------------------------------------------------------------------------------------------------//
187  TrajAnnealingCollection& trajannResults,
188  std::unique_ptr<TrajAnnealingCollection>& outputTrajAnnColl) {
189  const int size = trajannResults.size();
190  outputTrajAnnColl->reserve(size);
191 
192  for (unsigned int i = 0; i < trajannResults.size(); i++) {
193  outputTrajAnnColl->push_back(trajannResults[i]);
194  }
195 
196  theEvent.put(std::move(outputTrajAnnColl));
197 }
Propagator.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TrackProducerBase< reco::Track >::getFromES
virtual void getFromES(const edm::EventSetup &, edm::ESHandle< TrackerGeometry > &, edm::ESHandle< MagneticField > &, edm::ESHandle< TrajectoryFitter > &, edm::ESHandle< Propagator > &, edm::ESHandle< MeasurementTracker > &, edm::ESHandle< TransientTrackingRecHitBuilder > &)
Get needed services from the Event Setup.
MultiRecHitRecord
Definition: MultiRecHitRecord.h:12
TrajAnnealingCollection
std::vector< TrajAnnealing > TrajAnnealingCollection
Definition: TrajAnnealing.h:36
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
TrackerGeometry.h
TrackProducerBase< reco::Track >::setConf
void setConf(const edm::ParameterSet &conf)
Set parameter set.
Definition: TrackProducerBase.h:71
DAFTrackProducer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< MeasurementTrackerEvent >
AlgoProductTraits< reco::Track >::AlgoProductCollection
std::vector< AlgoProduct > AlgoProductCollection
Definition: AlgoProductTraits.h:20
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TrackProducerBase< reco::Track >::getConf
const edm::ParameterSet & getConf() const
Definition: TrackProducerBase.h:100
KfTrackProducerBase
Definition: KfTrackProducerBase.h:16
MakerMacros.h
TrackerTopology.h
cms::cuda::bs
bs
Definition: HistoContainer.h:127
TrackerTopologyRcd.h
DAFTrackProducer::getFromEvt
void getFromEvt(edm::Event &, edm::Handle< TrajTrackAssociationCollection > &, reco::BeamSpot &)
Definition: DAFTrackProducer.cc:173
reco::BeamSpot
Definition: BeamSpot.h:21
edm::ESHandle< TrackerGeometry >
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
TrackProducerBase< reco::Track >::setAlias
void setAlias(std::string alias)
set the aliases of produced collections
Definition: TrackProducerBase.h:83
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
TrajTrackAssociation.h
TrajAnnealing.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DAFTrackProducer::DAFTrackProducer
DAFTrackProducer(const edm::ParameterSet &iConfig)
Definition: DAFTrackProducer.cc:20
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
KfTrackProducerBase::putInEvt
virtual void putInEvt(edm::Event &, const Propagator *prop, const MeasurementTracker *measTk, std::unique_ptr< TrackingRecHitCollection > &, std::unique_ptr< reco::TrackCollection > &, std::unique_ptr< reco::TrackExtraCollection > &, std::unique_ptr< std::vector< Trajectory > > &, std::unique_ptr< std::vector< int > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *, const TrackerTopology *ttopo, int BeforeOrAfter=0)
Put produced collections in the event.
Definition: KfTrackProducerBase.cc:21
TrackProducerBase< reco::Track >::alias_
std::string alias_
Definition: TrackProducerBase.h:107
DAFTrackProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Method where the procduction take place. To be implemented in concrete classes.
Definition: DAFTrackProducer.cc:44
DAFTrackProducer::srcTT_
edm::EDGetToken srcTT_
Definition: DAFTrackProducer.h:35
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
DAFTrackProducerAlgorithm::runWithCandidate
void runWithCandidate(const TrackingGeometry *, const MagneticField *, const TrajTrackAssociationCollection &, const MeasurementTrackerEvent *measTk, const TrajectoryFitter *, const TransientTrackingRecHitBuilder *, const MultiRecHitCollector *measurementTracker, const SiTrackerMultiRecHitUpdator *, const reco::BeamSpot &, AlgoProductCollection &, TrajAnnealingCollection &, bool, AlgoProductCollection &, AlgoProductCollection &) const
Run the Final Fit taking TrackCandidates as input.
Definition: DAFTrackProducerAlgorithm.cc:30
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
TrackProducerBase< reco::Track >::setSrc
void setSrc(const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
set label of source collection
Definition: TrackProducerBase.h:74
DAFTrackProducer::TrajAnnSaving_
bool TrajAnnSaving_
Definition: DAFTrackProducer.h:34
TrackProducerBase< reco::Track >::bsSrc_
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
Definition: TrackProducerBase.h:110
Trajectory.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
MultiRecHitCollector.h
Frameworkfwd.h
TrackProducerBase< reco::Track >::mteSrc_
edm::EDGetTokenT< MeasurementTrackerEvent > mteSrc_
Definition: TrackProducerBase.h:111
TrackingComponentsRecord.h
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
MultiRecHitRecord.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DAFTrackProducer::putInEvtTrajAnn
void putInEvtTrajAnn(edm::Event &theEvent, TrajAnnealingCollection &trajannResults, std::unique_ptr< TrajAnnealingCollection > &selTrajAnn)
Definition: DAFTrackProducer.cc:186
cms::Exception
Definition: Exception.h:70
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
SiTrackerMultiRecHitUpdator.h
edm::OwnVector< TrackingRecHit >
DAFTrackProducer::theAlgo
DAFTrackProducerAlgorithm theAlgo
Definition: DAFTrackProducer.h:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37