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']:
478 for mat
in range(30):
479 entries[mat] = self.
h[
'scifi-mat_'+str(mat)].
GetEntries()
480 res = sorted(entries.items(), key=operator.itemgetter(1),reverse=
True)
481 if res[0][1]>minEntries:
482 for mat
in range(30):
487 e = str(s)+p+str(mat%3)
488 self.
alarms[
'scifi'].append(e)
496 for side
in [
'L',
'R']:
497 entries[str(10*s+p)+side] = self.
h[
'mufi-sig'+p+str(10*s+p)].
GetEntries()
498 res = sorted(entries.items(), key=operator.itemgetter(1),reverse=
True)
499 if res[0][1]>minEntries:
501 for side
in [
'L',
'R']:
502 if entries[str(10*s+p)+side] < 1:
503 self.
alarms[
'Veto'].append(str(10*s+p)+side())
508 for side
in [
'L',
'R']:
509 entries[str(s*10+p)+side] = self.
h[
'mufi-sig2'+p+str(s*10+p)].
GetEntries()
510 res = sorted(entries.items(), key=operator.itemgetter(1),reverse=
True)
513 for side
in [
'L',
'R']:
514 if entries[str(s*10+p)+side] < 1:
515 self.
alarms[
'Veto'].append(str(s*10+p)+side())
527 zPos={
'MuFilter':{},
'Scifi':{}}
532 if s==3
and (plane%2==0
or plane==7):
535 elif s==3
and plane%2==1:
538 self.
MuFilter.GetPosition(s*10000+p*1000+bar,A,B)
539 zPos[
'MuFilter'][s*10+plane] = (A.Z()+B.Z())/2.
540 for s
in range(1,self.
Scifi.GetConfParI(
"Scifi/nscifi")+1):
545 self.
Scifi.GetPosition(channel+1000*sipm+10000*mat+100000*o+1000000*s,A,B)
546 zPos[
'Scifi'][s*10+o] = (A.Z()+B.Z())/2.
573 def map2Dict(self,aHit,T='GetAllSignals',mask=True):
574 if T==
"SumOfSignals":
576 elif T==
"GetAllSignals" or T==
"GetAllTimes":
579 print(
'use case not known',T)
583 if T==
"GetAllTimes": ROOT.fixRootT(aHit,key,Value,mask)
584 else: ROOT.fixRoot(aHit,key,Value,mask)
586 for k
in range(key.size()):
587 if T==
"SumOfSignals": theDict[key[k].Data()] = Value[k]
588 else: theDict[key[k]] = Value[k]
593 params = {0:
'Width(scale)',1:
'mostProbable',2:
'norm',3:
'sigma',4:
'N2'}
594 F = ROOT.TF1(
'langau',langaufun,0,200,len(params))
596 params = {0:
'Width(scale)',1:
'mostProbable',2:
'norm',3:
'sigma'}
597 F = ROOT.TF1(
'langau',twoLangaufun,0,200,len(params))
598 for p
in params: F.SetParName(p,params[p])
599 rc = hist.Fit(
'landau',
'S'+o,
'',bmin,bmax)
601 if not res:
return res
602 F.SetParameter(2,res.Parameter(0))
603 F.SetParameter(1,res.Parameter(1))
604 F.SetParameter(0,res.Parameter(2))
605 F.SetParameter(3,res.Parameter(2))
607 F.SetParLimits(0,0,100)
608 F.SetParLimits(1,0,100)
609 F.SetParLimits(3,0,10)
610 rc = hist.Fit(F,
'S'+o,
'',bmin,bmax)
667 def myPrint(self,tc,name,subdir='',withRootFile=True):
668 srun =
'run'+str(self.
options.runNumber)
669 if isinstance(tc, ROOT.TCanvas) :
675 if not os.path.isdir(srun): os.system(
'mkdir '+srun)
676 pname = srun+
'/'+name+
'-'+srun
677 tc.Print(pname+
'.png')
678 tc.Print(pname+
'.pdf')