Skip to content
Snippets Groups Projects
Commit b2a42a55 authored by Mark K Jones's avatar Mark K Jones Committed by GitHub
Browse files

Merge pull request #99 from Yero1990/hmc_calib

Hmc calib
parents bb11ecbf af5295eb
No related branches found
No related tags found
No related merge requests found
......@@ -12,17 +12,8 @@ TString f0 = "input_RUN.txt";
ifstream infile(f0);
infile >> run_NUM;
//Create RUN Directories if they dont exist
char *dir0 = Form("mkdir ../root_files/run%d", run_NUM);
char *dir1 = Form("mkdir ../data_files/run%d", run_NUM);
if (system(dir0 || dir1) != 0) {
system(dir0);
system(dir1);
}
//open file
TFile *f = new TFile(Form("../../../ROOTfiles/test_%d.root", run_NUM), "READ");
TFile *f = new TFile(Form("../../../ROOTfiles/hms_replay_%d.root", run_NUM), "READ");
//create new file
TFile *g = new TFile(Form("../root_files/run%d/hms_dc_time_%d.root", run_NUM, run_NUM), "RECREATE"); // create new file to store histo
......@@ -38,58 +29,58 @@ TString plane_names[NPLANES]={"1x1", "1y1", "1u1", "1v1", "1y2", "1x2", "2x1", "
//Declare Variables to Loop Over
Int_t Ndata[NPLANES];
Double_t hdc_time[NPLANES][1000];
//Declare Histogram array to store AVG drift times per plane
TH1F* h[NPLANES];
g->cd();
//Loop over each plane
for(Int_t ip=0; ip<NPLANES; ip++){
TString base_name = SPECTROMETER+"."+DETECTOR+"."+plane_names[ip];
TString ndata_name = "Ndata."+base_name+".time";
TString drift_time = base_name+".time";
TString drift_time_histo = "hdc"+plane_names[ip]+"_time";
TString drift_time_histo = "hdc"+plane_names[ip]+"_time";
TString title = "hdc"+plane_names[ip]+"_drifttime";
//Set Branch Address
tree->SetBranchAddress(drift_time, &hdc_time[ip][0]);
tree->SetBranchAddress(drift_time, &hdc_time[ip][0]);
tree->SetBranchAddress(ndata_name, &Ndata[ip]); /* Ndata represents number of triggers vs number of hits that each trigger produced.
A hit is refer to as when a trigger(traversing particle), ionizes the WC gas and ionized
electrons reach the rearest sense wire, producing a detectable signal in the O'scope */
//Create Histograms
h[ip] = new TH1F(drift_time_histo, title, 200, -50, 350); //set time to 400 ns/200 bins = 2ns/bin
}
//Declare number of entries in the tree
Long64_t nentries = tree->GetEntries(); //number of triggers (particles that passed through all 4 hodo planes)
//Loop over all entries
for(Long64_t i=0; i<nentries; i++)
{
tree->GetEntry(i);
//Loop over number of hits for each trigger in each DC plane
//Loop over number of hits for each trigger in each DC plane
for(ip=0; ip<NPLANES; ip++){
for(Int_t j=0; j<Ndata[ip]; j++){
h[ip]->Fill(hdc_time[ip][j]);
h[ip]->Fill(hdc_time[ip][j]);
}
}
}
//Write histograms to file
g->Write();
......
......@@ -5,18 +5,17 @@
void get_hdc_time_histo_tzero_corrected()
{
//read run number from input file
int run_NUM;
TString f0 = "input_RUN.txt";
ifstream infile(f0);
infile >> run_NUM;
infile >> run_NUM;
TString run = Form("run%d", run_NUM);
//open file
TFile *f = new TFile(Form("../../../ROOTfiles/test_%d.root", run_NUM), "READ");
TFile *f = new TFile(Form("../../../ROOTfiles/hms_replay_%d.root", run_NUM), "READ");
//updates file
TFile *g = new TFile(Form("../root_files/run%d/hms_dc_t0_corrected_%d.root", run_NUM, run_NUM), "UPDATE"); // create new file to store histo
......@@ -33,42 +32,42 @@ void get_hdc_time_histo_tzero_corrected()
//Declare Variables to Loop Over
Int_t Ndata[NPLANES];
Double_t hdc_time[NPLANES][1000];
//Declare Histogram array to store AVG drift times per plane
TH1F* h[NPLANES];
g->cd();
//Loop over each plane
for(Int_t ip=0; ip<NPLANES; ip++){
TString base_name = SPECTROMETER+"."+DETECTOR+"."+plane_names[ip];
TString ndata_name = "Ndata."+base_name+".time";
TString drift_time = base_name+".time";
TString drift_time_histo = "hdc"+plane_names[ip]+"_time: t0_corr";
TString drift_time_histo = "hdc"+plane_names[ip]+"_time: t0_corr";
TString title = "hdc"+plane_names[ip]+"_drifttime: t0-corrected";
//Set Branch Address
tree->SetBranchAddress(drift_time, hdc_time[ip]);
tree->SetBranchAddress(drift_time, hdc_time[ip]);
tree->SetBranchAddress(ndata_name, &Ndata[ip]); /* Ndata represents number of triggers vs number of hits that each trigger produced.
A hit is refer to as when a trigger(traversing particle), ionizes the WC gas and ionized
electrons reach the rearest sense wire, producing a detectable signal in the O'scope */
//Create Histograms
h[ip] = new TH1F(drift_time_histo, title, 200, -50, 350); //set time to 400 ns/200 bins = 2ns/bin
}
//open and read tzero data file
ifstream ifs;
ifs.open("../data_files/" + run + "/tzero.dat");
double t_zero_offsets[NPLANES];
for (ip=0; ip < 12; ip++) {
for (ip=0; ip < 12; ip++) {
ifs >> t_zero_offsets[ip]; //add tzero offsets to array
}
//Declare number of entries in the tree
Long64_t nentries = tree->GetEntries(); //number of triggers (particles that passed through all 4 hodo planes)
......@@ -76,29 +75,29 @@ void get_hdc_time_histo_tzero_corrected()
for(Long64_t i=0; i<nentries; i++)
{
tree->GetEntry(i);
//Loop over number of hits for each trigger in each DC plane
//Loop over number of hits for each trigger in each DC plane
for(ip=0; ip<NPLANES; ip++){
for(Int_t j=0; j<Ndata[ip]; j++){
h[ip]->Fill(hdc_time[ip][j] - t_zero_offsets[ip]); //add t0 offset correction
h[ip]->Fill(hdc_time[ip][j] - t_zero_offsets[ip]); //add t0 offset correction
}
}
}
//Write histograms to file
g->Write();
......
......@@ -4,12 +4,12 @@
void update_hdcparam()
{
//read run number from input file
int run_NUM;
TString f0 = "input_RUN.txt";
ifstream infile(f0);
infile >> run_NUM;
infile >> run_NUM;
TString run = Form("run%d", run_NUM);
......@@ -20,92 +20,59 @@ void update_hdcparam()
//open t_zero file
ifstream ifs;
ifs.open("../data_files/"+ run +"/tzero_weighted_avg_" + run + ".txt");
while (getline(ifs, line))
{
istringstream ss(line);
char id;
if ( ss >> t_zero)
{
if (id != '#') //skip comments
if (id != '#') //skip comments
{
//count lines
//count lines
lin_NUM = lin_NUM + 1;
cout << lin_NUM << endl;
cout << lin_NUM << endl;
t_zero[lin_NUM-1] = line;
tzero[lin_NUM-1] = atof(t_zero[lin_NUM-1].c_str()); // convert string to double
cout << tzero[lin_NUM-1] << endl;
}
}
}
}
}
ifs.close();
//Update hdc.param parameter file
TString hdc_param = "../../../PARAM/HMS/DC/hdc_new.param";
ofstream ofs(hdc_param);
ofs << ";---------------------------------------------------------------------" << endl;
ofs <<"; HMS_TRACKING"<< endl;
ofs <<"; CTP parameter file containing all tracking parameters for the HMS "<< endl;
ofs <<";----------------------------------------------------------------------"<< endl;
ofs <<"; sigma of wire chamber resolution for each plane "<< endl;
ofs <<" hdc_sigma = 0.020 "<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" 0.020"<< endl;
ofs <<" hdc_tdc_min_win = -25000,-25000,-25000,-25000,-25000,-25000 "<< endl;
ofs <<" -25000,-25000,-25000,-25000,-25000,-25000 "<< endl;
ofs <<" hdc_tdc_max_win = 25000,25000,25000,25000,25000,25000 "<< endl;
ofs <<" 25000,25000,25000,25000,25000,25000 "<< endl;
ofs <<"; hms drift chamber tdc's time per channel "<< endl;
ofs <<" hdc_tdc_time_per_channel = -0.10 "<< endl;
ofs <<"; hms zero time for drift chambers !DECREASING this number moves the hdtime plots to LOWER time. "<< endl;
ofs <<"hdc_plane_time_zero = ";
//*****************************************************************
//output all t_0 corrected values to hdc.param
for (int i=0; i<12; i++) {
//Update hdc.param parameter file
TString new_tzero = "../../../PARAM/HMS/DC/new_tzero.param";
ofstream ofs(new_tzero);
//output all t_0 corrected values to hdc.param
for (int i=0; i<12; i++) {
{
if (i < = 5){
ofs << time_shift - tzero[i] << ",";
ofs << time_shift - tzero[i] << ",";
}
if (i ==6) {ofs << "\n" << time_shift - tzero[6] << ",";}
else if (i>6 && i <11) {
ofs << time_shift - tzero[i] << ",";
ofs << time_shift - tzero[i] << ",";
}
if (i==11){ ofs << time_shift - tzero[i] << endl;}
}
}
//*****************************************************************
ofs << "\n";
ofs <<"; Dave Abbott's wire velocity correction "<< endl;
ofs <<"hdc_wire_velocity = 12.0 "<< endl;
ofs <<"hdc_central_time = 7,9,3,4,6,5 "<< endl;
ofs << " 7,5,3,4,6,6" << endl;
ofs.close();
//create a t_zero data file copy in another directory that will also use these values
TString tzero_dat = "../data_files/" + run + "/tzero.dat";
ofstream ofs(tzero_dat);
for (int i=0; i<12; i++)
for (int i=0; i<12; i++)
{
ofs << tzero[i] << endl;
ofs << tzero[i] << endl;
}
}
......@@ -154,7 +154,7 @@ public :
Double_t H_dc_stubtest;
Double_t H_dc_tnhit;
Double_t H_dc_trawhit;
//THaEvent *Event_Branch;
ULong64_t fEvtHdr_fEvtTime;
UInt_t fEvtHdr_fEvtNum;
......@@ -327,11 +327,11 @@ wire_drift_times::wire_drift_times(TTree *tree) : fChain(0)
int run_NUM;
TString f0 = "input_RUN.txt";
ifstream infile(f0);
infile >> run_NUM;
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(Form("../../../ROOTfiles/test_%d.root", run_NUM));
infile >> run_NUM;
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(Form("../../../ROOTfiles/hms_replay_%d.root", run_NUM));
if (!f || !f->IsOpen()) {
f = new TFile(Form("../../../ROOTfiles/test_%d.root", run_NUM));
f = new TFile(Form("../../../ROOTfiles/hms_replay_%d.root", run_NUM));
}
f->GetObject("T",tree);
......
......@@ -29,6 +29,44 @@ TH1F hdc2v1_wirenum 'HMS DC 2V1 Wiremap; Wire Number; Number of Entries' H.dc.2v
TH1F hdc2y2_wirenum 'HMS DC 2Y2 Wiremap; Wire Number; Number of Entries' H.dc.2y2.wirenum 52 0.5 52.5
TH1F hdc2x2_wirenum 'HMS DC 2X2 Wiremap; Wire Number; Number of Entries' H.dc.2x2.wirenum 113 0.5 113.5
#drift distances
TH1F hdc1x1_dist 'HDC 1X1 Drift Distance' H.dc.1x1.dist 50 -0.1 0.6
TH1F hdc1x1_dist_cut 'HDC CUT 1X1 Drift Distance' H.dc.1x1.dist 50 -0.1 0.6 time_cut1
TH1F hdc1y1_dist 'HDC 1Y1 Drift Distance' H.dc.1y1.dist 50 -0.1 0.6
TH1F hdc1y1_dist_cut 'HDC CUT 1Y1 Drift Distance' H.dc.1y1.dist 50 -0.1 0.6 time_cut2
TH1F hdc1u1_dist 'HDC 1U1 Drift Distance' H.dc.1u1.dist 50 -0.1 0.6
TH1F hdc1u1_dist_cut 'HDC CUT 1U1 Drift Distance' H.dc.1u1.dist 50 -0.1 0.6 time_cut3
TH1F hdc1v1_dist 'HDC 1V1 Drift Distance' H.dc.1v1.dist 50 -0.1 0.6
TH1F hdc1v1_dist_cut 'HDC CUT 1V1 Drift Distance' H.dc.1v1.dist 50 -0.1 0.6 time_cut4
TH1F hdc1y2_dist 'HDC 1Y2 Drift Distance' H.dc.1y2.dist 50 -0.1 0.6
TH1F hdc1y2_dist_cut 'HDC CUT 1Y2 Drift Distance' H.dc.1y2.dist 50 -0.1 0.6 time_cut5
TH1F hdc1x2_dist 'HDC 1X2 Drift Distance' H.dc.1x2.dist 50 -0.1 0.6
TH1F hdc1x2_dist_cut 'HDC CUT 1X2 Drift Distance' H.dc.1x2.dist 50 -0.1 0.6 time_cut6
TH1F hdc2x1_dist 'HDC 2X1 Drift Distance' H.dc.2x1.dist 50 -0.1 0.6
TH1F hdc2x1_dist_cut 'HDC CUT 2X1 Drift Distance' H.dc.2x1.dist 50 -0.1 0.6 time_cut7
TH1F hdc2y1_dist 'HDC 2Y1 Drift Distance' H.dc.2y1.dist 50 -0.1 0.6
TH1F hdc2y1_dist_cut 'HDC CUT 2Y1 Drift Distance' H.dc.2y1.dist 50 -0.1 0.6 time_cut8
TH1F hdc2u1_dist 'HDC 2U1 Drift Distance' H.dc.2u1.dist 50 -0.1 0.6
TH1F hdc2u1_dist_cut 'HDC CUT 2U1 Drift Distance' H.dc.2u1.dist 50 -0.1 0.6 time_cut9
TH1F hdc2v1_dist 'HDC 2V1 Drift Distance' H.dc.2v1.dist 50 -0.1 0.6
TH1F hdc2v1_dist_cut 'HDC CUT 2V1 Drift Distance' H.dc.2v1.dist 50 -0.1 0.6 time_cut10
TH1F hdc2y2_dist 'HDC 2Y2 Drift Distance' H.dc.2y2.dist 50 -0.1 0.6
TH1F hdc2y2_dist_cut 'HDC CUT 2Y2 Drift Distance' H.dc.2y2.dist 50 -0.1 0.6 time_cut11
TH1F hdc2x2_dist 'HDC 2X2 Drift Distance' H.dc.2x2.dist 50 -0.1 0.6
TH1F hdc2x2_dist_cut 'HDC CUT 2X2 Drift Distance' H.dc.2x2.dist 50 -0.1 0.6 time_cut12
TH2F hdc1x1_wirenum_vs_tdc 'HMS DC 1X1 Wire Number vs. TDC; Wire Number; TDC Time (ns)' H.dc.1x1.wirenum H.dc.1x1.time 113 0.5 113.5 2000 -500 1500
TH2F hdc1y1_wirenum_vs_tdc 'HMS DC 1Y1 Wire Number vs. TDC; Wire Number; TDC Time (ns)' H.dc.1y1.wirenum H.dc.1y1.time 52 0.5 52.5 2000 -500 1500
TH2F hdc1u1_wirenum_vs_tdc 'HMS DC 1U1 Wire Number vs. TDC; Wire Number; TDC Time (ns)' H.dc.1u1.wirenum H.dc.1u1.time 107 0.5 107.5 2000 -500 1500
......
......@@ -9,5 +9,20 @@ Decode_master 1
Block: CoarseTracking
CoarseTracking_master 1
#add cuts to stricter times and apply them to drift distances
time_cut1 H.dc.1x1.time > 0 && H.dc.1x1.time < 250
time_cut2 H.dc.1y1.time > 0 && H.dc.1y1.time < 250
time_cut3 H.dc.1u1.time > 0 && H.dc.1u1.time < 250
time_cut4 H.dc.1v1.time > 0 && H.dc.1v1.time < 250
time_cut5 H.dc.1y2.time > 0 && H.dc.1y2.time < 250
time_cut6 H.dc.1x2.time > 0 && H.dc.1x2.time < 250
time_cut7 H.dc.2x1.time > 0 && H.dc.2x1.time < 250
time_cut8 H.dc.2y1.time > 0 && H.dc.1y1.time < 250
time_cut9 H.dc.2u1.time > 0 && H.dc.2u1.time < 250
time_cut10 H.dc.2v1.time > 0 && H.dc.2v1.time < 250
time_cut11 H.dc.2y2.time > 0 && H.dc.2y2.time < 250
time_cut12 H.dc.2x2.time > 0 && H.dc.2x2.time < 250
Block: CoarseReconstruct
CourseReconstruct 0
......@@ -16,8 +16,12 @@ hdc_tdc_time_per_channel = -0.10
; Zero time correction for each plane in ns that is added to TDC time.
; From SANE.
hdc_plane_time_zero = 1309.36, 1312.62, 1300.6, 1305.36, 1307.75, 1305.64
1303.28, 1305.77, 1300.24, 1300.45, 1311.34, 1301.44
hdc_plane_time_zero = 1312.50,1316.50,1310.8,1313.0,1311.45,1312.76,
1315.0,1313.40,1310.8,1312.0,1317.4,1313.5
; For wire velocity corrections.
; From SANE.
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment