CMS 3D CMS Logo

DTGeometryESModule.cc

Go to the documentation of this file.
00001 
00008 #include "DTGeometryESModule.h"
00009 #include <Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromDDD.h>
00010 
00011 #include <Geometry/Records/interface/IdealGeometryRecord.h>
00012 #include <Geometry/Records/interface/MuonNumberingRecord.h>
00013 
00014 // Alignments
00015 #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h"
00016 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00017 #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
00018 #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h"
00019 #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorRcd.h"
00020 #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h"
00021 
00022 #include <FWCore/Framework/interface/ESHandle.h>
00023 #include <FWCore/Framework/interface/ModuleFactory.h>
00024 
00025 #include <memory>
00026 
00027 using namespace edm;
00028 
00029 DTGeometryESModule::DTGeometryESModule(const edm::ParameterSet & p)
00030   : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
00031     myLabel_(p.getParameter<std::string>("appendToDataLabel"))
00032 {
00033 
00034   applyAlignment_ = p.getParameter<bool>("applyAlignment");
00035 
00036   setWhatProduced(this, dependsOn(&DTGeometryESModule::geometryCallback_) );
00037 
00038   edm::LogInfo("Geometry") << "@SUB=DTGeometryESModule"
00039                            << "Label '" << myLabel_ << "' "
00040                            << (applyAlignment_ ? "looking for" : "IGNORING")
00041                            << " alignment labels '" << alignmentsLabel_ << "'.";
00042 }
00043 
00044 
00045 DTGeometryESModule::~DTGeometryESModule(){}
00046 
00047 
00048 boost::shared_ptr<DTGeometry>
00049 DTGeometryESModule::produce(const MuonGeometryRecord & record) {
00050 
00051   //
00052   // Called whenever the alignments or alignment errors change
00053   //  
00054   if ( applyAlignment_ ) {
00055     // applyAlignment_ is scheduled for removal. 
00056     // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
00057     edm::ESHandle<Alignments> globalPosition;
00058     record.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
00059     edm::ESHandle<Alignments> alignments;
00060     record.getRecord<DTAlignmentRcd>().get(alignmentsLabel_, alignments);
00061     edm::ESHandle<AlignmentErrors> alignmentErrors;
00062     record.getRecord<DTAlignmentErrorRcd>().get(alignmentsLabel_, alignmentErrors);
00063     // Only apply alignment if values exist
00064     if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
00065       edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
00066                              << "Alignment(Error)s and global position (label '"
00067                              << alignmentsLabel_ << "') empty: Geometry producer (label "
00068                              << "'" << myLabel_ << "') assumes fake and does not apply.";
00069     } else {
00070       GeometryAligner aligner;
00071       aligner.applyAlignments<DTGeometry>( &(*_dtGeometry),
00072                                            &(*alignments), &(*alignmentErrors),
00073                                            align::DetectorGlobalPosition(*globalPosition, DetId(DetId::Muon)));
00074     }
00075   }
00076 
00077   return _dtGeometry;
00078 
00079 }
00080 
00081 
00082 //______________________________________________________________________________
00083 void DTGeometryESModule::geometryCallback_( const MuonNumberingRecord& record )
00084 {
00085   
00086   //
00087   // Called whenever the muon numbering (or ideal geometry) changes
00088   //
00089   edm::ESHandle<DDCompactView> cpv;
00090   edm::ESHandle<MuonDDDConstants> mdc;
00091   record.getRecord<IdealGeometryRecord>().get(cpv);
00092   record.get( mdc );
00093   DTGeometryBuilderFromDDD builder;
00094   _dtGeometry = boost::shared_ptr<DTGeometry>(builder.build(&(*cpv), *mdc));
00095 
00096 }
00097 DEFINE_FWK_EVENTSETUP_MODULE(DTGeometryESModule);

Generated on Tue Jun 9 17:37:21 2009 for CMSSW by  doxygen 1.5.4