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 'MphysOverMcal' == key
or 'Ramp' == key
or 'Params' in key:
33 if 'Pedestal' == key
or 'PhysWave' == key
or 'CaliWave' or 'MphysOverMcal' == key
or 'Ramp' == key
or 'Params' in key:
38 KeyInput=
'LArAutoCorr'
47 ofcphyskeytmp = key.split(
"OFCPhys")[1]
48 if 'Mu' in ofcphyskeytmp:
49 ofcphyskey=ofcphyskeytmp.replace(
"Mu",
"")
51 ofcphyskey=ofcphyskeytmp
56 shapekey = key.split(
"Shape")[1]
62 if [i
for i
in flags._flagdict.keys()
if FlagInput
in i]:
64 Folder = flags._get(
'LArCalib.'+FlagInput+
'.Folder')
65 except Exception
as e:
67 print(flags._flagdict)
70 print(
'No folder in flags for '+FlagInput)
71 print(flags._flagdict.keys())
74 if shapekey
is not None:
75 if Folder.endswith(
"/"):
80 if ofcphyskey
is not None and ofcphyskey !=
"":
81 print(
"Folder: ",Folder,
" ofcphyskey: ",ofcphyskey)
82 if "4samples" in Folder:
83 Folder = Folder.replace(
"4samples", ofcphyskey)
84 elif Folder.endswith(
"/"):
87 Folder+=
"/"+ofcphyskey
89 if "OFCPhys" in FlagInput:
90 print(
"Folder: ",Folder)
92 from PyCool
import cool
93 dbSvc=cool.DatabaseSvcFactory.databaseService()
96 db=dbSvc.openDatabase(db_string)
97 except Exception
as e:
98 print (
'Problem opening database',e)
101 cool_folder=db.getFolder(Folder)
102 tags = [ x
for x
in cool_folder.listTags() ]
104 TagSpec =
str(tags[0])
106 if flags.LArCalib.OFC.Ncoll > 0
or 'Mu' in key:
107 TagSpec = [
str(tag)
for tag
in tags
if "-mu-" in str(tag)][0]
109 TagSpec = [
str(tag)
for tag
in tags
if "-mu-" not in str(tag)][0]
111 from LArCalibProcessing.utils
import FolderTagResolver
as FolderTagResover
112 FolderTagResover._globalTag=flags.IOVDb.GlobalTag
116 FolderTag = rs.getFolderTagSuffix(Folder)
119 from LArCalibProcessing.LArCalibConfigFlags
import LArCalibFolderTag
123 if 'Wave' in KeyInput:
124 OutputObjectSpec = KeyInput+
"Container#"+KeyOutput+
"#"+Folder
126 OutputObjectSpec = KeyInput+
"Complete#"+KeyOutput+
"#"+Folder
127 OutputObjectSpecTag = TagSpec
129 print(
"**",KeyInput,FlagInput,
"folder **",Folder)
130 print(
"** TagSpec: ",TagSpec)
131 print(
"** keyOutput: ",KeyOutput)
137 for sqf
in InputSQLiteFiles:
138 thiskey = KeyInput+
str(InputSQLiteFiles.index(sqf))
140 if 'PhysAutoCorr' in key: thiskey=
'Phys'+thiskey
142 if 'OFC' in key
and 'Mu' in key:
144 if 'OFC' in key
and 'Cali' in key:
147 inkeys.append(thiskey)
148 if 'Wave' in KeyInput:
149 inobjs.append(KeyInput+
"Container#"+thiskey)
151 inobjs.append(KeyInput+
"Complete#"+thiskey)
153 if 'Wave' in KeyInput
or 'Params' in KeyInput:
154 result.merge(
addFolders(flags,Folder,tag=TagSpec,detDb=sqf,modifiers=
"<key>"+thiskey+
"</key>"))
156 result.merge(
addFolders(flags,Folder,tag=TagSpec,detDb=sqf,modifiers=
"<key>"+thiskey+
"</key>", className=KeyInput+
"Complete"))
161 if 'Wave' in KeyInput:
162 result.addCondAlgo(CompFactory.getComp(
'ForceLoadCondObj')(KeyOutput,ObjectList=inobjs))
163 result.addCondAlgo(CompFactory.getComp(
'LArConditionsMergerAlg<LArDAC2uAComplete,'+KeyInput+
'Container>')(key+
"Merger",
164 GroupingType = GroupingType, WriteKey = KeyOutput, DetStoreReadKeys = inkeys))
165 elif 'Params' in KeyInput:
166 result.addCondAlgo(CompFactory.getComp(
'ForceLoadCondObj')(KeyOutput,ObjectList=inobjs))
167 result.addCondAlgo(CompFactory.getComp(
'LArConditionsMergerAlg<LArDAC2uAComplete,'+KeyInput+
'Complete>')(key+
"Merger",
168 GroupingType = GroupingType, WriteKey = KeyOutput, DetStoreReadKeys = inkeys))
170 result.addCondAlgo(CompFactory.getComp(
'LArConditionsMergerAlg<'+KeyInput+
'Complete, LArPhysWaveContainer>')(key+
"Merger",
171 GroupingType = GroupingType, WriteKey = KeyOutput, ReadKeys = inkeys))
173 if ( flags.LArCalib.Output.POOLFile ):
175 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
176 result.merge(
OutputConditionsAlgCfg(flags,name=
"OutputConditionsAlg"+KeyInput, outputFile=flags.LArCalib.Output.POOLFile,
177 ObjectList=[OutputObjectSpec], IOVTagList=[OutputObjectSpecTag],
178 Run1 = flags.LArCalib.IOVStart, Run2= flags.LArCalib.IOVEnd, WriteIOV=
True))
181 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
True))
184 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
186 RunNumber = flags.LArCalib.Input.RunNumbers[0],
189 InitialTimeStamp = 0,
190 TimeStampInterval = 1))
192 result.printConfig(withDetails=
True, printDefaults=
True)