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