1#include "tofcalgsec/calib_barrel_common.h"
13 CanvasName.push_back(
static_cast<string>(
"Offset") );
14 CanvasName.push_back(
static_cast<string>(
"Offset-PlusMinus") );
15 CanvasName.push_back(
static_cast<string>(
"Sigma") );
16 CanvasName.push_back(
static_cast<string>(
"Sigma-TCorrelation") );
25 numGraphs = numGraphs + (*iter);
28 cout <<
"tofcalgsec::calib_barrel_common: the number of Graphs is NOT reasonable!!!" << endl;
32 m_name = string(
"calib_barrel_common");
35 const double tbegin = -1.5;
36 const double tend = 1.5;
40 for(
unsigned int j=0; j<
nKind; j++ ) {
42 if( j==0 ) { sprintf( hname,
"tleft-z%i", k); }
43 else if( j==1 ) { sprintf( hname,
"tright-z%i", k); }
44 else if( j==2 ) { sprintf( hname,
"tplus-z%i", k); }
45 else if( j==3 ) { sprintf( hname,
"tminus-z%i", k); }
46 m_fitresult.push_back( HepVector(
nParCommon,0 ) );
47 m_histograms.push_back(
new TH1F( hname, hname, tbin, tbegin, tend ) );
50 sprintf( hname,
"deltaT" );
51 m_fitresult.push_back( HepVector(
nParCommon,0 ) );
52 m_histograms.push_back(
new TH1F( hname, hname, tbin, tbegin, tend ) );
58 zpos[i] =
zbegin + ( i+0.5 )*zstep;
59 zposerr[i] = 0.5*zstep;
74 std::cout << setiosflags(ios::left) << setw(10) << icounter << setw(8) <<
data->size() << setw(30) <<
name() << std::endl;
76 if(
data->size() > 0 ) {
77 std::vector<Record*>::iterator
iter =
data->begin();
79 fillRecord( (*
iter) );
94void calib_barrel_common::fillRecord(
const Record* r ) {
95 double zhit = r->
zrhit();
96 if( zhit<zbegin || zhit>
zend )
return;
97 int zbin =
static_cast<int>((zhit-
zbegin)/zstep);
99 cout <<
"tofcalgsec::calib_barrel_common: zhit is out of range, zhit=" << zhit <<
" zbin=" << zbin << endl;
115void calib_barrel_common::fitHistogram() {
116 TF1* g =
new TF1(
"g",
"gaus");
120 std::vector<TH1F*>::iterator iter1 =
m_histograms.begin();
121 std::vector<HepVector>::iterator iter2 = m_fitresult.begin();
123 (*iter1)->Fit( g,
"Q");
124 (*iter2)[0] = g->GetParameter(1);
125 (*iter2)[1] = g->GetParError(1);
126 (*iter2)[2] = g->GetParameter(2);
127 (*iter2)[3] = g->GetParError(2);
130 iter2 = m_fitresult.end() - 1;
139void calib_barrel_common::fillGraph() {
141 char gname1[256], gname2[256];
151 std::vector<double> toffset, toffseterr;
152 std::vector<double> tsigma, tsigmaerr;
158 unsigned int number = 0;
159 std::vector<HepVector>::iterator
iter = m_fitresult.begin();
160 for(
unsigned int j=0; j<
nKind; j++ ) {
163 toffset[k] = (*(
iter+number))[0];
164 toffseterr[k] = (*(
iter+number))[1];
165 tsigma[k] = (*(
iter+number))[2];
166 tsigmaerr[k] = (*(
iter+number))[3];
169 sprintf( gname1,
"Offset" );
170 gra[j] =
new TGraphErrors(
nBinPerCounter, &zpos[0], &toffset[0], &zposerr[0], &toffseterr[0]);
171 gra[j]->SetTitle(gname1);
173 sprintf( gname2,
"Sigma" );
174 gra[j+4] =
new TGraphErrors(
nBinPerCounter, &zpos[0], &tsigma[0], &zposerr[0], &tsigmaerr[0]);
175 gra[j+4]->SetTitle(gname2);
181 double sigMinus = (*(
iter+number))[2];
183 double sigErrMinus = (*(
iter+number))[3];
184 if( sigPlus>sigMinus ) {
185 tsigma[k] = sqrt( sigPlus*sigPlus - sigMinus*sigMinus );
188 tsigma[k] = 0.0 - sqrt( sigMinus*sigMinus - sigPlus*sigPlus );
190 tsigmaerr[k] = sqrt( sigErrPlus*sigErrPlus + sigErrMinus*sigErrMinus );
195 gra[j]->SetMarkerSize(1.5);
196 gra[j]->SetMarkerStyle(20);
197 gra[j]->SetMarkerColor(2);
199 gra[j]->SetMaximum( 0.22 );
200 gra[j]->SetMinimum( 0.07 );
203 gra[j]->SetMaximum( 0.20 );
204 gra[j]->SetMinimum( -0.02 );
208 gra[j]->SetMarkerSize(1.5);
209 gra[j]->SetMarkerStyle(21);
210 gra[j]->SetMarkerColor(4);
223void calib_barrel_common::fitGraph() {
224 TF1* p0 =
new TF1(
"p0",
"pol0");
228 std::vector<TGraphErrors*>::iterator
iter=
m_graphs.end()-1;
229 (*iter)->Fit(
"p0",
"Q" );
230 X[0] = p0->GetParameter(0);
231 X[1] = p0->GetParError(0);
std::vector< Record * > RecordSet
const unsigned int NBarrel
const int nGraphTotalCommon
std::vector< TH1F * > m_histograms
unsigned int nBinPerCounter
std::vector< unsigned int > nGraphPerCanvas
std::vector< string > CanvasName
unsigned int nCanvasPerCounter
unsigned int nHistPerCounter
const string & name() const
std::vector< HepVector > m_result
std::vector< TGraphErrors * > m_graphs
calib_barrel_common(const unsigned int nzbin)
void calculate(RecordSet *&data, unsigned int icounter)