-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
save TOF calibration work for future calibrations
- Loading branch information
Showing
27 changed files
with
3,123 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/python | ||
|
||
|
||
import os,sys,getopt | ||
|
||
opts, args = getopt.getopt(sys.argv[1:],"yYP:p:") | ||
OK = 0 # enable actual ccdb command | ||
|
||
RunPeriod =0 | ||
# check input parameter to verify if you really want to execute the commands | ||
for opt,arg in opts: | ||
if opt in ("-Y","-y"): | ||
OK = 1 | ||
if opt in ("-P","-p"): | ||
RunPeriod = int(arg) | ||
|
||
|
||
if RunPeriod<1: | ||
print "Missing Run Period, has to be specified: -P 7 [6,5,4]" | ||
sys.exit() | ||
|
||
# default set to 7 | ||
loc = '/cache/halld/home/zihlmann/TOF_calib/fall19/' | ||
loc = '/work/halld2/home/zihlmann/HallD/work/tofcalib/jobs/' | ||
|
||
if RunPeriod == 6: | ||
loc = '/cache/halld/home/zihlmann/TOF_calib/spring19/' | ||
|
||
if RunPeriod == 5: | ||
loc = '/cache/halld/home/zihlmann/TOF_calib/fall18/' | ||
|
||
if RunPeriod == 4: | ||
loc = '/cache/halld/home/zihlmann/TOF_calib/spring18/' | ||
|
||
RunList = [] | ||
if (RunPeriod<7): | ||
for f in os.listdir(loc): | ||
if f.endswith('.root'): | ||
r = f[11:16] | ||
RunList.append(int(r)) | ||
else: | ||
for d in os.listdir(loc): | ||
if d.startswith('Run'): | ||
r = d[3:8] | ||
RunList.append(str(r)) | ||
|
||
RunList.sort() | ||
for R in RunList: | ||
cmd = 'root -q -b \"src/baseline.C('+str(R)+')\"' | ||
print cmd | ||
if OK: | ||
os.system(cmd) | ||
#sys.exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/python | ||
|
||
# read from directory pedestals/ and create list to write to ccdb | ||
|
||
import os,sys,getopt | ||
|
||
OK=0 | ||
|
||
opts, args = getopt.getopt(sys.argv[1:],"yY") | ||
for opt,arg in opts: | ||
if opt in ("-Y","-y"): | ||
OK = 1 | ||
|
||
loc = 'pedestals/' | ||
|
||
R4List = [] | ||
R5List = [] | ||
R6List = [] | ||
R7List = [] | ||
for f in os.listdir(loc): | ||
if f.startswith('pedpos_'): | ||
r = int(f[10:15]) | ||
if r<50000: | ||
R4List.append(f) | ||
elif r<60000: | ||
R5List.append(f) | ||
elif r<70000: | ||
R6List.append(f) | ||
elif r<80000: | ||
R7List.append(f) | ||
|
||
R4List.sort() | ||
R5List.sort() | ||
R6List.sort() | ||
R7List.sort() | ||
|
||
Start = 70000 | ||
Stop = 79999 | ||
cnt = 0 | ||
oldf = '' | ||
for f in R7List: | ||
if cnt<1: | ||
oldf = loc+f | ||
cnt += 1 | ||
continue | ||
rend = int(f[10:15]) | ||
cmd = 'ccdb add -r '+str(Start)+'-'+str(rend)+' TOF2/pedestals '+oldf | ||
print cmd | ||
if OK: | ||
os.system(cmd) | ||
Start = rend | ||
oldf = loc+f | ||
cnt += 1 | ||
if cnt == len(R7List): | ||
cmd = 'ccdb add -r '+str(Start)+'-'+str(Stop)+' TOF2/pedestals '+oldf | ||
print cmd | ||
if OK: | ||
os.system(cmd) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// | ||
// purpose: determine location of baseline peak to generate a input file | ||
// for ccdb listing the baselines for each PMT of the run being | ||
// analyzed. The input file is tofdata_runXXXXX.root same as | ||
// for the calibration but only using the histogram TOFpedestal | ||
|
||
int DEBUG = 0; | ||
|
||
void baseline(int R){ | ||
|
||
string dirloc; | ||
int NPMTS = 176; | ||
string f("tofdata_run"); | ||
if (R>69999){ | ||
//string s("/cache/halld/home/zihlmann/TOF_calib/fall19/"); | ||
string s("/work/halld2/home/zihlmann/HallD/work/tofcalib/jobs/Run"); | ||
s += to_string(R)+"/"; | ||
dirloc = s; | ||
NPMTS = 184; | ||
} else if (R>56999){ | ||
string s("/cache/halld/home/zihlmann/TOF_calib/spring19/"); | ||
dirloc = s; | ||
} else if (R>46999){ | ||
string s("/cache/halld/home/zihlmann/TOF_calib/fall18/"); | ||
dirloc = s; | ||
} else if (R>36999){ | ||
string s("/cache/halld/home/zihlmann/TOF_calib/spring18/"); | ||
dirloc = s; | ||
} else { | ||
cout<<"run range invalid! BAIL!"<<endl; | ||
return; | ||
} | ||
|
||
f += to_string(R)+".root"; | ||
if (R>69999){ // special only for this!!!!! | ||
string b("hd_root_tofcalib.root"); | ||
f = b; | ||
} | ||
string inf = dirloc+f; | ||
TFile *RF = new TFile(inf.c_str(), "READ"); | ||
|
||
TH2D *h2d = (TH2D*)RF->Get("TOFcalib/TOFPedestal"); | ||
if (!h2d){ | ||
cout<<"historgram TOFcalib/TOFPedestal NOT FOUND!"<<endl; | ||
return; | ||
} | ||
|
||
double PedPos[200]; | ||
for (int n=1; n<(NPMTS+1); n++){ | ||
|
||
PedPos[n-1] = 100.; | ||
|
||
TH1D *h = (TH1D*) h2d->ProjectionY("pj",n,n); | ||
if (h->GetEntries()<1000){ | ||
continue; | ||
} | ||
int maxbin = h->GetMaximumBin(); | ||
int nbins = h->GetXaxis()->GetNbins(); | ||
|
||
if ((maxbin>nbins-10)||(maxbin<10)){ | ||
continue; | ||
} | ||
double pos,w; | ||
pos = h->GetBinCenter(maxbin); | ||
w = h->GetBinWidth(maxbin); | ||
//cout<<n<<" " << pos<<" "<<w<<" "<<maxbin<<endl; | ||
h->Fit("gaus","Q","R", pos-5*w, pos+3*w); | ||
TF1 *f1 = h->GetFunction("gaus"); | ||
pos = f1->GetParameter(1); | ||
w = f1->GetParameter(2); | ||
h->Fit("gaus","Q","R", pos-4.*w, pos+2.*w); | ||
f1 = h->GetFunction("gaus"); | ||
pos = f1->GetParameter(1); | ||
w = f1->GetParameter(2); | ||
|
||
//cout<<" "<<pos<<" / "<<w<<endl; | ||
|
||
PedPos[n-1] = pos/4.; | ||
|
||
if (DEBUG>1){ | ||
h->Draw(); | ||
gPad->SetGrid(); | ||
gPad->Update(); | ||
sleep(1); | ||
} | ||
|
||
} | ||
|
||
char of[128]; | ||
sprintf(of, "pedestals/pedpos_run%d.dat",R); | ||
ofstream OUTF; | ||
OUTF.open(of,std::ofstream::out); | ||
for (int n=0; n<NPMTS; n++){ | ||
OUTF<<PedPos[n]<<endl; | ||
} | ||
OUTF.close(); | ||
|
||
} | ||
|
Oops, something went wrong.