File indexing completed on 2024-04-06 11:59:30
0001 #include "Calibration/Tools/interface/Pi0CalibXMLwriter.h"
0002 #include <string>
0003 #include <cstdio>
0004
0005 Pi0CalibXMLwriter::Pi0CalibXMLwriter(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 Pi0CalibXMLwriter::Pi0CalibXMLwriter(EcalSubdetector subdet, int loop) : subdet_(subdet), loop_(loop) {
0023 char filename[128];
0024 if (subdet_ == EcalEndcap) {
0025 sprintf(filename, "endcap_calib_loop_%d.xml", loop);
0026 } else {
0027 sprintf(filename, "barrel_calib_loop_%d.xml", loop);
0028 }
0029 FILENAME = fopen(filename, "w");
0030 fprintf(FILENAME, "<?xml version=\"1.0\" ?>\n");
0031 fprintf(FILENAME, "<CalibrationConstants>\n");
0032 if (subdet == EcalEndcap) {
0033 fprintf(FILENAME, "<EcalEndcap>\n");
0034 } else {
0035 fprintf(FILENAME, "<EcalBarrel>\n");
0036 }
0037 }
0038
0039 Pi0CalibXMLwriter::~Pi0CalibXMLwriter() {
0040 if (subdet_ == EcalEndcap) {
0041 fprintf(FILENAME, "<EcalEndcap>\n");
0042 } else {
0043 fprintf(FILENAME, "<EcalBarrel>\n");
0044 }
0045 fprintf(FILENAME, "</CalibrationConstants>\n");
0046 fclose(FILENAME);
0047 }
0048
0049 void Pi0CalibXMLwriter::writeLine(EBDetId const& det, float calib) {
0050 int eta = det.ieta();
0051 int phi = det.iphi();
0052 fprintf(FILENAME, "<Cell eta_index=\"%d\" phi_index=\"%d\" scale_factor=\"%f\"/>\n", eta, phi, calib);
0053 }
0054
0055 void Pi0CalibXMLwriter::writeLine(EEDetId const& det, float calib) {
0056 int x = det.ix();
0057 int y = det.iy();
0058 int z = det.zside() > 0 ? 1 : 0;
0059 fprintf(FILENAME, "<Cell x_index=\"%d\" y_index=\"%d\" z_index=\"%d\" scale_factor=\"%f\"/>\n", x, y, z, calib);
0060 }