CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackingRecHitProducer Class Reference
Inheritance diagram for TrackingRecHitProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginRun (edm::Run const &, const edm::EventSetup &eventSetup) override
 
void beginStream (edm::StreamID id) override
 
void endStream () override
 
void produce (edm::Event &event, const edm::EventSetup &eventSetup) override
 
 TrackingRecHitProducer (const edm::ParameterSet &config)
 
 ~TrackingRecHitProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void setupDetIdPipes (const edm::EventSetup &eventSetup)
 

Private Attributes

std::map< unsigned int, TrackingRecHitPipe_detIdPipes
 
edm::IOVSyncValue _iovSyncValue
 
std::vector< SiPixelTemplateStore_pixelTempStore
 
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
 
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 45 of file TrackingRecHitProducer.cc.

Constructor & Destructor Documentation

TrackingRecHitProducer::TrackingRecHitProducer ( const edm::ParameterSet config)

Definition at line 71 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, _simHitToken, edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::dump(), Exception, reco::get(), edm::ParameterSet::getParameter(), validationMuonRPCDigis_cfi::simHitTag, and AlCaHLTBitMon_QueryRunRegistry::string.

72 {
73  edm::ConsumesCollector consumeCollector = consumesCollector();
74  const std::vector<edm::ParameterSet>& pluginConfigs = config.getParameter<std::vector<edm::ParameterSet>>("plugins");
75 
76  for (unsigned int iplugin = 0; iplugin<pluginConfigs.size(); ++iplugin)
77  {
78  const edm::ParameterSet& pluginConfig = pluginConfigs[iplugin];
79  const std::string pluginType = pluginConfig.getParameter<std::string>("type");
80  const std::string pluginName = pluginConfig.getParameter<std::string>("name");
81 
82  TrackingRecHitAlgorithm* recHitAlgorithm = TrackingRecHitAlgorithmFactory::get()->tryToCreate(pluginType,pluginName,pluginConfig,consumeCollector);
83  if (recHitAlgorithm)
84  {
85  edm::LogInfo("TrackingRecHitProducer: ")<< "adding plugin type '"<<pluginType<<"' as '"<<pluginName<<"'"<<std::endl;
86  _recHitAlgorithms.push_back(recHitAlgorithm);
87  }
88  else
89  {
90  throw cms::Exception("TrackingRecHitAlgorithm plugin not found: ") << "plugin type = "<<pluginType<<"\nconfiguration=\n"<<pluginConfig.dump();
91  }
92  }
93 
95  _simHitToken = consumes<std::vector<PSimHit>>(simHitTag);
96 
97  produces<FastTrackerRecHitCollection>();
98  produces<FastTrackerRecHitRefCollection>("simHit2RecHitMap");
99 }
T getParameter(std::string const &) const
std::string dump(unsigned int indent=0) const
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T get(const Candidate &c)
Definition: component.h:55
TrackingRecHitProducer::~TrackingRecHitProducer ( )
override

Definition at line 101 of file TrackingRecHitProducer.cc.

References _pixelTempStore, _recHitAlgorithms, patPFMETCorrections_cff::algo, and x.

102 {
104  {
105  delete algo;
106  }
107  _recHitAlgorithms.clear();
108 
109  //--- Delete the templates. This is safe even if thePixelTemp_ vector is empty.
110  for (auto x : _pixelTempStore) x.destroy();
111 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
std::vector< SiPixelTemplateStore > _pixelTempStore

Member Function Documentation

void TrackingRecHitProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup eventSetup 
)
override

Definition at line 122 of file TrackingRecHitProducer.cc.

References _pixelTempStore, _recHitAlgorithms, patPFMETCorrections_cff::algo, Exception, edm::EventSetup::get(), edm::ESHandle< T >::product(), and SiPixelTemplate::pushfile().

123 {
124  //--- Since all pixel algorithms (of which there could be several) use the same
125  // templateStore, filled out from the same DB Object, we need to it centrally
126  // (namely here), and then distribute it to the algorithms. Note that only
127  // the pixel algorithms implement beginRun(), for the strip tracker this defaults
128  // to a no-op.
129 
131  eventSetup.get<SiPixelTemplateDBObjectESProducerRcd>().get(templateDBobject);
132  const SiPixelTemplateDBObject * pixelTemplateDBObject = templateDBobject.product();
133 
134  //--- Now that we have the DB object, load the correct templates from the DB.
135  // (They are needed for data and full sim MC, so in a production FastSim
136  // run, everything should already be in the DB.)
137  if ( !SiPixelTemplate::pushfile( *pixelTemplateDBObject, _pixelTempStore ) ) {
138  throw cms::Exception("TrackingRecHitProducer:")
139  << "SiPixel Templates not loaded correctly from the DB object!" << std::endl;
140  }
141 
143  {
144  algo->beginRun(run, eventSetup, pixelTemplateDBObject, _pixelTempStore );
145  }
146 }
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
const T & get() const
Definition: EventSetup.h:55
std::vector< SiPixelTemplateStore > _pixelTempStore
T const * product() const
Definition: ESHandle.h:86
void TrackingRecHitProducer::beginStream ( edm::StreamID  id)
overridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 114 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, and patPFMETCorrections_cff::algo.

115 {
117  {
118  algo->beginStream(id);
119  }
120 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
void TrackingRecHitProducer::endStream ( )
overridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 274 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, patPFMETCorrections_cff::algo, and DEFINE_FWK_MODULE.

275 {
277  {
278  algo->endStream();
279  }
280 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
void TrackingRecHitProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

Definition at line 189 of file TrackingRecHitProducer.cc.

References _detIdPipes, _recHitAlgorithms, _simHitToken, patPFMETCorrections_cff::algo, PSimHit::detUnitId(), Exception, plotBeamSpotDB::first, eostools::move(), TrackingRecHitPipe::produce(), setupDetIdPipes(), rpcPointValidation_cfi::simHit, trackerHits::simHits, and edm::OwnVector< T, P >::size().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

190 {
191 
192 
193  //resetup pipes if new iov
194  setupDetIdPipes(eventSetup);
195  //begin event
197  {
198  algo->beginEvent(event,eventSetup);
199  }
200 
201  //build DetId -> PSimHit map
203  event.getByToken(_simHitToken,simHits);
204 
205  std::unique_ptr<FastTrackerRecHitCollection> output_recHits(new FastTrackerRecHitCollection);
206  output_recHits->reserve(simHits->size());
207 
208  edm::RefProd<FastTrackerRecHitCollection> output_recHits_refProd = event.getRefBeforePut<FastTrackerRecHitCollection>();
209  std::unique_ptr<FastTrackerRecHitRefCollection> output_recHitRefs(new FastTrackerRecHitRefCollection(simHits->size(),FastTrackerRecHitRef()));
210 
211  std::map<unsigned int,std::vector<std::pair<unsigned int,const PSimHit*>>> simHitsIdPairPerDetId;
212  for (unsigned int ihit = 0; ihit < simHits->size(); ++ihit)
213  {
214  const PSimHit* simHit = &(*simHits)[ihit];
215  simHitsIdPairPerDetId[simHit->detUnitId()].push_back(std::make_pair(ihit,simHit));
216  }
217 
218  for (auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end(); ++simHitsIdPairIt)
219  {
220  const DetId& detId = simHitsIdPairIt->first;
221  std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt = _detIdPipes.find(detId);
222  if (pipeIt!=_detIdPipes.cend())
223  {
224  auto& simHitIdPairList = simHitsIdPairIt->second;
225  const TrackingRecHitPipe& pipe = pipeIt->second;
226 
227  TrackingRecHitProductPtr product = std::make_shared<TrackingRecHitProduct>(detId,simHitIdPairList);
228 
229  product = pipe.produce(product);
230 
231  const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList = product->getRecHitToSimHitIdPairs();
232 
233 
234  for (unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit)
235  {
236  output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].first);
237  const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList = recHitToSimHitIdPairsList[irecHit].second;
238  for (unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit)
239  {
240  unsigned int simHitId = simHitIdPairList[isimHit].first;
241  if (not (*output_recHitRefs)[simHitId].isNull())
242  {
243  throw cms::Exception("FastSimulation/TrackingRecHitProducer","A PSimHit cannot lead to multiple FastTrackerRecHits");
244  }
245  (*output_recHitRefs)[simHitId] = FastTrackerRecHitRef(output_recHits_refProd,output_recHits->size()-1);
246  }
247  }
248  }
249  else
250  {
251  //there should be at least an empty pipe for each DetId
252  throw cms::Exception("FastSimulation/TrackingRecHitProducer","A PSimHit carries a DetId which does not belong to the TrackerGeometry: "+std::to_string(detId));
253  }
254  }
255 
256  //end event
257  for (TrackingRecHitAlgorithm* algo: _recHitAlgorithms)
258  {
259  algo->endEvent(event,eventSetup);
260  }
261 
262  // note from lukas:
263  // all rechits need a unique id numbers
264  for(unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex)
265  {
266  ((FastSingleTrackerRecHit*)&(*output_recHits)[recHitIndex])->setId(recHitIndex);
267  }
268 
269  event.put(std::move(output_recHits));
270  event.put(std::move(output_recHitRefs),"simHit2RecHitMap");
271 
272 }
void setupDetIdPipes(const edm::EventSetup &eventSetup)
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
size_type size() const
Definition: OwnVector.h:264
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
edm::Ref< FastTrackerRecHitCollection > FastTrackerRecHitRef
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
Definition: DetId.h:18
std::vector< FastTrackerRecHitRef > FastTrackerRecHitRefCollection
Definition: pipe.py:1
TrackingRecHitProductPtr produce(TrackingRecHitProductPtr product) const
def move(src, dest)
Definition: eostools.py:510
unsigned int detUnitId() const
Definition: PSimHit.h:93
void TrackingRecHitProducer::setupDetIdPipes ( const edm::EventSetup eventSetup)
private

Definition at line 148 of file TrackingRecHitProducer.cc.

References _detIdPipes, _iovSyncValue, _recHitAlgorithms, TrackingRecHitPipe::addAlgorithm(), patPFMETCorrections_cff::algo, TrackerGeometry::detIds(), Exception, edm::EventSetup::get(), TrackingRecHitAlgorithm::getSelectionString(), edm::EventSetup::iovSyncValue(), TrackerDetIdSelector::passSelection(), pipe::pipe(), TrackerTopology::print(), edm::ESHandle< T >::product(), and TrackingRecHitPipe::size().

Referenced by produce().

149 {
150  if (_iovSyncValue!=eventSetup.iovSyncValue())
151  {
152  _iovSyncValue=eventSetup.iovSyncValue();
153  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
154  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
155  eventSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometryHandle);
156  eventSetup.get<TrackerTopologyRcd>().get(trackerTopologyHandle);
157  const TrackerGeometry* trackerGeometry = trackerGeometryHandle.product();
158  const TrackerTopology* trackerTopology = trackerTopologyHandle.product();
159 
160  _detIdPipes.clear();
161 
162  //build pipes for all detIds
163  const std::vector<DetId>& detIds = trackerGeometry->detIds();
164  std::vector<unsigned int> numberOfDetIdsPerAlgorithm(_recHitAlgorithms.size(),0);
165 
166  for (const DetId& detId: detIds)
167  {
168  TrackerDetIdSelector selector(detId,*trackerTopology);
169 
171  for (unsigned int ialgo = 0; ialgo < _recHitAlgorithms.size(); ++ialgo)
172  {
174  if (selector.passSelection(algo->getSelectionString()))
175  {
176  numberOfDetIdsPerAlgorithm[ialgo]+=1;
177  pipe.addAlgorithm(algo);
178  }
179  }
180  if (pipe.size()==0)
181  {
182  throw cms::Exception("FastSimulation/TrackingRecHitProducer: DetId not configured! ("+trackerTopology->print(detId)+")");
183  }
184  _detIdPipes[detId.rawId()]=pipe;
185  }
186  }
187 }
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
void addAlgorithm(TrackingRecHitAlgorithm *algorithm)
std::string print(DetId detid) const
const std::string & getSelectionString() const
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
unsigned int size() const
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
def pipe(cmdline, input=None)
Definition: pipe.py:5
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
const IOVSyncValue & iovSyncValue() const
Definition: EventSetup.h:100
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

std::map<unsigned int, TrackingRecHitPipe> TrackingRecHitProducer::_detIdPipes
private

Definition at line 52 of file TrackingRecHitProducer.cc.

Referenced by produce(), and setupDetIdPipes().

edm::IOVSyncValue TrackingRecHitProducer::_iovSyncValue
private

Definition at line 51 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

std::vector< SiPixelTemplateStore > TrackingRecHitProducer::_pixelTempStore
private

Definition at line 54 of file TrackingRecHitProducer.cc.

Referenced by beginRun(), and ~TrackingRecHitProducer().

std::vector<TrackingRecHitAlgorithm*> TrackingRecHitProducer::_recHitAlgorithms
private
edm::EDGetTokenT<std::vector<PSimHit> > TrackingRecHitProducer::_simHitToken
private

Definition at line 49 of file TrackingRecHitProducer.cc.

Referenced by produce(), and TrackingRecHitProducer().