diff --git a/CALIBRATION/hms_dc_calib/scripts/get_hdc_time_histo_tzero_corrected.C b/CALIBRATION/hms_dc_calib/scripts/get_hdc_time_histo_tzero_corrected.C index d847ce0bc3b186b97eb26a7a470c4139fa7064d9..fe9719255f9804ba5c9df1f2c1cb9c9f93dba482 100644 --- a/CALIBRATION/hms_dc_calib/scripts/get_hdc_time_histo_tzero_corrected.C +++ b/CALIBRATION/hms_dc_calib/scripts/get_hdc_time_histo_tzero_corrected.C @@ -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();