CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CondTools/Ecal/bin/array2xmlEB.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
00003 #include "CondTools/Ecal/interface/EcalIntercalibConstantsXMLTranslator.h"
00004 #include "CondTools/Ecal/interface/EcalCondHeader.h"
00005 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00006 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00007 
00008 #include <string>
00009 #include <sstream>
00010 #include <fstream>
00011 
00012 using namespace std;
00013 
00014 void usage(){
00015   cout << endl;
00016   cout << "array2xml [arrayfile] [xmlfile]" <<  endl;
00017   cout << "Read coefficients from straight array [denseindex]"<<endl;
00018   cout << "and write in xml format" << endl;
00019 
00020 }
00021 
00022 
00023 int main(int argc, char* argv[]){
00024 
00025  if (argc!=3) {
00026     usage();
00027     exit(0);
00028   }
00029 
00030 
00031  string arrayfilename(argv[1]);
00032  string xmlfilename(argv[2]);
00033  fstream arrayfile(arrayfilename.c_str(),ios::in);
00034  
00035 
00036  EcalIntercalibConstants rcd ;
00037 
00038  float c=0;
00039  int   idx=0;
00040 
00041  while (arrayfile>>c){
00042    uint32_t id=EBDetId::unhashIndex(idx);
00043    rcd[id]=c;
00044    ++idx;
00045  }
00046  cout << idx << endl;
00047  
00048  for (int cellid = 0; 
00049        cellid < EEDetId::kSizeForDenseIndexing; 
00050        ++cellid){// loop on EB cells
00051     
00052     
00053 
00054     if (EEDetId::validHashIndex(cellid)){  
00055       uint32_t rawid = EEDetId::unhashIndex(cellid);
00056      
00057       rcd[rawid]=0.0;
00058      
00059     } // if
00060   } 
00061 
00062 
00063 
00064  
00065    
00066  // write new format
00067  EcalCondHeader h; 
00068  EcalIntercalibConstantsXMLTranslator::writeXML(xmlfilename,h,rcd); 
00069    
00070 
00071 }