ATLAS Offline Software
Functions | Variables
python.LArNewCalib_MergeDB Namespace Reference

Functions

def DBConnectionFile (sqlitefile)
 
def mergeDBCfg (flags, InputKeys=[], InputSQLiteFiles=[])
 
def list_of_strings (arg)
 

Variables

 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
 
 dest
 
 default
 
 help
 
 type
 
 False
 
 action
 
 args = parser.parse_args()
 
list InputSQLiteFiles = [ db for db in os.listdir(".") if db.endswith(".db") ]
 
 flags = initConfigFlags()
 
 RunNumbers
 
 Database
 
 Database2
 
 POOLFile
 
 DBConnection
 
 GlobalTag
 
 Files
 
 Ncoll
 
 IOVStart
 
 doAlign
 
 AtlasVersion
 
 DumpDetStore
 
 DumpCondStore
 
 cfg = MainServicesCfg(flags)
 
 WriteCatalog
 
 DBInstance
 
 withDetails
 
 True
 
 summariseProps
 
 printDefaults
 

Function Documentation

◆ DBConnectionFile()

def python.LArNewCalib_MergeDB.DBConnectionFile (   sqlitefile)

Definition at line 8 of file LArNewCalib_MergeDB.py.

8 def DBConnectionFile(sqlitefile):
9  return "sqlite://;schema="+sqlitefile+";dbname=CONDBR2"
10 

◆ list_of_strings()

def python.LArNewCalib_MergeDB.list_of_strings (   arg)

Definition at line 194 of file LArNewCalib_MergeDB.py.

194  def list_of_strings(arg):
195  return arg.split(',')
196 

◆ mergeDBCfg()

def python.LArNewCalib_MergeDB.mergeDBCfg (   flags,
  InputKeys = [],
  InputSQLiteFiles = [] 
)

Definition at line 11 of file LArNewCalib_MergeDB.py.

11 def mergeDBCfg(flags, InputKeys=[], InputSQLiteFiles=[]):
12  result=ComponentAccumulator()
13 
14  print("mergeDBCfg",len(InputSQLiteFiles)," SQLite files: ",InputSQLiteFiles)
15  print(len(InputKeys)," InputKeys: ",InputKeys)
16 
17 
18  if not flags.LArCalib.isSC: GroupingType = "ExtendedSubDetector"
19  else: GroupingType = "SuperCells"
20 
21  if ( flags.LArCalib.Output.POOLFile ):
22  if os.path.exists(flags.LArCalib.Output.POOLFile):
23  os.remove(flags.LArCalib.Output.POOLFile)
24 
25  for key in InputKeys:
26 
27  print("Working for: ",key)
28  KeyOutput = key
29  FlagInput = key
30 
31  if 'Pedestal' == key or 'PhysWave' == key or 'CaliWave' or 'MphysOverMcal' == key or 'Ramp' == key or 'Params' in key:
32  KeyInput="LAr"+key
33  KeyOutput="LAr"+key
34 
35  if 'AutoCorr' in key:
36  KeyInput='LArAutoCorr'
37 
38  ofcphyskey=None
39  if "OFC" in key:
40  KeyInput = "LArOFC"
41  if "Cali" in key:
42  FlagInput = "OFCCali"
43 
44  if "Phys" in key:
45  ofcphyskeytmp = key.split("OFCPhys")[1]
46  if 'Mu' in ofcphyskeytmp:
47  ofcphyskey=ofcphyskeytmp.replace("Mu","")
48  else:
49  ofcphyskey=ofcphyskeytmp
50  FlagInput = "OFCPhys"
51 
52  shapekey=None
53  if "Shape" in key:
54  shapekey = key.split("Shape")[1]
55  FlagInput = "Shape"
56  KeyInput = "LArShape"
57 
58 
59  #if FlagInput in flags._flagdict.keys():
60  if [i for i in flags._flagdict.keys() if FlagInput in i]:
61  try:
62  Folder = flags._get('LArCalib.'+FlagInput+'.Folder')
63  except Exception as e:
64  print(e)
65  print(flags._flagdict)
66  sys.exit(-1)
67  else:
68  print('No folder in flags for '+FlagInput)
69  print(flags._flagdict.keys())
70  sys.exit(-2)
71 
72  if shapekey is not None:
73  if Folder.endswith("/"):
74  Folder+=shapekey
75  else:
76  Folder+="/"+shapekey
77 
78  if ofcphyskey is not None and ofcphyskey != "":
79  print("Folder: ",Folder," ofcphyskey: ",ofcphyskey)
80  if "4samples" in Folder:
81  Folder = Folder.replace("4samples", ofcphyskey)
82  elif Folder.endswith("/"):
83  Folder+=ofcphyskey
84  else:
85  Folder+="/"+ofcphyskey
86 
87  if "OFCPhys" in FlagInput:
88  print("Folder: ",Folder)
89  # Get the available tags
90  from PyCool import cool
91  dbSvc=cool.DatabaseSvcFactory.databaseService()
92  db_string=DBConnectionFile(InputSQLiteFiles[0])
93  try:
94  db=dbSvc.openDatabase(db_string)
95  except Exception as e:
96  print ('Problem opening database',e)
97  print(db_string)
98  sys.exit(-3)
99  cool_folder=db.getFolder(Folder)
100  tags = [ x for x in cool_folder.listTags() ]
101  if len(tags) == 1:
102  TagSpec = str(tags[0])
103  else:
104  if flags.LArCalib.OFC.Ncoll > 0 or 'Mu' in key:
105  TagSpec = [ str(tag) for tag in tags if "-mu-" in str(tag)][0]
106  else:
107  TagSpec = [ str(tag) for tag in tags if "-mu-" not in str(tag)][0]
108  else:
109  from LArCalibProcessing.utils import FolderTagResolver as FolderTagResover
110  FolderTagResover._globalTag=flags.IOVDb.GlobalTag
111  #rs=FolderTagResover(flags.LArCalib.Input.Database2)
112  # until not all folders in COOL:
113  rs=FolderTagResover(DBConnectionFile(InputSQLiteFiles[0]))
114  FolderTag = rs.getFolderTagSuffix(Folder)
115  del rs
116 
117  from LArCalibProcessing.LArCalibConfigFlags import LArCalibFolderTag
118  TagSpec = LArCalibFolderTag(Folder,FolderTag)
119 
120 
121  if 'Wave' in KeyInput:
122  OutputObjectSpec = KeyInput+"Container#"+KeyOutput+"#"+Folder
123  else:
124  OutputObjectSpec = KeyInput+"Complete#"+KeyOutput+"#"+Folder
125  OutputObjectSpecTag = TagSpec
126 
127  print("**",KeyInput,FlagInput,"folder **",Folder)
128  print("** TagSpec: ",TagSpec)
129  print("** keyOutput: ",KeyOutput)
130 
131  result.addEventAlgo(CompFactory.getComp('LArBlockCorrections')())
132 
133  result.addEventAlgo(CompFactory.getComp('LArBlockCorrections')())
134 
135  inkeys=[]
136  inobjs=[]
137 
138  for sqf in InputSQLiteFiles:
139  thiskey = KeyInput+str(InputSQLiteFiles.index(sqf))
140  if 'OFC' in key and 'Mu' in key:
141  thiskey+="Mu"
142  if 'OFC' in key and 'Cali' in key:
143  thiskey+="Cali"
144  inkeys.append(thiskey)
145  if 'Wave' in KeyInput:
146  inobjs.append(KeyInput+"Container#"+thiskey)
147  else:
148  inobjs.append(KeyInput+"Complete#"+thiskey)
149 
150  if 'Wave' in KeyInput or 'Params' in KeyInput:
151  result.merge(addFolders(flags,Folder,tag=TagSpec,detDb=sqf,modifiers="<key>"+thiskey+"</key>"))
152  else:
153  result.merge(addFolders(flags,Folder,tag=TagSpec,detDb=sqf,modifiers="<key>"+thiskey+"</key>", className=KeyInput+"Complete"))
154 
155 
156  if 'Wave' in KeyInput:
157  result.addCondAlgo(CompFactory.getComp('ForceLoadCondObj')(KeyOutput,ObjectList=inobjs))
158  result.addCondAlgo(CompFactory.getComp('LArConditionsMergerAlg<LArDAC2uAComplete,'+KeyInput+'Container>')(key+"Merger",
159  GroupingType = GroupingType, WriteKey = KeyOutput, DetStoreReadKeys = inkeys))
160  elif 'Params' in KeyInput:
161  result.addCondAlgo(CompFactory.getComp('ForceLoadCondObj')(KeyOutput,ObjectList=inobjs))
162  result.addCondAlgo(CompFactory.getComp('LArConditionsMergerAlg<LArDAC2uAComplete,'+KeyInput+'Complete>')(key+"Merger",
163  GroupingType = GroupingType, WriteKey = KeyOutput, DetStoreReadKeys = inkeys))
164  else:
165  result.addCondAlgo(CompFactory.getComp('LArConditionsMergerAlg<'+KeyInput+'Complete, LArPhysWaveContainer>')(key+"Merger",
166  GroupingType = GroupingType, WriteKey = KeyOutput, ReadKeys = inkeys))
167 
168  if ( flags.LArCalib.Output.POOLFile ):
169 
170  from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
171  result.merge(OutputConditionsAlgCfg(flags,name="OutputConditionsAlg"+KeyInput, outputFile=flags.LArCalib.Output.POOLFile,
172  ObjectList=[OutputObjectSpec], IOVTagList=[OutputObjectSpecTag],
173  Run1 = flags.LArCalib.IOVStart, Run2= flags.LArCalib.IOVEnd, WriteIOV=True))
174  pass
175 
176  result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
177 
178  #MC Event selector since we have no input data file
179  from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
180  result.merge(McEventSelectorCfg(flags,
181  RunNumber = flags.LArCalib.Input.RunNumbers[0],
182  EventsPerRun = 1,
183  FirstEvent = 1,
184  InitialTimeStamp = 0,
185  TimeStampInterval = 1))
186 
187  result.printConfig(withDetails=True, printDefaults=True)
188  return result
189 
190 

Variable Documentation

◆ action

python.LArNewCalib_MergeDB.action

Definition at line 206 of file LArNewCalib_MergeDB.py.

◆ args

python.LArNewCalib_MergeDB.args = parser.parse_args()

Definition at line 209 of file LArNewCalib_MergeDB.py.

◆ AtlasVersion

python.LArNewCalib_MergeDB.AtlasVersion

Definition at line 250 of file LArNewCalib_MergeDB.py.

◆ cfg

python.LArNewCalib_MergeDB.cfg = MainServicesCfg(flags)

Definition at line 259 of file LArNewCalib_MergeDB.py.

◆ Database

python.LArNewCalib_MergeDB.Database

Definition at line 231 of file LArNewCalib_MergeDB.py.

◆ Database2

python.LArNewCalib_MergeDB.Database2

Definition at line 232 of file LArNewCalib_MergeDB.py.

◆ DBConnection

python.LArNewCalib_MergeDB.DBConnection

Definition at line 236 of file LArNewCalib_MergeDB.py.

◆ DBInstance

python.LArNewCalib_MergeDB.DBInstance

Definition at line 271 of file LArNewCalib_MergeDB.py.

◆ default

python.LArNewCalib_MergeDB.default

Definition at line 199 of file LArNewCalib_MergeDB.py.

◆ dest

python.LArNewCalib_MergeDB.dest

Definition at line 199 of file LArNewCalib_MergeDB.py.

◆ doAlign

python.LArNewCalib_MergeDB.doAlign

Definition at line 246 of file LArNewCalib_MergeDB.py.

◆ DumpCondStore

python.LArNewCalib_MergeDB.DumpCondStore

Definition at line 253 of file LArNewCalib_MergeDB.py.

◆ DumpDetStore

python.LArNewCalib_MergeDB.DumpDetStore

Definition at line 252 of file LArNewCalib_MergeDB.py.

◆ False

python.LArNewCalib_MergeDB.False

Definition at line 206 of file LArNewCalib_MergeDB.py.

◆ Files

python.LArNewCalib_MergeDB.Files

Definition at line 241 of file LArNewCalib_MergeDB.py.

◆ flags

python.LArNewCalib_MergeDB.flags = initConfigFlags()

Definition at line 226 of file LArNewCalib_MergeDB.py.

◆ GlobalTag

python.LArNewCalib_MergeDB.GlobalTag

Definition at line 239 of file LArNewCalib_MergeDB.py.

◆ help

python.LArNewCalib_MergeDB.help

Definition at line 199 of file LArNewCalib_MergeDB.py.

◆ InputSQLiteFiles

python.LArNewCalib_MergeDB.InputSQLiteFiles = [ db for db in os.listdir(".") if db.endswith(".db") ]

Definition at line 215 of file LArNewCalib_MergeDB.py.

◆ IOVStart

python.LArNewCalib_MergeDB.IOVStart

Definition at line 244 of file LArNewCalib_MergeDB.py.

◆ Ncoll

python.LArNewCalib_MergeDB.Ncoll

Definition at line 243 of file LArNewCalib_MergeDB.py.

◆ parser

python.LArNewCalib_MergeDB.parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)

Definition at line 198 of file LArNewCalib_MergeDB.py.

◆ POOLFile

python.LArNewCalib_MergeDB.POOLFile

Definition at line 234 of file LArNewCalib_MergeDB.py.

◆ printDefaults

python.LArNewCalib_MergeDB.printDefaults

Definition at line 273 of file LArNewCalib_MergeDB.py.

◆ RunNumbers

python.LArNewCalib_MergeDB.RunNumbers

Definition at line 230 of file LArNewCalib_MergeDB.py.

◆ summariseProps

python.LArNewCalib_MergeDB.summariseProps

Definition at line 273 of file LArNewCalib_MergeDB.py.

◆ True

python.LArNewCalib_MergeDB.True

Definition at line 273 of file LArNewCalib_MergeDB.py.

◆ type

python.LArNewCalib_MergeDB.type

Definition at line 199 of file LArNewCalib_MergeDB.py.

◆ withDetails

python.LArNewCalib_MergeDB.withDetails

Definition at line 273 of file LArNewCalib_MergeDB.py.

◆ WriteCatalog

python.LArNewCalib_MergeDB.WriteCatalog

Definition at line 270 of file LArNewCalib_MergeDB.py.

python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.LArNewCalib_MergeDB.mergeDBCfg
def mergeDBCfg(flags, InputKeys=[], InputSQLiteFiles=[])
Definition: LArNewCalib_MergeDB.py:11
OutputConditionsAlgConfig.OutputConditionsAlgCfg
def OutputConditionsAlgCfg(flags, name="OutputConditionsAlg", outputFile='condobjs.root', **kwargs)
Definition: OutputConditionsAlgConfig.py:5
python.McEventSelectorConfig.McEventSelectorCfg
def McEventSelectorCfg(flags, **kwargs)
Definition: McEventSelectorConfig.py:5
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
python.LArNewCalib_MergeDB.DBConnectionFile
def DBConnectionFile(sqlitefile)
Definition: LArNewCalib_MergeDB.py:8
python.LArCalibConfigFlags.LArCalibFolderTag
def LArCalibFolderTag(folder, tag)
Definition: LArCalibConfigFlags.py:96
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11
python.LArNewCalib_MergeDB.list_of_strings
def list_of_strings(arg)
Definition: LArNewCalib_MergeDB.py:194