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