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