CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

FEConfigLUTGroupDat Class Reference

#include <FEConfigLUTGroupDat.h>

Inheritance diagram for FEConfigLUTGroupDat:
IDataItem IDBObject

List of all members.

Public Member Functions

 FEConfigLUTGroupDat ()
int getLUTGroupId () const
int getLUTValue (int i) const
std::string getTable ()
void setLUTGroupId (int x)
void setLUTValue (int i, int x)
 ~FEConfigLUTGroupDat ()

Private Member Functions

void fetchData (std::map< EcalLogicID, FEConfigLUTGroupDat > *fillMap, FEConfigLUTInfo *iconf) throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeArrayDB (const std::map< EcalLogicID, FEConfigLUTGroupDat > *data, FEConfigLUTInfo *iconf) throw (std::runtime_error)
void writeDB (const EcalLogicID *ecid, const FEConfigLUTGroupDat *item, FEConfigLUTInfo *iconf) throw (std::runtime_error)

Private Attributes

int m_group_id
int m_lut [1024]

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 11 of file FEConfigLUTGroupDat.h.


Constructor & Destructor Documentation

FEConfigLUTGroupDat::FEConfigLUTGroupDat ( )

Definition at line 11 of file FEConfigLUTGroupDat.cc.

References i, and NULL.

{
  m_env = NULL;
  m_conn = NULL;
  m_writeStmt = NULL;
  m_readStmt = NULL;

  m_group_id=0;
  for(int i=0; i<1024; i++){
    m_lut[i] = 0;
  }

}
FEConfigLUTGroupDat::~FEConfigLUTGroupDat ( )

Definition at line 27 of file FEConfigLUTGroupDat.cc.

{
}

Member Function Documentation

void FEConfigLUTGroupDat::fetchData ( std::map< EcalLogicID, FEConfigLUTGroupDat > *  fillMap,
FEConfigLUTInfo iconf 
) throw (std::runtime_error) [private]
int FEConfigLUTGroupDat::getLUTGroupId ( ) const [inline]

Definition at line 21 of file FEConfigLUTGroupDat.h.

References m_group_id.

Referenced by popcon::EcalTPGLutIdMapHandler::getNewObjects(), and writeArrayDB().

{ return m_group_id; }
int FEConfigLUTGroupDat::getLUTValue ( int  i) const [inline]

Definition at line 24 of file FEConfigLUTGroupDat.h.

References i, and m_lut.

Referenced by popcon::EcalTPGLutIdMapHandler::getNewObjects(), and writeArrayDB().

{ return m_lut[i]; }
std::string FEConfigLUTGroupDat::getTable ( ) [inline, virtual]

Implements IDataItem.

Definition at line 18 of file FEConfigLUTGroupDat.h.

{ return "FE_CONFIG_LUT_PER_GROUP_DAT"; }
void FEConfigLUTGroupDat::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IDataItem.

Definition at line 33 of file FEConfigLUTGroupDat.cc.

{
  this->checkConnection();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO fe_lut_per_group_dat (lut_conf_id, group_id, "
                      " lut_id, lut_value ) "
                      "VALUES (:lut_conf_id, :group_id, "
                      ":lut_id, :lut_value )" );
  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTGroupDat::prepareWrite():  "+e.getMessage()));
  }
}
void FEConfigLUTGroupDat::setLUTGroupId ( int  x) [inline]

Definition at line 20 of file FEConfigLUTGroupDat.h.

References m_group_id, and x.

Referenced by EcalTPGParamBuilder::analyze().

{ m_group_id = x; }
void FEConfigLUTGroupDat::setLUTValue ( int  i,
int  x 
) [inline]

Definition at line 23 of file FEConfigLUTGroupDat.h.

References i, m_lut, and x.

Referenced by EcalTPGParamBuilder::analyze().

{ m_lut[i] = x; }
void FEConfigLUTGroupDat::writeArrayDB ( const std::map< EcalLogicID, FEConfigLUTGroupDat > *  data,
FEConfigLUTInfo iconf 
) throw (std::runtime_error) [private]

Definition at line 180 of file FEConfigLUTGroupDat.cc.

References prof2calltree::count, gather_cfg::cout, AlCaHLTBitMon_QueryRunRegistry::data, getLUTGroupId(), getLUTValue(), i, AlCaHLTBitMon_ParallelJobs::p, x, detailsBasic3DVector::y, and z.

{
  this->checkConnection();
  this->checkPrepare();

  int iconfID = iconf->fetchID();
  if (!iconfID) { throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB:  ICONF not in DB")); }


  int nrows=data->size()*1024; 
  
  int* iconfid_vec= new int[nrows];
  int* xx= new int[nrows];
  int* yy= new int[nrows];
  int* zz= new int[nrows];



  ub2* iconf_len= new ub2[nrows];
  ub2* x_len= new ub2[nrows];
  ub2* y_len= new ub2[nrows];
  ub2* z_len= new ub2[nrows];


  const FEConfigLUTGroupDat* dataitem;
  int count=0;
  typedef map< EcalLogicID, FEConfigLUTGroupDat >::const_iterator CI;
  for (CI p = data->begin(); p != data->end(); ++p) {
        
        
        dataitem = &(p->second);
        int x=dataitem->getLUTGroupId();
        

        for (int i=0; i<1024; i++){
          iconfid_vec[count]=iconfID;
          int y=i;
          int z=dataitem->getLUTValue(i);

          xx[count]=x;
          yy[count]=y;
          zz[count]=z;
          
          
          iconf_len[count]=sizeof(iconfid_vec[count]);
          
          x_len[count]=sizeof(xx[count]);
          y_len[count]=sizeof(yy[count]);
          z_len[count]=sizeof(zz[count]);
          
          count++;

        }
     }


  try {

    //    for (int i=0; i<nrows; i++){

    int i=0;
      cout << "about to insert "<< iconfid_vec[i]<<" " <<xx[i]<< " "<< yy[i]<< " "<< zz[i]<< endl;
     i=nrows-1;
      cout << "about to insert "<< iconfid_vec[i]<<" " <<xx[i]<< " "<< yy[i]<< " "<< zz[i]<< endl;
      // }
    m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len);
    m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len );
    m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
    m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );

    m_writeStmt->executeArrayUpdate(nrows);


    delete [] iconfid_vec;
    delete [] xx;
    delete [] yy;
    delete [] zz;



    delete [] iconf_len;
    delete [] x_len;
    delete [] y_len;
    delete [] z_len;


  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB():  "+e.getMessage()));
  }
}
void FEConfigLUTGroupDat::writeDB ( const EcalLogicID ecid,
const FEConfigLUTGroupDat item,
FEConfigLUTInfo iconf 
) throw (std::runtime_error) [private]

Definition at line 49 of file FEConfigLUTGroupDat.cc.

References prof2calltree::count, gather_cfg::cout, x, detailsBasic3DVector::y, and z.

{
  this->checkConnection();
  this->checkPrepare();

  int iconfID = iconf->fetchID();

  cout<< "iconf="<< iconfID << endl;

  if (!iconfID) { throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB:  ICONF not in DB")); }


  int nrows=1024;
  int* iconfid_vec= new int[nrows];
  int* xx= new int[nrows];
  int* yy= new int[nrows];
  int* zz= new int[nrows];


  ub2* iconf_len= new ub2[nrows];
  ub2* x_len= new ub2[nrows];
  ub2* y_len= new ub2[nrows];
  ub2* z_len= new ub2[nrows];



    for(int count=0; count<nrows; count++){

        iconfid_vec[count]=iconfID;
        int x=item->getLUTGroupId();
        int y=count;
        int z=m_lut[count];

        xx[count]=x;
        yy[count]=y;
        zz[count]=z;

        iconf_len[count]=sizeof(iconfid_vec[count]);
        
        x_len[count]=sizeof(xx[count]);
        y_len[count]=sizeof(yy[count]);
        z_len[count]=sizeof(zz[count]);

     }


  try {
    m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT, sizeof(iconfid_vec[0]),iconf_len);
    m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT, sizeof(xx[0]), x_len );
    m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT , sizeof(yy[0]), y_len );
    m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT , sizeof(zz[0]), z_len );

    m_writeStmt->executeArrayUpdate(nrows);


    delete [] iconfid_vec;
    delete [] xx;
    delete [] yy;
    delete [] zz;



    delete [] iconf_len;
    delete [] x_len;
    delete [] y_len;
    delete [] z_len;


  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTGroupDat::writeArrayDB():  "+e.getMessage()));
  }
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 13 of file FEConfigLUTGroupDat.h.


Member Data Documentation

Definition at line 44 of file FEConfigLUTGroupDat.h.

Referenced by getLUTGroupId(), and setLUTGroupId().

int FEConfigLUTGroupDat::m_lut[1024] [private]

Definition at line 45 of file FEConfigLUTGroupDat.h.

Referenced by getLUTValue(), and setLUTValue().