3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
5 from LArCalibProcessing.utils
import FolderTagResolver
6 from IOVDbSvc.IOVDbSvcConfig
import addFolders
8 def _OFPhasePickerCfg(flags, inputSuffix="4samples3bins17phases",outputSuffix="4samples1phase",keySuffix="",nColl=0,loadInputs=True, storeShape=True, InputSCOFCPhaseDb = "", SCOFCPhaseTag = "", InputSCOFCWeightDb="", SCOFCWeightTag=""):
11 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
12 if flags.LArCalib.isSC:
13 FolderTagResolver._defaultSuffix=
"-UPD3-00"
14 rs=FolderTagResolver(dbname=
"sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
16 tagstr=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+inputSuffix)
17 tagpref=tagstr[0:tagstr.find(inputSuffix)+len(inputSuffix)]
18 tagpost=tagstr[tagstr.find(inputSuffix)+len(inputSuffix):]
20 if 'mu' not in tagstr:
21 inputOFCTag=f
'{tagpref}-mu-{nc}{tagpost}'
24 tagstr=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+outputSuffix)
25 tagpref=tagstr[0:tagstr.find(outputSuffix)+len(outputSuffix)]
26 tagpost=tagstr[tagstr.find(outputSuffix)+len(outputSuffix):]
27 outputOFCTag=f
'{tagpref}-mu-{nc}{tagpost}'
29 inputOFCTag=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+inputSuffix)
30 outputOFCTag=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+outputSuffix)
32 inputShapeTag=rs.getFolderTag(flags.LArCalib.Shape.Folder+inputSuffix)
33 if flags.LArCalib.OFC.ShapeCorrection:
34 tagstr=rs.getFolderTag(flags.LArCalib.Shape.Folder+outputSuffix)
35 tagpref=tagstr[0:tagstr.find(outputSuffix)+len(outputSuffix)]
36 tagpost=tagstr[tagstr.find(outputSuffix)+len(outputSuffix):]
37 outputShapeTag=f
'{tagpref}-corr{tagpost}'
39 outputShapeTag=rs.getFolderTag(flags.LArCalib.Shape.Folder+outputSuffix)
44 from LArCalibProcessing.LArCalibBaseConfig
import chanSelStr
46 result.merge(
addFolders(flags,flags.LArCalib.OFCPhys.Folder+inputSuffix,detDb=flags.LArCalib.Input.Database,
47 tag=inputOFCTag, modifiers=
chanSelStr(flags)+
"<key>LArOFC"+keySuffix+
"</key>"))
48 result.merge(
addFolders(flags,flags.LArCalib.Shape.Folder+inputSuffix,detDb=flags.LArCalib.Input.Database,
49 tag=inputShapeTag, modifiers=
chanSelStr(flags)+
"<key>LArShape"+keySuffix+
"</key>"))
51 LArOFPhasePick = CompFactory.LArOFPhasePicker(
"LArOFPhasePicker"+keySuffix)
52 if flags.LArCalib.isSC:
53 LArOFPhasePick.KeyPhase =
"LArSCOFCPhase"
55 print(
"InputSCOFCPhaseDb: ",InputSCOFCPhaseDb)
56 result.merge(
addFolders(flags,
"/LAR/ElecCalibOflSC/OFCBin/PhysShift",detDb=InputSCOFCPhaseDb,tag=SCOFCPhaseTag,
57 modifiers=
"<key>LArSCOFCPhase</key>"))
58 if InputSCOFCWeightDb !=
"" and SCOFCWeightTag !=
"":
59 result.merge(
addFolders(flags,
"/LAR/ElecCalibOflSC/OFCFactor",detDb=InputSCOFCWeightDb,tag=SCOFCWeightTag,className=
"CondAttrListCollection"))
60 LArOFCWeightCondAlg=CompFactory.getComp(
"LArFlatConditionsAlg<LArOFCweightSC>")
61 result.addCondAlgo(LArOFCWeightCondAlg(ReadKey=
"/LAR/ElecCalibOflSC/OFCFactor", WriteKey=
"LArOFCbWSC"))
62 LArOFPhasePick.OFCbWeightKey=
"LArOFCbWSC"
65 LArOFPhasePick.KeyPhase =
""
72 LArOFPhasePick.KeyOFC_new =
"LArOFC"+muSuffix
73 LArOFPhasePick.KeyOFC =
"LArOFC"+keySuffix
75 LArOFPhasePick.KeyShape_new =
"LArShape"+
"_uncorr" if flags.LArCalib.OFC.ShapeCorrection
else "LArShape"
76 LArOFPhasePick.KeyShape =
"LArShape"+keySuffix
78 LArOFPhasePick.doShape =
False
79 LArOFPhasePick.GroupingType = flags.LArCalib.GroupingType
80 LArOFPhasePick.DefaultPhase = 4
81 LArOFPhasePick.TimeOffsetCorrection = 12
82 LArOFPhasePick.isSC = flags.LArCalib.isSC
84 LArOFPhasePick.OutputLevel=DEBUG
86 result.addEventAlgo(LArOFPhasePick)
88 if flags.LArCalib.OFC.ShapeCorrection
and storeShape:
89 result.merge(
addFolders(flags,
"/LAR/ElecCalibOfl/Shape/Residuals/5samples",
"LAR_OFL"))
90 resShapeCorr=CompFactory.LArShapeCorrector(
"LArShapeCorr"+keySuffix)
91 resShapeCorr.KeyShape=
"LArShape_uncorr"
92 resShapeCorr.KeyShape_newcorr=
"LArShape"
93 result.addEventAlgo(resShapeCorr)
95 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
96 Obj=[
"LArOFCComplete#LArOFC"+muSuffix+
"#"+flags.LArCalib.OFCPhys.Folder+outputSuffix,]
99 Obj+=[
"LArShapeComplete#LArShape#"+flags.LArCalib.Shape.Folder+outputSuffix,]
100 Tag+=[outputShapeTag,]
103 outputFile=flags.LArCalib.Output.POOLFile,
106 Run1=flags.LArCalib.IOVStart,
107 Run2=flags.LArCalib.IOVEnd
111 rootfile=flags.LArCalib.Output.ROOTFile
113 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
114 OFC2Ntup=CompFactory.LArOFC2Ntuple(
"LArOFC2Ntuple"+muSuffix)
115 OFC2Ntup.ContainerKey =
"LArOFC"+muSuffix
116 OFC2Ntup.NtupleName =
"OFC"+muSuffix
117 OFC2Ntup.AddFEBTempInfo =
False
118 OFC2Ntup.AddCalib =
True
119 OFC2Ntup.isSC = flags.LArCalib.isSC
120 OFC2Ntup.BadChanKey = bcKey
121 result.addEventAlgo(OFC2Ntup)
123 Shape2Ntup=CompFactory.LArShape2Ntuple(
"LArShape2Ntuple")
124 Shape2Ntup.ContainerKey=
"LArShape"
125 Shape2Ntup.NtupleName=
"SHAPE"
126 Shape2Ntup.AddFEBTempInfo =
False
127 Shape2Ntup.AddCalib =
True
128 Shape2Ntup.isSC = flags.LArCalib.isSC
129 Shape2Ntup.BadChanKey = bcKey
130 result.addEventAlgo(Shape2Ntup)
135 def LArOFPhasePickerCfg(flags,loadInputs=True,InputSCOFCPhaseDb = "/afs/cern.ch/user/p/pavol/w0/public/DB_update_22/fillDB/SCOFCPhase.db",SCOFCPhaseTag="LARElecCalibOflSCOFCBinPhysShift-07",InputSCOFCWeightDb="",SCOFCWeightTag=""):
138 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg
141 if flags.LArCalib.isSC:
142 result.merge(
_OFPhasePickerCfg(flags, inputSuffix=
"4samples",outputSuffix=
"4samples1phase",keySuffix=
"_1ns", nColl=0, loadInputs=loadInputs,InputSCOFCPhaseDb=InputSCOFCPhaseDb,SCOFCPhaseTag=SCOFCPhaseTag,InputSCOFCWeightDb=InputSCOFCWeightDb,SCOFCWeightTag=SCOFCWeightTag))
143 if flags.LArCalib.OFC.Ncoll > 0:
144 result.merge(
_OFPhasePickerCfg(flags, inputSuffix=
"4samples",outputSuffix=
"4samples1phase",keySuffix=
"_1ns_mu", nColl=flags.LArCalib.OFC.Ncoll, loadInputs=loadInputs, storeShape=
False,InputSCOFCPhaseDb=InputSCOFCPhaseDb,SCOFCPhaseTag=SCOFCPhaseTag,InputSCOFCWeightDb=InputSCOFCWeightDb,SCOFCWeightTag=SCOFCWeightTag))
146 result.merge(
_OFPhasePickerCfg(flags, inputSuffix=
"4samples3bins17phases",outputSuffix=
"4samples1phase",keySuffix=
"_3ns", nColl=0, loadInputs=loadInputs))
147 if flags.LArCalib.OFC.Ncoll > 0:
148 result.merge(
_OFPhasePickerCfg(flags, inputSuffix=
"4samples3bins17phases",outputSuffix=
"4samples1phase",keySuffix=
"_3ns_mu", nColl=flags.LArCalib.OFC.Ncoll, loadInputs=loadInputs, storeShape=
False))
151 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
False))
152 result.getService(
"IOVDbSvc").DBInstance=
""
155 rootfile=flags.LArCalib.Output.ROOTFile
158 if os.path.exists(rootfile):
160 result.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
161 result.setAppProperty(
"HistogramPersistency",
"ROOT")
166 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
168 RunNumber = flags.LArCalib.Input.RunNumbers[0],
171 InitialTimeStamp = 0,
172 TimeStampInterval = 1))
174 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
184 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg
187 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
188 if flags.LArCalib.isSC:
189 FolderTagResolver._defaultSuffix=
"-UPD3-00"
190 rs=FolderTagResolver(dbname=
"sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
191 inputOFCTag=rs.getFolderTag(flags.LArCalib.OFCCali.Folder)
192 outputOFCTag=rs.getFolderTag(flags.LArCalib.OFCCali.Folder+
"1phase")
195 from LArCalibProcessing.LArCalibBaseConfig
import chanSelStr
197 result.merge(
addFolders(flags,flags.LArCalib.OFCCali.Folder,detDb=flags.LArCalib.Input.Database,
198 tag=inputOFCTag, modifiers=
chanSelStr(flags)))
200 LArOFPhasePick = CompFactory.LArOFPhasePicker(
"LArCaliOFPhasePicker")
201 LArOFPhasePick.KeyPhase =
""
202 LArOFPhasePick.KeyOFC_new =
"LArOFC1phase"
203 LArOFPhasePick.KeyOFC =
"LArOFCCali"
204 LArOFPhasePick.doShape =
False
205 LArOFPhasePick.GroupingType = flags.LArCalib.GroupingType
206 LArOFPhasePick.DefaultPhase = DefaultPhase
207 LArOFPhasePick.isSC = flags.LArCalib.isSC
209 LArOFPhasePick.OutputLevel=DEBUG
211 result.addEventAlgo(LArOFPhasePick)
213 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
214 Obj=[
"LArOFCComplete#LArOFC1phase#"+flags.LArCalib.OFCCali.Folder+
"1phase",]
218 outputFile=flags.LArCalib.Output.POOLFile,
221 Run1=flags.LArCalib.IOVStart,
222 Run2=flags.LArCalib.IOVEnd
225 rootfile=flags.LArCalib.Output.ROOTFile
227 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
228 OFC2Ntup=CompFactory.LArOFC2Ntuple(
"LArCaliOFC2Ntuple")
229 OFC2Ntup.ContainerKey =
"LArOFC1phase"
230 OFC2Ntup.NtupleName =
"OFC1phase"
231 OFC2Ntup.AddFEBTempInfo =
False
232 OFC2Ntup.AddCalib =
True
233 OFC2Ntup.isSC = flags.LArCalib.isSC
234 OFC2Ntup.BadChanKey = bcKey
235 result.addEventAlgo(OFC2Ntup)
237 if os.path.exists(rootfile):
238 print(
"Warning, removing existing file: ",rootfile)
240 result.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
241 result.setAppProperty(
"HistogramPersistency",
"ROOT")
246 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
False))
247 result.getService(
"IOVDbSvc").DBInstance=
""
250 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
252 RunNumber = flags.LArCalib.Input.RunNumbers[0],
255 InitialTimeStamp = 0,
256 TimeStampInterval = 1))
258 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg