ATLAS Offline Software
PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 
4 from McParticleTools.McParticleToolsConf import EtaPtFilterTool
5 from McParticleTools.McParticleToolsConf import TruthParticleCnvTool
6 
7 from McParticleAlgs.McParticleAlgsConf import TruthParticleBuilder
8 class test_McAodBuilder( TruthParticleBuilder ):
9 
10  __slots__ = ( )
11 
12  def __init__( self,
13  name = "McAodBuilder" ):
14  super( test_McAodBuilder, self ).__init__( name )
15  return
16 
17  def setDefaults(cls, handle):
18 
19  if not hasattr(handle, 'FilterTool'):
20 
21 
25  handle.FilterTool = EtaPtFilterTool()
26  handle.FilterTool.McEvents = "GEN_EVENT"
27  handle.FilterTool.McEventsOutput = "GEN_AOD"
28  pass
29 
30  if not hasattr(handle, 'CnvTool'):
31 
32 
36  handle.CnvTool = TruthParticleCnvTool()
37  pass
38  return
39 
40  pass # test_McAodBuilder
41 
42 from McParticleTools.McParticleToolsConf import GenAodValidationTool
43 from McParticleTools.McParticleToolsConf import HepMcWriterTool
44 from McParticleAlgs.McParticleAlgsConf import McAodValidationAlg
45 
46 class test_McAodValidation( McAodValidationAlg ):
47 
48  __slots__ = ( )
49 
50  def __init__( self, name = "McAodValidation" ):
51  super( test_McAodValidation, self ).__init__( name )
52  return
53 
54  def setDefaults(cls, handle):
55 
56  # declare the sub-tools (will be easier with ToolHandleArrayProperty)
57  handle.ValidationTools = [
58  "GenAodValidationTool/GenAodValidation",
59  "SpclMcValidationTool/SpclMcValidation",
60  ]
61 
62  if not hasattr(handle, "GenAodValidation"):
63  genAodValidation = GenAodValidationTool( "GenAodValidation" )
64  genAodValidation.RefMcEvents = "GEN_EVENT"
65  genAodValidation += HepMcWriterTool("RefHepMcWriterTool")
66  genAodValidation += HepMcWriterTool("CheckHepMcWriterTool")
67 
68  handle += genAodValidation
69  return
70 
71  pass # test_McAodValidation
72 
73 from McParticleTools.McParticleToolsConf import McVtxFilterTool
74 from McParticleAlgs.McParticleAlgsConf import McAodFilter
75 
76 class test_McAodFilter( McAodFilter ):
77 
78  __slots__ = ( )
79 
80  def __init__( self, name = "McAodFilter" ):
81  super( test_McAodFilter, self ).__init__( name )
82  return
83 
84  def setDefaults(cls, handle):
85 
86  handle.DoGenAod = True
87  handle.McVtxFilterTool = McVtxFilterTool()
88  handle.McVtxFilterTool.McEvents = "GEN_EVENT"
89  handle.McVtxFilterTool.McEventsOutput = "MyGEN_EVENT"
90  handle.McVtxFilterTool.DoSignalProcessVtx = True
91 
92  handle.DoTruthParticles = True
93  handle.TruthParticleCnvTool = TruthParticleCnvTool()
94  handle.TruthParticleCnvTool.McEvents = "MyGEN_EVENT"
95  handle.TruthParticleCnvTool.TruthParticlesOutput = "MySpclMC"
96 
97  return
98 
99  pass # test_McAodFilter
100 
101 not_yet = """
102 ## -- Generator helper
103 from Pythia_i.Pythia_iConf import Pythia
104 from Herwig_i.Herwig_iConf import Herwig
105 from Herwig_i.Herwig_iConf import Jimmy
106 
107 def makeGenEvents( genName = "Pythia",
108  genProcess = "ttbar",
109  cfgGenName = "EvGen" ):
110  Little helper method to provide a quick way to produce Mc-events
111 
112  if genName.lower() not in [ "pythia", "jimmy", "herwig" ]:
113  raise RuntimeError, "Unknown GENERATOR [%s]" % str(genName)
114  if genProcess not in ["ttbar", "HiggsTo4Leptons", "Z+j"]:
115  raise RuntimeError, "Unknown PROCESS [%s]" % str(genProcess)
116 
117  if genName.lower() == "pythia":
118  genAlg = Pythia(cfgGenName)
119  if genProcess == "Z+j":
120  genAlg.PythiaCommand = [ "pysubs msel 13",
121  "pysubs ckin 3 18.",
122  "pypars mstp 43 2" ]
123  elif genProcess == "ttbar":
124  # semi-leptonic decay of a ttbar pair (lepton=e,mu)
125  genAlg.PythiaCommand = [
126  "pysubs msel 6",
127  "pysubs ckin 3 18.",
128  "pypars mstp 43 2",
129  # Customisation of subprocess generation
130  "pysubs msub 81 1", # qqbar -> QQbar
131  "pysubs msub 82 1", # gq -> QQbar
132  "pysubs msub 96 1", # SemiHard QCD 2 -> 2
133  # top
134  "pydat3 mdme 41 1 0", # gt
135  "pydat3 mdme 42 1 0", # gamma t
136  "pydat3 mdme 43 1 0", # Z0 t
137  "pydat3 mdme 44 1 0", # W+ d
138  "pydat3 mdme 45 1 0", # W+ s
139  "pydat3 mdme 46 1 1", # W+ b
140  "pydat3 mdme 47 1 0", # W+ b'
141  "pydat3 mdme 48 1 0", # h0 t
142  "pydat3 mdme 49 1 0", # H+ b
143  "pydat3 mdme 50 1 0", # ~chi_10 ~t_1
144  "pydat3 mdme 51 1 0", # ~chi_20 ~t_1
145  "pydat3 mdme 52 1 0", # ~chi_30 ~t_1
146  "pydat3 mdme 53 1 0", # ~chi_40 ~t_1
147  "pydat3 mdme 54 1 0", # ~g ~t_1
148  "pydat3 mdme 55 1 0", # ~gravitino ~t_1
149  # W
150  "pydat3 mdme 190 1 2", # dbar u
151  "pydat3 mdme 191 1 2", # dbar c
152  "pydat3 mdme 192 1 2", # dbar t
153  "pydat3 mdme 193 1 0", # dbar t'
154  "pydat3 mdme 194 1 2", # sbar u
155  "pydat3 mdme 195 1 2", # sbar c
156  "pydat3 mdme 196 1 2", # sbar t
157  "pydat3 mdme 197 1 0", # sbar t'
158  "pydat3 mdme 198 1 2", # bbar u
159  "pydat3 mdme 199 1 2", # bbar c
160  "pydat3 mdme 200 1 2", # bbar t
161  "pydat3 mdme 201 1 0", # bbar t'
162  "pydat3 mdme 202 1 0", # b'bar u
163  "pydat3 mdme 203 1 0", # b'bar c
164  "pydat3 mdme 204 1 0", # b'bar t
165  "pydat3 mdme 205 1 0", # b'bar t'
166  "pydat3 mdme 206 1 0", # e+ nu_e
167  "pydat3 mdme 207 1 3", # mu+ nu_mu
168  "pydat3 mdme 208 1 0", # tau+ nu_tau
169  "pydat3 mdme 209 1 0" # tau'+ nu'_tau
170  ]
171  elif genProcess == "HiggsTo4Leptons":
172  genAlg.PythiaCommand = [
173  # Higgs mass set:
174  "pydat2 pmas 25 1 150.",
175  # Select Higgs production
176  "pysubs msel 16",
177  # Higgs Decays
178  "pydat3 mdme 210 1 0",
179  "pydat3 mdme 211 1 0",
180  "pydat3 mdme 212 1 0",
181  "pydat3 mdme 213 1 0",
182  "pydat3 mdme 214 1 0",
183  "pydat3 mdme 215 1 0",
184  "pydat3 mdme 218 1 0",
185  "pydat3 mdme 219 1 0",
186  "pydat3 mdme 220 1 0",
187  "pydat3 mdme 222 1 0",
188  "pydat3 mdme 223 1 0",
189  "pydat3 mdme 224 1 0",
190  "pydat3 mdme 225 1 1",
191  "pydat3 mdme 226 1 0",
192 
193  # Z Decays
194  "pydat3 mdme 174 1 0",
195  "pydat3 mdme 175 1 0",
196  "pydat3 mdme 176 1 0",
197  "pydat3 mdme 177 1 0",
198  "pydat3 mdme 178 1 0",
199  "pydat3 mdme 179 1 0",
200  "pydat3 mdme 180 1 0",
201  "pydat3 mdme 181 1 0",
202  "pydat3 mdme 182 1 1",
203  "pydat3 mdme 183 1 0",
204  "pydat3 mdme 184 1 1",
205  "pydat3 mdme 185 1 0",
206  "pydat3 mdme 186 1 0",
207  "pydat3 mdme 187 1 0",
208  "pydat3 mdme 188 1 0",
209  "pydat3 mdme 189 1 0"
210  ]
211  else:
212  raise RuntimeError, "Unknown PROCESS [%s]" % str(genProcess)
213 
214  # Some ISR,FSR,MultipleInteractions and Hadronization parameters
215  genAlg.PythiaCommand += [
216  "pypars mstp 61 1", # ISR
217  "pypars mstp 71 1", # FSR
218  "pypars mstp 81 1", # MultInt
219  "pypars mstp 111 1", # Hadronization
220  ]
221 
222  # Pythia listing documentation level (0-1-2)
223  Pythia.PythiaCommand += [ "pypars mstp 125 2" ]
224 
225 
226  elif genName.lower() == "jimmy":
227  genAlg = Jimmy(cfgGenName)
228  if genProcess == "Z+j":
229  genAlg.JimmyCommand = [
230  "iproc 12150",
231  "modpdf 10042",
232  "autpdf HWLHAPDF",
233  "msflag 1",
234  "jmbug 0"
235  ]
236  elif genProcess == "ttbar":
237  import commands
238  osCmd = commands.getoutput( "get_files inparmMcAtNlo.dat" )
239  # osCmd = commands.getoutput( "get_files tt.events" )
240  genAlg.JimmyCommand = [
241  "iproc mcatnlo",
242  "modpdf 10042", "autpdf HWLHAPDF",
243  "msflag 1",
244  "jmbug 0"
245  ]
246  del osCmd
247 
248  else:
249  raise RuntimeError, "Unknown PROCESS [%s]" % std(genProcess)
250 
251  elif genName.lower() == "Herwig":
252  genAlg = Herwig(cfgGenName)
253  if genProcess == "Z+j":
254  genAlg.HerwigCommand = [
255  "iproc 2150",
256  "modpdf 10042",
257  "autpdf HWLHAPDF"
258  ]
259 
260  elif genProcess == "ttbar":
261  genAlg.HerwigCommand = [
262  "iproc 1700",
263  "modpdf 10042",
264  "autpdf HWLHAPDF"
265  ]
266 
267  else:
268  raise RuntimeError, "Unknown PROCESS [%s]" % str(genProcess)
269 
270  else:
271  raise RuntimeError, "Unknown GENERATOR [%s]" % str(genName)
272 
273  return genAlg
274 """
python.tests.test_McAodBuilder
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:8
python.tests.test_McAodBuilder.setDefaults
def setDefaults(cls, handle)
Default configuration of the filter tool [ESD-McEventCollection --> AOD-McEventCollection].
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:17
python.tests.test_McAodFilter.setDefaults
def setDefaults(cls, handle)
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:84
python.tests.test_McAodBuilder.__init__
def __init__(self, name="McAodBuilder")
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:12
python.tests.test_McAodValidation.setDefaults
def setDefaults(cls, handle)
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:54
python.tests.test_McAodValidation.__init__
def __init__(self, name="McAodValidation")
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:50
python.tests.test_McAodFilter
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:76
python.tests.test_McAodFilter.__init__
def __init__(self, name="McAodFilter")
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:80
python.tests.test_McAodValidation
Definition: PhysicsAnalysis/TruthParticleID/McParticleAlgs/python/tests.py:46