11def _ofcAlg(flags,postfix,folderSuffix,nPhases,dPhases,nDelays,nColl):
12 result=ComponentAccumulator()
13 LArPhysOFCAlg = CompFactory.LArOFCAlg("LArOFCPhysAlg_"+postfix)
14 LArPhysOFCAlg.isSC = flags.LArCalib.isSC
15 LArPhysOFCAlg.ReadCaliWave = False
16 LArPhysOFCAlg.KeyList = [ "LArPhysWave" ]
17 LArPhysOFCAlg.Normalize = flags.LArCalib.OFC.Normalize
18 LArPhysOFCAlg.Verify = True
19 LArPhysOFCAlg.GroupingType = flags.LArCalib.GroupingType
20 LArPhysOFCAlg.Nphase = nPhases
21 LArPhysOFCAlg.Dphase = dPhases
22 LArPhysOFCAlg.Ndelay = nDelays
23 LArPhysOFCAlg.Nsample = flags.LArCalib.OFC.Nsamples
24 LArPhysOFCAlg.FillShape = True
25 LArPhysOFCAlg.TimeShift = False
26 LArPhysOFCAlg.AddTimeOffset = -1.0*12.0
27 if not flags.LArCalib.isSC:
28 LArPhysOFCAlg.LArPhysWaveBinKey = "LArPhysWaveShift"
29 LArPhysOFCAlg.UseDelta = flags.LArCalib.OFC.useDelta
30 LArPhysOFCAlg.KeyOFC = "LArOFC_"+postfix
31 LArPhysOFCAlg.KeyShape = "LArShape_"+postfix
32 LArPhysOFCAlg.ComputeOFCPed = flags.LArCalib.OFC.usePed
33
34 if flags.LArCalib.isSC and flags.LArCalib.OFC.usePed:
35 LArPhysOFCAlg.ErrAmplitude = 0.1
36 LArPhysOFCAlg.ErrTime = 1.5
37
38 if flags.LArCalib.OFC.Nsamples==4 and not flags.LArCalib.isSC:
39 LArPhysOFCAlg.ReadDSPConfig = True
40 LArPhysOFCAlg.DSPConfigFolder = "/LAR/Configuration/DSPConfiguration"
41
42
43 LArPhysOFCAlg.DecoderTool = CompFactory.LArAutoCorrDecoderTool(UseAlwaysHighGain=flags.LArCalib.PhysACuseHG,
44 isSC = flags.LArCalib.isSC)
45
46 result.addEventAlgo(LArPhysOFCAlg)
47 if (nColl>0):
48
49 LArPhysOFCAlgMu=deepcopy(LArPhysOFCAlg)
50 LArPhysOFCAlgMu.name=LArPhysOFCAlg.name+"_mu"
51 LArPhysOFCAlgMu.KeyOFC = "LArOFC_"+postfix+"_mu"
52 LArPhysOFCAlg.KeyShape = "LArShape_"+postfix+"_mu"
53 LArPhysOFCAlgMu.DecoderTool = CompFactory.LArAutoCorrDecoderTool(DecodeMode=1,
54 UseAlwaysHighGain=flags.LArCalib.PhysACuseHG,
55 isSC = flags.LArCalib.isSC,
56 KeyAutoCorr="LArPhysAutoCorr")
57 result.addEventAlgo(LArPhysOFCAlgMu)
58
59
60 rootfile=flags.LArCalib.Output.ROOTFile
61 if rootfile != "":
62 bcKey = "LArBadChannelSC" if flags.LArCalib.isSC else "LArBadChannel"
63 OFC2Ntup=CompFactory.LArOFC2Ntuple("LArOFC2Ntuple_"+postfix)
64 OFC2Ntup.ContainerKey = "LArOFC_"+postfix
65 OFC2Ntup.NtupleName = "OFC_"+postfix
66 OFC2Ntup.AddFEBTempInfo = False
67 OFC2Ntup.AddCalib = True
68 OFC2Ntup.isSC = flags.LArCalib.isSC
69 OFC2Ntup.BadChanKey = bcKey
70 result.addEventAlgo(OFC2Ntup)
71
72 if (nColl>0):
73 OFC2NtupMu=CompFactory.LArOFC2Ntuple("LArOFC2Ntuple_"+postfix+"_mu")
74 OFC2NtupMu.ContainerKey = "LArOFC_"+postfix+"_mu"
75 OFC2NtupMu.NtupleName = "OFC_"+postfix+"_mu"
76 OFC2NtupMu.AddFEBTempInfo = False
77 OFC2NtupMu.AddCalib = True
78 OFC2NtupMu.isSC = flags.LArCalib.isSC
79 OFC2NtupMu.BadChanKey = bcKey
80 result.addEventAlgo(OFC2NtupMu)
81
82
83 Shape2Ntup=CompFactory.LArShape2Ntuple("LArShape2Ntuple_"+postfix)
84 Shape2Ntup.ContainerKey="LArShape_"+postfix
85 Shape2Ntup.NtupleName="SHAPE_"+postfix
86 Shape2Ntup.AddFEBTempInfo = False
87 Shape2Ntup.AddCalib = True
88 Shape2Ntup.isSC = flags.LArCalib.isSC
89 Shape2Ntup.BadChanKey = bcKey
90 result.addEventAlgo(Shape2Ntup)
91
92
93 objList=["LArOFCComplete#LArOFC_"+postfix+"#"+flags.LArCalib.OFCPhys.Folder+folderSuffix,
94 "LArShapeComplete#LArShape_"+postfix+"#"+flags.LArCalib.Shape.Folder+folderSuffix]
95
96 if flags.LArCalib.isSC:
97 FolderTagResolver._defaultSuffix="-UPD3-00"
98 rs=FolderTagResolver(dbname="sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
99 OFCTag=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+folderSuffix)
100 ShapeTag=rs.getFolderTag(flags.LArCalib.Shape.Folder+folderSuffix)
101 tagList=[OFCTag,ShapeTag]
102
103 if nColl > 0:
104 objList+=["LArOFCComplete#LArOFC_"+postfix+"_mu#"+flags.LArCalib.OFCPhys.Folder+folderSuffix]
105 tagstr=rs.getFolderTag(flags.LArCalib.OFCPhys.Folder+folderSuffix)
106 tagpref=tagstr[0:tagstr.find(folderSuffix)+len(folderSuffix)]
107 tagpost=tagstr[tagstr.find(folderSuffix)+len(folderSuffix):]
108 nc=int(nColl)
109 OFCTagmu=f'{tagpref}-mu-{nc}{tagpost}'
110 tagList.append(OFCTagmu)
111 del rs
112
113 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
114 result.merge(OutputConditionsAlgCfg(flags,name="OutCondAlg",
115 outputFile=flags.LArCalib.Output.POOLFile,
116 ObjectList=objList,
117 IOVTagList=tagList,
118 Run1=flags.LArCalib.IOVStart,
119 Run2=flags.LArCalib.IOVEnd
120 ))
121
122 return result
123
124