CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XMLLUTLoader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: XMLTools
4 // Class : XMLLUTLoader
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
18 #include <cstdio>
19 
20 //
21 // constants, enums and typedefs
22 //
23 
24 //
25 // static data member definitions
26 //
27 
28 //
29 // constructors and destructor
30 //
32 {
33  kind_of_part = "HCAL HTR Crate";
34  name_label = "CRATE17";
35  trig_prim_lookuptbl_data_file = "testLUT_17.xml";
36  crate = 17;
37 }
38 
40 {
41  comment_description = "checksum for all crates version test:2";
42  name_label = "CMS-HCAL-ROOT";
43  trig_prim_lookuptbl_data_file = "./testLUT_checksums.xml";
44  crate = -1;
45 }
46 
48 {
49 }
50 
52 {
53  setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name );
54  setTagValue( "NAME", config -> name );
55  setTagAttribute( "RUN", "mode", config -> run_mode );
56  setTagAttribute( "DATA_SET", "id", config -> data_set_id );
57  setTagAttribute( "IOV", "id", config -> iov_id );
58  setTagValue( "INTERVAL_OF_VALIDITY_BEGIN", config -> iov_begin );
59  setTagValue( "INTERVAL_OF_VALIDITY_END", config -> iov_end );
60  setTagAttribute( "TAG", "id", config -> tag_id );
61  setTagAttribute( "TAG", "mode", config -> tag_mode );
62  setTagValue( "TAG_NAME", config -> tag_name );
63  setTagValue( "DETECTOR_NAME", config -> detector_name );
64  setTagValue( "COMMENT_DESCRIPTION", config -> comment_description );
65 
66  setTagAttribute( "TAG", "idref", config -> tag_id, 1 );
67  setTagAttribute( "IOV", "idref", config -> iov_id, 1 );
68  setTagAttribute( "DATA_SET", "idref", config -> data_set_id, 1 );
69 }
70 
71 // XMLLUTLoader::XMLLUTLoader(const XMLLUTLoader& rhs)
72 // {
73 // // do actual copying here;
74 // }
75 
77 {
78 }
79 
80 //
81 // assignment operators
82 //
83 // const XMLLUTLoader& XMLLUTLoader::operator=(const XMLLUTLoader& rhs)
84 // {
85 // //An exception safe implementation is
86 // XMLLUTLoader temp(rhs);
87 // swap(rhs);
88 //
89 // return *this;
90 // }
91 
92 //
93 // member functions
94 //
96 {
97  DOMElement * root = document -> getDocumentElement();
98 
99  XMLDOMBlock dataSetDoc( templateFileName );
100  DOMDocument * dataSet = dataSetDoc . getDocument();
101 
102  // changes to the LUT <data_set> node
103  setTagValue( "VERSION", config -> version, 0, dataSet );
104  setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
105  char timebuf[50];
106  //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
107  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
108  setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
109  setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
110  setTagValue( "KIND_OF_PART", config -> kind_of_part, 0, dataSet );
111  setTagValue( "NAME_LABEL", config -> name_label, 0, dataSet );
112  setTagValue( "TRIG_PRIM_LOOKUPTBL_DATA_FILE", config -> trig_prim_lookuptbl_data_file, 0, dataSet );
113  setTagValue( "CRATE", config -> crate, 0, dataSet );
114 
115  // copy the <data_set> node into the final XML
116  DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
117  root -> appendChild( cloneDataSet );
118 
119  return 0;
120 }
121 
123 {
124  DOMElement * root = document -> getDocumentElement();
125 
126  XMLDOMBlock dataSetDoc( templateFileName );
127  DOMDocument * dataSet = dataSetDoc . getDocument();
128 
129  // changes to the Checksums <data_set> node
130  setTagValue( "VERSION", config -> version, 0, dataSet );
131  setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
132  char timebuf[50];
133  //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
134  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
135  setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
136  setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
137  setTagValue( "COMMENT_DESCRIPTION", config -> comment_description, 0, dataSet );
138  setTagValue( "NAME_LABEL", config -> name_label, 0, dataSet );
139  setTagValue( "TRIG_PRIM_LOOKUPTBL_DATA_FILE", config -> trig_prim_lookuptbl_data_file, 0, dataSet );
140  setTagValue( "CRATE", config -> crate, 0, dataSet );
141 
142  // copy the <data_set> node into the final XML
143  DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
144  root -> appendChild( cloneDataSet );
145 
146  return 0;
147 }
148 
149 int XMLLUTLoader::createLoader( const std::vector<int>& crate_number, const std::vector<std::string>& file_name )
150 {
153 
154  for ( std::vector<std::string>::const_iterator _file = file_name . begin(); _file != file_name . end(); _file++ )
155  {
156  conf . trig_prim_lookuptbl_data_file = *_file;
157  conf . trig_prim_lookuptbl_data_file += ".dat";
158  conf . crate = crate_number[ _file - file_name . begin() ];
159 
160  char _buf[128];
161  sprintf( _buf, "CRATE%.2d", conf . crate );
162  std::string _namelabel;
163  _namelabel . append( _buf );
164  conf . name_label = _namelabel;
165  addLUT( &conf );
166  }
167 
168  CSconf . trig_prim_lookuptbl_data_file += ".dat";
169  addChecksums( &CSconf );
170  write( "LUTLoader.xml" );
171 
172  return 0;
173 }
174 
175 //
176 // const member functions
177 //
178 
179 //
180 // static member functions
181 //
int addLUT(lutDBConfig *config, std::string templateFileName="HCAL_TRIG_PRIM_LOOKUP_TABLE.dataset.template")
Definition: XMLLUTLoader.cc:95
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:322
DOMDocument * document
Definition: XMLDOMBlock.h:97
virtual ~XMLLUTLoader()
Definition: XMLLUTLoader.cc:76
DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
#define end
Definition: vmac.h:37
tuple conf
Definition: dbtoconf.py:185
int createLoader(const std::vector< int > &crate_number, const std::vector< std::string > &file_name)
#define begin
Definition: vmac.h:30
int addChecksums(checksumsDBConfig *config, std::string templateFileName="HCAL_TRIG_PRIM_LOOKUP_TABLE.checksums.template")
std::string trig_prim_lookuptbl_data_file
Definition: XMLLUTLoader.h:44
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