11 def mergeDBCfg(flags, InputKeys=[], InputSQLiteFiles=[]):
14 print(
"mergeDBCfg",len(InputSQLiteFiles),
" SQLite files: ",InputSQLiteFiles)
15 print(len(InputKeys),
" InputKeys: ",InputKeys)
18 if not flags.LArCalib.isSC: GroupingType =
"ExtendedSubDetector"
19 else: GroupingType =
"SuperCells"
21 if ( flags.LArCalib.Output.POOLFile ):
22 if os.path.exists(flags.LArCalib.Output.POOLFile):
23 os.remove(flags.LArCalib.Output.POOLFile)
27 print(
"Working for: ",key)
31 if 'Pedestal' == key
or 'PhysWave' == key
or 'CaliWave' or 'MphysOverMcal' == key
or 'Ramp' == key
or 'Params' in key:
36 KeyInput=
'LArAutoCorr'
45 ofcphyskeytmp = key.split(
"OFCPhys")[1]
46 if 'Mu' in ofcphyskeytmp:
47 ofcphyskey=ofcphyskeytmp.replace(
"Mu",
"")
49 ofcphyskey=ofcphyskeytmp
54 shapekey = key.split(
"Shape")[1]
60 if [i
for i
in flags._flagdict.keys()
if FlagInput
in i]:
62 Folder = flags._get(
'LArCalib.'+FlagInput+
'.Folder')
63 except Exception
as e:
65 print(flags._flagdict)
68 print(
'No folder in flags for '+FlagInput)
69 print(flags._flagdict.keys())
72 if shapekey
is not None:
73 if Folder.endswith(
"/"):
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(
"/"):
85 Folder+=
"/"+ofcphyskey
87 if "OFCPhys" in FlagInput:
88 print(
"Folder: ",Folder)
90 from PyCool
import cool
91 dbSvc=cool.DatabaseSvcFactory.databaseService()
94 db=dbSvc.openDatabase(db_string)
95 except Exception
as e:
96 print (
'Problem opening database',e)
99 cool_folder=db.getFolder(Folder)
100 tags = [ x
for x
in cool_folder.listTags() ]
102 TagSpec =
str(tags[0])
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]
107 TagSpec = [
str(tag)
for tag
in tags
if "-mu-" not in str(tag)][0]
109 from LArCalibProcessing.utils
import FolderTagResolver
as FolderTagResover
110 FolderTagResover._globalTag=flags.IOVDb.GlobalTag
114 FolderTag = rs.getFolderTagSuffix(Folder)
117 from LArCalibProcessing.LArCalibConfigFlags
import LArCalibFolderTag
121 if 'Wave' in KeyInput:
122 OutputObjectSpec = KeyInput+
"Container#"+KeyOutput+
"#"+Folder
124 OutputObjectSpec = KeyInput+
"Complete#"+KeyOutput+
"#"+Folder
125 OutputObjectSpecTag = TagSpec
127 print(
"**",KeyInput,FlagInput,
"folder **",Folder)
128 print(
"** TagSpec: ",TagSpec)
129 print(
"** keyOutput: ",KeyOutput)
131 result.addEventAlgo(CompFactory.getComp(
'LArBlockCorrections')())
133 result.addEventAlgo(CompFactory.getComp(
'LArBlockCorrections')())
138 for sqf
in InputSQLiteFiles:
139 thiskey = KeyInput+
str(InputSQLiteFiles.index(sqf))
140 if 'OFC' in key
and 'Mu' in key:
142 if 'OFC' in key
and 'Cali' in key:
144 inkeys.append(thiskey)
145 if 'Wave' in KeyInput:
146 inobjs.append(KeyInput+
"Container#"+thiskey)
148 inobjs.append(KeyInput+
"Complete#"+thiskey)
150 if 'Wave' in KeyInput
or 'Params' in KeyInput:
151 result.merge(
addFolders(flags,Folder,tag=TagSpec,detDb=sqf,modifiers=
"<key>"+thiskey+
"</key>"))
153 result.merge(
addFolders(flags,Folder,tag=TagSpec,detDb=sqf,modifiers=
"<key>"+thiskey+
"</key>", className=KeyInput+
"Complete"))
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))
165 result.addCondAlgo(CompFactory.getComp(
'LArConditionsMergerAlg<'+KeyInput+
'Complete, LArPhysWaveContainer>')(key+
"Merger",
166 GroupingType = GroupingType, WriteKey = KeyOutput, ReadKeys = inkeys))
168 if ( flags.LArCalib.Output.POOLFile ):
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))
176 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
False))
179 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
181 RunNumber = flags.LArCalib.Input.RunNumbers[0],
184 InitialTimeStamp = 0,
185 TimeStampInterval = 1))
187 result.printConfig(withDetails=
True, printDefaults=
True)