CMS 3D CMS Logo

Pi0CalibXMLwriter.cc
Go to the documentation of this file.
2 #include <string>
3 #include <cstdio>
4 
6  char filename[128];
7  if (subdet_ == EcalEndcap) {
8  sprintf(filename, "endcap_iniCalib.xml");
9  } else {
10  sprintf(filename, "barrel_iniCalib.xml");
11  }
12  FILENAME = fopen(filename, "w");
13  fprintf(FILENAME, "<?xml version=\"1.0\" ?>\n");
14  fprintf(FILENAME, "<CalibrationConstants>\n");
15  if (subdet == EcalEndcap) {
16  fprintf(FILENAME, "<EcalEndcap>\n");
17  } else {
18  fprintf(FILENAME, "<EcalBarrel>\n");
19  }
20 }
21 
22 Pi0CalibXMLwriter::Pi0CalibXMLwriter(EcalSubdetector subdet, int loop) : subdet_(subdet), loop_(loop) {
23  char filename[128];
24  if (subdet_ == EcalEndcap) {
25  sprintf(filename, "endcap_calib_loop_%d.xml", loop);
26  } else {
27  sprintf(filename, "barrel_calib_loop_%d.xml", loop);
28  }
29  FILENAME = fopen(filename, "w");
30  fprintf(FILENAME, "<?xml version=\"1.0\" ?>\n");
31  fprintf(FILENAME, "<CalibrationConstants>\n");
32  if (subdet == EcalEndcap) {
33  fprintf(FILENAME, "<EcalEndcap>\n");
34  } else {
35  fprintf(FILENAME, "<EcalBarrel>\n");
36  }
37 }
38 
40  if (subdet_ == EcalEndcap) {
41  fprintf(FILENAME, "<EcalEndcap>\n");
42  } else {
43  fprintf(FILENAME, "<EcalBarrel>\n");
44  }
45  fprintf(FILENAME, "</CalibrationConstants>\n");
46  fclose(FILENAME);
47 }
48 
49 void Pi0CalibXMLwriter::writeLine(EBDetId const& det, float calib) {
50  int eta = det.ieta();
51  int phi = det.iphi();
52  fprintf(FILENAME, "<Cell eta_index=\"%d\" phi_index=\"%d\" scale_factor=\"%f\"/>\n", eta, phi, calib);
53 }
54 
55 void Pi0CalibXMLwriter::writeLine(EEDetId const& det, float calib) {
56  int x = det.ix();
57  int y = det.iy();
58  int z = det.zside() > 0 ? 1 : 0;
59  fprintf(FILENAME, "<Cell x_index=\"%d\" y_index=\"%d\" z_index=\"%d\" scale_factor=\"%f\"/>\n", x, y, z, calib);
60 }
EcalSubdetector subdet_
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
void writeLine(EBDetId const &, float)
int ix() const
Definition: EEDetId.h:77
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
int zside() const
Definition: EEDetId.h:71
Pi0CalibXMLwriter(EcalSubdetector=EcalBarrel)
EcalSubdetector
int iy() const
Definition: EEDetId.h:83