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