ATLAS Offline Software
fillPileUpNoiseLumi.py
Go to the documentation of this file.
1 #!/bin/env python
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 
4 from PyCool import cool
5 
6 def createFolder(db,name):
7  desc='<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'
8  spec = cool.RecordSpecification()
9  spec.extend('LBAvInstLumi',cool.StorageType.Float)
10  spec.extend('Valid',cool.StorageType.UInt32)
11  folderSpec=cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
12  #return db.createFolder(name,spec,desc,cool.FolderVersioning.MULTI_VERSION, True)
13  return db.createFolder(name,folderSpec,desc, True)
14 
15 
16 
17 def fillPileUpNoiseLumi(db,tag,dataIn, folderName="/CALO/Ofl/Noise/PileUpNoiseLumi"):
18 
19  data=0.
20  data=dataIn
21 
22  if db.existsFolder(folderName):
23  folder = db.getFolder(folderName)
24  else:
25  #create new folder
26  print("Folder", folderName,"does not exit yet. Creating it now.")
27  folder=createFolder(db,folderName)
28 
29  since=cool.ValidityKeyMin
30  until=cool.ValidityKeyMax
31 
32  payload = cool.Record(folder.payloadSpecification())
33  payload["LBAvInstLumi"]=data
34  payload["Valid"]=0
35  folder.storeObject(since,until,payload,cool.ChannelId(0),tag)
36  folder.storeObject(since,until,payload,cool.ChannelId(1),tag)
37 
38  return 0
39 
40 
41 if __name__=='__main__':
42  import os,sys
43 
44  if len(sys.argv)<2 or sys.argv[1]=="-h" or sys.argv[1]=="--help":
45  print("Usage:")
46 
47  print("fillPileUpNoiseLumi.py lumi")
48  sys.exit(-1)
49 
50 
51  from LArConditionsCommon.getCurrentFolderTag import getCurrentFolderTag
52  (current,next)=getCurrentFolderTag("COOLOFL_CALO/CONDBR2","/CALO/Ofl/Noise/PileUpNoiseLumi")
53  if current is None:
54  print("Failed to get CURRENT folder level tag!")
55  sys.exit(-1)
56 
57  try:
58  float(sys.argv[1])
59  except ValueError:
60  print("Argument is not a float")
61 
62  newlumi=float(sys.argv[1])
63 
64  sqlitename="PileUpNoiseLumi.db"
65  if os.access(sqlitename,os.F_OK):
66  print("ERROR: File",sqlitename,"exists already. Please delete!")
67  sys.exit(-1)
68 
69  print("Using folder-level tag:",current)
70  connect="sqlite://;schema="+sqlitename+";dbname=CONDBR2"
71  dbSvc = cool.DatabaseSvcFactory.databaseService()
72  try:
73  db = dbSvc.openDatabase(connect,False)
74  except Exception:
75  print("Database does not exist, try to create it ...")
76  try:
77  db=dbSvc.createDatabase(connect)
78  except Exception as e:
79  print(e)
80  print("Could not create database")
81  sys.exit(-1)
82  pass
83  pass
84 
85  data=fillPileUpNoiseLumi(db,current,newlumi)
86  sys.exit(0)
fillPileUpNoiseLumi
Definition: fillPileUpNoiseLumi.py:1
fillPileUpNoiseLumi.fillPileUpNoiseLumi
def fillPileUpNoiseLumi(db, tag, dataIn, folderName="/CALO/Ofl/Noise/PileUpNoiseLumi")
Definition: fillPileUpNoiseLumi.py:17
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.getCurrentFolderTag.getCurrentFolderTag
def getCurrentFolderTag(dbname, folderName, ES=False)
Definition: getCurrentFolderTag.py:11
fillPileUpNoiseLumi.createFolder
def createFolder(db, name)
Definition: fillPileUpNoiseLumi.py:6
readCCLHist.float
float
Definition: readCCLHist.py:83