CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiPixelRawToClusterCUDA Class Reference
Inheritance diagram for SiPixelRawToClusterCUDA:
edm::stream::EDProducer< edm::ExternalWork >

Public Member Functions

 SiPixelRawToClusterCUDA (const edm::ParameterSet &iConfig)
 
 ~SiPixelRawToClusterCUDA () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork >
 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
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void acquire (const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

std::unique_ptr< SiPixelFedCablingTreecabling_
 
const SiPixelFedCablingMapcablingMap_ = nullptr
 
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcdcablingMapToken_
 
edm::EDPutTokenT< cms::cuda::Product< SiPixelClustersCUDA > > clusterPutToken_
 
const SiPixelClusterThresholds clusterThresholds_
 
cms::cuda::ContextState ctxState_
 
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigiErrorsCUDA > > digiErrorPutToken_
 
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigisCUDA > > digiPutToken_
 
PixelDataFormatter::Errors errors_
 
std::vector< unsigned int > fedIds_
 
edm::ESGetToken< SiPixelGainCalibrationForHLTGPU, SiPixelGainCalibrationForHLTGPURcdgainsToken_
 
pixelgpudetails::SiPixelRawToClusterGPUKernel gpuAlgo_
 
edm::ESGetToken< SiPixelROCsStatusAndMappingWrapper, CkfComponentsRecordgpuMapToken_
 
const bool includeErrors_
 
const bool isRun2_
 
uint32_t nDigis_
 
edm::EDGetTokenT< FEDRawDataCollectionrawGetToken_
 
edm::ESWatcher< SiPixelFedCablingMapRcdrecordWatcher_
 
std::unique_ptr< PixelUnpackingRegionsregions_
 
const bool useQuality_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork >
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 SiPixelRawToClusterCUDA.cc.

Constructor & Destructor Documentation

◆ SiPixelRawToClusterCUDA()

SiPixelRawToClusterCUDA::SiPixelRawToClusterCUDA ( const edm::ParameterSet iConfig)
explicit

Definition at line 84 of file SiPixelRawToClusterCUDA.cc.

References edm::ParameterSet::getParameter().

85  : rawGetToken_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("InputLabel"))),
88  gpuMapToken_(esConsumes<SiPixelROCsStatusAndMappingWrapper, CkfComponentsRecord>()),
89  gainsToken_(esConsumes<SiPixelGainCalibrationForHLTGPU, SiPixelGainCalibrationForHLTGPURcd>()),
90  cablingMapToken_(esConsumes<SiPixelFedCablingMap, SiPixelFedCablingMapRcd>(
91  edm::ESInputTag("", iConfig.getParameter<std::string>("CablingMapLabel")))),
92  isRun2_(iConfig.getParameter<bool>("isRun2")),
93  includeErrors_(iConfig.getParameter<bool>("IncludeErrors")),
94  useQuality_(iConfig.getParameter<bool>("UseQualityInfo")),
95  clusterThresholds_{iConfig.getParameter<int32_t>("clusterThreshold_layer1"),
96  iConfig.getParameter<int32_t>("clusterThreshold_otherLayers")} {
97  if (includeErrors_) {
98  digiErrorPutToken_ = produces<cms::cuda::Product<SiPixelDigiErrorsCUDA>>();
99  }
100 
101  // regions
102  if (!iConfig.getParameter<edm::ParameterSet>("Regions").getParameterNames().empty()) {
103  regions_ = std::make_unique<PixelUnpackingRegions>(iConfig, consumesCollector());
104  }
105 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigiErrorsCUDA > > digiErrorPutToken_
edm::ESGetToken< SiPixelGainCalibrationForHLTGPU, SiPixelGainCalibrationForHLTGPURcd > gainsToken_
edm::EDPutTokenT< cms::cuda::Product< SiPixelClustersCUDA > > clusterPutToken_
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigisCUDA > > digiPutToken_
const SiPixelClusterThresholds clusterThresholds_
std::unique_ptr< PixelUnpackingRegions > regions_
edm::ESGetToken< SiPixelROCsStatusAndMappingWrapper, CkfComponentsRecord > gpuMapToken_
edm::EDGetTokenT< FEDRawDataCollection > rawGetToken_
std::vector< std::string > getParameterNames() const
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > cablingMapToken_

◆ ~SiPixelRawToClusterCUDA()

SiPixelRawToClusterCUDA::~SiPixelRawToClusterCUDA ( )
overridedefault

Member Function Documentation

◆ acquire()

void SiPixelRawToClusterCUDA::acquire ( const edm::Event iEvent,
const edm::EventSetup iSetup,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder 
)
overrideprivate

Definition at line 132 of file SiPixelRawToClusterCUDA.cc.

References cms::cuda::assert(), cabling_, cablingMap_, cablingMapToken_, edm::ESWatcher< T >::check(), clusterThresholds_, ctxState_, errors_, Exception, l1tstage2_dqm_sourceclient-live_cfg::fedId, fedIds_, gainsToken_, edm::EventSetup::getHandle(), edm::EventSetup::getTransientHandle(), gpuAlgo_, gpuMapToken_, RecoTauValidation_cfi::header, mps_fire::i, iEvent, includeErrors_, pixelgpudetails::SiPixelRawToClusterGPUKernel::WordFedAppender::initializeWordFed(), edm::MessageDrop::instance(), isRun2_, LogDebug, pixelgpudetails::SiPixelRawToClusterGPUKernel::makeClustersAsync(), FEDNumbering::MINSiPixeluTCAFEDID, eostools::move(), nDigis_, l1ctLayer2EG_cff::nWords, l1tstage2_dqm_sourceclient-live_cfg::rawData, rawGetToken_, recordWatcher_, regions_, command_line::start, and useQuality_.

134  {
135  cms::cuda::ScopedContextAcquire ctx{iEvent.streamID(), std::move(waitingTaskHolder), ctxState_};
136 
137  auto hgpuMap = iSetup.getHandle(gpuMapToken_);
138  if (hgpuMap->hasQuality() != useQuality_) {
139  throw cms::Exception("LogicError")
140  << "UseQuality of the module (" << useQuality_
141  << ") differs the one from SiPixelROCsStatusAndMappingWrapper. Please fix your configuration.";
142  }
143  // get the GPU product already here so that the async transfer can begin
144  const auto* gpuMap = hgpuMap->getGPUProductAsync(ctx.stream());
145 
146  auto hgains = iSetup.getHandle(gainsToken_);
147  // get the GPU product already here so that the async transfer can begin
148  const auto* gpuGains = hgains->getGPUProductAsync(ctx.stream());
149 
150  cms::cuda::device::unique_ptr<unsigned char[]> modulesToUnpackRegional;
151  const unsigned char* gpuModulesToUnpack;
152 
153  if (regions_) {
154  regions_->run(iEvent, iSetup);
155  LogDebug("SiPixelRawToCluster") << "region2unpack #feds: " << regions_->nFEDs();
156  LogDebug("SiPixelRawToCluster") << "region2unpack #modules (BPIX,EPIX,total): " << regions_->nBarrelModules() << " "
157  << regions_->nForwardModules() << " " << regions_->nModules();
158  modulesToUnpackRegional = hgpuMap->getModToUnpRegionalAsync(*(regions_->modulesToUnpack()), ctx.stream());
159  gpuModulesToUnpack = modulesToUnpackRegional.get();
160  } else {
161  gpuModulesToUnpack = hgpuMap->getModToUnpAllAsync(ctx.stream());
162  }
163 
164  // initialize cabling map or update if necessary
165  if (recordWatcher_.check(iSetup)) {
166  // cabling map, which maps online address (fed->link->ROC->local pixel) to offline (DetId->global pixel)
167  auto cablingMap = iSetup.getTransientHandle(cablingMapToken_);
168  cablingMap_ = cablingMap.product();
169  fedIds_ = cablingMap->fedIds();
170  cabling_ = cablingMap->cablingTree();
171  LogDebug("map version:") << cabling_->version();
172  }
173 
174  const auto& buffers = iEvent.get(rawGetToken_);
175 
176  errors_.clear();
177 
178  // GPU specific: Data extraction for RawToDigi GPU
179  unsigned int wordCounter = 0;
180  unsigned int fedCounter = 0;
181  bool errorsInEvent = false;
182 
183  std::vector<unsigned int> index(fedIds_.size(), 0);
184  std::vector<cms_uint32_t const*> start(fedIds_.size(), nullptr);
185  std::vector<ptrdiff_t> words(fedIds_.size(), 0);
186 
187  // In CPU algorithm this loop is part of PixelDataFormatter::interpretRawData()
188  ErrorChecker errorcheck;
189  for (uint32_t i = 0; i < fedIds_.size(); ++i) {
190  const int fedId = fedIds_[i];
191  if (regions_ && !regions_->mayUnpackFED(fedId))
192  continue;
193 
194  // for GPU
195  // first 150 index stores the fedId and next 150 will store the
196  // start index of word in that fed
198  fedCounter++;
199 
200  // get event data for this fed
201  const FEDRawData& rawData = buffers.FEDData(fedId);
202 
203  // GPU specific
204  int nWords = rawData.size() / sizeof(cms_uint64_t);
205  if (nWords == 0) {
206  continue;
207  }
208 
209  // check CRC bit
210  const cms_uint64_t* trailer = reinterpret_cast<const cms_uint64_t*>(rawData.data()) + (nWords - 1);
211  if (not errorcheck.checkCRC(errorsInEvent, fedId, trailer, errors_)) {
212  continue;
213  }
214 
215  // check headers
216  const cms_uint64_t* header = reinterpret_cast<const cms_uint64_t*>(rawData.data());
217  header--;
218  bool moreHeaders = true;
219  while (moreHeaders) {
220  header++;
221  bool headerStatus = errorcheck.checkHeader(errorsInEvent, fedId, header, errors_);
222  moreHeaders = headerStatus;
223  }
224 
225  // check trailers
226  bool moreTrailers = true;
227  trailer++;
228  while (moreTrailers) {
229  trailer--;
230  bool trailerStatus = errorcheck.checkTrailer(errorsInEvent, fedId, nWords, trailer, errors_);
231  moreTrailers = trailerStatus;
232  }
233 
234  const cms_uint32_t* bw = (const cms_uint32_t*)(header + 1);
235  const cms_uint32_t* ew = (const cms_uint32_t*)(trailer);
236 
237  assert(0 == (ew - bw) % 2);
238  index[i] = wordCounter;
239  start[i] = bw;
240  words[i] = (ew - bw);
241  wordCounter += (ew - bw);
242 
243  } // end of for loop
244 
245  nDigis_ = wordCounter;
246 
247  if (nDigis_ == 0)
248  return;
249 
250  // copy the FED data to a single cpu buffer
252  for (uint32_t i = 0; i < fedIds_.size(); ++i) {
253  wordFedAppender.initializeWordFed(fedIds_[i], index[i], start[i], words[i]);
254  }
255 
258  gpuMap,
259  gpuModulesToUnpack,
260  gpuGains,
261  wordFedAppender,
263  wordCounter,
264  fedCounter,
265  useQuality_,
267  edm::MessageDrop::instance()->debugEnabled,
268  ctx.stream());
269 }
Definition: start.py:1
std::unique_ptr< SiPixelFedCablingTree > cabling_
edm::ESWatcher< SiPixelFedCablingMapRcd > recordWatcher_
cms::cuda::ContextState ctxState_
void initializeWordFed(int fedId, unsigned int index, cms_uint32_t const *src, unsigned int length)
edm::ESGetToken< SiPixelGainCalibrationForHLTGPU, SiPixelGainCalibrationForHLTGPURcd > gainsToken_
static MessageDrop * instance()
Definition: MessageDrop.cc:33
const SiPixelFedCablingMap * cablingMap_
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
assert(be >=bs)
int iEvent
Definition: GenABIO.cc:224
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
unsigned int cms_uint32_t
Definition: typedefs.h:15
std::vector< unsigned int > fedIds_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
const SiPixelClusterThresholds clusterThresholds_
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:162
pixelgpudetails::SiPixelRawToClusterGPUKernel gpuAlgo_
void makeClustersAsync(bool isRun2, const SiPixelClusterThresholds clusterThresholds, const SiPixelROCsStatusAndMapping *cablingMap, const unsigned char *modToUnp, const SiPixelGainForHLTonGPU *gains, const WordFedAppender &wordFed, SiPixelFormatterErrors &&errors, const uint32_t wordCounter, const uint32_t fedCounter, bool useQualityInfo, bool includeErrors, bool debug, cudaStream_t stream)
unsigned long long cms_uint64_t
Definition: typedefs.h:17
std::unique_ptr< PixelUnpackingRegions > regions_
edm::ESGetToken< SiPixelROCsStatusAndMappingWrapper, CkfComponentsRecord > gpuMapToken_
PixelDataFormatter::Errors errors_
edm::EDGetTokenT< FEDRawDataCollection > rawGetToken_
def move(src, dest)
Definition: eostools.py:511
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > cablingMapToken_
#define LogDebug(id)

◆ fillDescriptions()

void SiPixelRawToClusterCUDA::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 107 of file SiPixelRawToClusterCUDA.cc.

References edm::ParameterSetDescription::addOptional(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, kSiPixelClusterThresholdsDefaultPhase1, SiPixelClusterThresholds::layer1, SiPixelClusterThresholds::otherLayers, and AlCaHLTBitMon_QueryRunRegistry::string.

107  {
109  desc.add<bool>("isRun2", true);
110  desc.add<bool>("IncludeErrors", true);
111  desc.add<bool>("UseQualityInfo", false);
112  // Note: this parameter is obsolete: it is ignored and will have no effect.
113  // It is kept to avoid breaking older configurations, and will not be printed in the generated cfi.py file.
114  desc.addOptionalNode(edm::ParameterDescription<uint32_t>("MaxFEDWords", 0, true), false)
115  ->setComment("This parameter is obsolete and will be ignored.");
116  desc.add<int32_t>("clusterThreshold_layer1", kSiPixelClusterThresholdsDefaultPhase1.layer1);
117  desc.add<int32_t>("clusterThreshold_otherLayers", kSiPixelClusterThresholdsDefaultPhase1.otherLayers);
118  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
119  {
121  psd0.addOptional<std::vector<edm::InputTag>>("inputs");
122  psd0.addOptional<std::vector<double>>("deltaPhi");
123  psd0.addOptional<std::vector<double>>("maxZ");
124  psd0.addOptional<edm::InputTag>("beamSpot");
125  desc.add<edm::ParameterSetDescription>("Regions", psd0)
126  ->setComment("## Empty Regions PSet means complete unpacking");
127  }
128  desc.add<std::string>("CablingMapLabel", "")->setComment("CablingMap label"); //Tav
129  descriptions.addWithDefaultLabel(desc);
130 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
constexpr SiPixelClusterThresholds kSiPixelClusterThresholdsDefaultPhase1

◆ produce()

void SiPixelRawToClusterCUDA::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 271 of file SiPixelRawToClusterCUDA.cc.

References clusterPutToken_, ctxState_, digiErrorPutToken_, digiPutToken_, pixelgpudetails::SiPixelRawToClusterGPUKernel::getErrors(), pixelgpudetails::SiPixelRawToClusterGPUKernel::getResults(), gpuAlgo_, iEvent, includeErrors_, eostools::move(), nDigis_, and createJobs::tmp.

271  {
273 
274  if (nDigis_ == 0) {
275  // default construct collections and place them in event
276  ctx.emplace(iEvent, digiPutToken_, SiPixelDigisCUDA{});
278  if (includeErrors_) {
280  }
281  return;
282  }
283 
284  auto tmp = gpuAlgo_.getResults();
285  ctx.emplace(iEvent, digiPutToken_, std::move(tmp.first));
286  ctx.emplace(iEvent, clusterPutToken_, std::move(tmp.second));
287  if (includeErrors_) {
288  ctx.emplace(iEvent, digiErrorPutToken_, gpuAlgo_.getErrors());
289  }
290 }
cms::cuda::ContextState ctxState_
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigiErrorsCUDA > > digiErrorPutToken_
std::pair< SiPixelDigisCUDA, SiPixelClustersCUDA > getResults()
edm::EDPutTokenT< cms::cuda::Product< SiPixelClustersCUDA > > clusterPutToken_
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigisCUDA > > digiPutToken_
int iEvent
Definition: GenABIO.cc:224
pixelgpudetails::SiPixelRawToClusterGPUKernel gpuAlgo_
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ cabling_

std::unique_ptr<SiPixelFedCablingTree> SiPixelRawToClusterCUDA::cabling_
private

Definition at line 69 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ cablingMap_

const SiPixelFedCablingMap* SiPixelRawToClusterCUDA::cablingMap_ = nullptr
private

Definition at line 71 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ cablingMapToken_

edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> SiPixelRawToClusterCUDA::cablingMapToken_
private

Definition at line 67 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ clusterPutToken_

edm::EDPutTokenT<cms::cuda::Product<SiPixelClustersCUDA> > SiPixelRawToClusterCUDA::clusterPutToken_
private

Definition at line 60 of file SiPixelRawToClusterCUDA.cc.

Referenced by produce().

◆ clusterThresholds_

const SiPixelClusterThresholds SiPixelRawToClusterCUDA::clusterThresholds_
private

Definition at line 81 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ ctxState_

cms::cuda::ContextState SiPixelRawToClusterCUDA::ctxState_
private

Definition at line 62 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire(), and produce().

◆ digiErrorPutToken_

edm::EDPutTokenT<cms::cuda::Product<SiPixelDigiErrorsCUDA> > SiPixelRawToClusterCUDA::digiErrorPutToken_
private

Definition at line 59 of file SiPixelRawToClusterCUDA.cc.

Referenced by produce().

◆ digiPutToken_

edm::EDPutTokenT<cms::cuda::Product<SiPixelDigisCUDA> > SiPixelRawToClusterCUDA::digiPutToken_
private

Definition at line 58 of file SiPixelRawToClusterCUDA.cc.

Referenced by produce().

◆ errors_

PixelDataFormatter::Errors SiPixelRawToClusterCUDA::errors_
private

Definition at line 75 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ fedIds_

std::vector<unsigned int> SiPixelRawToClusterCUDA::fedIds_
private

Definition at line 70 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ gainsToken_

Definition at line 66 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ gpuAlgo_

pixelgpudetails::SiPixelRawToClusterGPUKernel SiPixelRawToClusterCUDA::gpuAlgo_
private

Definition at line 74 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire(), and produce().

◆ gpuMapToken_

edm::ESGetToken<SiPixelROCsStatusAndMappingWrapper, CkfComponentsRecord> SiPixelRawToClusterCUDA::gpuMapToken_
private

Definition at line 65 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ includeErrors_

const bool SiPixelRawToClusterCUDA::includeErrors_
private

Definition at line 78 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire(), and produce().

◆ isRun2_

const bool SiPixelRawToClusterCUDA::isRun2_
private

Definition at line 77 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ nDigis_

uint32_t SiPixelRawToClusterCUDA::nDigis_
private

Definition at line 80 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire(), and produce().

◆ rawGetToken_

edm::EDGetTokenT<FEDRawDataCollection> SiPixelRawToClusterCUDA::rawGetToken_
private

Definition at line 56 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ recordWatcher_

edm::ESWatcher<SiPixelFedCablingMapRcd> SiPixelRawToClusterCUDA::recordWatcher_
private

Definition at line 64 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ regions_

std::unique_ptr<PixelUnpackingRegions> SiPixelRawToClusterCUDA::regions_
private

Definition at line 72 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().

◆ useQuality_

const bool SiPixelRawToClusterCUDA::useQuality_
private

Definition at line 79 of file SiPixelRawToClusterCUDA.cc.

Referenced by acquire().