1#include "tofcalgsec/calib_etf_bunch.h"
13 CanvasName.push_back(
static_cast<string>(
"Offset-bunch0") );
14 CanvasName.push_back(
static_cast<string>(
"Offset-bunch1") );
15 CanvasName.push_back(
static_cast<string>(
"Offset-bunch2") );
16 CanvasName.push_back(
static_cast<string>(
"Offset-bunch3") );
17 CanvasName.push_back(
static_cast<string>(
"Sigma-bunch0") );
18 CanvasName.push_back(
static_cast<string>(
"Sigma-bunch1") );
19 CanvasName.push_back(
static_cast<string>(
"Sigma-bunch2") );
20 CanvasName.push_back(
static_cast<string>(
"Sigma-bunch3") );
34 numGraphs = numGraphs + (*iter);
37 cout <<
"tofcalgsec::calib_barrel_common: the number of Graphs is NOT reasonable!!!" << endl;
41 m_name = string(
"calib_etf_bunch");
44 const double tbegin = -0.8;
45 const double tend = 0.8;
49 for(
unsigned int j=0; j<
nKind; j++ ) {
51 if( k==0 ) { sprintf( hname,
"tleft-bunch%i", j); }
52 else if( k==1 ) { sprintf( hname,
"tright-bunch%i", j); }
53 else if( k==2 ) { sprintf( hname,
"tcombine-bunch%i", j); }
55 m_histograms.push_back(
new TH1F( hname, hname, tbin, tbegin, tend ) );
80 std::cout << setiosflags(ios::left) << setw(10) << icounter << setw(8) <<
data->size() << setw(30) <<
name() << std::endl;
82 if(
data->size() > 0 ) {
83 std::vector<Record*>::iterator
iter =
data->begin();
85 fillRecord( (*
iter) );
99void calib_etf_bunch::fillRecord(
const Record* r ) {
100 double t0 = r->
phi();
101 int ibunch =
static_cast<int>(t0/(8.0*12000./499.8/8./4. )+0.1)%4;
114void calib_etf_bunch::fitHistogram() {
115 TF1* g =
new TF1(
"g",
"gaus");
119 std::vector<TH1F*>::iterator iter1 =
m_histograms.begin();
120 std::vector<HepVector>::iterator iter2 = m_fitresult.begin();
122 (*iter1)->Fit( g,
"Q");
123 (*iter2)[0] = g->GetParameter(1);
124 (*iter2)[1] = g->GetParError(1);
125 (*iter2)[2] = g->GetParameter(2);
126 (*iter2)[3] = g->GetParError(2);
133void calib_etf_bunch::fillGraph() {
135 char gname1[256], gname2[256];
149 std::vector<double> toffset, toffseterr;
150 std::vector<double> tsigma, tsigmaerr;
156 unsigned int number = 0;
157 std::vector<HepVector>::iterator
iter = m_fitresult.begin();
158 for(
unsigned int j=0; j<
nKind; j++ ) {
159 sprintf( gname1,
"bunch%i-offset", j );
160 sprintf( gname2,
"bunch%i-sigma", j );
167 toffset[k] = (*(
iter+number))[0];
168 toffseterr[k] = (*(
iter+number))[1];
169 tsigma[k] = (*(
iter+number))[2];
170 tsigmaerr[k] = (*(
iter+number))[3];
171 gra[j]->SetBinContent( k+1, toffset[k] );
172 gra[j]->SetBinError( k+1, toffseterr[k] );
173 gra[j+
nKind]->SetBinContent( k+1, tsigma[k] );
174 gra[j+
nKind]->SetBinError( k+1, tsigmaerr[k] );
179 gra[j]->SetMarkerSize(1.5);
180 gra[j]->SetMarkerStyle(20);
181 gra[j]->SetMarkerColor(2);
184 gra[j+1]->SetMarkerSize(1.5);
185 gra[j+1]->SetMarkerStyle(21);
186 gra[j+1]->SetMarkerColor(4);
194void calib_etf_bunch::fitGraph() {
195 TF1* p0 =
new TF1(
"p0",
"pol0");
199 X = HepVector( 2, 0 );
202 (*(
iter+i))->Fit(
"p0",
"Q" );
203 X[0] = p0->GetParameter(0);
204 X[1] = p0->GetParError(0);
std::vector< Record * > RecordSet
const unsigned int NStrip
const int nGraphTotalBunch
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
void calculate(RecordSet *&data, unsigned int ibunch)
calib_etf_bunch(const unsigned int nbunch)