From a1c8b50948df5709c207ec48383ca392a97e3d2b Mon Sep 17 00:00:00 2001 From: Yero1990 <cyero002@fiu.edu> Date: Sat, 17 Mar 2018 10:40:07 -0400 Subject: [PATCH] Dc calib work (#429) * moved 'old_scripts' directory to UTIL_ED * Added optional num_evts argument to take '-1' as an option to loop over all events in the TTree. * updated good_event definition: X.cal.etot>0.1&&X.cer_npeSum>1.0&&(5/6 PLANE HITS) * added percent variable to determine fit region for HMS/SHMS independently * add t0_err_threshold as criteria for accepting good wire drift time fits * Started to implement Per Card DC Calibration: 1)Added per-card methods in header file, 2)Added varible plane_cars[NPLANES] to store max number of disc. cards in a plane * added per-card histogram definitions * added GetCard() method * Added option to calibrated by card ... Currently working on EventLoop() method * Implement GetCard() method within EventLoop() method :: Add option to fill uncorrected plane and card drift times while in 'card' mode during the calibration * added GetTwentyPercent_Card() method * added FitCardDriftTime() method * re-arranged methods * added card histograms to WriteToFile() method * added mode string to setup directory methood * Working version of DC Calib using 'card' optional argument * Finished implementing per card DC Calibration --- CALIBRATION/dc_calib/scripts/DC_calib.C | 1152 ++++++++++++++--- CALIBRATION/dc_calib/scripts/DC_calib.h | 67 +- CALIBRATION/dc_calib/scripts/main_calib.C | 9 +- .../scripts/old_scripts/get_LookUp_Values.C | 128 -- .../scripts/old_scripts/get_pdc_time_histo.C | 95 -- .../get_pdc_time_histo_tzero_corrected.C | 218 ---- .../scripts/old_scripts/get_tzero_param.C | 303 ----- .../old_scripts/get_tzero_per_wire_param.C | 150 --- .../scripts/old_scripts/get_wire_tzero.C | 424 ------ .../dc_calib/scripts/old_scripts/run_Cal.C | 110 -- .../scripts/old_scripts/update_pdcparam.C | 111 -- .../scripts/old_scripts/wire_drift_times.C | 308 ----- .../scripts/old_scripts/wire_drift_times.h | 552 -------- 13 files changed, 1016 insertions(+), 2611 deletions(-) delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/get_LookUp_Values.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo_tzero_corrected.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_param.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_per_wire_param.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/get_wire_tzero.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/run_Cal.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/update_pdcparam.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.C delete mode 100644 CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.h diff --git a/CALIBRATION/dc_calib/scripts/DC_calib.C b/CALIBRATION/dc_calib/scripts/DC_calib.C index 2348d582..abf9b035 100644 --- a/CALIBRATION/dc_calib/scripts/DC_calib.C +++ b/CALIBRATION/dc_calib/scripts/DC_calib.C @@ -5,13 +5,14 @@ using namespace std; //_____________________________________________________________ -DC_calib::DC_calib(string a, TString b, const int c, Long64_t d, TString e) +DC_calib::DC_calib(string a, TString b, const int c, Long64_t d, TString e, string f) :spec(a), //set spectrometer to 'HMS', or 'SHMS' ex. DC_Calib(HMS, pdc_replay.C, 488, 50000) ifile_name(b), //initialization list run_NUM(c), num_evts(d), - pid(e) + pid(e), + mode(f) { //Initialize pointers dir_log = NULL; @@ -38,12 +39,31 @@ DC_calib::DC_calib(string a, TString b, const int c, Long64_t d, TString e) twenty_perc_maxContent = NULL; ref_time = NULL; tZero_fit = NULL; - graph = NULL; gr1_canv = NULL; + + if(mode=="card") + { + //--Card Variables + entries_card = NULL; + t_zero_card = NULL; + t_zero_card_err = NULL; + card_hist = NULL; + corr_card_hist = NULL; + fitted_card_hist = NULL; + wire_min = NULL; + wire_max = NULL; + wireBinContentMax = NULL; + wireBinContentLow = NULL; + wireBinContentHigh = NULL; + wireBinHigh = NULL; + wireBinLow = NULL; + wireFitRangeLow = NULL; + wireFitRangeHigh = NULL; + } } @@ -57,6 +77,9 @@ DC_calib::~DC_calib() delete out_file; out_file = NULL; delete graph; graph = NULL; delete gr1_canv; gr1_canv = NULL; + + + //Delete 1D Arrays pointers to free up 'heap' space delete [] dt_vs_wire; dt_vs_wire = NULL; @@ -64,6 +87,7 @@ DC_calib::~DC_calib() delete [] plane_dt; plane_dt = NULL; delete [] plane_dt_corr; plane_dt_corr = NULL; + //free 2d dynamic array cell_dt[][] for(int ip = 0; ip<NPLANES; ip++) { @@ -80,6 +104,29 @@ DC_calib::~DC_calib() delete [] twenty_perc_maxContent[ip]; delete [] ref_time[ip]; delete [] offset[ip]; + + + + if (mode=="card") + { + //Card Variables + delete [] entries_card[ip]; + delete [] t_zero_card[ip]; + delete [] t_zero_card_err[ip]; + delete [] card_hist[ip]; + delete [] corr_card_hist[ip]; + delete [] fitted_card_hist[ip]; + delete [] wire_min[ip]; + delete [] wire_max[ip]; + delete [] wireBinContentMax[ip]; + delete [] wireBinContentLow[ip]; + delete [] wireBinContentHigh[ip]; + delete [] wireBinHigh[ip]; + delete [] wireBinLow[ip]; + delete [] wireFitRangeHigh[ip]; + delete [] wireFitRangeLow[ip]; + } + } delete [] entries; entries = NULL; @@ -95,8 +142,30 @@ DC_calib::~DC_calib() delete [] twenty_perc_maxContent; twenty_perc_maxContent = NULL; delete [] ref_time; ref_time = NULL; delete [] offset; offset = NULL; + + + if (mode=="card") + { + //Card Variables + delete [] entries_card; entries_card = NULL; + delete [] t_zero_card; t_zero_card = NULL; + delete [] t_zero_card_err; t_zero_card_err = NULL; + delete [] card_hist; card_hist = NULL; + delete [] corr_card_hist; corr_card_hist = NULL; + delete [] fitted_card_hist; fitted_card_hist = NULL; + delete [] wire_min; wire_min = NULL; + delete [] wire_max; wire_max = NULL; + delete [] wireBinContentMax; wireBinContentMax = NULL; + delete [] wireBinContentLow; wireBinContentLow = NULL; + delete [] wireBinContentHigh; wireBinContentHigh = NULL; + delete [] wireBinHigh; wireBinHigh = NULL; + delete [] wireBinLow; wireBinLow = NULL; + delete [] wireFitRangeLow; wireFitRangeLow = NULL; + delete [] wireFitRangeHigh; wireFitRangeHigh = NULL; + } } + //____________________________________________________________ void DC_calib::setup_Directory() { @@ -105,7 +174,7 @@ void DC_calib::setup_Directory() if (spec == "HMS") { - dir_log = Form("mkdir -p ./%s_DC_Log_%d/", spec.c_str(), run_NUM); + dir_log = Form("mkdir -p ./%s_DC_%sLog_%d/", spec.c_str(), mode.c_str(), run_NUM); //Check if directory exists if (system(dir_log) != 0) @@ -120,7 +189,7 @@ void DC_calib::setup_Directory() else if (spec == "SHMS") { - dir_log = Form("mkdir -p ./%s_DC_Log_%d/", spec.c_str(), run_NUM); + dir_log = Form("mkdir -p ./%s_DC_%sLog_%d/", spec.c_str(), mode.c_str(), run_NUM); //Check if directory exists if (system(dir_log) != 0) @@ -146,8 +215,12 @@ void DC_calib::SetPlaneNames() //initialize DC plane names if(spec=="SHMS") { - tdc_offset = 0.0; + //--per wire ONLY + percent = 0.40; + t0_err_thrs = 15; max_wire_entry = 1000; + + tdc_offset = 0.0; SPECTROMETER = "P"; spectre = "p"; @@ -163,15 +236,37 @@ void DC_calib::SetPlaneNames() planes[9] = plane_names[9]="2x1", nwires[9] = 79; planes[10] = plane_names[10]="2u2", nwires[10] = 107; planes[11] = plane_names[11]="2u1", nwires[11] = 107; - + + if (mode=="card") + { + //cout << "Setting Plane Cards . . ." << endl; + //---Per Card ONLY---- + plane_cards[0] = 7; + plane_cards[1] = 7; + plane_cards[2] = 5; + plane_cards[3] = 5; + plane_cards[4] = 7; + plane_cards[5] = 7; + plane_cards[6] = 7; + plane_cards[7] = 7; + plane_cards[8] = 5; + plane_cards[9] = 5; + plane_cards[10] = 7; + plane_cards[11] = 7; + } + } else if(spec=="HMS") { + + //per wire ONLY + percent = 0.20; ///set 20% of max drit time content to fit around + t0_err_thrs = 0; max_wire_entry = 1000; - tdc_offset = 115.; //wires 81-96 - // tdc_offset_1v2 = 109.9; //49-65 + + tdc_offset = 115.; SPECTROMETER = "H"; spectre="h"; @@ -187,6 +282,23 @@ void DC_calib::SetPlaneNames() planes[9] = plane_names[9]="2x1", nwires[9] = 102; planes[10] = plane_names[10]="2u2", nwires[10] = 96; planes[11] = plane_names[11]="2u1", nwires[11] = 96; + + if (mode=="card") + { + //---Per-Card ONLY--- + plane_cards[0] = 6; + plane_cards[1] = 6; + plane_cards[2] = 7; + plane_cards[3] = 7; + plane_cards[4] = 6; + plane_cards[5] = 6; + plane_cards[6] = 6; + plane_cards[7] = 6; + plane_cards[8] = 7; + plane_cards[9] = 7; + plane_cards[10] = 6; + plane_cards[11] = 6; + } } } @@ -194,7 +306,7 @@ void DC_calib::SetPlaneNames() //____________________________________________________________________________________ void DC_calib::SetTdcOffset() { - cout << "Setting TDC offsets for the HMS " << endl; + //cout << "Setting TDC offsets for the HMS " << endl; for (int ip = 0; ip < NPLANES; ip ++) { @@ -223,7 +335,7 @@ void DC_calib::SetTdcOffset() void DC_calib::GetDCLeafs() { - cout << "DC_calib::GetDCLeafs " << endl; + //open input root file in_file = new TFile(ifile_name, "READ" ); @@ -237,10 +349,15 @@ void DC_calib::GetDCLeafs() { cout << "Number of entries entered: " << num_evts << " exeeds MAX number of entries: " << nentries << endl; cout << "Setting the number of entries to: " << nentries << endl; - - num_evts = nentries; + num_evts = nentries; } + else if (num_evts==-1) + { + cout << "Analyzing ALL entries: " << nentries << " entries " << endl; + num_evts = nentries; + } + //Loop over each plane for (int ip = 0; ip < NPLANES; ip++) @@ -264,9 +381,9 @@ void DC_calib::GetDCLeafs() cal_etot_leaf = "P.cal.etot"; cer_npe_leaf = "P.ngcer.npeSum"; - //Check Branch Status - status_cal = tree->GetBranchStatus(cal_etot_leaf); - status_cer = tree->GetBranchStatus(cer_npe_leaf); + //Check Branch Status + status_cal = tree->GetBranchStatus(cal_etot_leaf); //returns a boolean + status_cer = tree->GetBranchStatus(cer_npe_leaf); //return a boolean if ((!status_cal || !status_cer )&& (pid=="pid_elec")) @@ -366,8 +483,29 @@ void DC_calib::AllocateDynamicArrays() twenty_perc_maxContent = new Double_t*[NPLANES]; /*Array to store 20% of maximum bin content (peak)*/ ref_time = new Double_t*[NPLANES]; /*Array to store ref_time(time corresp. to 20% of peak) times for each sense wire*/ offset = new Double_t*[NPLANES]; + + + if (mode=="card") + { + //cout << "Allocating Card Variables . . ." << endl; + //Card Variables + entries_card = new Int_t*[NPLANES]; + t_zero_card = new Double_t*[NPLANES]; + t_zero_card_err = new Double_t*[NPLANES]; + card_hist = new TH1F*[NPLANES]; //Array to store uncorrected histogram per card + fitted_card_hist = new TH1F*[NPLANES]; //Array to store fitted card histogram + corr_card_hist = new TH1F*[NPLANES]; //Array to store corrected histogram per card + wire_min = new Int_t*[NPLANES]; + wire_max = new Int_t*[NPLANES]; + wireBinContentMax = new Double_t*[NPLANES]; + wireBinContentLow = new Double_t*[NPLANES]; + wireBinContentHigh = new Double_t*[NPLANES]; + wireBinHigh = new Double_t*[NPLANES]; + wireBinLow = new Double_t*[NPLANES]; + wireFitRangeLow = new Double_t*[NPLANES]; + wireFitRangeHigh = new Double_t*[NPLANES]; + } - for(int ip=0; ip<NPLANES; ip++) { entries[ip] = new Int_t[nwires[ip]]; @@ -383,6 +521,29 @@ void DC_calib::AllocateDynamicArrays() twenty_perc_maxContent[ip] = new Double_t[nwires[ip]]; ref_time[ip] = new Double_t[nwires[ip]]; offset[ip] = new Double_t[nwires[ip]]; + + + if (mode=="card") + { + + //Card Variables + entries_card[ip] = new Int_t[plane_cards[ip]]; + t_zero_card[ip] = new Double_t[plane_cards[ip]]; + t_zero_card_err[ip] = new Double_t[plane_cards[ip]]; + card_hist[ip] = new TH1F[plane_cards[ip]]; + fitted_card_hist[ip] = new TH1F[plane_cards[ip]]; + corr_card_hist[ip] = new TH1F[plane_cards[ip]]; + wire_min[ip] = new Int_t[plane_cards[ip]]; + wire_max[ip] = new Int_t[plane_cards[ip]]; + wireBinContentMax[ip] = new Double_t [plane_cards[ip]]; + wireBinContentLow[ip] = new Double_t [plane_cards[ip]]; + wireBinContentHigh[ip] = new Double_t [plane_cards[ip]]; + wireBinLow[ip] = new Double_t [plane_cards[ip]]; + wireBinHigh[ip] = new Double_t [plane_cards[ip]]; + wireFitRangeLow[ip] = new Double_t [plane_cards[ip]]; + wireFitRangeHigh[ip] = new Double_t [plane_cards[ip]]; + + } } @@ -460,36 +621,334 @@ void DC_calib::CreateHistoNames() cell_dt_corr[ip][wire].SetXTitle("Drift Time (ns)"); cell_dt_corr[ip][wire].SetYTitle("Number of Entries / 1 ns"); - } + } //End Loop over wires + + if (mode=="card") + { + //cout << "Setting Card Histogram Names . . ." << endl; + //Loop over plane cards :: CARD_MODE + for (card = 0; card < plane_cards[ip]; card++ ) + { + + card_hist_name = Form("UnCorr_Card_%d", card+1); + card_hist_title = spec + " DC Plane " +plane_names[ip] + Form(": Uncorrected Card_%d", card+1); + + + card_hist[ip][card].SetName(card_hist_name); + card_hist[ip][card].SetTitle(card_hist_title); + card_hist[ip][card].SetBins(NBINS, MINBIN, MAXBIN); + card_hist[ip][card].SetXTitle("Drift Time (ns)"); + card_hist[ip][card].SetYTitle("Number of Entries / 1 ns"); + + fitted_card_hist_name = Form("Fitted_Card_%d", card+1); + fitted_card_hist_title = spec + " DC Plane " +plane_names[ip] + Form(": Fitted Card_%d", card+1); + + fitted_card_hist[ip][card].SetName(fitted_card_hist_name); + fitted_card_hist[ip][card].SetTitle(fitted_card_hist_title); + fitted_card_hist[ip][card].SetBins(200, MINBIN, MAXBIN); + fitted_card_hist[ip][card].SetXTitle("Drift Time (ns)"); + fitted_card_hist[ip][card].SetYTitle("Number of Entries / 1 ns"); + + + corr_card_hist_name = Form("Corr_Card_%d", card+1); + corr_card_hist_title = spec + " DC Plane " +plane_names[ip] + Form(": Corrected Card_%d", card+1); + + + corr_card_hist[ip][card].SetName(corr_card_hist_name); + corr_card_hist[ip][card].SetTitle(corr_card_hist_title); + corr_card_hist[ip][card].SetBins(NBINS, MINBIN, MAXBIN); + corr_card_hist[ip][card].SetXTitle("Drift Time (ns)"); + corr_card_hist[ip][card].SetYTitle("Number of Entries / 1 ns"); + + + } //end loop over cards + + + } //end card mode + + } //End Loop over Planes + +} //End CreateHistoNames() method + +//________________________________________________________________________ +void DC_calib::GetCard() +{ + + //ONLY required in :: CARD MODE - } + if (spec=="HMS") + { + //---1U1 MIN---- ----1U1 MAX----- + wire_min[0][0]=1; wire_max[0][0]=16; + wire_min[0][1]=17; wire_max[0][1]=32; + wire_min[0][2]=33; wire_max[0][2]=48; + wire_min[0][3]=49; wire_max[0][3]=64; + wire_min[0][4]=65; wire_max[0][4]=80; + wire_min[0][5]=81; wire_max[0][5]=96; + + //--1U2 MIN---- ---1U2 MAX------ + wire_min[1][0]=1; wire_max[1][0]=16; + wire_min[1][1]=17; wire_max[1][1]=32; + wire_min[1][2]=33; wire_max[1][2]=48; + wire_min[1][3]=49; wire_max[1][3]=64; + wire_min[1][4]=65; wire_max[1][4]=80; + wire_min[1][5]=81; wire_max[1][5]=96; + + //--1X1 MIN---- ----1X1 MAX----- + wire_min[2][0]=1; wire_max[2][0]=11; + wire_min[2][1]=12; wire_max[2][1]=27; + wire_min[2][2]=28; wire_max[2][2]=43; + wire_min[2][3]=44; wire_max[2][3]=59; + wire_min[2][4]=60; wire_max[2][4]=75; + wire_min[2][5]=76; wire_max[2][5]=91; + wire_min[2][6]=92; wire_max[2][6]=102; + + //--1X2 MIN----- ----1X2 MAX------ + wire_min[3][0]=1; wire_max[3][0]=11; + wire_min[3][1]=12; wire_max[3][1]=27; + wire_min[3][2]=28; wire_max[3][2]=43; + wire_min[3][3]=44; wire_max[3][3]=59; + wire_min[3][4]=60; wire_max[3][4]=75; + wire_min[3][5]=76; wire_max[3][5]=91; + wire_min[3][6]=92; wire_max[3][6]=102; + + //--1V2 MIN----- ---1V2 MAX------- + wire_min[4][0]=1; wire_max[4][0]=16; + wire_min[4][1]=17; wire_max[4][1]=32; + wire_min[4][2]=33; wire_max[4][2]=48; + wire_min[4][3]=49; wire_max[4][3]=64; + wire_min[4][4]=65; wire_max[4][4]=80; + wire_min[4][5]=81; wire_max[4][5]=96; + + + //--1V1 MIN----- ---1V1 MAX------- + wire_min[5][0]=1; wire_max[5][0]=16; + wire_min[5][1]=17; wire_max[5][1]=32; + wire_min[5][2]=33; wire_max[5][2]=48; + wire_min[5][3]=49; wire_max[5][3]=64; + wire_min[5][4]=65; wire_max[5][4]=80; + wire_min[5][5]=81; wire_max[5][5]=96; + + //--2V1 MIN----- ---2V1 MAX------- + wire_min[6][0]=1; wire_max[6][0]=16; + wire_min[6][1]=17; wire_max[6][1]=32; + wire_min[6][2]=33; wire_max[6][2]=48; + wire_min[6][3]=49; wire_max[6][3]=64; + wire_min[6][4]=65; wire_max[6][4]=80; + wire_min[6][5]=81; wire_max[6][5]=96; + + //--2V2 MIN----- ---2V2 MAX------- + wire_min[7][0]=1; wire_max[7][0]=16; + wire_min[7][1]=17; wire_max[7][1]=32; + wire_min[7][2]=33; wire_max[7][2]=48; + wire_min[7][3]=49; wire_max[7][3]=64; + wire_min[7][4]=65; wire_max[7][4]=80; + wire_min[7][5]=81; wire_max[7][5]=96; + + //--2X2 MIN----- ----2X2 MAX------ + wire_min[8][0]=1; wire_max[8][0]=11; + wire_min[8][1]=12; wire_max[8][1]=27; + wire_min[8][2]=28; wire_max[8][2]=43; + wire_min[8][3]=44; wire_max[8][3]=59; + wire_min[8][4]=60; wire_max[8][4]=75; + wire_min[8][5]=76; wire_max[8][5]=91; + wire_min[8][6]=92; wire_max[8][6]=102; + + //--2X1 MIN----- ----2X1 MAX------ + wire_min[9][0]=1; wire_max[9][0]=11; + wire_min[9][1]=12; wire_max[9][1]=27; + wire_min[9][2]=28; wire_max[9][2]=43; + wire_min[9][3]=44; wire_max[9][3]=59; + wire_min[9][4]=60; wire_max[9][4]=75; + wire_min[9][5]=76; wire_max[9][5]=91; + wire_min[9][6]=92; wire_max[9][6]=102; + + + //--2U2 MIN----- ---2U2 MAX------- + wire_min[10][0]=1; wire_max[10][0]=16; + wire_min[10][1]=17; wire_max[10][1]=32; + wire_min[10][2]=33; wire_max[10][2]=48; + wire_min[10][3]=49; wire_max[10][3]=64; + wire_min[10][4]=65; wire_max[10][4]=80; + wire_min[10][5]=81; wire_max[10][5]=96; + + //--2U1 MIN----- ---2U1 MAX------- + wire_min[11][0]=1; wire_max[11][0]=16; + wire_min[11][1]=17; wire_max[11][1]=32; + wire_min[11][2]=33; wire_max[11][2]=48; + wire_min[11][3]=49; wire_max[11][3]=64; + wire_min[11][4]=65; wire_max[11][4]=80; + wire_min[11][5]=81; wire_max[11][5]=96; + + + } //end hms card defnitions + + else if (spec=="SHMS") + + { + + //---1U1 MIN--- ----1U1 MAX------- + wire_min[0][0]=1, wire_max[0][0]=15; + wire_min[0][1]=16, wire_max[0][1]=31; + wire_min[0][2]=32, wire_max[0][2]=47; + wire_min[0][3]=48, wire_max[0][3]=63; + wire_min[0][4]=64, wire_max[0][4]=79; + wire_min[0][5]=80, wire_max[0][5]=95; + wire_min[0][6]=96, wire_max[0][6]=107; + + //--1U2 MIN---- ---1U2 MAX-------- + wire_min[1][0]=1, wire_max[1][0]=12; + wire_min[1][1]=13, wire_max[1][1]=28; + wire_min[1][2]=29, wire_max[1][2]=44; + wire_min[1][3]=45, wire_max[1][3]=60; + wire_min[1][4]=61, wire_max[1][4]=76; + wire_min[1][5]=77, wire_max[1][5]=92; + wire_min[1][6]=93, wire_max[1][6]=107; + + //--1X1 MIN---- ---1X1 MAX-------- + wire_min[2][0]=1, wire_max[2][0]=16; + wire_min[2][1]=17, wire_max[2][1]=32; + wire_min[2][2]=33, wire_max[2][2]=48; + wire_min[2][3]=49, wire_max[2][3]=64; + wire_min[2][4]=65, wire_max[2][4]=79; + + //--1X2 MIN---- ---1X2 MAX-------- + wire_min[3][0]=1, wire_max[3][0]=15; + wire_min[3][1]=16, wire_max[3][1]=31; + wire_min[3][2]=32, wire_max[3][2]=47; + wire_min[3][3]=48, wire_max[3][3]=63; + wire_min[3][4]=64, wire_max[3][4]=79; + + //--1V1 MIN---- --1V1 MAX--------- + wire_min[4][0]=1, wire_max[4][0]=15; + wire_min[4][1]=16, wire_max[4][1]=31; + wire_min[4][2]=32, wire_max[4][2]=47; + wire_min[4][3]=48, wire_max[4][3]=63; + wire_min[4][4]=64, wire_max[4][4]=79; + wire_min[4][5]=80, wire_max[4][5]=95; + wire_min[4][6]=96, wire_max[4][6]=107; + + //--1V2 MIN---- --1V2 MAX--------- + wire_min[5][0]=1, wire_max[5][0]=12; + wire_min[5][1]=13, wire_max[5][1]=28; + wire_min[5][2]=29, wire_max[5][2]=44; + wire_min[5][3]=45, wire_max[5][3]=60; + wire_min[5][4]=61, wire_max[5][4]=76; + wire_min[5][5]=77, wire_max[5][5]=92; + wire_min[5][6]=93, wire_max[5][6]=107; + + //--2V2 MIN---- --2V2 MAX--------- + wire_min[6][0]=1, wire_max[6][0]=12; + wire_min[6][1]=13, wire_max[6][1]=28; + wire_min[6][2]=29, wire_max[6][2]=44; + wire_min[6][3]=45, wire_max[6][3]=60; + wire_min[6][4]=61, wire_max[6][4]=76; + wire_min[6][5]=77, wire_max[6][5]=92; + wire_min[6][6]=93, wire_max[6][6]=107; + + //--2V1 MIN---- --2V1 MAX--------- + wire_min[7][0]=1, wire_max[7][0]=15; + wire_min[7][1]=16, wire_max[7][1]=31; + wire_min[7][2]=32, wire_max[7][2]=47; + wire_min[7][3]=48, wire_max[7][3]=63; + wire_min[7][4]=64, wire_max[7][4]=79; + wire_min[7][5]=80, wire_max[7][5]=95; + wire_min[7][6]=96, wire_max[7][6]=107; + + //--2X2 MIN---- --2X2 MAX--------- + wire_min[8][0]=1, wire_max[8][0]=15; + wire_min[8][1]=16, wire_max[8][1]=31; + wire_min[8][2]=32, wire_max[8][2]=47; + wire_min[8][3]=48, wire_max[8][3]=63; + wire_min[8][4]=64, wire_max[8][4]=79; + + //--2X1 MIN---- --2X1 MAX--------- + wire_min[9][0]=1, wire_max[9][0]=16; + wire_min[9][1]=17, wire_max[9][1]=32; + wire_min[9][2]=33, wire_max[9][2]=48; + wire_min[9][3]=49, wire_max[9][3]=64; + wire_min[9][4]=65, wire_max[9][4]=79; + + //--2U2 MIN---- --2U2 MAX--------- + wire_min[10][0]=1, wire_max[10][0]=12; + wire_min[10][1]=13, wire_max[10][1]=28; + wire_min[10][2]=29, wire_max[10][2]=44; + wire_min[10][3]=45, wire_max[10][3]=60; + wire_min[10][4]=61, wire_max[10][4]=76; + wire_min[10][5]=77, wire_max[10][5]=92; + wire_min[10][6]=93, wire_max[10][6]=107; + + //--2U1 MIN---- --2U1 MAX--------- + wire_min[11][0]=1, wire_max[11][0]=15; + wire_min[11][1]=16, wire_max[11][1]=31; + wire_min[11][2]=32, wire_max[11][2]=47; + wire_min[11][3]=48, wire_max[11][3]=63; + wire_min[11][4]=64, wire_max[11][4]=79; + wire_min[11][5]=80, wire_max[11][5]=95; + wire_min[11][6]=96, wire_max[11][6]=107; + + + } //end shms card definitions -} +} //End method getCard //________________________________________________________________ void DC_calib::EventLoop(string option="") { + if (mode=="card") + { + //cout << "Executing GetCard() Method . . ." << endl; + GetCard(); + } + //cout << "successful GetCards() " << endl; //Initialize counter to count how many good events (5/6 hits / chamber) ngood_evts = 0; //Loop over all entries for(Long64_t i=0; i<num_evts; i++) { - //cout << "=======Entry:======== " << i << endl; - tree->GetEntry(i); - //Initialize chamber hit counter + tree->GetEntry(i); + + //------READ USER 'pid' input to determine particle type to calibrate---------- + + //NO PID Cut, + if(pid=="pid_kFALSE") + { + cal_elec = 1; + cer_elec = 1; + } + + //PID Cut, Set Bool_t to actual leaf value, and see if it passes cut + else if (pid=="pid_elec") + { + cal_elec = cal_etot>0.1; //normalize energy > 0.1 (bkg cleanup) + cer_elec = cer_npe>1.0; //number of photoelec. > 1 (electrons) + + } + + else + { + cout << "Enter which particle to calibrate in main_calib.C: " << endl; + cout << "For electrons: 'pid_elec' " << endl; + cout << "NO PID Cuts: 'pid_KFALSE' " << endl; + cout << "Exiting NOW!" << endl; + exit (EXIT_SUCCESS); + } + + //---------------------------------------------------------------------------- + //cout << "Set PID Flags " << endl; + //Initialize chamber hit counter cnts_ch1=0; cnts_ch2=0; - //Count how many planes were hit per chamber (5/6 minimum / chamber for good events) for(int ip=0; ip<NPLANES; ip++) { - //cout << "Plane: " << ip << " Ndata: " << ndata_time[ip] << endl; - + + //Count how many planes were hit by the event if(ip<=5 && ndata_time[ip]==1) { cnts_ch1++; @@ -507,45 +966,20 @@ void DC_calib::EventLoop(string option="") { ngood_evts++; } - + good_event=kFALSE; - - //------READ USER 'pid' input to determine particle type to calibrate---------- - //NO PID Cut, - if(pid=="pid_kFALSE") - { - //cal_elec = 1; - cer_elec = 1; - } - - //PID Cut, Set Bool_t to actual leaf value, and see if it passes cut - else if (pid=="pid_elec") - { - //cal_elec = cal_etot>0.1; //normalize energy > 0.1 (bkg cleanup) - cer_elec = cer_npe>1.0; //number of photoelec. > 1 (electrons) - } - - else - { - cout << "Enter which particle to calibrate in main_calib.C: " << endl; - cout << "For electrons: 'pid_elec' " << endl; - cout << "NO PID Cuts: 'pid_KFALSE' " << endl; - cout << "Exiting NOW!" << endl; - exit (EXIT_SUCCESS); - } - - //---------------------------------------------------------------------------- - - good_event = cer_elec && cnts_ch1>4 && cnts_ch2>4; + //***good event definition***: cal_energy > 100 MeV, cer_npeSum > 1.0, 5/6 plane hits + good_event = cal_elec && cer_elec && cnts_ch1>4 && cnts_ch2>4; + // cout << "passed cut: " << i << endl; for(Int_t ip=0; ip<NPLANES; ip++) { // cout << "PLANE: " << ip << endl; - if (ndata_time[ip]==1) + if (good_event&&ndata_time[ip]==1) { @@ -557,7 +991,17 @@ void DC_calib::EventLoop(string option="") { //get wire hit for ith event in 'ip' plane - wire = int(wire_num[ip][j]); + wire = int(wire_num[ip][j]); + + //cout << "About to enter Wire Mode in EventLoop. . ." << endl; + + + + if (mode=="wire") + { + + //-----------WIRE MODE ONLY---------------------------- + if (option=="FillUncorrectedTimes") { //Fill uncorrected plane drift times (from: get_pdc_time_histo.C ) @@ -566,6 +1010,8 @@ void DC_calib::EventLoop(string option="") cell_dt[ip][wire-1].Fill(drift_time[ip][j] - offset[ip][wire-1]); fitted_cell_dt[ip][wire-1].Fill(drift_time[ip][j] - offset[ip][wire-1]); } + + else if (option=="ApplyT0Correction") { //Fill corrected plane drift times @@ -574,21 +1020,92 @@ void DC_calib::EventLoop(string option="") dt_vs_wire_corr[ip].Fill(wire_num[ip][j], drift_time[ip][j] - offset[ip][wire-1] - t_zero[ip][wire-1]); t_zero_final[ip][wire-1] = offset[ip][wire-1] + t_zero[ip][wire-1]; } - + + //-------------END WIRE MODE ONLY------------------------ + + } + + //cout << "About To Enter Card Mode in EventLoop() " << endl; + + if (mode=="card") + { + + + //cout << "Entered in Card Mode " << endl; + //------------CARD MODE ONLY----------------------------- + + if (option=="FillUncorrectedTimes") + { + + + //Fill uncorrected plane drift times + plane_dt[ip].Fill(drift_time[ip][j] - offset[ip][wire-1]); + dt_vs_wire[ip].Fill(wire_num[ip][j], drift_time[ip][j] - offset[ip][wire-1]); + + //Loop over plane cards + for (card = 0; card < plane_cards[ip]; card++ ) + { + + //Conditions + if (wire >= wire_min[ip][card] && wire <= wire_max[ip][card]) + { + //Fill Uncorrected Cards dRIFT tIME + card_hist[ip][card].Fill(drift_time[ip][j]); + fitted_card_hist[ip][card].Fill(drift_time[ip][j]); + + } //End loop over wires + + } //End loop over cards + + } //end option argument + + + else if (option=="ApplyT0Correction") + { + + for (card = 0; card < plane_cards[ip]; card++ ) + { + + //Fill Corrected plane drift times (using the CARD method) + + if (wire >= wire_min[ip][card] && wire <= wire_max[ip][card]) + { + + //Fill Corrected Plane Drift Times + plane_dt_corr[ip].Fill(drift_time[ip][j] - t_zero_card[ip][card]); + + + //Fill Corrected Card Drift Times + dt_vs_wire_corr[ip].Fill(wire_num[ip][j], drift_time[ip][j] - t_zero_card[ip][card]); + corr_card_hist[ip][card].Fill(drift_time[ip][j]-t_zero_card[ip][card]); + t_zero_final[ip][wire-1] = t_zero[ip][wire-1]; + + } + + } //loop over cards + + } //end option argument + + //------------END CARD MODE ONLY------------------------ + + + } //End CARD MODE + } //end loop over hits //----------------------------------------------------------------------------------------- - } //END loop over planes + } //good event cut - } //end loop over pid cuts + } //end plane loop } //end loop over events } // end event loop method + //_________________________________________________________________________ /* void DC_calib::CalcT0Historical() @@ -663,7 +1180,9 @@ void DC_calib::GetTwentyPercent_Peak() //Loop over DC PLANES for (int ip = 0; ip<NPLANES; ip++) { + + //Loop over DC wires for (wire = 0; wire < nwires[ip]; wire++) { @@ -671,7 +1190,7 @@ void DC_calib::GetTwentyPercent_Peak() bin_max[ip][wire] = cell_dt[ip][wire].GetMaximumBin(); //Get bin with Maximum Content bin_maxContent[ip][wire] = cell_dt[ip][wire].GetBinContent(bin_max[ip][wire]); //Get content of bin_max time_max[ip][wire] = cell_dt[ip][wire].GetXaxis()->GetBinCenter(bin_max[ip][wire]); //Get time (ns) [x-axis] corresponding to bin_max - twenty_perc_maxContent[ip][wire] = bin_maxContent[ip][wire] * 0.20; + twenty_perc_maxContent[ip][wire] = bin_maxContent[ip][wire] * percent; //Calculate 20% of max bin content //ref_time[ip][wire] = cell_dt[ip][wire].GetBinCenter(cell_dt[ip][wire].FindBin(twenty_perc_maxContent[ip][wire])); //Loop over DC drift time bins @@ -708,11 +1227,11 @@ void DC_calib::GetTwentyPercent_Peak() ref_time[ip][wire] = cell_dt[ip][wire].GetXaxis()->GetBinCenter(bin_num[0]); //Get time corresponding ~20% Max BIN CONTENT - } + } // end wire loop - } + } //end planes loop -} +} //End GetTwentyPercent_Peak() method //____________________________________________________________________________________ @@ -765,26 +1284,31 @@ void DC_calib::FitWireDriftTime() std_dev = fitted_cell_dt[ip][wire].GetStdDev(); //Require sufficient events and NOT CRAZY! tzero values, otherwis, set t0 to ZERO - if (abs(-y_int/m) < std_dev*5.0 && m > 0.2 && entries[ip][wire]>max_wire_entry) + if ( abs(-y_int/m) < std_dev*5.0 && m > 0.2 && entries[ip][wire]>max_wire_entry ) { t_zero[ip][wire] = - y_int/m ; t_zero_err[ip][wire] = sqrt(y_int_err*y_int_err/(m*m) + y_int*y_int*m_err*m_err/(m*m*m*m) ); - //calculate the weighted average - sum_NUM = sum_NUM + t_zero[ip][wire]/pow(t_zero_err[ip][wire],2); - sum_DEN = sum_DEN + 1.0/ (pow(t_zero_err[ip][wire],2)); - //cout << "wire: " << wire + 1 << " :: " << "tzero: " << t_zero[ip][wire] << endl; + + if (t_zero_err[ip][wire] < t0_err_thrs) + { + //calculate the weighted average + sum_NUM = sum_NUM + t_zero[ip][wire]/pow(t_zero_err[ip][wire],2); + sum_DEN = sum_DEN + 1.0/ (pow(t_zero_err[ip][wire],2)); + //cout << "wire: " << wire + 1 << " :: " << "tzero: " << t_zero[ip][wire] << endl; + } + else if (t_zero_err[ip][wire] >= t0_err_thrs) { + + t_zero[ip][wire] = 0.0; + + } + } - else if (abs(-y_int/m)>=5.0*std_dev || m <= 0.2 || entries[ip][wire] <= max_wire_entry) + else if (abs(-y_int/m)>=5.0*std_dev || m <= 0.2 || entries[ip][wire] <= max_wire_entry || t_zero_err[ip][wire] >= t0_err_thrs ) { - - t_zero[ip][wire] = 0.0; - //if (ip==3) { - //cout << "wire: " << wire << " t_zero_bad: " << t_zero[ip][wire] << endl; - //cout << "m = " << m << " :: " << entries[ip][wire] << endl; - //} + t_zero[ip][wire] = 0.0; } } //END LOOP OVER WIRES @@ -807,8 +1331,124 @@ void DC_calib::FitWireDriftTime() }//END LOOP OVER PLANES -} +} //End FitWireDriftTime() method + +//_______________________________________________________________________ +void DC_calib::GetTwentyPercent_Card() +{ + + binValLow = binValHigh = binSearchLow = 0, binSearchHigh = 0; + binDiffThreshHigh = 100; binDiffThreshLow = 100; + + for (int ip = 0; ip<NPLANES; ip++) + { + + for (card = 0; card < plane_cards[ip]; card++) + { + + binSearchHigh = fitted_card_hist[ip][card].GetMaximumBin(); //returns bin value of maximum content + wireBinContentMax[ip][card] = fitted_card_hist[ip][card].GetMaximum(); // return maximum histo bin content + wireBinContentLow[ip][card] = wireBinContentMax[ip][card]*0.20; // Get content with 20% of max bin content + wireBinContentHigh[ip][card] = wireBinContentMax[ip][card]*0.60; // Get content with 60% of max bin content + + + // | content_of_desired_bin - (binSearch_HighContent-binSearchLowContent) | <= binDiffTherhold + fitted_card_hist[ip][card].GetBinWithContent(wireBinContentLow[ip][card], binValLow, binSearchLow, binSearchHigh, binDiffThreshLow); + fitted_card_hist[ip][card].GetBinWithContent(wireBinContentHigh[ip][card], binValHigh, binSearchLow, binSearchHigh, binDiffThreshHigh); + + while(binValLow == 0) + { + + binDiffThreshLow = binDiffThreshLow + 100; + + fitted_card_hist[ip][card].GetBinWithContent(wireBinContentLow[ip][card], binValLow, binSearchLow, binSearchHigh, binDiffThreshLow); + + } + + while(binValHigh == 0) + { + binDiffThreshHigh = binDiffThreshHigh + 100; + + fitted_card_hist[ip][card].GetBinWithContent(wireBinContentHigh[ip][card], binValHigh, binSearchLow, binSearchHigh, binDiffThreshHigh); + } + + wireBinLow[ip][card] = binValLow; + wireBinHigh[ip][card] = binValHigh; + wireFitRangeLow[ip][card] = fitted_card_hist[ip][card].GetBinCenter(wireBinLow[ip][card]); + wireFitRangeHigh[ip][card] = fitted_card_hist[ip][card].GetBinCenter(wireBinHigh[ip][card]); + + } //end plane cards loop + + } //end planes loop + +} //end GetTwentyPercent_Card() method + +//___________________________________________________________________ +void DC_calib::FitCardDriftTime() +{ + + for (Int_t ip = 0; ip < NPLANES; ip++) + { + + //Loop over DC cards + for (card = 0; card < plane_cards[ip]; card++) + { + + tZero_fit = new TF1("tZero_fit", "[0]*x + [1]", wireFitRangeLow[ip][card], wireFitRangeHigh[ip][card]); + + //Set Parameter Names and Values + tZero_fit->SetParName(0, "slope"); + tZero_fit->SetParName(1, "y-int"); + tZero_fit->SetParameter(0, 1.0); + tZero_fit->SetParameter(1, 1.0); + + entries_card[ip][card] = fitted_card_hist[ip][card].GetEntries(); + + //Fit Function in specified range + fitted_card_hist[ip][card].Fit("tZero_fit", "QR"); + + gStyle->SetOptFit(1); + + //Get Parameters and their errors + m = tZero_fit->GetParameter(0); + y_int = tZero_fit->GetParameter(1); + m_err = tZero_fit->GetParError(0); + y_int_err = tZero_fit->GetParError(1); + std_dev = fitted_card_hist[ip][card].GetStdDev(); + + //Require sufficient events and NOT CRAZY! tzero values, otherwis, set t0 to ZERO + if (abs(-y_int/m) < std_dev*5.0 && m > 0.0 && entries_card[ip][card]>max_wire_entry) + { + + t_zero_card[ip][card] = - y_int/m ; + t_zero_card_err[ip][card] = sqrt(y_int_err*y_int_err/(m*m) + y_int*y_int*m_err*m_err/(m*m*m*m) ); + + for(wire=1; wire<=nwires[ip]; wire++) + { + + if (wire >= wire_min[ip][card] && wire <=wire_max[ip][card]) + { + + t_zero[ip][wire-1] = t_zero_card[ip][card]; + t_zero_err[ip][wire-1] = t_zero_card_err[ip][card]; + + } + + } //end wire loop + + } //end 'if' statement + + else if (abs(-y_int/m)>=5.0*std_dev || m <= 0.0 || entries_card[ip][card] <= max_wire_entry) + { + t_zero[ip][card] = 0.0; + } + + } //end loop over cards + + } // end loop over planes + +} //end FitCardDriftTime() method //________________________________________________________________ void DC_calib::Calculate_tZero() @@ -816,19 +1456,147 @@ void DC_calib::Calculate_tZero() //CalcT0Historical(); - GetTwentyPercent_Peak(); - FitWireDriftTime(); + if (mode=="wire") + { + GetTwentyPercent_Peak(); + FitWireDriftTime(); + } + + else if (mode=="card") + { + + GetTwentyPercent_Card(); + FitCardDriftTime(); + + } + } -//________________________________________________________________ -void DC_calib::WriteToFile(Int_t debug = 0) +//__________________________________________________________________________ +void DC_calib::WriteTZeroParam() { - + otxtfile_name = "./"+spec+"_DC_"+mode.c_str()+"Log_"+ std::to_string(run_NUM) +"/"+spectre+"dc_tzero_per_wire_"+std::to_string(run_NUM)+".param"; + out_txtFILE.open(otxtfile_name); - //create output ROOT file to write UnCALIB./CALIB. histos - ofile_name = "./"+spec+"_DC_Log_"+std::to_string(run_NUM) +"/"+spec+"_DC_driftimes.root"; - out_file = new TFile(ofile_name, "RECREATE"); + for (int ip=0; ip<NPLANES; ip++) { + + //write plane headers + out_txtFILE << spectre+"tzero"+plane_names[ip] << "=" << endl; + + //cout << "Plane: " << ip << endl; + for (wire=0; wire<nwires[ip]; wire++) + { + //cout << "Plane: " << ip << " :: wire: " << wire+1 << " :: " << "tzero_final: "<< t_zero_final[ip][wire] << endl; + if (wire <= 10) + { + out_txtFILE << setprecision(6) << t_zero_final[ip][wire] << fixed << ","; + } + else if (wire>10 && wire <(nwires[ip]-1)) + { + out_txtFILE << setprecision(6) << t_zero_final[ip][wire] << ((wire+1) % 16 ? ", " : "\n") << fixed; + } + else if (wire==nwires[ip]-1) + { + out_txtFILE << setprecision(6) << t_zero_final[ip][wire] << fixed << endl; + + } + + } //END LOOP OVER WIRES + + } //END LOOP OVER PLANES + + out_txtFILE.close(); + +} //end WriteTZeroParam() Method + +//_________________________________________________________________________________ +void DC_calib::WriteLookUpTable() +{ + otxtfile_name = "./"+spec+"_DC_"+mode.c_str()+"Log_"+std::to_string(run_NUM)+"/"+spectre+"dc_calib_"+std::to_string(run_NUM)+".param"; + out_txtFILE.open(otxtfile_name); + Double_t t_offset_firstbin = 0.0; + //Set headers for subsequent columns of data + out_txtFILE << Form("; Lookup Table: RUN %d", run_NUM) << "\n"; + out_txtFILE << "; number of bins in time to distance lookup table" << "\n"; + out_txtFILE << Form(spectre+"driftbins = %d", TOTAL_BINS+1) << "\n"; + out_txtFILE << "; number of 1st bin in table in ns" << "\n"; + out_txtFILE << spectre+Form("drift1stbin=%f", t_offset_firstbin + 1.) << "\n"; + out_txtFILE << "; bin size in ns" << "\n"; + out_txtFILE << spectre+"driftbinsz=1" << "\n"; + +//Loop over each plane of hms/shms Drift Chambers (DC1 & DC2) + + for (int ip=0; ip<NPLANES; ip++){ + + + //Get bin corresponding to t0 = 0 ns + bin_t0[ip] = plane_dt_corr[ip].GetXaxis()->FindBin(t_offset_firstbin); + + //Get final bin + bin_final[ip] = bin_t0[ip] + TOTAL_BINS; + + //Find total BIN Content over entire integration range + binContent_TOTAL[ip] = 0.; //set counter to zero + + + for (int bin = bin_t0[ip]; bin <= bin_final[ip]; bin ++ ) { + + bin_Content[ip] = plane_dt_corr[ip].GetBinContent(bin); + + binContent_TOTAL[ip] = bin_Content[ip] + binContent_TOTAL[ip]; + + // cout << "Bin: " << bin << endl; + // cout << "Content " << bin_Content[ip] << endl; + // cout << "Content SUM : " << binContent_TOTAL[ip] << endl; + } + + TString headers = spectre+"wc" + plane_names[ip] + "fract="; + out_txtFILE << headers; + + //Calculate LookUp Value + + binSUM[ip] = 0.0; + bin_count = 0; + + for (int bin = bin_t0[ip]; bin <= bin_final[ip]; bin++) { + + bin_Content[ip] = plane_dt_corr[ip].GetBinContent(bin); + binSUM[ip] = binSUM[ip] + bin_Content[ip]; + + + lookup_value[ip] = binSUM[ip] / binContent_TOTAL[ip]; + bin_count = bin_count + 1; + + if (bin_count <= 16 ) { + out_txtFILE << setprecision(5) << lookup_value[ip] << fixed << ","; + } + + else if (bin_count >16 && bin_count <= TOTAL_BINS) { + out_txtFILE << setprecision(5) << lookup_value[ip] << ((bin_count+1) % 20 ? "," : "\n") << fixed; + } + else { + out_txtFILE << setprecision(5) << lookup_value[ip] << fixed << endl; + } + + } //END LOOP OVER plane drift time BINS + + } //END LOOP OVER PLANES + + out_txtFILE.close(); + +} //end WriteLookUpTable() method + + + +//________________________________________________________________ +void DC_calib::WriteToFile(Int_t debug = 0) +{ + + + //create output ROOT file to write UnCALIB./CALIB. histos + ofile_name = "./"+spec+"_DC_"+mode.c_str()+"Log_"+std::to_string(run_NUM) +"/"+spec+"_DC_driftimes.root"; + out_file = new TFile(ofile_name, "RECREATE"); //***NOTE*** debug = 0 (OFF), 1 (ON) @@ -845,6 +1613,8 @@ void DC_calib::WriteToFile(Int_t debug = 0) plane_dt[ip].Write(); } + + //------write corrected plane drift time histos to a directory on FILE-------- main_dir = out_file->mkdir("corr_plane_times"); main_dir->cd(); @@ -853,15 +1623,13 @@ void DC_calib::WriteToFile(Int_t debug = 0) { //write histos to root file plane_dt_corr[ip].Write(); - } - + } - - //---------------------------------------------------------------------- - + if (mode=="wire") + { //--------write uncorrected cell drift times histos to FILE-------- main_dir = out_file->mkdir("uncorr_wire_times"); @@ -904,8 +1672,6 @@ void DC_calib::WriteToFile(Int_t debug = 0) } //END LOOP OVER PLANES - - //------------------------------------------------------------------------ @@ -934,7 +1700,7 @@ void DC_calib::WriteToFile(Int_t debug = 0) for (int ip = 0; ip < NPLANES; ip++) { - otxtfile_name = Form("./%s_DC_Log_%d/t_zero_values_%s.dat", spec.c_str(), run_NUM, planes[ip].c_str()); + otxtfile_name = Form("./%s_DC_%sLog_%d/t_zero_values_%s.dat", spec.c_str(), mode.c_str(), run_NUM, planes[ip].c_str()); out_txtFILE.open(otxtfile_name); out_txtFILE << "#Plane_" + plane_names[ip] << endl; out_txtFILE << "#Wire " << setw(12) << "tzero " << setw(12) << "t_zero_err " << setw(12) << "entries" << endl; @@ -960,7 +1726,7 @@ void DC_calib::WriteToFile(Int_t debug = 0) gr1_canv = new TCanvas("gr1", "", 2000, 500); gr1_canv->SetGrid(); //write TGraph: tzero v. wire number to root file - itxtfile_name = "./"+spec+"_DC_Log_"+ std::to_string(run_NUM) +"/"+"t_zero_values_"+plane_names[ip]+".dat"; + itxtfile_name = "./"+spec+"_DC_"+mode.c_str()+"Log_"+ std::to_string(run_NUM) +"/"+"t_zero_values_"+plane_names[ip]+".dat"; graph = new TGraphErrors(itxtfile_name, "%lg %lg %lg"); graph->SetName("graph"); @@ -982,123 +1748,101 @@ void DC_calib::WriteToFile(Int_t debug = 0) gr1_canv->Write(graph_title); //write to a root file } - - } //END DEBUG - -} - + + } //end "wire mode" -//__________________________________________________________________________ -void DC_calib::WriteTZeroParam() -{ - otxtfile_name = "./"+spec+"_DC_Log_"+ std::to_string(run_NUM) +"/"+spectre+"dc_tzero_per_wire_"+std::to_string(run_NUM)+".param"; - out_txtFILE.open(otxtfile_name); - - for (int ip=0; ip<NPLANES; ip++) { + if (mode=="card") + { + //--------write uncorrected CARD drift times histos to FILE-------- - //write plane headers - out_txtFILE << spectre+"tzero"+plane_names[ip] << "=" << endl; - - //cout << "Plane: " << ip << endl; - for (wire=0; wire<nwires[ip]; wire++) - { - //cout << "Plane: " << ip << " :: wire: " << wire+1 << " :: " << "tzero_final: "<< t_zero_final[ip][wire] << endl; - if (wire <= 10) - { - out_txtFILE << setprecision(6) << t_zero_final[ip][wire] << fixed << ","; - } - else if (wire>10 && wire <(nwires[ip]-1)) - { - out_txtFILE << setprecision(6) << t_zero_final[ip][wire] << ((wire+1) % 16 ? ", " : "\n") << fixed; - } - else if (wire==nwires[ip]-1) - { - out_txtFILE << setprecision(6) << t_zero_final[ip][wire] << fixed << endl; - - } - - } //END LOOP OVER WIRES + main_dir = out_file->mkdir("uncorr_card_times"); + + for (int ip=0; ip<NPLANES; ip++) + { + + // create planes sub-directories to store card drift times + (main_dir->mkdir("plane "+plane_names[ip], ""))->cd(); + + dt_vs_wire[ip].Write(); //write 2d drifttimet_vs_wire to FILE + + for (card = 0; card < plane_cards[ip]; card++) + { + + card_hist[ip][card].Write(); //Write wire driftimes to FILE + + } //end card loop - } //END LOOP OVER PLANES - - out_txtFILE.close(); - -} + }//end plane loop -//_________________________________________________________________________________ -void DC_calib::WriteLookUpTable() -{ - otxtfile_name = "./"+spec+"_DC_Log_"+std::to_string(run_NUM)+"/"+spectre+"dc_calib_"+std::to_string(run_NUM)+".param"; - out_txtFILE.open(otxtfile_name); - Double_t t_offset_firstbin = 0.0; - //Set headers for subsequent columns of data - out_txtFILE << Form("; Lookup Table: RUN %d", run_NUM) << "\n"; - out_txtFILE << "; number of bins in time to distance lookup table" << "\n"; - out_txtFILE << Form(spectre+"driftbins = %d", TOTAL_BINS+1) << "\n"; - out_txtFILE << "; number of 1st bin in table in ns" << "\n"; - out_txtFILE << spectre+Form("drift1stbin=%f", t_offset_firstbin + 1.) << "\n"; - out_txtFILE << "; bin size in ns" << "\n"; - out_txtFILE << spectre+"driftbinsz=1" << "\n"; - -//Loop over each plane of hms/shms Drift Chambers (DC1 & DC2) + - for (int ip=0; ip<NPLANES; ip++){ - - - //Get bin corresponding to t0 = 0 ns - bin_t0[ip] = plane_dt_corr[ip].GetXaxis()->FindBin(t_offset_firstbin); - - //Get final bin - bin_final[ip] = bin_t0[ip] + TOTAL_BINS; + //--------write corrected CARD drift times histos to FILE-------- - //Find total BIN Content over entire integration range - binContent_TOTAL[ip] = 0.; //set counter to zero - - - for (int bin = bin_t0[ip]; bin <= bin_final[ip]; bin ++ ) { - - bin_Content[ip] = plane_dt_corr[ip].GetBinContent(bin); - - binContent_TOTAL[ip] = bin_Content[ip] + binContent_TOTAL[ip]; - - // cout << "Bin: " << bin << endl; - // cout << "Content " << bin_Content[ip] << endl; - // cout << "Content SUM : " << binContent_TOTAL[ip] << endl; - } - - TString headers = spectre+"wc" + plane_names[ip] + "fract="; - out_txtFILE << headers; - - //Calculate LookUp Value - - binSUM[ip] = 0.0; - bin_count = 0; - - for (int bin = bin_t0[ip]; bin <= bin_final[ip]; bin++) { - - bin_Content[ip] = plane_dt_corr[ip].GetBinContent(bin); - binSUM[ip] = binSUM[ip] + bin_Content[ip]; - - - lookup_value[ip] = binSUM[ip] / binContent_TOTAL[ip]; - bin_count = bin_count + 1; - - if (bin_count <= 16 ) { - out_txtFILE << setprecision(5) << lookup_value[ip] << fixed << ","; - } - - else if (bin_count >16 && bin_count <= TOTAL_BINS) { - out_txtFILE << setprecision(5) << lookup_value[ip] << ((bin_count+1) % 20 ? "," : "\n") << fixed; - } - else { - out_txtFILE << setprecision(5) << lookup_value[ip] << fixed << endl; - } - - } //END LOOP OVER plane drift time BINS + main_dir = out_file->mkdir("corr_card_times"); + + for (int ip=0; ip<NPLANES; ip++) + { + + // create planes sub-directories to store card drift times + (main_dir->mkdir("plane "+plane_names[ip], ""))->cd(); + + dt_vs_wire_corr[ip].Write(); //write 2d drifttimet_vs_wire to FILE + + for (card = 0; card < plane_cards[ip]; card++) + { + + corr_card_hist[ip][card].Write(); //Write wire driftimes to FILE + + } //end card loop + + } //end plane loop + + + //-------Write Fitted Card Drift Time histos to FILE---------------------------- + - } //END LOOP OVER PLANES + main_dir = out_file->mkdir("fitted_card_drift_times"); + + for (int ip=0; ip<NPLANES; ip++) + { + + // create planes sub-directories to store fitted wire drift times + (main_dir->mkdir("plane "+plane_names[ip], ""))->cd(); + + for (card = 0; card < plane_cards[ip]; card++) + { + fitted_card_hist[ip][card].Write(); //Write card driftimes to FILE + + } + + } //end plane loop + + //-----Write 'tzero-per-card' values to a TEXT FILE-------------------- + + //open a text FILE to write + + for (int ip = 0; ip < NPLANES; ip++) + { + otxtfile_name = "./"+spec+"_DC_"+mode.c_str()+"Log_"+ std::to_string(run_NUM) +"/"+"t_zeroCARD_values_"+plane_names[ip]+".dat"; + out_txtFILE.open(otxtfile_name); + out_txtFILE << "#Plane_" + plane_names[ip] << endl; + out_txtFILE << "#Card " << setw(12) << "tzero " << setw(12) << "t_zero_err " << setw(12) << "entries" << endl; + + for (card = 0; card < plane_cards[ip]; card++) + { + out_txtFILE << card << " " << t_zero_card[ip][card] << " " << t_zero_card_err[ip][card] << " " << entries_card[ip][card] << endl; + } //end card loop + + out_txtFILE.close(); + + } //end plane loop + - out_txtFILE.close(); + } //end "card mode" + + } //END DEBUG + -} +} //end WriteToFile() method + diff --git a/CALIBRATION/dc_calib/scripts/DC_calib.h b/CALIBRATION/dc_calib/scripts/DC_calib.h index dc8fead5..90cf5ce5 100644 --- a/CALIBRATION/dc_calib/scripts/DC_calib.h +++ b/CALIBRATION/dc_calib/scripts/DC_calib.h @@ -12,11 +12,20 @@ class DC_calib public: //consructor and destructor - DC_calib(string a, TString b, const Int_t c, Long64_t d, TString e); + DC_calib(string a, TString b, const Int_t c, Long64_t d, TString e, string f); ~DC_calib(); //Define Functions + + + //----Per-Card Methods + void GetCard(); + void GetTwentyPercent_Card(); + void FitCardDriftTime(); + void ApplyTZeroCorrectionPerCard(); + + //---Per Global/Per Wire methods void setup_Directory(); void SetPlaneNames(); void SetTdcOffset(); @@ -25,7 +34,7 @@ class DC_calib void CreateHistoNames(); void EventLoop(string option); void WriteToFile(Int_t debug); - void CalcT0Historical(); + // void CalcT0Historical(); void Calculate_tZero(); void GetTwentyPercent_Peak(); void FitWireDriftTime(); @@ -34,6 +43,9 @@ class DC_calib private: + + //Calibration mode + string mode; Int_t run_NUM; Long64_t num_evts; @@ -140,7 +152,7 @@ class DC_calib Double_t **time_max; Double_t **twenty_perc_maxContent; Double_t **ref_time; - + //variables to be used in loop over bins for wire drift time Int_t content_bin; //stores content for each bin Int_t counts; //a counter used to count the number of bins that have >20% max bin content for a plane @@ -151,6 +163,7 @@ class DC_calib //Declare 'FIT' related variables Int_t **entries; //wire drift time histo entries + Int_t **entries_card; Int_t binx; Double_t time_init; //start fit value Double_t time_final; //end fit value @@ -164,11 +177,17 @@ class DC_calib Double_t std_dev; Double_t **t_zero; Double_t **t_zero_err; - + Double_t **t_zero_card; + Double_t **t_zero_card_err; + //tzero with tdc offsets taken into account, //to be written into tzero param file Double_t **t_zero_final; + //set limits on tzero fit procedure + Double_t percent; //set % of drift_time max bin content to do fit + Double_t t0_err_thrs; //set max error on t0 fit, as criteria for 'good' t0 + //declare variables to make plot of tzero v. wire number Double_t weighted_avg[NPLANES]; @@ -193,6 +212,46 @@ class DC_calib Double_t tdc_offset; Double_t max_wire_entry; + //---Per Card "SPECIFIC" Variables--- + + Int_t plane_cards[NPLANES]; //number of disc. cards / plane + Int_t card; + + //GetTwentyPercent_Card()/Fit Card methods variables + Int_t binValLow; + Int_t binValHigh; + Int_t binSearchLow; + Int_t binSearchHigh; + Double_t binDiffThreshHigh; + Double_t binDiffThreshLow; + + Double_t **wireBinContentMax; + Double_t **wireBinContentLow; + Double_t **wireBinContentHigh; + Double_t **wireBinHigh; + Double_t **wireBinLow; + Double_t **wireFitRangeLow; + Double_t **wireFitRangeHigh; + + //TStrings for Histo Names + TString card_hist_name; + TString card_hist_title; + + TString fitted_card_hist_name; + TString fitted_card_hist_title; + + TString corr_card_hist_name; + TString corr_card_hist_title; + + + //Card Histograms + TH1F **card_hist; + TH1F **corr_card_hist; + TH1F **fitted_card_hist; + + Int_t **wire_min; + Int_t **wire_max; + }; diff --git a/CALIBRATION/dc_calib/scripts/main_calib.C b/CALIBRATION/dc_calib/scripts/main_calib.C index cb25a564..42ca5066 100644 --- a/CALIBRATION/dc_calib/scripts/main_calib.C +++ b/CALIBRATION/dc_calib/scripts/main_calib.C @@ -16,11 +16,12 @@ int main_calib() clock_t cl; cl = clock(); - //pid_elec, pid_hadron, pid_kFALSE (no PID cuts) + //pid_elec, pid_kFALSE (no PID cuts) // | // v - DC_calib obj("HMS", "../../../ROOTfiles/hms_replay_production_all_1856_dcuncal.root", 1856,2000000, "pid_kFALSE"); - //DC_calib obj("SHMS", "../../../ROOTfiles/shms_replay_production_all_2071_-1_dcuncalib.root", 2071, 3000000, "pid_bkg"); + //DC_calib obj("HMS", "../../../ROOTfiles/hms_replay_production_all_1856_hodtrefcut1000_-1.root", 1856,-1, "pid_elec"); + //DC_calib obj("SHMS", "../../../ROOTfiles/shms_replay_production_all_2774_-1.root", 2774, -1, "pid_elec"); + DC_calib obj("SHMS", "~/abishek/hallc_replay/ROOTfiles/shms_replay_production_all_1791_-1.root", 1791, 10000000, "pid_elec", "card"); // DC_calib obj("HMS", "../../../ROOTfiles/hms_coin_replay_production_1866_1000000.root", 1866, 1000, "pid_kFALSE"); obj.setup_Directory(); @@ -35,7 +36,7 @@ int main_calib() obj.WriteTZeroParam(); obj.WriteLookUpTable(); obj.WriteToFile(1); //set argument to (1) for debugging - + //stop clock cl = clock() - cl; diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/get_LookUp_Values.C b/CALIBRATION/dc_calib/scripts/old_scripts/get_LookUp_Values.C deleted file mode 100644 index 3b77d8d4..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/get_LookUp_Values.C +++ /dev/null @@ -1,128 +0,0 @@ -/*This code produces a lookup table necessary to convert drift times to - drift distances in the shms drift chambers -*/ - -#define NPLANES 12 -#define TOTAL_BINS 274 -void get_LookUp_Values() { - - - //Read Run Number from txt file - int run_NUM; - Long64_t num_evts; //added - string input_file; //added - - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> input_file >> run_NUM >> num_evts; - - //Open root file containing drift time histos - TFile *f = new TFile(Form("../root_files/run%d/shms_tzero_corr_histo.root", run_NUM),"READ"); - - //Define histogram array - TH1F *h[NPLANES]; - - //Define the number Drift Chamber planes - TString plane_names[NPLANES]={"1u1", "1u2", "1x1", "1x2", "1v1", "1v2", "2v2", "2v1", "2x2", "2x1", "2u2", "2u1"}; - - //Declare bin properties - int bin_t0[NPLANES]; - int bin_final[NPLANES]; /*Array to store the bin number corresponding to last bin*/ - int bin_Content[NPLANES]; /*Array to store the content (# events) corresponding to the bin with maximum content*/ - double binContent_TOTAL[NPLANES]; /*Array to store sum of all bin contents for each plane*/ - double binSUM[NPLANES]; - int bin; - int binx; - double lookup_value[NPLANES]; /*Array to store lookup values for each plane*/ - - //Create an output file to store lookup values - ofstream ofs; - TString lookup_table = Form("../../../PARAM/SHMS/DC/CALIB/pdc_calib_%d.param", run_NUM); - ofs.open (lookup_table); - - - //Set headers for subsequent columns of data - ofs << Form("; Lookup Table: RUN %d", run_NUM) << "\n"; - ofs << "; number of bins in time to distance lookup table" << "\n"; - ofs << Form("pdriftbins = %d", TOTAL_BINS+1) << "\n"; - ofs << "; number of 1st bin in table in ns" << "\n"; - ofs << "pdrift1stbin=0" << "\n"; - ofs << "; bin size in ns" << "\n"; - ofs << "pdriftbinsz=1" << "\n"; - - - - //Loop over each plane of shms Drift Chambers (DC1 & DC2) - - for (int ip=0; ip<NPLANES; ip++){ - - TString drift_time_histo = "pdc"+plane_names[ip]+"_time"; - - //Get drift time histograms from root file - h[ip] = (TH1F*)f->Get(drift_time_histo); - - //Get bin corresponding to t0 = 0 ns - bin_t0[ip] = h[ip]->GetXaxis()->FindBin(0.0); - - //Get final bin - bin_final[ip] = bin_t0[ip] + TOTAL_BINS; - - - - //Find total BIN Content over entire integration range - binContent_TOTAL[ip] = 0; //set counter to zero - - for (bin = bin_t0[ip]; bin <= bin_final[ip]; bin ++ ) { - - bin_Content[ip] = h[ip] -> GetBinContent(bin); - - binContent_TOTAL[ip] = bin_Content[ip] + binContent_TOTAL[ip]; - - // cout << "Bin: " << bin << endl; - // cout << "Content " << bin_Content[ip] << endl; - // cout << "Content SUM : " << binContent_TOTAL[ip] << endl; - } - - TString headers = "pwc" + plane_names[ip] + "fract="; - ofs << headers; - - //Calculate LookUp Value - - binSUM[ip] = 0.0; - int bin_count = 0; - - for (bin = bin_t0[ip]; bin <= bin_final[ip]; bin++) { - - bin_Content[ip] = h[ip] -> GetBinContent(bin); - binSUM[ip] = binSUM[ip] + bin_Content[ip]; - - - lookup_value[ip] = binSUM[ip] / binContent_TOTAL[ip]; - bin_count = bin_count + 1; - - if (bin_count <= 16 ) { - ofs << setprecision(5) << lookup_value[ip] << fixed << ","; - } - - else if (bin_count >16 && bin_count <= 274) { - ofs << setprecision(5) << lookup_value[ip] << ((bin_count+1) % 20 ? "," : "\n") << fixed; - } - else { - ofs << setprecision(5) << lookup_value[ip] << fixed << endl; - } - - } - - } - -} - - - - - - - - - - diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo.C b/CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo.C deleted file mode 100644 index 6bb64537..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo.C +++ /dev/null @@ -1,95 +0,0 @@ -//Script to add necessary drift time histograms/plane from original root file to new root file - - -#define NPLANES 12 -#define NBINS 400 -#define bin_min -50.5 -#define bin_max 349.5 -void get_pdc_time_histo() -{ - - //Read Run Number from txt file - int run_NUM; - Long64_t num_evts; //added - string input_file; //added - - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> input_file >> run_NUM >> num_evts; - - TString file_name = "../../../ROOTfiles/"+input_file; - - //open file - TFile *f = new TFile(file_name, "READ"); - - //create new file - TFile *g = new TFile(Form("../root_files/run%d/shms_dc_time_%d.root", run_NUM, run_NUM), "RECREATE"); // create new file to store histo - - f->cd(); - - //Get the tree - TTree *tree = (TTree*)f->Get("T"); - TString SPECTROMETER="P"; - TString DETECTOR="dc"; - TString plane_names[NPLANES]={"1u1", "1u2", "1x1", "1x2", "1v1", "1v2", "2v2", "2v1", "2x2", "2x1", "2u2", "2u1"}; - - //Declare Variables to Loop Over - Int_t Ndata[NPLANES]; - Double_t pdc_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 = "pdc"+plane_names[ip]+"_time"; - TString title = "pdc"+plane_names[ip]+"_drifttime"; - - //Set Branch Address - tree->SetBranchAddress(drift_time, pdc_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, NBINS, bin_min, bin_max); //set time to 400 ns/200 bins = 2ns/bin - h[ip]->GetXaxis()->SetTitle("Drift Time (ns)"); - h[ip]->GetYaxis()->SetTitle("Number of Entries / 1 ns"); - } - - - //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<num_evts; i++) - { - tree->GetEntry(i); - - - //Loop over number of hits for each trigger in each DC plane - for(Int_t ip=0; ip<NPLANES; ip++){ - - - for(Int_t j=0; j<Ndata[ip]; j++){ - - h[ip]->Fill(pdc_time[ip][j]); - } - - } - - } - - //Write histograms to file - - g->Write(); - -} diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo_tzero_corrected.C b/CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo_tzero_corrected.C deleted file mode 100644 index b8e6f595..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/get_pdc_time_histo_tzero_corrected.C +++ /dev/null @@ -1,218 +0,0 @@ -#define NPLANES 12 -#define NBINS 400 -using namespace std; -void get_pdc_time_histo_tzero_corrected() -{ - - - int run_NUM; - Long64_t num_evts; //added - string input_file; //added - - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> input_file >> run_NUM >> num_evts; - - TString run = Form("run%d", run_NUM); - - //this script reads all tzero values inside tzero_group.dat and assigns them to their corresponding planes. - //these values will then be used to shift the drift time histos, wire by wire (t0-correction wire-by-wire) - - int ip; //to loop over planes - int sw; //to loop over sensewires - - - int tot_wires[NPLANES] = {107, 107, 79, 79, 107, 107, 107, 107, 79, 79, 107, 107}; - - //sum over all wires in both DC - int wire_sum = 0; - for (ip=0; ip<NPLANES; ip++) { - wire_sum = wire_sum + tot_wires[ip]; - } - - - //open and read tzero data file - ifstream file; - file.open("../data_files/"+run+"/tzero_values_per_wire.dat"); - - string line; - int counter; - Double_t value; - Double_t *tzero_offset; - tzero_offset = new Double_t[wire_sum]; - - - counter = 0; - - while (getline(file, line)) { - - if (line[0]!='#' ) - { - sscanf(line.c_str(), "%lf", &value); //pass data in file to variable 'value' - tzero_offset[counter] = value; //write all tzero values for all wires in both DC to an array - //cout << tzero_offset[counter] << endl; - counter++; - } - } - - - //*************************************************************** - - //pass all tzero values into their corresponding planes - - //declare a 2d dynamic array to store tzero values to be used for t0-correction - Double_t **tzero = new Double_t*[NPLANES]; - - for (ip = 0; ip < NPLANES; ip++) - { - tzero[ip] = new Double_t[tot_wires[ip]]; - } - - //initialize 2d dynamic array to 0.0 - for (ip = 0; ip<NPLANES; ip++) { - for (sw = 0; sw<tot_wires[ip]; sw++) { - tzero[ip][sw] = 0.0; - - } - } - - counter = 0; - for (ip = 0; ip<NPLANES; ip++) { - - for (sw = 0; sw < tot_wires[ip]; sw++) { - - tzero[ip][sw] = tzero_offset[counter]; //tzero corrections that must be added wire by wire - //cout << tzero[ip][sw] << endl; - //cout << tzero[ip][sw] << " :: "<<tzero_offset[counter] << endl; - counter++; - } - } - - - - - - //***************************************************************************************** - - //THIS SCRIPT WILL READ the drift times array tzero[ip][sw] on a wire basis and apply the tzero correction. - - - - int i; - - int bin_width = 1; - int bin_Content; - Double_t shift; //will be the t0 offset - - //Declare plane names to loop over - - TString plane_names[NPLANES]={"1u1", "1u2", "1x1", "1x2", "1v1", "1v2", "2v2", "2v1", "2x2", "2x1", "2u2", "2u1"}; - - //Declare a root file to read individual DC cell drift times - TString root_file; - TFile *f[NPLANES]; - - //Declare root file were NEW tzero corrected histograms will be added - TString file_name = Form("../root_files/run%d/shms_tzero_corr_histos.root", run_NUM); - TFile *g = new TFile(file_name, "RECREATE"); - - TH1F *h_add[NPLANES]; //t0-corrected plane drift times - - - - - - //Loop over all planes - for (ip = 0; ip < NPLANES; ip++){ - - //READ wire drift time root file per plane - root_file = "../root_files/"+run+"/shms_DC_"+plane_names[ip]+Form("_%d_wire_histos.root",run_NUM); - f[ip] = new TFile(root_file, "READ"); - - - h_add[ip] =new TH1F("plane_"+plane_names[ip]+"drifttime", "", NBINS, -50, 350); - - h_add[ip]->GetXaxis()->SetTitle("Drift Time (ns)"); - h_add[ip]->GetYaxis()->SetTitle("Number of Entries / 1 ns"); - - - TH1F *cell_dt[107]; - TH1F *cell_dt_corr[107]; - - - - //Get wire histos from root file and loop over each - // sense wire of a plane in shms Drift Chambers (DC1 or DC2) - - f[ip]->cd(); //change to file containing uncorrected wire drift times - - for (sw=1; sw<=tot_wires[ip]; sw++){ - - - - //set title of histos in root file - TString drift_time_histo = Form("wire_%d", sw); - - //Get drift time histograms from root file - cell_dt[sw-1] = (TH1F*)f[ip]->Get(drift_time_histo); - - - //Create corrected wire histos - cell_dt_corr[sw-1] = new TH1F(plane_names[ip]+Form("_wire_%d_corr", sw), "", NBINS, -50, 350); - - cell_dt_corr[sw-1]->GetXaxis()->SetTitle("Drift Time (ns)"); - cell_dt_corr[sw-1]->GetYaxis()->SetTitle("Number of Entries / 1 ns"); - - - shift = tzero[ip][sw-1]; //the shift represents how much the drift time histo needs to be offset - - //cout << "sw: " << sw << " :: " << "offset: " << shift << endl; - - //************APPLY TZERO OFFSET ON A WIRE-BY-WIRE BASIS TO ALL WIRES IN ALL PLANES*************** - - - //INCLUDE the code 'shift.C ', which shifts a histogram - - for (i=1; i<=NBINS; i++) { - - bin_Content = cell_dt[sw-1]->GetBinContent(i); - - - cell_dt_corr[sw-1]->SetBinContent(i-shift/bin_width, bin_Content); //apply the t0 correction - - } - - - - - //************************************************************************************************* - - - - //write wire drift times (after tzero corrections) to file - g->cd(); - cell_dt_corr[sw-1]->Write(plane_names[ip]+Form("_wire_%d", sw), TObject::kWriteDelete); - - - //add all cell drift times into a single plane - h_add[ip]->Add(cell_dt_corr[sw-1]); - - - - } // end loop over sense wires - - - //Wire combined wire drift times (t0 -corrected) for each plane to file, - g->cd(); - h_add[ip]->Write(); - - - - - } // end loop over planes - - - - - -} diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_param.C b/CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_param.C deleted file mode 100644 index 1e1e061f..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_param.C +++ /dev/null @@ -1,303 +0,0 @@ -#include <iostream> -#include <fstream> -#include <math.h> -#include <string> - -#define NPLANES 12 - - -void get_tzero_param() -{ - - //read run number from input file - int run_NUM; - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> run_NUM; - - TString run = Form("run%d", run_NUM); - - // 0 1 2 3 4 5 6 7 8 9 10 11 - //TString planes[NPLANES] = {"1u1","1u2","1x1","1x2","1v1","1v2","2u1","2u2","2x1","2x2","2v1","2v2"}; - - TString planes[NPLANES] = {"1u1","1u2","1x1","1x2","1v1","1v2","2v2","2v1","2x2","2x1","2u2","2u1"}; //planes 0, 1, 2, 3, 4, 5 OK :: - - //what needs to be changed - - //2u1 (6) --> 2v2 (11)|| 2u2 (7) --> 2v1 (10)||, 2x1 (8) --> 2x2(9)||, - - -int fNWires[NPLANES] = {107, 107, 79, 79, 107, 107, 107, 107, 79, 79, 107, 107}; -int group_size[NPLANES] = {7, 7, 5, 5, 7, 7, 7, 7, 5, 5, 7, 7}; - -int group; -int sw; -int ip; - - - -//allocate space for calc. of weighted avg of cable group -Double_t *sum_NUM; -Double_t *sum_DEN; -Double_t *weighted_AVG; -Double_t *weighted_AVG_err; - -Int_t *wire; -Double_t *t0; -Double_t *t0_err; -Int_t *entries; - -Int_t **dc_group_min; -Int_t **dc_group_max; - -//dynamic allocation of a 2d array in dim. of plane and groups, (depending on which plane, group size is 5 or 7) -dc_group_min = new Int_t*[NPLANES]; -for (ip=0; ip<NPLANES; ip++){ - dc_group_min[ip] = new Int_t[group_size[ip]]; -} - - -//Fill the 2d array with 1st sensewire corresponding to each group in a given plane - for (ip=0; ip<NPLANES; ip++) { - - dc_group_min[ip][0]=1; //set initial array value to 1st sensewire in the group - for (group=1; group < group_size[ip]; group++){ - - if (ip==2 || ip==9){ - //dc_group_min[ip][5] = {1, 17, 33, 49, 65}; //plane 2(1x1) or plane9(2x1) - dc_group_min[ip][group] = dc_group_min[ip][group-1] + 16; - } - - else if (ip==3 || ip==8){ - //dc_group_min[ip][5] = {{1, 16, 32, 48, 64}}; //plane 3(1x2) or plane 8(2x2) - dc_group_min[ip][1]=16; - dc_group_min[ip][group+1] = dc_group_min[ip][group] + 16; - } - - else if(ip==0 || ip==4 || ip==11 || ip ==7){ - // dc_group_min[ip][7] = {{1, 16, 32, 48, 64, 80, 96}}; //planes: 1u1, 1v1, 2u1, 2v1 - dc_group_min[ip][1]=16; - dc_group_min[ip][group+1] = dc_group_min[ip][group] + 16; - } - - else if(ip==1 || ip==5 || ip==10 || ip==6){ - // dc_group_min[ip][7] = {{1, 13, 29, 45, 61, 77, 93}}; //planes 1u2, 1v2, 2u2, 2v2 - dc_group_min[ip][1]=13; - dc_group_min[ip][group+1] = dc_group_min[ip][group] + 16; - } - - }//end loop over groups - - - }//end loop over planes - - //**************************************** - - //dynamic allocation of a 2d array in dim. of plane and groups, (depending on which plane, group size is 5 or 7) -dc_group_max = new Int_t*[NPLANES]; -for (ip=0; ip<NPLANES; ip++){ - dc_group_max[ip] = new Int_t[group_size[ip]]; -} - -//Fill the 2d array with last sensewire corresponding to each group in a given plane - for (ip=0; ip<NPLANES; ip++) { - - - for (group=1; group < group_size[ip]; group++){ - - if (ip==2 || ip==9){ - //dc_group_max[ip][5] = {16, 32, 48, 64, 79}; //plane 2(1x1) or plane 9(2x1) - dc_group_max[ip][0]=16; - dc_group_max[ip][group] = dc_group_max[ip][group-1] + 16; - } - - else if (ip==3 || ip==8){ - //dc_group_max[ip][5] = {15, 31, 47, 63, 79}; //plane 3(1x2) or plane 8(2x2) - dc_group_max[ip][0]=15; - dc_group_max[ip][group] = dc_group_max[ip][group-1] + 16; - } - - else if(ip==0 || ip==4 || ip==11 || ip ==7){ - // dc_group_max[ip][7] = {15, 31, 47, 63, 79, 95, 107}; //planes: 1u1, 1v1, 2u1, 2v1 - dc_group_max[ip][0]=15; - dc_group_max[ip][group] = dc_group_max[ip][group-1] + 16; - } - - else if(ip==1 || ip==5 || ip==10 || ip==6){ - // dc_group_max[ip][7] = {12, 28, 44, 60, 76, 92, 107}; //planes 1u2, 1v2, 2u2, 2v2 - dc_group_max[ip][0]=12; - dc_group_max[ip][group] = dc_group_max[ip][group-1] + 16; - } - - }//end loop over groups - - - }//end loop over planes - - - - - - //********************************* - //sanity check to see if arrays were filled properly! - // for (int i=0; i<7; i++) { - // cout << dc_group_max[1][i] << endl; - // } - //note: some planes max values exceeded th ephysical max wire, - //but does not pose any problems when setting the limits - //********************************* - - - - - //declare a 2d dynamic arrays to store weighted average per group - Double_t** weighted_avg = new Double_t*[NPLANES]; - Double_t** weighted_avg_err = new Double_t*[NPLANES]; - - for (ip = 0; ip < NPLANES; ip++) { - weighted_avg[ip] = new Double_t[group_size[ip]]; - weighted_avg_err[ip] = new Double_t[group_size[ip]]; - } - - //initialize a 2d dynamic array - for (ip=0; ip<NPLANES; ip++) { - for (group=0; group<group_size[ip]; group++) { - weighted_avg[ip][group] = 0.0; - weighted_avg_err[ip][group] = 0.0; - } - } - - -//Loop over each plane - for(ip=0; ip<NPLANES; ip++) { - - - - wire = new Int_t[fNWires[ip]]; - t0 = new Double_t[fNWires[ip]]; - t0_err = new Double_t[fNWires[ip]]; - entries = new Int_t[fNWires[ip]]; - - - //open and read each wire tzero file - ifstream ifs; - ifs.open(Form("../data_files/run%d/hdc_"+planes[ip]+"tzero_run%d_updated.txt", run_NUM, run_NUM ) ); - - - - if (ifs.is_open()) { - // cout << "File opened!" << endl; - ifs.ignore(50000, '\n'); //ignore the first line - - for (sw=0; sw<fNWires[ip]; ++sw) { - ifs >> wire[sw] >> t0[sw] >> t0_err[sw] >> entries[sw]; - //cout - // << "wire: " << wire[sw] << " " << endl; - // << "t0: " << t0[sw] << " " - // << "t0_err: " << t0_err[sw] << " " - // << "entries: " << entries[sw] << endl; - } - ifs.close(); - } // ifstream condition - else { - // cout << "File not opened!" << endl; - } - - //Loop over each ribbon cable group of wires - for (group =0; group<group_size[ip]; group++) { - - //initialize variables - double sum_num = 0.0; - double sum_den = 0.0; - double w_avg = 0.0; - double w_avg_err = 0.0; - - for (sw = 1; sw<=fNWires[ip]; sw++) { - - // compute the sums if the sense wires lie in a given group - if (sw >= dc_group_min[ip][group] && sw <= dc_group_max[ip][group] && t0[sw-1]!=0) { - - //calculate numerator and denominator of weighted average for each group - - sum_num = sum_num + t0[sw-1]/(t0_err[sw-1]*t0_err[sw-1]); - sum_den = sum_den + 1.0/(t0_err[sw-1]*t0_err[sw-1]); - - - } - - } // end loop over sensewires - - //compute weighted average per ribbon cable group - if (sum_den!=0.0) { - w_avg = sum_num / sum_den; - w_avg_err = sqrt( 1.0 / sum_den ); - - weighted_avg[ip][group] = w_avg; //write weighted average to an array - weighted_avg_err[ip][group] = w_avg_err; - } - - } //end loop over groups - - } //end loop over planes - - - //create output file stream to write tzero values to a data file - ofstream out; - TString tzero_file = "../data_files/"+run+"/tzero_group.dat"; - out.open(tzero_file); - - //Create an output parameter file to store tzero values - ofstream ofs; - TString wire_tzero = Form("./pdc_tzero_per_wire_run%d.param", run_NUM); - ofs.open (wire_tzero); - - //loop over planes - for (ip = 0; ip < NPLANES; ip++) - { - //write plane headers - ofs << "ptzero"+planes[ip] << "=" << endl; - out << "#PLANE: " << planes[ip] << endl; - //loop over group - for (group = 0; group < group_size[ip]; group++) - { - out << "#GROUP: " << group+1 << endl; - - //loop over sensewires - for (sw = 1; sw<=fNWires[ip]; sw++) { - - if (sw >= dc_group_min[ip][group] && sw <= dc_group_max[ip][group]) - { - out << setprecision(7) << weighted_avg[ip][group] << endl; - if (sw<fNWires[ip]) - { - ofs << setprecision(7) << weighted_avg[ip][group] << ((sw+1) % 16 ? ", " : "\n") << fixed; - } - else { - ofs << setprecision(7) << weighted_avg[ip][group] << fixed << endl; - ofs << endl; - } - } - - } // end loop over sensewires - - }// end loop over groups - - }//end loop over planes - - //close files - ofs.close(); - out.close(); - -} - - - - - - - - - - - - diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_per_wire_param.C b/CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_per_wire_param.C deleted file mode 100644 index 7dd900b9..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/get_tzero_per_wire_param.C +++ /dev/null @@ -1,150 +0,0 @@ -#include <iostream> -#include <fstream> -#include <math.h> -#include <string> - -#define NPLANES 12 - -using namespace std; -void get_tzero_per_wire_param() -{ - - - //read run number from input file - int run_NUM; - Long64_t num_evts; //added - string input_file; //added - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> input_file >> run_NUM >> num_evts; - - TString run = Form("run%d", run_NUM); - - TString planes[NPLANES] = {"1u1","1u2","1x1","1x2","1v1","1v2","2v2","2v1","2x2","2x1","2u2","2u1"}; //planes 0, 1, 2, 3, 4, 5 OK :: - - - int fNWires[NPLANES] = {107, 107, 79, 79, 107, 107, 107, 107, 79, 79, 107, 107}; - - int sw; - int ip; - -Int_t **wire = new Int_t*[NPLANES]; -Double_t **t0 = new Double_t*[NPLANES]; -//Double_t **t0_err = new Double_t*[NPLANES]; -//Int_t **entries = new Int_t*[NPLANES]; - - for (ip = 0; ip < NPLANES; ip++) { - t0[ip] = new Double_t[fNWires[ip]]; - for (sw=0; sw<fNWires[ip]; sw++) { - t0[ip][sw] = 0.0; - } - } - - - -//Loop over each plane - for(ip=0; ip<NPLANES; ip++) { - - //write plane headers - - int nwire; - double nt0; - double nt0_err; - int nentries; - - - //open and read each wire tzero file - TString file_name = Form("../data_files/run%d/shms_dc_", run_NUM) + planes[ip] + Form("tzero_run%d_updated.dat", run_NUM); - - // cout << file_name << endl; - - string line; - ifstream input; - input.open(file_name); - - - sw = 0; - while (getline(input, line)) - { - // cout << line << endl; - if (line[0]!='#') - { - // if(!input.good()) {break;} - sscanf(line.c_str(), "%d %lf", &nwire, &nt0); - - - // if(sw>0) { - - t0[ip][nwire-1] = nt0; - - // } - // sw++; - - } - - } - - input.close(); - - - - - - } //end loop over planes - - -//create output file stream to write tzero values to a data file - ofstream out; - TString tzero_file = "../data_files/"+run+"/tzero_values_per_wire.dat"; - out.open(tzero_file); - - //Create an output parameter file to store tzero values - ofstream ofs; - TString wire_tzero = Form("../../../PARAM/SHMS/DC/CALIB/pdc_tzero_per_wire_%d.param", run_NUM); - ofs.open (wire_tzero); - - - for (ip=0; ip<NPLANES; ip++) { - - //write plane headers - ofs << "ptzero"+planes[ip] << "=" << endl; - out << "#PLANE: " << planes[ip] << endl; - - for (sw=0; sw<fNWires[ip]; sw++) { - - out << setprecision(6) << t0[ip][sw] << endl; - - if (sw <= 10) - { - ofs << setprecision(6) << t0[ip][sw] << fixed << ","; - } - else if (sw>10 && sw <(fNWires[ip]-1)) - { - ofs << setprecision(6) << t0[ip][sw] << ((sw+1) % 16 ? ", " : "\n") << fixed; - } - else if (sw==78 || sw == 106) { - ofs << setprecision(6) << t0[ip][sw] << fixed << endl; - } - - - - } - } - - //close files - ofs.close(); - out.close(); - -} - - - - - - - - - - - - diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/get_wire_tzero.C b/CALIBRATION/dc_calib/scripts/old_scripts/get_wire_tzero.C deleted file mode 100644 index 343a2feb..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/get_wire_tzero.C +++ /dev/null @@ -1,424 +0,0 @@ - - -/*Script to extract reference time "t0" for each sense wire in a given HMS Wire Chamber Plane with COSMIC RUNS. -20% (MAX BIN CONTENT) is calculated per wire, and the corresponding bin is fitted linearly about +/- -a certain number of bins and this fit is extrapolated to y=0(x-axis). The extrapolated value is take to be t0*/ - -#include <vector> -#include "TMath.h" -#include <iomanip> -#include <iostream> - -#define NPLANES 12 - using namespace std; -void get_wire_tzero() -{ - - - int run_NUM; - Long64_t num_evts; //added - string input_file; //added - - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> input_file >> run_NUM >> num_evts; //read the input file (added) - - //check if tzero_weighted_avg text file exists (if it does, DELETE IT, otherwise new values will be appended to it, in addition to pre-existing tzero values) - std::ifstream stream(Form("../data_files/run%d/tzero_weighted_avg_run%d.dat",run_NUM, run_NUM)); - if (stream.good()) - { - gSystem->Exec(Form("rm ../data_files/run%d/tzero_weighted_avg_run%d.dat",run_NUM, run_NUM)); - } - - TString run = Form("run%d", run_NUM); - - //Declare plane names to loop over - TString plane_names[NPLANES]={"1u1", "1u2", "1x1", "1x2", "1v1", "1v2", "2v2", "2v1", "2x2", "2x1", "2u2", "2u1"}; - int fNWires[NPLANES] = {107, 107, 79, 79, 107, 107, 107, 107, 79, 79, 107, 107}; - - //Declare a root file array to store individual DC cell drift times - TString root_file; - TFile *f[NPLANES]; - - // int total_wires; //integer to store total sense wires for a plane chosen by the user - - //Loop over all planes - for (int ip = 0; ip < NPLANES; ip++){ - - //READ root file - root_file = "../root_files/"+run+"/shms_DC_"+plane_names[ip]+Form("_%d_wire_histos.root",run_NUM); - f[ip] = new TFile(root_file, "READ"); - - //Create a file output file stream object to write t0 values to data file - ofstream ofs; - TString t_zero_file = "../data_files/" + run + "/shms_dc_"+plane_names[ip]+Form("tzero_run%d.dat", run_NUM); - ofs.open (t_zero_file); - - //Set headers for subsequent columns of data - ofs << "#WIRE " << setw(15) << "t0" << setw(15) << "t0_err" << setw(15) << "entries" << endl; - - //Create root file to store fitted wire drift times histos and "t0 vs. wirenum" - TString output_root_file = "../root_files/"+run+"/shms_DC_"+plane_names[ip]+Form("_%d_fitted_histos.root", run_NUM); - TFile *g = new TFile(output_root_file,"RECREATE"); - - f[ip]->cd(); //change to file containing the wire drift times histos - - // int total_wires; //integer to store total sense wires for a plane chosen by the user - - //INITIALIZE VARIABLES - int total_wires; - int sensewire; - TH1F *cell_dt[107]; - Int_t *bin_max; - Int_t *bin_maxContent; - Double_t *time_max; - Double_t *twenty_perc_maxContent; - Double_t *ref_time; - - - - //Declarations - int time_init; //start fit value - int time_final; //end fit value - int t_zero; - int entries; //entries for each wire - - double m; //slope - double y_int; //y-intercept - double m_err; - double y_int_err; - double t_zero_err; - - //Set variables depending on which plane is being studied - if(ip == 0 || ip == 1 || ip == 4 || ip == 5 || ip == 6 || ip == 7 || ip == 10 || ip == 11) { - //declare array of histos to store drift times - total_wires=107; - - //Declare bin properties for given sense wires in a plane - - bin_max = new Int_t[total_wires]; /*Array to store the bin number corresponding to the drift time distribution peak*/ - bin_maxContent= new Int_t[total_wires]; /*Array to store the content (# events) corresponding to the bin with maximum content*/ - time_max= new Double_t[total_wires]; /*Array to store the x-axis(drift time (ns)) corresponding to bin_max*/ - twenty_perc_maxContent= new Double_t[total_wires]; /*Array to store 20% of maximum bin content (peak)*/ - ref_time= new Double_t[total_wires]; /*Array to store reference times for each sense wire*/ - - } - - else if(ip == 2 || ip == 3 || ip == 8 || ip == 9) { - total_wires=79; - bin_max = new Int_t[total_wires]; - bin_maxContent= new Int_t[total_wires]; - time_max= new Double_t[total_wires]; - twenty_perc_maxContent= new Double_t[total_wires]; - ref_time= new Double_t[total_wires]; - } - - - /*Get wire histos from root file and loop over each - sense wire of a plane in shms Drift Chambers (DC1 or DC2)*/ - - for (sensewire=1; sensewire<=total_wires; sensewire++){ - - //Get title of histos in root file - TString drift_time_histo = Form("wire_%d", sensewire); - - //Get drift time histograms from root file - cell_dt[sensewire-1] = (TH1F*)f[ip]->Get(drift_time_histo); - - - //Get bin with Maximum Content - bin_max[sensewire-1] = cell_dt[sensewire-1]->GetMaximumBin(); - - //Get content of bin_max - bin_maxContent[sensewire-1] = cell_dt[sensewire-1]->GetBinContent(bin_max[sensewire-1]); - - //Get time (ns) [x-axis] corresponding to bin_max - time_max[sensewire-1] = cell_dt[sensewire-1]->GetXaxis()->GetBinCenter(bin_max[sensewire-1]); - - //Calculate 20% of max content - twenty_perc_maxContent[sensewire-1] = bin_maxContent[sensewire-1] * 0.20; - - - } - - - - //****************************************************// - //Determine which bin has around 20% max_BinContent *// - //****************************************************// - - - //Declarations - int content_bin; //stores content for each bin - int counts; //a counter used to count the number of bins that have >20% max bin content for a plane - int bin; //store bin number - int j; //jth bin, used to loop over n bins - - //Declare vector arrays - vector<int> content; //stores bin content - vector <int> bin_num; //stores bin number - - - //Loop over each wire - for(sensewire=1; sensewire<=total_wires; sensewire++) { - - //Loop over each bin for individual wire drift time histo - for(bin=0; bin < bin_max[sensewire-1]; bin++) { - - content_bin = cell_dt[sensewire-1]->GetBinContent(bin); //get bin content for all bins in a wire - - content.push_back(content_bin); //add bin content to array - bin_num.push_back(bin); //add bin number to array - - - // check if 2 bin contents have been stored and examine if these contents exceed or not 20% of peak - if (content.size() == 2) { - - //initialize counter to count how many bin contents >= 20% - counts = 0; - - // Loop over 2 bin contents stored in array content - for (j=0; j<2; j++){ - - if(content[j] >= twenty_perc_maxContent[sensewire-1]){ - counts = counts+1; - - if(counts >= 2) { goto stop;} - - - } - - content.clear(); - bin_num.clear(); - - } - - } - } - - //Print the time(ns) and BIN NUM corresponding to 20% of MAX content - //if 2/2 elements exceeds 20% of Max content (for each plane) - - stop: - ref_time[sensewire-1] = cell_dt[sensewire-1] ->GetXaxis() -> GetBinCenter(bin_num[0]); //Get time corresponding ~20% Max BIN CONTENT - - //cout << " ******* " << "Wire " << sensewire << " ******* " << endl; - //cout << "time (20% of Max BIN): " << ref_time[sensewire-1] << " ns" << endl; - //cout << "BIN: " << bin_num[0] << endl; - - - //*********************************************************// - //*******Extract the "t0" Using a Fitting Procedure********// - //*********************************************************// - - - - //Get time corresponding to bin (fit range) - time_init = cell_dt[sensewire-1] -> GetXaxis() -> GetBinCenter(bin_num[0]-5); //choose bin range over which to fit - time_final = cell_dt[sensewire-1] -> GetXaxis() -> GetBinCenter(bin_num[0]+5); - - //Create Fit Function - TF1* tZero_fit = new TF1("tZero_fit", "[0]*x + [1]", time_init, time_final); - - //Set Parameter Names and Values - tZero_fit->SetParName(0, "slope"); - tZero_fit->SetParName(1, "y-int"); - tZero_fit->SetParameter(0, 1.0); - tZero_fit->SetParameter(1, 1.0); - - //Fit Function in specified range - cell_dt[sensewire-1]->Fit("tZero_fit", "QR"); - - //Get Parameters and their errors - m = tZero_fit->GetParameter(0); - y_int = tZero_fit->GetParameter(1); - m_err = tZero_fit->GetParError(0); - y_int_err = tZero_fit->GetParError(1); - - //Calculate error on t0 using error propagation method of expanding partial derivatives - t_zero = - y_int/m; - t_zero_err = sqrt(y_int_err*y_int_err/(m*m) + y_int*y_int*m_err*m_err/(m*m*m*m) ); - entries = cell_dt[sensewire-1]->GetEntries(); //number of entries (triggers) per wire - //cout << "y_int: " << y_int << " :: " << "m: " << m << " :: " << "t0: " << setprecision(6) << -y_int/m << endl; - //Write "t0" values to file - ofs << sensewire << setw(15) << setprecision(6) << -y_int/m << setw(15) << t_zero_err << setw(15) << entries << endl; - - //Change to output root file and write fitted histos to file - g->cd(); - cell_dt[sensewire-1]->Write(); - - } - - // Make Plot of t0 versus Wire Number - - TCanvas *t = new TCanvas("t", "", 2000,500); - t->SetGrid(); - - - TGraphErrors *graph = new TGraphErrors(t_zero_file, "%lg %lg %lg"); - graph->SetName("graph"); - TString title = "DC"+plane_names[ip]+": t0 versus sensewire"; - graph->SetTitle(title); - graph->SetMarkerStyle(20); - graph->SetMarkerColor(1); - graph->GetXaxis()->SetLimits(0., total_wires); - graph->GetXaxis()->SetTitle("Wire Number"); - graph->GetXaxis()->CenterTitle(); - graph->GetYaxis()->SetTitle("t-Zero (ns)"); - graph->GetYaxis()->CenterTitle(); - graph->GetYaxis()->SetRangeUser(-50.0, 50.0); - graph->Draw("AP"); - t->Update(); - t->Write(title); //write to a root file - - - //close dat file - ofs.close(); - - //*****************************************************************************************// - // CALCULATE THE "t0s" WEIGHTED AVERAGE FOR WIRE DRIFT TIMES WITH ENTRIES > = 300 // - //*****************************************************************************************// - - - //open t0 dat file - ifstream ifs; - ifs.open (t_zero_file); - string line; - - //open new data file to write updated t0 values - TString t_zero_file_corr = "../data_files/" + run + "/shms_dc_"+plane_names[ip]+Form("tzero_run%d_updated.dat", run_NUM); - ofs.open(t_zero_file_corr); - ofs << "#Wire" << setw(15) << "t_zero" << setw(15) << "t_zero_err" << setw(15) << "entries" << endl; - - //Initialize variables related to weighted avg - double sum_NUM; //numerator of weighted avg - double sum_DEN; //denominator of weighted avg - double weighted_AVG; - double weighted_AVG_err; - - int counter; - // double t0_corr; - //double t0_corr_err; - Double_t t0; - Double_t t0_err; - - //set them to zero to start sum inside while loop - sum_NUM = 0.0; - sum_DEN = 0.0; - - weighted_AVG =0.0 ; - weighted_AVG_err= 0.0; - - counter = 0; - //read line bt line the t_zero_file - while(getline(ifs, line)) { - - if(line[0]!='#') { - - sscanf(line.c_str(), "%d %lf %lf %d", &sensewire, &t0, &t0_err, &entries); //assign each of the variables above a data in the t_zero_file - - // if(sensewire<=fNWires[ip]){ - - //cout << sensewire << endl; - //Check if entries for each sensewire exceeds a certain number of events - - if (entries>300 && abs(t0)<30) - { - - //cout << ip << "::" << sensewire << "::" << t0 << endl; - //Calculate the weighted average of t0s - sum_NUM = sum_NUM + t0/(t0_err*t0_err); - sum_DEN = sum_DEN + 1.0/(t0_err*t0_err); - - //cout << "sum_NUM : " << sum_NUM << endl; - //cout << "sum_DEN : " << sum_DEN << endl; - - - - - ofs << sensewire << setw(15) << t0 << setw(15) << t0_err << setw(15) << entries << endl; - //cout << "TZERO: " << t0 << endl; - - - - } - - else { ofs << sensewire << setw(15) << 0.0 << setw(15) << 0.0 << setw(15) << entries << endl;} - - //} - - } //end if statement - } - - - - weighted_AVG = sum_NUM / sum_DEN; - weighted_AVG_err = sqrt( 1.0 / sum_DEN ); - - - - //open new data file to write weighted average of updated t_zero values - - TString t_zero_AVG = Form("../data_files/run%d/tzero_weighted_avg_run%d.dat", run_NUM, run_NUM); - - ofstream ofile; - ofile.open(t_zero_AVG, std::ofstream::out | std::ofstream::app); //open file in and output and append mode - - ofile << " #weighted_AVG " << " " << " DC plane: " << plane_names[ip] << endl; - ofile << weighted_AVG << endl; - - - ifs.close(); - - // Make Plot of t0 versus Wire Number for entries > 300 events - - TCanvas *t1 = new TCanvas("t1", "", 2000,500); - t1->SetGrid(); - - //TString mygraph = "hdc"+plane_names[ip]+Form("_t_zero_run%d.txt", run); - TGraphErrors *graph1 = new TGraphErrors(t_zero_file_corr, "%lg %lg %lg"); - graph1->SetName("graph1"); - TString title1 = "shms_dc"+plane_names[ip]+": t0 versus sensewire_corrected"; - graph1->SetTitle(title1); - graph1->SetMarkerStyle(20); - graph1->SetMarkerColor(1); - //graph1->GetXaxis()->SetLimits(0., total_wires); - graph1->GetXaxis()->SetTitle("Wire Number"); - graph1->GetXaxis()->CenterTitle(); - graph1->GetYaxis()->SetTitle("t-Zero (ns)"); - graph1->GetYaxis()->CenterTitle(); - graph1->GetYaxis()->SetRangeUser(-50.0, 50.0); - graph1->Draw("AP"); - t1->Update(); - - // Draw TLine - TLine *wght_avg = new TLine(t1->GetUxmin(), weighted_AVG, t1->GetUxmax(), weighted_AVG); - wght_avg->SetLineColor(kRed); - wght_avg->SetLineWidth(2); - wght_avg->SetLineStyle(2); - wght_avg->Draw(); - - //Add text to canvas - TLatex* ltx1 = new TLatex(); - ltx1->DrawLatex(t1->GetUxmax()*0.75,40, Form("Weighted Average = %lf #pm %lf ns", weighted_AVG, weighted_AVG_err) ); - - t1->Write(title1); //write canvas to a root file - - ofs.close(); //close data file - - - - - - - - - - } - - - - - - -} diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/run_Cal.C b/CALIBRATION/dc_calib/scripts/old_scripts/run_Cal.C deleted file mode 100644 index 2f637700..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/run_Cal.C +++ /dev/null @@ -1,110 +0,0 @@ -//SCRIPT TO RUN OVER ALL HMS DC CALIBRATION SCRIPTS AT ONCE, AND UPDATE THE -//NECESSARY PARAMTER FILES hdriftmap.param and hdc.param - - - using namespace std; - - void run_Cal() - { - - //User Input filename, Run and number of events to analyze - string file_name; - cout << "Enter Root File Name (without '.root' extension): " << endl; - cin >> file_name; - - - - int run_NUM; - cout << "Enter Run Number: " << endl; - cin >> run_NUM; - - - int num_evts; - cout << "Enter Number of Events to analyze: " << endl; - cin >> num_evts; - - string suffix = ".root"; - - - - - //Create input file with run number - ofstream fout; - fout.open("scripts/input_RUN.txt", std::ofstream::trunc); - fout << file_name+suffix << " "; - fout << run_NUM << " "; - fout << num_evts << " "; - fout.close(); - - - - - //Create root and data files Directories if they dont exist - const char *dir_root = "mkdir ./root_files/"; - const char *dir_data = "mkdir ./data_files/"; - - if (system(dir_root) != 0 || system(dir_data) != 0) - { - cout << " ... creating 'root_files' directory " << endl; - cout << " ... creating 'data_files' directory " << endl; - - system(dir_root); - system(dir_data); - } - - - - //Create run Directories if they dont exist - const char *dir0 = Form("mkdir ./root_files/run%d", run_NUM); - const char *dir1 = Form("mkdir ./data_files/run%d", run_NUM); - - if (system(dir0) != 0 || system(dir1) != 0) - { - system(dir0); - system(dir1); - - } - - - //Make a copy of the input root file to be calibrated; - string original_filepath; - string dc_uncal_filepath; - - original_filepath = "../../ROOTfiles/"+file_name+suffix; - dc_uncal_filepath = "../../ROOTfiles/"+file_name+"_dc_uncal"+suffix; - gSystem->CopyFile(original_filepath.c_str(), dc_uncal_filepath.c_str()); - - - - //change directories and execute scripts - gSystem->cd("./scripts"); - gSystem->Exec("root -l -q get_pdc_time_histo.C"); - - //Load and Loop over Make Class events to get individual drift times - gROOT->LoadMacro("wire_drift_times.C"); - gROOT->ProcessLine("wire_drift_times t"); //process line allows one to execute interactive root commands from a script, such as this one - gROOT->ProcessLine("t.Loop()"); - //gROOT->ProcessLine(".q"); - gROOT->Reset(); - - - - gSystem->cd("./scripts"); - - - //execute code to get t0 from each wire in each plane - gSystem->Exec("root -l -q -b get_wire_tzero.C"); - - //execute code to update parameter file with new t0 values per wire - gSystem->Exec("root -l -q get_tzero_per_wire_param.C"); - - //execute code to get t0 corrected drift times - gSystem->Exec("root -l -q get_pdc_time_histo_tzero_corrected.C"); - - //execute code to update LookUp Table - gSystem->Exec("root -l -q get_LookUp_Values.C"); - - - } - - diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/update_pdcparam.C b/CALIBRATION/dc_calib/scripts/old_scripts/update_pdcparam.C deleted file mode 100644 index bc10993b..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/update_pdcparam.C +++ /dev/null @@ -1,111 +0,0 @@ -//This scirpt will produce an updated version of hdc.param file, with -//the necessary t-zero corrections -#define time_shift 1280.0 - -void update_pdcparam() -{ - - //read run number from input file - int run_NUM; - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> run_NUM; - - TString run = Form("run%d", run_NUM); - - int lin_NUM = 0; - string t_zero[12]; - double tzero[12]; - string line; - //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 - { - //count lines - lin_NUM = lin_NUM + 1; - 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 pdc.param parameter file -TString pdc_param = "../../../PARAM/SHMS/DC/pdc_tracking_new.param"; -ofstream ofs(pdc_param); - -// ofs << ";---------------------------------------------------------------------" << endl; -// ofs <<"; SHMS_TRACKING"<< endl; -// ofs <<"; CTP parameter file containing all tracking parameters for the SHMS "<< endl; -// ofs <<";----------------------------------------------------------------------"<< endl; -// ofs <<"; sigma of wire chamber resolution for each plane "<< endl; -// ofs <<" pdc_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 <<" pdc_tdc_min_win = -25000,-25000,-25000,-25000,-25000,-25000 "<< endl; -// ofs <<" -25000,-25000,-25000,-25000,-25000,-25000 "<< endl; -// ofs <<" pdc_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 <<" pdc_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 <<"pdc_plane_time_zero = "; - - -//***************************************************************** -//output all t_0 corrected values to pdc.param -for (int i=0; i<12; i++) { -{ -if (i < = 5){ -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] << ","; -} -if (i==11){ ofs << time_shift - tzero[i] << endl;} -} -} -//***************************************************************** -// ofs << "\n"; -// ofs <<"; Dave Abbott's wire velocity correction "<< endl; -// ofs <<"pdc_wire_velocity = 12.0 "<< endl; -// ofs <<"pdc_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++) -{ -ofs << tzero[i] << endl; -} - -} diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.C b/CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.C deleted file mode 100644 index fc7d9d5a..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.C +++ /dev/null @@ -1,308 +0,0 @@ -#define wire_drift_times_cxx -#include "wire_drift_times.h" -#include <TH2.h> -#include <TStyle.h> -#include <TCanvas.h> - -#define NPLANES 12 -#define NBINS 400 -#define bin_min -50.5 -#define bin_max 349.5 -void wire_drift_times::Loop() -{ - // In a ROOT session, you can do: - // Root > .L wire_drift_times.C - // Root > wire_drift_times t - // Root > t.GetEntry(12); // Fill t data members with entry number 12 - // Root > t.Show(); // Show values of entry 12 - // Root > t.Show(16); // Read and show values of entry 16 - // Root > t.Loop(); // Loop on all entries - // - - // This is the loop skeleton where: - // jentry is the global entry number in the chain - // ientry is the entry number in the current Tree - // Note that the argument to GetEntry must be: - // jentry for TChain::GetEntry - // ientry for TTree::GetEntry and TBranch::GetEntry - // - // To read only selected branches, Insert statements like: - // METHOD1: - // fChain->SetBranchStatus("*",0); // disable all branches - // fChain->SetBranchStatus("branchname",1); // activate branchname - // METHOD2: replace line - // fChain->GetEntry(jentry); //read all branches - //by b_branchname->GetEntry(ientry); //read only this branch - if (fChain == 0) return; - - Long64_t nentries = fChain->GetEntriesFast(); - - //Read Run Number from txt file - int run_NUM; - Long64_t num_evts; //added - string input_file; //added - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> input_file >> run_NUM >> num_evts; - - TString run = Form("run%d", run_NUM); - //Declare plane names to loop over - TString plane_names[NPLANES]={"1u1", "1u2", "1x1", "1x2", "1v1", "1v2", "2v2", "2v1", "2x2", "2x1", "2u2", "2u1"}; - - //Declare a root file array to store individual DC cell drift times - TString root_file[NPLANES]; - TFile *g[NPLANES]; - - //integer to store total sense wires for a plane chosen by the user - static const Int_t total_wires_x = 79; - static const Int_t total_wires_uv = 107; - - Long64_t nbytes = 0, nb = 0; - - //Loop over all planes - for (int ip = 0; ip < NPLANES; ip++){ - - //Initialize a root file array to store individual DC cell drift times - root_file[ip] = "../root_files/" + run + "/shms_DC_"+plane_names[ip]+Form("_%d_wire_histos.root", run_NUM); - g[ip] = new TFile(root_file[ip], "RECREATE"); - g[ip]->cd(); - - /*========================PLANES 1X1,1X2,2X1,2X2=====================================*/ - - //If specific planes are encountered, treat them as follows: - - //variable declarations - int wirenum; - - /*PLANE 1U1, 1V1, 2U1, 2V1*/ - //If specific planes are encountered, treat them as follows: - if(ip == 0 || ip == 1 || ip == 4 || ip == 5 || ip == 6 || ip == 7 || ip == 10 || ip == 11) { - - TH1F *cell_dt[total_wires_uv]; - TH2F *drifttime_vs_wire = new TH2F("drifttime_vs_wire", "", 107., 0.,107., NBINS, bin_min, bin_max); - - - - drifttime_vs_wire->GetXaxis()->SetTitle("Wire Number"); - drifttime_vs_wire->GetYaxis()->SetTitle("Drift Time (ns)"); - - //Initialize wire drift time histograms - for (wirenum=1; wirenum<=total_wires_uv; wirenum++){ - cell_dt[wirenum-1] = new TH1F(Form("wire_%d", wirenum), "", NBINS, bin_min, bin_max); - - cell_dt[wirenum-1]->GetXaxis()->SetTitle("Drift Time (ns)"); - cell_dt[wirenum-1]->GetYaxis()->SetTitle("Number of Entries / 1 ns"); - } - - //Loop over all entries (triggers or events) - for (Long64_t jentry=0; jentry<num_evts; jentry++) { - Long64_t ientry = LoadTree(jentry); - if (ientry < 0) break; - nb = fChain->GetEntry(jentry); nbytes += nb; - // if (Cut(ientry) < 0) continue; - - if (ip == 0) { - for (int i=0; i< Ndata_P_dc_1u1_wirenum; i++){ - wirenum = int(P_dc_1u1_wirenum[i]); - //cout << " wire num: " << P_dc_1u1_wirenum[i] << endl; - //cout << "Time: " << P_dc_1u1_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_1u1_time[i]); - drifttime_vs_wire->Fill(P_dc_1u1_wirenum[i], P_dc_1u1_time[i]); - - } - } - - if (ip == 1) { - for (int i=0; i< Ndata_P_dc_1u2_wirenum; i++){ - wirenum = int(P_dc_1u2_wirenum[i]); - //cout << " wire num: " << P_dc_1u2_wirenum[i] << endl; - //cout << "Time: " << P_dc_1u2_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_1u2_time[i]); - drifttime_vs_wire->Fill(P_dc_1u2_wirenum[i], P_dc_1u2_time[i]); - - } - } - - if (ip == 4) { - for (int i=0; i< Ndata_P_dc_1v1_wirenum; i++){ - wirenum = int(P_dc_1v1_wirenum[i]); - //cout << " wire num: " << P_dc_1v1_wirenum[i] << endl; - //cout << "Time: " << P_dc_1v1_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_1v1_time[i]); - drifttime_vs_wire->Fill(P_dc_1v1_wirenum[i], P_dc_1v1_time[i]); - - } - } - - if (ip == 5) { - for (int i=0; i< Ndata_P_dc_1v2_wirenum; i++){ - wirenum = int(P_dc_1v2_wirenum[i]); - //cout << " wire num: " << P_dc_1v2_wirenum[i] << endl; - //cout << "Time: " << P_dc_1v2_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_1v2_time[i]); - drifttime_vs_wire->Fill(P_dc_1v2_wirenum[i], P_dc_1v2_time[i]); - - } - } - - if (ip == 6) { - for (int i=0; i< Ndata_P_dc_2v2_wirenum; i++){ - wirenum = int(P_dc_2v2_wirenum[i]); - //cout << " wire num: " << P_dc_2v2_wirenum[i] << endl; - //cout << "Time: " << P_dc_2v2_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_2v2_time[i]); - drifttime_vs_wire->Fill(P_dc_2v2_wirenum[i], P_dc_2v2_time[i]); - - } - } - - if (ip == 7) { - for (int i=0; i< Ndata_P_dc_2v1_wirenum; i++){ - wirenum = int(P_dc_2v1_wirenum[i]); - //cout << " wire num: " << P_dc_2v1_wirenum[i] << endl; - //cout << "Time: " << P_dc_2v1_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_2v1_time[i]); - drifttime_vs_wire->Fill(P_dc_2v1_wirenum[i], P_dc_2v1_time[i]); - - } - } - - if (ip == 10) { - for (int i=0; i< Ndata_P_dc_2u2_wirenum; i++){ - wirenum = int(P_dc_2u2_wirenum[i]); - //cout << " wire num: " << P_dc_2u2_wirenum[i] << endl; - //cout << "Time: " << P_dc_2u2_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_2u2_time[i]); - drifttime_vs_wire->Fill(P_dc_2u2_wirenum[i], P_dc_2u2_time[i]); - - } - } - - if (ip == 11) { - for (int i=0; i< Ndata_P_dc_2u1_wirenum; i++){ - wirenum = int(P_dc_2u1_wirenum[i]); - //cout << " wire num: " << P_dc_2u1_wirenum[i] << endl; - //cout << "Time: " << P_dc_2u1_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_2u1_time[i]); - drifttime_vs_wire->Fill(P_dc_2u1_wirenum[i], P_dc_2u1_time[i]); - - } - } - - - - } - } - - if(ip == 2 || ip == 3 || ip == 8 || ip == 9) { - - TH1F *cell_dt[total_wires_x]; - TH2F *drifttime_vs_wire = new TH2F("drifttime_vs_wire", "", 79., 0., 79., NBINS, bin_min, bin_max); - - - - drifttime_vs_wire->GetXaxis()->SetTitle("Wire Number"); - drifttime_vs_wire->GetYaxis()->SetTitle("Drift Time (ns)"); - - //Initialize wire drift time histograms - for (int wirenum=1; wirenum<=total_wires_x; wirenum++){ - cell_dt[wirenum-1] = new TH1F(Form("wire_%d", wirenum), "", NBINS, bin_min, bin_max); - - cell_dt[wirenum-1]->GetXaxis()->SetTitle("Drift Time (ns)"); - cell_dt[wirenum-1]->GetYaxis()->SetTitle("Number of Entries / 1 ns"); - - - } - - //Loop over all entries (triggers or events) - for (Long64_t jentry=0; jentry<num_evts; jentry++) { - Long64_t ientry = LoadTree(jentry); - if (ientry < 0) break; - nb = fChain->GetEntry(jentry); nbytes += nb; - // if (Cut(ientry) < 0) continue; - - if (ip == 2) { - for (int i=0; i< Ndata_P_dc_1x1_wirenum; i++){ - wirenum = int(P_dc_1x1_wirenum[i]); - //cout << " wire num: " << P_dc_1x1_wirenum[i] << endl; - //cout << "Time: " << P_dc_1x1_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_1x1_time[i]); - drifttime_vs_wire->Fill(P_dc_1x1_wirenum[i], P_dc_1x1_time[i]); - - } - } - - if (ip == 3) { - for (int i=0; i< Ndata_P_dc_1x2_wirenum; i++){ - wirenum = int(P_dc_1x2_wirenum[i]); - //cout << " wire num: " << P_dc_1x2_wirenum[i] << endl; - //cout << "Time: " << P_dc_1x2_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_1x2_time[i]); - drifttime_vs_wire->Fill(P_dc_1x2_wirenum[i], P_dc_1x2_time[i]); - - } - } - - if (ip == 8) { - for (int i=0; i< Ndata_P_dc_2x2_wirenum; i++){ - wirenum = int(P_dc_2x2_wirenum[i]); - //cout << " wire num: " << P_dc_2x2_wirenum[i] << endl; - //cout << "Time: " << P_dc_2x2_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_2x2_time[i]); - drifttime_vs_wire->Fill(P_dc_2x2_wirenum[i], P_dc_2x2_time[i]); - - } - } - - if (ip == 9) { - for (int i=0; i< Ndata_P_dc_2x1_wirenum; i++){ - wirenum = int(P_dc_2x1_wirenum[i]); - //cout << " wire num: " << P_dc_2x1_wirenum[i] << endl; - //cout << "Time: " << P_dc_2x1_time[i] << endl; - - //Fill the Histograms - cell_dt[wirenum-1]->Fill(P_dc_2x1_time[i]); - drifttime_vs_wire->Fill(P_dc_2x1_wirenum[i], P_dc_2x1_time[i]); - - } - } - - - - } - } - - - - //Write wire drift time histos to file - g[ip]->Write(); - cout << "EVERYTHING OK in plane:" << ip << endl; - - } - - - // cout << "\r \r" << (float)sensewire / total_wires * 100.0 << "%" << flush; - -} diff --git a/CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.h b/CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.h deleted file mode 100644 index 577f2203..00000000 --- a/CALIBRATION/dc_calib/scripts/old_scripts/wire_drift_times.h +++ /dev/null @@ -1,552 +0,0 @@ -////////////////////////////////////////////////////////// -// This class has been automatically generated on -// Tue Mar 7 17:30:40 2017 by ROOT version 5.34/36 -// from TTree T/Hall A Analyzer Output DST -// found on file: ROOTfiles/pdc_replay_437.root -////////////////////////////////////////////////////////// - -#ifndef wire_drift_times_h -#define wire_drift_times_h - -#include <TROOT.h> -#include <TChain.h> -#include <TFile.h> - -// Header file for the classes stored in the TTree if any. - -// Fixed size dimensions of array or collections stored in the TTree if any. - -class wire_drift_times { -public : - - TTree *fChain; //!pointer to the analyzed TTree or TChain - Int_t fCurrent; //!current Tree number in a TChain - - // Declaration of leaf types - Int_t Ndata_P_dc_1u1_dist; - Double_t P_dc_1u1_dist[107]; //[Ndata.P.dc.1u1.dist] - Int_t Ndata_P_dc_1u1_rawtdc; - Double_t P_dc_1u1_rawtdc[107]; //[Ndata.P.dc.1u1.rawtdc] - Int_t Ndata_P_dc_1u1_time; - Double_t P_dc_1u1_time[107]; //[Ndata.P.dc.1u1.time] - Int_t Ndata_P_dc_1u1_wirenum; - Double_t P_dc_1u1_wirenum[107]; //[Ndata.P.dc.1u1.wirenum] - Int_t Ndata_P_dc_1u2_dist; - Double_t P_dc_1u2_dist[107]; //[Ndata.P.dc.1u2.dist] - Int_t Ndata_P_dc_1u2_rawtdc; - Double_t P_dc_1u2_rawtdc[107]; //[Ndata.P.dc.1u2.rawtdc] - Int_t Ndata_P_dc_1u2_time; - Double_t P_dc_1u2_time[107]; //[Ndata.P.dc.1u2.time] - Int_t Ndata_P_dc_1u2_wirenum; - Double_t P_dc_1u2_wirenum[107]; //[Ndata.P.dc.1u2.wirenum] - Int_t Ndata_P_dc_1v1_dist; - Double_t P_dc_1v1_dist[107]; //[Ndata.P.dc.1v1.dist] - Int_t Ndata_P_dc_1v1_rawtdc; - Double_t P_dc_1v1_rawtdc[107]; //[Ndata.P.dc.1v1.rawtdc] - Int_t Ndata_P_dc_1v1_time; - Double_t P_dc_1v1_time[107]; //[Ndata.P.dc.1v1.time] - Int_t Ndata_P_dc_1v1_wirenum; - Double_t P_dc_1v1_wirenum[107]; //[Ndata.P.dc.1v1.wirenum] - Int_t Ndata_P_dc_1v2_dist; - Double_t P_dc_1v2_dist[107]; //[Ndata.P.dc.1v2.dist] - Int_t Ndata_P_dc_1v2_rawtdc; - Double_t P_dc_1v2_rawtdc[107]; //[Ndata.P.dc.1v2.rawtdc] - Int_t Ndata_P_dc_1v2_time; - Double_t P_dc_1v2_time[107]; //[Ndata.P.dc.1v2.time] - Int_t Ndata_P_dc_1v2_wirenum; - Double_t P_dc_1v2_wirenum[107]; //[Ndata.P.dc.1v2.wirenum] - Int_t Ndata_P_dc_1x1_dist; - Double_t P_dc_1x1_dist[80]; //[Ndata.P.dc.1x1.dist] - Int_t Ndata_P_dc_1x1_rawtdc; - Double_t P_dc_1x1_rawtdc[80]; //[Ndata.P.dc.1x1.rawtdc] - Int_t Ndata_P_dc_1x1_time; - Double_t P_dc_1x1_time[80]; //[Ndata.P.dc.1x1.time] - Int_t Ndata_P_dc_1x1_wirenum; - Double_t P_dc_1x1_wirenum[80]; //[Ndata.P.dc.1x1.wirenum] - Int_t Ndata_P_dc_1x2_dist; - Double_t P_dc_1x2_dist[80]; //[Ndata.P.dc.1x2.dist] - Int_t Ndata_P_dc_1x2_rawtdc; - Double_t P_dc_1x2_rawtdc[80]; //[Ndata.P.dc.1x2.rawtdc] - Int_t Ndata_P_dc_1x2_time; - Double_t P_dc_1x2_time[80]; //[Ndata.P.dc.1x2.time] - Int_t Ndata_P_dc_1x2_wirenum; - Double_t P_dc_1x2_wirenum[80]; //[Ndata.P.dc.1x2.wirenum] - Int_t Ndata_P_dc_2u1_dist; - Double_t P_dc_2u1_dist[107]; //[Ndata.P.dc.2u1.dist] - Int_t Ndata_P_dc_2u1_rawtdc; - Double_t P_dc_2u1_rawtdc[107]; //[Ndata.P.dc.2u1.rawtdc] - Int_t Ndata_P_dc_2u1_time; - Double_t P_dc_2u1_time[107]; //[Ndata.P.dc.2u1.time] - Int_t Ndata_P_dc_2u1_wirenum; - Double_t P_dc_2u1_wirenum[107]; //[Ndata.P.dc.2u1.wirenum] - Int_t Ndata_P_dc_2u2_dist; - Double_t P_dc_2u2_dist[107]; //[Ndata.P.dc.2u2.dist] - Int_t Ndata_P_dc_2u2_rawtdc; - Double_t P_dc_2u2_rawtdc[107]; //[Ndata.P.dc.2u2.rawtdc] - Int_t Ndata_P_dc_2u2_time; - Double_t P_dc_2u2_time[107]; //[Ndata.P.dc.2u2.time] - Int_t Ndata_P_dc_2u2_wirenum; - Double_t P_dc_2u2_wirenum[107]; //[Ndata.P.dc.2u2.wirenum] - Int_t Ndata_P_dc_2v1_dist; - Double_t P_dc_2v1_dist[107]; //[Ndata.P.dc.2v1.dist] - Int_t Ndata_P_dc_2v1_rawtdc; - Double_t P_dc_2v1_rawtdc[107]; //[Ndata.P.dc.2v1.rawtdc] - Int_t Ndata_P_dc_2v1_time; - Double_t P_dc_2v1_time[107]; //[Ndata.P.dc.2v1.time] - Int_t Ndata_P_dc_2v1_wirenum; - Double_t P_dc_2v1_wirenum[107]; //[Ndata.P.dc.2v1.wirenum] - Int_t Ndata_P_dc_2v2_dist; - Double_t P_dc_2v2_dist[107]; //[Ndata.P.dc.2v2.dist] - Int_t Ndata_P_dc_2v2_rawtdc; - Double_t P_dc_2v2_rawtdc[107]; //[Ndata.P.dc.2v2.rawtdc] - Int_t Ndata_P_dc_2v2_time; - Double_t P_dc_2v2_time[107]; //[Ndata.P.dc.2v2.time] - Int_t Ndata_P_dc_2v2_wirenum; - Double_t P_dc_2v2_wirenum[107]; //[Ndata.P.dc.2v2.wirenum] - Int_t Ndata_P_dc_2x1_dist; - Double_t P_dc_2x1_dist[80]; //[Ndata.P.dc.2x1.dist] - Int_t Ndata_P_dc_2x1_rawtdc; - Double_t P_dc_2x1_rawtdc[80]; //[Ndata.P.dc.2x1.rawtdc] - Int_t Ndata_P_dc_2x1_time; - Double_t P_dc_2x1_time[80]; //[Ndata.P.dc.2x1.time] - Int_t Ndata_P_dc_2x1_wirenum; - Double_t P_dc_2x1_wirenum[80]; //[Ndata.P.dc.2x1.wirenum] - Int_t Ndata_P_dc_2x2_dist; - Double_t P_dc_2x2_dist[80]; //[Ndata.P.dc.2x2.dist] - Int_t Ndata_P_dc_2x2_rawtdc; - Double_t P_dc_2x2_rawtdc[80]; //[Ndata.P.dc.2x2.rawtdc] - Int_t Ndata_P_dc_2x2_time; - Double_t P_dc_2x2_time[80]; //[Ndata.P.dc.2x2.time] - Int_t Ndata_P_dc_2x2_wirenum; - Double_t P_dc_2x2_wirenum[80]; //[Ndata.P.dc.2x2.wirenum] - Int_t Ndata_P_dc_residual; - Double_t P_dc_residual[12]; //[Ndata.P.dc.residual] - Int_t Ndata_P_dc_x; - Double_t P_dc_x[10]; //[Ndata.P.dc.x] - Int_t Ndata_P_dc_xp; - Double_t P_dc_xp[10]; //[Ndata.P.dc.xp] - Int_t Ndata_P_dc_y; - Double_t P_dc_y[10]; //[Ndata.P.dc.y] - Int_t Ndata_P_dc_yp; - Double_t P_dc_yp[10]; //[Ndata.P.dc.yp] - Double_t P_dc_1u1_nhit; - Double_t P_dc_1u2_nhit; - Double_t P_dc_1v1_nhit; - Double_t P_dc_1v2_nhit; - Double_t P_dc_1x1_nhit; - Double_t P_dc_1x2_nhit; - Double_t P_dc_2u1_nhit; - Double_t P_dc_2u2_nhit; - Double_t P_dc_2v1_nhit; - Double_t P_dc_2v2_nhit; - Double_t P_dc_2x1_nhit; - Double_t P_dc_2x2_nhit; - Double_t P_dc_Ch1_maxhits; - Double_t P_dc_Ch1_nhit; - Double_t P_dc_Ch1_spacepoints; - Double_t P_dc_Ch1_trawhit; - Double_t P_dc_Ch2_maxhits; - Double_t P_dc_Ch2_nhit; - Double_t P_dc_Ch2_spacepoints; - Double_t P_dc_Ch2_trawhit; - Double_t P_dc_nhit; - Double_t P_dc_nsp; - Double_t P_dc_ntrack; - Double_t P_dc_stubtest; - Double_t P_dc_tnhit; - Double_t P_dc_trawhit; - //THaEvent *Event_Branch; - ULong64_t fEvtHdr_fEvtTime; - UInt_t fEvtHdr_fEvtNum; - Int_t fEvtHdr_fEvtType; - Int_t fEvtHdr_fEvtLen; - Int_t fEvtHdr_fHelicity; - Int_t fEvtHdr_fTargetPol; - Int_t fEvtHdr_fRun; - - // List of branches - TBranch *b_Ndata_P_dc_1u1_dist; //! - TBranch *b_P_dc_1u1_dist; //! - TBranch *b_Ndata_P_dc_1u1_rawtdc; //! - TBranch *b_P_dc_1u1_rawtdc; //! - TBranch *b_Ndata_P_dc_1u1_time; //! - TBranch *b_P_dc_1u1_time; //! - TBranch *b_Ndata_P_dc_1u1_wirenum; //! - TBranch *b_P_dc_1u1_wirenum; //! - TBranch *b_Ndata_P_dc_1u2_dist; //! - TBranch *b_P_dc_1u2_dist; //! - TBranch *b_Ndata_P_dc_1u2_rawtdc; //! - TBranch *b_P_dc_1u2_rawtdc; //! - TBranch *b_Ndata_P_dc_1u2_time; //! - TBranch *b_P_dc_1u2_time; //! - TBranch *b_Ndata_P_dc_1u2_wirenum; //! - TBranch *b_P_dc_1u2_wirenum; //! - TBranch *b_Ndata_P_dc_1v1_dist; //! - TBranch *b_P_dc_1v1_dist; //! - TBranch *b_Ndata_P_dc_1v1_rawtdc; //! - TBranch *b_P_dc_1v1_rawtdc; //! - TBranch *b_Ndata_P_dc_1v1_time; //! - TBranch *b_P_dc_1v1_time; //! - TBranch *b_Ndata_P_dc_1v1_wirenum; //! - TBranch *b_P_dc_1v1_wirenum; //! - TBranch *b_Ndata_P_dc_1v2_dist; //! - TBranch *b_P_dc_1v2_dist; //! - TBranch *b_Ndata_P_dc_1v2_rawtdc; //! - TBranch *b_P_dc_1v2_rawtdc; //! - TBranch *b_Ndata_P_dc_1v2_time; //! - TBranch *b_P_dc_1v2_time; //! - TBranch *b_Ndata_P_dc_1v2_wirenum; //! - TBranch *b_P_dc_1v2_wirenum; //! - TBranch *b_Ndata_P_dc_1x1_dist; //! - TBranch *b_P_dc_1x1_dist; //! - TBranch *b_Ndata_P_dc_1x1_rawtdc; //! - TBranch *b_P_dc_1x1_rawtdc; //! - TBranch *b_Ndata_P_dc_1x1_time; //! - TBranch *b_P_dc_1x1_time; //! - TBranch *b_Ndata_P_dc_1x1_wirenum; //! - TBranch *b_P_dc_1x1_wirenum; //! - TBranch *b_Ndata_P_dc_1x2_dist; //! - TBranch *b_P_dc_1x2_dist; //! - TBranch *b_Ndata_P_dc_1x2_rawtdc; //! - TBranch *b_P_dc_1x2_rawtdc; //! - TBranch *b_Ndata_P_dc_1x2_time; //! - TBranch *b_P_dc_1x2_time; //! - TBranch *b_Ndata_P_dc_1x2_wirenum; //! - TBranch *b_P_dc_1x2_wirenum; //! - TBranch *b_Ndata_P_dc_2u1_dist; //! - TBranch *b_P_dc_2u1_dist; //! - TBranch *b_Ndata_P_dc_2u1_rawtdc; //! - TBranch *b_P_dc_2u1_rawtdc; //! - TBranch *b_Ndata_P_dc_2u1_time; //! - TBranch *b_P_dc_2u1_time; //! - TBranch *b_Ndata_P_dc_2u1_wirenum; //! - TBranch *b_P_dc_2u1_wirenum; //! - TBranch *b_Ndata_P_dc_2u2_dist; //! - TBranch *b_P_dc_2u2_dist; //! - TBranch *b_Ndata_P_dc_2u2_rawtdc; //! - TBranch *b_P_dc_2u2_rawtdc; //! - TBranch *b_Ndata_P_dc_2u2_time; //! - TBranch *b_P_dc_2u2_time; //! - TBranch *b_Ndata_P_dc_2u2_wirenum; //! - TBranch *b_P_dc_2u2_wirenum; //! - TBranch *b_Ndata_P_dc_2v1_dist; //! - TBranch *b_P_dc_2v1_dist; //! - TBranch *b_Ndata_P_dc_2v1_rawtdc; //! - TBranch *b_P_dc_2v1_rawtdc; //! - TBranch *b_Ndata_P_dc_2v1_time; //! - TBranch *b_P_dc_2v1_time; //! - TBranch *b_Ndata_P_dc_2v1_wirenum; //! - TBranch *b_P_dc_2v1_wirenum; //! - TBranch *b_Ndata_P_dc_2v2_dist; //! - TBranch *b_P_dc_2v2_dist; //! - TBranch *b_Ndata_P_dc_2v2_rawtdc; //! - TBranch *b_P_dc_2v2_rawtdc; //! - TBranch *b_Ndata_P_dc_2v2_time; //! - TBranch *b_P_dc_2v2_time; //! - TBranch *b_Ndata_P_dc_2v2_wirenum; //! - TBranch *b_P_dc_2v2_wirenum; //! - TBranch *b_Ndata_P_dc_2x1_dist; //! - TBranch *b_P_dc_2x1_dist; //! - TBranch *b_Ndata_P_dc_2x1_rawtdc; //! - TBranch *b_P_dc_2x1_rawtdc; //! - TBranch *b_Ndata_P_dc_2x1_time; //! - TBranch *b_P_dc_2x1_time; //! - TBranch *b_Ndata_P_dc_2x1_wirenum; //! - TBranch *b_P_dc_2x1_wirenum; //! - TBranch *b_Ndata_P_dc_2x2_dist; //! - TBranch *b_P_dc_2x2_dist; //! - TBranch *b_Ndata_P_dc_2x2_rawtdc; //! - TBranch *b_P_dc_2x2_rawtdc; //! - TBranch *b_Ndata_P_dc_2x2_time; //! - TBranch *b_P_dc_2x2_time; //! - TBranch *b_Ndata_P_dc_2x2_wirenum; //! - TBranch *b_P_dc_2x2_wirenum; //! - TBranch *b_Ndata_P_dc_residual; //! - TBranch *b_P_dc_residual; //! - TBranch *b_Ndata_P_dc_x; //! - TBranch *b_P_dc_x; //! - TBranch *b_Ndata_P_dc_xp; //! - TBranch *b_P_dc_xp; //! - TBranch *b_Ndata_P_dc_y; //! - TBranch *b_P_dc_y; //! - TBranch *b_Ndata_P_dc_yp; //! - TBranch *b_P_dc_yp; //! - TBranch *b_P_dc_1u1_nhit; //! - TBranch *b_P_dc_1u2_nhit; //! - TBranch *b_P_dc_1v1_nhit; //! - TBranch *b_P_dc_1v2_nhit; //! - TBranch *b_P_dc_1x1_nhit; //! - TBranch *b_P_dc_1x2_nhit; //! - TBranch *b_P_dc_2u1_nhit; //! - TBranch *b_P_dc_2u2_nhit; //! - TBranch *b_P_dc_2v1_nhit; //! - TBranch *b_P_dc_2v2_nhit; //! - TBranch *b_P_dc_2x1_nhit; //! - TBranch *b_P_dc_2x2_nhit; //! - TBranch *b_P_dc_Ch1_maxhits; //! - TBranch *b_P_dc_Ch1_nhit; //! - TBranch *b_P_dc_Ch1_spacepoints; //! - TBranch *b_P_dc_Ch1_trawhit; //! - TBranch *b_P_dc_Ch2_maxhits; //! - TBranch *b_P_dc_Ch2_nhit; //! - TBranch *b_P_dc_Ch2_spacepoints; //! - TBranch *b_P_dc_Ch2_trawhit; //! - TBranch *b_P_dc_nhit; //! - TBranch *b_P_dc_nsp; //! - TBranch *b_P_dc_ntrack; //! - TBranch *b_P_dc_stubtest; //! - TBranch *b_P_dc_tnhit; //! - TBranch *b_P_dc_trawhit; //! - TBranch *b_Event_Branch_fEvtHdr_fEvtTime; //! - TBranch *b_Event_Branch_fEvtHdr_fEvtNum; //! - TBranch *b_Event_Branch_fEvtHdr_fEvtType; //! - TBranch *b_Event_Branch_fEvtHdr_fEvtLen; //! - TBranch *b_Event_Branch_fEvtHdr_fHelicity; //! - TBranch *b_Event_Branch_fEvtHdr_fTargetPol; //! - TBranch *b_Event_Branch_fEvtHdr_fRun; //! - - wire_drift_times(TTree *tree=0); - virtual ~wire_drift_times(); - virtual Int_t Cut(Long64_t entry); - virtual Int_t GetEntry(Long64_t entry); - virtual Long64_t LoadTree(Long64_t entry); - virtual void Init(TTree *tree); - virtual void Loop(); - virtual Bool_t Notify(); - virtual void Show(Long64_t entry = -1); -}; - -#endif - -#ifdef wire_drift_times_cxx -wire_drift_times::wire_drift_times(TTree *tree) : fChain(0) -{ -// if parameter tree is not specified (or zero), connect the file -// used to generate this class and read the Tree. - if (tree == 0) { - int run_NUM; - Long64_t num_evts; //added - string input_file; //added - TString f0 = "input_RUN.txt"; - ifstream infile(f0); - infile >> input_file >> run_NUM >> num_evts; - string path_to_inputfile = "../../../ROOTfiles/"+input_file; - TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(path_to_inputfile.c_str()); - if (!f || !f->IsOpen()) { - f = new TFile(path_to_inputfile.c_str()); - } - f->GetObject("T",tree); - - } - Init(tree); -} - -wire_drift_times::~wire_drift_times() -{ - if (!fChain) return; - delete fChain->GetCurrentFile(); -} - -Int_t wire_drift_times::GetEntry(Long64_t entry) -{ -// Read contents of entry. - if (!fChain) return 0; - return fChain->GetEntry(entry); -} -Long64_t wire_drift_times::LoadTree(Long64_t entry) -{ -// Set the environment to read one entry - if (!fChain) return -5; - Long64_t centry = fChain->LoadTree(entry); - if (centry < 0) return centry; - if (fChain->GetTreeNumber() != fCurrent) { - fCurrent = fChain->GetTreeNumber(); - Notify(); - } - return centry; -} - -void wire_drift_times::Init(TTree *tree) -{ - // The Init() function is called when the selector needs to initialize - // a new tree or chain. Typically here the branch addresses and branch - // pointers of the tree will be set. - // It is normally not necessary to make changes to the generated - // code, but the routine can be extended by the user if needed. - // Init() will be called many times when running on PROOF - // (once per file to be processed). - - // Set branch addresses and branch pointers - if (!tree) return; - fChain = tree; - fCurrent = -1; - fChain->SetMakeClass(1); - - fChain->SetBranchAddress("Ndata.P.dc.1u1.dist", &Ndata_P_dc_1u1_dist, &b_Ndata_P_dc_1u1_dist); - fChain->SetBranchAddress("P.dc.1u1.dist", P_dc_1u1_dist, &b_P_dc_1u1_dist); - fChain->SetBranchAddress("Ndata.P.dc.1u1.rawtdc", &Ndata_P_dc_1u1_rawtdc, &b_Ndata_P_dc_1u1_rawtdc); - fChain->SetBranchAddress("P.dc.1u1.rawtdc", P_dc_1u1_rawtdc, &b_P_dc_1u1_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.1u1.time", &Ndata_P_dc_1u1_time, &b_Ndata_P_dc_1u1_time); - fChain->SetBranchAddress("P.dc.1u1.time", P_dc_1u1_time, &b_P_dc_1u1_time); - fChain->SetBranchAddress("Ndata.P.dc.1u1.wirenum", &Ndata_P_dc_1u1_wirenum, &b_Ndata_P_dc_1u1_wirenum); - fChain->SetBranchAddress("P.dc.1u1.wirenum", P_dc_1u1_wirenum, &b_P_dc_1u1_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.1u2.dist", &Ndata_P_dc_1u2_dist, &b_Ndata_P_dc_1u2_dist); - fChain->SetBranchAddress("P.dc.1u2.dist", P_dc_1u2_dist, &b_P_dc_1u2_dist); - fChain->SetBranchAddress("Ndata.P.dc.1u2.rawtdc", &Ndata_P_dc_1u2_rawtdc, &b_Ndata_P_dc_1u2_rawtdc); - fChain->SetBranchAddress("P.dc.1u2.rawtdc", P_dc_1u2_rawtdc, &b_P_dc_1u2_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.1u2.time", &Ndata_P_dc_1u2_time, &b_Ndata_P_dc_1u2_time); - fChain->SetBranchAddress("P.dc.1u2.time", P_dc_1u2_time, &b_P_dc_1u2_time); - fChain->SetBranchAddress("Ndata.P.dc.1u2.wirenum", &Ndata_P_dc_1u2_wirenum, &b_Ndata_P_dc_1u2_wirenum); - fChain->SetBranchAddress("P.dc.1u2.wirenum", P_dc_1u2_wirenum, &b_P_dc_1u2_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.1v1.dist", &Ndata_P_dc_1v1_dist, &b_Ndata_P_dc_1v1_dist); - fChain->SetBranchAddress("P.dc.1v1.dist", P_dc_1v1_dist, &b_P_dc_1v1_dist); - fChain->SetBranchAddress("Ndata.P.dc.1v1.rawtdc", &Ndata_P_dc_1v1_rawtdc, &b_Ndata_P_dc_1v1_rawtdc); - fChain->SetBranchAddress("P.dc.1v1.rawtdc", P_dc_1v1_rawtdc, &b_P_dc_1v1_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.1v1.time", &Ndata_P_dc_1v1_time, &b_Ndata_P_dc_1v1_time); - fChain->SetBranchAddress("P.dc.1v1.time", P_dc_1v1_time, &b_P_dc_1v1_time); - fChain->SetBranchAddress("Ndata.P.dc.1v1.wirenum", &Ndata_P_dc_1v1_wirenum, &b_Ndata_P_dc_1v1_wirenum); - fChain->SetBranchAddress("P.dc.1v1.wirenum", P_dc_1v1_wirenum, &b_P_dc_1v1_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.1v2.dist", &Ndata_P_dc_1v2_dist, &b_Ndata_P_dc_1v2_dist); - fChain->SetBranchAddress("P.dc.1v2.dist", P_dc_1v2_dist, &b_P_dc_1v2_dist); - fChain->SetBranchAddress("Ndata.P.dc.1v2.rawtdc", &Ndata_P_dc_1v2_rawtdc, &b_Ndata_P_dc_1v2_rawtdc); - fChain->SetBranchAddress("P.dc.1v2.rawtdc", P_dc_1v2_rawtdc, &b_P_dc_1v2_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.1v2.time", &Ndata_P_dc_1v2_time, &b_Ndata_P_dc_1v2_time); - fChain->SetBranchAddress("P.dc.1v2.time", P_dc_1v2_time, &b_P_dc_1v2_time); - fChain->SetBranchAddress("Ndata.P.dc.1v2.wirenum", &Ndata_P_dc_1v2_wirenum, &b_Ndata_P_dc_1v2_wirenum); - fChain->SetBranchAddress("P.dc.1v2.wirenum", P_dc_1v2_wirenum, &b_P_dc_1v2_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.1x1.dist", &Ndata_P_dc_1x1_dist, &b_Ndata_P_dc_1x1_dist); - fChain->SetBranchAddress("P.dc.1x1.dist", P_dc_1x1_dist, &b_P_dc_1x1_dist); - fChain->SetBranchAddress("Ndata.P.dc.1x1.rawtdc", &Ndata_P_dc_1x1_rawtdc, &b_Ndata_P_dc_1x1_rawtdc); - fChain->SetBranchAddress("P.dc.1x1.rawtdc", P_dc_1x1_rawtdc, &b_P_dc_1x1_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.1x1.time", &Ndata_P_dc_1x1_time, &b_Ndata_P_dc_1x1_time); - fChain->SetBranchAddress("P.dc.1x1.time", P_dc_1x1_time, &b_P_dc_1x1_time); - fChain->SetBranchAddress("Ndata.P.dc.1x1.wirenum", &Ndata_P_dc_1x1_wirenum, &b_Ndata_P_dc_1x1_wirenum); - fChain->SetBranchAddress("P.dc.1x1.wirenum", P_dc_1x1_wirenum, &b_P_dc_1x1_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.1x2.dist", &Ndata_P_dc_1x2_dist, &b_Ndata_P_dc_1x2_dist); - fChain->SetBranchAddress("P.dc.1x2.dist", P_dc_1x2_dist, &b_P_dc_1x2_dist); - fChain->SetBranchAddress("Ndata.P.dc.1x2.rawtdc", &Ndata_P_dc_1x2_rawtdc, &b_Ndata_P_dc_1x2_rawtdc); - fChain->SetBranchAddress("P.dc.1x2.rawtdc", P_dc_1x2_rawtdc, &b_P_dc_1x2_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.1x2.time", &Ndata_P_dc_1x2_time, &b_Ndata_P_dc_1x2_time); - fChain->SetBranchAddress("P.dc.1x2.time", P_dc_1x2_time, &b_P_dc_1x2_time); - fChain->SetBranchAddress("Ndata.P.dc.1x2.wirenum", &Ndata_P_dc_1x2_wirenum, &b_Ndata_P_dc_1x2_wirenum); - fChain->SetBranchAddress("P.dc.1x2.wirenum", P_dc_1x2_wirenum, &b_P_dc_1x2_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.2u1.dist", &Ndata_P_dc_2u1_dist, &b_Ndata_P_dc_2u1_dist); - fChain->SetBranchAddress("P.dc.2u1.dist", P_dc_2u1_dist, &b_P_dc_2u1_dist); - fChain->SetBranchAddress("Ndata.P.dc.2u1.rawtdc", &Ndata_P_dc_2u1_rawtdc, &b_Ndata_P_dc_2u1_rawtdc); - fChain->SetBranchAddress("P.dc.2u1.rawtdc", P_dc_2u1_rawtdc, &b_P_dc_2u1_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.2u1.time", &Ndata_P_dc_2u1_time, &b_Ndata_P_dc_2u1_time); - fChain->SetBranchAddress("P.dc.2u1.time", P_dc_2u1_time, &b_P_dc_2u1_time); - fChain->SetBranchAddress("Ndata.P.dc.2u1.wirenum", &Ndata_P_dc_2u1_wirenum, &b_Ndata_P_dc_2u1_wirenum); - fChain->SetBranchAddress("P.dc.2u1.wirenum", P_dc_2u1_wirenum, &b_P_dc_2u1_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.2u2.dist", &Ndata_P_dc_2u2_dist, &b_Ndata_P_dc_2u2_dist); - fChain->SetBranchAddress("P.dc.2u2.dist", P_dc_2u2_dist, &b_P_dc_2u2_dist); - fChain->SetBranchAddress("Ndata.P.dc.2u2.rawtdc", &Ndata_P_dc_2u2_rawtdc, &b_Ndata_P_dc_2u2_rawtdc); - fChain->SetBranchAddress("P.dc.2u2.rawtdc", P_dc_2u2_rawtdc, &b_P_dc_2u2_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.2u2.time", &Ndata_P_dc_2u2_time, &b_Ndata_P_dc_2u2_time); - fChain->SetBranchAddress("P.dc.2u2.time", P_dc_2u2_time, &b_P_dc_2u2_time); - fChain->SetBranchAddress("Ndata.P.dc.2u2.wirenum", &Ndata_P_dc_2u2_wirenum, &b_Ndata_P_dc_2u2_wirenum); - fChain->SetBranchAddress("P.dc.2u2.wirenum", P_dc_2u2_wirenum, &b_P_dc_2u2_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.2v1.dist", &Ndata_P_dc_2v1_dist, &b_Ndata_P_dc_2v1_dist); - fChain->SetBranchAddress("P.dc.2v1.dist", P_dc_2v1_dist, &b_P_dc_2v1_dist); - fChain->SetBranchAddress("Ndata.P.dc.2v1.rawtdc", &Ndata_P_dc_2v1_rawtdc, &b_Ndata_P_dc_2v1_rawtdc); - fChain->SetBranchAddress("P.dc.2v1.rawtdc", P_dc_2v1_rawtdc, &b_P_dc_2v1_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.2v1.time", &Ndata_P_dc_2v1_time, &b_Ndata_P_dc_2v1_time); - fChain->SetBranchAddress("P.dc.2v1.time", P_dc_2v1_time, &b_P_dc_2v1_time); - fChain->SetBranchAddress("Ndata.P.dc.2v1.wirenum", &Ndata_P_dc_2v1_wirenum, &b_Ndata_P_dc_2v1_wirenum); - fChain->SetBranchAddress("P.dc.2v1.wirenum", P_dc_2v1_wirenum, &b_P_dc_2v1_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.2v2.dist", &Ndata_P_dc_2v2_dist, &b_Ndata_P_dc_2v2_dist); - fChain->SetBranchAddress("P.dc.2v2.dist", P_dc_2v2_dist, &b_P_dc_2v2_dist); - fChain->SetBranchAddress("Ndata.P.dc.2v2.rawtdc", &Ndata_P_dc_2v2_rawtdc, &b_Ndata_P_dc_2v2_rawtdc); - fChain->SetBranchAddress("P.dc.2v2.rawtdc", P_dc_2v2_rawtdc, &b_P_dc_2v2_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.2v2.time", &Ndata_P_dc_2v2_time, &b_Ndata_P_dc_2v2_time); - fChain->SetBranchAddress("P.dc.2v2.time", P_dc_2v2_time, &b_P_dc_2v2_time); - fChain->SetBranchAddress("Ndata.P.dc.2v2.wirenum", &Ndata_P_dc_2v2_wirenum, &b_Ndata_P_dc_2v2_wirenum); - fChain->SetBranchAddress("P.dc.2v2.wirenum", P_dc_2v2_wirenum, &b_P_dc_2v2_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.2x1.dist", &Ndata_P_dc_2x1_dist, &b_Ndata_P_dc_2x1_dist); - fChain->SetBranchAddress("P.dc.2x1.dist", P_dc_2x1_dist, &b_P_dc_2x1_dist); - fChain->SetBranchAddress("Ndata.P.dc.2x1.rawtdc", &Ndata_P_dc_2x1_rawtdc, &b_Ndata_P_dc_2x1_rawtdc); - fChain->SetBranchAddress("P.dc.2x1.rawtdc", P_dc_2x1_rawtdc, &b_P_dc_2x1_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.2x1.time", &Ndata_P_dc_2x1_time, &b_Ndata_P_dc_2x1_time); - fChain->SetBranchAddress("P.dc.2x1.time", P_dc_2x1_time, &b_P_dc_2x1_time); - fChain->SetBranchAddress("Ndata.P.dc.2x1.wirenum", &Ndata_P_dc_2x1_wirenum, &b_Ndata_P_dc_2x1_wirenum); - fChain->SetBranchAddress("P.dc.2x1.wirenum", P_dc_2x1_wirenum, &b_P_dc_2x1_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.2x2.dist", &Ndata_P_dc_2x2_dist, &b_Ndata_P_dc_2x2_dist); - fChain->SetBranchAddress("P.dc.2x2.dist", P_dc_2x2_dist, &b_P_dc_2x2_dist); - fChain->SetBranchAddress("Ndata.P.dc.2x2.rawtdc", &Ndata_P_dc_2x2_rawtdc, &b_Ndata_P_dc_2x2_rawtdc); - fChain->SetBranchAddress("P.dc.2x2.rawtdc", P_dc_2x2_rawtdc, &b_P_dc_2x2_rawtdc); - fChain->SetBranchAddress("Ndata.P.dc.2x2.time", &Ndata_P_dc_2x2_time, &b_Ndata_P_dc_2x2_time); - fChain->SetBranchAddress("P.dc.2x2.time", P_dc_2x2_time, &b_P_dc_2x2_time); - fChain->SetBranchAddress("Ndata.P.dc.2x2.wirenum", &Ndata_P_dc_2x2_wirenum, &b_Ndata_P_dc_2x2_wirenum); - fChain->SetBranchAddress("P.dc.2x2.wirenum", P_dc_2x2_wirenum, &b_P_dc_2x2_wirenum); - fChain->SetBranchAddress("Ndata.P.dc.residual", &Ndata_P_dc_residual, &b_Ndata_P_dc_residual); - fChain->SetBranchAddress("P.dc.residual", P_dc_residual, &b_P_dc_residual); - fChain->SetBranchAddress("Ndata.P.dc.x", &Ndata_P_dc_x, &b_Ndata_P_dc_x); - fChain->SetBranchAddress("P.dc.x", P_dc_x, &b_P_dc_x); - fChain->SetBranchAddress("Ndata.P.dc.xp", &Ndata_P_dc_xp, &b_Ndata_P_dc_xp); - fChain->SetBranchAddress("P.dc.xp", P_dc_xp, &b_P_dc_xp); - fChain->SetBranchAddress("Ndata.P.dc.y", &Ndata_P_dc_y, &b_Ndata_P_dc_y); - fChain->SetBranchAddress("P.dc.y", P_dc_y, &b_P_dc_y); - fChain->SetBranchAddress("Ndata.P.dc.yp", &Ndata_P_dc_yp, &b_Ndata_P_dc_yp); - fChain->SetBranchAddress("P.dc.yp", P_dc_yp, &b_P_dc_yp); - fChain->SetBranchAddress("P.dc.1u1.nhit", &P_dc_1u1_nhit, &b_P_dc_1u1_nhit); - fChain->SetBranchAddress("P.dc.1u2.nhit", &P_dc_1u2_nhit, &b_P_dc_1u2_nhit); - fChain->SetBranchAddress("P.dc.1v1.nhit", &P_dc_1v1_nhit, &b_P_dc_1v1_nhit); - fChain->SetBranchAddress("P.dc.1v2.nhit", &P_dc_1v2_nhit, &b_P_dc_1v2_nhit); - fChain->SetBranchAddress("P.dc.1x1.nhit", &P_dc_1x1_nhit, &b_P_dc_1x1_nhit); - fChain->SetBranchAddress("P.dc.1x2.nhit", &P_dc_1x2_nhit, &b_P_dc_1x2_nhit); - fChain->SetBranchAddress("P.dc.2u1.nhit", &P_dc_2u1_nhit, &b_P_dc_2u1_nhit); - fChain->SetBranchAddress("P.dc.2u2.nhit", &P_dc_2u2_nhit, &b_P_dc_2u2_nhit); - fChain->SetBranchAddress("P.dc.2v1.nhit", &P_dc_2v1_nhit, &b_P_dc_2v1_nhit); - fChain->SetBranchAddress("P.dc.2v2.nhit", &P_dc_2v2_nhit, &b_P_dc_2v2_nhit); - fChain->SetBranchAddress("P.dc.2x1.nhit", &P_dc_2x1_nhit, &b_P_dc_2x1_nhit); - fChain->SetBranchAddress("P.dc.2x2.nhit", &P_dc_2x2_nhit, &b_P_dc_2x2_nhit); - fChain->SetBranchAddress("P.dc.Ch1.maxhits", &P_dc_Ch1_maxhits, &b_P_dc_Ch1_maxhits); - fChain->SetBranchAddress("P.dc.Ch1.nhit", &P_dc_Ch1_nhit, &b_P_dc_Ch1_nhit); - fChain->SetBranchAddress("P.dc.Ch1.spacepoints", &P_dc_Ch1_spacepoints, &b_P_dc_Ch1_spacepoints); - fChain->SetBranchAddress("P.dc.Ch1.trawhit", &P_dc_Ch1_trawhit, &b_P_dc_Ch1_trawhit); - fChain->SetBranchAddress("P.dc.Ch2.maxhits", &P_dc_Ch2_maxhits, &b_P_dc_Ch2_maxhits); - fChain->SetBranchAddress("P.dc.Ch2.nhit", &P_dc_Ch2_nhit, &b_P_dc_Ch2_nhit); - fChain->SetBranchAddress("P.dc.Ch2.spacepoints", &P_dc_Ch2_spacepoints, &b_P_dc_Ch2_spacepoints); - fChain->SetBranchAddress("P.dc.Ch2.trawhit", &P_dc_Ch2_trawhit, &b_P_dc_Ch2_trawhit); - fChain->SetBranchAddress("P.dc.nhit", &P_dc_nhit, &b_P_dc_nhit); - fChain->SetBranchAddress("P.dc.nsp", &P_dc_nsp, &b_P_dc_nsp); - fChain->SetBranchAddress("P.dc.ntrack", &P_dc_ntrack, &b_P_dc_ntrack); - fChain->SetBranchAddress("P.dc.stubtest", &P_dc_stubtest, &b_P_dc_stubtest); - fChain->SetBranchAddress("P.dc.tnhit", &P_dc_tnhit, &b_P_dc_tnhit); - fChain->SetBranchAddress("P.dc.trawhit", &P_dc_trawhit, &b_P_dc_trawhit); - fChain->SetBranchAddress("fEvtHdr.fEvtTime", &fEvtHdr_fEvtTime, &b_Event_Branch_fEvtHdr_fEvtTime); - fChain->SetBranchAddress("fEvtHdr.fEvtNum", &fEvtHdr_fEvtNum, &b_Event_Branch_fEvtHdr_fEvtNum); - fChain->SetBranchAddress("fEvtHdr.fEvtType", &fEvtHdr_fEvtType, &b_Event_Branch_fEvtHdr_fEvtType); - fChain->SetBranchAddress("fEvtHdr.fEvtLen", &fEvtHdr_fEvtLen, &b_Event_Branch_fEvtHdr_fEvtLen); - fChain->SetBranchAddress("fEvtHdr.fHelicity", &fEvtHdr_fHelicity, &b_Event_Branch_fEvtHdr_fHelicity); - fChain->SetBranchAddress("fEvtHdr.fTargetPol", &fEvtHdr_fTargetPol, &b_Event_Branch_fEvtHdr_fTargetPol); - fChain->SetBranchAddress("fEvtHdr.fRun", &fEvtHdr_fRun, &b_Event_Branch_fEvtHdr_fRun); - Notify(); -} - -Bool_t wire_drift_times::Notify() -{ - // The Notify() function is called when a new file is opened. This - // can be either for a new TTree in a TChain or when when a new TTree - // is started when using PROOF. It is normally not necessary to make changes - // to the generated code, but the routine can be extended by the - // user if needed. The return value is currently not used. - - return kTRUE; -} - -void wire_drift_times::Show(Long64_t entry) -{ -// Print contents of entry. -// If entry is not specified, print current entry - if (!fChain) return; - fChain->Show(entry); -} -Int_t wire_drift_times::Cut(Long64_t entry) -{ -// This function may be called from Loop. -// returns 1 if entry is accepted. -// returns -1 otherwise. - return 1; -} -#endif // #ifdef wire_drift_times_cxx -- GitLab