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