CMS 3D CMS Logo

Public Member Functions

lumi::TRGDummy2DB Class Reference

Inheritance diagram for lumi::TRGDummy2DB:
lumi::DataPipe

List of all members.

Public Member Functions

virtual const std::string dataType () const
virtual unsigned long long retrieveData (unsigned int)
virtual const std::string sourceType () const
 TRGDummy2DB (const std::string &dest)
virtual ~TRGDummy2DB ()

Detailed Description

Definition at line 25 of file TRGDummy2DB.cc.


Constructor & Destructor Documentation

lumi::TRGDummy2DB::TRGDummy2DB ( const std::string &  dest)

Definition at line 36 of file TRGDummy2DB.cc.

lumi::TRGDummy2DB::~TRGDummy2DB ( ) [virtual]

Definition at line 119 of file TRGDummy2DB.cc.

{}

Member Function Documentation

const std::string lumi::TRGDummy2DB::dataType ( ) const [virtual]

Implements lumi::DataPipe.

Definition at line 113 of file TRGDummy2DB.cc.

                                             {
    return "TRG";
  }
unsigned long long lumi::TRGDummy2DB::retrieveData ( unsigned int  runnum) [virtual]

Implements lumi::DataPipe.

Definition at line 37 of file TRGDummy2DB.cc.

References trackerHits::c, estimatePileup2::cmslsnum, prof2calltree::count, gather_cfg::cout, Exception, lumi::idDealer::generateNextIDForTable(), i, j, lumi::DataPipe::m_authpath, lumi::DataPipe::m_dest, lumi::N_TRGALGOBIT, lumi::N_TRGTECHBIT, summaryLumi::runnum, python::IdGenerator::schema, python::CommonUtils::session, lumi::DBConfig::setAuthentication(), AlCaHLTBitMon_QueryRunRegistry::string, python::CommonUtils::svc, and lumi::LumiNames::trgTableName().

                                                                  {
    //
    //generate dummy data of trg for the given run and write data to LumiDB
    //
    coral::ConnectionService* svc=new coral::ConnectionService;
    lumi::DBConfig dbconf(*svc);
    
    if(!m_authpath.empty()){
      dbconf.setAuthentication(m_authpath);
    }
    coral::ISessionProxy* session=svc->connect(m_dest,coral::Update);
    coral::ITypeConverter& tpc=session->typeConverter();
    tpc.setCppTypeForSqlType("unsigned int","NUMBER(7)");
    tpc.setCppTypeForSqlType("unsigned int","NUMBER(10)");
    tpc.setCppTypeForSqlType("unsigned long long","NUMBER(20)");
    try{
      unsigned int totalcmsls=32;
      session->transaction().start(false);
      coral::ISchema& schema=session->nominalSchema();
      lumi::idDealer idg(schema);
      coral::ITable& trgtable=schema.tableHandle(LumiNames::trgTableName());
      coral::AttributeList trgData;
      trgData.extend("TRG_ID",typeid(unsigned long long));
      trgData.extend("RUNNUM",typeid(unsigned int));
      trgData.extend("CMSLSNUM",typeid(unsigned int));
      trgData.extend("BITNUM",typeid(unsigned int));
      trgData.extend("BITNAME",typeid(std::string));
      trgData.extend("TRGCOUNT",typeid(unsigned int));
      trgData.extend("DEADTIME",typeid(unsigned long long));
      trgData.extend("PRESCALE",typeid(unsigned int));
      coral::IBulkOperation* trgInserter=trgtable.dataEditor().bulkInsert(trgData,totalcmsls*(lumi::N_TRGALGOBIT+lumi::N_TRGTECHBIT));
      //loop over lumi LS
      unsigned long long& trg_id=trgData["TRG_ID"].data<unsigned long long>();
      unsigned int& trgrunnum=trgData["RUNNUM"].data<unsigned int>();
      unsigned int& cmslsnum=trgData["CMSLSNUM"].data<unsigned int>();
      unsigned int& bitnum=trgData["BITNUM"].data<unsigned int>();
      std::string& bitname=trgData["BITNAME"].data<std::string>();
      unsigned int& count=trgData["TRGCOUNT"].data<unsigned int>();
      unsigned long long& deadtime=trgData["DEADTIME"].data<unsigned long long>();
      unsigned int& prescale=trgData["PRESCALE"].data<unsigned int>();
      
      for(unsigned int i=1;i<=totalcmsls;++i){
        for(unsigned int j=0;j<(lumi::N_TRGALGOBIT+lumi::N_TRGTECHBIT);++j){ //total n of trg bits
          trg_id = idg.generateNextIDForTable(LumiNames::trgTableName());
          trgrunnum = runnum;
          cmslsnum = i;
          bitnum=j;
          char c[10];
          if(j>(lumi::N_TRGALGOBIT-1)){
            ::sprintf(c,"%d",j-(lumi::N_TRGALGOBIT-1));
            bitname=std::string(c);
          }else{
            ::sprintf(c,"%d",j);
            bitname=std::string("FakeTRGBIT_")+std::string(c);
          }
          count=12345;
          deadtime=6785;
          prescale=1;
          trgInserter->processNextIteration();
        }
      }
      trgInserter->flush();
      delete trgInserter;
    }catch( const coral::Exception& er){
      std::cout<<"database problem "<<er.what()<<std::endl;
      session->transaction().rollback();
      delete session;
      delete svc;
      throw er;
    }
    //delete detailInserter;
    session->transaction().commit();
    delete session;
    delete svc;
    return 0;
  }
const std::string lumi::TRGDummy2DB::sourceType ( ) const [virtual]

Implements lumi::DataPipe.

Definition at line 116 of file TRGDummy2DB.cc.

                                               {
    return "DUMMY";
  }