CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CaloGeometryEP.h
Go to the documentation of this file.
1 #ifndef GEOMETRY_CALOGEOMETRY_CALOGEOMETRYEP_H
2 #define GEOMETRY_CALOGEOMETRY_CALOGEOMETRYEP_H
3 
4 #include <memory>
14 
15 template <class T, class D>
17 public:
19  using PtrType = typename LoaderType::PtrType;
20 
21  CaloGeometryEP<T, D>(const edm::ParameterSet& ps) : applyAlignment_(ps.getParameter<bool>("applyAlignment")) {
22  auto cc = setWhatProduced(this, &CaloGeometryEP<T, D>::produceAligned, edm::es::Label(T::producerTag()));
23 
24  if (applyAlignment_) {
25  alignmentsToken_ = cc.template consumesFrom<Alignments, typename T::AlignmentRecord>(edm::ESInputTag{});
26  globalsToken_ = cc.template consumesFrom<Alignments, GlobalPositionRcd>(edm::ESInputTag{});
27  }
28  cpvToken_ = cc.template consumesFrom<D, IdealGeometryRecord>(edm::ESInputTag{});
29  }
30 
31  ~CaloGeometryEP<T, D>() override {}
32  PtrType produceAligned(const typename T::AlignedRecord& iRecord) {
33  const Alignments* alignPtr(nullptr);
34  const Alignments* globalPtr(nullptr);
35  if (applyAlignment_) // get ptr if necessary
36  {
37  const auto& alignments = iRecord.get(alignmentsToken_);
38  // require expected size
39  assert(alignments.m_align.size() == T::numberOfAlignments());
40  alignPtr = &alignments;
41 
42  const auto& globals = iRecord.get(globalsToken_);
43  globalPtr = &globals;
44  }
45  edm::ESTransientHandle<D> cpv = iRecord.getTransientHandle(cpvToken_);
46 
47  LoaderType loader;
48  return loader.load(cpv.product(), alignPtr, globalPtr);
49  }
50 
51 private:
56 };
57 
58 #endif
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ESGetToken< Alignments, GlobalPositionRcd > globalsToken_
typename LoaderType::PtrType PtrType
assert(be >=bs)
edm::ESGetToken< D, IdealGeometryRecord > cpvToken_
edm::ESGetToken< Alignments, typename T::AlignmentRecord > alignmentsToken_
T const * product() const
PtrType produceAligned(const typename T::AlignedRecord &iRecord)