CMS 3D CMS Logo

XMLHTRZeroSuppressionLoader.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     XMLTools
00004 // Class  :     XMLHTRZeroSuppressionLoader
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Gena Kukartsev, kukarzev@fnal.gov
00010 //         Created:  Tue Oct 23 14:30:20 CDT 2007
00011 // $Id: XMLHTRZeroSuppressionLoader.cc,v 1.2 2008/04/16 13:31:25 kukartse Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "CaloOnlineTools/HcalOnlineDb/interface/XMLHTRZeroSuppressionLoader.h"
00018 #include "CaloOnlineTools/HcalOnlineDb/interface/XMLProcessor.h"
00019 #include "CaloOnlineTools/HcalOnlineDb/interface/LMap.h"
00020 
00021 
00022 //
00023 // constants, enums and typedefs
00024 //
00025 
00026 //
00027 // static data member definitions
00028 //
00029 
00030 //
00031 // constructors and destructor
00032 //
00033 XMLHTRZeroSuppressionLoader::loaderBaseConfig::_loaderBaseConfig()
00034 {
00035   extention_table_name = "HCAL_ZERO_SUPPRESSION_TYPE01";
00036   name = "HCAL zero suppression [type 1]";
00037   run_type = "hcal-test";
00038   run_number = 1;
00039   run_begin_timestamp = 1194394284;
00040   comment_description = "Fake set of ZS by kukartsev";
00041   data_set_id = "-1";
00042   iov_id = "1";
00043   iov_begin = 1;
00044   iov_end = -1;
00045   tag_id = "2";
00046   tag_mode = "auto";
00047   tag_name = "test ZS kukartsev";
00048   detector_name = "HCAL";
00049   elements_comment_description = "Fake ZS for testing (kukartsev)";
00050 }
00051 
00052 XMLHTRZeroSuppressionLoader::datasetDBConfig::_datasetDBConfig() : XMLProcessor::DBConfig()
00053 {
00054     comment_description = "Default ZS comment description";
00055     extention_table_name = "HCAL_CHANNELS";
00056     eta = 1;
00057     phi = 1;
00058     depth = 1;
00059     z = -1;
00060     hcal_channel_id = 1107312769;
00061     string detector_name = "HB";
00062     zero_suppression = 2;
00063 }
00064 
00065 XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader( loaderBaseConfig * config, string templateBase ) : XMLDOMBlock( templateBase )
00066 {
00067   setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name );
00068   setTagValue( "NAME", config -> name );
00069   setTagValue( "RUN_TYPE", config -> run_type );
00070   setTagValue( "RUN_NUMBER", config -> run_number );
00071   char timebuf[50];
00072   strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> run_begin_timestamp) ) );
00073   setTagValue( "COMMENT_DESCRIPTION", config -> comment_description );
00074   setTagAttribute( "DATA_SET", "id", config -> data_set_id );
00075   setTagAttribute( "IOV", "id", config -> iov_id );
00076   setTagValue( "INTERVAL_OF_VALIDITY_BEGIN", config -> iov_begin );
00077   setTagValue( "INTERVAL_OF_VALIDITY_END", config -> iov_end );
00078   setTagAttribute( "TAG", "id", config -> tag_id );
00079   setTagAttribute( "TAG", "mode", config -> tag_mode );
00080   setTagValue( "TAG_NAME", config -> tag_name );
00081   setTagValue( "DETECTOR_NAME", config -> detector_name );
00082   setTagValue( "COMMENT_DESCRIPTION", config -> elements_comment_description, 1 );
00083 
00084   setTagAttribute( "TAG", "idref", config -> tag_id, 1 );
00085   setTagAttribute( "IOV", "idref", config -> iov_id, 1 );
00086   setTagAttribute( "DATA_SET", "idref", config -> data_set_id, 1 );
00087 }
00088 
00089 // XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader(const XMLHTRZeroSuppressionLoader& rhs)
00090 // {
00091 //    // do actual copying here;
00092 // }
00093 
00094 XMLHTRZeroSuppressionLoader::~XMLHTRZeroSuppressionLoader()
00095 {
00096 }
00097 
00098 //
00099 // assignment operators
00100 //
00101 // const XMLHTRZeroSuppressionLoader& XMLHTRZeroSuppressionLoader::operator=(const XMLHTRZeroSuppressionLoader& rhs)
00102 // {
00103 //   //An exception safe implementation is
00104 //   XMLHTRZeroSuppressionLoader temp(rhs);
00105 //   swap(rhs);
00106 //
00107 //   return *this;
00108 // }
00109 
00110 //
00111 // member functions
00112 //
00113 int XMLHTRZeroSuppressionLoader::addZS( datasetDBConfig * config, string templateFileName )
00114 {
00115   DOMElement * root = document -> getDocumentElement();
00116 
00117   XMLDOMBlock dataSetDoc( templateFileName );
00118   DOMDocument * dataSet = dataSetDoc . getDocument();
00119 
00120   // changes to the HTR Zero Suppression <data_set> node
00121   setTagValue( "VERSION", config -> version, 0, dataSet );
00122   setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
00123   char timebuf[50];
00124   //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
00125   strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
00126   setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
00127 
00128   setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
00129   setTagValue( "COMMENT_DESCRIPTION", config -> comment_description, 0, dataSet );
00130   setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name, 0, dataSet );
00131 
00132   setTagValue( "ETA", config -> eta, 0, dataSet );
00133   setTagValue( "PHI", config -> phi, 0, dataSet );
00134   setTagValue( "DEPTH", config -> depth, 0, dataSet );
00135   setTagValue( "Z", config -> z, 0, dataSet );
00136   setTagValue( "HCAL_CHANNEL_ID", config -> hcal_channel_id, 0, dataSet );
00137   setTagValue( "DETECTOR_NAME", config -> detector_name, 0, dataSet );
00138   setTagValue( "ZERO_SUPPRESSION", config -> zero_suppression, 0, dataSet );
00139 
00140   // copy the <data_set> node into the final XML
00141   DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
00142   root -> appendChild( cloneDataSet );
00143 
00144   return 0;
00145 }
00146 
00147 
00148 
00149 
00150 
00151 
00152 /* deprecated - to be removed
00153 int XMLHTRZeroSuppressionLoader::createLoader( void )
00154 {
00155   XMLHTRZeroSuppressionLoader::datasetDBConfig conf;
00156 
00157   LMap map_hbef;
00158   map_hbef . read( "HCALmapHBEF_11.9.2007.txt", "HBEF" ); // HBEF logical map
00159 
00160   for( vector<LMapRow>::const_iterator row = map_hbef . _table . begin(); row != map_hbef . _table . end(); row++ )
00161     {
00162       conf . comment_description = "kukarzev: test, fixed eta side";
00163       conf . subversion = "3";
00164       conf . eta = (row -> eta);
00165       conf . z = (row -> side);
00166       conf . phi = row -> phi;
00167       conf . depth = row -> depth;
00168       conf . detector_name = row -> det;
00169 
00170       conf . zero_suppression = 2;
00171 
00172       addZS( &conf );
00173     }
00174   
00175   LMap map_ho;
00176   map_ho . read( "HCALmapHO_11.9.2007.txt", "HO" ); // HO logical map
00177 
00178   for( vector<LMapRow>::const_iterator row = map_ho . _table . begin(); row != map_ho . _table . end(); row++ )
00179     {
00180       conf . comment_description = "kukarzev: test, fixed eta side";
00181       conf . subversion = "3";
00182       conf . eta = (row -> eta);
00183       conf . z = (row -> side);
00184       conf . phi = row -> phi;
00185       conf . depth = row -> depth;
00186       conf . detector_name = row -> det;
00187 
00188       conf . zero_suppression = 2;
00189 
00190       addZS( &conf );
00191     }
00192   
00193   write( "XMLHTRZeroSuppressionLoader.xml" );
00194 
00195   return 0;
00196 }
00197 
00198 */

Generated on Tue Jun 9 17:25:57 2009 for CMSSW by  doxygen 1.5.4