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
32 if flags.LArCalib.OFC.Nsamples==4
and not flags.LArCalib.isSC:
33 LArPhysOFCAlg.ReadDSPConfig =
True
34 LArPhysOFCAlg.DSPConfigFolder =
"/LAR/Configuration/DSPConfiguration"
37 LArPhysOFCAlg.DecoderTool = CompFactory.LArAutoCorrDecoderTool(UseAlwaysHighGain=flags.LArCalib.PhysACuseHG,
38 isSC = flags.LArCalib.isSC)
40 result.addEventAlgo(LArPhysOFCAlg)
43 LArPhysOFCAlgMu=deepcopy(LArPhysOFCAlg)
44 LArPhysOFCAlgMu.name=LArPhysOFCAlg.name+
"_mu"
45 LArPhysOFCAlgMu.KeyOFC =
"LArOFC_"+postfix+
"_mu"
46 LArPhysOFCAlg.KeyShape =
"LArShape_"+postfix+
"_mu"
47 LArPhysOFCAlgMu.DecoderTool = CompFactory.LArAutoCorrDecoderTool(DecodeMode=1,
48 UseAlwaysHighGain=flags.LArCalib.PhysACuseHG,
49 isSC = flags.LArCalib.isSC,
50 KeyAutoCorr=
"LArPhysAutoCorr")
51 result.addEventAlgo(LArPhysOFCAlgMu)
54 rootfile=flags.LArCalib.Output.ROOTFile
56 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
57 OFC2Ntup=CompFactory.LArOFC2Ntuple(
"LArOFC2Ntuple_"+postfix)
58 OFC2Ntup.ContainerKey =
"LArOFC_"+postfix
59 OFC2Ntup.NtupleName =
"OFC_"+postfix
60 OFC2Ntup.AddFEBTempInfo =
False
61 OFC2Ntup.AddCalib =
True
62 OFC2Ntup.isSC = flags.LArCalib.isSC
63 OFC2Ntup.BadChanKey = bcKey
64 result.addEventAlgo(OFC2Ntup)
67 OFC2NtupMu=CompFactory.LArOFC2Ntuple(
"LArOFC2Ntuple_"+postfix+
"_mu")
68 OFC2NtupMu.ContainerKey =
"LArOFC_"+postfix+
"_mu"
69 OFC2NtupMu.NtupleName =
"OFC_"+postfix+
"_mu"
70 OFC2NtupMu.AddFEBTempInfo =
False
71 OFC2NtupMu.AddCalib =
True
72 OFC2NtupMu.isSC = flags.LArCalib.isSC
73 OFC2NtupMu.BadChanKey = bcKey
74 result.addEventAlgo(OFC2NtupMu)
77 Shape2Ntup=CompFactory.LArShape2Ntuple(
"LArShape2Ntuple_"+postfix)
78 Shape2Ntup.ContainerKey=
"LArShape_"+postfix
79 Shape2Ntup.NtupleName=
"SHAPE_"+postfix
80 Shape2Ntup.AddFEBTempInfo =
False
81 Shape2Ntup.AddCalib =
True
82 Shape2Ntup.isSC = flags.LArCalib.isSC
83 Shape2Ntup.BadChanKey = bcKey
84 result.addEventAlgo(Shape2Ntup)
87 objList=[
"LArOFCComplete#LArOFC_"+postfix+
"#"+flags.LArCalib.OFCPhys.Folder+folderSuffix,
88 "LArShapeComplete#LArShape_"+postfix+
"#"+flags.LArCalib.Shape.Folder+folderSuffix]
90 if flags.LArCalib.isSC:
91 FolderTagResolver._defaultSuffix=
"-UPD3-00"
92 rs=FolderTagResolver(dbname=
"sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
93 OFCTag=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+folderSuffix)
94 ShapeTag=rs.getFolderTag(flags.LArCalib.Shape.Folder+folderSuffix)
95 tagList=[OFCTag,ShapeTag]
98 objList+=[
"LArOFCComplete#LArOFC_"+postfix+
"_mu#"+flags.LArCalib.OFCPhys.Folder+folderSuffix]
99 tagstr=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+folderSuffix)
100 tagpref=tagstr[0:tagstr.find(folderSuffix)+len(folderSuffix)]
101 tagpost=tagstr[tagstr.find(folderSuffix)+len(folderSuffix):]
103 OFCTagmu=f
'{tagpref}-mu-{nc}{tagpost}'
104 tagList.append(OFCTagmu)
107 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
109 outputFile=flags.LArCalib.Output.POOLFile,
112 Run1=flags.LArCalib.IOVStart,
113 Run2=flags.LArCalib.IOVEnd
122 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg,chanSelStr
125 nColl=flags.LArCalib.OFC.Ncoll
126 from LArCalibProcessing.utils
import FolderTagResolver
127 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
128 if flags.LArCalib.isSC:
129 FolderTagResolver._defaultSuffix=
"-UPD3-00"
130 rs=FolderTagResolver(dbname=
"sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
131 PhysWaveTag=rs.getFolderTag(flags.LArCalib.PhysWave.Folder)
132 AutoCorrTag=rs.getFolderTag(flags.LArCalib.AutoCorr.Folder)
133 PhysAutoCorrTag= rs.getFolderTag(flags.LArCalib.PhysAutoCorr.Folder)
134 if (nColl>0
and "mu" not in PhysAutoCorrTag):
136 elems=PhysAutoCorrTag.split(
"-")
137 PhysAutoCorrTag=
"-".
join([elems[0]+
"_mu_%i"%nColl,]+elems[1:])
140 PhysCaliTdiffTag=rs.getFolderTag(flags.LArCalib.PhysCaliTdiff.Folder)
143 result.merge(
addFolders(flags,flags.LArCalib.PhysWave.Folder,detDb=flags.LArCalib.Input.Database, tag=PhysWaveTag, modifiers=
chanSelStr(flags)))
144 result.merge(
addFolders(flags,flags.LArCalib.AutoCorr.Folder,detDb=flags.LArCalib.Input.Database, tag=AutoCorrTag, modifiers=
chanSelStr(flags)))
146 result.merge(
addFolders(flags,flags.LArCalib.PhysAutoCorr.Folder,detDb=flags.LArCalib.Input.Database, tag=PhysAutoCorrTag,modifiers=
chanSelStr(flags)))
150 result.merge(
addFolders(flags,
"/LAR/ElecCalibOfl/OFCBin/PhysWaveShifts",
"LAR_OFL",tag=
"LARElecCalibOflOFCBinPhysWaveShifts-UPD3-00"))
151 result.merge(
addFolders(flags,
"/LAR/Configuration/DSPConfiguration",
"LAR_ONL"))
153 if (flags.LArCalib.OFC.UsePhysCalibTDiff):
154 result.merge(
addFolders(flags,flags.LArCalib.PhysCaliTdiff.Folder,detDb=
"LAR_OFL", db=
"COMP200", tag=PhysCaliTdiffTag))
157 if flags.LArCalib.isSC:
158 result.merge(
_ofcAlg(flags,
"1ns",
"%isamples"%(flags.LArCalib.OFC.Nsamples),nPhases=50,dPhases=1,nDelays=24,nColl=nColl))
160 result.merge(
_ofcAlg(flags,
"3ns",
"%isamples3bins17phases"%flags.LArCalib.OFC.Nsamples,nPhases=8,dPhases=3,nDelays=24,nColl=nColl))
163 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
False))
164 result.getService(
"IOVDbSvc").DBInstance=
""
167 rootfile=flags.LArCalib.Output.ROOTFile
170 if os.path.exists(rootfile):
172 result.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
173 result.setAppProperty(
"HistogramPersistency",
"ROOT")
178 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
180 RunNumber = flags.LArCalib.Input.RunNumbers[0],
183 InitialTimeStamp = 0,
184 TimeStampInterval = 1))
186 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
193 if __name__ ==
"__main__":
196 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
198 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
201 ConfigFlags.Input.Files=[]
202 ConfigFlags.LArCalib.Input.RunNumbers=[500000]
203 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"
204 ConfigFlags.LArCalib.Input.SubDet=
"EM"
205 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"
206 ConfigFlags.LArCalib.OFC.Ncoll=20
207 ConfigFlags.LArCalib.BadChannelTag=
"-RUN2-UPD3-00"
208 ConfigFlags.LArCalib.Output.ROOTFile=
"larofc.root"
209 ConfigFlags.IOVDb.DatabaseInstance=
"CONDBR2"
210 ConfigFlags.IOVDb.DBConnection=
"sqlite://;schema=output.sqlite;dbname=CONDBR2"
211 ConfigFlags.IOVDb.GlobalTag=
"LARCALIB-RUN2-02"
212 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
213 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
214 ConfigFlags.IOVDb.DatabaseInstance=
"CONDBR2"
215 ConfigFlags.LAr.doAlign=
False
216 ConfigFlags.Input.RunNumbers=ConfigFlags.LArCalib.Input.RunNumbers
218 ConfigFlags.fillFromArgs()
223 print(cfg.getService(
"IOVDbSvc").Folders)
224 print(
"Start running...")
225 sys.exit(cfg.run(1).isFailure())