Commit 5a10f3c6 authored by scott snyder's avatar scott snyder
Browse files

H6G4Sim: Python 3 and flake8 fixes

Update to work with python 3.

Enable flake8 checking and fix warnings.
parent ac28b5e0
......@@ -11,3 +11,10 @@ atlas_install_joboptions( share/*.py )
atlas_install_runtime( G4macros/*.mac )
atlas_install_scripts( share/cbtG4_trf.py )
atlas_add_test( flake8
SCRIPT flake8 --select=ATL,F,E7,E9,W6 ${CMAKE_CURRENT_SOURCE_DIR}/python
POST_EXEC_SCRIPT nopost.sh )
atlas_add_test( flake8_share
SCRIPT flake8 --select=ATL,F,E7,E9,W6 --ignore=F401,F403,F405,F821,ATL900 ${CMAKE_CURRENT_SOURCE_DIR}/share
POST_EXEC_SCRIPT nopost.sh )
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from __future__ import print_function
import os, sys, string
from math import sqrt
import ROOT
from array import array
from math import sqrt
def getXYInPolygon(s,nev0=1500):
......@@ -18,14 +18,14 @@ def drawXYInPolygon(nev0=1500):
nevtot = 0
nevinwin = 0
xset,yset,nset = getXYSetInPolygon(nev0)
print "Number of points ", len(xset), len(yset)
print ("Number of points ", len(xset), len(yset))
#histXY = ROOT.TH2F( 'clusE', 'clusE', 500, -500.0, 500.0, 500, -500., 500. )
histXY = ROOT.TH2F( 'clusE', 'clusE', 2000, -800.0, 800.0, 2000, -800., 800. )
histXY.SetStats(0)
histXY.SetTitle("")
for i in range(0,len(xset)):
#print "nrun:",i+1," xCryo:",xset[i], "yTable:",yset[i]
print 'nrun %3d xCryo %5d yTable %5d nev %5d' % (i+1,xset[i], yset[i], nset[i])
#print ("nrun:",i+1," xCryo:",xset[i], "yTable:",yset[i])
print ('nrun %3d xCryo %5d yTable %5d nev %5d' % (i+1,xset[i], yset[i], nset[i]))
nevtot = nevtot + nset[i]
dist = sqrt(xset[i]*xset[i] + (70-yset[i])*(70-yset[i]))
if dist < 300:
......@@ -36,12 +36,12 @@ def drawXYInPolygon(nev0=1500):
c0.SetFillColor(10)
c0.SetFillStyle(0)
c0.cd()
ROOT.gPad.SetGrid();
ROOT.gPad.SetLeftMargin(0.12);
ROOT.gPad.SetRightMargin(0.12);
ROOT.gPad.SetTopMargin(0.12);
ROOT.gPad.SetBottomMargin(0.12);
tc = ROOT.TEllipse(0,70,300);
ROOT.gPad.SetGrid()
ROOT.gPad.SetLeftMargin(0.12)
ROOT.gPad.SetRightMargin(0.12)
ROOT.gPad.SetTopMargin(0.12)
ROOT.gPad.SetBottomMargin(0.12)
tc = ROOT.TEllipse(0,70,300)
tc.SetFillStyle(0)
tc.SetLineWidth(2)
histXY.SetMarkerStyle(20)
......@@ -62,9 +62,9 @@ def drawXYInPolygon(nev0=1500):
#for i in range(0,500):
#x,y = getXYInPolygon(i)
#print "nrun:",i+1," xCryo:",x, "yTable:",y
#print ("nrun:",i+1," xCryo:",x, "yTable:",y)
print "nevtot:",nevtot, "in win:",nevinwin
print ("nevtot:",nevtot, "in win:",nevinwin)
return c0, histXY, tc, myPoly
......@@ -98,7 +98,7 @@ def getXYSetInPolygon(nev0=1500):
y_Ytop = 700
n_Ybot = nev0*2
y_Ybot = -400
print "Initial number of events:", nev0, "y_Ytop:",y_Ytop, "n_Ytop:",n_Ytop, "y_Ybot:",y_Ybot, "n_Ybot:",n_Ybot
print ("Initial number of events:", nev0, "y_Ytop:",y_Ytop, "n_Ytop:",n_Ytop, "y_Ybot:",y_Ybot, "n_Ybot:",n_Ybot)
# - - - - - -
# - 2 3 4 - -
# - 1 + 5 - -
......@@ -110,13 +110,13 @@ def getXYSetInPolygon(nev0=1500):
nset = []
xset.append(x0)
yset.append(y0)
#nset.append((n_Ytop+(y0-400)*(n_Ytop-n_Ybot)/800)/100*100);
nset.append( (n_Ybot+(y0-y_Ybot)*(n_Ytop-n_Ybot)/(y_Ytop-y_Ybot))/10*10 );
#nset.append((n_Ytop+(y0-400)*(n_Ytop-n_Ybot)/800)/100*100)
nset.append( (n_Ybot+(y0-y_Ybot)*(n_Ytop-n_Ybot)/(y_Ytop-y_Ybot))/10*10 )
for iRound in range(1,1000):
boxSide = 1+iRound*2
nPoints = (boxSide-1)*4
#print "----------------------------------------"
#print "iRound:", iRound, " boxSide ", boxSide, "nPoints ", nPoints
#print ("----------------------------------------")
#print ("iRound:", iRound, " boxSide ", boxSide, "nPoints ", nPoints)
nGoodPoints = 0
for iPoint in range(0, nPoints):
boxSideNum = iPoint/(boxSide-1)
......@@ -135,15 +135,15 @@ def getXYSetInPolygon(nev0=1500):
iY = y0 - iRound*dy
mt = ROOT.TMath
result = mt.IsInside(iX, iY, poly_np, poly_x, poly_y)
#print "iPoint ", iPoint," from nPoints ",nPoints, " boxSideNum:",boxSideNum, " mod:", boxSideStep, " iX:", iX, " iY:", iY, result
#print ("iPoint ", iPoint," from nPoints ",nPoints, " boxSideNum:",boxSideNum, " mod:", boxSideStep, " iX:", iX, " iY:", iY, result)
if result == 1:
nGoodPoints += 1
xset.append(iX)
yset.append(iY)
nset.append( (n_Ybot+(iY-y_Ybot)*(n_Ytop-n_Ybot)/(y_Ytop-y_Ybot))/10*10 );
#print "nGoodPoints:", nGoodPoints, " nPoints:", nPoints
nset.append( (n_Ybot+(iY-y_Ybot)*(n_Ytop-n_Ybot)/(y_Ytop-y_Ybot))/10*10 )
#print ("nGoodPoints:", nGoodPoints, " nPoints:", nPoints)
if nGoodPoints == 0:
break;
break
return xset, yset, nset
......@@ -160,10 +160,10 @@ def getXYSetInPolygon(nev0=1500):
#ss = s%(nx*ny)
#iy=ss/nx
#ix=ss%nx
##print seed,ix,iy
##print (seed,ix,iy)
#x=xmin+ix*dx
#y=ymin+iy*dy
##print "s:",s,"nx:", nx, "ny:",ny, "nx*ny:",nx*ny,"ix:",ix,"iy:",iy,"x:",x,"y:",y, "ss",ss
##print ("s:",s,"nx:", nx, "ny:",ny, "nx*ny:",nx*ny,"ix:",ix,"iy:",iy,"x:",x,"y:",y, "ss",ss)
#return x,y
......@@ -191,12 +191,12 @@ def getXYSetInPolygon(nev0=1500):
#x=xmin+ix*dx
#y=ymin+iy*dy
#dist = sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0))
##print "ix, iy",ix, iy, "x,y", x,y, "dist", dist
##print ("ix, iy",ix, iy, "x,y", x,y, "dist", dist)
#if dist <= r0:
#xset.append(x)
#yset.append(y)
#ss = s%(len(xset))
##print "s:",s+1,"ntot:",ntot,"len_xyset;",len(xset), "ss:",ss, "xy:",xset[ss], yset[ss]
#print "nrun:",s+1," xCryo:",xset[ss], "yTable:",yset[ss]
##print ("s:",s+1,"ntot:",ntot,"len_xyset;",len(xset), "ss:",ss, "xy:",xset[ss], yset[ss])
#print ("nrun:",s+1," xCryo:",xset[ss], "yTable:",yset[ss])
#return xset[ss], yset[ss]
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
################################################################
#
# job Options fragment to create LArDigits from LArHits which
......@@ -7,7 +8,7 @@
################################################################
# overall calorimeter noise options (could be set by top jobOptions)
if not 'doCaloNoise' in dir():
if 'doCaloNoise' not in dir():
doCaloNoise = True
# We also need the conditions svc for MC constants:
......@@ -21,11 +22,10 @@ topSequence = AlgSequence()
#theApp.Dlls += [ "LArTools","LArCalibUtils" ]
#ToolSvc = Service( "ToolSvc" )
from Digitization.DigitizationFlags import jobproperties
from AthenaCommon.ConfigurableDb import getConfigurable
from AthenaCommon.AppMgr import ToolSvc
from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault
theADC2MeVTool = LArADC2MeVToolDefault()
theADC2MeVTool.MCSym=TRUE
theADC2MeVTool.MCSym=True
ToolSvc += theADC2MeVTool
# The following are properties for LArDigitization:
isOverlay = False
......@@ -33,13 +33,13 @@ useLArFloat = True
# get main tool which does the real work
from LArDigitization.LArPileUpToolDefault import LArPileUpToolDefault
theLArPileUpTool = LArPileUpToolDefault(useLArFloat,isOverlay,"LArDigitContainer_MC","LArPileUpTool")
theLArPileUpTool.UseTriggerTime = TRUE
theLArPileUpTool.UseTriggerTime = True
theLArPileUpTool.TriggerTimeToolName = "LArTBH6TriggerTimeTool"
# ................... electronic noise
if doCaloNoise:
theLArPileUpTool.NoiseOnOff = TRUE # if true, noise added in all subdetectors
theLArPileUpTool.NoiseOnOff = True # if true, noise added in all subdetectors
else:
theLArPileUpTool.NoiseOnOff = FALSE
theLArPileUpTool.NoiseOnOff = False
#
# --------------------------------------------------------
......@@ -103,13 +103,13 @@ theLArPileUpTool.EnergyThresh = -99.
#
# .................. switches on the noise
#put false if you want cancel the noise in one or several sub-detectors
theLArPileUpTool.NoiseInEMB = FALSE; # if false, noise in Barrel is off
theLArPileUpTool.NoiseInEMEC = TRUE; # if false, noise in EndCap is off
theLArPileUpTool.NoiseInHEC = TRUE; # if false, noise in HEC is off
theLArPileUpTool.NoiseInFCAL = TRUE; # if false, noise in FCAL is off
theLArPileUpTool.NoiseInEMB = False # if false, noise in Barrel is off
theLArPileUpTool.NoiseInEMEC = True # if false, noise in EndCap is off
theLArPileUpTool.NoiseInHEC = True # if false, noise in HEC is off
theLArPileUpTool.NoiseInFCAL = True # if false, noise in FCAL is off
#
# .................... turn on cross-talk in EM calorimeter
theLArPileUpTool.CrossTalk = TRUE
theLArPileUpTool.CrossTalk = True
#
# ..................... Pile up turned off
# ... use new calibration classes
......
#!/usr/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
__doc__ = """Run Geant4 simulation on generated events and produce a HITS file."""
......@@ -52,7 +53,7 @@ class CTBH62004G4JobTransform( JobTransform ):
#install the DBRelease 'by hand' (needed since preRunAction()'s are not called)
#self.getArgument('DBRelease').install()
# get the list of arguments to be used in sub-transforms
argDict = self.argumentOriginalDict()
#argDict = self.argumentOriginalDict()
# no need to re-install the DBRelease in sub-transforms
#argDict['DBRelease'] = 'NONE'
#
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#==============================================================
#
# Job options file for Digitization
......@@ -7,19 +8,19 @@
#==============================================================
# Number of events to be processed (default is 10)
if (not "EvtMax" in dir()):
if ("EvtMax" not in dir()):
EvtMax = 10
if (not "doCaloNoise" in dir()):
doCaloNoise = TRUE
if ("doCaloNoise" not in dir()):
doCaloNoise = True
if (not "PoolHitsInput" in dir()):
if ("PoolHitsInput" not in dir()):
PoolHitsInput = [ "Test.pool.root" ]
if (not "PoolRDOOutput" in dir()):
if ("PoolRDOOutput" not in dir()):
PoolRDOOutput = "TestDigi.pool.root"
if (not "SkipEvents" in dir()):
if ("SkipEvents" not in dir()):
SkipEvents = 0
import AthenaCommon.AtlasUnixStandardJob
......@@ -85,8 +86,8 @@ if DetFlags.writeRDOPool.any_on():
# Pool Output
from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream
Stream1 = AthenaPoolOutputStream("Stream1")
Stream1.ItemList+=["EventInfo#*"];
Stream1.ItemList+=["TBEventInfo#*"];
Stream1.ItemList+=["EventInfo#*"]
Stream1.ItemList+=["TBEventInfo#*"]
Stream1.ItemList+=["McEventCollection#*"]
Stream1.OutputFile = PoolRDOOutput
......@@ -138,15 +139,15 @@ if DetFlags.LAr_on():
ToolSvc += LArTBH6TriggerTimeTool()
from LArRecUtils.LArOFCToolDefault import LArOFCToolDefault
theLArOFCTool = LArOFCToolDefault()
theLArOFCTool.FromDatabase=FALSE
theLArOFCTool.FromDatabase=False
ToolSvc += theLArOFCTool
ToolSvc.LArTBH6TriggerTimeTool.isFixed=TRUE
ToolSvc.LArTBH6TriggerTimeTool.isFixed=True
ToolSvc.LArTBH6TriggerTimeTool.FixedTime = 83. #maybe this one
ToolSvc.LArTBH6TriggerTimeTool.OutputLevel = 4
include( "H6G4Sim/LArDigitization_H6G4_jobOptions.py" )
DetDescrCnvSvc.DecodeIdDict = TRUE
DetDescrCnvSvc.DecodeIdDict = True
include( "LArROD/LArROD_jobOptions.py" )
LArRawChannelBuilder.Ecut=0
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# --- Steering flags -----------------------------------------
if not "XCryo" in dir():
if "XCryo" not in dir():
XCryo = 0.
if not "YTable" in dir():
if "YTable" not in dir():
YTable = 0.
if not "BeamE" in dir():
if "BeamE" not in dir():
BeamE = " log 200. 300000."
if not "Xsmear" in dir():
if "Xsmear" not in dir():
Xsmear = 50.
if not "Ysmear" in dir():
if "Ysmear" not in dir():
Ysmear = 50.
if not "EvtMax" in dir():
if "EvtMax" not in dir():
EvtMax = 10
if not "G4seed" in dir():
if "G4seed" not in dir():
G4seed = 1234
if not "GSeed1" in dir():
if "GSeed1" not in dir():
GSeed1 = "2000160768"
if not "GSeed2" in dir():
if "GSeed2" not in dir():
GSeed2 = "643921183"
if not "ParticlePDG" in dir():
if "ParticlePDG" not in dir():
ParticlePDG = "211"
if not "PhysicsList" in dir():
if "PhysicsList" not in dir():
PhysicsList = "QGSP_BERT"
if not "PoolHitsOutput" in dir():
if "PoolHitsOutput" not in dir():
PoolHitsOutput = 'H6LAr_MyOutputFile.root'
if not "SingleRun" in dir():
if "SingleRun" not in dir():
SingleRun = False
if not "doFilter" in dir():
if "doFilter" not in dir():
doFilter = False
if not "doBirk" in dir():
if "doBirk" not in dir():
doBirk = True
# -------- end of steering flags ------------------
......@@ -123,8 +124,8 @@ simFlags.RandomSeedOffset.set_Value_and_Lock(G4seed)
if SingleRun:
try:
Energy=float(BeamE)
except:
print "Wrong energy literal: ",BeamE," using 100 GeV !!!"
except ValueError:
printfunc ("Wrong energy literal: ",BeamE," using 100 GeV !!!")
Energy=100000.
simFlags.PhysicsList.set_Value_and_Lock(PhysicsList)
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
## jO to run H6 TB 2004 simulation
##--------------------------------
if not 'PoolHitsOutput' in dir():
if 'PoolHitsOutput' not in dir():
PoolHitsOutput="H6LAr_MyOutputFile.root"
if not 'EvtMax' in dir():
if 'EvtMax' not in dir():
EvtMax=10
if not 'CryoXPos' in dir():
if 'CryoXPos' not in dir():
CryoXPos=0.
if not 'TableYPos' in dir():
if 'TableYPos' not in dir():
TableYPos=0.
if not 'ParticlePDG' in dir():
if 'ParticlePDG' not in dir():
ParticlePDG='211'
if not 'Energy' in dir():
if 'Energy' not in dir():
Energy=200000
##--------------------------------
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#==============================================================
#
# Job options file for Geant4 Simulations
......@@ -18,7 +19,7 @@ include( "AtlasG4Sim/HitAthenaPoolWriteOptions.py" )
include ("DetDescrCnvSvc/DetStore_joboptions.py")
DetDescrCnvSvc = Service( "DetDescrCnvSvc" )
DetDescrCnvSvc.DecodeIdDict = TRUE
DetDescrCnvSvc.DecodeIdDict = True
include( "CaloIdCnv/CaloIdCnv_joboptions.py" )
include( "G4Svc/jobOptions.G4Svc.py" )
......@@ -43,13 +44,13 @@ theApp.EvtMax = 100
# -----
G4Svc = Service( "G4Svc" )
G4Svc.PhysicsList = "none"
G4Svc.SaveHits = FALSE
G4Svc.Visualize = FALSE
G4Svc.SaveHits = False
G4Svc.Visualize = False
G4Svc.RunVerbosity = 2
G4Svc.EventVerbosity = 0
G4Svc.TrackingVerbosity = 0
G4Svc.Listener = FALSE
G4Svc.InteractiveG4 = FALSE
G4Svc.Listener = False
G4Svc.InteractiveG4 = False
G4Svc.FADSMacro = "env.mac:H6G4LArCal.mac:PhysicsList.mac:Filters.mac"
# ParticleGun
# -----------------
......@@ -59,7 +60,7 @@ import ParticleGun as PG
try:
ParticleGeneratorPDG=' constant '+ParticlePDG
particl = int(ParticlePDG)
except:
except ValueError:
log.warning('tbH6Generator: You are running geantino')
ParticleGeneratorPDG=' constant 999'
particl = 999
......@@ -67,7 +68,7 @@ except:
try:
ParticleGeneratorEnergy=' constant '+ repr(Energy)
energy = float(Energy)
except:
except ValueError:
log.warning('Unknown energy. Set 200 GeV')
ParticleGeneratorEnergy=' constant 200000'
energy = 200000.
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#==============================================================
#
# Job options file for Geant4 Simulations
......@@ -75,13 +76,13 @@ theApp.EvtMax = 1
# -----
G4Svc = Service( "G4Svc" )
G4Svc.PhysicsList = "none"
G4Svc.SaveHits = FALSE
G4Svc.Visualize = FALSE
G4Svc.SaveHits = False
G4Svc.Visualize = False
G4Svc.RunVerbosity = 2
G4Svc.EventVerbosity = 0
G4Svc.TrackingVerbosity = 0
G4Svc.Listener = FALSE
G4Svc.InteractiveG4 = FALSE
G4Svc.Listener = False
G4Svc.InteractiveG4 = False
G4Svc.FADSMacro = "H6G4LArCal2002.mac:PhysicsList.mac"
#--------------------------------------------------------------
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# get the logger
from AthenaCommon.Logging import *
ctbG4log = logging.getLogger('ctbG4')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment