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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () 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< std::unique_ptr< 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::TrackingRecHitProducer ( const edm::ParameterSet config)

Definition at line 68 of file TrackingRecHitProducer.cc.

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

References _recHitAlgorithms, _simHitToken, Exception, get, eostools::move(), TrackingRecHitProducer_cfi::pluginConfig, validationMuonRPCDigis_cfi::simHitTag, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~TrackingRecHitProducer()

TrackingRecHitProducer::~TrackingRecHitProducer ( )
override

Definition at line 97 of file TrackingRecHitProducer.cc.

97  {
98  //--- Delete the templates. This is safe even if thePixelTemp_ vector is empty.
99  for (auto x : _pixelTempStore)
100  x.destroy();
101 }

References _pixelTempStore, and x.

Member Function Documentation

◆ beginRun()

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

Definition at line 109 of file TrackingRecHitProducer.cc.

109  {
110  //--- Since all pixel algorithms (of which there could be several) use the same
111  // templateStore, filled out from the same DB Object, we need to it centrally
112  // (namely here), and then distribute it to the algorithms. Note that only
113  // the pixel algorithms implement beginRun(), for the strip tracker this defaults
114  // to a no-op.
115 
117  eventSetup.get<SiPixelTemplateDBObjectESProducerRcd>().get(templateDBobject);
118  const SiPixelTemplateDBObject* pixelTemplateDBObject = templateDBobject.product();
119 
120  //--- Now that we have the DB object, load the correct templates from the DB.
121  // (They are needed for data and full sim MC, so in a production FastSim
122  // run, everything should already be in the DB.)
123  if (!SiPixelTemplate::pushfile(*pixelTemplateDBObject, _pixelTempStore)) {
124  throw cms::Exception("TrackingRecHitProducer:")
125  << "SiPixel Templates not loaded correctly from the DB object!" << std::endl;
126  }
127 
128  for (auto& algo : _recHitAlgorithms) {
129  algo->beginRun(run, eventSetup, pixelTemplateDBObject, _pixelTempStore);
130  }
131 }

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

◆ beginStream()

void TrackingRecHitProducer::beginStream ( edm::StreamID  id)
override

Definition at line 103 of file TrackingRecHitProducer.cc.

103  {
104  for (auto& algo : _recHitAlgorithms) {
105  algo->beginStream(id);
106  }
107 }

References _recHitAlgorithms.

◆ endStream()

void TrackingRecHitProducer::endStream ( )
override

Definition at line 255 of file TrackingRecHitProducer.cc.

255  {
256  for (auto& algo : _recHitAlgorithms) {
257  algo->endStream();
258  }
259 }

References _recHitAlgorithms.

◆ produce()

void TrackingRecHitProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

Definition at line 173 of file TrackingRecHitProducer.cc.

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

References _detIdPipes, _recHitAlgorithms, _simHitToken, Exception, dqmdumpme::first, eostools::move(), setupDetIdPipes(), rpcPointValidation_cfi::simHit, FastTrackerRecHitCombiner_cfi::simHits, and edm::OwnVector< T, P >::size().

◆ setupDetIdPipes()

void TrackingRecHitProducer::setupDetIdPipes ( const edm::EventSetup eventSetup)
private

Definition at line 133 of file TrackingRecHitProducer.cc.

133  {
134  auto const& trackerGeomRec = eventSetup.get<TrackerDigiGeometryRecord>();
135  auto const& trackerTopoRec = eventSetup.get<TrackerTopologyRcd>();
136  if (trackerGeomRec.cacheIdentifier() != _trackerGeometryCacheID or
137  trackerTopoRec.cacheIdentifier() != _trackerTopologyCacheID) {
138  _trackerGeometryCacheID = trackerGeomRec.cacheIdentifier();
139  _trackerTopologyCacheID = trackerTopoRec.cacheIdentifier();
140  edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
141  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
142  trackerGeomRec.get(trackerGeometryHandle);
143  trackerTopoRec.get(trackerTopologyHandle);
144  const TrackerGeometry* trackerGeometry = trackerGeometryHandle.product();
145  const TrackerTopology* trackerTopology = trackerTopologyHandle.product();
146 
147  _detIdPipes.clear();
148 
149  //build pipes for all detIds
150  const std::vector<DetId>& detIds = trackerGeometry->detIds();
151  std::vector<unsigned int> numberOfDetIdsPerAlgorithm(_recHitAlgorithms.size(), 0);
152 
153  for (const DetId& detId : detIds) {
154  TrackerDetIdSelector selector(detId, *trackerTopology);
155 
157  for (unsigned int ialgo = 0; ialgo < _recHitAlgorithms.size(); ++ialgo) {
158  auto& algo = _recHitAlgorithms[ialgo];
159  if (selector.passSelection(algo->getSelectionString())) {
160  numberOfDetIdsPerAlgorithm[ialgo] += 1;
161  pipe.addAlgorithm(algo.get());
162  }
163  }
164  if (pipe.size() == 0) {
165  throw cms::Exception("FastSimulation/TrackingRecHitProducer: DetId not configured! (" +
166  trackerTopology->print(detId) + ")");
167  }
168  _detIdPipes[detId.rawId()] = pipe;
169  }
170  }
171 }

References _detIdPipes, _recHitAlgorithms, _trackerGeometryCacheID, _trackerTopologyCacheID, edm::eventsetup::EventSetupRecord::cacheIdentifier(), TrackerGeometry::detIds(), Exception, edm::EventSetup::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), or, TrackerDetIdSelector::passSelection(), pipe::pipe(), TrackerTopology::print(), and edm::ESHandle< T >::product().

Referenced by produce().

Member Data Documentation

◆ _detIdPipes

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

Definition at line 50 of file TrackingRecHitProducer.cc.

Referenced by produce(), and setupDetIdPipes().

◆ _pixelTempStore

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

Definition at line 52 of file TrackingRecHitProducer.cc.

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

◆ _recHitAlgorithms

std::vector<std::unique_ptr<TrackingRecHitAlgorithm> > TrackingRecHitProducer::_recHitAlgorithms
private

◆ _simHitToken

edm::EDGetTokenT<std::vector<PSimHit> > TrackingRecHitProducer::_simHitToken
private

Definition at line 46 of file TrackingRecHitProducer.cc.

Referenced by produce(), and TrackingRecHitProducer().

◆ _trackerGeometryCacheID

unsigned long long TrackingRecHitProducer::_trackerGeometryCacheID = 0
private

Definition at line 48 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

◆ _trackerTopologyCacheID

unsigned long long TrackingRecHitProducer::_trackerTopologyCacheID = 0
private

Definition at line 49 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

edm::RefProd
Definition: EDProductfwd.h:25
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
validationMuonRPCDigis_cfi.simHitTag
simHitTag
Definition: validationMuonRPCDigis_cfi.py:9
SiPixelTemplate::pushfile
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
Definition: SiPixelTemplate.cc:129
TrackerTopology
Definition: TrackerTopology.h:16
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TrackingRecHitProducer::_trackerTopologyCacheID
unsigned long long _trackerTopologyCacheID
Definition: TrackingRecHitProducer.cc:49
edm::Handle
Definition: AssociativeIterator.h:50
dqmdumpme.first
first
Definition: dqmdumpme.py:55
config
Definition: config.py:1
DetId
Definition: DetId.h:17
cmsdt::algo
algo
Definition: constants.h:164
TrackingRecHitPipe
Definition: TrackingRecHitPipe.h:9
TrackingRecHitProductPtr
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
Definition: TrackingRecHitProduct.h:47
TrackingRecHitProducer::_recHitAlgorithms
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms
Definition: TrackingRecHitProducer.cc:47
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
TrackerDetIdSelector
Definition: TrackerDetIdSelector.h:94
FastTrackerRecHitRef
edm::Ref< FastTrackerRecHitCollection > FastTrackerRecHitRef
Definition: FastTrackerRecHitCollection.h:9
edm::ESHandle
Definition: DTSurvey.h:22
TrackerTopology::print
std::string print(DetId detid) const
Definition: TrackerTopology.cc:252
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:103
pipe
Definition: pipe.py:1
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
FastSingleTrackerRecHit
Definition: FastSingleTrackerRecHit.h:7
SiPixelTemplateDBObject
Definition: SiPixelTemplateDBObject.h:16
TrackingRecHitProducer::setupDetIdPipes
void setupDetIdPipes(const edm::EventSetup &eventSetup)
Definition: TrackingRecHitProducer.cc:133
TrackingRecHitProducer::_pixelTempStore
std::vector< SiPixelTemplateStore > _pixelTempStore
Definition: TrackingRecHitProducer.cc:52
get
#define get
SiPixelTemplateDBObjectESProducerRcd
Definition: SiPixelTemplateDBObjectESProducerRcd.h:11
TrackingRecHitProducer::_detIdPipes
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
Definition: TrackingRecHitProducer.cc:50
TrackingRecHitProducer_cfi.pluginConfig
pluginConfig
Definition: TrackingRecHitProducer_cfi.py:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TrackingRecHitProducer::_trackerGeometryCacheID
unsigned long long _trackerGeometryCacheID
Definition: TrackingRecHitProducer.cc:48
Exception
Definition: hltDiff.cc:246
or
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
TrackerGeometry::detIds
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
Definition: TrackerGeometry.h:64
TrackingRecHitProducer::_simHitToken
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
Definition: TrackingRecHitProducer.cc:46
edm::eventsetup::EventSetupRecord::cacheIdentifier
unsigned long long cacheIdentifier() const
Definition: EventSetupRecord.h:184
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
pipe.pipe
def pipe(cmdline, input=None)
Definition: pipe.py:5
PSimHit
Definition: PSimHit.h:15
event
Definition: event.py:1
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
edm::OwnVector
Definition: OwnVector.h:24
TrackerGeometry
Definition: TrackerGeometry.h:14