CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/CaloOnlineTools/HcalOnlineDb/src/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.5 2010/08/06 20:24:13 wmtan Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "CaloOnlineTools/HcalOnlineDb/interface/XMLHTRZeroSuppressionLoader.h"
00018 #include "CalibCalorimetry/HcalTPGAlgos/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     extention_table_name = "HCAL_CHANNELS_OLD_V01";
00057     eta = 1;
00058     phi = 1;
00059     depth = 1;
00060     z = -1;
00061     hcal_channel_id = 1107312769;
00062     std::string detector_name = "HB";
00063     zero_suppression = 2;
00064 }
00065 
00066 XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader( loaderBaseConfig * config, std::string templateBase ) : XMLDOMBlock( templateBase )
00067 {
00068   setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name );
00069   setTagValue( "NAME", config -> name );
00070   setTagValue( "RUN_TYPE", config -> run_type );
00071   setTagValue( "RUN_NUMBER", config -> run_number );
00072   char timebuf[50];
00073   strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> run_begin_timestamp) ) );
00074   setTagValue( "COMMENT_DESCRIPTION", config -> comment_description );
00075   setTagAttribute( "DATA_SET", "id", config -> data_set_id );
00076   setTagAttribute( "IOV", "id", config -> iov_id );
00077   setTagValue( "INTERVAL_OF_VALIDITY_BEGIN", config -> iov_begin );
00078   setTagValue( "INTERVAL_OF_VALIDITY_END", config -> iov_end );
00079   setTagAttribute( "TAG", "id", config -> tag_id );
00080   setTagAttribute( "TAG", "mode", config -> tag_mode );
00081   setTagValue( "TAG_NAME", config -> tag_name );
00082   setTagValue( "DETECTOR_NAME", config -> detector_name );
00083   setTagValue( "COMMENT_DESCRIPTION", config -> elements_comment_description, 1 );
00084 
00085   setTagAttribute( "TAG", "idref", config -> tag_id, 1 );
00086   setTagAttribute( "IOV", "idref", config -> iov_id, 1 );
00087   setTagAttribute( "DATA_SET", "idref", config -> data_set_id, 1 );
00088 }
00089 
00090 // XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader(const XMLHTRZeroSuppressionLoader& rhs)
00091 // {
00092 //    // do actual copying here;
00093 // }
00094 
00095 XMLHTRZeroSuppressionLoader::~XMLHTRZeroSuppressionLoader()
00096 {
00097 }
00098 
00099 //
00100 // assignment operators
00101 //
00102 // const XMLHTRZeroSuppressionLoader& XMLHTRZeroSuppressionLoader::operator=(const XMLHTRZeroSuppressionLoader& rhs)
00103 // {
00104 //   //An exception safe implementation is
00105 //   XMLHTRZeroSuppressionLoader temp(rhs);
00106 //   swap(rhs);
00107 //
00108 //   return *this;
00109 // }
00110 
00111 //
00112 // member functions
00113 //
00114 int XMLHTRZeroSuppressionLoader::addZS( datasetDBConfig * config, std::string templateFileName )
00115 {
00116   DOMElement * root = document -> getDocumentElement();
00117 
00118   XMLDOMBlock dataSetDoc( templateFileName );
00119   DOMDocument * dataSet = dataSetDoc . getDocument();
00120 
00121   // changes to the HTR Zero Suppression <data_set> node
00122   setTagValue( "VERSION", config -> version, 0, dataSet );
00123   setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
00124   char timebuf[50];
00125   //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
00126   strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
00127   setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
00128 
00129   setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
00130   setTagValue( "COMMENT_DESCRIPTION", config -> comment_description, 0, dataSet );
00131   setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name, 0, dataSet );
00132 
00133   setTagValue( "ETA", config -> eta, 0, dataSet );
00134   setTagValue( "PHI", config -> phi, 0, dataSet );
00135   setTagValue( "DEPTH", config -> depth, 0, dataSet );
00136   setTagValue( "Z", config -> z, 0, dataSet );
00137   setTagValue( "HCAL_CHANNEL_ID", config -> hcal_channel_id, 0, dataSet );
00138   setTagValue( "DETECTOR_NAME", config -> detector_name, 0, dataSet );
00139   setTagValue( "ZERO_SUPPRESSION", config -> zero_suppression, 0, dataSet );
00140 
00141   // copy the <data_set> node into the final XML
00142   DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
00143   root -> appendChild( cloneDataSet );
00144 
00145   return 0;
00146 }
00147 
00148 
00149 
00150 
00151 
00152 
00153 /* deprecated - to be removed
00154 int XMLHTRZeroSuppressionLoader::createLoader( void )
00155 {
00156   XMLHTRZeroSuppressionLoader::datasetDBConfig conf;
00157 
00158   LMap map_hbef;
00159   map_hbef . read( "HCALmapHBEF_11.9.2007.txt", "HBEF" ); // HBEF logical map
00160 
00161   for( std::vector<LMapRow>::const_iterator row = map_hbef . _table . begin(); row != map_hbef . _table . end(); row++ )
00162     {
00163       conf . comment_description = "kukarzev: test, fixed eta side";
00164       conf . subversion = "3";
00165       conf . eta = (row -> eta);
00166       conf . z = (row -> side);
00167       conf . phi = row -> phi;
00168       conf . depth = row -> depth;
00169       conf . detector_name = row -> det;
00170 
00171       conf . zero_suppression = 2;
00172 
00173       addZS( &conf );
00174     }
00175   
00176   LMap map_ho;
00177   map_ho . read( "HCALmapHO_11.9.2007.txt", "HO" ); // HO logical map
00178 
00179   for( std::vector<LMapRow>::const_iterator row = map_ho . _table . begin(); row != map_ho . _table . end(); row++ )
00180     {
00181       conf . comment_description = "kukarzev: test, fixed eta side";
00182       conf . subversion = "3";
00183       conf . eta = (row -> eta);
00184       conf . z = (row -> side);
00185       conf . phi = row -> phi;
00186       conf . depth = row -> depth;
00187       conf . detector_name = row -> det;
00188 
00189       conf . zero_suppression = 2;
00190 
00191       addZS( &conf );
00192     }
00193   
00194   write( "XMLHTRZeroSuppressionLoader.xml" );
00195 
00196   return 0;
00197 }
00198 
00199 */