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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void setupDetIdPipes (const edm::EventSetup &eventSetup)
 

Private Attributes

std::map< unsigned int, TrackingRecHitPipe_detIdPipes
 
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms
 
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
 
unsigned long long _trackerGeometryCacheID = 0
 
unsigned long long _trackerTopologyCacheID = 0
 
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcdsiPixelTemplateDBObjectESToken_
 
const edm::ESGetToken< std::vector< SiPixelTemplateStore >, SiPixelTemplateDBObjectESProducerRcdsiPixelTemplateStoreESToken_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeometryESToken_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtrackerTopologyESToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 43 of file TrackingRecHitProducer.cc.

Constructor & Destructor Documentation

◆ TrackingRecHitProducer()

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

Definition at line 71 of file TrackingRecHitProducer.cc.

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

72  : siPixelTemplateDBObjectESToken_(esConsumes<edm::Transition::BeginRun>()),
73  siPixelTemplateStoreESToken_(esConsumes<edm::Transition::BeginRun>()),
76  edm::ConsumesCollector consumeCollector = consumesCollector();
77  const std::vector<edm::ParameterSet>& pluginConfigs = config.getParameter<std::vector<edm::ParameterSet>>("plugins");
78 
79  for (unsigned int iplugin = 0; iplugin < pluginConfigs.size(); ++iplugin) {
80  const edm::ParameterSet& pluginConfig = pluginConfigs[iplugin];
81  const std::string pluginType = pluginConfig.getParameter<std::string>("type");
82  const std::string pluginName = pluginConfig.getParameter<std::string>("name");
83 
84  std::unique_ptr<TrackingRecHitAlgorithm> recHitAlgorithm{
85  TrackingRecHitAlgorithmFactory::get()->tryToCreate(pluginType, pluginName, pluginConfig, consumeCollector)};
86  if (recHitAlgorithm) {
87  edm::LogInfo("TrackingRecHitProducer: ")
88  << "adding plugin type '" << pluginType << "' as '" << pluginName << "'" << std::endl;
89  _recHitAlgorithms.push_back(std::move(recHitAlgorithm));
90  } else {
91  throw cms::Exception("TrackingRecHitAlgorithm plugin not found: ")
92  << "plugin type = " << pluginType << "\nconfiguration=\n"
93  << pluginConfig.dump();
94  }
95  }
96 
97  edm::InputTag simHitTag = config.getParameter<edm::InputTag>("simHits");
98  _simHitToken = consumes<std::vector<PSimHit>>(simHitTag);
99 
100  produces<FastTrackerRecHitCollection>();
101  produces<FastTrackerRecHitRefCollection>("simHit2RecHitMap");
102 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_
edm::EDGetTokenT< std::vector< PSimHit > > _simHitToken
Definition: config.py:1
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryESToken_
Log< level::Info, false > LogInfo
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > siPixelTemplateDBObjectESToken_
const edm::ESGetToken< std::vector< SiPixelTemplateStore >, SiPixelTemplateDBObjectESProducerRcd > siPixelTemplateStoreESToken_
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms
#define get
def move(src, dest)
Definition: eostools.py:511

◆ ~TrackingRecHitProducer()

TrackingRecHitProducer::~TrackingRecHitProducer ( )
override

Definition at line 104 of file TrackingRecHitProducer.cc.

104 {}

Member Function Documentation

◆ beginRun()

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

Definition at line 112 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms, options_cfi::eventSetup, writedatasetfile::run, siPixelTemplateDBObjectESToken_, and siPixelTemplateStoreESToken_.

112  {
113  //--- Since all pixel algorithms (of which there could be several) use the same
114  // templateStore, filled out from the same DB Object, we need to it centrally
115  // (namely here), and then distribute it to the algorithms. Note that only
116  // the pixel algorithms implement beginRun(), for the strip tracker this defaults
117  // to a no-op.
118 
119  const SiPixelTemplateDBObject& pixelTemplateDBObject = eventSetup.getData(siPixelTemplateDBObjectESToken_);
120  const auto& pixelTemplateStore = eventSetup.getData(siPixelTemplateStoreESToken_);
121 
122  for (auto& algo : _recHitAlgorithms) {
123  algo->beginRun(run, eventSetup, &pixelTemplateDBObject, pixelTemplateStore);
124  }
125 }
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > siPixelTemplateDBObjectESToken_
const edm::ESGetToken< std::vector< SiPixelTemplateStore >, SiPixelTemplateDBObjectESProducerRcd > siPixelTemplateStoreESToken_
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms

◆ beginStream()

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

Definition at line 106 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms.

106  {
107  for (auto& algo : _recHitAlgorithms) {
108  algo->beginStream(id);
109  }
110 }
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms

◆ endStream()

void TrackingRecHitProducer::endStream ( )
override

Definition at line 246 of file TrackingRecHitProducer.cc.

References _recHitAlgorithms.

246  {
247  for (auto& algo : _recHitAlgorithms) {
248  algo->endStream();
249  }
250 }
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms

◆ produce()

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

Definition at line 164 of file TrackingRecHitProducer.cc.

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

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

◆ setupDetIdPipes()

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

Definition at line 127 of file TrackingRecHitProducer.cc.

References _detIdPipes, _recHitAlgorithms, _trackerGeometryCacheID, _trackerTopologyCacheID, edm::eventsetup::EventSetupRecord::cacheIdentifier(), TrackerGeometry::detIds(), options_cfi::eventSetup, Exception, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), or, pipe::pipe(), TrackerTopology::print(), collectionMerger::selector, trackerGeometryESToken_, and trackerTopologyESToken_.

Referenced by produce().

127  {
128  auto const& trackerGeomRec = eventSetup.get<TrackerDigiGeometryRecord>();
129  auto const& trackerTopoRec = eventSetup.get<TrackerTopologyRcd>();
130  if (trackerGeomRec.cacheIdentifier() != _trackerGeometryCacheID or
131  trackerTopoRec.cacheIdentifier() != _trackerTopologyCacheID) {
132  _trackerGeometryCacheID = trackerGeomRec.cacheIdentifier();
133  _trackerTopologyCacheID = trackerTopoRec.cacheIdentifier();
134 
135  const TrackerGeometry& trackerGeometry = trackerGeomRec.get(trackerGeometryESToken_);
136  const TrackerTopology& trackerTopology = trackerTopoRec.get(trackerTopologyESToken_);
137 
138  _detIdPipes.clear();
139 
140  //build pipes for all detIds
141  const std::vector<DetId>& detIds = trackerGeometry.detIds();
142  std::vector<unsigned int> numberOfDetIdsPerAlgorithm(_recHitAlgorithms.size(), 0);
143 
144  for (const DetId& detId : detIds) {
145  TrackerDetIdSelector selector(detId, trackerTopology);
146 
148  for (unsigned int ialgo = 0; ialgo < _recHitAlgorithms.size(); ++ialgo) {
149  auto& algo = _recHitAlgorithms[ialgo];
150  if (selector.passSelection(algo->getSelectionString())) {
151  numberOfDetIdsPerAlgorithm[ialgo] += 1;
152  pipe.addAlgorithm(algo.get());
153  }
154  }
155  if (pipe.size() == 0) {
156  throw cms::Exception("FastSimulation/TrackingRecHitProducer: DetId not configured! (" +
157  trackerTopology.print(detId) + ")");
158  }
159  _detIdPipes[detId.rawId()] = pipe;
160  }
161  }
162 }
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
std::string print(DetId detid) const
std::map< unsigned int, TrackingRecHitPipe > _detIdPipes
unsigned long long _trackerGeometryCacheID
unsigned long long cacheIdentifier() const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryESToken_
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
def pipe(cmdline, input=None)
Definition: pipe.py:5
Definition: DetId.h:17
std::vector< std::unique_ptr< TrackingRecHitAlgorithm > > _recHitAlgorithms
unsigned long long _trackerTopologyCacheID
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: pipe.py:1

Member Data Documentation

◆ _detIdPipes

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

Definition at line 49 of file TrackingRecHitProducer.cc.

Referenced by produce(), and setupDetIdPipes().

◆ _recHitAlgorithms

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

◆ _simHitToken

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

Definition at line 45 of file TrackingRecHitProducer.cc.

Referenced by produce(), and TrackingRecHitProducer().

◆ _trackerGeometryCacheID

unsigned long long TrackingRecHitProducer::_trackerGeometryCacheID = 0
private

Definition at line 47 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

◆ _trackerTopologyCacheID

unsigned long long TrackingRecHitProducer::_trackerTopologyCacheID = 0
private

Definition at line 48 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

◆ siPixelTemplateDBObjectESToken_

const edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd> TrackingRecHitProducer::siPixelTemplateDBObjectESToken_
private

Definition at line 51 of file TrackingRecHitProducer.cc.

Referenced by beginRun().

◆ siPixelTemplateStoreESToken_

const edm::ESGetToken<std::vector<SiPixelTemplateStore>, SiPixelTemplateDBObjectESProducerRcd> TrackingRecHitProducer::siPixelTemplateStoreESToken_
private

Definition at line 53 of file TrackingRecHitProducer.cc.

Referenced by beginRun().

◆ trackerGeometryESToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> TrackingRecHitProducer::trackerGeometryESToken_
private

Definition at line 54 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().

◆ trackerTopologyESToken_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> TrackingRecHitProducer::trackerTopologyESToken_
private

Definition at line 55 of file TrackingRecHitProducer.cc.

Referenced by setupDetIdPipes().