CMS 3D CMS Logo

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

Public Member Functions

void produce (edm::Event &e, const edm::EventSetup &c) override
 
 SiPixelDigiMorphing (const edm::ParameterSet &conf)
 
 ~SiPixelDigiMorphing () override=default
 
- 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
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

enum  MorphOption { kDilate, kErode }
 

Private Member Functions

void morph (uint64_t *const imap, uint64_t *omap, uint64_t *const kernel, MorphOption op) const
 

Private Attributes

const uint32_t fakeAdc_
 
const int32_t iters_
 
std::vector< uint64_t > kernel1_
 
std::vector< uint64_t > kernel2_
 
int32_t ksize_
 
uint64_t mask_
 
const int32_t ncols_
 
int32_t ncols_r_
 
const int32_t nrocs_
 
const int32_t nrows_
 
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi_
 
edm::EDPutTokenT< edm::DetSetVector< PixelDigi > > tPutPixelDigi_
 

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 16 of file SiPixelDigiMorphing.cc.

Member Enumeration Documentation

◆ MorphOption

Enumerator
kDilate 
kErode 

Definition at line 41 of file SiPixelDigiMorphing.cc.

Constructor & Destructor Documentation

◆ SiPixelDigiMorphing()

SiPixelDigiMorphing::SiPixelDigiMorphing ( const edm::ParameterSet conf)
explicit

Definition at line 46 of file SiPixelDigiMorphing.cc.

References Exception, edm::ParameterSet::getParameter(), cuy::ii, iters_, dqmiolumiharvest::j, kernel1_, kernel2_, ksize_, mask_, ncols_, ncols_r_, nrocs_, and w().

47  : tPixelDigi_(consumes(conf.getParameter<edm::InputTag>("src"))),
49  nrows_(conf.getParameter<int32_t>("nrows")),
50  ncols_(conf.getParameter<int32_t>("ncols")),
51  nrocs_(conf.getParameter<int32_t>("nrocs")),
52  iters_(conf.getParameter<int32_t>("iters")),
53  fakeAdc_(conf.getParameter<uint32_t>("fakeAdc")) {
54  if (ncols_ % nrocs_ == 0) {
56  } else {
57  throw cms::Exception("Configuration") << "[SiPixelDigiMorphing]:"
58  << " number of columns not divisible with"
59  << " number of ROCs\n";
60  }
61 
62  if (ncols_r_ + 2 * iters_ <= int(sizeof(uint64_t) * 8)) {
63  ksize_ = 2 * iters_ + 1;
64  } else {
65  throw cms::Exception("Configuration") << "[SiPixelDigiMorphing]:"
66  << " too many columns per ROC"
67  << " or too many iterations set\n"
68  << " Ncol/Nrocs+2*iters should not be"
69  << " more than " << sizeof(uint64_t) * 8 << "\n";
70  }
71 
72  std::vector<int32_t> k1(conf.getParameter<std::vector<int32_t>>("kernel1"));
73  std::vector<int32_t> k2(conf.getParameter<std::vector<int32_t>>("kernel2"));
74 
75  kernel1_.resize(ksize_, 0);
76  kernel2_.resize(ksize_, 0);
77  mask_ = 0;
78  int w = (ncols_r_ + 2 * iters_) / ksize_ + ((ncols_r_ + 2 * iters_) % ksize_ != 0);
79  for (int j = 0; j < w; j++) {
80  for (int ii = 0; ii < ksize_; ii++) {
81  kernel1_[ii] <<= ksize_;
82  kernel1_[ii] |= k1[ii];
83  kernel2_[ii] <<= ksize_;
84  kernel2_[ii] |= k2[ii];
85  }
86  mask_ <<= ksize_;
87  mask_ |= 1;
88  }
89  mask_ <<= iters_;
90 }
std::vector< uint64_t > kernel2_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
T w() const
edm::EDPutTokenT< edm::DetSetVector< PixelDigi > > tPutPixelDigi_
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi_
ii
Definition: cuy.py:589
unsigned long long uint64_t
Definition: Time.h:13
std::vector< uint64_t > kernel1_

◆ ~SiPixelDigiMorphing()

SiPixelDigiMorphing::~SiPixelDigiMorphing ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 92 of file SiPixelDigiMorphing.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and HLT_2022v15_cff::InputTag.

92  {
94 
95  desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigis"));
96  desc.add<int32_t>("nrows", 160);
97  desc.add<int32_t>("ncols", 416);
98  desc.add<int32_t>("nrocs", 8);
99  desc.add<int32_t>("iters", 1);
100  desc.add<std::vector<int32_t>>("kernel1", {7, 7, 7});
101  desc.add<std::vector<int32_t>>("kernel2", {2, 7, 2});
102  desc.add<uint32_t>("fakeAdc", 100);
103 
104  descriptions.addWithDefaultLabel(desc);
105 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ morph()

void SiPixelDigiMorphing::morph ( uint64_t *const  imap,
uint64_t *  omap,
uint64_t *const  kernel,
MorphOption  op 
) const
private

Definition at line 166 of file SiPixelDigiMorphing.cc.

References b, mps_fire::i, cuy::ii, iters_, findQualityFiles::jj, kErode, ksize_, visualization-live-secondInstance_cfg::m, mask_, nrocs_, nrows_, EcalTangentSkim_cfg::o, PixelMapPlotter::roc, findQualityFiles::v, and validateGeometry_cfg::valid.

Referenced by produce().

166  {
167  uint64_t* i[ksize_]; // i(nput)
168  uint64_t* o = omap + iters_; // o(output)
169  unsigned char valid = 0;
170  unsigned char const validMask = (1 << ksize_) - 1;
171  uint64_t m[ksize_]; // m(ask)
172 
173  for (int ii = 0; ii < ksize_; ii++) {
174  i[ii] = imap + ii;
175  valid = (valid << 1) | (*i[ii] != 0);
176  m[ii] = mask_ << ii;
177  }
178 
179  for (int roc = 0; roc < nrocs_; roc++, o += 2 * iters_) {
180  for (int row = 0; row < nrows_; row++, o++) {
181  if ((valid & validMask) != 0) {
182  for (int jj = 0; jj < ksize_; jj++) {
183  for (int ii = 0; ii < ksize_; ii++) {
184  uint64_t v = (*i[ii]) & (kernel[ii] << jj); // v(ector)
185  if (op == kErode)
186  v ^= (kernel[ii] << jj);
187  uint64_t vv = v; // vv(vector bit - shifted and contracted)
188  for (int b = 1; b < ksize_; b++)
189  vv |= (v >> b);
190  *o |= ((vv << iters_) & m[jj]);
191  }
192  if (op == kErode)
193  *o ^= m[jj];
194  }
195  }
196  for (int ii = 0; ii < ksize_; ii++)
197  i[ii]++;
198  valid = (valid << 1) | (*i[ksize_ - 1] != 0);
199  }
200  for (int ii = 0; ii < ksize_; ii++) {
201  i[ii] += 2 * iters_;
202  valid = (valid << 1) | (*i[ii] != 0);
203  }
204  }
205 }
ii
Definition: cuy.py:589
unsigned long long uint64_t
Definition: Time.h:13
double b
Definition: hdecay.h:118

◆ produce()

void SiPixelDigiMorphing::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 107 of file SiPixelDigiMorphing.cc.

References HltBtagPostValidation_cff::c, cuy::col, MillePedeFileConverter_cfg::e, fakeAdc_, mps_fire::i, createfilelist::int, iters_, kDilate, kernel1_, kernel2_, kErode, morph(), eostools::move(), ncols_r_, nrocs_, nrows_, EcalTangentSkim_cfg::o, alignCSCRings::r, PixelMapPlotter::roc, tPixelDigi_, and tPutPixelDigi_.

107  {
108  auto const& inputDigi = e.get(tPixelDigi_);
109 
110  auto outputDigis = std::make_unique<edm::DetSetVector<PixelDigi>>();
111 
112  const int rocSize = nrows_ + 2 * iters_;
113  const int arrSize = nrocs_ * rocSize;
114 
115  uint64_t imap[arrSize];
116  uint64_t map1[arrSize];
117  uint64_t map2[arrSize];
118 
119  for (auto const& ds : inputDigi) {
120  auto rawId = ds.detId();
121  edm::DetSet<PixelDigi>* detDigis = nullptr;
122  detDigis = &(outputDigis->find_or_insert(rawId));
123 
124  memset(imap, 0, arrSize * sizeof(uint64_t));
125  for (auto const& di : ds) {
126  int r = int(di.column()) / ncols_r_;
127  int c = int(di.column()) % ncols_r_;
128  imap[r * rocSize + di.row() + iters_] |= uint64_t(1) << (c + iters_);
129  if (r > 0 && c < iters_) {
130  imap[(r - 1) * rocSize + di.row() + iters_] |= uint64_t(1) << (c + ncols_r_ + iters_);
131  } else if (++r < nrocs_ && c >= ncols_r_ - iters_) {
132  imap[r * rocSize + di.row() + iters_] |= uint64_t(1) << (c - ncols_r_ + iters_);
133  }
134  (*detDigis).data.emplace_back(di.row(), di.column(), di.adc(), 0);
135  }
136 
137  std::memcpy(map1, imap, arrSize * sizeof(uint64_t));
138  memset(map2, 0, arrSize * sizeof(uint64_t));
139 
140  morph(map1, map2, kernel1_.data(), kDilate);
141  morph(map2, map1, kernel2_.data(), kErode);
142 
143  uint64_t* i = imap + iters_;
144  uint64_t* o = map1 + iters_;
145  for (int roc = 0; roc < nrocs_; roc++, i += 2 * iters_, o += 2 * iters_) {
146  for (int row = 0; row < nrows_; row++, i++, o++) {
147  if (*o == 0)
148  continue;
149  *o >>= iters_;
150  *i >>= iters_;
151  for (int col = 0; col < ncols_r_; col++, (*i) >>= 1, (*o) >>= 1) {
152  if (*o == 0)
153  break;
154  if (((*i) & uint64_t(1)) == 1)
155  continue;
156  if (((*o) & uint64_t(1)) == 1) {
157  (*detDigis).data.emplace_back(row, roc * ncols_r_ + col, fakeAdc_, 1);
158  }
159  }
160  }
161  }
162  }
163  e.put(tPutPixelDigi_, std::move(outputDigis));
164 }
std::vector< uint64_t > kernel2_
edm::EDPutTokenT< edm::DetSetVector< PixelDigi > > tPutPixelDigi_
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi_
unsigned long long uint64_t
Definition: Time.h:13
void morph(uint64_t *const imap, uint64_t *omap, uint64_t *const kernel, MorphOption op) const
col
Definition: cuy.py:1009
std::vector< uint64_t > kernel1_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ fakeAdc_

const uint32_t SiPixelDigiMorphing::fakeAdc_
private

Definition at line 32 of file SiPixelDigiMorphing.cc.

Referenced by produce().

◆ iters_

const int32_t SiPixelDigiMorphing::iters_
private

Definition at line 31 of file SiPixelDigiMorphing.cc.

Referenced by morph(), produce(), and SiPixelDigiMorphing().

◆ kernel1_

std::vector<uint64_t> SiPixelDigiMorphing::kernel1_
private

Definition at line 37 of file SiPixelDigiMorphing.cc.

Referenced by produce(), and SiPixelDigiMorphing().

◆ kernel2_

std::vector<uint64_t> SiPixelDigiMorphing::kernel2_
private

Definition at line 38 of file SiPixelDigiMorphing.cc.

Referenced by produce(), and SiPixelDigiMorphing().

◆ ksize_

int32_t SiPixelDigiMorphing::ksize_
private

Definition at line 35 of file SiPixelDigiMorphing.cc.

Referenced by morph(), and SiPixelDigiMorphing().

◆ mask_

uint64_t SiPixelDigiMorphing::mask_
private

Definition at line 39 of file SiPixelDigiMorphing.cc.

Referenced by morph(), and SiPixelDigiMorphing().

◆ ncols_

const int32_t SiPixelDigiMorphing::ncols_
private

Definition at line 29 of file SiPixelDigiMorphing.cc.

Referenced by SiPixelDigiMorphing().

◆ ncols_r_

int32_t SiPixelDigiMorphing::ncols_r_
private

Definition at line 34 of file SiPixelDigiMorphing.cc.

Referenced by produce(), and SiPixelDigiMorphing().

◆ nrocs_

const int32_t SiPixelDigiMorphing::nrocs_
private

Definition at line 30 of file SiPixelDigiMorphing.cc.

Referenced by morph(), produce(), and SiPixelDigiMorphing().

◆ nrows_

const int32_t SiPixelDigiMorphing::nrows_
private

Definition at line 28 of file SiPixelDigiMorphing.cc.

Referenced by morph(), and produce().

◆ tPixelDigi_

edm::EDGetTokenT<edm::DetSetVector<PixelDigi> > SiPixelDigiMorphing::tPixelDigi_
private

Definition at line 25 of file SiPixelDigiMorphing.cc.

Referenced by produce().

◆ tPutPixelDigi_

edm::EDPutTokenT<edm::DetSetVector<PixelDigi> > SiPixelDigiMorphing::tPutPixelDigi_
private

Definition at line 26 of file SiPixelDigiMorphing.cc.

Referenced by produce().