98def compactifyCascade(run):
99 ncpus = 20
100 cmd = ''
101 Ntot = 0
102 NperJob = nev
103 for i in range(run,+ncpus):
104 fName = path+"run"+str(i)+"/Cascade-run"+str(i)+"-parp16-MSTP82-1-MSEL"+msel+".root"
105 f=open(path+"run"+str(i)+"/log"+str(i))
106 success = False
107 for l in f.readlines():
108 if not l.find('Macro finished succesfully')<0: success = True
109 if not success:
110 print("job not finished properly",fName)
111 continue
112 cmd += fName +" "
113 f.close()
114 Ntot+= NperJob
115 if cmd.find('root')<0:
116 print('no file found, exit')
117 else:
118 stat = str( int(Ntot/1E6))+'Mpot'
119 outFile = "Cascade-run"+str(run)+"-"+str(run+ncpus-1)+"-parp16-MSTP82-1-MSEL"+msel+"-"+stat+".root"
120 rc = os.system("hadd -O "+outFile + " " +cmd)
121 f = ROOT.TFile(outFile)
122 Npot = f.Get("2").GetBinContent(1)/2./chicc
123 f.Close()
124 stat = str( int(Npot/1E9))+'Bpot'
125 oldOutFile = outFile
126 outFile = "Cascade-run"+str(run)+"-"+str(run+ncpus-1)+"-parp16-MSTP82-1-MSEL"+msel+"-"+stat+".root"
127 os.system("mv "+oldOutFile+" "+outFile)
128 rc = os.system("xrdcp "+outFile+" $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/"+outFile)
129 if rc != 0:
130 print("copy to EOS failed, stop",outFile)
131 else:
132 rc = os.system("rm "+outFile)
133