CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Geometry/CaloEventSetup/plugins/CaloTowerConstituentsMapBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    CaloTowerConstituentsMapBuilder
00004 // Class:      CaloTowerConstituentsMapBuilder
00005 // 
00013 //
00014 // Original Author:  Jeremiah Mans
00015 //         Created:  Mon Oct  3 11:35:27 CDT 2005
00016 // $Id: CaloTowerConstituentsMapBuilder.cc,v 1.4 2010/03/26 19:35:00 sunanda Exp $
00017 //
00018 //
00019 
00020 
00021 // user include files
00022 #include "Geometry/CaloEventSetup/plugins/CaloTowerConstituentsMapBuilder.h"
00023 #include <zlib.h>
00024 #include <cstdio>
00025 #include <strings.h>
00026 
00027 //
00028 // constructors and destructor
00029 //
00030 CaloTowerConstituentsMapBuilder::CaloTowerConstituentsMapBuilder(const edm::ParameterSet& iConfig) :
00031   mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile",""))
00032   /*
00033   doStandardHBHE_(iConfig.getParameter<bool>("standardHBHE","true")),
00034   doStandardHF_(iConfig.getParameter<bool>("standardHF","true")),
00035   doStandardEB_(iConfig.getParameter<bool>("standardEB","true"))  
00036   */
00037 {
00038    //the following line is needed to tell the framework what
00039    // data is being produced
00040    setWhatProduced(this);
00041 
00042    //now do what ever other initialization is needed
00043 }
00044 
00045 
00046 CaloTowerConstituentsMapBuilder::~CaloTowerConstituentsMapBuilder()
00047 { 
00048 }
00049 
00050 
00051 //
00052 // member functions
00053 //
00054 
00055 // ------------ method called to produce the data  ------------
00056 CaloTowerConstituentsMapBuilder::ReturnType
00057 CaloTowerConstituentsMapBuilder::produce(const IdealGeometryRecord& iRecord)
00058 {
00059    std::auto_ptr<CaloTowerConstituentsMap> prod(new CaloTowerConstituentsMap());
00060    prod->useStandardHB(true);
00061    prod->useStandardHE(true);
00062    prod->useStandardHF(true);
00063    prod->useStandardHO(true);
00064    prod->useStandardEB(true);
00065 
00066    if (!mapFile_.empty()) {
00067      parseTextMap(mapFile_,*prod);
00068    }
00069    prod->sort();
00070    
00071    return prod;
00072 }
00073 
00074 void CaloTowerConstituentsMapBuilder::parseTextMap(const std::string& filename, CaloTowerConstituentsMap& theMap) {
00075   edm::FileInPath eff(filename);
00076 
00077   gzFile gzed=gzopen(eff.fullPath().c_str(),"rb");
00078   
00079   while (!gzeof(gzed)) {
00080     char line[1024];
00081     int ieta, iphi, rawid;
00082     gzgets(gzed,line,1023);
00083     if (index(line,'#')!=0)  *(index(line,'#'))=0;
00084     int ct=sscanf(line,"%i %d %d",&rawid,&ieta,&iphi);
00085     if (ct==3) {
00086       DetId detid(rawid);
00087       CaloTowerDetId tid(ieta,iphi);
00088       theMap.assign(detid,tid);
00089     }    
00090   }
00091   gzclose(gzed);
00092 
00093 }