CMS 3D CMS Logo

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

Public Member Functions

 HGCalLayerClustersFromSoAProducer (edm::ParameterSet const &config)
 
void produce (edm::Event &iEvent, edm::EventSetup const &iSetup) override
 
 ~HGCalLayerClustersFromSoAProducer () 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 Attributes

reco::CaloCluster::AlgoId algoId_
 
std::string detector_
 
edm::EDGetTokenT< HGCalSoARecHitsHostCollection > const getTokenSoACells_
 
edm::EDGetTokenT< HGCalSoAClustersHostCollection > const getTokenSoAClusters_
 
edm::EDGetTokenT< HGCalSoARecHitsExtraHostCollection > const getTokenSoARecHitsExtra_
 
unsigned int hitsTime_
 
std::string timeClname_
 

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 28 of file HGCalLayerClustersFromSoAProducer.cc.

Constructor & Destructor Documentation

◆ HGCalLayerClustersFromSoAProducer()

HGCalLayerClustersFromSoAProducer::HGCalLayerClustersFromSoAProducer ( edm::ParameterSet const &  config)
inline

Definition at line 30 of file HGCalLayerClustersFromSoAProducer.cc.

References algoId_, detector_, reco::CaloCluster::hfnose, reco::CaloCluster::hgcal_em, reco::CaloCluster::hgcal_had, AlCaHLTBitMon_QueryRunRegistry::string, and timeClname_.

31  : getTokenSoAClusters_(consumes(config.getParameter<edm::InputTag>("src"))),
32  getTokenSoACells_(consumes(config.getParameter<edm::InputTag>("hgcalRecHitsSoA"))),
33  getTokenSoARecHitsExtra_(consumes(config.getParameter<edm::InputTag>("hgcalRecHitsLayerClustersSoA"))),
34  detector_(config.getParameter<std::string>("detector")),
35  hitsTime_(config.getParameter<unsigned int>("nHitsTime")),
36  timeClname_(config.getParameter<std::string>("timeClname")) {
37 #if DEBUG_CLUSTERS_ALPAKA
38  moduleLabel_ = config.getParameter<std::string>("@module_label");
39 #endif
40  if (detector_ == "HFNose") {
42  } else if (detector_ == "EE") {
44  } else { //for FH or BH
46  }
47 
48  produces<std::vector<float>>("InitialLayerClustersMask");
49  produces<std::vector<reco::BasicCluster>>();
50  produces<edm::ValueMap<std::pair<float, float>>>(timeClname_);
51  }
edm::EDGetTokenT< HGCalSoARecHitsExtraHostCollection > const getTokenSoARecHitsExtra_
Definition: config.py:1
edm::EDGetTokenT< HGCalSoAClustersHostCollection > const getTokenSoAClusters_
edm::EDGetTokenT< HGCalSoARecHitsHostCollection > const getTokenSoACells_

◆ ~HGCalLayerClustersFromSoAProducer()

HGCalLayerClustersFromSoAProducer::~HGCalLayerClustersFromSoAProducer ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

static void HGCalLayerClustersFromSoAProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 152 of file HGCalLayerClustersFromSoAProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

152  {
154  desc.add<edm::InputTag>("src", edm::InputTag("hltHgcalSoALayerClustersProducer"));
155  desc.add<edm::InputTag>("hgcalRecHitsLayerClustersSoA", edm::InputTag("hltHgcalSoARecHitsLayerClustersProducer"));
156  desc.add<edm::InputTag>("hgcalRecHitsSoA", edm::InputTag("hltHgcalSoARecHitsProducer"));
157  desc.add<unsigned int>("nHitsTime", 3);
158  desc.add<std::string>("timeClname", "timeLayerCluster");
160  "detector", "EE", true, edm::Comment("the HGCAL component used to create clusters.")),
161  edm::allowedValues<std::string>("EE", "FH"));
162  descriptions.addWithDefaultLabel(desc);
163  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void HGCalLayerClustersFromSoAProducer::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
inlineoverride

Definition at line 55 of file HGCalLayerClustersFromSoAProducer.cc.

References algoId_, cms::cuda::assert(), bsc_activity_cfg::clusters, reco::CaloID::DET_HGCAL_ENDCAP, detector_, hgcalUtils::DumpClusters::dumpInfos(), hgcalUtils::DumpClustersSoA::dumpInfos(), hgcalUtils::DumpCellsSoA::dumpInfos(), f, trigObjTnPSource_cfi::filler, hgcalsimclustertime::ComputeClusterTime::fixSizeHighestDensity(), getTokenSoACells_, getTokenSoAClusters_, getTokenSoARecHitsExtra_, hitsTime_, mps_fire::i, iEvent, eostools::move(), convertSQLiteXML::runNumber, hcalRecHitTable_cff::time, and timeClname_.

55  {
56  auto const& deviceData = iEvent.get(getTokenSoAClusters_);
57 
58  auto const& deviceSoARecHitsExtra = iEvent.get(getTokenSoARecHitsExtra_);
59  auto const soaRecHitsExtra_v = deviceSoARecHitsExtra.view();
60 
61  auto const& deviceSoACells = iEvent.get(getTokenSoACells_);
62  auto const soaCells_v = deviceSoACells.view();
63 
64  auto const deviceView = deviceData.view();
65 
66  std::unique_ptr<std::vector<reco::BasicCluster>> clusters(new std::vector<reco::BasicCluster>);
67  clusters->reserve(deviceData->metadata().size());
68 
69  for (int i = 0; i < deviceData->metadata().size(); ++i) {
70  std::vector<std::pair<DetId, float>> thisCluster;
71  thisCluster.reserve(deviceView.cells(i));
72  clusters->emplace_back(deviceView.energy(i),
73  math::XYZPoint(deviceView.x(i), deviceView.y(i), deviceView.z(i)),
75  std::move(thisCluster),
76  algoId_);
77  clusters->back().setSeed(deviceView.seed(i));
78  }
79 
80  // Populate hits and fractions required to compute the cluster's time.
81  // This procedure is complex and involves two SoAs: the original RecHits
82  // SoA and the clustering algorithm's output SoA. Both SoAs have the same
83  // cardinality, and crucially, the output SoA includes the cluster index.
84 
85  // Create a vector of <clusters> locations, where each location holds a
86  // vector of 16 floats. These vectors are used to compute the time for
87  // each cluster. The size of 16 is a heuristic to minimize memory
88  // reallocation and the associated overhead when the vector's capacity
89  // needs to be extended.
90  std::vector<std::vector<float>> times(clusters->size(), std::vector<float>(16, 0.0f));
91  std::vector<std::vector<float>> timeErrors(clusters->size(), std::vector<float>(16, 0.0f));
92  for (int32_t i = 0; i < soaRecHitsExtra_v.metadata().size(); ++i) {
93  if (soaRecHitsExtra_v[i].clusterIndex() == -1) {
94  continue;
95  }
96  assert(soaRecHitsExtra_v[i].clusterIndex() < (int)clusters->size());
97  (*clusters)[soaRecHitsExtra_v[i].clusterIndex()].addHitAndFraction(soaCells_v[i].detid(), 1.f);
98  if (soaCells_v[i].timeError() < 0.f) {
99  continue;
100  }
101  times[soaRecHitsExtra_v[i].clusterIndex()].push_back(soaCells_v[i].time());
102  timeErrors[soaRecHitsExtra_v[i].clusterIndex()].push_back(
103  1.f / (soaCells_v[i].timeError() * soaCells_v[i].timeError()));
104  }
105 
106  // Finally, compute and assign the time to each cluster.
107  std::vector<std::pair<float, float>> cluster_times;
109  for (unsigned i = 0; i < clusters->size(); ++i) {
110  if (detector_ != "BH") {
111  cluster_times.push_back(timeEstimator.fixSizeHighestDensity(times[i], timeErrors[i], hitsTime_));
112  } else {
113  cluster_times.push_back(std::pair<float, float>(-99.f, -1.f));
114  }
115  }
116 
117 #if DEBUG_CLUSTERS_ALPAKA
118  auto runNumber = iEvent.eventAuxiliary().run();
119  auto lumiNumber = iEvent.eventAuxiliary().luminosityBlock();
120  auto evtNumber = iEvent.eventAuxiliary().id().event();
121 
122  hgcalUtils::DumpCellsSoA dumperCellsSoA;
123  dumperCellsSoA.dumpInfos(deviceSoACells, moduleLabel_, runNumber, lumiNumber, evtNumber);
124 
126  dumper.dumpInfos(*clusters, moduleLabel_, runNumber, lumiNumber, evtNumber, true);
127 
128  hgcalUtils::DumpClustersSoA dumperSoA;
129  dumperSoA.dumpInfos(deviceSoARecHitsExtra, moduleLabel_, runNumber, lumiNumber, evtNumber);
130 #endif
131 
132  auto clusterHandle = iEvent.put(std::move(clusters));
133 
134  auto timeCl = std::make_unique<edm::ValueMap<std::pair<float, float>>>();
136  filler.insert(clusterHandle, cluster_times.begin(), cluster_times.end());
137  filler.fill();
138  iEvent.put(std::move(timeCl), timeClname_);
139 
140  // The layerClusterMask for the HGCAL detector is created at a later
141  // stage, when the layer clusters from the different components of HGCAL
142  // are merged together into a unique collection. For the case of HFNose,
143  // since there is no further merging step needed, we create the
144  // layerClustersMask directly here.
145  if (detector_ == "HFNose") {
146  std::unique_ptr<std::vector<float>> layerClustersMask(new std::vector<float>);
147  layerClustersMask->resize(clusterHandle->size(), 1.0);
148  iEvent.put(std::move(layerClustersMask), "InitialLayerClustersMask");
149  }
150  }
edm::EDGetTokenT< HGCalSoARecHitsExtraHostCollection > const getTokenSoARecHitsExtra_
void dumpInfos(const T &clusters, const std::string &moduleLabel, edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event, bool dumpCellsDetId=false) const
edm::EDGetTokenT< HGCalSoAClustersHostCollection > const getTokenSoAClusters_
assert(be >=bs)
std::pair< float, float > fixSizeHighestDensity(std::vector< float > &time, std::vector< float > weight=std::vector< float >(), unsigned int minNhits=3, float deltaT=0.210, float timeWidthBy=0.5)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< HGCalSoARecHitsHostCollection > const getTokenSoACells_
double f[11][100]
void dumpInfos(const T &cells, const std::string &moduleLabel, edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event) const
void dumpInfos(const T &clustersSoA, const std::string &moduleLabel, edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event) const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ algoId_

reco::CaloCluster::AlgoId HGCalLayerClustersFromSoAProducer::algoId_
private

◆ detector_

std::string HGCalLayerClustersFromSoAProducer::detector_
private

◆ getTokenSoACells_

edm::EDGetTokenT<HGCalSoARecHitsHostCollection> const HGCalLayerClustersFromSoAProducer::getTokenSoACells_
private

Definition at line 167 of file HGCalLayerClustersFromSoAProducer.cc.

Referenced by produce().

◆ getTokenSoAClusters_

edm::EDGetTokenT<HGCalSoAClustersHostCollection> const HGCalLayerClustersFromSoAProducer::getTokenSoAClusters_
private

Definition at line 166 of file HGCalLayerClustersFromSoAProducer.cc.

Referenced by produce().

◆ getTokenSoARecHitsExtra_

edm::EDGetTokenT<HGCalSoARecHitsExtraHostCollection> const HGCalLayerClustersFromSoAProducer::getTokenSoARecHitsExtra_
private

Definition at line 168 of file HGCalLayerClustersFromSoAProducer.cc.

Referenced by produce().

◆ hitsTime_

unsigned int HGCalLayerClustersFromSoAProducer::hitsTime_
private

Definition at line 170 of file HGCalLayerClustersFromSoAProducer.cc.

Referenced by produce().

◆ timeClname_

std::string HGCalLayerClustersFromSoAProducer::timeClname_
private