14 void dumpProlog (std::ostream& fOutput) {
15 fOutput <<
"<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
16 fOutput <<
"<!DOCTYPE root []>" << std::endl;
17 fOutput <<
"<ROOT>" << std::endl;
20 void dumpRun (std::ostream& fOutput,
unsigned fRun) {
21 fOutput <<
"<RUN>"<< std::endl;
22 fOutput <<
" <RUN_TYPE>" <<
"CastorDbXml" <<
"</RUN_TYPE>"<< std::endl;
23 fOutput <<
" <RUN_NUMBER>" << fRun <<
"</RUN_NUMBER>"<< std::endl;
24 fOutput <<
"</RUN>" << std::endl;
27 void dumpHeader (std::ostream& fOutput,
unsigned fRun,
const std::string& fTableName,
const std::string& fTypeName) {
28 fOutput <<
" <HEADER>" << std::endl;
29 fOutput <<
" <TYPE>" << std::endl;
30 fOutput <<
" <EXTENSION_TABLE_NAME>" << fTableName <<
"</EXTENSION_TABLE_NAME>" << std::endl;
31 fOutput <<
" <NAME>" << fTypeName <<
"</NAME>" << std::endl;
32 fOutput <<
" </TYPE>" << std::endl;
33 dumpRun (fOutput, fRun);
34 fOutput <<
" </HEADER>" << std::endl;
37 void dumpFooter (std::ostream& fOutput) {
38 fOutput <<
"</ROOT>" << std::endl;
41 void dumpChannelId (std::ostream& fOutput,
DetId fChannel) {
43 fOutput <<
"<CHANNEL> "<< std::endl;
44 fOutput <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME> "<< std::endl;
45 fOutput <<
" <ETA>" <<
abs (converter.getField (1)) <<
"</ETA>"<< std::endl;
46 fOutput <<
" <PHI>" << converter.getField (2) <<
"</PHI> "<< std::endl;
47 fOutput <<
" <DEPTH>" << converter.getField (3) <<
"</DEPTH> "<< std::endl;
48 fOutput <<
" <Z>" << (converter.getField (1) > 0 ?
"1" :
"-1") <<
"</Z> "<< std::endl;
49 fOutput <<
" <DETECTOR_NAME>" << converter.getFlavor () <<
"</DETECTOR_NAME> "<< std::endl;
50 fOutput <<
" <HCAL_CHANNEL_ID>" << converter.getId().rawId () <<
"</HCAL_CHANNEL_ID> "<< std::endl;
51 fOutput <<
"</CHANNEL>"<< std::endl;
56 fOutput <<
"<DATA> "<< std::endl;
57 fOutput <<
" <CAPACITOR_0_VALUE>" << fValues [0] <<
"</CAPACITOR_0_VALUE> "<< std::endl;
58 fOutput <<
" <CAPACITOR_1_VALUE>" << fValues [1] <<
"</CAPACITOR_1_VALUE> "<< std::endl;
59 fOutput <<
" <CAPACITOR_2_VALUE>" << fValues [2] <<
"</CAPACITOR_2_VALUE> "<< std::endl;
60 fOutput <<
" <CAPACITOR_3_VALUE>" << fValues [3] <<
"</CAPACITOR_3_VALUE> "<< std::endl;
61 fOutput <<
" <SIGMA_0_0>" << fErrors.
getSigma (0,0) <<
"</SIGMA_0_0> "<< std::endl;
62 fOutput <<
" <SIGMA_1_1>" << fErrors.
getSigma (1,1) <<
"</SIGMA_1_1> "<< std::endl;
63 fOutput <<
" <SIGMA_2_2>" << fErrors.
getSigma (2,2) <<
"</SIGMA_2_2> "<< std::endl;
64 fOutput <<
" <SIGMA_3_3>" << fErrors.
getSigma (3,3) <<
"</SIGMA_3_3> "<< std::endl;
65 fOutput <<
" <SIGMA_0_1>" << fErrors.
getSigma (1,0) <<
"</SIGMA_0_1> "<< std::endl;
66 fOutput <<
" <SIGMA_0_2>" << fErrors.
getSigma (2,0) <<
"</SIGMA_0_2> "<< std::endl;
67 fOutput <<
" <SIGMA_0_3>" << fErrors.
getSigma (3,0) <<
"</SIGMA_0_3> "<< std::endl;
68 fOutput <<
" <SIGMA_1_2>" << fErrors.
getSigma (2,1) <<
"</SIGMA_1_2> "<< std::endl;
69 fOutput <<
" <SIGMA_1_3>" << fErrors.
getSigma (3,1) <<
"</SIGMA_1_3> "<< std::endl;
70 fOutput <<
" <SIGMA_2_3>" << fErrors.
getSigma (3,2) <<
"</SIGMA_2_3> "<< std::endl;
71 fOutput <<
"</DATA> " << std::endl;
74 void dumpData (std::ostream& fOutput,
const float* fValues,
const float* fErrors) {
75 fOutput <<
"<DATA> "<< std::endl;
76 fOutput <<
" <CAPACITOR_0_VALUE>" << fValues [0] <<
"</CAPACITOR_0_VALUE> "<< std::endl;
77 fOutput <<
" <CAPACITOR_1_VALUE>" << fValues [1] <<
"</CAPACITOR_1_VALUE> "<< std::endl;
78 fOutput <<
" <CAPACITOR_2_VALUE>" << fValues [2] <<
"</CAPACITOR_2_VALUE> "<< std::endl;
79 fOutput <<
" <CAPACITOR_3_VALUE>" << fValues [3] <<
"</CAPACITOR_3_VALUE> "<< std::endl;
80 fOutput <<
" <CAPACITOR_0_ERROR>" << fErrors [0] <<
"</CAPACITOR_0_ERROR> "<< std::endl;
81 fOutput <<
" <CAPACITOR_1_ERROR>" << fErrors [1] <<
"</CAPACITOR_1_ERROR> "<< std::endl;
82 fOutput <<
" <CAPACITOR_2_ERROR>" << fErrors [2] <<
"</CAPACITOR_2_ERROR> "<< std::endl;
83 fOutput <<
" <CAPACITOR_3_ERROR>" << fErrors [3] <<
"</CAPACITOR_3_ERROR> "<< std::endl;
84 fOutput <<
"</DATA> " << std::endl;
87 void dumpDataset (std::ostream& fOutput,
unsigned fVersion = 0,
const std::string& fFileName =
"",
const std::string& fDescription =
"") {
88 fOutput <<
"<DATA_SET>" << std::endl;
89 fOutput <<
" <VERSION>" << fVersion <<
"</VERSION>" << std::endl;
90 if (!fFileName.empty ())
91 fOutput <<
" <DATA_FILE_NAME>" << fFileName <<
"</DATA_FILE_NAME>" << std::endl;
92 if (!fDescription.empty ())
93 fOutput <<
" <COMMENT_DESCRIPTION>" << fDescription <<
"</COMMENT_DESCRIPTION>" << std::endl;
96 void endDataset (std::ostream& fOutput) {
97 fOutput <<
"</DATA_SET>" << std::endl;
100 void dumpMapping (std::ostream& fOutput,
unsigned fRun,
const std::string& fKind,
101 unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
102 const std::string& fTag,
unsigned fVersion,
const std::vector<DetId>& fChannels) {
105 fOutput <<
"<ELEMENTS>" << std::endl;
107 int i = fChannels.size ();
109 fOutput <<
"<DATA_SET id=\"" << i <<
"\">" << std::endl;
110 dumpRun (fOutput, fRun);
111 fOutput <<
"<KIND_OF_CONDITION><NAME>" << fKind <<
"</NAME></KIND_OF_CONDITION>" << std::endl;
112 dumpChannelId (fOutput, fChannels[i]);
113 fOutput <<
"<VERSION>" << fVersion <<
"</VERSION>" << std::endl;
114 fOutput <<
"</DATA_SET>" << std::endl;
117 fOutput <<
"<IOV id=\"" << IOV_ID <<
"\">";
118 fOutput <<
" <INTERVAL_OF_VALIDITY_BEGIN>" << fGMTIOVBegin <<
"</INTERVAL_OF_VALIDITY_BEGIN>"<< std::endl;
119 fOutput <<
" <INTERVAL_OF_VALIDITY_END>" << fGMTIOVEnd <<
"</INTERVAL_OF_VALIDITY_END>"<< std::endl;
120 fOutput <<
"</IOV>" << std::endl;
122 fOutput <<
"<TAG id=\"" << TAG_ID <<
"\" mode=\"create\">"<< std::endl;
123 fOutput <<
" <TAG_NAME>" << fTag <<
"</TAG_NAME>"<< std::endl;
124 fOutput <<
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>"<< std::endl;
125 fOutput <<
" <COMMENT_DESCRIPTION>Automatically created by CastorDbXml</COMMENT_DESCRIPTION>" << std::endl;
126 fOutput <<
"</TAG>" << std::endl;
128 fOutput <<
"</ELEMENTS>" << std::endl;
131 fOutput <<
"<MAPS>" << std::endl;
132 fOutput <<
"<TAG idref=\"" << TAG_ID <<
"\">" << std::endl;
133 fOutput <<
"<IOV idref=\"" << IOV_ID <<
"\">" << std::endl;
134 i = fChannels.size ();
136 fOutput <<
"<DATA_SET idref=\"" << i <<
"\"/>" << std::endl;
138 fOutput <<
"</IOV>" << std::endl;
139 fOutput <<
"</TAG>" << std::endl;
140 fOutput <<
"</MAPS>" << std::endl;
147 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
149 float dummyError = 0.0001;
150 std::cout <<
"CastorDbXml::dumpObject-> set default errors: 0.0001, 0.0001, 0.0001, 0.0001" << std::endl;
153 for (std::vector<DetId>::iterator channel = channels.begin ();
154 channel != channels.end ();
158 for (
int iCapId = 1; iCapId <= 4; iCapId++) {
159 item.
setSigma (iCapId, iCapId, dummyError*dummyError);
161 widths.addValues(item);
164 return dumpObject (fOutput, fRun, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, fObject, widths);
168 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
172 dumpProlog (fOutput);
173 dumpHeader (fOutput, fRun, KIND, KIND);
176 for (std::vector<DetId>::iterator channel = channels.begin ();
177 channel != channels.end ();
179 DetId chId = *channel;
190 dumpDataset (fOutput, fVersion,
"",
"");
191 dumpChannelId (fOutput,chId);
192 dumpData (fOutput, values, *errors);
193 endDataset (fOutput);
195 dumpMapping (fOutput, fRun, KIND, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, channels);
197 dumpFooter (fOutput);
202 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
204 float dummyErrors [4] = {0., 0., 0., 0.};
205 std::cout <<
"CastorDbXml::dumpObject-> set default errors: 4 x 0.0" << std::endl;
209 for (std::vector<DetId>::iterator channel = channels.begin (); channel != channels.end (); ++channel)
211 CastorGainWidth item(*channel,dummyErrors[0],dummyErrors[1],dummyErrors[2],dummyErrors[3]);
215 return dumpObject (fOutput, fRun, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, fObject, widths);
219 unsigned fRun,
unsigned long fGMTIOVBegin,
unsigned long fGMTIOVEnd,
const std::string& fTag,
unsigned fVersion,
222 const std::string TABLE =
"HCAL_GAIN_PEDSTL_CALIBRATIONS";
224 dumpProlog (fOutput);
225 dumpHeader (fOutput, fRun, TABLE, KIND);
228 for (std::vector<DetId>::iterator channel = channels.begin ();
229 channel != channels.end ();
231 DetId chId = *channel;
242 dumpDataset (fOutput, fVersion,
"",
"");
243 dumpChannelId (fOutput,chId);
245 endDataset (fOutput);
247 dumpMapping (fOutput, fRun, KIND, fGMTIOVBegin, fGMTIOVEnd, fTag, fVersion, channels);
249 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
Abs< T >::type abs(const T &t)
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