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