CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/CaloOnlineTools/HcalOnlineDb/src/LMapLoader.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     XMLTools
00004 // Class  :     LMapLoader
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Aram Avetisyan, avetisya@fnal.gov
00010 //         Created:  Tue Oct 23 14:30:20 CDT 2007
00011 // $Id: LMapLoader.cc,v 1.3 2010/08/06 20:24:13 wmtan Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "CaloOnlineTools/HcalOnlineDb/interface/LMapLoader.h"
00018 #include "CalibCalorimetry/HcalTPGAlgos/interface/XMLProcessor.h"
00019 
00020 //
00021 // constants, enums and typedefs
00022 //
00023 
00024 //
00025 // static data member definitions
00026 //
00027 
00028 //
00029 // constructors and destructor
00030 //
00031 
00032 
00033 LMapLoader::LMapLoader() : XMLDOMBlock( "FullLmapBase.xml" )
00034 {
00035   createLMapHBEFXMLBase( );
00036 }
00037 
00038 LMapLoader::LMapLoader( std::string templateLoaderBase ) : XMLDOMBlock( templateLoaderBase )
00039 {
00040   createLMapHBEFXMLBase( );
00041 }
00042 
00043 int LMapLoader::createLMapHBEFXMLBase( void ){
00044   document -> getElementsByTagName( XMLProcessor::_toXMLCh( "NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( "HCAL hardware logical channel maps v3" ) );
00045 
00046   return 0;
00047 }
00048 
00049 // LMapLoader::LMapLoader(const LMapLoader& rhs)
00050 // {
00051 //    // do actual copying here;
00052 // }
00053 
00054 LMapLoader::~LMapLoader()
00055 {
00056 }
00057 
00058 //
00059 // assignment operators
00060 //
00061 // const LMapLoader& LMapLoader::operator=(const LMapLoader& rhs)
00062 // {
00063 //   //An exception safe implementation is
00064 //   LMapLoader temp(rhs);
00065 //   swap(rhs);
00066 //
00067 //   return *this;
00068 // }
00069 
00070 //
00071 // member functions
00072 //
00073 
00074 int LMapLoader::addLMapHBEFDataset( LMapRowHBEF * row, std::string templateFileName )
00075 {
00076   DOMDocument * loader = document;
00077   //DOMElement * root = loader -> getDocumentElement();
00078   DOMElement * root = (DOMElement *)(loader -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(2));
00079 
00080   XMLDOMBlock dataSetDoc( templateFileName );
00081   DOMDocument * dataSet = dataSetDoc . getDocument();
00082   
00083   //Dataset
00084   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> side ) );  
00085   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->  eta) );  
00086   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> phi ) );  
00087   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dphi ) );  
00088 
00089   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> depth  ) );  
00090   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> det ) );  
00091   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RBX" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rbx ) );  
00092   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "WEDGE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> wedge ) );
00093  
00094   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rm  ) );  
00095   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> pixel ) );  
00096   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> qie ) );  
00097   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> adc ) );  
00098   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rm_fi ) );
00099 
00100   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fi_ch));
00101   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> crate ) );  
00102   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->  htr ) );  
00103   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fpga ) );
00104 
00105   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> htr_fi ));  
00106   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dcc_sl ) );  
00107   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->  spigo ) );  
00108   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dcc ) );  
00109   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_SITE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slb ) );  
00110   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slbin )); 
00111   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_CHANNEL2" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slbin2));
00112 
00113   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SLB_CABLE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> slnam ) );  
00114   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rctcra ) ); 
00115   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_CARD" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rctcar ) );
00116   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_CONNECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->rctcon));
00117   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RCT_NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rctnam ) );  
00118   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fedid ) );
00119   
00120       
00121   // copy the <data_set> node into the final XML
00122   DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(), true );
00123   root -> appendChild( cloneDataSet );
00124 
00125   return 0;
00126 }
00127 
00128 int LMapLoader::addLMapHODataset( LMapRowHO * row, std::string templateFileName )
00129 {
00130   DOMDocument * loader = document;
00131   //DOMElement * root = loader -> getDocumentElement();
00132   DOMElement * root = (DOMElement *)(loader -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(2));
00133 
00134   XMLDOMBlock dataSetDoc( templateFileName );
00135   DOMDocument * dataSet = dataSetDoc . getDocument();
00136   
00137   //Dataset
00138   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> sideO ) );  
00139   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->  etaO ) );  
00140   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> phiO ) );  
00141   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dphiO ) );
00142   
00143   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> depthO  ) );  
00144   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> detO ) ); 
00145   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RBX" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rbxO ) );  
00146   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> sectorO ) );
00147  
00148   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rmO  ) );  
00149   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> pixelO ) ); 
00150   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> qieO ) );  
00151   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> adcO ) );  
00152   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> rm_fiO ) );  
00153   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->fi_chO));
00154 
00155   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "LETTER_CODE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh(row ->let_codeO));
00156   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> crateO ) );  
00157   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->  htrO ) );  
00158   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fpgaO ) );
00159 
00160   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> htr_fiO ) );
00161   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dcc_slO ) );  
00162   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row ->  spigoO ) );  
00163   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> dccO ) );  
00164   dataSet -> getElementsByTagName( XMLProcessor::_toXMLCh( "FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( XMLProcessor::_toXMLCh( row -> fedidO ) );
00165   
00166       
00167   // copy the <data_set> node into the final XML
00168   DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(), true );
00169   root -> appendChild( cloneDataSet );
00170 
00171   return 0;
00172 }
00173 
00174 
00175 //
00176 // const member functions
00177 //
00178 
00179 //
00180 // static member functions
00181 //