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::LumiDummy2DB Class Reference
Inheritance diagram for lumi::LumiDummy2DB:
lumi::DataPipe

Public Member Functions

virtual const std::string dataType () const override
 
 LumiDummy2DB (const std::string &dest)
 
virtual unsigned long long retrieveData (unsigned int) override
 
virtual const std::string sourceType () const override
 
virtual ~LumiDummy2DB ()
 
- 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 27 of file LumiDummy2DB.cc.

Constructor & Destructor Documentation

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

Definition at line 38 of file LumiDummy2DB.cc.

38  :DataPipe(dest){
39  //check the format of dest
40  }
DataPipe(const std::string &)
Definition: DataPipe.cc:2
lumi::LumiDummy2DB::~LumiDummy2DB ( )
virtual

Definition at line 188 of file LumiDummy2DB.cc.

188 {}

Member Function Documentation

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

Implements lumi::DataPipe.

Definition at line 182 of file LumiDummy2DB.cc.

182  {
183  return "LUMI";
184  }
unsigned long long lumi::LumiDummy2DB::retrieveData ( unsigned int  runnum)
overridevirtual

Implements lumi::DataPipe.

Definition at line 41 of file LumiDummy2DB.cc.

References estimatePileup2::cmslsnum, edm::hlt::Exception, lumi::idDealer::generateNextIDForTable(), i, j, roll_playback::k, lumi::LumiNames::lumidetailTableName(), lumiPlot::lumilsnum, lumi::LumiNames::lumisummaryTableName(), lumi::DataPipe::m_authpath, lumi::DataPipe::m_dest, lumi::N_BX, lumi::N_LUMIALGO, summaryLumi::runnum, python.IdGenerator::schema, python.CommonUtils::session, lumi::DBConfig::setAuthentication(), AlCaHLTBitMon_QueryRunRegistry::string, and python.CommonUtils::svc.

41  {
42  //
43  //generate dummy data for lumi summary and detail for the given run and write data to LumiDB
44  //
45  coral::ConnectionService* svc=new coral::ConnectionService;
46  lumi::DBConfig dbconf(*svc);
47  if(!m_authpath.empty()){
48  dbconf.setAuthentication(m_authpath);
49  }
50  coral::ISessionProxy* session=svc->connect(m_dest,coral::Update);
51  coral::ITypeConverter& tpc=session->typeConverter();
52  tpc.setCppTypeForSqlType("unsigned int","NUMBER(10)");
53  try{
54  unsigned int totallumils=35;
55  unsigned int totalcmsls=32;
56  session->transaction().start(false);
57  coral::ISchema& schema=session->nominalSchema();
58  lumi::idDealer idg(schema);
59  coral::ITable& summarytable=schema.tableHandle(LumiNames::lumisummaryTableName());
60  coral::ITable& detailtable=schema.tableHandle(LumiNames::lumidetailTableName());
61  coral::AttributeList summaryData;
62  summaryData.extend("LUMISUMMARY_ID",typeid(unsigned long long));
63  summaryData.extend("RUNNUM",typeid(unsigned int));
64  summaryData.extend("CMSLSNUM",typeid(unsigned int));
65  summaryData.extend("LUMILSNUM",typeid(unsigned int));
66  summaryData.extend("LUMIVERSION",typeid(std::string));
67  summaryData.extend("DTNORM",typeid(float));
68  summaryData.extend("LHCNORM",typeid(float));
69  summaryData.extend("INSTLUMI",typeid(float));
70  summaryData.extend("INSTLUMIERROR",typeid(float));
71  summaryData.extend("INSTLUMIQUALITY",typeid(short));
72  summaryData.extend("LUMISECTIONQUALITY",typeid(short));
73  summaryData.extend("CMSALIVE",typeid(short));
74  summaryData.extend("STARTORBIT",typeid(unsigned int));
75  summaryData.extend("NUMORBIT",typeid(unsigned int));
76  summaryData.extend("BEAMENERGY",typeid(float));
77  summaryData.extend("BEAMSTATUS",typeid(std::string));
78 
79  coral::IBulkOperation* summaryInserter=summarytable.dataEditor().bulkInsert(summaryData,totallumils);
80  coral::AttributeList detailData;
81  detailData.extend("LUMIDETAIL_ID",typeid(unsigned long long));
82  detailData.extend("LUMISUMMARY_ID",typeid(unsigned long long));
83  detailData.extend("BXLUMIVALUE",typeid(coral::Blob));
84  detailData.extend("BXLUMIERROR",typeid(coral::Blob));
85  detailData.extend("BXLUMIQUALITY",typeid(coral::Blob));
86  detailData.extend("ALGONAME",typeid(std::string));
87  coral::IBulkOperation* detailInserter=detailtable.dataEditor().bulkInsert(detailData,totallumils*N_LUMIALGO);
88  //loop over lumi LS
89  unsigned long long& lumisummary_id=summaryData["LUMISUMMARY_ID"].data<unsigned long long>();
90  unsigned int& lumirunnum = summaryData["RUNNUM"].data<unsigned int>();
91  unsigned int& cmslsnum=summaryData["CMSLSNUM"].data<unsigned int>();
92  unsigned int& lumilsnum=summaryData["LUMILSNUM"].data<unsigned int>();
93  std::string& lumiversion = summaryData["LUMIVERSION"].data<std::string>();
94  float& dtnorm = summaryData["DTNORM"].data<float>();
95  float& lhcnorm = summaryData["LHCNORM"].data<float>();
96  float& instlumi = summaryData["INSTLUMI"].data<float>();
97  float& instlumierror = summaryData["INSTLUMIERROR"].data<float>();
98  short& instlumiquality = summaryData["INSTLUMIQUALITY"].data<short>();
99  short& lumisectionquality = summaryData["LUMISECTIONQUALITY"].data<short>();
100  short& cmsalive = summaryData["CMSALIVE"].data<short>();
101  unsigned int& startorbit=summaryData["STARTORBIT"].data<unsigned int>();
102  unsigned int& numorbit= summaryData["NUMORBIT"].data<unsigned int>();
103  float& beamenergy= summaryData["BEAMENERGY"].data<float>();
104  std::string& beamstatus= summaryData["BEAMSTATUS"].data<std::string>();
105 
106  unsigned long long& lumidetail_id=detailData["LUMIDETAIL_ID"].data<unsigned long long>();
107  unsigned long long& d2lumisummary_id=detailData["LUMISUMMARY_ID"].data<unsigned long long>();
108  coral::Blob& bxlumivalue=detailData["BXLUMIVALUE"].data<coral::Blob>();
109  coral::Blob& bxlumierror=detailData["BXLUMIERROR"].data<coral::Blob>();
110  coral::Blob& bxlumiquality=detailData["BXLUMIQUALITY"].data<coral::Blob>();
111  std::string& algoname=detailData["ALGONAME"].data<std::string>();
112  for(unsigned int i=1;i<=totallumils;++i){
113  lumisummary_id = idg.generateNextIDForTable(LumiNames::lumisummaryTableName());
114  lumilsnum=i;
115  lumirunnum = runnum;
116  lumiversion = "0";
117  dtnorm = 1.05;
118  lhcnorm = 1.2;
119  instlumi = 0.9;
120  instlumierror = 0.01;
121  instlumiquality = 8;
122  lumisectionquality = 16;
123  // unsigned int cmslsnum = 0;
124  short iscmsalive = 0;
125  if(i<=totalcmsls){
126  iscmsalive=1;
127  cmslsnum=i;
128  }
129  cmsalive=iscmsalive;
130  startorbit=2837495;
131  numorbit=34566;
132  beamenergy=362;
133  beamstatus="stable";
134  //fetch a new id value
135  //insert the new row
136  summaryInserter->processNextIteration();
137  summaryInserter->flush();
138  d2lumisummary_id=i;
139  for( unsigned int j=0; j<N_LUMIALGO; ++j ){
140  lumidetail_id=idg.generateNextIDForTable(LumiNames::lumidetailTableName());
141  if(j==0) algoname=std::string("ET");
142  if(j==1) algoname=std::string("OCC1");
143  if(j==2) algoname=std::string("OCC2");
144  float lumivalue[N_BX];
145  std::memset((void*)&lumivalue,0,sizeof(float)*N_BX);
146  float lumierror[N_BX];
147  std::memset((void*)&lumierror,0,sizeof(float)*N_BX );
148  short lumiquality[N_BX];
149  std::memset((void*)&lumiquality,0,sizeof(short)*N_BX );
150  bxlumivalue.resize(sizeof(float)*N_BX);
151  bxlumierror.resize(sizeof(float)*N_BX);
152  bxlumiquality.resize(sizeof(short)*N_BX);
153  void* bxlumivalueStartAddress=bxlumivalue.startingAddress();
154  void* bxlumierrorStartAddress=bxlumierror.startingAddress();
155  void* bxlumiqualityStartAddress=bxlumiquality.startingAddress();
156  for( unsigned int k=0; k<N_BX; ++k ){
157  lumivalue[k]=1.5;
158  lumierror[k]=0.1;
159  lumiquality[k]=1;
160  }
161  std::memmove(bxlumivalueStartAddress,lumivalue,sizeof(float)*N_BX);
162  std::memmove(bxlumierrorStartAddress,lumierror,sizeof(float)*N_BX);
163  std::memmove(bxlumiqualityStartAddress,lumiquality,sizeof(short)*N_BX);
164  detailInserter->processNextIteration();
165  }
166  }
167  detailInserter->flush();
168  delete summaryInserter;
169  delete detailInserter;
170  }catch( const coral::Exception& er){
171  session->transaction().rollback();
172  delete session;
173  delete svc;
174  throw er;
175  }
176  //delete detailInserter;
177  session->transaction().commit();
178  delete session;
179  delete svc;
180  return 0;
181  }
int i
Definition: DBlmapReader.cc:9
const unsigned int N_LUMIALGO
Definition: ConstantDef.h:4
std::string m_dest
Definition: DataPipe.h:27
static const std::string lumisummaryTableName()
Definition: LumiNames.cc:11
int j
Definition: DBlmapReader.cc:9
list lumilsnum
Definition: lumiPlot.py:485
const unsigned int N_BX
Definition: ConstantDef.h:5
static const std::string lumidetailTableName()
Definition: LumiNames.cc:17
std::string m_authpath
Definition: DataPipe.h:29
tuple runnum
Definition: summaryLumi.py:210
const std::string lumi::LumiDummy2DB::sourceType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 185 of file LumiDummy2DB.cc.

185  {
186  return "DUMMY";
187  }