Skip to content

Commit c120774

Browse files
Implement G4VHitsCollection overrides
1 parent 117e60a commit c120774

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

examples/B2/exampleB2a.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def __getitem__(self, i):
7777
def insert(self, item):
7878
self.collection.append(item)
7979

80-
def entries(self):
81-
return len(self.collection)
80+
def GetHit(self, i):
81+
return self.collection[i]
8282

8383
def GetSize(self):
8484
return len(self.collection)
@@ -117,7 +117,7 @@ def ProcessHits(self, aStep, rOhist):
117117

118118
def EndOfEvent(self, hce):
119119
if self.verboseLevel > 1:
120-
nofHits = self.fHitsCollection.entries()
120+
nofHits = self.fHitsCollection.GetSize()
121121
print("-------->Hits Collection: in this event there are", nofHits,
122122
"hits in the tracker chambers:")
123123
for i in range(nofHits):
@@ -399,7 +399,7 @@ def EndOfEventAction(self, event):
399399
trajectoryContainer = event.GetTrajectoryContainer()
400400
n_trajectories = 0
401401
if trajectoryContainer != None:
402-
n_trajectories = trajectoryContainer.entries()
402+
n_trajectories = trajectoryContainer.GetSize()
403403

404404
# periodic printing
405405
eventID = event.GetEventID()

examples/B2/exampleB2b.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def __getitem__(self, i):
7777
def insert(self, item):
7878
self.collection.append(item)
7979

80-
def entries(self):
81-
return len(self.collection)
80+
def GetHit(self, i):
81+
return self.collection[i]
8282

8383
def GetSize(self):
8484
return len(self.collection)
@@ -117,7 +117,7 @@ def ProcessHits(self, aStep, rOhist):
117117

118118
def EndOfEvent(self, hce):
119119
if self.verboseLevel > 1:
120-
nofHits = self.fHitsCollection.entries()
120+
nofHits = self.fHitsCollection.GetSize()
121121
print("-------->Hits Collection: in this event there are", nofHits,
122122
"hits in the tracker chambers:")
123123
for i in range(nofHits):
@@ -423,7 +423,7 @@ def EndOfEventAction(self, event):
423423
trajectoryContainer = event.GetTrajectoryContainer()
424424
n_trajectories = 0
425425
if trajectoryContainer != None:
426-
n_trajectories = trajectoryContainer.entries()
426+
n_trajectories = trajectoryContainer.GetSize()
427427

428428
# periodic printing
429429
eventID = event.GetEventID()

examples/B4/exampleB4c.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ def __getitem__(self, i):
244244
def insert(self, item):
245245
self.collection.append(item)
246246

247-
def entries(self):
247+
def GetHit(self, i):
248+
return self.collection[i]
249+
250+
def GetSize(self):
248251
return len(self.collection)
249252

250253

@@ -294,7 +297,7 @@ def ProcessHits(self, step, history):
294297
"MyCode0004", FatalException, msg)
295298

296299
# Get hit for total accounting
297-
hitTotal = self.fHitsCollection[self.fHitsCollection.entries()-1]
300+
hitTotal = self.fHitsCollection[self.fHitsCollection.GetSize()-1]
298301

299302
# Add values
300303
hit.Add(edep, stepLength)
@@ -304,7 +307,7 @@ def ProcessHits(self, step, history):
304307

305308
def EndOfEvent(self, hCofThisEvent):
306309
if self.verboseLevel > 1:
307-
nofHits = self.fHitsCollection.entries()
310+
nofHits = self.fHitsCollection.GetSize()
308311
print("")
309312
print("-------->Hits Collection: in this event they are", nofHits, end="")
310313
print(" hits in the tracker chambers: ")
@@ -340,8 +343,8 @@ def EndOfEventAction(self, event):
340343
gapHC = self.GetHitsCollection(self.fGapHCID, event)
341344

342345
# Get hit with total values
343-
absoHit = absoHC[absoHC.entries()-1]
344-
gapHit = gapHC[gapHC.entries()-1]
346+
absoHit = absoHC[absoHC.GetSize()-1]
347+
gapHit = gapHC[gapHC.GetSize()-1]
345348

346349
# Print per event (modulo n)
347350
eventID = event.GetEventID()

examples/B5/exampleB5.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,12 @@ def __getitem__(self, i):
383383
def insert(self, item):
384384
self.collection.append(item)
385385

386-
def entries(self):
386+
def GetSize(self):
387387
return len(self.collection)
388388

389+
def GetHit(self, i):
390+
return self.collection[i]
391+
389392
def __iter__(self):
390393
return self.collection.__iter__()
391394

@@ -744,7 +747,7 @@ def ProcessHits(self, step, touchableHist):
744747

745748
# check if this finger already has a hit
746749
ix = -1
747-
for i in range(0, self.fHitsCollection.entries()):
750+
for i in range(0, self.fHitsCollection.GetSize()):
748751
if self.fHitsCollection[i].fId == copyNo:
749752
ix = i
750753
break
@@ -925,7 +928,7 @@ def EndOfEventAction(self, event):
925928
if hc == None:
926929
return
927930

928-
nhit = hc.entries()
931+
nhit = hc.GetSize()
929932
analysisManager.FillH1(self.fDriftHistoID[0][iDet], nhit)
930933

931934
# columns 0, 1
@@ -988,7 +991,7 @@ def EndOfEventAction(self, event):
988991
if hc == None:
989992
return
990993

991-
print("Hodoscope", iDet + 1, "has", hc.entries(), "hits.")
994+
print("Hodoscope", iDet + 1, "has", hc.GetSize(), "hits.")
992995
for hit in hc:
993996
hit.Print()
994997

@@ -998,7 +1001,7 @@ def EndOfEventAction(self, event):
9981001
if hc == None:
9991002
return
10001003

1001-
print("Drift Chamber", iDet + 1, "has", hc.entries(), "hits.")
1004+
print("Drift Chamber", iDet + 1, "has", hc.GetSize(), "hits.")
10021005
for layer in range(0, kNofChambers):
10031006
for hit in hc:
10041007
if hit.fLayerID == layer:

0 commit comments

Comments
 (0)