CMS 3D CMS Logo

MTDDigiGeometryESModule.cc
Go to the documentation of this file.
5 
13 
14 // Alignments
24 
31 
32 #include <memory>
33 #include <string>
34 
36 public:
38  std::unique_ptr<MTDGeometry> produce(const MTDDigiGeometryRecord&);
39 
40  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
41 
42 private:
46 
50 
51  //alignment
56 
57  const bool applyAlignment_; // Switch to apply alignment corrections
58  const bool fromDDD_;
59 };
60 
61 //__________________________________________________________________
63  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
64  myLabel_(p.getParameter<std::string>("appendToDataLabel")),
65  applyAlignment_(p.getParameter<bool>("applyAlignment")),
66  fromDDD_(p.getParameter<bool>("fromDDD"))
67 
68 {
69  auto cc = setWhatProduced(this);
70  const edm::ESInputTag kEmpty;
74 
75  {
76  const edm::ESInputTag kAlignTag{"", alignmentsLabel_};
77  globalAlignToken_ = cc.consumesFrom<Alignments, GlobalPositionRcd>(kAlignTag);
78  mtdAlignToken_ = cc.consumesFrom<Alignments, MTDAlignmentRcd>(kAlignTag);
81  }
82 
83  edm::LogInfo("Geometry") << "@SUB=MTDDigiGeometryESModule"
84  << "Label '" << myLabel_ << "' " << (applyAlignment_ ? "looking for" : "IGNORING")
85  << " alignment labels '" << alignmentsLabel_ << "'.";
86 }
87 
88 //__________________________________________________________________
91  descDB.add<std::string>("appendToDataLabel", "");
92  descDB.add<bool>("fromDDD", false);
93  descDB.add<bool>("applyAlignment", true);
94  descDB.add<std::string>("alignmentsLabel", "");
95  descriptions.add("mtdGeometryDB", descDB);
96 
98  desc.add<std::string>("appendToDataLabel", "");
99  desc.add<bool>("fromDDD", true);
100  desc.add<bool>("applyAlignment", true);
101  desc.add<std::string>("alignmentsLabel", "");
102  descriptions.add("mtdGeometry", desc);
103 }
104 
105 //__________________________________________________________________
106 std::unique_ptr<MTDGeometry> MTDDigiGeometryESModule::produce(const MTDDigiGeometryRecord& iRecord) {
107  //
108  // Called whenever the alignments, alignment errors or global positions change
109  //
110  GeometricTimingDet const& gD = iRecord.get(geomTimingDetToken_);
111 
112  MTDTopology const& tTopo = iRecord.get(mtdTopoToken_);
113 
114  PMTDParameters const& ptp = iRecord.get(pmtdParamsToken_);
115 
117  std::unique_ptr<MTDGeometry> mtd(builder.build(&(gD), ptp, &tTopo));
118 
119  if (applyAlignment_) {
120  // Since fake is fully working when checking for 'empty', we should get rid of applyAlignment_!
121  Alignments const& globalPosition = iRecord.get(globalAlignToken_);
122  Alignments const& alignments = iRecord.get(mtdAlignToken_);
123  AlignmentErrorsExtended const& alignmentErrors = iRecord.get(alignErrorsToken_);
124  // apply if not empty:
125  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
126  edm::LogInfo("Config") << "@SUB=MTDDigiGeometryRecord::produce"
127  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
128  << "') empty: Geometry producer (label "
129  << "'" << myLabel_ << "') assumes fake and does not apply.";
130  } else {
131  GeometryAligner ali;
132  ali.applyAlignments<MTDGeometry>(mtd.get(),
133  &(alignments),
134  &(alignmentErrors),
136  }
137 
138  AlignmentSurfaceDeformations const& surfaceDeformations = iRecord.get(deformationsToken_);
139  // apply if not empty:
140  if (surfaceDeformations.empty()) {
141  edm::LogInfo("Config") << "@SUB=MTDDigiGeometryRecord::produce"
142  << "AlignmentSurfaceDeformations (label '" << alignmentsLabel_
143  << "') empty: Geometry producer (label "
144  << "'" << myLabel_ << "') assumes fake and does not apply.";
145  } else {
146  GeometryAligner ali;
147  ali.attachSurfaceDeformations<MTDGeometry>(mtd.get(), &(surfaceDeformations));
148  }
149  }
150 
151  return mtd;
152 }
153 
void attachSurfaceDeformations(const C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
edm::ESGetToken< GeometricTimingDet, IdealGeometryRecord > geomTimingDetToken_
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
edm::ESGetToken< Alignments, MTDAlignmentRcd > mtdAlignToken_
Class to update a given geometry with a set of alignments.
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< MTDTopology, MTDTopologyRcd > mtdTopoToken_
edm::ESGetToken< AlignmentSurfaceDeformations, MTDSurfaceDeformationRcd > deformationsToken_
bool empty() const
Test of empty vector without having to look into internals:
edm::ESGetToken< Alignments, GlobalPositionRcd > globalAlignToken_
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< PMTDParameters, PMTDParametersRcd > pmtdParamsToken_
bool empty() const
Test of empty vector without having to look into internals:
Definition: Alignments.h:15
edm::ESGetToken< AlignmentErrorsExtended, MTDAlignmentErrorExtendedRcd > alignErrorsToken_
MTDDigiGeometryESModule(const edm::ParameterSet &p)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
bool empty() const
Test of empty vector without having to look into internals:
MTDGeometry * build(const GeometricTimingDet *gd, const PMTDParameters &ptp, const MTDTopology *tTopo)
Log< level::Info, false > LogInfo
Definition: DetId.h:17
const std::string alignmentsLabel_
Called when geometry description changes.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
std::unique_ptr< MTDGeometry > produce(const MTDDigiGeometryRecord &)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const