CMS 3D CMS Logo

SiPixelClusterShapeCacheProducer.cc
Go to the documentation of this file.
6 
9 
13 
17 
20 
23 
24 #include <cassert>
25 
27 public:
28  explicit SiPixelClusterShapeCacheProducer(const edm::ParameterSet& iConfig);
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33  void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
34 
35 private:
37 
40 };
41 
43  : token_(consumes<InputCollection>(iConfig.getParameter<edm::InputTag>("src"))), geomToken_(esConsumes()) {
44  if (iConfig.getParameter<bool>("onDemand")) {
45  throw cms::Exception("OnDemandNotAllowed")
46  << "Use of the `onDemand` feature of SiPixelClusterShapeCacheProducer is no longer supported";
47  }
48  produces<SiPixelClusterShapeCache>();
49 }
50 
52 
55  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClusters"));
56  desc.add<bool>("onDemand", false)->setComment("The on demand feature is no longer supported");
57  descriptions.add("siPixelClusterShapeCache", desc);
58 }
59 
62  iEvent.getByToken(token_, input);
63 
64  if (!input.isValid()) {
65  edm::LogError("siPixelClusterShapeCache") << "input pixel cluster collection is not valid!";
66  auto output = std::make_unique<SiPixelClusterShapeCache>();
67  iEvent.put(std::move(output));
68  return;
69  }
70 
71  const auto& geom = &iSetup.getData(geomToken_);
72 
73  auto output = std::make_unique<SiPixelClusterShapeCache>(input);
74  output->resize(input->data().size());
75 
76  ClusterData data; // reused
77  ClusterShape clusterShape;
78 
79  for (const auto& detSet : *input) {
80  const GeomDetUnit* genericDet = geom->idToDetUnit(detSet.detId());
81  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
82  assert(pixDet);
83 
84  edmNew::DetSet<SiPixelCluster>::const_iterator iCluster = detSet.begin(), endCluster = detSet.end();
85  for (; iCluster != endCluster; ++iCluster) {
87  if (not output->isFilled(clusterRef)) {
88  data.size.clear();
89  clusterShape.determineShape(*pixDet, *iCluster, data);
90  output->insert(clusterRef, data);
91  }
92  }
93  }
94  output->shrink_to_fit();
95 
96  iEvent.put(std::move(output));
97 }
98 
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)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiPixelClusterShapeCacheProducer(const edm::ParameterSet &iConfig)
const edm::EDGetTokenT< InputCollection > token_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void determineShape(const PixelGeomDetUnit &pixelDet, const SiPixelRecHit &recHit, ClusterData &data)
Definition: ClusterShape.cc:75
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
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
def move(src, dest)
Definition: eostools.py:511