CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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   : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
00037     myLabel_(p.getParameter<std::string>("appendToDataLabel"))
00038 {
00039 
00040   setWhatProduced(this, dependsOn(&CSCGeometryESModule::geometryCallback_) );
00041 
00042   // Choose wire geometry modelling
00043   // We now _require_ some wire geometry specification in the CSCOrcaSpec.xml file
00044   // in the DDD Geometry.
00045   // Default as of transition to CMSSW is to use real values.
00046   // Alternative is to use pseudo-values which match reasonably closely
00047   // the calculated geometry values used up to and including ORCA_8_8_1.
00048   // (This was the default in ORCA.)
00049 
00050   useRealWireGeometry =   p.getParameter<bool>("useRealWireGeometry");
00051 
00052   // Suppress strips altogether in ME1a region of ME11?
00053 
00054   useOnlyWiresInME1a =    p.getParameter<bool>("useOnlyWiresInME1a");
00055 
00056   // Allow strips in ME1a region of ME11 but gang them?
00057   // Default is now to treat ME1a with ganged strips (e.g. in clusterizer)
00058 
00059   useGangedStripsInME1a = p.getParameter<bool>("useGangedStripsInME1a");
00060 
00061   if ( useGangedStripsInME1a ) useOnlyWiresInME1a = false; // override possible inconsistentcy
00062 
00063   // Use the backed-out offsets that correct the CTI
00064   useCentreTIOffsets = p.getParameter<bool>("useCentreTIOffsets"); 
00065 
00066   // Debug printout etc. in CSCGeometry etc.
00067 
00068   debugV = p.getUntrackedParameter<bool>("debugV", false);
00069 
00070   // Find out if using the DDD or CondDB Geometry source.
00071   useDDD_ = p.getParameter<bool>("useDDD");
00072 
00073   // Feed these value to where I need them
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   // Called whenever the alignments or alignment errors change
00090 
00091   if ( applyAlignment_ ) {
00092     // applyAlignment_ is scheduled for removal. 
00093     // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
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 // <<<<<<< CSCGeometryESModule.cc
00100 //     record.getRecord<CSCAlignmentErrorRcd>().get( alignmentErrors );
00101 //     GeometryAligner aligner;
00102 //     aligner.applyAlignments<CSCGeometry>( &(*_cscGeometry),
00103 //                                        &(*alignments), &(*alignmentErrors),
00104 //       align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon)));
00105 // =======
00106     record.getRecord<CSCAlignmentErrorRcd>().get(alignmentsLabel_,  alignmentErrors);
00107     // Only apply alignment if values exist
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 // >>>>>>> 1.8
00119   }
00120 
00121   return cscGeometry;
00122 }
00123 
00124 
00125 void CSCGeometryESModule::geometryCallback_( const MuonNumberingRecord& record )
00126 {
00127   // Called whenever the muon numbering (or ideal geometry) changes
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   // Called whenever the muon numbering (or ideal geometry) changes
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     //    _cscGeometry = boost::shared_ptr<CSCGeometry>(builder.build(_cscGeometry, &(*cpv), *mdc));
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     //    _cscGeometry = boost::shared_ptr<CSCGeometry>(cscgb.build(_cscGeometry, *rig, *rdp));
00155     cscgb.build(cscGeometry, *rig, *rdp);
00156   }
00157 
00158 }
00159 
00160 DEFINE_FWK_EVENTSETUP_MODULE(CSCGeometryESModule);