CMS 3D CMS Logo

MTDDigiGeometryESModule.cc
Go to the documentation of this file.
11 
12 // Alignments
22 
29 
30 #include <memory>
31 
32 //__________________________________________________________________
34  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
35  myLabel_(p.getParameter<std::string>("appendToDataLabel"))
36 {
37  applyAlignment_ = p.getParameter<bool>("applyAlignment");
38  fromDDD_ = p.getParameter<bool>("fromDDD");
39 
40  setWhatProduced(this);
41 
42  edm::LogInfo("Geometry") << "@SUB=MTDDigiGeometryESModule"
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( "mtdGeometryDB", 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( "mtdGeometry", desc );
67 }
68 
69 //__________________________________________________________________
70 std::shared_ptr<MTDGeometry>
72 {
73  //
74  // Called whenever the alignments, alignment errors or global positions change
75  //
77  iRecord.getRecord<IdealGeometryRecord>().get( gD );
78 
80  iRecord.getRecord<MTDTopologyRcd>().get(tTopoHand);
81  const MTDTopology *tTopo=tTopoHand.product();
82 
84  iRecord.getRecord<PMTDParametersRcd>().get( ptp );
85 
87  mtd_ = std::shared_ptr<MTDGeometry>(builder.build(&(*gD), *ptp, tTopo));
88 
89 
90  if (applyAlignment_) {
91  // Since fake is fully working when checking for 'empty', we should get rid of applyAlignment_!
92  edm::ESHandle<Alignments> globalPosition;
93  iRecord.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
94  edm::ESHandle<Alignments> alignments;
95  iRecord.getRecord<MTDAlignmentRcd>().get(alignmentsLabel_, alignments);
97  iRecord.getRecord<MTDAlignmentErrorExtendedRcd>().get(alignmentsLabel_, alignmentErrors);
98  // apply if not empty:
99  if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
100  edm::LogInfo("Config") << "@SUB=MTDDigiGeometryRecord::produce"
101  << "Alignment(Error)s and global position (label '"
102  << alignmentsLabel_ << "') empty: Geometry producer (label "
103  << "'" << myLabel_ << "') assumes fake and does not apply.";
104  } else {
105  GeometryAligner ali;
106  ali.applyAlignments<MTDGeometry>(&(*mtd_), &(*alignments), &(*alignmentErrors),
107  align::DetectorGlobalPosition(*globalPosition,
109  }
110 
112  iRecord.getRecord<MTDSurfaceDeformationRcd>().get(alignmentsLabel_, surfaceDeformations);
113  // apply if not empty:
114  if (surfaceDeformations->empty()) {
115  edm::LogInfo("Config") << "@SUB=MTDDigiGeometryRecord::produce"
116  << "AlignmentSurfaceDeformations (label '"
117  << alignmentsLabel_ << "') empty: Geometry producer (label "
118  << "'" << myLabel_ << "') assumes fake and does not apply.";
119  } else {
120  GeometryAligner ali;
121  ali.attachSurfaceDeformations<MTDGeometry>(&(*mtd_), &(*surfaceDeformations));
122  }
123  }
124 
125 
126  return mtd_;
127 }
128 
T getParameter(std::string const &) const
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.
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
std::shared_ptr< MTDGeometry > produce(const MTDDigiGeometryRecord &)
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:18
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
const std::string alignmentsLabel_
std::shared_ptr< MTDGeometry > mtd_
Called when geometry description changes.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
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)
T const * product() const
Definition: ESHandle.h:86