CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrackerDigiGeometryESModule.cc
Go to the documentation of this file.
29 
30 #include <memory>
31 #include <string>
32 
34 public:
37  std::unique_ptr<TrackerGeometry> produce(const TrackerDigiGeometryRecord&);
38 
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 private:
45 
51 
56 
57  const bool applyAlignment_; // Switch to apply alignment corrections
58 };
59 
60 //__________________________________________________________________
62  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
63  myLabel_(p.getParameter<std::string>("appendToDataLabel")),
64  applyAlignment_(p.getParameter<bool>("applyAlignment")) {
65  {
66  auto cc = setWhatProduced(this);
67  const edm::ESInputTag kEmptyTag;
68  geometricDetToken_ = cc.consumesFrom<GeometricDet, IdealGeometryRecord>(kEmptyTag);
69  trackerTopoToken_ = cc.consumesFrom<TrackerTopology, TrackerTopologyRcd>(kEmptyTag);
70  trackerParamsToken_ = cc.consumesFrom<PTrackerParameters, PTrackerParametersRcd>(kEmptyTag);
73 
74  if (applyAlignment_) {
75  const edm::ESInputTag kAlignTag{"", alignmentsLabel_};
76  globalAlignmentToken_ = cc.consumesFrom<Alignments, GlobalPositionRcd>(kAlignTag);
77  trackerAlignmentToken_ = cc.consumesFrom<Alignments, TrackerAlignmentRcd>(kAlignTag);
80  }
81  }
82 
83  edm::LogInfo("Geometry") << "@SUB=TrackerDigiGeometryESModule"
84  << "Label '" << myLabel_ << "' " << (applyAlignment_ ? "looking for" : "IGNORING")
85  << " alignment labels '" << alignmentsLabel_ << "'.";
86 }
87 
88 //__________________________________________________________________
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("trackerGeometryDB", 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("trackerGeometry", desc);
105 }
106 
107 //__________________________________________________________________
108 std::unique_ptr<TrackerGeometry> TrackerDigiGeometryESModule::produce(const TrackerDigiGeometryRecord& iRecord) {
109  //
110  // Called whenever the alignments, alignment errors or global positions change
111  //
112  auto const& gD = iRecord.get(geometricDetToken_);
113 
114  auto const& tTopo = iRecord.get(trackerTopoToken_);
115 
116  auto const& ptp = iRecord.get(trackerParamsToken_);
117 
118  auto const& ptitp = iRecord.get(trackerGeometricDetExtraToken_);
119 
121  std::unique_ptr<TrackerGeometry> tracker(builder.build(&gD, &ptitp, ptp, &tTopo));
122 
123  if (applyAlignment_) {
124  // Since fake is fully working when checking for 'empty', we should get rid of applyAlignment_!
125  auto const& globalPosition = iRecord.get(globalAlignmentToken_);
126  auto const& alignments = iRecord.get(trackerAlignmentToken_);
127  auto const& alignmentErrors = iRecord.get(alignmentErrorsToken_);
128  // apply if not empty:
129  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
130  edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
131  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
132  << "') empty: Geometry producer (label "
133  << "'" << myLabel_ << "') assumes fake and does not apply.";
134  } else {
135  GeometryAligner ali;
136  ali.applyAlignments<TrackerGeometry>(tracker.get(),
137  &(alignments),
138  &(alignmentErrors),
140  }
141 
142  auto const& surfaceDeformations = iRecord.get(deformationsToken_);
143  // apply if not empty:
144  if (surfaceDeformations.empty()) {
145  edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
146  << "AlignmentSurfaceDeformations (label '" << alignmentsLabel_
147  << "') empty: Geometry producer (label "
148  << "'" << myLabel_ << "') assumes fake and does not apply.";
149  } else {
150  GeometryAligner ali;
151  ali.attachSurfaceDeformations<TrackerGeometry>(tracker.get(), &(surfaceDeformations));
152  }
153  }
154 
155  return tracker;
156 }
157 
void attachSurfaceDeformations(const C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
Class to update a given geometry with a set of alignments.
TrackerGeometry * build(const GeometricDet *gd, const PTrackerAdditionalParametersPerDet *ptitp, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geometricDetToken_
std::unique_ptr< TrackerGeometry > produce(const TrackerDigiGeometryRecord &)
edm::ESGetToken< AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd > alignmentErrorsToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopoToken_
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
edm::ESGetToken< Alignments, GlobalPositionRcd > globalAlignmentToken_
const std::string alignmentsLabel_
Called when geometry description changes.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::ESGetToken< AlignmentSurfaceDeformations, TrackerSurfaceDeformationRcd > deformationsToken_
Log< level::Info, false > LogInfo
Definition: DetId.h:17
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void add(std::string const &label, ParameterSetDescription const &psetDescription)
TrackerDigiGeometryESModule(const edm::ParameterSet &p)
edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > trackerParamsToken_
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
edm::ESGetToken< Alignments, TrackerAlignmentRcd > trackerAlignmentToken_
edm::ESGetToken< PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd > trackerGeometricDetExtraToken_