ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
LArG4ShowerLibFunctions.TestShowerLib Class Reference
Collaboration diagram for LArG4ShowerLibFunctions.TestShowerLib:

Public Member Functions

def __init__ (self)
 
def fromLibs (self, libs)
 
def readFromFile (self, filename)
 
def writeToFile (self, filename)
 
def printInfo (self)
 
def drawHits (self)
 

Public Attributes

 library
 
 detector
 
 particle
 
 release
 
 geometry
 
 geant
 
 phys
 
 comment
 

Detailed Description

Definition at line 35 of file LArG4ShowerLibFunctions.py.

Constructor & Destructor Documentation

◆ __init__()

def LArG4ShowerLibFunctions.TestShowerLib.__init__ (   self)

Definition at line 36 of file LArG4ShowerLibFunctions.py.

36  def __init__(self) :
37  self.library = [] # list of StoredTestShower objs
38  self.detector= ""
39  self.particle= ""
40  self.release= ""
41  self.geometry= ""
42  self.geant= ""
43  self.phys= ""
44  self.comment= ""

Member Function Documentation

◆ drawHits()

def LArG4ShowerLibFunctions.TestShowerLib.drawHits (   self)

Definition at line 222 of file LArG4ShowerLibFunctions.py.

222  def drawHits(self):
223  from ROOT import TH3F
224  from math import sqrt,copysign,log10
225  hits = TH3F("HITS","Hits Distrib",50,1,1000,101,-300,300,100,0,500)
226  containmentZ = TH3F("CONTZ","ContZ Distrib",50,1,1000,101,-300,300,100,0,500)
227  containmentR = TH3F("CONTR","ContR Distrib",50,1,1000,101,-300,300,100,0,500)
228  for storedShower in self.library :
229  containmentR.Fill(log10(storedShower.momentum.e)*333,storedShower.rsize,storedShower.zsize/2,10)
230  containmentR.Fill(log10(storedShower.momentum.e)*333,-storedShower.rsize,storedShower.zsize/2,10)
231  containmentZ.Fill(log10(storedShower.momentum.e)*333,0,storedShower.zsize,10)
232  for hit in storedShower.shower :
233  hits.Fill(log10(storedShower.momentum.e)*333,copysign(sqrt(hit.x*hit.x + hit.y*hit.y),hit.x),hit.z)
234  return hits,containmentZ,containmentR
235 

◆ fromLibs()

def LArG4ShowerLibFunctions.TestShowerLib.fromLibs (   self,
  libs 
)

Definition at line 45 of file LArG4ShowerLibFunctions.py.

45  def fromLibs(self,libs) :
46  for lib in libs :
47  if not isinstance(lib,self.__class__):
48  print ("ERROR: Different types of libs")
49  return False
50  self.detector = libs[0].detector
51  self.particle = libs[0].particle
52  self.release = libs[0].release
53  self.geometry = libs[0].geometry
54  self.geant = libs[0].geant
55  self.phys = libs[0].phys
56  for lib in libs :
57  if ( self.detector != lib.detector or
58  self.particle != lib.particle or
59  self.release != lib.release or
60  self.geometry != lib.geometry or
61  self.geant != lib.geant or
62  self.phys != lib.phys ) :
63  print ("ERROR: DIFFERENT LIBS!!!")
64  return False
65  from datetime import datetime
66  self.comment = "ADDED "+str(datetime.now())
67  for lib in libs :
68  self.library += lib.library
69  return True

◆ printInfo()

def LArG4ShowerLibFunctions.TestShowerLib.printInfo (   self)

Definition at line 220 of file LArG4ShowerLibFunctions.py.

220  def printInfo(self) :
221  pass

◆ readFromFile()

def LArG4ShowerLibFunctions.TestShowerLib.readFromFile (   self,
  filename 
)

Definition at line 70 of file LArG4ShowerLibFunctions.py.

70  def readFromFile(self,filename) :
71  from ROOT import TFile
72  tfile = TFile(filename)
73  try :
74  ver = int(tfile.Get("version").GetVal())
75  except Exception:
76  print ("Not a TestShowerLib: Broken file")
77  tfile.Close()
78  return False
79  if (ver != 10) : #<<<<<<<<<<<<<<<<<<<<<<-------------- lib ver
80  print ("Not a TestShowerLib")
81  tfile.Close()
82  return False
83  meta = tfile.Get("meta")
84  libr = tfile.Get("library")
85  for event in meta :
86  self.detector=str(event.detector)
87  self.particle=str(event.particle)
88  self.release=str(event.release)
89  self.geometry=str(event.geometry)
90  self.geant=str(event.geantVersion)
91  self.phys=str(event.physicsList)
92  self.comment=str(event.comment)
93 
94  state = 0
95 
96  #state == 0 : first line of shower header
97  #state == 1 : second line of sower header
98  #state == 2 : hit
99 
100  for event in libr : #this is quite unclear, but easy to implement
101  if (state == 0) : #first line
102  curShower = StoredTestShower()
103  curShower.vertex.x = event.x
104  curShower.vertex.y = event.y
105  curShower.vertex.z = event.z
106  curShower.zsize = event.time
107  hitsInCurShower = event.e
108  state = 1
109  elif (state == 1) : #shower header
110  curShower.momentum.x = event.x
111  curShower.momentum.y = event.y
112  curShower.momentum.z = event.z
113  curShower.momentum.e = event.e
114  curShower.rsize = event.time
115  if (hitsInCurShower > 0) :
116  state = 2
117  else :
118  self.library.append(curShower)
119  state = 0
120  elif (state == 2) :
121  hit = FourVector()
122  hit.e = event.e
123  hit.x = event.x
124  hit.y = event.y
125  hit.z = event.z
126  hit.time = event.time
127  curShower.shower.append(hit)
128  hitsInCurShower -= 1
129  if (hitsInCurShower == 0) : #last hit
130  self.library.append(curShower)
131  state = 0
132  tfile.Close()
133  if (state != 0) :
134  print ("FILE CORRUPTED!!")
135  return False
136  return True

◆ writeToFile()

def LArG4ShowerLibFunctions.TestShowerLib.writeToFile (   self,
  filename 
)

Definition at line 137 of file LArG4ShowerLibFunctions.py.

137  def writeToFile(self,filename) :
138  from ROOT import TFile,TTree,TParameter
139  from ROOT import gROOT, addressof
140  gROOT.ProcessLine(
141  "struct MyMetaStruct {\
142  Char_t detector[40];\
143  Char_t release[40];\
144  Char_t geometry[40];\
145  Char_t geant[40];\
146  Char_t phys[40];\
147  Char_t comment[400];\
148  Int_t particle;\
149  };" )
150  from ROOT import MyMetaStruct
151  gROOT.ProcessLine(
152  "struct MyStruct {\
153  Float_t x;\
154  Float_t y;\
155  Float_t z;\
156  Float_t e;\
157  Float_t time;\
158  };" )
159  from ROOT import MyStruct
160 
161  tfile = TFile(filename,"RECREATE")
162 
163  ver = TParameter(int)("version",10) #<<<<<<<<<<<<<<<<<<<<<<-------------- lib ver
164  ver.Write("version")
165 
166  meta = TTree()
167  libr = TTree()
168 
169  mmstruct = MyMetaStruct()
170 
171  mmstruct.detector = "%s" % (str(self.detector))
172  mmstruct.particle = int(self.particle)
173  mmstruct.release = "%s" % (str(self.release))
174  mmstruct.geometry = "%s" % (str(self.geometry))
175  mmstruct.geant = "%s" % (str(self.geant))
176  mmstruct.phys = "%s" % (str(self.phys))
177  mmstruct.comment = "%s" % (str(self.comment))
178 
179  meta.Branch("detector",addressof(mmstruct,"detector"),"detector/C")
180  meta.Branch("particle",addressof(mmstruct,"particle"),"particle/I")
181  meta.Branch("release",addressof(mmstruct,"release"),"release/C")
182  meta.Branch("geometry",addressof(mmstruct,"geometry"),"geometry/C")
183  meta.Branch("geantVersion",addressof(mmstruct,"geant"),"geantVersion/C")
184  meta.Branch("physicsList",addressof(mmstruct,"phys"),"physicsList/C")
185  meta.Branch("comment",addressof(mmstruct,"comment"),"physicsList/C")
186 
187  meta.Fill()
188 
189  mstruct = MyStruct()
190 
191  libr.Branch("x",addressof(mstruct,"x"),"x/F")
192  libr.Branch("y",addressof(mstruct,"y"),"y/F")
193  libr.Branch("z",addressof(mstruct,"z"),"z/F")
194  libr.Branch("e",addressof(mstruct,"e"),"e/F")
195  libr.Branch("time",addressof(mstruct,"time"),"time/F")
196 
197  for storedShower in self.library :
198  mstruct.x = storedShower.vertex.x
199  mstruct.y = storedShower.vertex.y
200  mstruct.z = storedShower.vertex.z
201  mstruct.time = storedShower.zsize
202  mstruct.e = len(storedShower.shower)
203  libr.Fill()
204  mstruct.x = storedShower.momentum.x
205  mstruct.y = storedShower.momentum.y
206  mstruct.z = storedShower.momentum.z
207  mstruct.e = storedShower.momentum.e
208  mstruct.time = storedShower.rsize
209  libr.Fill()
210  for hit in storedShower.shower:
211  mstruct.e = hit.e
212  mstruct.x = hit.x
213  mstruct.y = hit.y
214  mstruct.z = hit.z
215  mstruct.time = hit.time
216  libr.Fill()
217  meta.Write("meta")
218  libr.Write("library")
219  tfile.Close()

Member Data Documentation

◆ comment

LArG4ShowerLibFunctions.TestShowerLib.comment

Definition at line 44 of file LArG4ShowerLibFunctions.py.

◆ detector

LArG4ShowerLibFunctions.TestShowerLib.detector

Definition at line 38 of file LArG4ShowerLibFunctions.py.

◆ geant

LArG4ShowerLibFunctions.TestShowerLib.geant

Definition at line 42 of file LArG4ShowerLibFunctions.py.

◆ geometry

LArG4ShowerLibFunctions.TestShowerLib.geometry

Definition at line 41 of file LArG4ShowerLibFunctions.py.

◆ library

LArG4ShowerLibFunctions.TestShowerLib.library

Definition at line 37 of file LArG4ShowerLibFunctions.py.

◆ particle

LArG4ShowerLibFunctions.TestShowerLib.particle

Definition at line 39 of file LArG4ShowerLibFunctions.py.

◆ phys

LArG4ShowerLibFunctions.TestShowerLib.phys

Definition at line 43 of file LArG4ShowerLibFunctions.py.

◆ release

LArG4ShowerLibFunctions.TestShowerLib.release

Definition at line 40 of file LArG4ShowerLibFunctions.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
systematicsTool.readFromFile
def readFromFile(filename, regexFilter=None, regexVeto=None)
Definition: systematicsTool.py:789
systematicsTool.writeToFile
def writeToFile(histDict, fOut)
Definition: systematicsTool.py:1035
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
str
Definition: BTagTrackIpAccessor.cxx:11