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 
44  : topoToken_(esConsumes()),
45  digiGetToken_(consumes<SiPixelDigisSoA>(iConfig.getParameter<edm::InputTag>("src"))),
46  digiPutToken_(produces<edm::DetSetVector<PixelDigi>>()),
47  clusterPutToken_(produces<SiPixelClusterCollectionNew>()),
48  clusterThresholds_{iConfig.getParameter<int>("clusterThreshold_layer1"),
49  iConfig.getParameter<int>("clusterThreshold_otherLayers")} {}
50 
53  desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigisSoA"));
54  desc.add<int>("clusterThreshold_layer1", kSiPixelClusterThresholdsDefaultPhase1.layer1);
55  desc.add<int>("clusterThreshold_otherLayers", kSiPixelClusterThresholdsDefaultPhase1.otherLayers);
56  descriptions.addWithDefaultLabel(desc);
57 }
58 
60  const auto& digis = iEvent.get(digiGetToken_);
61  const uint32_t nDigis = digis.size();
62  const auto& ttopo = iSetup.getData(topoToken_);
63 
64  auto collection = std::make_unique<edm::DetSetVector<PixelDigi>>();
65  auto outputClusters = std::make_unique<SiPixelClusterCollectionNew>();
66  outputClusters->reserve(gpuClustering::maxNumModules, nDigis / 4);
67 
68  edm::DetSet<PixelDigi>* detDigis = nullptr;
69  for (uint32_t i = 0; i < nDigis; i++) {
70  if (digis.pdigi(i) == 0)
71  continue;
72  detDigis = &collection->find_or_insert(digis.rawIdArr(i));
73  if ((*detDigis).empty())
74  (*detDigis).data.reserve(64); // avoid the first relocations
75  break;
76  }
77 
78  int32_t nclus = -1;
79  std::vector<PixelClusterizerBase::AccretionCluster> aclusters(gpuClustering::maxNumClustersPerModules);
80 #ifdef EDM_ML_DEBUG
81  auto totClustersFilled = 0;
82 #endif
83 
84  auto fillClusters = [&](uint32_t detId) {
85  if (nclus < 0)
86  return; // this in reality should never happen
88  auto layer = (DetId(detId).subdetId() == 1) ? ttopo.pxbLayer(detId) : 0;
90  for (int32_t ic = 0; ic < nclus + 1; ++ic) {
91  auto const& acluster = aclusters[ic];
92  // in any case we cannot go out of sync with gpu...
93  if (acluster.charge < clusterThreshold)
94  edm::LogWarning("SiPixelDigisClustersFromSoA") << "cluster below charge Threshold "
95  << "Layer/DetId/clusId " << layer << '/' << detId << '/' << ic
96  << " size/charge " << acluster.isize << '/' << acluster.charge;
97  SiPixelCluster cluster(acluster.isize, acluster.adc, acluster.x, acluster.y, acluster.xmin, acluster.ymin, ic);
98 #ifdef EDM_ML_DEBUG
99  ++totClustersFilled;
100 #endif
101  LogDebug("SiPixelDigisClustersFromSoA")
102  << "putting in this cluster " << ic << " " << cluster.charge() << " " << cluster.pixelADC().size();
103  // sort by row (x)
104  spc.push_back(std::move(cluster));
105  std::push_heap(spc.begin(), spc.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
106  return cl1.minPixelRow() < cl2.minPixelRow();
107  });
108  }
109  for (int32_t ic = 0; ic < nclus + 1; ++ic)
110  aclusters[ic].clear();
111  nclus = -1;
112  // sort by row (x)
113  std::sort_heap(spc.begin(), spc.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
114  return cl1.minPixelRow() < cl2.minPixelRow();
115  });
116  if (spc.empty())
117  spc.abort();
118  };
119 
120  for (uint32_t i = 0; i < nDigis; i++) {
121  if (digis.pdigi(i) == 0)
122  continue;
123  if (digis.clus(i) > 9000)
124  continue; // not in cluster; TODO add an assert for the size
125  assert(digis.rawIdArr(i) > 109999);
126  if ((*detDigis).detId() != digis.rawIdArr(i)) {
127  fillClusters((*detDigis).detId());
128  assert(nclus == -1);
129  detDigis = &collection->find_or_insert(digis.rawIdArr(i));
130  if ((*detDigis).empty())
131  (*detDigis).data.reserve(64); // avoid the first relocations
132  else {
133  edm::LogWarning("SiPixelDigisClustersFromSoA") << "Problem det present twice in input! " << (*detDigis).detId();
134  }
135  }
136  (*detDigis).data.emplace_back(digis.pdigi(i));
137  auto const& dig = (*detDigis).data.back();
138  // fill clusters
139  assert(digis.clus(i) >= 0);
141  nclus = std::max(digis.clus(i), nclus);
142  auto row = dig.row();
143  auto col = dig.column();
144  SiPixelCluster::PixelPos pix(row, col);
145  aclusters[digis.clus(i)].add(pix, digis.adc(i));
146  }
147 
148  // fill final clusters
149  if (detDigis)
150  fillClusters((*detDigis).detId());
151 #ifdef EDM_ML_DEBUG
152  LogDebug("SiPixelDigisClustersFromSoA") << "filled " << totClustersFilled << " clusters";
153 #endif
154 
157 }
158 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
SiPixelDigisClustersFromSoA::~SiPixelDigisClustersFromSoA
~SiPixelDigisClustersFromSoA() override=default
edmNew::DetSetVector::FastFiller::abort
void abort()
Definition: DetSetVectorNew.h:236
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:271
SiPixelDigisClustersFromSoA::digiGetToken_
edm::EDGetTokenT< SiPixelDigisSoA > digiGetToken_
Definition: SiPixelDigisClustersFromSoA.cc:35
edm::DetSet
Definition: DetSet.h:23
SiPixelDigisClustersFromSoA::topoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: SiPixelDigisClustersFromSoA.cc:33
edm::EDGetTokenT< SiPixelDigisSoA >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT
Definition: EDPutToken.h:33
cuy.col
col
Definition: cuy.py:1010
SiPixelCluster.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
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
edmNew::DetSetVector::FastFiller::push_back
void push_back(data_type const &d)
Definition: DetSetVectorNew.h:274
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:268
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:142
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:59
ParameterSetDescription.h
gpuClustering::maxNumModules
constexpr uint16_t maxNumModules
Definition: gpuClusteringConstants.h:29
SiPixelCluster::pixelADC
const std::vector< uint16_t > & pixelADC() const
Definition: SiPixelCluster.h:148
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:43
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
clear
void clear(HadCaloObj &c)
Definition: data.h:124
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
iEvent
int iEvent
Definition: GenABIO.cc:224
gpuClusteringConstants.h
SiPixelDigisSoA
Definition: SiPixelDigisSoA.h:13
gpuClustering::maxNumClustersPerModules
constexpr int32_t maxNumClustersPerModules
Definition: gpuClusteringConstants.h:30
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
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:51
EventSetup.h
SiPixelCluster::charge
int charge() const
Definition: SiPixelCluster.h:134
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edmNew::DetSetVector::FastFiller::end
DataIter end()
Definition: DetSetVectorNew.h:272
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:53
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87