3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
5 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
6 from LArCalibProcessing.utils
import FolderTagResolver
7 from IOVDbSvc.IOVDbSvcConfig
import addFolders
8 from copy
import deepcopy
10 def _ofcAlg(flags,postfix,folderSuffix,nPhases,dPhases,nDelays,nColl):
12 LArPhysOFCAlg = CompFactory.LArOFCAlg(
"LArOFCPhysAlg_"+postfix)
13 LArPhysOFCAlg.isSC = flags.LArCalib.isSC
14 LArPhysOFCAlg.ReadCaliWave =
False
15 LArPhysOFCAlg.KeyList = [
"LArPhysWave" ]
16 LArPhysOFCAlg.Normalize = flags.LArCalib.OFC.Normalize
17 LArPhysOFCAlg.Verify =
True
18 LArPhysOFCAlg.GroupingType = flags.LArCalib.GroupingType
19 LArPhysOFCAlg.Nphase = nPhases
20 LArPhysOFCAlg.Dphase = dPhases
21 LArPhysOFCAlg.Ndelay = nDelays
22 LArPhysOFCAlg.Nsample = flags.LArCalib.OFC.Nsamples
23 LArPhysOFCAlg.FillShape =
True
24 LArPhysOFCAlg.TimeShift =
False
25 LArPhysOFCAlg.AddTimeOffset = -1.0*12.0
26 if not flags.LArCalib.isSC:
27 LArPhysOFCAlg.LArPhysWaveBinKey =
"LArPhysWaveShift"
28 LArPhysOFCAlg.UseDelta = flags.LArCalib.OFC.useDelta
29 LArPhysOFCAlg.KeyOFC =
"LArOFC_"+postfix
30 LArPhysOFCAlg.KeyShape =
"LArShape_"+postfix
31 LArPhysOFCAlg.ComputeOFCPed = flags.LArCalib.OFC.usePed
33 if flags.LArCalib.isSC
and flags.LArCalib.OFC.usePed:
34 LArPhysOFCAlg.ErrAmplitude = 0.1
35 LArPhysOFCAlg.ErrTime = 1.5
37 if flags.LArCalib.OFC.Nsamples==4
and not flags.LArCalib.isSC:
38 LArPhysOFCAlg.ReadDSPConfig =
True
39 LArPhysOFCAlg.DSPConfigFolder =
"/LAR/Configuration/DSPConfiguration"
42 LArPhysOFCAlg.DecoderTool = CompFactory.LArAutoCorrDecoderTool(UseAlwaysHighGain=flags.LArCalib.PhysACuseHG,
43 isSC = flags.LArCalib.isSC)
45 result.addEventAlgo(LArPhysOFCAlg)
48 LArPhysOFCAlgMu=deepcopy(LArPhysOFCAlg)
49 LArPhysOFCAlgMu.name=LArPhysOFCAlg.name+
"_mu"
50 LArPhysOFCAlgMu.KeyOFC =
"LArOFC_"+postfix+
"_mu"
51 LArPhysOFCAlg.KeyShape =
"LArShape_"+postfix+
"_mu"
52 LArPhysOFCAlgMu.DecoderTool = CompFactory.LArAutoCorrDecoderTool(DecodeMode=1,
53 UseAlwaysHighGain=flags.LArCalib.PhysACuseHG,
54 isSC = flags.LArCalib.isSC,
55 KeyAutoCorr=
"LArPhysAutoCorr")
56 result.addEventAlgo(LArPhysOFCAlgMu)
59 rootfile=flags.LArCalib.Output.ROOTFile
61 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
62 OFC2Ntup=CompFactory.LArOFC2Ntuple(
"LArOFC2Ntuple_"+postfix)
63 OFC2Ntup.ContainerKey =
"LArOFC_"+postfix
64 OFC2Ntup.NtupleName =
"OFC_"+postfix
65 OFC2Ntup.AddFEBTempInfo =
False
66 OFC2Ntup.AddCalib =
True
67 OFC2Ntup.isSC = flags.LArCalib.isSC
68 OFC2Ntup.BadChanKey = bcKey
69 result.addEventAlgo(OFC2Ntup)
72 OFC2NtupMu=CompFactory.LArOFC2Ntuple(
"LArOFC2Ntuple_"+postfix+
"_mu")
73 OFC2NtupMu.ContainerKey =
"LArOFC_"+postfix+
"_mu"
74 OFC2NtupMu.NtupleName =
"OFC_"+postfix+
"_mu"
75 OFC2NtupMu.AddFEBTempInfo =
False
76 OFC2NtupMu.AddCalib =
True
77 OFC2NtupMu.isSC = flags.LArCalib.isSC
78 OFC2NtupMu.BadChanKey = bcKey
79 result.addEventAlgo(OFC2NtupMu)
82 Shape2Ntup=CompFactory.LArShape2Ntuple(
"LArShape2Ntuple_"+postfix)
83 Shape2Ntup.ContainerKey=
"LArShape_"+postfix
84 Shape2Ntup.NtupleName=
"SHAPE_"+postfix
85 Shape2Ntup.AddFEBTempInfo =
False
86 Shape2Ntup.AddCalib =
True
87 Shape2Ntup.isSC = flags.LArCalib.isSC
88 Shape2Ntup.BadChanKey = bcKey
89 result.addEventAlgo(Shape2Ntup)
92 objList=[
"LArOFCComplete#LArOFC_"+postfix+
"#"+flags.LArCalib.OFCPhys.Folder+folderSuffix,
93 "LArShapeComplete#LArShape_"+postfix+
"#"+flags.LArCalib.Shape.Folder+folderSuffix]
95 if flags.LArCalib.isSC:
96 FolderTagResolver._defaultSuffix=
"-UPD3-00"
97 rs=FolderTagResolver(dbname=
"sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
98 OFCTag=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+folderSuffix)
99 ShapeTag=rs.getFolderTag(flags.LArCalib.Shape.Folder+folderSuffix)
100 tagList=[OFCTag,ShapeTag]
103 objList+=[
"LArOFCComplete#LArOFC_"+postfix+
"_mu#"+flags.LArCalib.OFCPhys.Folder+folderSuffix]
104 tagstr=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+folderSuffix)
105 tagpref=tagstr[0:tagstr.find(folderSuffix)+len(folderSuffix)]
106 tagpost=tagstr[tagstr.find(folderSuffix)+len(folderSuffix):]
108 OFCTagmu=f
'{tagpref}-mu-{nc}{tagpost}'
109 tagList.append(OFCTagmu)
112 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
114 outputFile=flags.LArCalib.Output.POOLFile,
117 Run1=flags.LArCalib.IOVStart,
118 Run2=flags.LArCalib.IOVEnd
127 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg,chanSelStr
130 nColl=flags.LArCalib.OFC.Ncoll
131 from LArCalibProcessing.utils
import FolderTagResolver
132 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
133 if flags.LArCalib.isSC:
134 FolderTagResolver._defaultSuffix=
"-UPD3-00"
135 rs=FolderTagResolver(dbname=
"sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
136 PhysWaveTag=rs.getFolderTag(flags.LArCalib.PhysWave.Folder)
137 AutoCorrTag=rs.getFolderTag(flags.LArCalib.AutoCorr.Folder)
138 PhysAutoCorrTag= rs.getFolderTag(flags.LArCalib.PhysAutoCorr.Folder)
139 if (nColl>0
and "mu" not in PhysAutoCorrTag):
141 elems=PhysAutoCorrTag.split(
"-")
142 PhysAutoCorrTag=
"-".
join([elems[0]+
"_mu_%i"%nColl,]+elems[1:])
145 PhysCaliTdiffTag=rs.getFolderTag(flags.LArCalib.PhysCaliTdiff.Folder)
148 result.merge(
addFolders(flags,flags.LArCalib.PhysWave.Folder,detDb=flags.LArCalib.Input.Database, tag=PhysWaveTag, modifiers=
chanSelStr(flags)))
149 result.merge(
addFolders(flags,flags.LArCalib.AutoCorr.Folder,detDb=flags.LArCalib.Input.Database, tag=AutoCorrTag, modifiers=
chanSelStr(flags)))
151 result.merge(
addFolders(flags,flags.LArCalib.PhysAutoCorr.Folder,detDb=flags.LArCalib.Input.Database, tag=PhysAutoCorrTag,modifiers=
chanSelStr(flags)))
155 result.merge(
addFolders(flags,
"/LAR/ElecCalibOfl/OFCBin/PhysWaveShifts",
"LAR_OFL",tag=
"LARElecCalibOflOFCBinPhysWaveShifts-UPD3-00"))
156 result.merge(
addFolders(flags,
"/LAR/Configuration/DSPConfiguration",
"LAR_ONL"))
158 if (flags.LArCalib.OFC.UsePhysCalibTDiff):
159 result.merge(
addFolders(flags,flags.LArCalib.PhysCaliTdiff.Folder,detDb=
"LAR_OFL", db=
"COMP200", tag=PhysCaliTdiffTag))
162 if flags.LArCalib.isSC:
163 result.merge(
_ofcAlg(flags,
"1ns",
"%isamples"%(flags.LArCalib.OFC.Nsamples),nPhases=50,dPhases=1,nDelays=24,nColl=nColl))
165 result.merge(
_ofcAlg(flags,
"3ns",
"%isamples3bins17phases"%flags.LArCalib.OFC.Nsamples,nPhases=8,dPhases=3,nDelays=24,nColl=nColl))
168 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
False))
169 result.getService(
"IOVDbSvc").DBInstance=
""
172 rootfile=flags.LArCalib.Output.ROOTFile
175 if os.path.exists(rootfile):
177 result.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
178 result.setAppProperty(
"HistogramPersistency",
"ROOT")
183 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
185 RunNumber = flags.LArCalib.Input.RunNumbers[0],
188 InitialTimeStamp = 0,
189 TimeStampInterval = 1))
191 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
198 if __name__ ==
"__main__":
201 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
203 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
206 ConfigFlags.Input.Files=[]
207 ConfigFlags.LArCalib.Input.RunNumbers=[500000]
208 ConfigFlags.LArCalib.Input.Database=
"/home/wlampl/calibTest/00403758_00403761_00403762_EndCap-EMB-EMEC_HIGH_40_21.0.20_1/poolFiles/myDB200_00403758_00403761_00403762_EB-EMECC_one.db"
209 ConfigFlags.LArCalib.Input.SubDet=
"EM"
210 ConfigFlags.LArCalib.BadChannelDB=
"/home/wlampl/calibTest/00403758_00403761_00403762_EndCap-EMB-EMEC_HIGH_40_21.0.20_1/poolFiles/SnapshotBadChannel_00403758_00403761_00403762_EB-EMECC.db"
211 ConfigFlags.LArCalib.OFC.Ncoll=20
212 ConfigFlags.LArCalib.BadChannelTag=
"-RUN2-UPD3-00"
213 ConfigFlags.LArCalib.Output.ROOTFile=
"larofc.root"
214 ConfigFlags.IOVDb.DatabaseInstance=
"CONDBR2"
215 ConfigFlags.IOVDb.DBConnection=
"sqlite://;schema=output.sqlite;dbname=CONDBR2"
216 ConfigFlags.IOVDb.GlobalTag=
"LARCALIB-RUN2-02"
217 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
218 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
219 ConfigFlags.IOVDb.DatabaseInstance=
"CONDBR2"
220 ConfigFlags.LAr.doAlign=
False
221 ConfigFlags.Input.RunNumbers=ConfigFlags.LArCalib.Input.RunNumbers
223 ConfigFlags.fillFromArgs()
228 print(cfg.getService(
"IOVDbSvc").Folders)
229 print(
"Start running...")
230 sys.exit(cfg.run(1).isFailure())