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 : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
00037 myLabel_(p.getParameter<std::string>("appendToDataLabel"))
00038 {
00039
00040 setWhatProduced(this, dependsOn(&CSCGeometryESModule::geometryCallback_) );
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 useRealWireGeometry = p.getParameter<bool>("useRealWireGeometry");
00051
00052
00053
00054 useOnlyWiresInME1a = p.getParameter<bool>("useOnlyWiresInME1a");
00055
00056
00057
00058
00059 useGangedStripsInME1a = p.getParameter<bool>("useGangedStripsInME1a");
00060
00061 if ( useGangedStripsInME1a ) useOnlyWiresInME1a = false;
00062
00063
00064 useCentreTIOffsets = p.getParameter<bool>("useCentreTIOffsets");
00065
00066
00067
00068 debugV = p.getUntrackedParameter<bool>("debugV", false);
00069
00070
00071 useDDD_ = p.getParameter<bool>("useDDD");
00072
00073
00074 applyAlignment_ = p.getParameter<bool>("applyAlignment");
00075
00076
00077 edm::LogInfo("Geometry") << "@SUB=CSCGeometryESModule"
00078 << "Label '" << myLabel_ << "' "
00079 << (applyAlignment_ ? "looking for" : "IGNORING")
00080 << " alignment labels '" << alignmentsLabel_ << "'.";
00081 }
00082
00083
00084 CSCGeometryESModule::~CSCGeometryESModule(){}
00085
00086
00087 boost::shared_ptr<CSCGeometry> CSCGeometryESModule::produce(const MuonGeometryRecord& record) {
00088
00089
00090
00091 if ( applyAlignment_ ) {
00092
00093
00094 edm::ESHandle<Alignments> globalPosition;
00095 record.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
00096 edm::ESHandle<Alignments> alignments;
00097 record.getRecord<CSCAlignmentRcd>().get(alignmentsLabel_, alignments);
00098 edm::ESHandle<AlignmentErrors> alignmentErrors;
00099
00100
00101
00102
00103
00104
00105
00106 record.getRecord<CSCAlignmentErrorRcd>().get(alignmentsLabel_, alignmentErrors);
00107
00108 if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
00109 edm::LogInfo("Config") << "@SUB=CSCGeometryRecord::produce"
00110 << "Alignment(Error)s and global position (label '"
00111 << alignmentsLabel_ << "') empty: Geometry producer (label "
00112 << "'" << myLabel_ << "') assumes fake and does not apply.";
00113 } else {
00114 GeometryAligner aligner;
00115 aligner.applyAlignments<CSCGeometry>( &(*cscGeometry), &(*alignments), &(*alignmentErrors),
00116 align::DetectorGlobalPosition(*globalPosition, DetId(DetId::Muon)) );
00117 }
00118
00119 }
00120
00121 return cscGeometry;
00122 }
00123
00124
00125 void CSCGeometryESModule::geometryCallback_( const MuonNumberingRecord& record )
00126 {
00127
00128
00129 cscGeometry = boost::shared_ptr<CSCGeometry>( new CSCGeometry );
00130
00131 cscGeometry->setUseRealWireGeometry( useRealWireGeometry );
00132 cscGeometry->setOnlyWiresInME1a( useOnlyWiresInME1a );
00133 cscGeometry->setGangedStripsInME1a( useGangedStripsInME1a );
00134 cscGeometry->setUseCentreTIOffsets( useCentreTIOffsets );
00135 cscGeometry->setDebugV( debugV );
00136 if ( debugV ) cscGeometry->queryModelling();
00137
00138
00139
00140 if ( useDDD_ ) {
00141 edm::ESTransientHandle<DDCompactView> cpv;
00142 edm::ESHandle<MuonDDDConstants> mdc;
00143 record.getRecord<IdealGeometryRecord>().get(cpv);
00144 record.get( mdc );
00145 CSCGeometryBuilderFromDDD builder;
00146
00147 builder.build(cscGeometry, &(*cpv), *mdc);
00148 } else {
00149 edm::ESHandle<RecoIdealGeometry> rig;
00150 edm::ESHandle<CSCRecoDigiParameters> rdp;
00151 record.getRecord<CSCRecoGeometryRcd>().get(rig);
00152 record.getRecord<CSCRecoDigiParametersRcd>().get(rdp);
00153 CSCGeometryBuilder cscgb;
00154
00155 cscgb.build(cscGeometry, *rig, *rdp);
00156 }
00157
00158 }
00159
00160 DEFINE_FWK_EVENTSETUP_MODULE(CSCGeometryESModule);