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

virtual void beginRun (edm::Run const &, const edm::EventSetup &eventSetup)
 
virtual void beginStream (edm::StreamID id)
 
virtual void endStream ()
 
virtual void produce (edm::Event &event, const edm::EventSetup &eventSetup)
 
 TrackingRecHitProducer (const edm::ParameterSet &config)
 
virtual ~TrackingRecHitProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > 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< 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
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 40 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 ( )
virtual

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 
)
virtual

Definition at line 112 of file TrackingRecHitProducer.cc.

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

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 ( )
virtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 243 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, patPFMETCorrections_cff::algo, and DEFINE_FWK_MODULE.

244 {
246  {
247  algo->endStream();
248  }
249 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
void TrackingRecHitProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

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

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

118 {
119  if (_iovSyncValue!=eventSetup.iovSyncValue())
120  {
121  _iovSyncValue=eventSetup.iovSyncValue();
122  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
123  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
124  eventSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometryHandle);
125  eventSetup.get<TrackerTopologyRcd>().get(trackerTopologyHandle);
126  const TrackerGeometry* trackerGeometry = trackerGeometryHandle.product();
127  const TrackerTopology* trackerTopology = trackerTopologyHandle.product();
128 
129  _detIdPipes.clear();
130 
131  //build pipes for all detIds
132  const std::vector<DetId>& detIds = trackerGeometry->detIds();
133  std::vector<unsigned int> numberOfDetIdsPerAlgorithm(_recHitAlgorithms.size(),0);
134 
135  for (const DetId& detId: detIds)
136  {
137  TrackerDetIdSelector selector(detId,*trackerTopology);
138 
140  for (unsigned int ialgo = 0; ialgo < _recHitAlgorithms.size(); ++ialgo)
141  {
143  if (selector.passSelection(algo->getSelectionString()))
144  {
145  numberOfDetIdsPerAlgorithm[ialgo]+=1;
146  pipe.addAlgorithm(algo);
147  }
148  }
149  if (pipe.size()==0)
150  {
151  throw cms::Exception("FastSimulation/TrackingRecHitProducer: DetId not configured! ("+trackerTopology->print(detId)+")");
152  }
153  _detIdPipes[detId.rawId()]=pipe;
154  }
155  }
156 }
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
def pipe(cmdline, input=None)
Definition: pipe.py:5
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:56
const IOVSyncValue & iovSyncValue() const
Definition: EventSetup.h:101
const DetIdContainer & detIds() const
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
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().

edm::IOVSyncValue TrackingRecHitProducer::_iovSyncValue
private

Definition at line 46 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

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

Definition at line 44 of file TrackingRecHitProducer.cc.

Referenced by produce(), and TrackingRecHitProducer().