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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) 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
 
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
 
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
 
unsigned long long _trackerGeometryCacheID = 0
 
unsigned long long _trackerTopologyCacheID = 0
 

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 39 of file TrackingRecHitProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 65 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.

66 {
67  edm::ConsumesCollector consumeCollector = consumesCollector();
68  const std::vector<edm::ParameterSet>& pluginConfigs = config.getParameter<std::vector<edm::ParameterSet>>("plugins");
69 
70  for (unsigned int iplugin = 0; iplugin<pluginConfigs.size(); ++iplugin)
71  {
72  const edm::ParameterSet& pluginConfig = pluginConfigs[iplugin];
73  const std::string pluginType = pluginConfig.getParameter<std::string>("type");
74  const std::string pluginName = pluginConfig.getParameter<std::string>("name");
75 
76  TrackingRecHitAlgorithm* recHitAlgorithm = TrackingRecHitAlgorithmFactory::get()->tryToCreate(pluginType,pluginName,pluginConfig,consumeCollector);
77  if (recHitAlgorithm)
78  {
79  edm::LogInfo("TrackingRecHitProducer: ")<< "adding plugin type '"<<pluginType<<"' as '"<<pluginName<<"'"<<std::endl;
80  _recHitAlgorithms.push_back(recHitAlgorithm);
81  }
82  else
83  {
84  throw cms::Exception("TrackingRecHitAlgorithm plugin not found: ") << "plugin type = "<<pluginType<<"\nconfiguration=\n"<<pluginConfig.dump();
85  }
86  }
87 
89  _simHitToken = consumes<std::vector<PSimHit>>(simHitTag);
90 
91  produces<FastTrackerRecHitCollection>();
92  produces<FastTrackerRecHitRefCollection>("simHit2RecHitMap");
93 }
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 95 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, and patPFMETCorrections_cff::algo.

96 {
98  {
99  delete algo;
100  }
101  _recHitAlgorithms.clear();
102 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms

Member Function Documentation

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

Definition at line 112 of file TrackingRecHitProducer.cc.

113 {
114 
115 }
void TrackingRecHitProducer::beginStream ( edm::StreamID  id)
overridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 104 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, and patPFMETCorrections_cff::algo.

105 {
107  {
108  algo->beginStream(id);
109  }
110 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
void TrackingRecHitProducer::endStream ( )
overridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 247 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, patPFMETCorrections_cff::algo, and DEFINE_FWK_MODULE.

248 {
250  {
251  algo->endStream();
252  }
253 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
void TrackingRecHitProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

Definition at line 162 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().

163 {
164 
165 
166  //resetup pipes if new iov
167  setupDetIdPipes(eventSetup);
168  //begin event
170  {
171  algo->beginEvent(event,eventSetup);
172  }
173 
174  //build DetId -> PSimHit map
176  event.getByToken(_simHitToken,simHits);
177 
178  std::unique_ptr<FastTrackerRecHitCollection> output_recHits(new FastTrackerRecHitCollection);
179  output_recHits->reserve(simHits->size());
180 
181  edm::RefProd<FastTrackerRecHitCollection> output_recHits_refProd = event.getRefBeforePut<FastTrackerRecHitCollection>();
182  std::unique_ptr<FastTrackerRecHitRefCollection> output_recHitRefs(new FastTrackerRecHitRefCollection(simHits->size(),FastTrackerRecHitRef()));
183 
184  std::map<unsigned int,std::vector<std::pair<unsigned int,const PSimHit*>>> simHitsIdPairPerDetId;
185  for (unsigned int ihit = 0; ihit < simHits->size(); ++ihit)
186  {
187  const PSimHit* simHit = &(*simHits)[ihit];
188  simHitsIdPairPerDetId[simHit->detUnitId()].push_back(std::make_pair(ihit,simHit));
189  }
190 
191  for (auto simHitsIdPairIt = simHitsIdPairPerDetId.begin(); simHitsIdPairIt != simHitsIdPairPerDetId.end(); ++simHitsIdPairIt)
192  {
193  const DetId& detId = simHitsIdPairIt->first;
194  std::map<unsigned int, TrackingRecHitPipe>::const_iterator pipeIt = _detIdPipes.find(detId);
195  if (pipeIt!=_detIdPipes.cend())
196  {
197  auto& simHitIdPairList = simHitsIdPairIt->second;
198  const TrackingRecHitPipe& pipe = pipeIt->second;
199 
200  TrackingRecHitProductPtr product = std::make_shared<TrackingRecHitProduct>(detId,simHitIdPairList);
201 
202  product = pipe.produce(product);
203 
204  const std::vector<TrackingRecHitProduct::RecHitToSimHitIdPairs>& recHitToSimHitIdPairsList = product->getRecHitToSimHitIdPairs();
205 
206 
207  for (unsigned int irecHit = 0; irecHit < recHitToSimHitIdPairsList.size(); ++irecHit)
208  {
209  output_recHits->push_back(recHitToSimHitIdPairsList[irecHit].first);
210  const std::vector<TrackingRecHitProduct::SimHitIdPair>& simHitIdPairList = recHitToSimHitIdPairsList[irecHit].second;
211  for (unsigned int isimHit = 0; isimHit < simHitIdPairList.size(); ++isimHit)
212  {
213  unsigned int simHitId = simHitIdPairList[isimHit].first;
214  if (not (*output_recHitRefs)[simHitId].isNull())
215  {
216  throw cms::Exception("FastSimulation/TrackingRecHitProducer","A PSimHit cannot lead to multiple FastTrackerRecHits");
217  }
218  (*output_recHitRefs)[simHitId] = FastTrackerRecHitRef(output_recHits_refProd,output_recHits->size()-1);
219  }
220  }
221  }
222  else
223  {
224  //there should be at least an empty pipe for each DetId
225  throw cms::Exception("FastSimulation/TrackingRecHitProducer","A PSimHit carries a DetId which does not belong to the TrackerGeometry: "+std::to_string(detId));
226  }
227  }
228 
229  //end event
230  for (TrackingRecHitAlgorithm* algo: _recHitAlgorithms)
231  {
232  algo->endEvent(event,eventSetup);
233  }
234 
235  // note from lukas:
236  // all rechits need a unique id numbers
237  for(unsigned recHitIndex = 0; recHitIndex < output_recHits->size(); ++recHitIndex)
238  {
239  ((FastSingleTrackerRecHit*)&(*output_recHits)[recHitIndex])->setId(recHitIndex);
240  }
241 
242  event.put(std::move(output_recHits));
243  event.put(std::move(output_recHitRefs),"simHit2RecHitMap");
244 
245 }
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 117 of file TrackingRecHitProducer.cc.

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

Referenced by produce().

118 {
119  auto const& trackerGeomRec = eventSetup.get<TrackerDigiGeometryRecord>();
120  auto const& trackerTopoRec = eventSetup.get<TrackerTopologyRcd>();
121  if (trackerGeomRec.cacheIdentifier() != _trackerGeometryCacheID or
122  trackerTopoRec.cacheIdentifier() != _trackerTopologyCacheID )
123  {
124  _trackerGeometryCacheID = trackerGeomRec.cacheIdentifier();
125  _trackerTopologyCacheID = trackerTopoRec.cacheIdentifier();
126  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
127  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
128  trackerGeomRec.get(trackerGeometryHandle);
129  trackerTopoRec.get(trackerTopologyHandle);
130  const TrackerGeometry* trackerGeometry = trackerGeometryHandle.product();
131  const TrackerTopology* trackerTopology = trackerTopologyHandle.product();
132 
133  _detIdPipes.clear();
134 
135  //build pipes for all detIds
136  const std::vector<DetId>& detIds = trackerGeometry->detIds();
137  std::vector<unsigned int> numberOfDetIdsPerAlgorithm(_recHitAlgorithms.size(),0);
138 
139  for (const DetId& detId: detIds)
140  {
141  TrackerDetIdSelector selector(detId,*trackerTopology);
142 
144  for (unsigned int ialgo = 0; ialgo < _recHitAlgorithms.size(); ++ialgo)
145  {
147  if (selector.passSelection(algo->getSelectionString()))
148  {
149  numberOfDetIdsPerAlgorithm[ialgo]+=1;
150  pipe.addAlgorithm(algo);
151  }
152  }
153  if (pipe.size()==0)
154  {
155  throw cms::Exception("FastSimulation/TrackingRecHitProducer: DetId not configured! ("+trackerTopology->print(detId)+")");
156  }
157  _detIdPipes[detId.rawId()]=pipe;
158  }
159  }
160 }
unsigned long long cacheIdentifier() const
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
void addAlgorithm(TrackingRecHitAlgorithm *algorithm)
std::string print(DetId detid) const
unsigned long long _trackerGeometryCacheID
const std::string & getSelectionString() const
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
unsigned int size() const
void get(HolderT &iHolder) 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:58
unsigned long long _trackerTopologyCacheID
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

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

Definition at line 47 of file TrackingRecHitProducer.cc.

Referenced by produce(), and setupDetIdPipes().

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

Definition at line 43 of file TrackingRecHitProducer.cc.

Referenced by produce(), and TrackingRecHitProducer().

unsigned long long TrackingRecHitProducer::_trackerGeometryCacheID = 0
private

Definition at line 45 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

unsigned long long TrackingRecHitProducer::_trackerTopologyCacheID = 0
private

Definition at line 46 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().