CMS 3D CMS Logo

TrackerDigiGeometryESModule.cc
Go to the documentation of this file.
6 
7 // Alignments
10 
17 
18 #include <memory>
19 
20 //__________________________________________________________________
22  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
23  myLabel_(p.getParameter<std::string>("appendToDataLabel")),
24  applyAlignment_(p.getParameter<bool>("applyAlignment"))
25 {
26  {
27  auto cc = setWhatProduced(this);
28  const edm::ESInputTag kEmptyTag;
29  geometricDetToken_ = cc.consumesFrom<GeometricDet,IdealGeometryRecord>(kEmptyTag);
30  trackerTopoToken_ = cc.consumesFrom<TrackerTopology,TrackerTopologyRcd>(kEmptyTag);
31  trackerParamsToken_ = cc.consumesFrom<PTrackerParameters,PTrackerParametersRcd>(kEmptyTag);
32 
33  if(applyAlignment_) {
34  const edm::ESInputTag kAlignTag{"",alignmentsLabel_};
35  globalAlignmentToken_ = cc.consumesFrom<Alignments,GlobalPositionRcd>(kAlignTag);
36  trackerAlignmentToken_ = cc.consumesFrom<Alignments,TrackerAlignmentRcd>(kAlignTag);
39  }
40  }
41 
42  edm::LogInfo("Geometry") << "@SUB=TrackerDigiGeometryESModule"
43  << "Label '" << myLabel_ << "' "
44  << (applyAlignment_ ? "looking for" : "IGNORING")
45  << " alignment labels '" << alignmentsLabel_ << "'.";
46 }
47 
48 //__________________________________________________________________
50 
51 void
53 {
55  descDB.add<std::string>( "appendToDataLabel", "" );
56  descDB.add<bool>( "fromDDD", false );
57  descDB.add<bool>( "applyAlignment", true );
58  descDB.add<std::string>( "alignmentsLabel", "" );
59  descriptions.add( "trackerGeometryDB", descDB );
60 
62  desc.add<std::string>( "appendToDataLabel", "" );
63  desc.add<bool>( "fromDDD", true );
64  desc.add<bool>( "applyAlignment", true );
65  desc.add<std::string>( "alignmentsLabel", "" );
66  descriptions.add( "trackerGeometry", desc );
67 }
68 
69 //__________________________________________________________________
70 std::unique_ptr<TrackerGeometry>
72 {
73  //
74  // Called whenever the alignments, alignment errors or global positions change
75  //
76  auto const& gD = iRecord.get( geometricDetToken_ );
77 
78  auto const& tTopo = iRecord.get(trackerTopoToken_);
79 
80  auto const& ptp = iRecord.get( trackerParamsToken_ );
81 
83  std::unique_ptr<TrackerGeometry> tracker(builder.build(&gD, ptp, &tTopo));
84 
85  if (applyAlignment_) {
86  // Since fake is fully working when checking for 'empty', we should get rid of applyAlignment_!
87  auto const& globalPosition = iRecord.get( globalAlignmentToken_ );
88  auto const& alignments = iRecord.get( trackerAlignmentToken_ );
89  auto const& alignmentErrors = iRecord.get( alignmentErrorsToken_ );
90  // apply if not empty:
91  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
92  edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
93  << "Alignment(Error)s and global position (label '"
94  << alignmentsLabel_ << "') empty: Geometry producer (label "
95  << "'" << myLabel_ << "') assumes fake and does not apply.";
96  } else {
97  GeometryAligner ali;
98  ali.applyAlignments<TrackerGeometry>(tracker.get(), &(alignments), &(alignmentErrors),
99  align::DetectorGlobalPosition(globalPosition,
101  }
102 
103  auto const& surfaceDeformations = iRecord.get( deformationsToken_ );
104  // apply if not empty:
105  if (surfaceDeformations.empty()) {
106  edm::LogInfo("Config") << "@SUB=TrackerDigiGeometryRecord::produce"
107  << "AlignmentSurfaceDeformations (label '"
108  << alignmentsLabel_ << "') empty: Geometry producer (label "
109  << "'" << myLabel_ << "') assumes fake and does not apply.";
110  } else {
111  GeometryAligner ali;
112  ali.attachSurfaceDeformations<TrackerGeometry>(tracker.get(), &(surfaceDeformations));
113  }
114  }
115 
116  return tracker;
117 }
118 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
Class to update a given geometry with a set of alignments.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
std::unique_ptr< TrackerGeometry > produce(const TrackerDigiGeometryRecord &)
edm::ESGetToken< AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd > alignmentErrorsToken_
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geometricDetToken_
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
const std::string alignmentsLabel_
Called when geometry description changes.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::ESGetToken< AlignmentSurfaceDeformations, TrackerSurfaceDeformationRcd > deformationsToken_
edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > trackerParamsToken_
Definition: DetId.h:18
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
edm::ESGetToken< Alignments, TrackerAlignmentRcd > trackerAlignmentToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
TrackerDigiGeometryESModule(const edm::ParameterSet &p)
edm::ESGetToken< Alignments, GlobalPositionRcd > globalAlignmentToken_
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopoToken_