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.Get("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 147 of file SndlhcDigi.py.

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

◆ 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 114 of file SndlhcDigi.py.

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

◆ 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 aHit_TCA = self.digiScifi.ConstructedAt(index)
107 ROOT.std.swap(aHit, aHit_TCA)
108 index+=1
109 for k in mcPoints[detID]:
110 mcLinks.Add(detID,k, mcPoints[detID][k]/norm[detID])
111 mcLinks_TCA = self.digiScifi2MCPoints.ConstructedAt(0)
112 ROOT.std.swap(mcLinks, mcLinks_TCA)
113

◆ finish()

SndlhcDigi.SndlhcDigi.finish (   self)

Definition at line 183 of file SndlhcDigi.py.

183 def finish(self):
184 print('finished writing tree')
185 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: