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