ATLAS Offline Software
Loading...
Searching...
No Matches
LArCalib_RTMParamsConfig.py
Go to the documentation of this file.
1#!/usr/bin/env python3
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
7def LArRTMParamsCfg(flags):
8
9 #Get basic services and cond-algos
10 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg,chanSelStr
11 result=LArCalibBaseCfg(flags)
12
13 from LArCalibProcessing.utils import FolderTagResolver
14 FolderTagResolver._globalTag=flags.IOVDb.GlobalTag
15 rs=FolderTagResolver()
16 DetCellParamsTag=rs.getFolderTag(flags.LArCalib.DetCellParams.Folder)
17 CaliPulseParamsTag=rs.getFolderTag(flags.LArCalib.CaliPulseParams.Folder)
18 CaliWaveTag=rs.getFolderTag(flags.LArCalib.CaliWave.Folder)
19 del rs #Close database
20
21 #Retrieve CaliWave:
22 from IOVDbSvc.IOVDbSvcConfig import addFolders
23 result.merge(addFolders(flags,flags.LArCalib.CaliWave.Folder,detDb=flags.LArCalib.Input.Database, tag=CaliWaveTag, modifiers=chanSelStr(flags)))
24
25 if not flags.LArCalib.RTM.ExtractAll:
26 #Get information from database:
27 result.merge(addFolders(flags,flags.LArCalib.DetCellParams.Folder,detDb=flags.LArCalib.Input.Database, tag=DetCellParamsTag))
28 result.merge(addFolders(flags,flags.LArCalib.CaliPulseParams.Folder,detDb=flags.LArCalib.Input.Database, tag=CaliPulseParamsTag))
29
30
31 LArRTMParamExtractor = CompFactory.LArRTMParamExtractor()
32
33 LArRTMParamExtractor.KeyList = ["LArCaliWave"]
34 LArRTMParamExtractor.TestMode = False
35 LArRTMParamExtractor.GroupingType = flags.LArCalib.GroupingType
36 LArRTMParamExtractor.IgnoreDACSelection = True
37 LArRTMParamExtractor.isSC = flags.LArCalib.isSC
38
39 LArRTMParamExtractor.ExtractTaur = True
40 LArRTMParamExtractor.ExtractTcal = flags.LArCalib.RTM.ExtractAll
41 LArRTMParamExtractor.ExtractFstep = flags.LArCalib.RTM.ExtractAll
42 LArRTMParamExtractor.ExtractOmega0 = flags.LArCalib.RTM.ExtractAll
43
44 LArRTMParamExtractor.FT = flags.LArCalib.Preselection.FT
45 LArRTMParamExtractor.PosNeg = 0 if len(flags.LArCalib.Preselection.Side)==0 else flags.LArCalib.Preselection.Side[0]
46 LArRTMParamExtractor.Slot = flags.LArCalib.Preselection.Slot
47
48 LArRTMParamExtractor.DumpOmegaScan = flags.LArCalib.RTM.DumpOmegaScan
49 LArRTMParamExtractor.DumpResOscill = flags.LArCalib.RTM.DumpResOscill
50
51
52 theLArWFParamTool = CompFactory.LArWFParamTool()
53 theLArWFParamTool.isSC = flags.LArCalib.isSC
54
55 theLArWFParamTool.UseOmegaScanHelper = True
56 theLArWFParamTool.CosRespScan = [ False , True , False , False ] # Strips only
57 theLArWFParamTool.Omega0Min = [ 0.100 , 0.220 , 0.060 , 0.100 ]
58 theLArWFParamTool.Omega0Max = [ 0.600 , 0.310 , 0.215 , 0.700 ]
59 theLArWFParamTool.NpointScan = [ 800 , 900 , 310 , 120 ]
60 theLArWFParamTool.StoreResOscill = [True * 4] if flags.LArCalib.RTM.DumpResOscill else [False *4]
61
62 LArRTMParamExtractor.LArWFParamTool=theLArWFParamTool
63
64 result.addEventAlgo(LArRTMParamExtractor)
65
66 rootfile=flags.LArCalib.Output.ROOTFile
67 bcKey = "LArBadChannelSC" if flags.LArCalib.isSC else "LArBadChannel"
68 if rootfile != "":
69 LArWFParams2Ntuple = CompFactory.LArWFParams2Ntuple("LArWFParams2Ntuple")
70 LArWFParams2Ntuple.DumpCaliPulseParams = True
71 LArWFParams2Ntuple.DumpDetCellParams = True
72 LArWFParams2Ntuple.CaliPulseParamsKey="LArCaliPulseParams_RTM"
73 LArWFParams2Ntuple.DetCellParamsKey="LArDetCellParams_RTM"
74 LArWFParams2Ntuple.BadChanKey = bcKey
75 LArWFParams2Ntuple.isSC = flags.LArCalib.isSC
76 LArWFParams2Ntuple.AddCalib = True
77 result.addEventAlgo(LArWFParams2Ntuple)
78
79 if flags.LArCalib.RTM.DumpOmegaScan:
80 LArOmegaScans2Ntuple = CompFactory.LArCaliWaves2Ntuple("LArOmegaScans2Ntuple")
81 LArOmegaScans2Ntuple.NtupleName = "OMEGASCAN"
82 LArOmegaScans2Ntuple.BadChanKey = bcKey
83 LArOmegaScans2Ntuple.isSC = flags.LArCalib.isSC
84 LArOmegaScans2Ntuple.KeyList = ["OmegaScan"]
85 result.addEventAlgo(LArOmegaScans2Ntuple)
86
87 if ( flags.LArCalib.RTM.DumpResOscill ):
88 LArResOscillsBefore2Ntuple = CompFactory.LArCaliWaves2Ntuple("LArResOscillsBefore2Ntuple")
89 LArResOscillsBefore2Ntuple.NtupleName = "RESOSCILLBEFORE"
90 LArResOscillsBefore2Ntuple.BadChanKey = bcKey
91 LArResOscillsBefore2Ntuple.isSC = flags.LArCalib.isSC
92 LArResOscillsBefore2Ntuple.KeyList = ["ResOscillBefore"]
93 result.addEventAlgo(LArResOscillsBefore2Ntuple)
94
95 LArResOscillsAfter2Ntuple = CompFactory.LArCaliWaves2Ntuple("LArResOscillsAfter2Ntuple")
96 LArResOscillsAfter2Ntuple.NtupleName = "RESOSCILLAFTER"
97 LArResOscillsAfter2Ntuple.BadChanKey = bcKey
98 LArResOscillsAfter2Ntuple.KeyList = ["ResOscillAfter"]
99 result.addEventAlgo(LArResOscillsAfter2Ntuple)
100
101 import os
102 if os.path.exists(rootfile):
103 os.remove(rootfile)
104 result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
105 result.setAppProperty("HistogramPersistency","ROOT")
106 pass # end if ROOT ntuple writing
107
108
109
110 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
111 result.merge(OutputConditionsAlgCfg(flags,
112 outputFile=flags.LArCalib.Output.POOLFile,
113 ObjectList=["LArCaliPulseParamsComplete#"+"LArCaliPulseParams_RTM#"+flags.LArCalib.CaliPulseParams.Folder,
114 "LArDetCellParamsComplete#"+"LArDetCellParams_RTM#"+flags.LArCalib.DetCellParams.Folder,],
115 IOVTagList=[CaliPulseParamsTag,DetCellParamsTag],
116 Run1=flags.LArCalib.IOVStart,
117 Run2=flags.LArCalib.IOVEnd
118 ))
119
120 #RegistrationSvc
121 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
122 result.getService("IOVDbSvc").DBInstance=""
123
124
125 #MC Event selector since we have no input data file
126 from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
127 result.merge(McEventSelectorCfg(flags,
128 RunNumber = flags.LArCalib.Input.RunNumbers[0],
129 EventsPerRun = 1,
130 FirstEvent = 1,
131 InitialTimeStamp = 0,
132 TimeStampInterval = 1))
133
134 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
135 result.merge(PerfMonMTSvcCfg(flags))
136
137 return result
138
139if __name__ == "__main__":
140
141
142 from AthenaConfiguration.AllConfigFlags import initConfigFlags
143 ConfigFlags=initConfigFlags()
144 from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
145 addLArCalibFlags(ConfigFlags)
146
147 ConfigFlags.Input.Files=[]
148 ConfigFlags.LArCalib.Input.RunNumbers=[401351,]
149 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"
150 ConfigFlags.LArCalib.Input.SubDet="EM"
151 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"
152 ConfigFlags.LArCalib.BadChannelTag="-RUN2-UPD3-00"
153 ConfigFlags.LArCalib.Output.ROOTFile="larparams.root"
154 ConfigFlags.IOVDb.DatabaseInstance="CONDBR2"
155 ConfigFlags.IOVDb.DBConnection="sqlite://;schema=output.sqlite;dbname=CONDBR2"
156 ConfigFlags.IOVDb.GlobalTag="LARCALIB-RUN2-02"
157 from AthenaConfiguration.TestDefaults import defaultGeometryTags
158 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
159 ConfigFlags.IOVDb.DatabaseInstance="CONDBR2"
160 ConfigFlags.LAr.doAlign=False
161 ConfigFlags.Input.RunNumbers=ConfigFlags.LArCalib.Input.RunNumbers
162 #ConfigFlags.Exec.OutputLevel=1
163
164 ConfigFlags.lock()
165 ConfigFlags.fillFromArgs()
166 cfg=MainServicesCfg(ConfigFlags)
167 cfg.merge(LArRTMParamsCfg(ConfigFlags))
168
169 print("Start running...")
170 import sys
171 sys.exit(cfg.run(1).isFailure())
void print(char *figname, TCanvas *c1)