Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020 #include "Geometry/CaloEventSetup/plugins/CaloTowerConstituentsMapBuilder.h"
00021 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00022 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00023 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00024 #include <zlib.h>
00025 #include <strings.h>
00026
00027
00028
00029
00030 CaloTowerConstituentsMapBuilder::CaloTowerConstituentsMapBuilder(const edm::ParameterSet& iConfig) :
00031 mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile",""))
00032 {
00033
00034
00035 setWhatProduced(this);
00036
00037
00038 }
00039
00040
00041 CaloTowerConstituentsMapBuilder::~CaloTowerConstituentsMapBuilder()
00042 {
00043 }
00044
00045
00046
00047
00048
00049
00050 void
00051 CaloTowerConstituentsMapBuilder::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
00052 {
00053 edm::ParameterSetDescription desc;
00054 desc.addUntracked<std::string>( "MapFile", "" );
00055 descriptions.add( "caloTowerConstituents", desc );
00056 }
00057
00058
00059 CaloTowerConstituentsMapBuilder::ReturnType
00060 CaloTowerConstituentsMapBuilder::produce(const IdealGeometryRecord& iRecord)
00061 {
00062 edm::ESHandle<HcalTopology> topology ;
00063 iRecord.get( topology ) ;
00064
00065 std::auto_ptr<CaloTowerConstituentsMap> prod( new CaloTowerConstituentsMap( &*topology ));
00066
00067 prod->useStandardHB(true);
00068 prod->useStandardHE(true);
00069 prod->useStandardHF(true);
00070 prod->useStandardHO(true);
00071 prod->useStandardEB(true);
00072
00073 if (!mapFile_.empty()) {
00074 parseTextMap(mapFile_,*prod);
00075 }
00076 prod->sort();
00077
00078 return prod;
00079 }
00080
00081 void
00082 CaloTowerConstituentsMapBuilder::parseTextMap( const std::string& filename, CaloTowerConstituentsMap& theMap )
00083 {
00084 edm::FileInPath eff( filename );
00085
00086 gzFile gzed = gzopen( eff.fullPath().c_str(), "rb" );
00087
00088 while( !gzeof( gzed ))
00089 {
00090 char line[1024];
00091 int ieta, iphi, rawid;
00092 if( 0 != gzgets( gzed, line, 1023 ))
00093 {
00094 if( index( line, '#' ) != 0 )*( index( line, '#' )) = 0;
00095 int ct = sscanf( line, "%i %d %d", &rawid, &ieta, &iphi );
00096 if( ct == 3 )
00097 {
00098 DetId detid( rawid );
00099 CaloTowerDetId tid( ieta, iphi );
00100 theMap.assign( detid, tid );
00101 }
00102 }
00103 }
00104 gzclose( gzed );
00105 }