13 void dumpProlog(std::ostream& fOutput) {
14 fOutput <<
"<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
15 fOutput <<
"<!DOCTYPE root []>" << std::endl;
16 fOutput <<
"<ROOT>" << std::endl;
19 void dumpRun(std::ostream& fOutput,
unsigned fRun) {
20 fOutput <<
"<RUN>" << std::endl;
21 fOutput <<
" <RUN_TYPE>"
23 <<
"</RUN_TYPE>" << std::endl;
24 fOutput <<
" <RUN_NUMBER>" << fRun <<
"</RUN_NUMBER>" << std::endl;
25 fOutput <<
"</RUN>" << std::endl;
28 void dumpHeader(std::ostream& fOutput,
unsigned fRun,
const std::string& fTableName,
const std::string& fTypeName) {
29 fOutput <<
" <HEADER>" << std::endl;
30 fOutput <<
" <TYPE>" << std::endl;
31 fOutput <<
" <EXTENSION_TABLE_NAME>" << fTableName <<
"</EXTENSION_TABLE_NAME>" << std::endl;
32 fOutput <<
" <NAME>" << fTypeName <<
"</NAME>" << std::endl;
33 fOutput <<
" </TYPE>" << std::endl;
34 dumpRun(fOutput, fRun);
35 fOutput <<
" </HEADER>" << std::endl;
38 void dumpFooter(std::ostream& fOutput) { fOutput <<
"</ROOT>" << std::endl; }
40 void dumpChannelId(std::ostream& fOutput,
DetId fChannel) {
42 fOutput <<
"<CHANNEL> " << std::endl;
43 fOutput <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME> " << std::endl;
44 fOutput <<
" <ETA>" <<
abs(
converter.getField(1)) <<
"</ETA>" << std::endl;
45 fOutput <<
" <PHI>" <<
converter.getField(2) <<
"</PHI> " << std::endl;
46 fOutput <<
" <DEPTH>" <<
converter.getField(3) <<
"</DEPTH> " << std::endl;
47 fOutput <<
" <Z>" << (
converter.getField(1) > 0 ?
"1" :
"-1") <<
"</Z> " << std::endl;
48 fOutput <<
" <DETECTOR_NAME>" <<
converter.getFlavor() <<
"</DETECTOR_NAME> " << std::endl;
49 fOutput <<
" <HCAL_CHANNEL_ID>" <<
converter.getId().rawId() <<
"</HCAL_CHANNEL_ID> " << std::endl;
50 fOutput <<
"</CHANNEL>" << std::endl;
54 void dumpData(std::ostream& fOutput,
const float* fValues,
const CastorPedestalWidth& fErrors) {
55 fOutput <<
"<DATA> " << std::endl;
56 fOutput <<
" <CAPACITOR_0_VALUE>" << fValues[0] <<
"</CAPACITOR_0_VALUE> " << std::endl;
57 fOutput <<
" <CAPACITOR_1_VALUE>" << fValues[1] <<
"</CAPACITOR_1_VALUE> " << std::endl;
58 fOutput <<
" <CAPACITOR_2_VALUE>" << fValues[2] <<
"</CAPACITOR_2_VALUE> " << std::endl;
59 fOutput <<
" <CAPACITOR_3_VALUE>" << fValues[3] <<
"</CAPACITOR_3_VALUE> " << std::endl;
60 fOutput <<
" <SIGMA_0_0>" << fErrors.
getSigma(0, 0) <<
"</SIGMA_0_0> " << std::endl;
61 fOutput <<
" <SIGMA_1_1>" << fErrors.
getSigma(1, 1) <<
"</SIGMA_1_1> " << std::endl;
62 fOutput <<
" <SIGMA_2_2>" << fErrors.
getSigma(2, 2) <<
"</SIGMA_2_2> " << std::endl;
63 fOutput <<
" <SIGMA_3_3>" << fErrors.
getSigma(3, 3) <<
"</SIGMA_3_3> " << std::endl;
64 fOutput <<
" <SIGMA_0_1>" << fErrors.
getSigma(1, 0) <<
"</SIGMA_0_1> " << std::endl;
65 fOutput <<
" <SIGMA_0_2>" << fErrors.
getSigma(2, 0) <<
"</SIGMA_0_2> " << std::endl;
66 fOutput <<
" <SIGMA_0_3>" << fErrors.
getSigma(3, 0) <<
"</SIGMA_0_3> " << std::endl;
67 fOutput <<
" <SIGMA_1_2>" << fErrors.
getSigma(2, 1) <<
"</SIGMA_1_2> " << std::endl;
68 fOutput <<
" <SIGMA_1_3>" << fErrors.
getSigma(3, 1) <<
"</SIGMA_1_3> " << std::endl;
69 fOutput <<
" <SIGMA_2_3>" << fErrors.
getSigma(3, 2) <<
"</SIGMA_2_3> " << std::endl;
70 fOutput <<
"</DATA> " << std::endl;
73 void dumpData(std::ostream& fOutput,
const float* fValues,
const float* fErrors) {
74 fOutput <<
"<DATA> " << std::endl;
75 fOutput <<
" <CAPACITOR_0_VALUE>" << fValues[0] <<
"</CAPACITOR_0_VALUE> " << std::endl;
76 fOutput <<
" <CAPACITOR_1_VALUE>" << fValues[1] <<
"</CAPACITOR_1_VALUE> " << std::endl;
77 fOutput <<
" <CAPACITOR_2_VALUE>" << fValues[2] <<
"</CAPACITOR_2_VALUE> " << std::endl;
78 fOutput <<
" <CAPACITOR_3_VALUE>" << fValues[3] <<
"</CAPACITOR_3_VALUE> " << std::endl;
79 fOutput <<
" <CAPACITOR_0_ERROR>" << fErrors[0] <<
"</CAPACITOR_0_ERROR> " << std::endl;
80 fOutput <<
" <CAPACITOR_1_ERROR>" << fErrors[1] <<
"</CAPACITOR_1_ERROR> " << std::endl;
81 fOutput <<
" <CAPACITOR_2_ERROR>" << fErrors[2] <<
"</CAPACITOR_2_ERROR> " << std::endl;
82 fOutput <<
" <CAPACITOR_3_ERROR>" << fErrors[3] <<
"</CAPACITOR_3_ERROR> " << std::endl;
83 fOutput <<
"</DATA> " << std::endl;
86 void dumpDataset(std::ostream& fOutput,
87 unsigned fVersion = 0,
90 fOutput <<
"<DATA_SET>" << std::endl;
91 fOutput <<
" <VERSION>" << fVersion <<
"</VERSION>" << std::endl;
92 if (!fFileName.empty())
93 fOutput <<
" <DATA_FILE_NAME>" << fFileName <<
"</DATA_FILE_NAME>" << std::endl;
94 if (!fDescription.empty())
95 fOutput <<
" <COMMENT_DESCRIPTION>" << fDescription <<
"</COMMENT_DESCRIPTION>" << std::endl;
98 void endDataset(std::ostream& fOutput) { fOutput <<
"</DATA_SET>" << std::endl; }
100 void dumpMapping(std::ostream& fOutput,
103 unsigned long fGMTIOVBegin,
104 unsigned long fGMTIOVEnd,
107 const std::vector<DetId>& fChannels) {
110 fOutput <<
"<ELEMENTS>" << std::endl;
112 int i = fChannels.size();
114 fOutput <<
"<DATA_SET id=\"" <<
i <<
"\">" << std::endl;
115 dumpRun(fOutput, fRun);
116 fOutput <<
"<KIND_OF_CONDITION><NAME>" << fKind <<
"</NAME></KIND_OF_CONDITION>" << std::endl;
117 dumpChannelId(fOutput, fChannels[
i]);
118 fOutput <<
"<VERSION>" << fVersion <<
"</VERSION>" << std::endl;
119 fOutput <<
"</DATA_SET>" << std::endl;
122 fOutput <<
"<IOV id=\"" << IOV_ID <<
"\">";
123 fOutput <<
" <INTERVAL_OF_VALIDITY_BEGIN>" << fGMTIOVBegin <<
"</INTERVAL_OF_VALIDITY_BEGIN>" << std::endl;
124 fOutput <<
" <INTERVAL_OF_VALIDITY_END>" << fGMTIOVEnd <<
"</INTERVAL_OF_VALIDITY_END>" << std::endl;
125 fOutput <<
"</IOV>" << std::endl;
127 fOutput <<
"<TAG id=\"" << TAG_ID <<
"\" mode=\"create\">" << std::endl;
128 fOutput <<
" <TAG_NAME>" << fTag <<
"</TAG_NAME>" << std::endl;
129 fOutput <<
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << std::endl;
130 fOutput <<
" <COMMENT_DESCRIPTION>Automatically created by CastorDbXml</COMMENT_DESCRIPTION>" << std::endl;
131 fOutput <<
"</TAG>" << std::endl;
133 fOutput <<
"</ELEMENTS>" << std::endl;
136 fOutput <<
"<MAPS>" << std::endl;
137 fOutput <<
"<TAG idref=\"" << TAG_ID <<
"\">" << std::endl;
138 fOutput <<
"<IOV idref=\"" << IOV_ID <<
"\">" << std::endl;
139 i = fChannels.size();
141 fOutput <<
"<DATA_SET idref=\"" <<
i <<
"\"/>" << std::endl;
143 fOutput <<
"</IOV>" << std::endl;
144 fOutput <<
"</TAG>" << std::endl;
145 fOutput <<
"</MAPS>" << std::endl;
151 unsigned long fGMTIOVBegin,
152 unsigned long fGMTIOVEnd,
156 float dummyError = 0.0001;
157 std::cout <<
"CastorDbXml::dumpObject-> set default errors: 0.0001, 0.0001, 0.0001, 0.0001" << std::endl;
160 for (std::vector<DetId>::iterator channel =
channels.begin(); channel !=
channels.end(); ++channel) {
162 for (
int iCapId = 1; iCapId <= 4; iCapId++) {
163 item.setSigma(iCapId, iCapId, dummyError * dummyError);
165 widths.addValues(
item);
167 return dumpObject(fOutput, fRun, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, fObject, widths);
172 unsigned long fGMTIOVBegin,
173 unsigned long fGMTIOVEnd,
181 dumpHeader(fOutput, fRun, KIND, KIND);
184 for (std::vector<DetId>::iterator channel =
channels.begin(); channel !=
channels.end(); ++channel) {
185 DetId chId = *channel;
189 std::cerr <<
"CastorDbXml::dumpObject-> Can not get data for channel "
194 std::cerr <<
"CastorDbXml::dumpObject-> Can not get errors for channel "
198 dumpDataset(fOutput, fVersion,
"",
"");
199 dumpChannelId(fOutput, chId);
203 dumpMapping(fOutput, fRun, KIND, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion,
channels);
211 unsigned long fGMTIOVBegin,
212 unsigned long fGMTIOVEnd,
216 float dummyErrors[4] = {0., 0., 0., 0.};
217 std::cout <<
"CastorDbXml::dumpObject-> set default errors: 4 x 0.0" << std::endl;
221 for (std::vector<DetId>::iterator channel =
channels.begin(); channel !=
channels.end(); ++channel) {
222 CastorGainWidth item(*channel, dummyErrors[0], dummyErrors[1], dummyErrors[2], dummyErrors[3]);
226 return dumpObject(fOutput, fRun, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, fObject, widths);
231 unsigned long fGMTIOVBegin,
232 unsigned long fGMTIOVEnd,
238 const std::string TABLE =
"HCAL_GAIN_PEDSTL_CALIBRATIONS";
241 dumpHeader(fOutput, fRun, TABLE, KIND);
244 for (std::vector<DetId>::iterator channel =
channels.begin(); channel !=
channels.end(); ++channel) {
245 DetId chId = *channel;
249 std::cerr <<
"CastorDbXml::dumpObject-> Can not get data for channel "
254 std::cerr <<
"CastorDbXml::dumpObject-> Can not get errors for channel "
258 dumpDataset(fOutput, fVersion,
"",
"");
259 dumpChannelId(fOutput, chId);
263 dumpMapping(fOutput, fRun, KIND, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion,
channels);