00001 #include "Geometry/TrackerNumberingBuilder/plugins/TrackerGeometricDetESModule.h" 00002 #include "Geometry/TrackerNumberingBuilder/plugins/DDDCmsTrackerContruction.h" 00003 #include "Geometry/Records/interface/IdealGeometryRecord.h" 00004 #include "DetectorDescription/Core/interface/DDCompactView.h" 00005 00006 #include "CondDBCmsTrackerConstruction.h" 00007 00008 #include "FWCore/Framework/interface/EventSetup.h" 00009 #include "FWCore/Framework/interface/ESHandle.h" 00010 #include "FWCore/Framework/interface/ModuleFactory.h" 00011 #include "FWCore/Framework/interface/ESProducer.h" 00012 00013 00014 #include <memory> 00015 00016 using namespace edm; 00017 00018 TrackerGeometricDetESModule::TrackerGeometricDetESModule(const edm::ParameterSet & p) 00019 : fromDDD_(p.getParameter<bool>("fromDDD")) 00020 { 00021 if ( fromDDD_ ) { 00022 setWhatProduced(this, &TrackerGeometricDetESModule::produceFromDDDXML); 00023 findingRecord<IdealGeometryRecord>(); 00024 } else { 00025 setWhatProduced(this, &TrackerGeometricDetESModule::produceFromPGeometricDet); 00026 findingRecord<PGeometricDetRcd>(); 00027 } 00028 } 00029 00030 TrackerGeometricDetESModule::~TrackerGeometricDetESModule() {} 00031 00032 std::auto_ptr<GeometricDet> 00033 TrackerGeometricDetESModule::produceFromDDDXML(const IdealGeometryRecord & iRecord){ 00034 // 00035 // get the DDCompactView first 00036 // 00037 edm::ESHandle<DDCompactView> cpv; 00038 iRecord.get( cpv ); 00039 00040 DDDCmsTrackerContruction theDDDCmsTrackerContruction; 00041 return std::auto_ptr<GeometricDet> (const_cast<GeometricDet*>(theDDDCmsTrackerContruction.construct(&(*cpv)))); 00042 } 00043 00044 std::auto_ptr<GeometricDet> 00045 TrackerGeometricDetESModule::produceFromPGeometricDet(const PGeometricDetRcd & iRecord){ 00046 edm::ESHandle<PGeometricDet> pgd; 00047 iRecord.get( pgd ); 00048 00049 CondDBCmsTrackerConstruction cdbtc; 00050 // std::auto_ptr<GeometricDet> tt ( 00051 return std::auto_ptr<GeometricDet> ( const_cast<GeometricDet*>(cdbtc.construct( *pgd ))); 00052 00053 // DDDCmsTrackerConstruction theDDDCmsTrackerContruction; 00054 // return std::auto_ptr<GeometricDet> (const_cast<GeometricDet*>(theDDDCmsTrackerContruction.construct(&(*cpv)))); 00055 } 00056 00057 00058 void TrackerGeometricDetESModule::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, 00059 const edm::IOVSyncValue & iosv, 00060 edm::ValidityInterval & oValidity) 00061 { 00062 // TO CHECK: can we get the iov from the PoolDBESSource? if not, why not? 00063 edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime()); 00064 oValidity = infinity; 00065 } 00066 00067 DEFINE_FWK_EVENTSETUP_MODULE(TrackerGeometricDetESModule);