CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XMLHTRZeroSuppressionLoader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: XMLTools
4 // Class : XMLHTRZeroSuppressionLoader
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Gena Kukartsev, kukarzev@fnal.gov
10 // Created: Tue Oct 23 14:30:20 CDT 2007
11 //
12 
13 // system include files
14 
15 // user include files
19 
20 
21 //
22 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
33 {
34  extention_table_name = "HCAL_ZERO_SUPPRESSION_TYPE01";
35  name = "HCAL zero suppression [type 1]";
36  run_type = "hcal-test";
37  run_number = 1;
38  run_begin_timestamp = 1194394284;
39  comment_description = "Fake set of ZS by kukartsev";
40  data_set_id = "-1";
41  iov_id = "1";
42  iov_begin = 1;
43  iov_end = -1;
44  tag_id = "2";
45  tag_mode = "auto";
46  tag_name = "test ZS kukartsev";
47  detector_name = "HCAL";
48  elements_comment_description = "Fake ZS for testing (kukartsev)";
49 }
50 
52 {
53  comment_description = "Default ZS comment description";
54  //extention_table_name = "HCAL_CHANNELS";
55  extention_table_name = "HCAL_CHANNELS_OLD_V01";
56  eta = 1;
57  phi = 1;
58  depth = 1;
59  z = -1;
60  hcal_channel_id = 1107312769;
62  zero_suppression = 2;
63 }
64 
66 {
67  setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name );
68  setTagValue( "NAME", config -> name );
69  setTagValue( "RUN_TYPE", config -> run_type );
70  setTagValue( "RUN_NUMBER", config -> run_number );
71  char timebuf[50];
72  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> run_begin_timestamp) ) );
73  setTagValue( "COMMENT_DESCRIPTION", config -> comment_description );
74  setTagAttribute( "DATA_SET", "id", config -> data_set_id );
75  setTagAttribute( "IOV", "id", config -> iov_id );
76  setTagValue( "INTERVAL_OF_VALIDITY_BEGIN", config -> iov_begin );
77  setTagValue( "INTERVAL_OF_VALIDITY_END", config -> iov_end );
78  setTagAttribute( "TAG", "id", config -> tag_id );
79  setTagAttribute( "TAG", "mode", config -> tag_mode );
80  setTagValue( "TAG_NAME", config -> tag_name );
81  setTagValue( "DETECTOR_NAME", config -> detector_name );
82  setTagValue( "COMMENT_DESCRIPTION", config -> elements_comment_description, 1 );
83 
84  setTagAttribute( "TAG", "idref", config -> tag_id, 1 );
85  setTagAttribute( "IOV", "idref", config -> iov_id, 1 );
86  setTagAttribute( "DATA_SET", "idref", config -> data_set_id, 1 );
87 }
88 
89 // XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader(const XMLHTRZeroSuppressionLoader& rhs)
90 // {
91 // // do actual copying here;
92 // }
93 
95 {
96 }
97 
98 //
99 // assignment operators
100 //
101 // const XMLHTRZeroSuppressionLoader& XMLHTRZeroSuppressionLoader::operator=(const XMLHTRZeroSuppressionLoader& rhs)
102 // {
103 // //An exception safe implementation is
104 // XMLHTRZeroSuppressionLoader temp(rhs);
105 // swap(rhs);
106 //
107 // return *this;
108 // }
109 
110 //
111 // member functions
112 //
114 {
115  DOMElement * root = document -> getDocumentElement();
116 
117  XMLDOMBlock dataSetDoc( templateFileName );
118  DOMDocument * dataSet = dataSetDoc . getDocument();
119 
120  // changes to the HTR Zero Suppression <data_set> node
121  setTagValue( "VERSION", config -> version, 0, dataSet );
122  setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
123  char timebuf[50];
124  //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
125  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
126  setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
127 
128  setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
129  setTagValue( "COMMENT_DESCRIPTION", config -> comment_description, 0, dataSet );
130  setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name, 0, dataSet );
131 
132  setTagValue( "ETA", config -> eta, 0, dataSet );
133  setTagValue( "PHI", config -> phi, 0, dataSet );
134  setTagValue( "DEPTH", config -> depth, 0, dataSet );
135  setTagValue( "Z", config -> z, 0, dataSet );
136  setTagValue( "HCAL_CHANNEL_ID", config -> hcal_channel_id, 0, dataSet );
137  setTagValue( "DETECTOR_NAME", config -> detector_name, 0, dataSet );
138  setTagValue( "ZERO_SUPPRESSION", config -> zero_suppression, 0, dataSet );
139 
140  // copy the <data_set> node into the final XML
141  DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
142  root -> appendChild( cloneDataSet );
143 
144  return 0;
145 }
146 
147 
148 
149 
150 
151 
152 /* deprecated - to be removed
153 int XMLHTRZeroSuppressionLoader::createLoader( void )
154 {
155  XMLHTRZeroSuppressionLoader::datasetDBConfig conf;
156 
157  LMap map_hbef;
158  map_hbef . read( "HCALmapHBEF_11.9.2007.txt", "HBEF" ); // HBEF logical map
159 
160  for( std::vector<LMapRow>::const_iterator row = map_hbef . _table . begin(); row != map_hbef . _table . end(); row++ )
161  {
162  conf . comment_description = "kukarzev: test, fixed eta side";
163  conf . subversion = "3";
164  conf . eta = (row -> eta);
165  conf . z = (row -> side);
166  conf . phi = row -> phi;
167  conf . depth = row -> depth;
168  conf . detector_name = row -> det;
169 
170  conf . zero_suppression = 2;
171 
172  addZS( &conf );
173  }
174 
175  LMap map_ho;
176  map_ho . read( "HCALmapHO_11.9.2007.txt", "HO" ); // HO logical map
177 
178  for( std::vector<LMapRow>::const_iterator row = map_ho . _table . begin(); row != map_ho . _table . end(); row++ )
179  {
180  conf . comment_description = "kukarzev: test, fixed eta side";
181  conf . subversion = "3";
182  conf . eta = (row -> eta);
183  conf . z = (row -> side);
184  conf . phi = row -> phi;
185  conf . depth = row -> depth;
186  conf . detector_name = row -> det;
187 
188  conf . zero_suppression = 2;
189 
190  addZS( &conf );
191  }
192 
193  write( "XMLHTRZeroSuppressionLoader.xml" );
194 
195  return 0;
196 }
197 
198 */
DOMDocument * document
Definition: XMLDOMBlock.h:97
DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
int addZS(datasetDBConfig *config, std::string templateFileName="HCAL_HTR_ZERO_SUPPRESSION.dataset.template")
DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, DOMDocument *_document=NULL)
Definition: XMLDOMBlock.cc:364
DOMNode * setTagAttribute(const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
Definition: XMLDOMBlock.cc:408
string root
initialization
Definition: dbtoconf.py:70