CMS 3D CMS Logo

SiPixelDigisClustersFromSoA.cc
Go to the documentation of this file.
18 
19 // local include(s)
20 #include "PixelClusterizerBase.h"
22 
24 public:
25  explicit SiPixelDigisClustersFromSoA(const edm::ParameterSet& iConfig);
26  ~SiPixelDigisClustersFromSoA() override = default;
27 
28  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
29 
30 private:
31  void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
32 
34 
36 
39 
40  const SiPixelClusterThresholds clusterThresholds_; // Cluster threshold in electrons
41 
42  const bool produceDigis_;
43  const bool storeDigis_;
44 };
45 
47  : topoToken_(esConsumes()),
48  digiGetToken_(consumes<SiPixelDigisSoA>(iConfig.getParameter<edm::InputTag>("src"))),
49  clusterPutToken_(produces<SiPixelClusterCollectionNew>()),
50  clusterThresholds_{iConfig.getParameter<int>("clusterThreshold_layer1"),
51  iConfig.getParameter<int>("clusterThreshold_otherLayers")},
52  produceDigis_(iConfig.getParameter<bool>("produceDigis")),
53  storeDigis_(iConfig.getParameter<bool>("produceDigis") & iConfig.getParameter<bool>("storeDigis")) {
54  if (produceDigis_)
55  digiPutToken_ = produces<edm::DetSetVector<PixelDigi>>();
56 }
57 
60  desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigisSoA"));
61  desc.add<int>("clusterThreshold_layer1", kSiPixelClusterThresholdsDefaultPhase1.layer1);
62  desc.add<int>("clusterThreshold_otherLayers", kSiPixelClusterThresholdsDefaultPhase1.otherLayers);
63  desc.add<bool>("produceDigis", true);
64  desc.add<bool>("storeDigis", true);
65  descriptions.addWithDefaultLabel(desc);
66 }
67 
69  const auto& digis = iEvent.get(digiGetToken_);
70  const uint32_t nDigis = digis.size();
71  const auto& ttopo = iSetup.getData(topoToken_);
72 
73  std::unique_ptr<edm::DetSetVector<PixelDigi>> collection;
74  if (produceDigis_)
75  collection = std::make_unique<edm::DetSetVector<PixelDigi>>();
76  if (storeDigis_)
78  auto outputClusters = std::make_unique<SiPixelClusterCollectionNew>();
79  outputClusters->reserve(gpuClustering::maxNumModules, nDigis / 2);
80 
81  edm::DetSet<PixelDigi>* detDigis = nullptr;
82  uint32_t detId = 0;
83  for (uint32_t i = 0; i < nDigis; i++) {
84  // check for uninitialized digis
85  // this is set in RawToDigi_kernel in SiPixelRawToClusterGPUKernel.cu
86  if (digis.rawIdArr(i) == 0)
87  continue;
88  // check for noisy/dead pixels (electrons set to 0)
89  if (digis.adc(i) == 0)
90  continue;
91 
92  detId = digis.rawIdArr(i);
93  if (storeDigis_) {
94  detDigis = &collection->find_or_insert(detId);
95  if ((*detDigis).empty())
96  (*detDigis).data.reserve(64); // avoid the first relocations
97  }
98  break;
99  }
100 
101  int32_t nclus = -1;
103 #ifdef EDM_ML_DEBUG
104  auto totClustersFilled = 0;
105 #endif
106 
107  auto fillClusters = [&](uint32_t detId) {
108  if (nclus < 0)
109  return; // this in reality should never happen
111  auto layer = (DetId(detId).subdetId() == 1) ? ttopo.pxbLayer(detId) : 0;
113  for (int32_t ic = 0; ic < nclus + 1; ++ic) {
114  auto const& acluster = aclusters[ic];
115  // in any case we cannot go out of sync with gpu...
116  if (acluster.charge < clusterThreshold)
117  edm::LogWarning("SiPixelDigisClustersFromSoA") << "cluster below charge Threshold "
118  << "Layer/DetId/clusId " << layer << '/' << detId << '/' << ic
119  << " size/charge " << acluster.isize << '/' << acluster.charge;
120  // sort by row (x)
121  spc.emplace_back(acluster.isize, acluster.adc, acluster.x, acluster.y, acluster.xmin, acluster.ymin, ic);
122  aclusters[ic].clear();
123 #ifdef EDM_ML_DEBUG
124  ++totClustersFilled;
125  const auto& cluster{spc.back()};
126  LogDebug("SiPixelDigisClustersFromSoA")
127  << "putting in this cluster " << ic << " " << cluster.charge() << " " << cluster.pixelADC().size();
128 #endif
129  std::push_heap(spc.begin(), spc.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
130  return cl1.minPixelRow() < cl2.minPixelRow();
131  });
132  }
133  nclus = -1;
134  // sort by row (x)
135  std::sort_heap(spc.begin(), spc.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
136  return cl1.minPixelRow() < cl2.minPixelRow();
137  });
138  if (spc.empty())
139  spc.abort();
140  };
141 
142  for (uint32_t i = 0; i < nDigis; i++) {
143  // check for uninitialized digis
144  if (digis.rawIdArr(i) == 0)
145  continue;
146  // check for noisy/dead pixels (electrons set to 0)
147  if (digis.adc(i) == 0)
148  continue;
149  if (digis.clus(i) > 9000)
150  continue; // not in cluster; TODO add an assert for the size
151 #ifdef EDM_ML_DEBUG
152  assert(digis.rawIdArr(i) > 109999);
153 #endif
154  if (detId != digis.rawIdArr(i)) {
155  // new module
156  fillClusters(detId);
157 #ifdef EDM_ML_DEBUG
158  assert(nclus == -1);
159 #endif
160  detId = digis.rawIdArr(i);
161  if (storeDigis_) {
162  detDigis = &collection->find_or_insert(detId);
163  if ((*detDigis).empty())
164  (*detDigis).data.reserve(64); // avoid the first relocations
165  else {
166  edm::LogWarning("SiPixelDigisClustersFromSoA")
167  << "Problem det present twice in input! " << (*detDigis).detId();
168  }
169  }
170  }
171  PixelDigi dig(digis.pdigi(i));
172  if (storeDigis_)
173  (*detDigis).data.emplace_back(dig);
174  // fill clusters
175 #ifdef EDM_ML_DEBUG
176  assert(digis.clus(i) >= 0);
178 #endif
179  nclus = std::max(digis.clus(i), nclus);
180  auto row = dig.row();
181  auto col = dig.column();
182  SiPixelCluster::PixelPos pix(row, col);
183  aclusters[digis.clus(i)].add(pix, digis.adc(i));
184  }
185 
186  // fill final clusters
187  if (detId > 0)
188  fillClusters(detId);
189 
190 #ifdef EDM_ML_DEBUG
191  LogDebug("SiPixelDigisClustersFromSoA") << "filled " << totClustersFilled << " clusters";
192 #endif
193 
194  if (produceDigis_)
197 }
198 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
SiPixelDigisClustersFromSoA::~SiPixelDigisClustersFromSoA
~SiPixelDigisClustersFromSoA() override=default
edmNew::DetSetVector::FastFiller::abort
void abort()
Definition: DetSetVectorNew.h:237
SiPixelDigisClustersFromSoA::produceDigis_
const bool produceDigis_
Definition: SiPixelDigisClustersFromSoA.cc:42
Handle.h
SiPixelClusterThresholds::getThresholdForLayerOnCondition
constexpr int32_t getThresholdForLayerOnCondition(bool isLayer1) const noexcept
Definition: SiPixelClusterThresholds.h:5
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
edmNew::DetSetVector::FastFiller::begin
DataIter begin()
Definition: DetSetVectorNew.h:272
SiPixelDigisClustersFromSoA::digiGetToken_
edm::EDGetTokenT< SiPixelDigisSoA > digiGetToken_
Definition: SiPixelDigisClustersFromSoA.cc:35
edm::DetSet
Definition: DetSet.h:23
edmNew::DetSetVector::FastFiller::back
data_type & back()
Definition: DetSetVectorNew.h:297
SiPixelDigisClustersFromSoA::topoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: SiPixelDigisClustersFromSoA.cc:33
SiPixelDigisClustersFromSoA::storeDigis_
const bool storeDigis_
Definition: SiPixelDigisClustersFromSoA.cc:43
edm::EDGetTokenT< SiPixelDigisSoA >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT
Definition: EDPutToken.h:33
cuy.col
col
Definition: cuy.py:1009
SiPixelCluster.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SiPixelDigisClustersFromSoA::clusterThresholds_
const SiPixelClusterThresholds clusterThresholds_
Definition: SiPixelDigisClustersFromSoA.cc:40
PixelDigi
Definition: PixelDigi.h:14
SiPixelClusterThresholds
Definition: SiPixelClusterThresholds.h:4
cms::cuda::assert
assert(be >=bs)
SiPixelDigisClustersFromSoA::digiPutToken_
edm::EDPutTokenT< edm::DetSetVector< PixelDigi > > digiPutToken_
Definition: SiPixelDigisClustersFromSoA.cc:37
GetRecoTauVFromDQM_MC_cff.cl2
cl2
Definition: GetRecoTauVFromDQM_MC_cff.py:44
PixelClusterizerBase.h
PixelDigi.h
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SiPixelDigisClustersFromSoA
Definition: SiPixelDigisClustersFromSoA.cc:23
DetId
Definition: DetId.h:17
MakerMacros.h
TrackerTopology.h
edmNew::DetSetVector::FastFiller::empty
bool empty() const
Definition: DetSetVectorNew.h:269
PixelClusterizerBase::AccretionCluster::clear
void clear()
Definition: PixelClusterizerBase.h:39
SiPixelDigisSoA.h
kSiPixelClusterThresholdsDefaultPhase1
constexpr SiPixelClusterThresholds kSiPixelClusterThresholdsDefaultPhase1
Definition: SiPixelClusterThresholds.h:12
TrackerTopologyRcd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiPixelClusterThresholds.h
SiPixelCluster::minPixelRow
int minPixelRow() const
Definition: SiPixelCluster.h:150
slimmedTrackExtras_cff.outputClusters
outputClusters
Definition: slimmedTrackExtras_cff.py:14
EMEnrichingFilter_cfi.clusterThreshold
clusterThreshold
Definition: EMEnrichingFilter_cfi.py:12
SiPixelDigisClustersFromSoA::produce
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition: SiPixelDigisClustersFromSoA.cc:68
ParameterSetDescription.h
gpuClustering::maxNumModules
constexpr uint16_t maxNumModules
Definition: gpuClusteringConstants.h:18
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
SiPixelDigisClustersFromSoA::SiPixelDigisClustersFromSoA
SiPixelDigisClustersFromSoA(const edm::ParameterSet &iConfig)
Definition: SiPixelDigisClustersFromSoA.cc:46
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PixelClusterizerBase::AccretionCluster
Definition: PixelClusterizerBase.h:23
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
iEvent
int iEvent
Definition: GenABIO.cc:224
gpuClusteringConstants.h
SiPixelDigisSoA
Definition: SiPixelDigisSoA.h:14
gpuClustering::maxNumClustersPerModules
constexpr int32_t maxNumClustersPerModules
Definition: gpuClusteringConstants.h:19
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
edm::EventSetup
Definition: EventSetup.h:58
SiPixelDigisClustersFromSoA::clusterPutToken_
edm::EDPutTokenT< SiPixelClusterCollectionNew > clusterPutToken_
Definition: SiPixelDigisClustersFromSoA.cc:38
DetSetVector.h
SiPixelClusterThresholds::otherLayers
const int32_t otherLayers
Definition: SiPixelClusterThresholds.h:9
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
PixelClusterizerBase::AccretionCluster::add
bool add(SiPixelCluster::PixelPos const &p, uint16_t const iadc)
Definition: PixelClusterizerBase.h:47
edmNew::DetSetVector
Definition: DetSetNew.h:13
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId.h
SiPixelClusterThresholds::layer1
const int32_t layer1
Definition: SiPixelClusterThresholds.h:8
SiPixelDigisClustersFromSoA::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiPixelDigisClustersFromSoA.cc:58
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edmNew::DetSetVector::FastFiller::end
DataIter end()
Definition: DetSetVectorNew.h:273
edmNew::DetSetVector::FastFiller
Definition: DetSetVectorNew.h:202
ParameterSet.h
EDProducer.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
SiPixelCluster::PixelPos
Definition: SiPixelCluster.h:56
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edmNew::DetSetVector::FastFiller::emplace_back
void emplace_back(Args &&... args)
Definition: DetSetVectorNew.h:276
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87