CMS 3D CMS Logo

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.2 2007/05/29 17:44:01 meridian 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    using namespace edm::es;
00058    std::auto_ptr<EcalTrigTowerConstituentsMap> prod(new EcalTrigTowerConstituentsMap());
00059 
00060    if (!mapFile_.empty()) {
00061      parseTextMap(mapFile_,*prod);
00062    }
00063    return prod;
00064 }
00065 
00066 void EcalTrigTowerConstituentsMapBuilder::parseTextMap(const std::string& filename, EcalTrigTowerConstituentsMap& theMap) {
00067   edm::FileInPath eff(filename);
00068   
00069   std::ifstream f(eff.fullPath().c_str());
00070   if (!f.good())
00071     return; 
00072   
00073   int mod,cry,ietaTower,iphiTower;
00074   int ix,iy,iz;
00075   char line[80];  // a buffer for the line to read
00076   char ch;        // a temporary for holding the end of line
00077   while ((ch = f.peek()) != '-') {
00078     f.get(line,80,'\n');            // read 80 characters to end of line
00079     f.get(ch);                      // eat out the '\n'
00080     // extract the numbers
00081 /*
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 }

Generated on Tue Jun 9 17:37:10 2009 for CMSSW by  doxygen 1.5.4