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 }
DDAxes::y
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
EBDetId
Definition: EBDetId.h:17
Pi0CalibXMLwriter::subdet_
EcalSubdetector subdet_
Definition: Pi0CalibXMLwriter.h:20
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
DDAxes::x
Pi0CalibXMLwriter::writeLine
void writeLine(EBDetId const &, float)
Definition: Pi0CalibXMLwriter.cc:49
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
PVValHelper::eta
Definition: PVValidationHelpers.h:69
DDAxes::z
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
EEDetId::zside
int zside() const
Definition: EEDetId.h:71
EEDetId
Definition: EEDetId.h:14
calib
Definition: CalibElectron.h:12
EcalEndcap
Definition: EcalSubdetector.h:10
heppy_loop.loop
loop
Definition: heppy_loop.py:28
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
Pi0CalibXMLwriter::~Pi0CalibXMLwriter
~Pi0CalibXMLwriter()
Definition: Pi0CalibXMLwriter.cc:39
DDAxes::phi
Pi0CalibXMLwriter::Pi0CalibXMLwriter
Pi0CalibXMLwriter(EcalSubdetector=EcalBarrel)
Definition: Pi0CalibXMLwriter.cc:5
Pi0CalibXMLwriter.h
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
Pi0CalibXMLwriter::FILENAME
FILE * FILENAME
Definition: Pi0CalibXMLwriter.h:22