15 void dumpProlog (std::ostream& fOutput) {
16 fOutput <<
"<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
17 fOutput <<
"<!DOCTYPE root []>" << std::endl;
18 fOutput <<
"<ROOT>" << std::endl;
21 void dumpRun (std::ostream& fOutput,
unsigned fRun) {
22 fOutput <<
"<RUN>"<< std::endl;
23 fOutput <<
" <RUN_TYPE>" <<
"CastorDbXml" <<
"</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) {
39 fOutput <<
"</ROOT>" << std::endl;
42 void dumpChannelId (std::ostream& fOutput,
DetId fChannel) {
44 fOutput <<
"<CHANNEL> "<< std::endl;
45 fOutput <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME> "<< std::endl;
46 fOutput <<
" <ETA>" <<
abs (converter.getField (1)) <<
"</ETA>"<< std::endl;
47 fOutput <<
" <PHI>" << converter.getField (2) <<
"</PHI> "<< std::endl;
48 fOutput <<
" <DEPTH>" << converter.getField (3) <<
"</DEPTH> "<< std::endl;
49 fOutput <<
" <Z>" << (converter.getField (1) > 0 ?
"1" :
"-1") <<
"</Z> "<< std::endl;
50 fOutput <<
" <DETECTOR_NAME>" << converter.getFlavor () <<
"</DETECTOR_NAME> "<< std::endl;
51 fOutput <<
" <HCAL_CHANNEL_ID>" << converter.getId().rawId () <<
"</HCAL_CHANNEL_ID> "<< std::endl;
52 fOutput <<
"</CHANNEL>"<< std::endl;
57 fOutput <<
"<DATA> "<< std::endl;
58 fOutput <<
" <CAPACITOR_0_VALUE>" << fValues [0] <<
"</CAPACITOR_0_VALUE> "<< std::endl;
59 fOutput <<
" <CAPACITOR_1_VALUE>" << fValues [1] <<
"</CAPACITOR_1_VALUE> "<< std::endl;
60 fOutput <<
" <CAPACITOR_2_VALUE>" << fValues [2] <<
"</CAPACITOR_2_VALUE> "<< std::endl;
61 fOutput <<
" <CAPACITOR_3_VALUE>" << fValues [3] <<
"</CAPACITOR_3_VALUE> "<< std::endl;
62 fOutput <<
" <SIGMA_0_0>" << fErrors.
getSigma (0,0) <<
"</SIGMA_0_0> "<< std::endl;
63 fOutput <<
" <SIGMA_1_1>" << fErrors.
getSigma (1,1) <<
"</SIGMA_1_1> "<< std::endl;
64 fOutput <<
" <SIGMA_2_2>" << fErrors.
getSigma (2,2) <<
"</SIGMA_2_2> "<< std::endl;
65 fOutput <<
" <SIGMA_3_3>" << fErrors.
getSigma (3,3) <<
"</SIGMA_3_3> "<< std::endl;
66 fOutput <<
" <SIGMA_0_1>" << fErrors.
getSigma (1,0) <<
"</SIGMA_0_1> "<< std::endl;
67 fOutput <<
" <SIGMA_0_2>" << fErrors.
getSigma (2,0) <<
"</SIGMA_0_2> "<< std::endl;
68 fOutput <<
" <SIGMA_0_3>" << fErrors.
getSigma (3,0) <<
"</SIGMA_0_3> "<< std::endl;
69 fOutput <<
" <SIGMA_1_2>" << fErrors.
getSigma (2,1) <<
"</SIGMA_1_2> "<< std::endl;
70 fOutput <<
" <SIGMA_1_3>" << fErrors.
getSigma (3,1) <<
"</SIGMA_1_3> "<< std::endl;
71 fOutput <<
" <SIGMA_2_3>" << fErrors.
getSigma (3,2) <<
"</SIGMA_2_3> "<< std::endl;
72 fOutput <<
"</DATA> " << std::endl;
75 void dumpData (std::ostream& fOutput,
const float* fValues,
const float* fErrors) {
76 fOutput <<
"<DATA> "<< std::endl;
77 fOutput <<
" <CAPACITOR_0_VALUE>" << fValues [0] <<
"</CAPACITOR_0_VALUE> "<< std::endl;
78 fOutput <<
" <CAPACITOR_1_VALUE>" << fValues [1] <<
"</CAPACITOR_1_VALUE> "<< std::endl;
79 fOutput <<
" <CAPACITOR_2_VALUE>" << fValues [2] <<
"</CAPACITOR_2_VALUE> "<< std::endl;
80 fOutput <<
" <CAPACITOR_3_VALUE>" << fValues [3] <<
"</CAPACITOR_3_VALUE> "<< std::endl;
81 fOutput <<
" <CAPACITOR_0_ERROR>" << fErrors [0] <<
"</CAPACITOR_0_ERROR> "<< std::endl;
82 fOutput <<
" <CAPACITOR_1_ERROR>" << fErrors [1] <<
"</CAPACITOR_1_ERROR> "<< std::endl;
83 fOutput <<
" <CAPACITOR_2_ERROR>" << fErrors [2] <<
"</CAPACITOR_2_ERROR> "<< std::endl;
84 fOutput <<
" <CAPACITOR_3_ERROR>" << fErrors [3] <<
"</CAPACITOR_3_ERROR> "<< std::endl;
85 fOutput <<
"</DATA> " << std::endl;
88 void dumpDataset (std::ostream& fOutput,
unsigned fVersion = 0,
const std::string& fFileName =
"",
const std::string& fDescription =
"") {
89 fOutput <<
"<DATA_SET>" << std::endl;
90 fOutput <<
" <VERSION>" << fVersion <<
"</VERSION>" << std::endl;
91 if (!fFileName.empty ())
92 fOutput <<
" <DATA_FILE_NAME>" << fFileName <<
"</DATA_FILE_NAME>" << std::endl;
93 if (!fDescription.empty ())
94 fOutput <<
" <COMMENT_DESCRIPTION>" << fDescription <<
"</COMMENT_DESCRIPTION>" << std::endl;
97 void endDataset (std::ostream& fOutput) {
98 fOutput <<
"</DATA_SET>" << std::endl;
101 void dumpMapping (std::ostream& fOutput,
unsigned fRun,
const std::string& fKind,
102 unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
103 const std::string& fTag,
unsigned fVersion,
const std::vector<DetId>& fChannels) {
106 fOutput <<
"<ELEMENTS>" << std::endl;
108 int i = fChannels.size ();
110 fOutput <<
"<DATA_SET id=\"" << i <<
"\">" << std::endl;
111 dumpRun (fOutput, fRun);
112 fOutput <<
"<KIND_OF_CONDITION><NAME>" << fKind <<
"</NAME></KIND_OF_CONDITION>" << std::endl;
113 dumpChannelId (fOutput, fChannels[i]);
114 fOutput <<
"<VERSION>" << fVersion <<
"</VERSION>" << std::endl;
115 fOutput <<
"</DATA_SET>" << std::endl;
118 fOutput <<
"<IOV id=\"" << IOV_ID <<
"\">";
119 fOutput <<
" <INTERVAL_OF_VALIDITY_BEGIN>" << fGMTIOVBegin <<
"</INTERVAL_OF_VALIDITY_BEGIN>"<< std::endl;
120 fOutput <<
" <INTERVAL_OF_VALIDITY_END>" << fGMTIOVEnd <<
"</INTERVAL_OF_VALIDITY_END>"<< std::endl;
121 fOutput <<
"</IOV>" << std::endl;
123 fOutput <<
"<TAG id=\"" << TAG_ID <<
"\" mode=\"create\">"<< std::endl;
124 fOutput <<
" <TAG_NAME>" << fTag <<
"</TAG_NAME>"<< std::endl;
125 fOutput <<
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>"<< std::endl;
126 fOutput <<
" <COMMENT_DESCRIPTION>Automatically created by CastorDbXml</COMMENT_DESCRIPTION>" << std::endl;
127 fOutput <<
"</TAG>" << std::endl;
129 fOutput <<
"</ELEMENTS>" << std::endl;
132 fOutput <<
"<MAPS>" << std::endl;
133 fOutput <<
"<TAG idref=\"" << TAG_ID <<
"\">" << std::endl;
134 fOutput <<
"<IOV idref=\"" << IOV_ID <<
"\">" << std::endl;
135 i = fChannels.size ();
137 fOutput <<
"<DATA_SET idref=\"" << i <<
"\"/>" << std::endl;
139 fOutput <<
"</IOV>" << std::endl;
140 fOutput <<
"</TAG>" << std::endl;
141 fOutput <<
"</MAPS>" << std::endl;
148 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
150 float dummyError = 0.0001;
151 std::cout <<
"CastorDbXml::dumpObject-> set default errors: 0.0001, 0.0001, 0.0001, 0.0001" << std::endl;
154 for (std::vector<DetId>::iterator channel = channels.begin ();
155 channel != channels.end ();
159 for (
int iCapId = 1; iCapId <= 4; iCapId++) {
160 item.
setSigma (iCapId, iCapId, dummyError*dummyError);
162 widths.addValues(item);
165 return dumpObject (fOutput, fRun, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, fObject, widths);
169 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
173 dumpProlog (fOutput);
174 dumpHeader (fOutput, fRun, KIND, KIND);
177 for (std::vector<DetId>::iterator channel = channels.begin ();
178 channel != channels.end ();
180 DetId chId = *channel;
191 dumpDataset (fOutput, fVersion,
"",
"");
192 dumpChannelId (fOutput,chId);
193 dumpData (fOutput, values, *errors);
194 endDataset (fOutput);
196 dumpMapping (fOutput, fRun, KIND, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, channels);
198 dumpFooter (fOutput);
203 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
205 float dummyErrors [4] = {0., 0., 0., 0.};
206 std::cout <<
"CastorDbXml::dumpObject-> set default errors: 4 x 0.0" << std::endl;
210 for (std::vector<DetId>::iterator channel = channels.begin (); channel != channels.end (); channel++)
212 CastorGainWidth item(*channel,dummyErrors[0],dummyErrors[1],dummyErrors[2],dummyErrors[3]);
216 return dumpObject (fOutput, fRun, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, fObject, widths);
220 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
223 const std::string TABLE =
"HCAL_GAIN_PEDSTL_CALIBRATIONS";
225 dumpProlog (fOutput);
226 dumpHeader (fOutput, fRun, TABLE, KIND);
229 for (std::vector<DetId>::iterator channel = channels.begin ();
230 channel != channels.end ();
232 DetId chId = *channel;
243 dumpDataset (fOutput, fVersion,
"",
"");
244 dumpChannelId (fOutput,chId);
246 endDataset (fOutput);
248 dumpMapping (fOutput, fRun, KIND, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, channels);
250 dumpFooter (fOutput);
void setSigma(int fCapId1, int fCapId2, float fSigma)
std::vector< DetId > getAllChannels() const
bool dumpObject(std::ostream &fOutput, unsigned fRun, unsigned long fGMTIOVBegin, unsigned long fGMTIOVEnd, const std::string &fTag, unsigned fVersion, const CastorPedestals &fObject, const CastorPedestalWidths &fError)
const Item * getValues(DetId fId, bool throwOnFail=true) const
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
const float * getValues() const
get value for all capId = 0..3
std::string toString() const
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
bool addValues(const Item &myItem)
const float * getValues() const
get value for all capId = 0..3
const float * getValues() const
get value for all capId = 0..3