6def LArRampCfg(flags):
7
8 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg,chanSelStr
9 result=LArCalibBaseCfg(flags)
10
11
12 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
13 result.merge(ByteStreamReadCfg(flags))
14
15
16
17 gainStrMap={0:"HIGH",1:"MEDIUM",2:"LOW"}
18 digKey=gainStrMap[flags.LArCalib.Gain]
19
20 from LArCalibProcessing.utils import FolderTagResolver
21 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
22 tagResolver=FolderTagResolver()
23 pedestalTag=tagResolver.getFolderTag(flags.LArCalib.Pedestal.Folder)
24 caliOFCTag=tagResolver.getFolderTag(flags.LArCalib.OFCCali.Folder)
25
26 rampTag=tagResolver.getFolderTag(flags.LArCalib.Ramp.Folder)
27 del tagResolver
28
29 print(
"pedestalTag",pedestalTag)
30 print(
"rampTag",rampTag)
31
32
33 from IOVDbSvc.IOVDbSvcConfig import addFolders
34 result.merge(addFolders(flags,flags.LArCalib.Pedestal.Folder,detDb=flags.LArCalib.Input.Database, tag=pedestalTag, modifiers=chanSelStr(flags),
35 className="LArPedestalComplete"))
36 result.merge(addFolders(flags,flags.LArCalib.OFCCali.Folder,detDb=flags.LArCalib.Input.Database2, tag=caliOFCTag, modifiers=chanSelStr(flags)))
37
38
39 if not flags.LArCalib.isSC:
40 result.addEventAlgo(CompFactory.LArRawCalibDataReadingAlg(LArAccCalibDigitKey=digKey,
41 LArFebHeaderKey="LArFebHeader",
42 SubCaloPreselection=flags.LArCalib.Input.SubDet,
43 PosNegPreselection=flags.LArCalib.Preselection.Side,
44 BEPreselection=flags.LArCalib.Preselection.BEC,
45 FTNumPreselection=flags.LArCalib.Preselection.FT))
46
47 from LArROD.LArFebErrorSummaryMakerConfig import LArFebErrorSummaryMakerCfg
48 result.merge(LArFebErrorSummaryMakerCfg(flags))
49 result.getEventAlgo("LArFebErrorSummaryMaker").CheckAllFEB=False
50
51 if flags.LArCalib.Input.SubDet == "EM":
52 from LArCalibProcessing.LArStripsXtalkCorrConfig import LArStripsXtalkCorrCfg
53 result.merge(LArStripsXtalkCorrCfg(flags,[digKey,]))
54
55 theLArCalibShortCorrector = CompFactory.LArCalibShortCorrector(KeyList = [digKey,])
56 result.addEventAlgo(theLArCalibShortCorrector)
57 else:
58 digKey="SC"
59 theLArLATOMEDecoder = CompFactory.LArLATOMEDecoder("LArLATOMEDecoder")
60 if flags.LArCalib.Input.isRawData:
61 result.addEventAlgo(CompFactory.LArRawSCDataReadingAlg(adcCollKey = digKey, adcBasCollKey = "", etCollKey = "",
62 etIdCollKey = "", LATOMEDecoder = theLArLATOMEDecoder))
63 from LArCalibProcessing.LArCalib_CalibDigitsMakerConfig import LArCalibDigitsMakerCfg
64 result.merge(LArCalibDigitsMakerCfg(flags,digKey))
65
66 else:
67
68 from LArCabling.LArCablingConfig import LArCalibIdMappingCfg,LArOnOffIdMappingCfg
69 result.merge(LArOnOffIdMappingCfg(flags))
70 result.merge(LArCalibIdMappingCfg(flags))
71
72 result.addEventAlgo(CompFactory.LArRawSCCalibDataReadingAlg(LArSCAccCalibDigitKey = digKey, LATOMEDecoder = theLArLATOMEDecoder))
73
74 pass
75
76
77 bcKey = "LArBadChannelSC" if flags.LArCalib.isSC else "LArBadChannel"
78
79
80 theLArRampBuilder = CompFactory.LArRampBuilder()
81 theLArRampBuilder.KeyList = [digKey,]
82 theLArRampBuilder.SubtractDac0 = False
83 if flags.LArCalib.isSC:
84 theLArRampBuilder.ProblemsToMask=["deadCalib","deadReadout","deadPhys","maskedOSUM","OffOFCs","transmissionErrorFibre",]
85 else:
86 theLArRampBuilder.ProblemsToMask=["deadCalib","deadReadout","deadPhys","almostDead","short"]
87
88 theLArRampBuilder.RecoType = "OF"
89 theLArRampBuilder.PeakOFTool=CompFactory.LArOFPeakRecoTool(UseShape = False,OutputLevel=2)
90
91 theLArRampBuilder.DAC0 = 4294967294
92 theLArRampBuilder.StoreRawRamp = True
93 theLArRampBuilder.StoreRecRamp = True
94 theLArRampBuilder.Polynom = 1
95 theLArRampBuilder.RampRange = 3600
96 theLArRampBuilder.correctBias = False
97
98 theLArRampBuilder.minDAC = 10
99 theLArRampBuilder.KeyOutput = "LArRamp"
100 theLArRampBuilder.DeadChannelCut = -9999
101 theLArRampBuilder.GroupingType = flags.LArCalib.GroupingType
102
103
104 theLArRampBuilder.isSC = flags.LArCalib.isSC
105 theLArRampBuilder.BadChanKey = bcKey
106
107 if "HEC" in flags.LArCalib.Input.SubDet:
108 theLArRampBuilder.isHEC = True
109 theLArRampBuilder.HECKey = "LArHEC_PAmap"
110 result.merge(addFolders(flags,'/LAR/ElecCalibOfl/HecPAMap','LAR_OFL'))
111
112 result.addEventAlgo(theLArRampBuilder)
113
114
115
116 if flags.LArCalib.CorrectBadChannels:
117 LArRampPatcher=CompFactory.getComp("LArCalibPatchingAlg<LArRampComplete>")
119 theLArRampPatcher.ContainerKey="LArRamp"
120 theLArRampPatcher.BadChanKey=bcKey
121 theLArRampPatcher.PatchMethod="PhiAverage"
122 theLArRampPatcher.SuperCells=flags.LArCalib.isSC
123
124 if flags.LArCalib.isSC:
125 theLArRampPatcher.ProblemsToPatch=["deadCalib","deadReadout","deadPhys","maskedOSUM","OffOFCs","transmissionErrorFibre"]
126 theLArRampPatcher.OnOffMap="LArOnOffIdMapSC"
127 theLArRampPatcher.CalibLineKey="LArCalibIdMapSC"
128 else:
129 theLArRampPatcher.ProblemsToPatch=["deadCalib","deadReadout","deadPhys","almostDead","short"]
130 theLArRampPatcher.UseCorrChannels=False
131 result.addEventAlgo(theLArRampPatcher)
132
133
134 if flags.LArCalib.doValidation:
135
136 if flags.LArCalib.isSC:
137 fldr="/LAR/ElecCalibFlatSC/Ramp"
138 rmpFlt=CompFactory.getComp("LArFlatConditionsAlg<LArRampSC>")("RampFltVal")
139 else:
140 fldr="/LAR/ElecCalibFlat/Ramp"
141 rmpFlt=CompFactory.getComp("LArFlatConditionsAlg<LArRampFlat>")("RampFltVal")
142 result.merge(addFolders(flags,fldr,"LAR_ONL"))
143 condLoader=result.getCondAlgo("CondInputLoader")
144 condLoader.Load.add(("CondAttrListCollection",fldr))
145
146 rmpFlt.ReadKey=fldr
147 rmpFlt.WriteKey="LArRampRef"
148 result.addCondAlgo(rmpFlt)
149
150 from LArCalibDataQuality.Thresholds import rampThr, rampThrFEB
152
153 theRampValidationAlg=CompFactory.LArRampValidationAlg("RampVal")
154 theRampValidationAlg.RampTolerance=rampThr
155 theRampValidationAlg.RampToleranceFEB=rampThrFEB
156 if flags.LArCalib.isSC:
157 theRampValidationAlg.ProblemsToMask=["deadCalib","deadReadout","deadPhys","maskedOSUM",
158 "OffOFCs","transmissionErrorFibre"]
159 else:
160 theRampValidationAlg.ProblemsToMask=["deadReadout","deadCalib","deadPhys","almostDead",
161 "highNoiseHG","highNoiseMG","highNoiseLG"]
162 theRampValidationAlg.KeyList=["LArRamp"+digKey,]
163 if flags.LArCalib.isSC:
164 theRampValidationAlg.PatchMissingFEBs = False
165 theRampValidationAlg.CheckCompletness = False
166 else:
167 theRampValidationAlg.PatchMissingFEBs=True
168 theRampValidationAlg.UseCorrChannels=False
169 theRampValidationAlg.ValidationKey="LArRamp"
170 theRampValidationAlg.ReferenceKey="LArRampRef"
171
172 theRampValidationAlg.MsgLevelForDeviations=WARNING
173 theRampValidationAlg.ListOfDevFEBs="rampFebs.txt"
174
175 theRampValidationAlg.BadChanKey = bcKey
176 theRampValidationAlg.SuperCells = flags.LArCalib.isSC
177
178 if flags.LArCalib.isSC:
179 theRampValidationAlg.CablingKey = "LArOnOffIdMapSC"
180 theRampValidationAlg.CalibLineKey = "LArCalibIdMapSC"
181
182 result.addEventAlgo(theRampValidationAlg)
183
184
185 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
186 result.merge(OutputConditionsAlgCfg(flags,
187 outputFile=flags.LArCalib.Output.POOLFile,
188 ObjectList=["LArRampComplete#LArRamp#"+flags.LArCalib.Ramp.Folder,],
189 IOVTagList=[rampTag,],
190 Run1=flags.LArCalib.IOVStart,
191 Run2=flags.LArCalib.IOVEnd
192 ))
193
194
195 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
196
197
198
199 rootfile=flags.LArCalib.Output.ROOTFile
200
201 ntupKey = digKey
202 if flags.LArCalib.isSC:
203 ntupKey = "HIGH"
204 if rootfile != "":
205 result.addEventAlgo(CompFactory.LArRamps2Ntuple( ContainerKey = ["LArRamp"+ntupKey],
206 AddFEBTempInfo = False,
207 RealGeometry = True,
208 OffId = True,
209 AddCalib = True,
210 RawRamp = True,
211 SaveAllSamples = True,
212 BadChanKey = bcKey,
213 ApplyCorr=True,
214 isSC = flags.LArCalib.isSC
215 ))
216 if flags.LArCalib.Output.SaveAverages:
217 result.addEventAlgo(CompFactory.LArAverages2Ntuple( "LArAverages2Ntuple"+digKey,
218 ContainerKey = "SC" if flags.LArCalib.isSC else digKey,
219 BadChanKey = bcKey,
220 isSC = flags.LArCalib.isSC
221 ))
222
223 import os
224 if os.path.exists(rootfile):
225 os.remove(rootfile)
226 result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
227 result.setAppProperty("HistogramPersistency","ROOT")
228 pass
229
230
231 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
232 result.merge(PerfMonMTSvcCfg(flags))
233
234 return result
235
236
void print(char *figname, TCanvas *c1)