CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XMLHTRPatternLoader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: XMLTools
4 // Class : XMLHTRPatternLoader
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 XERCES_CPP_NAMESPACE_USE
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_HTR_DATA_PATTERNS";
35  name = "HCAL HRT data patterns";
36  run_mode = "no-run";
37  data_set_id = "-1";
38  iov_id = "1";
39  iov_begin = "0";
40  iov_end = "1";
41  tag_id = "2";
42  tag_mode = "auto";
43  tag_name = "HTR data pattern test";
44  detector_name = "HCAL";
45  comment_description = "empty comment, by kukarzev";
46 }
47 
49 {
50  kind_of_part = "HCAL HTR Crate";
51  name_label = "CRATE17";
52  htr_data_patterns_data_file = "testHTRPatterns_17.xml";
53  crate = 17;
54 }
55 
57 {
58  comment_description = "checksum for all crates version test:2";
59  name_label = "CMS-HCAL-ROOT";
60  htr_data_patterns_data_file = "./testHTRPattern_checksums.xml";
61  crate = -1;
62 }
63 
65 {
66 }
67 
69 {
70  setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name );
71  setTagValue( "NAME", config -> name );
72  setTagAttribute( "RUN", "mode", config -> run_mode );
73  setTagAttribute( "DATA_SET", "id", config -> data_set_id );
74  setTagAttribute( "IOV", "id", config -> iov_id );
75  setTagValue( "INTERVAL_OF_VALIDITY_BEGIN", config -> iov_begin );
76  setTagValue( "INTERVAL_OF_VALIDITY_END", config -> iov_end );
77  setTagAttribute( "TAG", "id", config -> tag_id );
78  setTagAttribute( "TAG", "mode", config -> tag_mode );
79  setTagValue( "TAG_NAME", config -> tag_name );
80  setTagValue( "DETECTOR_NAME", config -> detector_name );
81  setTagValue( "COMMENT_DESCRIPTION", config -> comment_description );
82 
83  setTagAttribute( "TAG", "idref", config -> tag_id, 1 );
84  setTagAttribute( "IOV", "idref", config -> iov_id, 1 );
85  setTagAttribute( "DATA_SET", "idref", config -> data_set_id, 1 );
86 }
87 
88 // XMLHTRPatternLoader::XMLHTRPatternLoader(const XMLHTRPatternLoader& rhs)
89 // {
90 // // do actual copying here;
91 // }
92 
94 {
95 }
96 
97 //
98 // assignment operators
99 //
100 // const XMLHTRPatternLoader& XMLHTRPatternLoader::operator=(const XMLHTRPatternLoader& rhs)
101 // {
102 // //An exception safe implementation is
103 // XMLHTRPatternLoader temp(rhs);
104 // swap(rhs);
105 //
106 // return *this;
107 // }
108 
109 //
110 // member functions
111 //
113 {
114  DOMElement * root = document -> getDocumentElement();
115 
116  XMLDOMBlock dataSetDoc( templateFileName );
117  DOMDocument * dataSet = dataSetDoc . getDocument();
118 
119  // changes to the HTRPATTERN <data_set> node
120  setTagValue( "VERSION", config -> version, 0, dataSet );
121  setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
122  char timebuf[50];
123  //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
124  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
125  setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
126  setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
127  setTagValue( "KIND_OF_PART", config -> kind_of_part, 0, dataSet );
128  setTagValue( "NAME_LABEL", config -> name_label, 0, dataSet );
129  setTagValue( "HTR_DATA_PATTERNS_DATA_FILE", config -> htr_data_patterns_data_file, 0, dataSet );
130  setTagValue( "CRATE", config -> crate, 0, dataSet );
131 
132  // copy the <data_set> node into the final XML
133  DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
134  root -> appendChild( cloneDataSet );
135 
136  return 0;
137 }
138 
140 {
141  DOMElement * root = document -> getDocumentElement();
142 
143  XMLDOMBlock dataSetDoc( templateFileName );
144  DOMDocument * dataSet = dataSetDoc . getDocument();
145 
146  // changes to the Checksums <data_set> node
147  setTagValue( "VERSION", config -> version, 0, dataSet );
148  setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
149  char timebuf[50];
150  //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
151  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
152  setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
153  setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
154  setTagValue( "COMMENT_DESCRIPTION", config -> comment_description, 0, dataSet );
155  setTagValue( "NAME_LABEL", config -> name_label, 0, dataSet );
156  setTagValue( "HTR_DATA_PATTERNS_DATA_FILE", config -> htr_data_patterns_data_file, 0, dataSet );
157  setTagValue( "CRATE", config -> crate, 0, dataSet );
158 
159  // copy the <data_set> node into the final XML
160  DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
161  root -> appendChild( cloneDataSet );
162 
163  return 0;
164 }
165 
166 int XMLHTRPatternLoader::createLoader( const std::vector<int>& crate_number, const std::vector<std::string>& file_name )
167 {
169 
170  for ( std::vector<std::string>::const_iterator _file = file_name . begin(); _file != file_name . end(); _file++ )
171  {
172  conf . htr_data_patterns_data_file = *_file;
173  conf . htr_data_patterns_data_file += ".dat";
174  conf . crate = crate_number[ _file - file_name . begin() ];
175 
176  char _buf[128];
177  sprintf( _buf, "CRATE%.2d", conf . crate );
178  std::string _namelabel;
179  _namelabel . append( _buf );
180  conf . name_label = _namelabel;
181  addPattern( &conf );
182  }
183 
184  write( "HTRPatternLoader.xml" );
185 
186  return 0;
187 }
188 
189 //
190 // const member functions
191 //
192 
193 //
194 // static member functions
195 //
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:322
int addChecksums(checksumsDBConfig *config, std::string templateFileName="HCAL_HTR_DATA_PATTERNS.checksums.template")
int addPattern(datasetDBConfig *config, std::string templateFileName="HCAL_HTR_DATA_PATTERNS.dataset.template")
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
#define end
Definition: vmac.h:37
XERCES_CPP_NAMESPACE::DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
tuple conf
Definition: dbtoconf.py:185
#define begin
Definition: vmac.h:30
int createLoader(const std::vector< int > &crate_number, const std::vector< std::string > &file_name)
XERCES_CPP_NAMESPACE::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