Go to the documentation of this file.00001
00002 #include "CSCGeometryESModule.h"
00003 #include "Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h"
00004 #include "Geometry/CSCGeometryBuilder/src/CSCGeometryBuilder.h"
00005 #include "Geometry/CSCGeometry/interface/CSCChamberSpecs.h"
00006
00007 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00008 #include "Geometry/Records/interface/MuonNumberingRecord.h"
00009
00010
00011
00012
00013 #include "Geometry/Records/interface/CSCRecoGeometryRcd.h"
00014 #include "Geometry/Records/interface/CSCRecoDigiParametersRcd.h"
00015 #include "CondFormats/GeometryObjects/interface/RecoIdealGeometry.h"
00016 #include "CondFormats/GeometryObjects/interface/CSCRecoDigiParameters.h"
00017 #include "DetectorDescription/Core/interface/DDCompactView.h"
00018
00019
00020 #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h"
00021 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00022 #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
00023 #include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h"
00024 #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorRcd.h"
00025 #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h"
00026
00027 #include "FWCore/Framework/interface/ESHandle.h"
00028 #include "FWCore/Framework/interface/ESTransientHandle.h"
00029 #include "FWCore/Framework/interface/ModuleFactory.h"
00030
00031 #include <memory>
00032
00033 using namespace edm;
00034
00035 CSCGeometryESModule::CSCGeometryESModule(const edm::ParameterSet & p)
00036 : recreateGeometry_(true),
00037 alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
00038 myLabel_(p.getParameter<std::string>("appendToDataLabel"))
00039 {
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 useRealWireGeometry = p.getParameter<bool>("useRealWireGeometry");
00050
00051
00052
00053 useOnlyWiresInME1a = p.getParameter<bool>("useOnlyWiresInME1a");
00054
00055
00056
00057
00058 useGangedStripsInME1a = p.getParameter<bool>("useGangedStripsInME1a");
00059
00060 if ( useGangedStripsInME1a ) useOnlyWiresInME1a = false;
00061
00062
00063 useCentreTIOffsets = p.getParameter<bool>("useCentreTIOffsets");
00064
00065
00066
00067 debugV = p.getUntrackedParameter<bool>("debugV", false);
00068
00069
00070 useDDD_ = p.getParameter<bool>("useDDD");
00071
00072
00073 applyAlignment_ = p.getParameter<bool>("applyAlignment");
00074
00075
00076 edm::LogInfo("Geometry") << "@SUB=CSCGeometryESModule"
00077 << "Label '" << myLabel_ << "' "
00078 << (applyAlignment_ ? "looking for" : "IGNORING")
00079 << " alignment labels '" << alignmentsLabel_ << "'.";
00080 if(useDDD_) {
00081 setWhatProduced(this, dependsOn(&CSCGeometryESModule::muonNumberingChanged_) );
00082 } else {
00083 setWhatProduced(this, dependsOn(&CSCGeometryESModule::cscRecoGeometryChanged_) & (&CSCGeometryESModule::cscRecoDigiParametersChanged_) );
00084 }
00085 }
00086
00087
00088 CSCGeometryESModule::~CSCGeometryESModule(){}
00089
00090
00091 boost::shared_ptr<CSCGeometry> CSCGeometryESModule::produce(const MuonGeometryRecord& record) {
00092
00093 initCSCGeometry_(record);
00094
00095
00096
00097 if ( applyAlignment_ ) {
00098
00099
00100 edm::ESHandle<Alignments> globalPosition;
00101 record.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
00102 edm::ESHandle<Alignments> alignments;
00103 record.getRecord<CSCAlignmentRcd>().get(alignmentsLabel_, alignments);
00104 edm::ESHandle<AlignmentErrors> alignmentErrors;
00105
00106
00107
00108
00109
00110
00111
00112 record.getRecord<CSCAlignmentErrorRcd>().get(alignmentsLabel_, alignmentErrors);
00113
00114 if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
00115 edm::LogInfo("Config") << "@SUB=CSCGeometryRecord::produce"
00116 << "Alignment(Error)s and global position (label '"
00117 << alignmentsLabel_ << "') empty: Geometry producer (label "
00118 << "'" << myLabel_ << "') assumes fake and does not apply.";
00119 } else {
00120 GeometryAligner aligner;
00121 aligner.applyAlignments<CSCGeometry>( &(*cscGeometry), &(*alignments), &(*alignmentErrors),
00122 align::DetectorGlobalPosition(*globalPosition, DetId(DetId::Muon)) );
00123 }
00124
00125 }
00126
00127 return cscGeometry;
00128 }
00129
00130
00131 void CSCGeometryESModule::initCSCGeometry_( const MuonGeometryRecord& record )
00132 {
00133 if(not recreateGeometry_) return;
00134
00135
00136
00137 cscGeometry = boost::shared_ptr<CSCGeometry>( new CSCGeometry );
00138
00139 cscGeometry->setUseRealWireGeometry( useRealWireGeometry );
00140 cscGeometry->setOnlyWiresInME1a( useOnlyWiresInME1a );
00141 cscGeometry->setGangedStripsInME1a( useGangedStripsInME1a );
00142 cscGeometry->setUseCentreTIOffsets( useCentreTIOffsets );
00143 cscGeometry->setDebugV( debugV );
00144 if ( debugV ) cscGeometry->queryModelling();
00145
00146
00147
00148 if ( useDDD_ ) {
00149 edm::ESTransientHandle<DDCompactView> cpv;
00150 edm::ESHandle<MuonDDDConstants> mdc;
00151 record.getRecord<IdealGeometryRecord>().get(cpv);
00152 record.getRecord<MuonNumberingRecord>().get( mdc );
00153 CSCGeometryBuilderFromDDD builder;
00154
00155 builder.build(cscGeometry, &(*cpv), *mdc);
00156 } else {
00157 edm::ESHandle<RecoIdealGeometry> rig;
00158 edm::ESHandle<CSCRecoDigiParameters> rdp;
00159 record.getRecord<CSCRecoGeometryRcd>().get(rig);
00160 record.getRecord<CSCRecoDigiParametersRcd>().get(rdp);
00161 CSCGeometryBuilder cscgb;
00162
00163 cscgb.build(cscGeometry, *rig, *rdp);
00164 }
00165 recreateGeometry_=false;
00166 }
00167
00168 void CSCGeometryESModule::muonNumberingChanged_( const MuonNumberingRecord& ) {
00169 recreateGeometry_=true;
00170 }
00171 void CSCGeometryESModule::cscRecoGeometryChanged_( const CSCRecoGeometryRcd& ) {
00172 recreateGeometry_=true;
00173 }
00174 void CSCGeometryESModule::cscRecoDigiParametersChanged_( const CSCRecoDigiParametersRcd& ) {
00175 recreateGeometry_=true;
00176 }
00177
00178
00179 DEFINE_FWK_EVENTSETUP_MODULE(CSCGeometryESModule);