CMS 3D CMS Logo

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