5import sys,os,subprocess,tempfile
6from LArCafJobs.GetLBsToIgnore
import getLBsToIgnore
10if __name__==
"__main__":
11 if len(sys.argv)<2
or not sys.argv[1].isdigit():
12 print(
"Usage: %s <runnumber> {outputfile}" % sys.argv[0])
16 runnumber=int(sys.argv[1])
18 outputFile=sys.argv[2]
20 outputFile=
"LCE_CellList_%i.txt" % runnumber
22 if not os.access(os.path.dirname(outputFile),os.W_OK):
23 print(
"ERROR, no write access to output text file",outputFile)
31 from GetProjectTag
import GetProjectTag
32 projectTag=GetProjectTag(runnumber)
33 if projectTag
is None:
34 print(
"Failed to get ProjectTag for run ",runnumber,
" from SFO DB")
37 print(
"Found project tag ",projectTag,
" for run ",runnumber)
39 eospath=
"/eos/atlas/atlascerngroupdisk/det-larg/Tier0/perm/%s/calibration_LArCellsEmpty/%8.8i/" % (projectTag,runnumber)
40 cmd = eoscmd+
" ls "+eospath
42 sRes = subprocess.getstatusoutput(cmd)
48 print(
"output: ", output)
50 if d1.find(
"NTUP_SAMPLESMON")!=-1:
56 print(
"Directory for LCE output of run %i not found on eos" % runnumber)
59 cmd = eoscmd+
" ls "+eospath
60 print(
"Checking path ",eospath)
61 sRes = subprocess.getstatusoutput(cmd)
63 output = sRes[1].
split(
'\n')
67 if d2
is not None and d2.find(
"NTUP_SAMPLESMON")!=-1:
69 path=
"root://eosatlas/"+eospath+
"/"+filename
77 print(
"Found project Tag",projectTag)
78 print(
"Input file ",path)
80 print(
"LCE output of run %i not found on eos" % runnumber)
84 workdir=tempfile.mkdtemp()
85 LCEFile=workdir+
"/"+filename
86 cmd=eoscmd+
" cp "+path+
" "+LCEFile
87 sRes = subprocess.getstatusoutput(cmd)
88 if (sRes[0] != 0
or not os.access(LCEFile,os.R_OK)):
89 print(
"ERROR, failed to copy LCE ntuple to local directory")
95 requireStableBeam=projectTag.endswith(
"TeV")
97 badLBs=getLBsToIgnore(runnumber,
True,bulk,requireStableBeam)
98 (badLBsF,badLBsFN)=tempfile.mkstemp(text=
True)
100 os.write(badLBsF,str.encode(
', '.join([ str(i)
for i
in sorted(badLBs) ])))
101 os.write(badLBsF,str.encode(
"\n"))
108 print(
"Running LCE_CellList",LCEFile,outputFile,badLBsFN)
110 sc=subprocess.call([
"LCE_CellList",LCEFile,outputFile,badLBsFN])
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")