78 if path.find(
'eos')>0:
79 path = options.server+options.path
81 path = path.replace(
"raw_data",
"convertedData").replace(
"data/",
"")
82 self.
myclient = client.FileSystem(options.server)
91 2:self.
MuFilter.GetConfParI(
"MuFilter/NUpstreamPlanes"),
92 3:2*self.
MuFilter.GetConfParI(
"MuFilter/NDownstreamPlanes")-1}
94 2:self.
MuFilter.GetConfParI(
"MuFilter/NUpstreamBars"),
95 3:self.
MuFilter.GetConfParI(
"MuFilter/NDownstreamBars")}
97 2:[self.
MuFilter.GetConfParI(
"MuFilter/UpstreamnSiPMs")-2,2],
98 3:[self.
MuFilter.GetConfParI(
"MuFilter/DownstreamnSiPMs"),0]}
99 self.
sdict = {0:
'Scifi',1:
'Veto',2:
'US',3:
'DS'}
108 self.
runNr = str(options.runNumber).zfill(6)
110 if hasattr(self,
"saveTo")
and options.saveTo!=
"":
111 name = options.saveTo+
'run'+self.
runNr+
'_'+str(options.nStart//1000000)+
'.root'
113 name =
'run'+self.
runNr+
'.root'
114 if options.interactive: name =
'I-'+name
116 for role
in [
'',
'shifter',
'expert']:
120 if options.interactive: self.
presenterFile.mkdir(
'eventdisplay/'+role)
128 options.chi2Max = 2000.
129 options.saturationLimit = 0.95
131 options.withGeoFile =
True
143 if t==
'simpleTracking':
151 if self.
eventTree.EventHeader.GetAccMode()==12:
160 f=ROOT.TFile.Open(options.fname)
161 eventChain = f.Get(
'rawConv')
163 eventChain = f.cbmsim
164 if eventChain.GetBranch(
'MCTrack'): self.
MonteCarlo =
True
168 if options.partition < 0:
170 if path.find(
'eos')>0:
172 dirlist = str( subprocess.check_output(
"xrdfs "+options.server+
" ls "+options.path+
"run_"+self.
runNr,shell=
True) )
173 for x
in dirlist.split(
'\\n'):
174 ix = x.find(
'sndsw_raw-')
176 partitions.append(x[ix:])
179 dirlist = os.listdir(options.path+
"run_"+self.
runNr)
181 if not x.find(
'sndsw_raw-')<0:
184 partitions = [
"sndsw_raw-"+ str(options.partition).zfill(4)+
".root"]
185 if options.runNumber>0:
186 eventChain = ROOT.TChain(
'rawConv')
188 eventChain.Add(path+
'run_'+self.
runNr+
'/'+p)
190 rc = eventChain.GetEvent(0)
191 self.
TStart = eventChain.EventHeader.GetEventTime()
192 if options.nEvents <0:
193 rc = eventChain.GetEvent(eventChain.GetEntries()-1)
195 rc = eventChain.GetEvent(options.nEvents-1)
196 self.
TEnd = eventChain.EventHeader.GetEventTime()
197 rc = eventChain.GetEvent(0)
199 self.
run = ROOT.FairRunAna()
200 ioman = ROOT.FairRootManager.Instance()
201 ioman.SetTreeName(eventChain.GetName())
202 outFile = ROOT.TMemFile(
'dummy',
'CREATE')
203 source = ROOT.FairFileSource(eventChain.GetCurrentFile())
204 for i
in range(1,len(partitions)):
206 source.AddFile(path+
'run_'+self.
runNr+
'/'+p)
207 self.
run.SetSource(source)
208 self.
sink = ROOT.FairRootFileSink(outFile)
215 xrdb = ROOT.FairRuntimeDb.instance()
216 xrdb.getContainer(
"FairBaseParSet").setStatic()
217 xrdb.getContainer(
"FairGeoParSet").setStatic()
220 if len(partitions)>0: self.
eventTree = ioman.GetInChain()
231 rc = eventChain.GetEvent(0)
233 self.
snd_geo.modules[
'Scifi'].InitEvent(eventChain.EventHeader)
234 self.
snd_geo.modules[
'MuFilter'].InitEvent(eventChain.EventHeader)
237 if eventChain.EventHeader.GetAccMode()==12:
247 if hasattr(eventChain.EventHeader,
"GetBunchType"):
248 if not eventChain.EventHeader.GetBunchType()<0:
250 print(
'take bunch info from event header')
253 fg = ROOT.TFile.Open(options.server+options.path+
'FSdict.root')
255 FSdict = pkl.load(
'FSdict')
257 if options.runNumber
in FSdict: self.
fsdict = FSdict[options.runNumber]
259 print(
'continue without knowing filling scheme',options.server+options.path)
261 print(
'extract bunch info from filling scheme')
263 for x
in [
'B1only',
'B2noB1',
'noBeam']:
264 for role
in [
'shifter',
'expert']:
474 for mat
in range(30):
475 entries[mat] = self.
h[
'scifi-mat_'+str(mat)].
GetEntries()
476 res = sorted(entries.items(), key=operator.itemgetter(1),reverse=
True)
477 if res[0][1]>minEntries:
478 for mat
in range(30):
483 e = str(s)+p+str(mat%3)
484 self.
alarms[
'scifi'].append(e)
492 for side
in [
'L',
'R']:
493 entries[str(10*s+p)+side] = self.
h[
'mufi-sig'+p+str(10*s+p)].
GetEntries()
494 res = sorted(entries.items(), key=operator.itemgetter(1),reverse=
True)
495 if res[0][1]>minEntries:
497 for side
in [
'L',
'R']:
498 if entries[str(10*s+p)+side] < 1:
499 self.
alarms[
'Veto'].append(str(10*s+p)+side())
504 for side
in [
'L',
'R']:
505 entries[str(s*10+p)+side] = self.
h[
'mufi-sig2'+p+str(s*10+p)].
GetEntries()
506 res = sorted(entries.items(), key=operator.itemgetter(1),reverse=
True)
509 for side
in [
'L',
'R']:
510 if entries[str(s*10+p)+side] < 1:
511 self.
alarms[
'Veto'].append(str(s*10+p)+side())
523 zPos={
'MuFilter':{},
'Scifi':{}}
528 if s==3
and (plane%2==0
or plane==7):
531 elif s==3
and plane%2==1:
534 self.
MuFilter.GetPosition(s*10000+p*1000+bar,A,B)
535 zPos[
'MuFilter'][s*10+plane] = (A.Z()+B.Z())/2.
541 self.
Scifi.GetPosition(channel+1000*sipm+10000*mat+100000*o+1000000*s,A,B)
542 zPos[
'Scifi'][s*10+o] = (A.Z()+B.Z())/2.
569 def map2Dict(self,aHit,T='GetAllSignals',mask=True):
570 if T==
"SumOfSignals":
572 elif T==
"GetAllSignals" or T==
"GetAllTimes":
575 print(
'use case not known',T)
579 if T==
"GetAllTimes": ROOT.fixRootT(aHit,key,Value,mask)
580 else: ROOT.fixRoot(aHit,key,Value,mask)
582 for k
in range(key.size()):
583 if T==
"SumOfSignals": theDict[key[k].Data()] = Value[k]
584 else: theDict[key[k]] = Value[k]
589 params = {0:
'Width(scale)',1:
'mostProbable',2:
'norm',3:
'sigma',4:
'N2'}
590 F = ROOT.TF1(
'langau',langaufun,0,200,len(params))
592 params = {0:
'Width(scale)',1:
'mostProbable',2:
'norm',3:
'sigma'}
593 F = ROOT.TF1(
'langau',twoLangaufun,0,200,len(params))
594 for p
in params: F.SetParName(p,params[p])
595 rc = hist.Fit(
'landau',
'S'+o,
'',bmin,bmax)
597 if not res:
return res
598 F.SetParameter(2,res.Parameter(0))
599 F.SetParameter(1,res.Parameter(1))
600 F.SetParameter(0,res.Parameter(2))
601 F.SetParameter(3,res.Parameter(2))
603 F.SetParLimits(0,0,100)
604 F.SetParLimits(1,0,100)
605 F.SetParLimits(3,0,10)
606 rc = hist.Fit(F,
'S'+o,
'',bmin,bmax)
663 def myPrint(self,tc,name,subdir='',withRootFile=True):
664 srun =
'run'+str(self.
options.runNumber)
665 if isinstance(tc, ROOT.TCanvas) :
671 if not os.path.isdir(srun): os.system(
'mkdir '+srun)
672 pname = srun+
'/'+name+
'-'+srun
673 tc.Print(pname+
'.png')
674 tc.Print(pname+
'.pdf')