23 numGraphs = numGraphs + (*iter);
26 cout <<
"tofcalgsec::calib_endcap_sigma: the number of Graphs is NOT reasonable!!!" << endl;
30 m_name = string(
"calib_endcap_sigma");
33 const double tbegin = -1.5;
34 const double tend = 1.5;
38 for(
unsigned int i=0; i<
NEndcap; i++ ) {
40 for(
unsigned int j=0; j<
nKind; j++ ) {
42 sprintf( hname,
"tleft-tofid%i-r%i", i, k);
43 m_histograms.push_back(
new TH1F( hname, hname, tbin, tbegin, tend ) );
54 rpos[i] =
rbegin + ( i+0.5 )*rstep;
55 rposerr[i] = 0.5*rstep;
70 std::cout << setiosflags(ios::left) << setw(10) << icounter << setw(8) <<
data->size() << setw(30) <<
name() << std::endl;
72 if(
data->size() > 0 ) {
73 std::vector<Record*>::iterator
iter =
data->begin();
75 fillRecord( (*
iter), icounter );
78 fitHistogram( icounter );
79 fillGraph( icounter );
86void calib_endcap_sigma::fillRecord(
const Record* r,
unsigned int icounter ) {
88 double rhit = r->
zrhit();
89 if( rhit<rbegin || rhit>
rend )
return;
90 int rbin =
static_cast<int>((rhit-
rbegin)/rstep);
91 if( rbin<0 ) { rbin = 0; }
93 cout <<
"tofcalgsec::calib_endcap_sigma:fillRecord: rhit is out of range, rhit=" << rhit <<
" rbin=" << rbin << endl;
98 (*iter)->Fill( r->
tleft() );
104void calib_endcap_sigma::fitHistogram(
unsigned int icounter ) {
105 TF1* g =
new TF1(
"g",
"gaus");
110 std::vector<HepVector>::iterator iter2 = m_fitresult.begin() + icounter*
nKind*
nBinPerCounter;
111 for(
unsigned int j=0; j<
nBinPerCounter; j++, iter1++, iter2++ ) {
112 (*iter1)->Fit( g,
"Q");
113 (*iter2)[0] = g->GetParameter(1);
114 (*iter2)[1] = g->GetParError(1);
115 (*iter2)[2] = g->GetParameter(2);
116 (*iter2)[3] = g->GetParError(2);
124void calib_endcap_sigma::fillGraph(
unsigned int icounter ) {
126 char gname1[256], gname2[256];
132 std::vector<double> toffset, toffseterr;
133 std::vector<double> tsigma, tsigmaerr;
141 toffset[k] = (*(
iter+k))[0];
142 toffseterr[k] = (*(
iter+k))[1];
143 tsigma[k] = (*(
iter+k))[2];
144 tsigmaerr[k] = (*(
iter+k))[3];
147 sprintf( gname1,
"offset-tofid-%i", icounter );
148 m_graphs.push_back(
new TGraphErrors(
nBinPerCounter, &rpos[0], &toffset[0], &rposerr[0], &toffseterr[0]) );
149 std::vector<TGraphErrors*>::iterator itgraph =
m_graphs.end() - 1;
150 (*itgraph)->SetTitle(gname1);
151 (*itgraph)->SetMarkerSize(1.5);
152 (*itgraph)->SetMarkerStyle(20);
153 (*itgraph)->SetMarkerColor(2);
155 sprintf( gname2,
"sigma-tofid-%i", icounter );
156 m_graphs.push_back(
new TGraphErrors(
nBinPerCounter, &rpos[0], &tsigma[0], &rposerr[0], &tsigmaerr[0]) );
158 (*itgraph)->SetTitle(gname2);
159 (*itgraph)->SetMarkerSize(1.5);
160 (*itgraph)->SetMarkerStyle(21);
161 (*itgraph)->SetMarkerColor(4);
167void calib_endcap_sigma::fitGraph(
unsigned int icounter ) {
169 TF1* p2 =
new TF1(
"p2",
"pol2",
rbegin,
rend );
174 (*itgraph)->Fit(
"p2",
"Q" );
176 X[0] = p2->GetParameter(0);
177 X[1] = p2->GetParameter(1);
178 X[2] = p2->GetParameter(2);
180 std::vector<HepVector>::iterator
iter =
m_result.begin() + icounter;
std::vector< Record * > RecordSet
const unsigned int NEndcap
std::vector< HepVector > m_result
std::vector< TH1F * > m_histograms
unsigned int nBinPerCounter
std::vector< TGraphErrors * > m_graphs
std::vector< unsigned int > nGraphPerCanvasPerCounter
unsigned int nCanvasPerCounter
unsigned int nHistPerCounter
const string & name() const
std::vector< string > CanvasPerCounterName
calib_endcap_sigma(const unsigned int nrbin)
void calculate(RecordSet *&data, unsigned int icounter)