SND@LHC Software
Loading...
Searching...
No Matches
SndlhcDigi.SndlhcDigi Class Reference

Public Member Functions

 __init__ (self, fout, makeClusterScifi)
 
 digitize (self)
 
 digitizeScifi (self)
 
 digitizeMuFilter (self)
 
 clusterScifi (self)
 
 finish (self)
 

Public Attributes

 iEvent
 
 fn
 
 sTree
 
 header
 
 eventHeader
 
 digiScifi
 
 digiScifiBranch
 
 digiScifi2MCPoints
 
 digiScifi2MCPointsBranch
 
 scifiDet
 
 mufiDet
 
 fibresSiPM
 
 siPMFibres
 
 makeClusterScifi
 
 clusScifi
 
 clusScifiBranch
 
 digiMuFilter
 
 digiMuFilterBranch
 
 digiMuFilter2MCPoints
 
 digiMuFilter2MCPointsBranch
 

Detailed Description

Definition at line 10 of file SndlhcDigi.py.

Constructor & Destructor Documentation

◆ __init__()

SndlhcDigi.SndlhcDigi.__init__ (   self,
  fout,
  makeClusterScifi 
)

Definition at line 12 of file SndlhcDigi.py.

12 def __init__(self,fout, makeClusterScifi):
13
14 self.iEvent = 0
15
16 outdir=os.getcwd()
17 outfile=outdir+"/"+fout
18 self.fn = ROOT.TFile(fout,'update')
19 self.sTree = self.fn.cbmsim
20
21 # event header
22 self.header = ROOT.SNDLHCEventHeader()
23 self.eventHeader = self.sTree.Branch("EventHeader.",self.header,32000,1)
24 #scifi
25 self.digiScifi = ROOT.TClonesArray("sndScifiHit")
26 self.digiScifiBranch = self.sTree.Branch("Digi_ScifiHits",self.digiScifi,32000,1)
27 self.digiScifi2MCPoints = ROOT.TClonesArray("Hit2MCPoints")
28 self.digiScifi2MCPoints.BypassStreamer(ROOT.kTRUE)
29 self.digiScifi2MCPointsBranch = self.sTree.Branch("Digi_ScifiHits2MCPoints",self.digiScifi2MCPoints,32000,1)
30 lsOfGlobals = ROOT.gROOT.GetListOfGlobals()
31 self.scifiDet = lsOfGlobals.FindObject('Scifi')
32 self.mufiDet = lsOfGlobals.FindObject('MuFilter')
33 if not self.scifiDet or not self.mufiDet:
34 exit('detector(s) not found, stop')
35# make sipm to fibre mapping
36 self.fibresSiPM = SciFiMapping.getFibre2SiPMCPP(self.scifiDet)
37 self.siPMFibres = SciFiMapping.getSiPM2FibreCPP(self.scifiDet)
38
39 #scifi clusters
40 self.makeClusterScifi = makeClusterScifi
41 if self.makeClusterScifi:
42 self.clusScifi = ROOT.TClonesArray("sndCluster")
43 self.clusScifiBranch = self.sTree.Branch("Cluster_Scifi",self.clusScifi,32000,1)
44
45 #muonFilter
46 self.digiMuFilter = ROOT.TClonesArray("MuFilterHit")
47 self.digiMuFilterBranch = self.sTree.Branch("Digi_MuFilterHits",self.digiMuFilter,32000,1)
48 self.digiMuFilter2MCPoints = ROOT.TClonesArray("Hit2MCPoints")
49 self.digiMuFilter2MCPoints.BypassStreamer(ROOT.kTRUE)
50 self.digiMuFilter2MCPointsBranch = self.sTree.Branch("Digi_MuFilterHits2MCPoints",self.digiMuFilter2MCPoints,32000,1)
51
getFibre2SiPMCPP(scifi)
getSiPM2FibreCPP(scifi)

Member Function Documentation

◆ clusterScifi()

SndlhcDigi.SndlhcDigi.clusterScifi (   self)

Definition at line 143 of file SndlhcDigi.py.

143 def clusterScifi(self):
144 index = 0
145 hitDict = {}
146 for k in range(self.sTree.Digi_ScifiHits.GetEntries()):
147 d = self.sTree.Digi_ScifiHits[k]
148 if not d.isValid(): continue
149 hitDict[d.GetDetectorID()] = k
150 hitList = list(hitDict.keys())
151 if len(hitList)>0:
152 hitList.sort()
153 tmp = [ hitList[0] ]
154 cprev = hitList[0]
155 ncl = 0
156 last = len(hitList)-1
157 hitlist = ROOT.std.vector("sndScifiHit*")()
158 for i in range(len(hitList)):
159 if i==0 and len(hitList)>1: continue
160 c=hitList[i]
161 if (c-cprev)==1:
162 tmp.append(c)
163 if (c-cprev)!=1 or c==hitList[last]:
164 first = tmp[0]
165 N = len(tmp)
166 hitlist.clear()
167 for aHit in tmp: hitlist.push_back( self.sTree.Digi_ScifiHits[hitDict[aHit]],)
168 aCluster = ROOT.sndCluster(first,N,hitlist,self.scifiDet)
169 if self.clusScifi.GetSize() == index: self.clusScifi.Expand(index+10)
170 self.clusScifi[index]=aCluster
171 index+=1
172 if c!=hitList[last]:
173 ncl+=1
174 tmp = [c]
175 cprev = c
176
177

◆ digitize()

SndlhcDigi.SndlhcDigi.digitize (   self)

Definition at line 52 of file SndlhcDigi.py.

52 def digitize(self):
53
54 self.header.SetRunId( self.sTree.MCEventHeader.GetRunID() )
55 self.header.SetEventNumber( self.sTree.MCEventHeader.GetEventID() ) # counts from 1
56 self.header.SetBunchType(101);
57 self.eventHeader.Fill()
58 self.digiScifi.Clear('C')
59 self.digiScifi2MCPoints.Clear('C')
60 self.digitizeScifi()
61 self.digiScifiBranch.Fill()
62 self.digiScifi2MCPointsBranch.Fill()
63 if self.makeClusterScifi:
64 self.clusScifi.Clear('C')
65 self.clusterScifi()
66 self.clusScifiBranch.Fill()
67
68 self.digiMuFilter.Clear('C')
69 self.digiMuFilter2MCPoints.Clear('C')
70 self.digitizeMuFilter()
71 self.digiMuFilterBranch.Fill()
72 self.digiMuFilter2MCPointsBranch.Fill()
73

◆ digitizeMuFilter()

SndlhcDigi.SndlhcDigi.digitizeMuFilter (   self)

Definition at line 112 of file SndlhcDigi.py.

112 def digitizeMuFilter(self):
113 hitContainer = {}
114 mcLinks = ROOT.Hit2MCPoints()
115 mcPoints = {}
116 norm = {}
117 k=-1
118 for p in self.sTree.MuFilterPoint:
119 k+=1
120 # collect all hits in same detector element
121 detID = p.GetDetectorID()
122 if not detID in hitContainer:
123 hitContainer[detID]=[]
124 mcPoints[detID] = {}
125 norm[detID] = 0
126 hitContainer[detID].append(p)
127 mcPoints[detID][k]=p.GetEnergyLoss()
128 norm[detID]+= p.GetEnergyLoss()
129 index = 0
130 for detID in hitContainer:
131 allPoints = ROOT.std.vector('MuFilterPoint*')()
132 for p in hitContainer[detID]:
133 allPoints.push_back(p)
134 aHit = ROOT.MuFilterHit(detID,allPoints)
135
136 if self.digiMuFilter.GetSize() == index: self.digiMuFilter.Expand(index+100)
137 self.digiMuFilter[index]=aHit
138 index+=1
139 for k in mcPoints[detID]:
140 mcLinks.Add(detID,k, mcPoints[detID][k]/norm[detID])
141 self.digiMuFilter2MCPoints[0]=mcLinks
142

◆ digitizeScifi()

SndlhcDigi.SndlhcDigi.digitizeScifi (   self)

Definition at line 74 of file SndlhcDigi.py.

74 def digitizeScifi(self):
75 hitContainer = {}
76 mcLinks = ROOT.Hit2MCPoints()
77 mcPoints = {}
78 norm = {}
79 k=-1
80 for p in self.sTree.ScifiPoint:
81 k+=1
82 # collect all hits in same SiPM channel
83 detID = p.GetDetectorID()
84 locFibreID = detID%100000
85 if not locFibreID in self.siPMFibres: continue # fibres in dead areas
86 for sipmChan in self.siPMFibres[locFibreID]:
87 globsipmChan = int(detID/100000)*100000+sipmChan
88 if not globsipmChan in hitContainer:
89 hitContainer[globsipmChan]=[]
90 mcPoints[globsipmChan] = {}
91 norm[globsipmChan] = 0
92 w = self.siPMFibres[locFibreID][sipmChan]['weight']
93 hitContainer[globsipmChan].append([p,w])
94 dE = p.GetEnergyLoss()*w
95 mcPoints[globsipmChan][k]=dE
96 norm[globsipmChan]+= dE
97 index = 0
98 for detID in hitContainer:
99 allPoints = ROOT.std.vector('ScifiPoint*')()
100 allWeights = ROOT.std.vector('Float_t')()
101 for p in hitContainer[detID]:
102 allPoints.push_back(p[0])
103 allWeights.push_back(p[1])
104 aHit = ROOT.sndScifiHit(detID,allPoints,allWeights)
105 if self.digiScifi.GetSize() == index: self.digiScifi.Expand(index+100)
106 self.digiScifi[index]=aHit
107 index+=1
108 for k in mcPoints[detID]:
109 mcLinks.Add(detID,k, mcPoints[detID][k]/norm[detID])
110 self.digiScifi2MCPoints[0]=mcLinks
111

◆ finish()

SndlhcDigi.SndlhcDigi.finish (   self)

Definition at line 178 of file SndlhcDigi.py.

178 def finish(self):
179 print('finished writing tree')
180 self.sTree.Write()

Member Data Documentation

◆ clusScifi

SndlhcDigi.SndlhcDigi.clusScifi

Definition at line 42 of file SndlhcDigi.py.

◆ clusScifiBranch

SndlhcDigi.SndlhcDigi.clusScifiBranch

Definition at line 43 of file SndlhcDigi.py.

◆ digiMuFilter

SndlhcDigi.SndlhcDigi.digiMuFilter

Definition at line 46 of file SndlhcDigi.py.

◆ digiMuFilter2MCPoints

SndlhcDigi.SndlhcDigi.digiMuFilter2MCPoints

Definition at line 48 of file SndlhcDigi.py.

◆ digiMuFilter2MCPointsBranch

SndlhcDigi.SndlhcDigi.digiMuFilter2MCPointsBranch

Definition at line 50 of file SndlhcDigi.py.

◆ digiMuFilterBranch

SndlhcDigi.SndlhcDigi.digiMuFilterBranch

Definition at line 47 of file SndlhcDigi.py.

◆ digiScifi

SndlhcDigi.SndlhcDigi.digiScifi

Definition at line 25 of file SndlhcDigi.py.

◆ digiScifi2MCPoints

SndlhcDigi.SndlhcDigi.digiScifi2MCPoints

Definition at line 27 of file SndlhcDigi.py.

◆ digiScifi2MCPointsBranch

SndlhcDigi.SndlhcDigi.digiScifi2MCPointsBranch

Definition at line 29 of file SndlhcDigi.py.

◆ digiScifiBranch

SndlhcDigi.SndlhcDigi.digiScifiBranch

Definition at line 26 of file SndlhcDigi.py.

◆ eventHeader

SndlhcDigi.SndlhcDigi.eventHeader

Definition at line 23 of file SndlhcDigi.py.

◆ fibresSiPM

SndlhcDigi.SndlhcDigi.fibresSiPM

Definition at line 36 of file SndlhcDigi.py.

◆ fn

SndlhcDigi.SndlhcDigi.fn

Definition at line 18 of file SndlhcDigi.py.

◆ header

SndlhcDigi.SndlhcDigi.header

Definition at line 22 of file SndlhcDigi.py.

◆ iEvent

SndlhcDigi.SndlhcDigi.iEvent

Definition at line 14 of file SndlhcDigi.py.

◆ makeClusterScifi

SndlhcDigi.SndlhcDigi.makeClusterScifi

Definition at line 40 of file SndlhcDigi.py.

◆ mufiDet

SndlhcDigi.SndlhcDigi.mufiDet

Definition at line 32 of file SndlhcDigi.py.

◆ scifiDet

SndlhcDigi.SndlhcDigi.scifiDet

Definition at line 31 of file SndlhcDigi.py.

◆ siPMFibres

SndlhcDigi.SndlhcDigi.siPMFibres

Definition at line 37 of file SndlhcDigi.py.

◆ sTree

SndlhcDigi.SndlhcDigi.sTree

Definition at line 19 of file SndlhcDigi.py.


The documentation for this class was generated from the following file: