File indexing completed on 2024-04-06 11:59:29
0001 #include "Calibration/Tools/interface/calibXMLwriter.h"
0002 #include <string>
0003 #include <cstdio>
0004
0005 calibXMLwriter::calibXMLwriter(EcalSubdetector subdet) : subdet_(subdet) {
0006 char filename[128];
0007 if (subdet_ == EcalEndcap) {
0008 sprintf(filename, "endcap_iniCalib.xml");
0009 } else {
0010 sprintf(filename, "barrel_iniCalib.xml");
0011 }
0012 FILENAME = fopen(filename, "w");
0013 fprintf(FILENAME, "<?xml version=\"1.0\" ?>\n");
0014 fprintf(FILENAME, "<CalibrationConstants>\n");
0015 if (subdet == EcalEndcap) {
0016 fprintf(FILENAME, "<EcalEndcap>\n");
0017 } else {
0018 fprintf(FILENAME, "<EcalBarrel>\n");
0019 }
0020 }
0021
0022 calibXMLwriter::~calibXMLwriter() {
0023 if (subdet_ == EcalEndcap) {
0024 fprintf(FILENAME, "<EcalEndcap>\n");
0025 } else {
0026 fprintf(FILENAME, "<EcalBarrel>\n");
0027 }
0028 fprintf(FILENAME, "</CalibrationConstants>\n");
0029 fclose(FILENAME);
0030 }
0031
0032 void calibXMLwriter::writeLine(EBDetId const& det, float calib) {
0033 int eta = det.ieta();
0034 int phi = det.iphi();
0035 fprintf(FILENAME, "<Cell eta_index=\"%d\" phi_index=\"%d\" scale_factor=\"%f\"/>\n", eta, phi, calib);
0036 }
0037
0038 void calibXMLwriter::writeLine(EEDetId const& det, float calib) {
0039 int x = det.ix();
0040 int y = det.iy();
0041 int z = det.zside();
0042 fprintf(FILENAME, "<Cell x_index=\"%d\" y_index=\"%d\" z_index=\"%d\" scale_factor=\"%f\"/>\n", x, y, z, calib);
0043 }