CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Geometry/CaloEventSetup/plugins/EcalTrigTowerConstituentsMapBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EcalTrigTowerConstituentsMapBuilder
00004 // Class:      EcalTrigTowerConstituentsMapBuilder
00005 // 
00013 //
00014 // Original Author:  Paolo Meridiani
00015 // $Id: EcalTrigTowerConstituentsMapBuilder.cc,v 1.4 2010/03/26 19:35:00 sunanda Exp $
00016 //
00017 //
00018 
00019 
00020 // user include files
00021 #include "Geometry/CaloEventSetup/plugins/EcalTrigTowerConstituentsMapBuilder.h"
00022 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00023 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00024 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00025 
00026 #include <iostream>
00027 #include <fstream>
00028 
00029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00030 
00031 //
00032 // constructors and destructor
00033 //
00034 EcalTrigTowerConstituentsMapBuilder::EcalTrigTowerConstituentsMapBuilder(const edm::ParameterSet& iConfig) :
00035   mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile",""))
00036 {
00037   //the following line is needed to tell the framework what
00038   // data is being produced
00039   setWhatProduced(this);
00040   
00041   //now do what ever other initialization is needed
00042 }
00043 
00044 
00045 EcalTrigTowerConstituentsMapBuilder::~EcalTrigTowerConstituentsMapBuilder()
00046 { 
00047 }
00048 
00049 //
00050 // member functions
00051 //
00052 
00053 // ------------ method called to produce the data  ------------
00054 EcalTrigTowerConstituentsMapBuilder::ReturnType
00055 EcalTrigTowerConstituentsMapBuilder::produce(const IdealGeometryRecord& iRecord)
00056 {
00057    std::auto_ptr<EcalTrigTowerConstituentsMap> prod(new EcalTrigTowerConstituentsMap());
00058 
00059    if (!mapFile_.empty()) {
00060      parseTextMap(mapFile_,*prod);
00061    }
00062    return prod;
00063 }
00064 
00065 void EcalTrigTowerConstituentsMapBuilder::parseTextMap(const std::string& filename, EcalTrigTowerConstituentsMap& theMap) {
00066   edm::FileInPath eff(filename);
00067   
00068   std::ifstream f(eff.fullPath().c_str());
00069   if (!f.good())
00070     return; 
00071   
00072   int ietaTower,iphiTower;
00073   int ix,iy,iz;
00074   char line[80];  // a buffer for the line to read
00075   char ch;        // a temporary for holding the end of line
00076   while ((ch = f.peek()) != '-') {
00077     f.get(line,80,'\n');            // read 80 characters to end of line
00078     f.get(ch);                      // eat out the '\n'
00079     // extract the numbers
00080 /*
00081   int mod,cry;
00082     int nread = sscanf (line, " %d %d %d %d",&mod,&cry,&ietaTower,&iphiTower);
00083     if (nread == 4 )
00084       {
00085         EEDetId eeid(mod,cry,1,EEDetId::SCCRYSTALMODE);
00086         EcalTrigTowerDetId etid(1,EcalEndcap,ietaTower-45+17,iphiTower);
00087         //      std::cout << eeid << "\n->" << etid << std::endl;
00088         theMap.assign(DetId(eeid),etid);
00089       }
00090 */
00091     int nread = sscanf (line, " %d %d %d %d %d",&ix,&iy,&iz,&ietaTower, &iphiTower);
00092     if (nread == 5) {
00093       EEDetId eeid(ix,iy,iz,0);
00094       // std::cout << "-- manu ix eta phi " << DetId(eeid).rawId() << " " << iz << " " << ietaTower << " " << iphiTower << std::endl;
00095       EcalTrigTowerDetId etid(iz,EcalEndcap,ietaTower,iphiTower);
00096       theMap.assign(DetId(eeid),etid);
00097     }
00098     
00099   }
00100   // Pass comment line
00101   f.get(line,80,'\n');            // read 80 characters to end of line
00102   f.get(ch);                      // eat out the '\n'
00103   // Next info line
00104   f.get(line,80,'\n');            // read 80 characters to end of line
00105   f.get(ch);                      // eat out the '\n'
00106   // extract the numbers
00107   //   int nTE;
00108   //   sscanf (line, " %d",&nTE);
00109   //   nTowEta_e=nTE;
00110   //   while ((ch = f.peek()) != EOF) {
00111   //     f.get(line,80,'\n');            // read 80 characters to end of line
00112   //     f.get(ch);                      // eat out the '\n'
00113   //     // extract the numbers
00114   //     float bound;
00115   //     sscanf (line, " %f", &bound);
00116   //     eta_boundaries.push_back(bound);
00117   //   }
00118   
00119   f.close();
00120   return;
00121 }