Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:50

0001 #include <iostream>
0002 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0003 #include "CondTools/Ecal/interface/EcalIntercalibConstantsXMLTranslator.h"
0004 #include "CondTools/Ecal/interface/EcalCondHeader.h"
0005 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0006 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0007 
0008 #include <string>
0009 #include <sstream>
0010 #include <fstream>
0011 
0012 using namespace std;
0013 
0014 void usage() {
0015   cout << endl;
0016   cout << "array2xml [arrayfile] [xmlfile]" << endl;
0017   cout << "Read coefficients from straight array [denseindex]" << endl;
0018   cout << "and write in xml format" << endl;
0019 }
0020 
0021 int main(int argc, char* argv[]) {
0022   if (argc != 3) {
0023     usage();
0024     exit(0);
0025   }
0026 
0027   string arrayfilename(argv[1]);
0028   string xmlfilename(argv[2]);
0029   fstream arrayfile(arrayfilename.c_str(), ios::in);
0030 
0031   EcalIntercalibConstants rcd;
0032 
0033   float c = 0;
0034   int idx = 0;
0035 
0036   while (arrayfile >> c) {
0037     uint32_t id = EBDetId::unhashIndex(idx);
0038     rcd[id] = c;
0039     ++idx;
0040   }
0041   cout << idx << endl;
0042 
0043   for (int cellid = 0; cellid < EEDetId::kSizeForDenseIndexing; ++cellid) {  // loop on EB cells
0044 
0045     if (EEDetId::validHashIndex(cellid)) {
0046       uint32_t rawid = EEDetId::unhashIndex(cellid);
0047 
0048       rcd[rawid] = 0.0;
0049 
0050     }  // if
0051   }
0052 
0053   // write new format
0054   EcalCondHeader h;
0055   EcalIntercalibConstantsXMLTranslator::writeXML(xmlfilename, h, rcd);
0056 }