CMS 3D CMS Logo

Functions
applyCalibration Namespace Reference

Functions

def calibrateRange (dbsession, normfactor, startrun, endrun)
 
def calibrateRun (dbsession, normfactor, runnum)
 
def main ()
 

Function Documentation

def applyCalibration.calibrateRange (   dbsession,
  normfactor,
  startrun,
  endrun 
)
update lumisummary set instlumi=instlumi*:norm where runnum>=:startrun and runnum<=:endrun

Definition at line 12 of file applyCalibration.py.

References objects.autophobj.float, createfilelist.int, edm.print(), and str.

Referenced by main().

12 def calibrateRange(dbsession,normfactor,startrun,endrun):
13  '''
14  update lumisummary set instlumi=instlumi*:norm where runnum>=:startrun and runnum<=:endrun
15  '''
16  try:
17  dbsession.transaction().start(False)
18  schema=dbsession.nominalSchema()
19  if not schema:
20  raise 'cannot connect to schema'
21  if not schema.existsTable('LUMISUMMARY'):
22  raise 'non-existing table LUMISUMMARY'
23  inputData=coral.AttributeList()
24  inputData.extend('normfactor','float')
25  inputData['normfactor'].setData(float(normfactor))
26  inputData.extend('startrun','unsigned int')
27  inputData['startrun'].setData(int(startrun))
28  inputData.extend('endrun','unsigned int')
29  inputData['endrun'].setData(int(endrun))
30  nchanged=schema.tableHandle('LUMISUMMARY').dataEditor().updateRows('INSTLUMI=INSTLUMI*:normfactor','RUNNUM>=:startrun AND RUNNUM<=:endrun',inputData)
31  dbsession.transaction().commit()
32  return nchanged
33  except Exception as e:
34  print(str(e))
35  dbsession.transaction().rollback()
36  del dbsession
Definition: start.py:1
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def calibrateRange(dbsession, normfactor, startrun, endrun)
#define str(s)
def applyCalibration.calibrateRun (   dbsession,
  normfactor,
  runnum 
)
update lumisummary set instlumi=instlumi*:norm where runnum=:run 

Definition at line 37 of file applyCalibration.py.

References objects.autophobj.float, createfilelist.int, edm.print(), and str.

Referenced by main().

37 def calibrateRun(dbsession,normfactor,runnum):
38  '''
39  update lumisummary set instlumi=instlumi*:norm where runnum=:run
40  '''
41  try:
42  dbsession.transaction().start(False)
43  schema=dbsession.nominalSchema()
44  if not schema:
45  raise 'cannot connect to schema'
46  if not schema.existsTable('LUMISUMMARY'):
47  raise 'non-existing table LUMISUMMARY'
48  inputData=coral.AttributeList()
49  inputData.extend('normfactor','float')
50  inputData['normfactor'].setData(float(normfactor))
51  inputData.extend('runnumber','unsigned int')
52  inputData['runnumber'].setData(int(runnum))
53  nchanged=schema.tableHandle('LUMISUMMARY').dataEditor().updateRows('INSTLUMI=INSTLUMI*:normfactor','RUNNUM=:runnumber',inputData)
54  dbsession.transaction().commit()
55  return nchanged
56  except Exception as e:
57  print(str(e))
58  dbsession.transaction().rollback()
59  del dbsession
60 
Definition: start.py:1
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def calibrateRun(dbsession, normfactor, runnum)
#define str(s)
def applyCalibration.main ( )

Definition at line 61 of file applyCalibration.py.

References calibrateRange(), calibrateRun(), and edm.print().

61 def main():
62  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="apply normalization factor to inst lumi")
63  parser.add_argument('-c',dest='connectstr',action='store',required=True,help='connectstr')
64  parser.add_argument('-norm',dest='normfactor',action='store',required=True,help='normalization factor to apply')
65  parser.add_argument('-P',dest='authpath',action='store',required=True,help='path to authentication file')
66  parser.add_argument('-r',dest='runnumber',action='store',required=False,help='run number')
67  parser.add_argument('-startrun',dest='startrun',action='store',required=False,help='start run for range action')
68  parser.add_argument('-endrun',dest='endrun',action='store',required=False,help='end run for range action')
69  parser.add_argument('action',choices=['run','range'],help='calibrate run')
70 
71  parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
72  args=parser.parse_args()
73  connectstr=args.connectstr
74  normfactor=args.normfactor
75  if len(args.authpath)!=0:
76  os.environ['CORAL_AUTH_PATH']=args.authpath
77  else:
78  raise '-P authpath argument is required'
79  svc=coral.ConnectionService()
80  session=svc.connect(connectstr,accessMode=coral.access_Update)
81  if args.debug:
82  msg=coral.MessageStream('')
83  msg.setMsgVerbosity(coral.message_Level_Debug)
84  n=0
85  if args.action == 'run':
86  runnumber=0
87  if args.runnumber:
88  runnumber=args.runnumber
89  else:
90  raise 'argument -r is required for action run'
91  if args.debug:
92  print('connectstr : ',connectstr)
93  print('normfactor : ',normfactor)
94  print('authpath : ',os.environ['CORAL_AUTH_PATH'])
95  print('runnumber : ',runnumber)
96  n=calibrateRun(session,normfactor,runnumber)
97  if args.action == 'range':
98  startrun=0
99  endrun=0
100  if args.startrun:
101  startrun=args.startrun
102  else:
103  raise 'argument -startrun is required for action range'
104  if args.endrun:
105  endrun=args.endrun
106  else:
107  raise 'argument -endrun is required for action range'
108  if args.debug:
109  print('connectstr : ',connectstr)
110  print('normfactor : ',normfactor)
111  print('authpath : ',os.environ['CORAL_AUTH_PATH'])
112  print('startrun : ',startrun)
113  print('endrun : ',endrun)
114  n=calibrateRange(session,normfactor,startrun,endrun)
115  print('number of rows changed: ',n)
116  del session
117  del svc
118 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def calibrateRun(dbsession, normfactor, runnum)
def calibrateRange(dbsession, normfactor, startrun, endrun)