CMS 3D CMS Logo

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

Public Member Functions

void produce (edm::Event &e, const edm::EventSetup &c) override
 The "Event" entrypoint: gets called by framework for every event. More...
 
void run (edm::Event &e, edm::Handle< SiPixelClusterCollectionNew > inputhandle, SiPixelRecHitCollectionNew &output, TrackerGeometry const &geom)
 
 SiPixelRecHitConverter (const edm::ParameterSet &conf)
 Constructor: set the ParameterSet and defer all thinking to setupCPE(). More...
 
 ~SiPixelRecHitConverter () override
 
- 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
 

Private Types

using HMSstorage = HostProduct< uint32_t[]>
 

Private Attributes

PixelCPEBase const * cpe_ = nullptr
 
std::string const cpeName_
 
bool m_newCont
 
edm::InputTag const src_
 
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const tCPE_
 
edm::EDPutTokenT< HMSstorage > const tHost_
 
edm::EDGetTokenT< SiPixelClusterCollectionNew > const tPixelCluster_
 
edm::EDPutTokenT< SiPixelRecHitCollection > const tPut_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > const tTrackerGeom_
 

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 92 of file SiPixelRecHitConverter.cc.

Member Typedef Documentation

◆ HMSstorage

Definition at line 116 of file SiPixelRecHitConverter.cc.

Constructor & Destructor Documentation

◆ SiPixelRecHitConverter()

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

Constructor: set the ParameterSet and defer all thinking to setupCPE().

Definition at line 133 of file SiPixelRecHitConverter.cc.

134  : src_(conf.getParameter<edm::InputTag>("src")),
135  cpeName_(conf.getParameter<std::string>("CPE")),
136  tPixelCluster_(consumes<SiPixelClusterCollectionNew>(src_)),
137  tPut_(produces<SiPixelRecHitCollection>()),
138  tHost_(produces<HMSstorage>()),
139  tTrackerGeom_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
140  tCPE_(esConsumes<PixelClusterParameterEstimator, TkPixelCPERecord>(edm::ESInputTag("", cpeName_))) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDPutTokenT< HMSstorage > const tHost_
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const tCPE_
edm::EDGetTokenT< SiPixelClusterCollectionNew > const tPixelCluster_
edm::EDPutTokenT< SiPixelRecHitCollection > const tPut_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > const tTrackerGeom_

◆ ~SiPixelRecHitConverter()

SiPixelRecHitConverter::~SiPixelRecHitConverter ( )
override

Definition at line 143 of file SiPixelRecHitConverter.cc.

143 {}

Member Function Documentation

◆ produce()

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

The "Event" entrypoint: gets called by framework for every event.

Definition at line 148 of file SiPixelRecHitConverter.cc.

References cpe_, MillePedeFileConverter_cfg::e, relativeConstraints::geom, edm::EventSetup::getData(), input, eostools::move(), convertSQLitetoXML_cfg::output, run(), tCPE_, tPixelCluster_, tPut_, and tTrackerGeom_.

148  {
149  // Step A.1: get input data
151  e.getByToken(tPixelCluster_, input);
152 
153  // Step A.2: get event setup
154  auto const& geom = es.getData(tTrackerGeom_);
155 
156  // Step B: create empty output collection
158 
159  // Step B*: create CPE
160  cpe_ = dynamic_cast<const PixelCPEBase*>(&es.getData(tCPE_));
161 
162  // Step C: Iterate over DetIds and invoke the strip CPE algorithm
163  // on each DetUnit
164 
165  run(e, input, output, geom);
166 
167  output.shrink_to_fit();
168  e.emplace(tPut_, std::move(output));
169  }
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const tCPE_
edm::EDGetTokenT< SiPixelClusterCollectionNew > const tPixelCluster_
static std::string const input
Definition: EdmProvDump.cc:50
void run(edm::Event &e, edm::Handle< SiPixelClusterCollectionNew > inputhandle, SiPixelRecHitCollectionNew &output, TrackerGeometry const &geom)
edm::EDPutTokenT< SiPixelRecHitCollection > const tPut_
Definition: output.py:1
def move(src, dest)
Definition: eostools.py:511
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > const tTrackerGeom_

◆ run()

void SiPixelRecHitConverter::run ( edm::Event iEvent,
edm::Handle< SiPixelClusterCollectionNew inputhandle,
SiPixelRecHitCollectionNew output,
TrackerGeometry const &  geom 
)

Iterate over DetUnits, then over Clusters and invoke the CPE on each, and make a RecHit to store the result. New interface reading DetSetVector by V.Chiochia (May 30th, 2006)

Definition at line 176 of file SiPixelRecHitConverter.cc.

References cms::cuda::assert(), cpe_, cpeName_, relativeConstraints::geom, PixelCPEBase::getParameters(), mps_fire::i, iEvent, GeomDet::index(), input, LogDebug, edmNew::makeRefTo(), gpuClustering::maxNumModules, eostools::move(), dqmiodumpmetadata::n, electrons_cff::numberOfClusters, edmNew::DetSetVector< T >::FastFiller::push_back(), edmNew::DetSetVector< T >::FastFiller::size(), tHost_, and mkLumiAveragedPlots::tuple.

Referenced by produce().

179  {
180  if (!cpe_) {
181  edm::LogError("SiPixelRecHitConverter") << " at least one CPE is not ready -- can't run!";
182  // TO DO: throw an exception here? The user may want to know...
183  assert(0);
184  return; // clusterizer is invalid, bail out
185  }
186 
187  int numberOfDetUnits = 0;
188  int numberOfClusters = 0;
189 
190  const SiPixelClusterCollectionNew& input = *inputhandle;
191 
192  // allocate a buffer for the indices of the clusters
193  auto hmsp = std::make_unique<uint32_t[]>(gpuClustering::maxNumModules + 1);
194  // hitsModuleStart is a non-owning pointer to the buffer
195  auto hitsModuleStart = hmsp.get();
196  // fill cluster arrays
197  std::array<uint32_t, gpuClustering::maxNumModules + 1> clusInModule{};
198  for (auto const& dsv : input) {
199  unsigned int detid = dsv.detId();
200  DetId detIdObject(detid);
201  const GeomDetUnit* genericDet = geom.idToDetUnit(detIdObject);
202  auto gind = genericDet->index();
203  // FIXME to be changed to support Phase2
204  if (gind >= int(gpuClustering::maxNumModules))
205  continue;
206  auto const nclus = dsv.size();
207  assert(nclus > 0);
208  clusInModule[gind] = nclus;
209  numberOfClusters += nclus;
210  }
211  hitsModuleStart[0] = 0;
212  assert(clusInModule.size() > gpuClustering::maxNumModules);
213  for (int i = 1, n = clusInModule.size(); i < n; ++i)
214  hitsModuleStart[i] = hitsModuleStart[i - 1] + clusInModule[i - 1];
215  assert(numberOfClusters == int(hitsModuleStart[gpuClustering::maxNumModules]));
216 
217  // wrap the buffer in a HostProduct, and move it to the Event, without reallocating the buffer or affecting hitsModuleStart
218  iEvent.emplace(tHost_, std::move(hmsp));
219 
220  numberOfClusters = 0;
221  for (auto const& dsv : input) {
222  numberOfDetUnits++;
223  unsigned int detid = dsv.detId();
224  DetId detIdObject(detid);
225  const GeomDetUnit* genericDet = geom.idToDetUnit(detIdObject);
226  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
227  assert(pixDet);
228  SiPixelRecHitCollectionNew::FastFiller recHitsOnDetUnit(output, detid);
229 
230  edmNew::DetSet<SiPixelCluster>::const_iterator clustIt = dsv.begin(), clustEnd = dsv.end();
231 
232  for (; clustIt != clustEnd; clustIt++) {
234  std::tuple<LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType> tuple =
235  cpe_->getParameters(*clustIt, *genericDet);
236  LocalPoint lp(std::get<0>(tuple));
237  LocalError le(std::get<1>(tuple));
238  SiPixelRecHitQuality::QualWordType rqw(std::get<2>(tuple));
239  // Create a persistent edm::Ref to the cluster
240  SiPixelClusterRefNew cluster = edmNew::makeRefTo(inputhandle, clustIt);
241  // Make a RecHit and add it to the DetSet
242  SiPixelRecHit hit(lp, le, rqw, *genericDet, cluster);
243  recHitsOnDetUnit.push_back(hit);
244 
245  LogDebug("SiPixelRecHitConverter") << "RecHit " << (numberOfClusters - 1) //
246  << " with local position " << lp << " and local error " << le;
247  } // <-- End loop on Clusters
248 
249  LogDebug("SiPixelRecHitConverter") << "Found " << recHitsOnDetUnit.size() << " RecHits on " << detid;
250 
251  } // <-- End loop on DetUnits
252 
253  LogDebug("SiPixelRecHitConverter") << cpeName_ << " converted " << numberOfClusters
254  << " SiPixelClusters into SiPixelRecHits, in " << numberOfDetUnits
255  << " DetUnits.";
256  }
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
edm::EDPutTokenT< HMSstorage > const tHost_
int index() const
Definition: GeomDet.h:83
data_type const * const_iterator
Definition: DetSetNew.h:31
Log< level::Error, false > LogError
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:50
int iEvent
Definition: GenABIO.cc:224
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const override
Definition: PixelCPEBase.h:134
constexpr uint16_t maxNumModules
Definition: DetId.h:17
Definition: output.py:1
def move(src, dest)
Definition: eostools.py:511
Our base class.
Definition: SiPixelRecHit.h:23
#define LogDebug(id)

Member Data Documentation

◆ cpe_

PixelCPEBase const* cms::SiPixelRecHitConverter::cpe_ = nullptr
private

Definition at line 119 of file SiPixelRecHitConverter.cc.

Referenced by produce(), and run().

◆ cpeName_

std::string const cms::SiPixelRecHitConverter::cpeName_
private

Definition at line 121 of file SiPixelRecHitConverter.cc.

Referenced by run().

◆ m_newCont

bool cms::SiPixelRecHitConverter::m_newCont
private

Definition at line 127 of file SiPixelRecHitConverter.cc.

◆ src_

edm::InputTag const cms::SiPixelRecHitConverter::src_
private

Definition at line 120 of file SiPixelRecHitConverter.cc.

◆ tCPE_

edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> const cms::SiPixelRecHitConverter::tCPE_
private

Definition at line 126 of file SiPixelRecHitConverter.cc.

Referenced by produce().

◆ tHost_

edm::EDPutTokenT<HMSstorage> const cms::SiPixelRecHitConverter::tHost_
private

Definition at line 124 of file SiPixelRecHitConverter.cc.

Referenced by run().

◆ tPixelCluster_

edm::EDGetTokenT<SiPixelClusterCollectionNew> const cms::SiPixelRecHitConverter::tPixelCluster_
private

Definition at line 122 of file SiPixelRecHitConverter.cc.

Referenced by produce().

◆ tPut_

edm::EDPutTokenT<SiPixelRecHitCollection> const cms::SiPixelRecHitConverter::tPut_
private

Definition at line 123 of file SiPixelRecHitConverter.cc.

Referenced by produce().

◆ tTrackerGeom_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> const cms::SiPixelRecHitConverter::tTrackerGeom_
private

Definition at line 125 of file SiPixelRecHitConverter.cc.

Referenced by produce().