ATLAS Offline Software
Loading...
Searching...
No Matches
LArCalib_PileUpAutoCorrConfig.py
Go to the documentation of this file.
2# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
4from AthenaConfiguration.ComponentFactory import CompFactory
5from AthenaConfiguration.MainServicesConfig import MainServicesCfg
6
8
9 #Get basic services and cond-algos
10 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg,chanSelStr
11 result=LArCalibBaseCfg(flags)
12
13 from IOVDbSvc.IOVDbSvcConfig import addFolders
14
15 #load fsampl, MinBias Average and PulseShape 32 samples from OFLP200
16 if flags.LArCalib.isSC:
17 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBMCSCCfg
18 # for the SC we need uA2MeV also from MC, because the one used for data are weighted with E->ET conversion
19 result.merge(LArElecCalibDBMCSCCfg(flags,["fSamplSC","ShapeSC","MinBiasSC","uA2MeVSC"]))
20 else:
21 result.merge(addFolders(flags,"/LAR/ElecCalibMC/Shape",detDb="LAR_OFL", db="OFLP200",tag="LARElecCalibMCShapeLArPileupShape-RUN2-2018",className="LArShape32MC",modifiers="<key>LArShapeMC</key>"))
22 result.merge(addFolders(flags,"/LAR/ElecCalibMC/fSampl",detDb="LAR_OFL", db="OFLP200",tag="LARElecCalibMCfSampl-G4101-20371-FTFP_BERT_BIRK_v2",className="LArfSamplMC"))
23 result.merge(addFolders(flags,"/LAR/ElecCalibMC/MinBias",detDb="LAR_OFL", db="OFLP200",tag="LARElecCalibMCMinBias-mc16-Epos-A3-s3687",className="LArMinBiasMC"))
24
25 result.addCondAlgo(CompFactory.LArMCSymCondAlg())
26
27 LArShapeSymAlg = CompFactory.getComp("LArSymConditionsAlg<LArShape32MC, LArShape32Sym>")
28 result.addCondAlgo(LArShapeSymAlg(ReadKey="LArShapeMC",WriteKey="LArShapeSym"))
29
30 LArfSamplSymAlg = CompFactory.getComp("LArSymConditionsAlg<LArfSamplMC, LArfSamplSym>")
31 result.addCondAlgo(LArfSamplSymAlg(ReadKey="LArfSampl", WriteKey="LArfSamplSym"))
32
33 LArMinBiasSymAlg = CompFactory.getComp("LArSymConditionsAlg<LArMinBiasMC, LArMinBiasSym>")
34 result.addCondAlgo(LArMinBiasSymAlg(ReadKey="LArMinBias",WriteKey="LArMinBiasSym"))
35
36 from LArCalibProcessing.utils import FolderTagResolver
37 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
38 if flags.LArCalib.isSC:
39 FolderTagResolver._defaultSuffix="-UPD3-00"
40 rs=FolderTagResolver(dbname="sqlite://;schema=%s;dbname=CONDBR2"%flags.LArCalib.Input.Database)
41 AutoCorrTag=rs.getFolderTag(flags.LArCalib.AutoCorr.Folder)
42 PedestalTag=rs.getFolderTag(flags.LArCalib.Pedestal.Folder)
43 RampTag=rs.getFolderTag(flags.LArCalib.Ramp.Folder)
44 MpMcTag=rs.getFolderTag(flags.LArCalib.MphysOverMcal.Folder)
45 rsac=FolderTagResolver(dbname="COOLOFL_LAR/CONDBR2")
46 PhysAutoCorrTag= rsac.getFolderTag(flags.LArCalib.PhysAutoCorr.Folder)
47 nColl=flags.LArCalib.OFC.Ncoll
48 if nColl>0:
49 if "mu" in PhysAutoCorrTag and str(nColl) not in PhysAutoCorrTag:
50 #Change mu in tag-name:
51 elems=PhysAutoCorrTag.split("_")
52 elems1=elems[2].split("-")
53 PhysAutoCorrTag="-".join([elems[0]+"_mu_%i"%nColl,]+elems1[1:])
54 del elems
55 del elems1
56 elif "mu" not in PhysAutoCorrTag:
57 #Insert mu in tag-name:
58 elems=PhysAutoCorrTag.split("-")
59 PhysAutoCorrTag="-".join([elems[0]+"_mu_%i"%nColl,]+elems[1:])
60 del elems
61 print("PhysAutoCorrTag: ",PhysAutoCorrTag)
62
63 del rs
64
65 result.merge(addFolders(flags,flags.LArCalib.AutoCorr.Folder,detDb=flags.LArCalib.Input.Database, tag=AutoCorrTag, modifiers=chanSelStr(flags)+"<key>LArAutoCorr</key>",
66 className="LArAutoCorrComplete"))
67 result.merge(addFolders(flags,flags.LArCalib.Pedestal.Folder,detDb=flags.LArCalib.Input.Database, tag=PedestalTag, modifiers=chanSelStr(flags)+"<key>LArPedestal</key>",
68 className="LArPedestalComplete"))
69 result.merge(addFolders(flags,flags.LArCalib.Ramp.Folder,detDb=flags.LArCalib.Input.Database, tag=RampTag, modifiers=chanSelStr(flags),
70 className="LArRampComplete"))
71 result.merge(addFolders(flags,flags.LArCalib.MphysOverMcal.Folder,detDb=flags.LArCalib.Input.Database, tag=MpMcTag, modifiers=chanSelStr(flags),
72 className="LArMphysOverMcalComplete"))
73
74 #Need ADC2MeV values for AutoCorrCondAlg ...
75 #use current production values as input conditions
76 if flags.LArCalib.isSC:
77 requiredConditions=["DAC2uA","HVScaleCorr"]
78 else:
79 #requiredConditions=["DAC2uA","uA2MeV","HVScaleCorr","Ramp","Pedestal","MphysOverMcal"]
80 # in 2024 put:
81 requiredConditions=["DAC2uA","uA2MeV","HVScaleCorr"]
82 if flags.LArCalib.isSC:
83 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBSCCfg
84 result.merge(LArElecCalibDBSCCfg(flags,requiredConditions))
85 mapKey="LArOnOffIdMapSC"
86 bcKey = "LArBadChannelSC"
87 uAKey = "LAruA2MeVSC"
88 DACKey = "LArDAC2uASC"
89 HVKey = "LArHVScaleCorrSC"
90 else:
91 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
92 result.merge(LArElecCalibDBCfg(flags,requiredConditions))
93 mapKey="LArOnOffIdMap"
94 bcKey = "LArBadChannel"
95 uAKey = "LAruA2MeV"
96 DACKey = "LArDAC2uA"
97 HVKey = "LArHVScaleCorr"
98
99 result.addCondAlgo(CompFactory.LArADC2MeVCondAlg(UseFEBGainTresholds=False,LArOnOffIdMappingKey=mapKey,CompleteDetector=False,LAruA2MeVKey=uAKey,LArDAC2uAKey=DACKey,LArHVScaleCorrKey=HVKey,isSuperCell=flags.LArCalib.isSC))
100
101 theLArAutoCorrTotalCondAlg=CompFactory.LArAutoCorrTotalCondAlg()
102 theLArAutoCorrTotalCondAlg.Nsamples=flags.LArCalib.OFC.Nsamples
103 from AthenaCommon.SystemOfUnits import ns
104 theLArAutoCorrTotalCondAlg.deltaBunch=int(flags.Beam.BunchSpacing/( 25.*ns)+0.5)
105 theLArAutoCorrTotalCondAlg.isSuperCell=flags.LArCalib.isSC
106 theLArAutoCorrTotalCondAlg.isMC=False
107 theLArAutoCorrTotalCondAlg.LArAutoCorrObjKey="LArAutoCorr"
108 theLArAutoCorrTotalCondAlg.LArAutoCorrTotalObjKey="LArPhysAutoCorr"
109 theLArAutoCorrTotalCondAlg.LArOnOffIdMappingObjKey=mapKey
110 theLArAutoCorrTotalCondAlg.LArPedestalObjKey="LArPedestal"
111 if flags.LArCalib.isSC:
112 theLArAutoCorrTotalCondAlg.LArShapeObjKey = "LArShapeSC"
113 theLArAutoCorrTotalCondAlg.LArfSamplObjKey = "LArfSamplSC"
114 theLArAutoCorrTotalCondAlg.LArMinBiasObjKey = "LArMinBiasSC"
115
116 result.addCondAlgo(theLArAutoCorrTotalCondAlg)
117
118 result.addEventAlgo(CompFactory.LArAutoCorrAlgToDB(GroupingType=flags.LArCalib.GroupingType,
119 NMinbias=nColl,isSC=flags.LArCalib.isSC))
120
121
122 #Ntuple writing
123 rootfile=flags.LArCalib.Output.ROOTFile
124 if rootfile != "":
125 result.addEventAlgo(CompFactory.LArAutoCorr2Ntuple(ContainerKey="LArPhysAutoCorr",OffId=True,isSC=flags.LArCalib.isSC,
126 BadChanKey=bcKey, AddCalib=True))
127 import os
128 if os.path.exists(rootfile):
129 os.remove(rootfile)
130 result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
131 result.setAppProperty("HistogramPersistency","ROOT")
132 pass # end if ROOT ntuple writing
133
134
135
136 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
137 result.merge(OutputConditionsAlgCfg(flags,
138 outputFile=flags.LArCalib.Output.POOLFile,
139 ObjectList=["LArAutoCorrComplete#LArPhysAutoCorr#"+flags.LArCalib.PhysAutoCorr.Folder,],
140 IOVTagList=[PhysAutoCorrTag,],
141 Run1=flags.LArCalib.IOVStart,
142 Run2=flags.LArCalib.IOVEnd
143 ))
144
145
146 #RegistrationSvc
147 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
148 result.getService("IOVDbSvc").DBInstance=""
149
150
151 #MC Event selector since we have no input data file
152 from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
153 result.merge(McEventSelectorCfg(flags,
154 RunNumber = flags.LArCalib.Input.RunNumbers[0],
155 EventsPerRun = 1,
156 FirstEvent = 1,
157 InitialTimeStamp = 0,
158 TimeStampInterval = 1))
159
160
161 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
162 result.merge(PerfMonMTSvcCfg(flags))
163
164 return result
165
166
167
168
169if __name__ == "__main__":
170
171 import sys
172 from AthenaConfiguration.AllConfigFlags import initConfigFlags
173 ConfigFlags=initConfigFlags()
174 from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
175 addLArCalibFlags(ConfigFlags)
176 from AthenaConfiguration.TestDefaults import defaultGeometryTags
177
178 ConfigFlags.Input.Files=[]
179 ConfigFlags.LArCalib.Input.RunNumbers=[400939,]
180 ConfigFlags.LArCalib.Input.Database="/home/wlampl/calibTest/00400939_00400943_00400945_Barrel-EMB-EMEC_HIGH_40_21.0.20_1/poolFiles/myDB200_00400939_00400943_00400945_EB-EMBA_one.db_Delay"
181 ConfigFlags.LArCalib.Input.SubDet="EM"
182 ConfigFlags.LArCalib.BadChannelDB="/home/wlampl/calibTest/00400939_00400943_00400945_Barrel-EMB-EMEC_HIGH_40_21.0.20_1/poolFiles/SnapshotBadChannel_00400939_00400943_00400945_EB-EMBA.db"
183 ConfigFlags.LArCalib.BadChannelTag="-RUN2-UPD3-00"
184 ConfigFlags.LArCalib.Output.ROOTFile="physAC.root"
185 ConfigFlags.IOVDb.DatabaseInstance="CONDBR2"
186 ConfigFlags.IOVDb.DBConnection="sqlite://;schema=output.sqlite;dbname=CONDBR2"
187 ConfigFlags.IOVDb.GlobalTag="LARCALIB-RUN2-02"
188 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
189 #ConfigFlags.Exec.OutputLevel=1
190 ConfigFlags.LArCalib.OFC.Ncoll=20
191 ConfigFlags.LArCalib.OFC.Nsamples=5
192
193 ConfigFlags.fillFromArgs()
194 ConfigFlags.lock()
195
196 cfg=MainServicesCfg(ConfigFlags)
197 cfg.merge(LArPileUpAutoCorrCfg(ConfigFlags))
198
199
200 print("Folders:")
201 print(cfg.getService("IOVDbSvc").Folders)
202 print("ADC2MeV:")
203 print(cfg.getCondAlgo("LArADC2MeVCondAlg"))
204 print("AutoCorrTotal:")
205 print(cfg.getCondAlgo("LArAutoCorrTotalCondAlg"))
206
207
208 print("Start running...")
209 sys.exit(cfg.run(1).isFailure())
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177