10def _ofcAlg(flags,postfix,folderSuffix,nPhases,dPhases,nDelays,nColl):
11 result=ComponentAccumulator()
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
32
33 if flags.LArCalib.isSC and flags.LArCalib.OFC.usePed:
34 LArPhysOFCAlg.ErrAmplitude = 0.1
35 LArPhysOFCAlg.ErrTime = 1.5
36
37 if flags.LArCalib.OFC.Nsamples==4 and not flags.LArCalib.isSC:
38 LArPhysOFCAlg.ReadDSPConfig = True
39 LArPhysOFCAlg.DSPConfigFolder = "/LAR/Configuration/DSPConfiguration"
40
41
42 LArPhysOFCAlg.DecoderTool = CompFactory.LArAutoCorrDecoderTool(UseAlwaysHighGain=flags.LArCalib.PhysACuseHG,
43 isSC = flags.LArCalib.isSC)
44
45 result.addEventAlgo(LArPhysOFCAlg)
46 if (nColl>0):
47
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)
57
58
59 rootfile=flags.LArCalib.Output.ROOTFile
60 if 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)
70
71 if (nColl>0):
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)
80
81
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)
90
91
92 objList=["LArOFCComplete#LArOFC_"+postfix+"#"+flags.LArCalib.OFCPhys.Folder+folderSuffix,
93 "LArShapeComplete#LArShape_"+postfix+"#"+flags.LArCalib.Shape.Folder+folderSuffix]
94
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]
101
102 if nColl > 0:
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):]
107 nc=int(nColl)
108 OFCTagmu=f'{tagpref}-mu-{nc}{tagpost}'
109 tagList.append(OFCTagmu)
110 del rs
111
112 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
113 result.merge(OutputConditionsAlgCfg(flags,name="OutCondAlg",
114 outputFile=flags.LArCalib.Output.POOLFile,
115 ObjectList=objList,
116 IOVTagList=tagList,
117 Run1=flags.LArCalib.IOVStart,
118 Run2=flags.LArCalib.IOVEnd
119 ))
120
121 return result
122
123