Go to the documentation of this file.00001
00008 #include "DTGeometryESModule.h"
00009 #include <Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromDDD.h>
00010 #include <Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromCondDB.h>
00011
00012 #include <Geometry/Records/interface/IdealGeometryRecord.h>
00013 #include <Geometry/Records/interface/MuonNumberingRecord.h>
00014 #include "CondFormats/GeometryObjects/interface/RecoIdealGeometry.h"
00015 #include "Geometry/Records/interface/DTRecoGeometryRcd.h"
00016
00017
00018 #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h"
00019 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00020 #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
00021 #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h"
00022 #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorRcd.h"
00023 #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h"
00024
00025 #include <FWCore/Framework/interface/ESHandle.h>
00026 #include <FWCore/Framework/interface/ESTransientHandle.h>
00027 #include <FWCore/Framework/interface/ModuleFactory.h>
00028
00029 #include <memory>
00030 #include <iostream>
00031
00032 using namespace edm;
00033 using namespace std;
00034
00035 DTGeometryESModule::DTGeometryESModule(const edm::ParameterSet & p)
00036 : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
00037 myLabel_(p.getParameter<std::string>("appendToDataLabel")),
00038 fromDDD_(p.getParameter<bool>("fromDDD"))
00039 {
00040
00041 applyAlignment_ = p.getParameter<bool>("applyAlignment");
00042
00043 if(fromDDD_) {
00044 setWhatProduced(this, dependsOn(&DTGeometryESModule::geometryCallback_) );
00045 } else {
00046 setWhatProduced(this, dependsOn(&DTGeometryESModule::dbGeometryCallback_) );
00047 }
00048
00049 edm::LogInfo("Geometry") << "@SUB=DTGeometryESModule"
00050 << "Label '" << myLabel_ << "' "
00051 << (applyAlignment_ ? "looking for" : "IGNORING")
00052 << " alignment labels '" << alignmentsLabel_ << "'.";
00053 }
00054
00055 DTGeometryESModule::~DTGeometryESModule(){}
00056
00057 boost::shared_ptr<DTGeometry>
00058 DTGeometryESModule::produce(const MuonGeometryRecord & record) {
00059
00060
00061
00062
00063 if ( applyAlignment_ ) {
00064
00065
00066 edm::ESHandle<Alignments> globalPosition;
00067 record.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
00068 edm::ESHandle<Alignments> alignments;
00069 record.getRecord<DTAlignmentRcd>().get(alignmentsLabel_, alignments);
00070 edm::ESHandle<AlignmentErrors> alignmentErrors;
00071 record.getRecord<DTAlignmentErrorRcd>().get(alignmentsLabel_, alignmentErrors);
00072
00073 if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
00074 edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
00075 << "Alignment(Error)s and global position (label '"
00076 << alignmentsLabel_ << "') empty: Geometry producer (label "
00077 << "'" << myLabel_ << "') assumes fake and does not apply.";
00078 } else {
00079 GeometryAligner aligner;
00080 aligner.applyAlignments<DTGeometry>( &(*_dtGeometry),
00081 &(*alignments), &(*alignmentErrors),
00082 align::DetectorGlobalPosition(*globalPosition, DetId(DetId::Muon)));
00083 }
00084 }
00085
00086 return _dtGeometry;
00087
00088 }
00089
00090 void DTGeometryESModule::geometryCallback_( const MuonNumberingRecord& record ) {
00091
00092
00093
00094
00095 _dtGeometry = boost::shared_ptr<DTGeometry>(new DTGeometry );
00096 edm::ESHandle<MuonDDDConstants> mdc;
00097 record.get( mdc );
00098
00099 edm::ESTransientHandle<DDCompactView> cpv;
00100 record.getRecord<IdealGeometryRecord>().get(cpv);
00101
00102 DTGeometryBuilderFromDDD builder;
00103 builder.build(_dtGeometry, &(*cpv), *mdc);
00104
00105 }
00106
00107 void DTGeometryESModule::dbGeometryCallback_( const DTRecoGeometryRcd& record ) {
00108
00109
00110
00111
00112 _dtGeometry = boost::shared_ptr<DTGeometry>(new DTGeometry );
00113 edm::ESHandle<RecoIdealGeometry> rig;
00114 record.get(rig);
00115
00116 DTGeometryBuilderFromCondDB builder;
00117 builder.build(_dtGeometry, *rig);
00118
00119 }
00120
00121
00122 DEFINE_FWK_EVENTSETUP_MODULE(DTGeometryESModule);