1#include "tofcalgsec/calib_endcap_sigma.h"
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,
"endcap-offset-tofid-%i", icounter );
149 std::vector<TH1F*>::iterator itgraph =
m_graphs.end() - 1;
150 (*itgraph)->SetMarkerSize(1.5);
151 (*itgraph)->SetMarkerStyle(20);
152 (*itgraph)->SetMarkerColor(2);
154 (*itgraph)->SetBinContent( k+1, toffset[k] );
155 (*itgraph)->SetBinError( k+1, toffseterr[k] );
158 sprintf( gname2,
"endcap-sigma-tofid-%i", icounter );
161 (*itgraph)->SetMarkerSize(1.5);
162 (*itgraph)->SetMarkerStyle(21);
163 (*itgraph)->SetMarkerColor(4);
165 (*itgraph)->SetBinContent( k+1, tsigma[k] );
166 (*itgraph)->SetBinError( k+1, tsigmaerr[k] );
173void calib_endcap_sigma::fitGraph(
unsigned int icounter ) {
175 TF1* p2 =
new TF1(
"p2",
"pol2",
rbegin,
rend );
180 (*itgraph)->Fit(
"p2",
"Q" );
182 X[0] = p2->GetParameter(0);
183 X[1] = p2->GetParameter(1);
184 X[2] = p2->GetParameter(2);
186 std::vector<HepVector>::iterator
iter =
m_result.begin() + icounter;
std::vector< Record * > RecordSet
const unsigned int NEndcap
std::vector< string > CanvasPerCounterName
std::vector< TH1F * > m_histograms
std::vector< TH1F * > m_graphs
unsigned int nBinPerCounter
unsigned int nCanvasPerCounter
unsigned int nHistPerCounter
const string & name() const
std::vector< HepVector > m_result
std::vector< unsigned int > nGraphPerCanvasPerCounter
calib_endcap_sigma(const unsigned int nrbin)
void calculate(RecordSet *&data, unsigned int icounter)
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)