10 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
11 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
12 from InDetAlignGenAlgs.InDetAlignAlgsConfig
import CreateITkMisalignAlgCfg
13 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorFlags
14 from InDetAlignGenTools.InDetAlignGenToolsConfig
import ITkAlignDBTool
16 from AthenaConfiguration.ComponentFactory
import CompFactory
19 "Block use of specified conditions DB folder so data can be read from elsewhere"
20 from IOVDbSvc.IOVDbSvcConfig
import IOVDbSvcCfg
22 iovdbsvc=ca.getService(
"IOVDbSvc")
24 for i
in range(0,len(iovdbsvc.Folders)):
25 if (iovdbsvc.Folders[i].
find(folder)>=0):
26 del iovdbsvc.Folders[i]
28 condInputLoader=ca.getCondAlgo(
"CondInputLoader")
29 for i
in range(0, len(condInputLoader.Load)):
30 if (folder
in condInputLoader.Load[i][-1] ):
31 del condInputLoader.Load[i]
38 flags.Input.isMC =
True
40 flags.Input.Files = []
42 from AthenaConfiguration.TestDefaults
import defaultGeometryTags,defaultConditionsTags
43 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
44 flags.GeoModel.Align.Dynamic =
False
46 flags.ITk.Geometry.AllLocal =
False
53 flags.TrackingGeometry.MaterialSource =
"Input"
57 if 'MisalignMode' not in kwargs.keys():
60 MisalignMode=
int(kwargs.get(
'MisalignMode',11))
61 databaseFilename =
'MisalignmentSet%s.db' % (MisalignMode)
62 flags.IOVDb.DBConnection=
"sqlite://;schema=%s;dbname=OFLCOND" % (databaseFilename)
63 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
66 flags.Concurrency.NumThreads = 1
67 flags.Concurrency.NumConcurrentEvents = 1
72 def CreateMis(flags,name="CreateITkMisalignAlg",**kwargs):
77 misalignmentOnTopOfExistingSet =
False
78 readDBPoolFile =
False
80 createFreshDB = not(readDBPoolFile
or misalignmentOnTopOfExistingSet)
82 MisalignMode = kwargs.pop(
'MisalignMode',11)
86 if MisalignMode
in [11, 12, 31]:
88 outFiles =
'MisalignmentSet%s' % (MisalignMode)
89 misalignModeMap = {0:
'no Misalignment',
90 1:
'misalignment by 6 parameters',
91 2:
'random misalignment',
92 3:
'IBL-stave temperature dependent bowing',
93 11:
'R deltaR (radial expansion)', 12:
'Phi deltaR (ellipse)',13:
'Z deltaR (funnel)',
94 21:
'R deltaPhi (curl)', 22:
'Phi deltaPhi (clamshell) ',23:
'Z deltaPhi (twist)',
95 31:
'R deltaZ (telescope)',32:
'Phi deltaZ (skew)',33:
'Z deltaZ (z-expansion)'}
99 print (
"\n CreateMisalignAlg: Creation of misalignment mode %s: %s \n" % (
int(MisalignMode),misalignModeMap.get(
int(MisalignMode),
'unknown')))
100 kwargs.setdefault(
"ASCIIFilenameBase",outFiles)
101 kwargs.setdefault(
"SQLiteTag",
'MisalignmentMode_'+
str(misalignModeMap.get(
int(MisalignMode),
'unknown')))
102 kwargs.setdefault(
"MisalignMode",
int(MisalignMode))
103 kwargs.setdefault(
"MaxShift",shiftInMicrons)
104 kwargs.setdefault(
"CreateFreshDB",createFreshDB)
106 outputAlignFolder=
"/Indet/AlignITk"
107 inputAlignFolder=
"/Indet/Align"
111 kargsTool.setdefault(
"SCTTwoSide",
True)
112 kargsTool.setdefault(
"DBRoot",outputAlignFolder)
113 kargsTool.setdefault(
"DBKey",outputAlignFolder)
114 kargsTool.setdefault(
"forceUserDBConfig",
True)
116 print(
"Writing DB Pool File")
117 InDetCondStream=CompFactory.AthenaOutputStreamTool(
"CondStream_write",OutputFile = outFiles+
'.pool.root')
118 InDetCondStream.PoolContainerPrefix=
"<type>"
119 InDetCondStream.TopLevelContainerName=
""
120 InDetCondStream.SubLevelBranchName=
"<key>"
121 kargsTool.setdefault(
"CondStream",InDetCondStream)
124 kwargs.setdefault(
"IDAlignDBTool",dbTool)
126 cfg=
CreateITkMisalignAlgCfg(flags,name=name,SetITkPixelAlignable=
True,SetITkStripAlignable=
True,setAlignmentFolderName=inputAlignFolder,**kwargs)
130 print(
"To be writen DB pool File")
134 if __name__ ==
"__main__":
135 if(len(sys.argv[1:])):
136 kwargs=dict(arg.split(
'=')
for arg
in sys.argv[1:])
151 print(
"Failed to run the Misalignment Algorithm")