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

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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void setupDetIdPipes (const edm::EventSetup &eventSetup)
 

Private Attributes

std::map< unsigned int, TrackingRecHitPipe_detIdPipes
 
std::vector< SiPixelTemplateStore_pixelTempStore
 
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
 

Detailed Description

Definition at line 44 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::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
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 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
T get() const
Definition: EventSetup.h:63
std::vector< SiPixelTemplateStore > _pixelTempStore
T const * product() const
Definition: ESHandle.h:86
void TrackingRecHitProducer::beginStream ( edm::StreamID  id)
override

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

Definition at line 278 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, patPFMETCorrections_cff::algo, and DEFINE_FWK_MODULE.

279 {
281  {
282  algo->endStream();
283  }
284 }
std::vector< TrackingRecHitAlgorithm * > _recHitAlgorithms
void TrackingRecHitProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

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

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

149 {
150  auto const& trackerGeomRec = eventSetup.get<TrackerDigiGeometryRecord>();
151  auto const& trackerTopoRec = eventSetup.get<TrackerTopologyRcd>();
152  if (trackerGeomRec.cacheIdentifier() != _trackerGeometryCacheID or
153  trackerTopoRec.cacheIdentifier() != _trackerTopologyCacheID )
154  {
155  _trackerGeometryCacheID = trackerGeomRec.cacheIdentifier();
156  _trackerTopologyCacheID = trackerTopoRec.cacheIdentifier();
157  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
158  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
159  trackerGeomRec.get(trackerGeometryHandle);
160  trackerTopoRec.get(trackerTopologyHandle);
161  const TrackerGeometry* trackerGeometry = trackerGeometryHandle.product();
162  const TrackerTopology* trackerTopology = trackerTopologyHandle.product();
163 
164  _detIdPipes.clear();
165 
166  //build pipes for all detIds
167  const std::vector<DetId>& detIds = trackerGeometry->detIds();
168  std::vector<unsigned int> numberOfDetIdsPerAlgorithm(_recHitAlgorithms.size(),0);
169 
170  for (const DetId& detId: detIds)
171  {
172  TrackerDetIdSelector selector(detId,*trackerTopology);
173 
175  for (unsigned int ialgo = 0; ialgo < _recHitAlgorithms.size(); ++ialgo)
176  {
178  if (selector.passSelection(algo->getSelectionString()))
179  {
180  numberOfDetIdsPerAlgorithm[ialgo]+=1;
181  pipe.addAlgorithm(algo);
182  }
183  }
184  if (pipe.size()==0)
185  {
186  throw cms::Exception("FastSimulation/TrackingRecHitProducer: DetId not configured! ("+trackerTopology->print(detId)+")");
187  }
188  _detIdPipes[detId.rawId()]=pipe;
189  }
190  }
191 }
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
T get() const
Definition: EventSetup.h:63
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 52 of file TrackingRecHitProducer.cc.

Referenced by produce(), and 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 48 of file TrackingRecHitProducer.cc.

Referenced by produce(), and TrackingRecHitProducer().

unsigned long long TrackingRecHitProducer::_trackerGeometryCacheID = 0
private

Definition at line 50 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

unsigned long long TrackingRecHitProducer::_trackerTopologyCacheID = 0
private

Definition at line 51 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().