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 36 of file LArG4ShowerLibFunctions.py.

Constructor & Destructor Documentation

◆ __init__()

def LArG4ShowerLibFunctions.TestShowerLib.__init__ (   self)

Definition at line 37 of file LArG4ShowerLibFunctions.py.

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

Member Function Documentation

◆ drawHits()

def LArG4ShowerLibFunctions.TestShowerLib.drawHits (   self)

Definition at line 223 of file LArG4ShowerLibFunctions.py.

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

◆ fromLibs()

def LArG4ShowerLibFunctions.TestShowerLib.fromLibs (   self,
  libs 
)

Definition at line 46 of file LArG4ShowerLibFunctions.py.

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

◆ printInfo()

def LArG4ShowerLibFunctions.TestShowerLib.printInfo (   self)

Definition at line 221 of file LArG4ShowerLibFunctions.py.

221  def printInfo(self) :
222  pass

◆ readFromFile()

def LArG4ShowerLibFunctions.TestShowerLib.readFromFile (   self,
  filename 
)

Definition at line 71 of file LArG4ShowerLibFunctions.py.

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

◆ writeToFile()

def LArG4ShowerLibFunctions.TestShowerLib.writeToFile (   self,
  filename 
)

Definition at line 138 of file LArG4ShowerLibFunctions.py.

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

Member Data Documentation

◆ comment

LArG4ShowerLibFunctions.TestShowerLib.comment

Definition at line 45 of file LArG4ShowerLibFunctions.py.

◆ detector

LArG4ShowerLibFunctions.TestShowerLib.detector

Definition at line 39 of file LArG4ShowerLibFunctions.py.

◆ geant

LArG4ShowerLibFunctions.TestShowerLib.geant

Definition at line 43 of file LArG4ShowerLibFunctions.py.

◆ geometry

LArG4ShowerLibFunctions.TestShowerLib.geometry

Definition at line 42 of file LArG4ShowerLibFunctions.py.

◆ library

LArG4ShowerLibFunctions.TestShowerLib.library

Definition at line 38 of file LArG4ShowerLibFunctions.py.

◆ particle

LArG4ShowerLibFunctions.TestShowerLib.particle

Definition at line 40 of file LArG4ShowerLibFunctions.py.

◆ phys

LArG4ShowerLibFunctions.TestShowerLib.phys

Definition at line 44 of file LArG4ShowerLibFunctions.py.

◆ release

LArG4ShowerLibFunctions.TestShowerLib.release

Definition at line 41 of file LArG4ShowerLibFunctions.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
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.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11