CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DBlmapWriter.cc
Go to the documentation of this file.
1 #include <fstream>
2 
6 
7 
9 
10 }
11 
13 
14 }
15 
17 {
18  XMLDOMBlock * result = new XMLDOMBlock( templateFileName );
19  DOMDocument * loader = result -> getDocument();
20  //DOMElement * root = loader -> getDocumentElement();
21 
22  loader -> getElementsByTagName( XMLProcessor::_toXMLCh( "NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( "HCAL LMAP for HB, HE, HF" ) );
23  //DOMElement * _tag = (DOMElement *)(loader -> getElementsByTagName( XMLProcessor::_toXMLCh( "TAG" ) ) -> item(0));
24  //_tag -> setAttribute( XMLProcessor::_toXMLCh("mode"), XMLProcessor::_toXMLCh("test_mode") );
25 
26  return result;
27 }
28 
29 
30 
32 {
33  DOMDocument * loader = doc -> getDocument();
34  DOMElement * root = loader -> getDocumentElement();
35 
36  XMLDOMBlock dataSetDoc( templateFileName );
37  DOMDocument * dataSet = dataSetDoc . getDocument();
38 
39  //Dataset
40  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> side ) );
41  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> eta) );
42  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> phi ) );
43  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dphi ) );
44 
45  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> depth ) );
46  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> det ) );
47  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RBX_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rbx ) );
48  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "WEDGE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> wedge ) );
49 
50  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rm ) );
51  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> pixel ) );
52  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> qie ) );
53  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> adc ) );
54  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rm_fi ) );
55 
56  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fi_ch));
57  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> crate ) );
58  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> htr ) );
59  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fpga ) );
60 
61  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> htr_fi ));
62  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dcc_sl ) );
63  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> spigo ) );
64  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dcc ) );
65  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_SITE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slb ) );
66  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slbin ));
67  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_CHANNEL2" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slbin2));
68 
69  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_CABLE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slnam ) );
70  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rctcra ) );
71  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_CARD" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rctcar ) );
72  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_CONNECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->rctcon));
73  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rctnam ) );
74  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fedid ) );
75 
76 
77  // copy the <data_set> node into the final XML
78  DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(), true );
79  root -> appendChild( cloneDataSet );
80 
81  return 0;
82 }
83 
85 {
86  XMLDOMBlock * result = new XMLDOMBlock( templateFileName );
87  DOMDocument * loader = result -> getDocument();
88  //DOMElement * root = loader -> getDocumentElement();
89 
90  loader -> getElementsByTagName( XMLProcessor::_toXMLCh( "NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( "HCAL LMAP for HO" ) );
91  //DOMElement * _tag = (DOMElement *)(loader -> getElementsByTagName( XMLProcessor::_toXMLCh( "TAG" ) ) -> item(0));
92  //_tag -> setAttribute( XMLProcessor::_toXMLCh("mode"), XMLProcessor::_toXMLCh("test_mode") );
93 
94  return result;
95 }
96 
97 
99 {
100  DOMDocument * loader = doc -> getDocument();
101  DOMElement * root = loader -> getDocumentElement();
102 
103  XMLDOMBlock dataSetDoc( templateFileName );
104  DOMDocument * dataSet = dataSetDoc . getDocument();
105 
106  //Dataset
107  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> sideO ) );
108  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> etaO ) );
109  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> phiO ) );
110  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dphiO ) );
111 
112  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> depthO ) );
113  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> detO ) );
114  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RBX_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rbxO ) );
115  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> sectorO ) );
116 
117  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rmO ) );
118  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> pixelO ) );
119  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> qieO ) );
120  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> adcO ) );
121  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rm_fiO ) );
122  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->fi_chO));
123 
124  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "LETTER_CODE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh(row ->let_codeO));
125  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> crateO ) );
126  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> htrO ) );
127  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fpgaO ) );
128 
129  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> htr_fiO ) );
130  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dcc_slO ) );
131  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> spigoO ) );
132  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dccO ) );
133  dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fedidO ) );
134 
135 
136  // copy the <data_set> node into the final XML
137  DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(), true );
138  root -> appendChild( cloneDataSet );
139 
140  return 0;
141 }
142 
143 
144 
146  std::cout << "XML Test..." << std::endl;
147 
148  //XMLProcessor * theProcessor = XMLProcessor::getInstance();
149 
150  //XMLDOMBlock * doc = theProcessor -> createLMapHBEFXMLBase( "FullLmapBase.xml" );
151  LMapLoader doc;
152 
155 
156 
157  std::ifstream fcha("/afs/fnal.gov/files/home/room3/avetisya/public_html/HCAL/Maps/HCALmapHBEF_Feb.21.2008.txt");
158  std::ifstream fcho("/afs/fnal.gov/files/home/room3/avetisya/public_html/HCAL/Maps/HCALmapHO_Feb.21.2008.txt");
159 
160  //List in order HB HE HF
161  //side eta phi dphi depth det
162  //rbx wedge rm pixel qie
163  //adc rm_fi fi_ch crate htr
164  //fpga htr_fi dcc_sl spigo dcc
165  //slb slbin slbin2 slnam rctcra rctcar
166  //rctcon rctnam fedid
167 
168  const int NCHA = 6912;
169  const int NCHO = 2160;
170  int ncho = 0;
171  int i, j;
172  std::string ndump;
173 
174  int sideC[NCHA], etaC[NCHA], phiC[NCHA], dphiC[NCHA], depthC[NCHA], wedgeC[NCHA], crateC[NCHA], rmC[NCHA], rm_fiC[NCHA], htrC[NCHA];
175  int htr_fiC[NCHA], fi_chC[NCHA], spigoC[NCHA], dccC[NCHA], dcc_slC[NCHA], fedidC[NCHA], pixelC[NCHA], qieC[NCHA], adcC[NCHA];
176  int slbC[NCHA], rctcraC[NCHA], rctcarC[NCHA], rctconC[NCHA];
177  std::string detC[NCHA], rbxC[NCHA], fpgaC[NCHA], slbinC[NCHA], slbin2C[NCHA], slnamC[NCHA], rctnamC[NCHA];
178 
179  int sideO[NCHO], etaO[NCHO], phiO[NCHO], dphiO[NCHO], depthO[NCHO], sectorO[NCHO], crateO[NCHO], rmO[NCHO], rm_fiO[NCHO], htrO[NCHO];
180  int htr_fiO[NCHO], fi_chO[NCHO], spigoO[NCHO], dccO[NCHO], dcc_slO[NCHO], fedidO[NCHO], pixelO[NCHO], qieO[NCHO], adcO[NCHO];
181  int geoO[NCHO], blockO[NCHO], lcO[NCHO];
182  std::string detO[NCHO], rbxO[NCHO], fpgaO[NCHO], let_codeO[NCHO];
183 
184  int counter = 0;
185  for (i = 0; i < NCHA; i++){
186  if(i == counter){
187  for (j = 0; j < 31; j++){
188  fcha>>ndump;
189  ndump = "";
190  }
191  counter += 21;
192  }
193  fcha>>sideC[i];
194  fcha>>etaC[i]>>phiC[i]>>dphiC[i]>>depthC[i]>>detC[i];
195  fcha>>rbxC[i]>>wedgeC[i]>>rmC[i]>>pixelC[i]>>qieC[i];
196  fcha>>adcC[i]>>rm_fiC[i]>>fi_chC[i]>>crateC[i]>>htrC[i];
197  fcha>>fpgaC[i]>>htr_fiC[i]>>dcc_slC[i]>>spigoC[i]>>dccC[i];
198  fcha>>slbC[i]>>slbinC[i]>>slbin2C[i]>>slnamC[i]>>rctcraC[i]>>rctcarC[i];
199  fcha>>rctconC[i]>>rctnamC[i]>>fedidC[i];
200  }
201 
202  for(i = 0; i < NCHA; i++){
203  aRow . side = sideC[i];
204  aRow . eta = etaC[i];
205  aRow . phi = phiC[i];
206  aRow . dphi = dphiC[i];
207  aRow . depth = depthC[i];
208  aRow . det = detC[i];
209  aRow . rbx = rbxC[i];
210  aRow . wedge = wedgeC[i];
211  aRow . rm = rmC[i];
212  aRow . pixel = pixelC[i];
213  aRow . qie = qieC[i];
214  aRow . adc = adcC[i];
215  aRow . rm_fi = rm_fiC[i];
216  aRow . fi_ch = fi_chC[i];
217  aRow . crate = crateC[i];
218  aRow . htr = htrC[i];
219  aRow . fpga = fpgaC[i];
220  aRow . htr_fi = htr_fiC[i];
221  aRow . dcc_sl = dcc_slC[i];
222  aRow . spigo = spigoC[i];
223  aRow . dcc = dccC[i];
224  aRow . slb = slbC[i];
225  aRow . slbin = slbinC[i];
226  aRow . slbin2 = slbin2C[i];
227  aRow . slnam = slnamC[i];
228  aRow . rctcra = rctcraC[i];
229  aRow . rctcar = rctcarC[i];
230  aRow . rctcon = rctconC[i];
231  aRow . rctnam = rctnamC[i];
232  aRow . fedid = fedidC[i];
233 
234  doc . addLMapHBEFDataset( &aRow, "FullHCALDataset.xml" );
235  }
236 
237  counter = 0;
238  for (i = 0; i < NCHO; i++){
239  if(i == counter){
240  for (j = 0; j < 27; j++){
241  fcho>>ndump;
242  ndump = "";
243  }
244  counter += 21;
245  }
246  fcho>>sideO[i];
247  if (sideO[i] != 1 && sideO[i] != -1){
248  std::cerr<<ncho<<'\t'<<sideO[i]<<std::endl;
249  break;
250  }
251  fcho>>etaO[i]>>phiO[i]>>dphiO[i]>>depthO[i]>>detO[i];
252  fcho>>rbxO[i]>>sectorO[i]>>rmO[i]>>pixelO[i]>>qieO[i];
253  fcho>>adcO[i]>>rm_fiO[i]>>fi_chO[i]>>let_codeO[i]>>crateO[i]>>htrO[i];
254  fcho>>fpgaO[i]>>htr_fiO[i]>>dcc_slO[i]>>spigoO[i]>>dccO[i];
255  fcho>>fedidO[i]>>geoO[i]>>blockO[i]>>lcO[i];
256 
257  ncho++;
258  }
259 
260  for(i = 0; i < NCHO; i++){
261  bRow . sideO = sideO[i];
262  bRow . etaO = etaO[i];
263  bRow . phiO = phiO[i];
264  bRow . dphiO = dphiO[i];
265  bRow . depthO = depthO[i];
266 
267  bRow . detO = detO[i];
268  bRow . rbxO = rbxO[i];
269  bRow . sectorO = sectorO[i];
270  bRow . rmO = rmO[i];
271  bRow . pixelO = pixelO[i];
272 
273  bRow . qieO = qieO[i];
274  bRow . adcO = adcO[i];
275  bRow . rm_fiO = rm_fiO[i];
276  bRow . fi_chO = fi_chO[i];
277  bRow . let_codeO = let_codeO[i];
278 
279  bRow . crateO = crateO[i];
280  bRow . htrO = htrO[i];
281  bRow . fpgaO = fpgaO[i];
282  bRow . htr_fiO = htr_fiO[i];
283  bRow . dcc_slO = dcc_slO[i];
284 
285  bRow . spigoO = spigoO[i];
286  bRow . dccO = dccO[i];
287  bRow . fedidO = fedidO[i];
288 
289  doc . addLMapHODataset( &bRow, "FullHCALDataset.xml" );
290 
291  }
292 
293  doc . write( "FullHCALmap.xml" );
294 
295 
296  std::cout << "XML Test...done" << std::endl;
297 
298  return 0;
299 }
int adc(sample_type sample)
get the ADC sample (12 bits)
XMLDOMBlock * createLMapHBEFXMLBase(std::string templateFileName)
Definition: DBlmapWriter.cc:16
XMLDOMBlock * createLMapHOXMLBase(std::string templateFileName)
Definition: DBlmapWriter.cc:84
int i
Definition: DBlmapReader.cc:9
int addLMapHODataset(XMLDOMBlock *doc, LMapRowHO *row, std::string templateFileName)
Definition: DBlmapWriter.cc:98
T eta() const
tuple result
Definition: query.py:137
string rm
Definition: submit.py:76
int j
Definition: DBlmapReader.cc:9
tuple doc
Definition: asciidump.py:381
int addLMapHBEFDataset(XMLDOMBlock *doc, LMapRowHBEF *row, std::string templateFileName)
Definition: DBlmapWriter.cc:31
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:184
static std::atomic< unsigned int > counter
tuple cout
Definition: gather_cfg.py:121
int createLMap(void)
string root
initialization
Definition: dbtoconf.py:70
Definition: DDAxes.h:10