Skip to content
Snippets Groups Projects
Commit 1f51bb65 authored by Yero1990's avatar Yero1990 Committed by Eric Pooser
Browse files

Hms hodo calib work (#463)

* Added method to write hms hodo params into a .param file

* added runNUM argument to timeWalkCalib.C, so that it would be included in the output param filename :: Added a few lines to the hms output param file

* added the new hms hodo param file
parent e131a4d9
No related branches found
No related tags found
No related merge requests found
// Macro to perform time-walk fits and extract the calibration parameters
// Author: Eric Pooser, pooser@jlab.org
// Declare ROOT files
TFile *histoFile, *outFile;
// Declare Output Parameter File
ofstream outParam;
// Declare constants
static const UInt_t nPlanes = 4;
static const UInt_t nSides = 2;
static const UInt_t nBarsMax = 21;
static const UInt_t nBarsMax = 16;
static const UInt_t nTwFitPars = 3;
static const Double_t tdcThresh = 120.0; // 30 mV in units of FADC channels
......@@ -17,6 +22,12 @@ static const Double_t c0twParInit = -15.0;
static const Double_t c1twParInit = 5.0;
static const Double_t c2twParInit = 0.25;
//Parameter values to be written to param file
Double_t c0[nPlanes][nSides][nBarsMax] = {0.};
Double_t c1[nPlanes][nSides][nBarsMax] = {0.};
Double_t c2[nPlanes][nSides][nBarsMax] = {0.};
static const Double_t fontSize = 0.05;
static const Double_t yTitleOffset = 0.75;
static const Double_t markerSize = 2.0;
......@@ -222,11 +233,113 @@ void drawParams(UInt_t iplane) {
return;
} // drawParams
//Add a method to Get Fit Parameters
void WriteFitParam(int runNUM)
{
TString outPar_Name = Form("../../PARAM/HMS/HODO/hhodo_calib_%d.param", runNUM);
outParam.open(outPar_Name);
outParam << ";HMS Hodoscopes Output Parameter File" << endl;
outParam << " " << endl;
outParam << " ; use htofusinginvadc=1 if want invadc_offset " << endl;
outParam << " ; invadc_linear, and invadc_adc to be used " << endl;
outParam << "htofusinginvadc=1 " << endl;
outParam << " " << endl;
//Fill 3D Par array
for (UInt_t iplane=0; iplane < nPlanes; iplane++)
{
for (UInt_t iside=0; iside < nSides; iside++) {
for(UInt_t ipaddle = 0; ipaddle < nbars[iplane]; ipaddle++) {
c0[iplane][iside][ipaddle] = twFit[iplane][iside][ipaddle]->GetParameter("c_{0}");
c1[iplane][iside][ipaddle] = twFit[iplane][iside][ipaddle]->GetParameter("c_{1}");
c2[iplane][iside][ipaddle] = twFit[iplane][iside][ipaddle]->GetParameter("c_{2}");
} //end paddle loop
} //end side loop
} //end plane loop
//Wrtie to Param FIle
outParam << ";Param c1-Pos" << endl;
outParam << "; " << setw(12) << "1x " << setw(15) << "1y " << setw(15) << "2x " << setw(15) << "2y " << endl;
outParam << "c1_Pos = ";
//Loop over all paddles
for(UInt_t ipaddle = 0; ipaddle < nBarsMax; ipaddle++) {
//Write c1-Pos values
if(ipaddle==0){
outParam << c1[0][0][ipaddle] << setw(15) << c1[1][0][ipaddle] << setw(15) << c1[2][0][ipaddle] << setw(15) << c1[3][0][ipaddle] << fixed << endl;
}
else {
outParam << setw(17) << c1[0][0][ipaddle] << setw(15) << c1[1][0][ipaddle] << setw(15) << c1[2][0][ipaddle] << setw(15) << c1[3][0][ipaddle] << fixed << endl;
}
} //end loop over paddles
outParam << " " << endl;
outParam << ";Param c1-Neg" << endl;
outParam << "; " << setw(12) << "1x " << setw(15) << "1y " << setw(15) << "2x " << setw(15) << "2y " << endl;
outParam << "c1_Neg = ";
//Loop over all paddles
for(UInt_t ipaddle = 0; ipaddle < nBarsMax; ipaddle++) {
//Write c1-Neg values
if(ipaddle==0){
outParam << c1[0][1][ipaddle] << setw(15) << c1[1][1][ipaddle] << setw(15) << c1[2][1][ipaddle] << setw(15) << c1[3][1][ipaddle] << fixed << endl;
}
else {
outParam << setw(17) << c1[0][1][ipaddle] << setw(15) << c1[1][1][ipaddle] << setw(15) << c1[2][1][ipaddle] << setw(15) << c1[3][1][ipaddle] << fixed << endl;
}
} //end loop over paddles
outParam << " " << endl;
outParam << ";Param c2-Pos" << endl;
outParam << "; " << setw(12) << "1x " << setw(15) << "1y " << setw(15) << "2x " << setw(15) << "2y " << endl;
outParam << "c2_Pos = ";
//Loop over all paddles
for(UInt_t ipaddle = 0; ipaddle < nBarsMax; ipaddle++) {
//Write c2-Pos values
if(ipaddle==0)
{
outParam << c2[0][0][ipaddle] << setw(15) << c2[1][0][ipaddle] << setw(15) << c2[2][0][ipaddle] << setw(15) << c2[3][0][ipaddle] << fixed << endl;
}
else {
outParam << setw(17) << c2[0][0][ipaddle] << setw(15) << c2[1][0][ipaddle] << setw(15) << c2[2][0][ipaddle] << setw(15) << c2[3][0][ipaddle] << fixed << endl;
}
} //end loop over paddles
outParam << " " << endl;
outParam << ";Param c2-Neg" << endl;
outParam << "; " << setw(12) << "1x " << setw(15) << "1y " << setw(15) << "2x " << setw(15) << "2y " << endl;
outParam << "c2_Neg = ";
//Loop over all paddles
for(UInt_t ipaddle = 0; ipaddle < nBarsMax; ipaddle++) {
//Write c2-Neg values
if (ipaddle==0){
outParam << c2[0][1][ipaddle] << setw(15) << c2[1][1][ipaddle] << setw(15) << c2[2][1][ipaddle] << setw(15) << c2[3][1][ipaddle] << fixed << endl;
}
else{
outParam << setw(17) << c2[0][1][ipaddle] << setw(15) << c2[1][1][ipaddle] << setw(15) << c2[2][1][ipaddle] << setw(15) << c2[3][1][ipaddle] << fixed << endl;
}
} //end loop over paddles
outParam.close();
} //end method
//=:=:=:=:=
//=: Main
//=:=:=:=:=
void timeWalkCalib() {
void timeWalkCalib(int run) {
using namespace std;
//prevent root from displaying graphs while executing
gROOT->SetBatch(1);
// ROOT settings
gStyle->SetTitleFontSize(fontSize);
......@@ -285,9 +398,11 @@ void timeWalkCalib() {
// Draw the time-walk parameter graphs
drawParams(iplane);
} // Plane loop
return;
} // timeWalkFits()
//Write to a param file
WriteFitParam(run);
}
......
;HMS Hodoscopes Output Parameter File
; use htofusinginvadc=1 if want invadc_offset
; invadc_linear, and invadc_adc to be used
htofusinginvadc=1
;Param c1-Pos
; 1x 1y 2x 2y
c1_Pos = 0.819027 1.41186 2.32872 1.46428
2.207128 3.187273 2.074593 1.750816
7.983453 2.126108 1.906823 2.117386
3.073156 1.582985 2.086830 2.449768
3.768713 4.136275 1.676022 1.394880
3.509375 2.185954 2.514874 2.000962
3.491312 2.763838 1.759023 3.858148
2.440381 2.145233 2.139788 2.088941
5.276700 0.404955 1.699047 2.313945
1.771944 1.581550 1.682843 1.542734
14.931448 0.000000 2.084104 0.000000
9.956889 0.000000 3.557773 0.000000
11.323196 0.000000 2.622266 0.000000
2.716784 0.000000 2.258604 0.000000
2.012462 0.000000 1.659209 0.000000
1.380740 0.000000 1.363198 0.000000
;Param c1-Neg
; 1x 1y 2x 2y
c1_Neg = 2.491850 1.219653 1.514545 1.359626
1.417311 2.595391 2.340332 1.662741
8.952472 2.093015 2.531239 2.902317
4.904775 2.003444 3.784816 2.047449
1.451639 2.527254 4.614227 1.227058
16.113918 2.874847 5.681276 1.824491
8.758572 2.298264 3.905578 1.153105
3.328502 2.699598 5.064324 1.794633
15.977368 2.265645 6.660858 1.658787
5.869666 1.341041 2.633762 0.954160
13.911405 0.000000 6.624087 0.000000
7.222109 0.000000 3.399204 0.000000
19.733347 0.000000 3.646857 0.000000
3.554593 0.000000 3.719042 0.000000
2.501336 0.000000 2.009574 0.000000
1.514542 0.000000 3.041217 0.000000
;Param c2-Pos
; 1x 1y 2x 2y
c2_Pos = 0.800818 0.688159 0.361689 0.547470
0.424856 0.274696 0.414385 0.473044
0.111285 0.409492 0.436868 0.378090
0.313996 0.512042 0.407730 0.352738
0.237399 0.212177 0.509222 0.604016
0.265618 0.388077 0.353205 0.408538
0.260990 0.313623 0.461489 0.219490
0.400690 0.415163 0.408679 0.400332
0.171046 1.400490 0.510330 0.392314
0.511252 0.584952 0.498493 0.653343
0.063082 0.000000 0.408709 0.000000
0.087474 0.000000 0.255524 0.000000
0.086283 0.000000 0.346336 0.000000
0.324846 0.000000 0.393374 0.000000
0.429733 0.000000 0.545845 0.000000
0.596471 0.000000 0.573301 0.000000
;Param c2-Neg
; 1x 1y 2x 2y
c2_Neg = 0.392238 0.639491 0.502620 0.587681
0.594349 0.362502 0.372293 0.497877
0.098630 0.401988 0.349340 0.305566
0.197926 0.524730 0.245058 0.443191
0.657146 0.370732 0.209873 0.652018
0.061999 0.318930 0.158678 0.501406
0.111300 0.390369 0.252101 0.716545
0.283347 0.343220 0.190034 0.505662
0.059642 0.420855 0.144001 0.523623
0.164370 0.628903 0.357733 0.773707
0.073184 0.000000 0.148840 0.000000
0.140914 0.000000 0.271973 0.000000
0.053692 0.000000 0.275449 0.000000
0.271366 0.000000 0.256495 0.000000
0.393127 0.000000 0.490331 0.000000
0.584891 0.000000 0.290152 0.000000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment