CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelClusterShapeCacheProducer.cc
Go to the documentation of this file.
6 
9 
13 
17 
20 
23 
24 #include <cassert>
25 
26 namespace {
27  class ClusterShapeLazyGetter: public SiPixelClusterShapeCache::LazyGetter {
28  public:
29  ClusterShapeLazyGetter() {}
30  ~ClusterShapeLazyGetter() {}
31 
32  void fill(const SiPixelClusterShapeCache::ClusterRef& cluster, const PixelGeomDetUnit *pixDet, const SiPixelClusterShapeCache& constCache) const override {
33  if(constCache.isFilled(cluster))
34  return;
35  SiPixelClusterShapeCache& cache = const_cast<SiPixelClusterShapeCache&>(constCache);
36  this->data_.size.clear();
37  this->clusterShape_.determineShape(*pixDet, *cluster, this->data_);
38  cache.insert(cluster, this->data_);
39  }
40 
41  private:
42  mutable ClusterData data_; // reused
43  mutable ClusterShape clusterShape_;
44  };
45 }
46 
48 public:
49  explicit SiPixelClusterShapeCacheProducer(const edm::ParameterSet& iConfig);
51 
52  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
53 
54  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
55 
56 private:
58 
60  const bool onDemand_;
61 };
62 
64  token_(consumes<InputCollection>(iConfig.getParameter<edm::InputTag>("src"))),
65  onDemand_(iConfig.getParameter<bool>("onDemand"))
66 {
67  produces<SiPixelClusterShapeCache>();
68 }
69 
71 
74  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClusters"));
75  desc.add<bool>("onDemand", false);
76  descriptions.add("siPixelClusterShapeCache", desc);
77 }
78 
81  iEvent.getByToken(token_, input);
82 
84  iSetup.get<TrackerDigiGeometryRecord>().get(geom);
85 
86  auto filler = std::make_shared<ClusterShapeLazyGetter>();
87 
88  std::auto_ptr<SiPixelClusterShapeCache> output(onDemand_ ?
89  new SiPixelClusterShapeCache(input, filler) :
90  new SiPixelClusterShapeCache(input));
91  output->resize(input->data().size());
92 
93  if(!onDemand_) {
94  for(const auto& detSet: *input) {
95  const GeomDetUnit *genericDet = geom->idToDetUnit(detSet.detId());
96  const PixelGeomDetUnit *pixDet = dynamic_cast<const PixelGeomDetUnit *>(genericDet);
97  assert(pixDet);
98 
99  edmNew::DetSet<SiPixelCluster>::const_iterator iCluster = detSet.begin(), endCluster = detSet.end();
100  for(; iCluster != endCluster; ++iCluster) {
101  SiPixelClusterShapeCache::ClusterRef clusterRef = edmNew::makeRefTo(input, iCluster);
102  filler->fill(clusterRef, pixDet, *output);
103  }
104  }
105  output->shrink_to_fit();
106  }
107 
108  iEvent.put(output);
109 }
110 
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)
bool isFilled(const ClusterRef &cluster) const
void insert(const ClusterRef &cluster, const T &data)
SiPixelClusterShapeCacheProducer(const edm::ParameterSet &iConfig)
virtual void fill(const ClusterRef &cluster, const PixelGeomDetUnit *pixDet, const SiPixelClusterShapeCache &cache) const =0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
assert(m_qm.get())
data_type const * const_iterator
Definition: DetSetNew.h:30
static std::string const input
Definition: EdmProvDump.cc:43
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< InputCollection > token_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)