test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
lumi::TRGDummy2DB Class Reference
Inheritance diagram for lumi::TRGDummy2DB:
lumi::DataPipe

Public Member Functions

virtual const std::string dataType () const override
 
virtual unsigned long long retrieveData (unsigned int) override
 
virtual const std::string sourceType () const override
 
 TRGDummy2DB (const std::string &dest)
 
virtual ~TRGDummy2DB ()
 
- Public Member Functions inherited from lumi::DataPipe
 DataPipe (const std::string &)
 
std::string getAuthPath () const
 
std::string getMode () const
 
float getNorm () const
 
std::string getSource () const
 
void setAuthPath (const std::string &authpath)
 
void setMode (const std::string &mode)
 
void setNoCheckingStableBeam ()
 
void setNorm (float norm)
 
void setNoValidate ()
 
void setSource (const std::string &source)
 
virtual ~DataPipe ()
 

Additional Inherited Members

- Protected Attributes inherited from lumi::DataPipe
std::string m_authpath
 
std::string m_dest
 
std::string m_mode
 
bool m_nocheckingstablebeam
 
float m_norm
 
bool m_novalidate
 
std::string m_source
 

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.

36 :DataPipe(dest){}
DataPipe(const std::string &)
Definition: DataPipe.cc:2
lumi::TRGDummy2DB::~TRGDummy2DB ( )
virtual

Definition at line 119 of file TRGDummy2DB.cc.

119 {}

Member Function Documentation

const std::string lumi::TRGDummy2DB::dataType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 113 of file TRGDummy2DB.cc.

113  {
114  return "TRG";
115  }
unsigned long long lumi::TRGDummy2DB::retrieveData ( unsigned int  runnum)
overridevirtual

Implements lumi::DataPipe.

Definition at line 37 of file TRGDummy2DB.cc.

References trackerHits::c, estimatePileup2::cmslsnum, prof2calltree::count, gather_cfg::cout, edm::hlt::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().

37  {
38  //
39  //generate dummy data of trg for the given run and write data to LumiDB
40  //
41  coral::ConnectionService* svc=new coral::ConnectionService;
42  lumi::DBConfig dbconf(*svc);
43 
44  if(!m_authpath.empty()){
45  dbconf.setAuthentication(m_authpath);
46  }
47  coral::ISessionProxy* session=svc->connect(m_dest,coral::Update);
48  coral::ITypeConverter& tpc=session->typeConverter();
49  tpc.setCppTypeForSqlType("unsigned int","NUMBER(7)");
50  tpc.setCppTypeForSqlType("unsigned int","NUMBER(10)");
51  tpc.setCppTypeForSqlType("unsigned long long","NUMBER(20)");
52  try{
53  unsigned int totalcmsls=32;
54  session->transaction().start(false);
55  coral::ISchema& schema=session->nominalSchema();
56  lumi::idDealer idg(schema);
57  coral::ITable& trgtable=schema.tableHandle(LumiNames::trgTableName());
58  coral::AttributeList trgData;
59  trgData.extend("TRG_ID",typeid(unsigned long long));
60  trgData.extend("RUNNUM",typeid(unsigned int));
61  trgData.extend("CMSLSNUM",typeid(unsigned int));
62  trgData.extend("BITNUM",typeid(unsigned int));
63  trgData.extend("BITNAME",typeid(std::string));
64  trgData.extend("TRGCOUNT",typeid(unsigned int));
65  trgData.extend("DEADTIME",typeid(unsigned long long));
66  trgData.extend("PRESCALE",typeid(unsigned int));
67  coral::IBulkOperation* trgInserter=trgtable.dataEditor().bulkInsert(trgData,totalcmsls*(lumi::N_TRGALGOBIT+lumi::N_TRGTECHBIT));
68  //loop over lumi LS
69  unsigned long long& trg_id=trgData["TRG_ID"].data<unsigned long long>();
70  unsigned int& trgrunnum=trgData["RUNNUM"].data<unsigned int>();
71  unsigned int& cmslsnum=trgData["CMSLSNUM"].data<unsigned int>();
72  unsigned int& bitnum=trgData["BITNUM"].data<unsigned int>();
73  std::string& bitname=trgData["BITNAME"].data<std::string>();
74  unsigned int& count=trgData["TRGCOUNT"].data<unsigned int>();
75  unsigned long long& deadtime=trgData["DEADTIME"].data<unsigned long long>();
76  unsigned int& prescale=trgData["PRESCALE"].data<unsigned int>();
77 
78  for(unsigned int i=1;i<=totalcmsls;++i){
79  for(unsigned int j=0;j<(lumi::N_TRGALGOBIT+lumi::N_TRGTECHBIT);++j){ //total n of trg bits
80  trg_id = idg.generateNextIDForTable(LumiNames::trgTableName());
81  trgrunnum = runnum;
82  cmslsnum = i;
83  bitnum=j;
84  char c[10];
85  if(j>(lumi::N_TRGALGOBIT-1)){
86  ::sprintf(c,"%d",j-(lumi::N_TRGALGOBIT-1));
87  bitname=std::string(c);
88  }else{
89  ::sprintf(c,"%d",j);
90  bitname=std::string("FakeTRGBIT_")+std::string(c);
91  }
92  count=12345;
93  deadtime=6785;
94  prescale=1;
95  trgInserter->processNextIteration();
96  }
97  }
98  trgInserter->flush();
99  delete trgInserter;
100  }catch( const coral::Exception& er){
101  std::cout<<"database problem "<<er.what()<<std::endl;
102  session->transaction().rollback();
103  delete session;
104  delete svc;
105  throw er;
106  }
107  //delete detailInserter;
108  session->transaction().commit();
109  delete session;
110  delete svc;
111  return 0;
112  }
int i
Definition: DBlmapReader.cc:9
static const std::string trgTableName()
Definition: LumiNames.cc:35
std::string m_dest
Definition: DataPipe.h:27
const unsigned int N_TRGTECHBIT
Definition: ConstantDef.h:7
int j
Definition: DBlmapReader.cc:9
std::string m_authpath
Definition: DataPipe.h:29
tuple cout
Definition: gather_cfg.py:121
tuple runnum
Definition: summaryLumi.py:210
const unsigned int N_TRGALGOBIT
Definition: ConstantDef.h:6
const std::string lumi::TRGDummy2DB::sourceType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 116 of file TRGDummy2DB.cc.

116  {
117  return "DUMMY";
118  }