14 " raw data conversion by event "
20 if (options.path.find(
'eos')<0
and options.server.find(
'root://')<0
and not options.online)
or os.path.isdir(options.path): local =
True
23 server = options.server
24 from XRootD
import client
26 if options.runNumber>0:
27 runNr = str(options.runNumber).zfill(6)
28 path = options.path+
'run_'+ runNr+
'/'
29 if options.partition < 0:
33 part = str(options.partition).zfill(4)
34 inFile =
'data_'+part+
'.root'
35 self.
outFile =
"sndsw_raw_"+runNr+
'-'+part+
'.root'
37 server = options.server
38 runNr = str( abs(options.runNumber) ).zfill(6)
39 path = options.path+
'run_'+ runNr+
'/'
40 inFile =
'data_'+part+
'.root'
41 self.
outFile = ROOT.TMemFile(
'monitorRawData',
'recreate')
46 if options.path.find(
'2022')!=-1: fpath =
"/eos/experiment/sndlhc/convertedData/physics/2022/"
47 elif options.path.find(
'2023')!=-1: fpath =
"/eos/experiment/sndlhc/convertedData/physics/2023/"
48 elif options.path.find(
'2024')!=-1: fpath =
"/eos/experiment/sndlhc/convertedData/physics/2024/"
49 elif options.path.find(
'2025')!=-1: fpath =
"/eos/experiment/sndlhc/convertedData/physics/2025/"
50 else: fpath =
"/eos/experiment/sndlhc/convertedData/commissioning/TI18/"
51 fg = ROOT.TFile.Open(options.server+fpath+
"/FSdict.root")
53 FSdict = pkl.load(
'FSdict')
55 if options.runNumber
in FSdict:
56 if 'B1' in FSdict[options.runNumber]: self.
fsdict = FSdict[options.runNumber]
58 print(
'continue without knowing filling scheme',options.server+options.path)
66 if self.
fsdict[
'phaseShift2'] == 0
or self.
fsdict[
'phaseShift2'] == 1718:
69 for bunchNumber
in range (0, Nbunches):
70 nb1 = (Nbunches + bunchNumber - self.
fsdict[
'phaseShift1'])%Nbunches
71 nb2 = (Nbunches + bunchNumber - self.
fsdict[
'phaseShift1']- self.
fsdict[
'phaseShift2'])%Nbunches
72 b1 = nb1
in self.
fsdict[
'B1']
73 b2 = nb2
in self.
fsdict[
'B2']
77 IP1 = self.
fsdict[
'B1'][nb1][
'IP1']
79 IP2 = self.
fsdict[
'B2'][nb2][
'IP2']
80 self.
FSmap.Add(ROOT.TObjString(str(bunchNumber)), ROOT.TObjString(str(int(IP2))+str(int(IP1))+str(int(b2))+str(int(b1))))
81 else: self.
FSmap.Add(ROOT.TObjString(
"0"), ROOT.TObjString(
"-1"))
83 self.
run = ROOT.FairRunAna()
84 self.
ioman = ROOT.FairRootManager.Instance()
88 mpath = options.path+options.monitorTag+
'run_'+ runNr+
'/'
89 self.
fiN=ROOT.TFile.Open(server+mpath+inFile)
91 self.
fiN=ROOT.TFile.Open(server+path+inFile)
97 if options.nEvents<0: self.
nEvents = self.
fiN.Get(
"data").GetEntries()
98 else: self.
nEvents = min(options.nEvents,self.
fiN.Get(
"data").GetEntries())
100 if options.nEvents<0: self.
nEvents = self.
fiN.Get(
"event").GetEntries()
101 else: self.
nEvents = min(options.nEvents,self.
fiN.Get(
"event").GetEntries())
102 print(
'converting ',self.
nEvents,
' events ',
' of run',options.runNumber)
104 ioman.RegisterInputObject(
'runN', ROOT.TObjString(str(options.runNumber)))
105 ioman.RegisterInputObject(
'pathCalib', ROOT.TObjString(server+path))
106 ioman.RegisterInputObject(
'pathJSON', ROOT.TObjString(server+path))
107 ioman.RegisterInputObject(
'nEvents', ROOT.TObjString(str(self.
nEvents)))
108 ioman.RegisterInputObject(
'nStart', ROOT.TObjString(str(options.nStart)))
109 ioman.RegisterInputObject(
'debug', ROOT.TObjString(str(options.debug)))
110 ioman.RegisterInputObject(
'stop', ROOT.TObjString(str(options.stop)))
111 ioman.RegisterInputObject(
'heartBeat', ROOT.TObjString(str(options.heartBeat)))
112 ioman.RegisterInputObject(
'makeCalibration', ROOT.TObjString(str(int(options.makeCalibration))))
113 ioman.RegisterInputObject(
'chi2Max', ROOT.TObjString(str(options.chi2Max)))
114 ioman.RegisterInputObject(
'saturationLimit', ROOT.TObjString(str(options.saturationLimit)))
115 ioman.RegisterInputObject(
'local', ROOT.TObjString(str(int(local))))
116 ioman.RegisterInputObject(
'newFormat', ROOT.TObjString(str(int(self.
newFormat))))
117 ioman.RegisterInputObject(
'FSmap', self.
FSmap)
121 logger = ROOT.FairLogger.GetLogger()
122 logger.SetColoredLog(
True)
123 logger.SetLogVerbosityLevel(
'low')
124 logger.SetLogScreenLevel(
'error')
125 logger.SetLogToScreen(
True)
127 logger.SetLogToFile(
True)
128 logger.SetLogFileName(
'run_'+str(options.runNumber)+
'-'+part+
'_CPP.log')
129 logger.SetLogFileLevel(
'info')
130 logger.SetLogScreenLevel(
'info')
133 ioman.RegisterInputObject(
"rawData", self.
fiN)
137 elif options.FairTask_convRaw: self.
outfile = ROOT.FairRootFileSink(self.
outFile.replace(
'.root',
'_CPP.root'))
142 self.
run.SetEventHeaderPersistence(
False)
143 self.
xrdb = ROOT.FairRuntimeDb.instance()
144 self.
xrdb.getContainer(
"FairBaseParSet").setStatic()
145 self.
xrdb.getContainer(
"FairGeoParSet").setStatic()
147 if options.FairTask_convRaw:
148 self.
run.AddTask(ROOT.ConvRawData())
156 if options.makeCalibration:
158 fqdc_cal = open(path+
'/qdc_cal.csv')
159 Lqdc = fqdc_cal.readlines()
160 ftdc_cal = open(path+
'/tdc_cal.csv')
161 Ltdc = ftdc_cal.readlines()
163 with client.File()
as f:
164 f.open(server+path+
"/qdc_cal.csv")
166 Lqdc = L.decode().split(
'\n')
168 f.open(server+path+
"/tdc_cal.csv")
170 Ltdc = L.decode().split(
'\n')
176 for l
in range(1,len(L)):
177 tmp = L[l].replace(
'\n',
'').split(
',')
178 if len(tmp)<10:
continue
179 board_id = int(tmp[0])
180 if not board_id
in qdc_cal: qdc_cal[board_id]={}
182 if not fe_id
in qdc_cal[board_id]: qdc_cal[board_id][fe_id]={}
183 channel = int(tmp[2])
184 if not channel
in qdc_cal[board_id][fe_id]: qdc_cal[board_id][fe_id][channel]={}
186 if not tac
in qdc_cal[board_id][fe_id][channel]: qdc_cal[board_id][fe_id][channel][tac]={}
187 X = qdc_cal[board_id][fe_id][channel][tac]
192 X[
'e']=float(tmp[10])
193 if float(tmp[9]) < 2: X[
'chi2Ndof'] = 999999.
194 else: X[
'chi2Ndof']=float(tmp[7])/float(tmp[9])
197 for l
in range(1,len(L)):
198 tmp = L[l].replace(
'\n',
'').split(
',')
199 if len(tmp)<9:
continue
200 board_id = int(tmp[0])
201 if not board_id
in qdc_cal: qdc_cal[board_id]={}
203 if not fe_id
in qdc_cal[board_id]: qdc_cal[board_id][fe_id]={}
204 channel = int(tmp[2])
205 if not channel
in qdc_cal[board_id][fe_id]: qdc_cal[board_id][fe_id][channel]={}
207 if not tac
in qdc_cal[board_id][fe_id][channel]: qdc_cal[board_id][fe_id][channel][tac]={}
209 if not tdc
in qdc_cal[board_id][fe_id][channel][tac]: qdc_cal[board_id][fe_id][channel][tac][tdc]={}
210 X = qdc_cal[board_id][fe_id][channel][tac][tdc]
215 if float(tmp[10]) < 2: X[
'chi2Ndof'] = 999999.
216 else: X[
'chi2Ndof']=float(tmp[8])/float(tmp[10])
221 key = {
'DS':2,
'US':1,
'Veto':0}
222 sndswPath = os.environ[
'SNDSW_ROOT']
224 infile = sndswPath+
"/geometry/"+system+
"_SiPM_mapping.csv"
226 if os.path.isdir(sndswPath+
"/geometry"):
227 with open(infile,
"r")
as f:
228 reader = csv.DictReader(f, delimiter=
',')
229 for i, row
in enumerate(reader):
230 SiPMmap[system][int(row[
'SiPM'])] = [int(row[
'CN']), int(row[
'pin']), int(row[
'TOFPET']), int(row[
'CHANNEL'])]
232 for channel
in SiPMmap[system]:
233 row = SiPMmap[system][channel]
234 self.
TofpetMap[key[system]][row[2]*1000+row[3]] = channel
236 with open(path+
'board_mapping.json')
as f:
239 with client.File()
as f:
240 f.open(server+path+
"/board_mapping.json")
241 status, jsonStr = f.read()
245 self.
slots = {0:
'A',1:
'A',2:
'B',3:
'B',4:
'C',5:
'C',6:
'D',7:
'D'}
249 board_id = int(b.split(
'_')[1])
252 for slot
in self.
slots:
254 tmp = self.
boardMaps[
'MuFilter'][b][x].split(
'_')[0]
256 elif tmp==
'DS': s = 2
262 for o
in [
'Left',
'Right']:
263 self.
offMap[
'Veto_'+str(s)+o] =[10000 + (s-1)*1000+ 0,8,2]
264 self.
offMap[
'Veto_3Vert'] = [10000 + 2*1000+ 6,-8,1]
266 for o
in [
'Left',
'Right']:
267 self.
offMap[
'US_'+str(s)+o] =[20000 + (s-1)*1000+ 9,-8,2]
270 self.
offMap[
'DS_'+str(s)+o] =[30000 + (s-1)*1000+ 119, -1,1]
272 for o
in [
'Left',
'Right']:
273 self.
offMap[
'DS_'+str(s)+o] =[30000 + (s-1)*1000+ 59,-1,2]
276 for b
in self.
fiN.GetListOfKeys():
278 if name.find(
'board')!=0:
continue
282 self.
sTree = ROOT.TTree(
'rawConv',
'raw data converted')
283 ROOT.gDirectory.pwd()
294 B.SetName(
'BranchList')
295 B.Add(ROOT.TObjString(
'sndScifiHit'))
296 B.Add(ROOT.TObjString(
'MuFilterHit'))
297 B.Add(ROOT.TObjString(
'SNDLHCEventHeader'))
298 self.
fSink.WriteObject(B,
"BranchList", ROOT.TObject.kSingleKey)
299 self.
fSink.SetRunId(options.runNumber)
306 def channel(self,tofpet_id,tofpet_channel,position):
307 return (64 * tofpet_id + 63 - tofpet_channel + 512*position)
311 def qdc_chi2(self,board_id,tofpet_id,channel,tac,TDC=0):
313 par = qdc_cal[board_id][tofpet_id][channel][tac]
314 parT = qdc_cal[board_id][tofpet_id][channel][tac][TDC]
315 return max(par[
'chi2Ndof'],parT[
'chi2Ndof'])
317 def qdc_sat(self,board_id,tofpet_id,channel,tac,v_fine):
319 par = qdc_cal[board_id][tofpet_id][channel][tac]
320 return v_fine/par[
'd']
322 def comb_calibration(self,board_id,tofpet_id,channel,tac,v_coarse,v_fine,t_coarse,t_fine,GQDC = 1.0, TDC=0):
324 par = qdc_cal[board_id][tofpet_id][channel][tac]
327 ftdc = (-parT[
'b']-ROOT.TMath.Sqrt(parT[
'b']**2-4*parT[
'a']*(parT[
'c']-x)))/(2*parT[
'a'])
328 timestamp = t_coarse + ftdc
329 tf = timestamp - t_coarse
331 fqdc = -par[
'c']*ROOT.TMath.Log(1+ROOT.TMath.Exp( par[
'a']*(x-par[
'e'])**2-par[
'b']*(x-par[
'e']) )) + par[
'd']
332 value = (v_fine-fqdc)/GQDC
333 return timestamp,value,max(par[
'chi2Ndof'],parT[
'chi2Ndof']),v_fine/par[
'd']
341 for c
in qdc_cal[b][t]:
342 for tac
in qdc_cal[b][t][c]:
343 par = qdc_cal[b][t][c][tac]
344 if 'chi2Ndof' in par: chi2 = par[
'chi2Ndof']
346 parT = qdc_cal[b][t][c][tac][TDC]
347 if 'chi2Ndof' in parT: chi2T = parT[
'chi2Ndof']
349 key = tac +10*c + t*10*100 + b*10*100*100
350 if not key
in report: report[key]=[chi2,chi2T]
354 key = (tofpet_id%2)*1000 + tofpet_channel
355 tmp = boardMaps[
'MuFilter'][board][self.
slots[tofpet_id]]
356 sipmChannel = TofpetMap[system][key]-1
357 nSiPMs = abs(offMap[tmp][1])
358 nSides = abs(offMap[tmp][2])
359 direction = int(offMap[tmp][1]/nSiPMs)
360 detID = offMap[tmp][0] + direction*(sipmChannel//(nSiPMs))
361 sipm_number = sipmChannel%(nSiPMs)
362 print(sipmChannel,nSiPMs,nSides,detID,sipm_number)
365 runNr = str( abs(self.
options.runNumber) ).zfill(6)
366 path = self.
options.path+
'run_'+ runNr+
'/'
367 from XRootD
import client
368 with client.File()
as f:
369 f.open(self.
options.server+path+
"/channels.csv")
376 filename =
"currently_processed_file.txt"
378 from XRootD
import client
379 with client.File()
as f:
380 f.open(self.
options.server+path+filename)
384 for l
in self.
Lcrun: print(l)
387 runNr = str( abs(self.
options.runNumber) ).zfill(6)
388 path = self.
options.path+
'run_'+ runNr+
'/'
389 jname =
"run_timestamps.json"
390 from XRootD
import client
391 with client.File()
as f:
392 f.open(self.
options.server+path+jname)
393 status, jsonStr = f.read()
395 date = json.loads(jsonStr)
396 time_str = date[
'start_time'].replace(
'Z',
'')
397 time_obj = time.strptime(time_str,
'%Y-%m-%dT%H:%M:%S')
398 startTimeOfRun = calendar.timegm(time_obj)
399 return startTimeOfRun
411 if self.
options.FairTask_convRaw:
422 if self.
options.FairTask_convRaw:
425 self.
run.GetTask(
"ConvRawData").UpdateInput(eventNumber)
427 Fout = self.
outfile.GetRootFile()
428 self.
sTree = Fout.Get(
'cbmsim')
431 print(
'run ',self.
options.runNumber,
' event',eventNumber,
" ",time.ctime())
433 event = self.
fiN.Get(
"data")
434 event.GetEvent(eventNumber)
435 self.
header.SetEventTime(event.evt_timestamp)
436 self.
header.SetUTCtimestamp(int(event.evt_timestamp*6.23768*1e-9 + self.
run_startUTC))
437 self.
header.SetEventNumber(event.evt_number)
438 self.
header.SetFlags(event.evt_flags)
440 if self.
FSmap.GetEntries()>1:
441 if self.
header.GetAccMode()== 12:
442 self.
header.SetBunchType(int(str(self.
FSmap.GetValue(str(int((event.evt_timestamp%(4*3564))/8))))))
444 self.
header.SetBunchType(int(str(self.
FSmap.GetValue(str(int((event.evt_timestamp%(4*3564))/4))))))
446 self.
header.SetBunchType(int(str(self.
FSmap.GetValue(
"0"))))
453 digiMuFilterStore = {}
455 for n
in range(event.n_hits):
456 board_id = event.boardId[n]
457 board =
'board_'+str(board_id)
460 station,mat = self.
boardMaps[
'Scifi'][board]
461 elif board
in self.
boardMaps[
'MuFilter']:
464 print(board+
' not known. Serious error, stop')
467 tofpet_id = event.tofpetId[n]
468 tofpet_channel = event.tofpetChannel[n]
469 if self.
options.makeCalibration:
472 print(scifi,board_id,tofpet_id,tofpet_channel,tac,event.tCoarse[n],event.tFine[n],event.vCoarse[n],event.vFine[n])
473 TDC,QDC,Chi2ndof,satur = self.
comb_calibration(board_id,tofpet_id,tofpet_channel,tac,event.vCoarse[n],event.vFine[n],event.tCoarse[n],event.tFine[n])
475 TDC = event.timestamp[n]
477 QDCchi2N = event.valueCalChi2[n]/event.valueCalDof[n]
478 TDCchi2N = event.timestampCalChi2[n]/event.timestampCalDof[n]
479 Chi2ndof = max( QDCchi2N,TDCchi2N )
480 satur = event.value_saturation[n]
481 if Chi2ndof > self.
options.chi2Max:
482 if QDC>1E20: QDC = 997.
483 if QDC != QDC: QDC = 998.
486 elif satur > self.
options.saturationLimit
or QDC>1E20
or QDC != QDC:
487 if QDC>1E20: QDC = 987.
489 print(
'inf',board_id,tofpet_id,tofpet_channel,event.tac[n],event.vCoarse[n],event.vFine[n],TDC-event.tCoarse[n],eventNumber,Chi2ndof)
490 if QDC != QDC: QDC = 988.
492 print(
'nan',board_id,tofpet_id,tofpet_channel,event.tac[n],event.vCoarse[n],event.vFine[n],TDC-event.tCoarse[n],eventNumber,Chi2ndof)
493 A = int(min( QDC,1000))
494 B = min(satur,999)/1000.
497 elif Chi2ndof > self.
options.chi2Max:
501 print(
'calibrated: tdc = ',TDC,
' qdc = ',QDC)
506 key = (tofpet_id%2)*1000 + tofpet_channel
509 if (tmp ==
"DS_5Vert"):
continue
510 if self.
options.debug
or not tmp.find(
'not')<0: print(
'debug',tmp,system,key,board,tofpet_id,tofpet_id%2,tofpet_channel)
513 print(
'key does not exist',key)
514 print(system, key,board,tofpet_id, self.
TofpetMap[system])
516 sipmChannel = self.
TofpetMap[system][key]-1
519 direction = int(self.
offMap[tmp][1]/nSiPMs)
520 detID = self.
offMap[tmp][0] + direction*(sipmChannel//(nSiPMs))
521 sipm_number = sipmChannel%(nSiPMs)
522 if tmp.find(
'Right')>0:
523 sipm_number += nSiPMs
524 if not detID
in digiMuFilterStore:
525 digiMuFilterStore[detID] = ROOT.MuFilterHit(detID,nSiPMs,nSides)
526 test = digiMuFilterStore[detID].GetSignal(sipm_number)
527 digiMuFilterStore[detID].SetDigi(QDC,TDC,sipm_number)
528 digiMuFilterStore[detID].SetDaqID(sipm_number,n,board_id, tofpet_id, tofpet_channel)
529 if mask: digiMuFilterStore[detID].SetMasked(sipm_number)
532 print(
'create mu hit: ',detID,tmp,system,tofpet_id,self.
offMap[tmp],sipmChannel,nSiPMs,nSides,test)
533 print(
' ',detID,sipm_number,QDC,TDC)
534 if test>0
or detID%1000>200
or sipm_number>15:
535 print(
'what goes wrong?',detID,sipm_number,system,key,board,tofpet_id,tofpet_channel,test)
541 if station[2]==
"Y": orientation = 0
542 sipmLocal = (chan - mat*512)
543 sipmID = 1000000*int(station[1]) + 100000*orientation + 10000*mat + 1000*(sipmLocal//128) + chan%128
544 if not sipmID
in digiSciFiStore:
545 digiSciFiStore[sipmID] = ROOT.sndScifiHit(sipmID)
546 digiSciFiStore[sipmID].SetDigi(QDC,TDC)
547 digiSciFiStore[sipmID].SetDaqID(0,n, board_id, tofpet_id, tofpet_channel)
548 if mask: digiSciFiStore[sipmID].setInvalid()
550 print(
'create scifi hit: tdc = ',board,sipmID,QDC,TDC)
551 print(
'tofpet:', tofpet_id,tofpet_channel,mat,chan)
552 print(station[1],station[2],mat,chan,int(chan/128)%4,chan%128)
555 for sipmID
in digiSciFiStore:
557 aHit = digiSciFiStore[sipmID]
559 ROOT.std.swap(aHit, aHit_TCA)
561 for detID
in digiMuFilterStore:
563 aHit = digiMuFilterStore[detID]
564 aHit_TCA = self.
digiMuFilter.ConstructedAt(indexMuFilter)
565 ROOT.std.swap(aHit, aHit_TCA)
568 if self.
options.FairTask_convRaw:
571 self.
run.GetTask(
"ConvRawData").UpdateInput(eventNumber)
573 Fout = self.
outfile.GetRootFile()
574 self.
sTree = Fout.Get(
'cbmsim')
577 print(
'run ',self.
options.runNumber,
' event',eventNumber,
" ",time.ctime())
578 event = self.
fiN.Get(
"event")
579 rc = event.GetEvent(eventNumber)
580 self.
header.SetEventTime(event.timestamp)
589 digiMuFilterStore = {}
592 board_id = int(board.split(
'_')[1])
595 station,mat = self.
boardMaps[
'Scifi'][board]
596 elif board
in self.
boardMaps[
'MuFilter']:
599 print(board+
' not known. Serious error, stop')
602 rc = bt.GetEvent(eventNumber)
603 for n
in range(bt.n_hits):
605 tofpet_id = bt.tofpet_id[n]
606 tofpet_channel = bt.tofpet_channel[n]
607 if self.
options.makeCalibration:
609 print(scifi,board_id,bt.tofpet_id[n],bt.tofpet_channel[n],bt.tac[n],bt.t_coarse[n],bt.t_fine[n],bt.v_coarse[n],bt.v_fine[n])
611 TDC,QDC,Chi2ndof,satur = self.
comb_calibration(board_id,tofpet_id,tofpet_channel,tac,bt.v_coarse[n],bt.v_fine[n],bt.t_coarse[n],bt.t_fine[n])
613 TDC = bt.timestamp[n]
617 if Chi2ndof > self.
options.chi2Max:
618 if QDC>1E20: QDC = 997.
619 if QDC != QDC: QDC = 998.
622 elif satur > self.
options.saturationLimit
or QDC>1E20
or QDC != QDC:
623 if QDC>1E20: QDC = 987.
625 print(
'inf',board_id,bt.tofpet_id[n],bt.tofpet_channel[n],bt.tac[n],bt.v_coarse[n],bt.v_fine[n],TDC-bt.t_coarse[n],eventNumber,Chi2ndof)
626 if QDC != QDC: QDC = 988.
628 print(
'nan',board_id,bt.tofpet_id[n],bt.tofpet_channel[n],bt.tac[n],bt.v_coarse[n],bt.v_fine[n],\
629 TDC-bt.t_coarse[n],TDC,bt.t_coarse[n],eventNumber,Chi2ndof)
630 A = int(min( QDC,1000))
631 B = min(satur,999)/1000.
634 elif Chi2ndof > self.
options.chi2Max:
638 print(
'calibrated: tdc = ',TDC,
' qdc = ',QDC)
643 key = (tofpet_id%2)*1000 + tofpet_channel
646 if (tmp ==
"DS_5Vert"):
continue
647 if self.
options.debug
or not tmp.find(
'not')<0: print(
'debug',tmp,system,key,board,tofpet_id,tofpet_id%2,tofpet_channel)
650 print(
'key does not exist',key)
651 print(system, key,board,tofpet_id, self.
TofpetMap[system])
653 sipmChannel = self.
TofpetMap[system][key]-1
654 nSiPMs = abs(self.
offMap[tmp][1])
655 nSides = abs(self.
offMap[tmp][2])
656 direction = int(self.
offMap[tmp][1]/nSiPMs)
657 detID = self.
offMap[tmp][0] + direction*(sipmChannel//(nSiPMs))
658 sipm_number = sipmChannel%(nSiPMs)
659 if tmp.find(
'Right')>0:
660 sipm_number += nSiPMs
661 if not detID
in digiMuFilterStore:
662 digiMuFilterStore[detID] = ROOT.MuFilterHit(detID,nSiPMs,nSides)
663 test = digiMuFilterStore[detID].GetSignal(sipm_number)
664 digiMuFilterStore[detID].SetDigi(QDC,TDC,sipm_number)
665 digiMuFilterStore[detID].SetDaqID(sipm_number, board_id, tofpet_id, tofpet_channel)
666 if mask: digiMuFilterStore[detID].SetMasked(sipm_number)
669 print(
'create mu hit: ',detID,tmp,system,tofpet_id,self.
offMap[tmp],sipmChannel,nSiPMs,nSides,test)
670 print(
' ',detID,sipm_number,QDC,TDC)
671 if test>0
or detID%1000>200
or sipm_number>15:
672 print(
'what goes wrong?',detID,sipm_number,system,key,board,tofpet_id,tofpet_channel,test)
678 if station[2]==
"Y": orientation = 0
679 sipmLocal = (chan - mat*512)
680 sipmID = 1000000*int(station[1]) + 100000*orientation + 10000*mat + 1000*(sipmLocal//128) + chan%128
681 if not sipmID
in digiSciFiStore:
682 digiSciFiStore[sipmID] = ROOT.sndScifiHit(sipmID)
683 digiSciFiStore[sipmID].SetDigi(QDC,TDC)
684 digiSciFiStore[sipmID].SetDaqID(0, board_id, tofpet_id, tofpet_channel)
685 if mask: digiSciFiStore[sipmID].setInvalid()
687 print(
'create scifi hit: tdc = ',board,sipmID,QDC,TDC)
688 print(
'tofpet:', tofpet_id,tofpet_channel,mat,chan)
689 print(station[1],station[2],mat,chan,int(chan/128)%4,chan%128)
692 for sipmID
in digiSciFiStore:
694 aHit = digiSciFiStore[sipmID]
695 aHit_TCA = self.
digiSciFi.ConstructedAt(indexSciFi)
696 ROOT.std.swap(aHit, aHit_TCA)
698 for detID
in digiMuFilterStore:
700 aHit = digiMuFilterStore[detID]
701 aHit_TCA = self.
digiMuFilter.ConstructedAt(indexMuFilter)
702 ROOT.std.swap(aHit, aHit_TCA)
707 if self.
options.FairTask_convRaw:
717 print(
'number of events processed',self.
sTree.GetEntries(),self.
fiN.Get(
"event").GetEntries())
721 print(
"File closed ",self.
fiN.GetName())