CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc

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 // #include "CondFormats/DataRecord/interface/RecoIdealGeometryRcd.h"
00011 // #include "CondFormats/DataRecord/interface/CSCRecoDigiParametersRcd.h"
00012 //#include "Geometry/Records/interface/RecoIdealGeometryRcd.h"
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 // Alignments
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   // Choose wire geometry modelling
00042   // We now _require_ some wire geometry specification in the CSCOrcaSpec.xml file
00043   // in the DDD Geometry.
00044   // Default as of transition to CMSSW is to use real values.
00045   // Alternative is to use pseudo-values which match reasonably closely
00046   // the calculated geometry values used up to and including ORCA_8_8_1.
00047   // (This was the default in ORCA.)
00048 
00049   useRealWireGeometry =   p.getParameter<bool>("useRealWireGeometry");
00050 
00051   // Suppress strips altogether in ME1a region of ME11?
00052 
00053   useOnlyWiresInME1a =    p.getParameter<bool>("useOnlyWiresInME1a");
00054 
00055   // Allow strips in ME1a region of ME11 but gang them?
00056   // Default is now to treat ME1a with ganged strips (e.g. in clusterizer)
00057 
00058   useGangedStripsInME1a = p.getParameter<bool>("useGangedStripsInME1a");
00059 
00060   if ( useGangedStripsInME1a ) useOnlyWiresInME1a = false; // override possible inconsistentcy
00061 
00062   // Use the backed-out offsets that correct the CTI
00063   useCentreTIOffsets = p.getParameter<bool>("useCentreTIOffsets"); 
00064 
00065   // Debug printout etc. in CSCGeometry etc.
00066 
00067   debugV = p.getUntrackedParameter<bool>("debugV", false);
00068 
00069   // Find out if using the DDD or CondDB Geometry source.
00070   useDDD_ = p.getParameter<bool>("useDDD");
00071 
00072   // Feed these value to where I need them
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   // Called whenever the alignments or alignment errors change
00096 
00097   if ( applyAlignment_ ) {
00098     // applyAlignment_ is scheduled for removal. 
00099     // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
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 // <<<<<<< CSCGeometryESModule.cc
00106 //     record.getRecord<CSCAlignmentErrorRcd>().get( alignmentErrors );
00107 //     GeometryAligner aligner;
00108 //     aligner.applyAlignments<CSCGeometry>( &(*_cscGeometry),
00109 //                                        &(*alignments), &(*alignmentErrors),
00110 //       align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
00111 // =======
00112     record.getRecord<CSCAlignmentErrorRcd>().get(alignmentsLabel_,  alignmentErrors);
00113     // Only apply alignment if values exist
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 // >>>>>>> 1.8
00125   }
00126 
00127   return cscGeometry;
00128 }
00129 
00130 
00131 void CSCGeometryESModule::initCSCGeometry_( const MuonGeometryRecord& record )
00132 {
00133   if(not recreateGeometry_) return;
00134 
00135   // Updates whenever a dependent Record was changed
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   // Called whenever the muon numbering (or ideal geometry) changes
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     //    _cscGeometry = boost::shared_ptr<CSCGeometry>(builder.build(_cscGeometry, &(*cpv), *mdc));
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     //    _cscGeometry = boost::shared_ptr<CSCGeometry>(cscgb.build(_cscGeometry, *rig, *rdp));
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);