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++ ) {
162 sprintf( gname1,
"tlefttright-offset" );
163 sprintf( gname2,
"tlefttright-sigma" );
166 sprintf( gname1,
"tcommon-offset" );
167 sprintf( gname2,
"tcommon-sigma" );
170 sprintf( gname1,
"tplusminus-offset" );
171 sprintf( gname2,
"tplusminus-sigma" );
174 sprintf( gname1,
"tcorrelation-offset" );
175 sprintf( gname2,
"tcorrelation-sigma" );
183 toffset[k] = (*(
iter+number))[0];
184 toffseterr[k] = (*(
iter+number))[1];
185 tsigma[k] = (*(
iter+number))[2];
186 tsigmaerr[k] = (*(
iter+number))[3];
187 gra[j]->SetBinContent( k+1, toffset[k] );
188 gra[j]->SetBinError( k+1, toffseterr[k] );
189 gra[j+4]->SetBinContent( k+1, tsigma[k] );
190 gra[j+4]->SetBinError( k+1, tsigmaerr[k] );
198 double sigMinus = (*(
iter+number))[2];
200 double sigErrMinus = (*(
iter+number))[3];
201 if( sigPlus>sigMinus ) {
202 tsigma[k] = sqrt( sigPlus*sigPlus - sigMinus*sigMinus );
205 tsigma[k] = 0.0 - sqrt( sigMinus*sigMinus - sigPlus*sigPlus );
207 tsigmaerr[k] = sqrt( sigErrPlus*sigErrPlus + sigErrMinus*sigErrMinus );
214 gra[j]->SetMarkerSize(1.5);
215 gra[j]->SetMarkerStyle(20);
216 gra[j]->SetMarkerColor(2);
218 gra[j]->SetMaximum( 0.22 );
219 gra[j]->SetMinimum( 0.07 );
222 gra[j]->SetMaximum( 0.20 );
223 gra[j]->SetMinimum( -0.02 );
227 gra[j]->SetMarkerSize(1.5);
228 gra[j]->SetMarkerStyle(21);
229 gra[j]->SetMarkerColor(4);
242void calib_barrel_common::fitGraph() {
243 TF1* p0 =
new TF1(
"p0",
"pol0");
248 (*iter)->Fit(
"p0",
"Q" );
249 X[0] = p0->GetParameter(0);
250 X[1] = p0->GetParError(0);
std::vector< Record * > RecordSet
const unsigned int NBarrel
const int nGraphTotalCommon
std::vector< TH1F * > m_histograms
std::vector< TH1F * > m_graphs
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
calib_barrel_common(const unsigned int nzbin)
void calculate(RecordSet *&data, unsigned int icounter)