CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CalibTracker/SiStripESProducers/plugins/fake/SiStripHashedDetIdFakeESSource.cc

Go to the documentation of this file.
00001 #include "CalibTracker/SiStripESProducers/plugins/fake/SiStripHashedDetIdFakeESSource.h"
00002 #include "CalibFormats/SiStripObjects/interface/SiStripHashedDetId.h"
00003 #include "CalibTracker/Records/interface/SiStripHashedDetIdRcd.h"
00004 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include <sstream>
00007 #include <vector>
00008 #include <map>
00009 
00010 using namespace sistrip;
00011 
00012 // -----------------------------------------------------------------------------
00013 //
00014 SiStripHashedDetIdFakeESSource::SiStripHashedDetIdFakeESSource( const edm::ParameterSet& pset )
00015   : SiStripHashedDetIdESProducer( pset ),
00016     detIds_( pset.getParameter<edm::FileInPath>("DetIdsFile") )
00017 {
00018   findingRecord<SiStripHashedDetIdRcd>();
00019   edm::LogVerbatim("HashedDetId") 
00020     << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
00021     << " Constructing object...";
00022 }
00023 
00024 // -----------------------------------------------------------------------------
00025 //
00026 SiStripHashedDetIdFakeESSource::~SiStripHashedDetIdFakeESSource() {
00027   edm::LogVerbatim("HashedDetId")
00028     << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
00029     << " Destructing object...";
00030 }
00031 
00032 // -----------------------------------------------------------------------------
00033 // 
00034 SiStripHashedDetId* SiStripHashedDetIdFakeESSource::make( const SiStripHashedDetIdRcd& ) {
00035   edm::LogVerbatim("HashedDetId")
00036     << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
00037     << " Building \"fake\" hashed DetId map from ascii file";
00038   
00039   typedef std::map<uint32_t,SiStripDetInfoFileReader::DetInfo>  Dets;
00040   Dets det_info = SiStripDetInfoFileReader( detIds_.fullPath() ).getAllData();
00041   
00042   std::vector<uint32_t> dets;
00043   dets.reserve(16000);
00044 
00045   Dets::const_iterator idet = det_info.begin();
00046   Dets::const_iterator jdet = det_info.end();
00047   for ( ; idet != jdet; ++idet ) { dets.push_back( idet->first ); }
00048   edm::LogVerbatim("HashedDetId")
00049     << "[SiStripHashedDetIdESProducer::" << __func__ << "]"
00050     << " Retrieved " << dets.size()
00051     << " DetIds from ascii file!";
00052   
00053   SiStripHashedDetId* hash = new SiStripHashedDetId( dets );
00054   LogTrace("HashedDetId")
00055     << "[SiStripHashedDetIdESProducer::" << __func__ << "]"
00056     << " DetId hash map: " << std::endl
00057     << *hash;
00058   
00059   return hash;
00060   
00061 }
00062 
00063 // -----------------------------------------------------------------------------
00064 // 
00065 void SiStripHashedDetIdFakeESSource::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& key, 
00066                                                      const edm::IOVSyncValue& iov_sync, 
00067                                                      edm::ValidityInterval& iov_validity ) {
00068   edm::ValidityInterval infinity( iov_sync.beginOfTime(), iov_sync.endOfTime() );
00069   iov_validity = infinity;
00070 }