00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "CaloOnlineTools/HcalOnlineDb/interface/XMLRBXPedestalsLoader.h"
00018 #include "CaloOnlineTools/HcalOnlineDb/interface/XMLProcessor.h"
00019 #include "CaloOnlineTools/HcalOnlineDb/interface/LMap.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 XMLRBXPedestalsLoader::loaderBaseConfig::_loaderBaseConfig()
00034 {
00035 extention_table_name = "HCAL_RBX_CONFIGURATION_TYPE01";
00036 name = "HCAL RBX configuration [PEDESTAL]";
00037 run_mode = "auto";
00038 data_set_id = "-1";
00039 iov_id = "1";
00040 iov_begin = 1;
00041 iov_end = -1;
00042 tag_id = "2";
00043 tag_mode = "auto";
00044 tag_name = "test_kukartsev_v1";
00045 detector_name = "HCAL";
00046 elements_comment_description = "RBX pedestals";
00047 }
00048
00049 XMLRBXPedestalsLoader::datasetDBConfig::_datasetDBConfig() : XMLProcessor::DBConfig()
00050 {
00051 comment_description = "RBX pedestals for an RBX slot";
00052 name_label = "HEM10";
00053 kind_of_part = "HCAL RBX Slot";
00054 }
00055
00056 XMLRBXPedestalsLoader::XMLRBXPedestalsLoader( loaderBaseConfig * config, string templateBase ) : XMLDOMBlock( templateBase )
00057 {
00058
00059 init();
00060
00061 setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name );
00062 setTagValue( "NAME", config -> name );
00063 setTagAttribute( "RUN", "mode", config -> run_mode );
00064 setTagAttribute( "DATA_SET", "id", config -> data_set_id );
00065 setTagAttribute( "IOV", "id", config -> iov_id );
00066 setTagValue( "INTERVAL_OF_VALIDITY_BEGIN", config -> iov_begin );
00067 setTagValue( "INTERVAL_OF_VALIDITY_END", config -> iov_end );
00068 setTagAttribute( "TAG", "id", config -> tag_id );
00069 setTagAttribute( "TAG", "mode", config -> tag_mode );
00070 setTagValue( "TAG_NAME", config -> tag_name );
00071 setTagValue( "DETECTOR_NAME", config -> detector_name );
00072 setTagValue( "COMMENT_DESCRIPTION", config -> elements_comment_description );
00073 setTagAttribute( "TAG", "idref", config -> tag_id, 1 );
00074 setTagAttribute( "IOV", "idref", config -> iov_id, 1 );
00075 setTagAttribute( "DATA_SET", "idref", config -> data_set_id, 1 );
00076 }
00077
00078
00079 XMLRBXPedestalsLoader::~XMLRBXPedestalsLoader()
00080 {
00081 if( _data_ped_delay ) delete _data_ped_delay;
00082 if( _data_gol ) delete _data_gol;
00083 }
00084
00085
00086 int XMLRBXPedestalsLoader::addRBXSlot( datasetDBConfig * config, string brickFileName, string rbx_config_type, string templateFileName )
00087 {
00088 DOMElement * root = document -> getDocumentElement();
00089
00090 XMLDOMBlock dataSetDoc( templateFileName );
00091 DOMDocument * dataSet = dataSetDoc . getDocument();
00092
00093 char timebuf[50];
00094 strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
00095 setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
00096 setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
00097 setTagValue( "VERSION", config -> version, 0, dataSet );
00098 setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
00099 setTagValue( "COMMENT_DESCRIPTION", config -> comment_description, 0, dataSet );
00100 setTagValue( "NAME_LABEL", config -> name_label, 0, dataSet );
00101 setTagValue( "KIND_OF_PART", config -> kind_of_part, 0, dataSet );
00102
00103
00104
00105 XMLDOMBlock rbxBrickDoc( brickFileName );
00106 DOMDocument * rbxBrick = rbxBrickDoc . getDocument();
00107 for ( int _item = 0; _item < rbxBrick -> getElementsByTagName( XMLProcessor::_toXMLCh( "Data" ) ) -> getLength(); _item++ )
00108 {
00109 DOMElement * dataset_root = dataSet -> getDocumentElement();
00110
00111 string _rm = rbxBrickDoc . getTagAttribute( "Data", "rm", _item );
00112 string _qie = rbxBrickDoc . getTagAttribute( "Data", "card", _item );
00113 string _adc;
00114
00115 MemBufInputSource * _data;
00116 if ( rbx_config_type == "pedestals" || rbx_config_type == "delays" ){
00117 _adc = rbxBrickDoc . getTagAttribute( "Data", "qie", _item );
00118 _data = _data_ped_delay;
00119 }
00120 else if ( rbx_config_type == "gols" ){
00121 _adc = rbxBrickDoc . getTagAttribute( "Data", "gol", _item );
00122 _data = _data_gol;
00123 }
00124 else{
00125 cout << "XMLRBXPedestalsLoader::addRBXSlot(): Unknown config type... exiting" << endl;
00126 exit(1);
00127 }
00128 XMLDOMBlock dataDoc( *_data );
00129 DOMDocument * data = dataDoc . getDocument();
00130 string _value = rbxBrickDoc . getTagValue( "Data", _item );
00131 setTagValue( "MODULE_POSITION", _rm, 0, data );
00132 setTagValue( "QIE_CARD_POSITION", _qie, 0, data );
00133 if ( rbx_config_type == "pedestals" || rbx_config_type == "delays" ){
00134 setTagValue( "QIE_ADC_NUMBER", _adc, 0, data );
00135 }
00136 else if ( rbx_config_type == "gols" ){
00137 setTagValue( "FIBER_NUMBER", _adc, 0, data );
00138 }
00139 else{
00140 cout << "XMLRBXPedestalsLoader::addRBXSlot(): Unknown config type... exiting" << endl;
00141 exit(1);
00142 }
00143 setTagValue( "INTEGER_VALUE", _value, 0, data );
00144 DOMNode * cloneData = dataSet -> importNode( data -> getDocumentElement(), true );
00145 dataset_root -> appendChild( cloneData );
00146 }
00147
00148
00149 DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
00150 root -> appendChild( cloneDataSet );
00151
00152
00153 string _name;
00154 int parameter_iter = -1;
00155 do
00156 {
00157 parameter_iter++;
00158 _name = rbxBrickDoc . getTagAttribute( "Parameter", "name", parameter_iter );
00159
00160 } while( _name != "CREATIONTAG" );
00161 string _creationtag = rbxBrickDoc . getTagValue( "Parameter", parameter_iter );
00162
00163
00164
00165 parameter_iter = -1;
00166 do
00167 {
00168 parameter_iter++;
00169 _name = rbxBrickDoc . getTagAttribute( "Parameter", "name", parameter_iter );
00170
00171 } while( _name != "RBX" );
00172 string _rbx = rbxBrickDoc . getTagValue( "Parameter", parameter_iter );
00173
00174
00175
00176 cout << _rbx << endl;
00177 setTagValue( "NAME_LABEL", _rbx );
00178
00179 return 0;
00180 }
00181
00182 int XMLRBXPedestalsLoader::fixRbxName( string & rbx )
00183 {
00184 string _fourth = rbx . substr(0,4);
00185 if ( _fourth == "HBM0" || _fourth == "HBP0" || _fourth == "HEP0" || _fourth == "HFP0" || _fourth == "HOP0" || _fourth == "HOM0" ) rbx . erase( 3, 1 );
00186
00187 if ( rbx == "HO0M02" ) rbx = "HO0M2";
00188 if ( rbx == "HO0M04" ) rbx = "HO0M4";
00189 if ( rbx == "HO0M06" ) rbx = "HO0M6";
00190 if ( rbx == "HO0M08" ) rbx = "HO0M8";
00191 if ( rbx == "HO0M10" ) rbx = "HO0M10";
00192 if ( rbx == "HO0M12" ) rbx = "HO0M12";
00193 if ( rbx == "HO0P02" ) rbx = "HO0P2";
00194 if ( rbx == "HO0P04" ) rbx = "HO0P4";
00195 if ( rbx == "HO0P06" ) rbx = "HO0P6";
00196 if ( rbx == "HO0P08" ) rbx = "HO0P8";
00197 if ( rbx == "HO0P10" ) rbx = "HO0P10";
00198 if ( rbx == "HO0P12" ) rbx = "HO0P12";
00199
00200 return 0;
00201 }
00202
00203 int XMLRBXPedestalsLoader::init( void )
00204 {
00205
00206 static const char * _str = "\
00207 <DATA>\n\
00208 <MODULE_POSITION>2</MODULE_POSITION>\n\
00209 <QIE_CARD_POSITION>1</QIE_CARD_POSITION>\n\
00210 <QIE_ADC_NUMBER>0</QIE_ADC_NUMBER>\n\
00211 <INTEGER_VALUE>4</INTEGER_VALUE>\n\
00212 </DATA>\n\
00213 ";
00214 const XMLByte * _template = (const XMLByte *)_str;
00215 _data_ped_delay = new MemBufInputSource( _template, strlen( (const char *)_template ), "_data_ped_delay", false );
00216
00217
00218 static const char * _str2 = "\
00219 <DATA>\n\
00220 <MODULE_POSITION>2</MODULE_POSITION>\n\
00221 <QIE_CARD_POSITION>1</QIE_CARD_POSITION>\n\
00222 <FIBER_NUMBER>0</FIBER_NUMBER>\n\
00223 <INTEGER_VALUE>4</INTEGER_VALUE>\n\
00224 </DATA>\n\
00225 ";
00226 const XMLByte * _template2 = (const XMLByte *)_str2;
00227 _data_gol = new MemBufInputSource( _template2, strlen( (const char *)_template2 ), "_data_gol", false );
00228
00229 return 0;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238