5static double endcapQFunc(
double *x,
double *par) {
7 double f = par[0] + par[1]*(xx-44.5) + par[2]*(xx-44.5)*(xx-44.5);
27 CanvasName.push_back(
static_cast<string>(
"Pulse Height Most Probable Value vs TOF Counter Number") );
28 CanvasName.push_back(
static_cast<string>(
"Pulse Height Sigma vs TOF Counter Number") );
35 numGraphs1 = numGraphs1 + (*iter);
38 cout <<
"tofcalgsec::calib_endcap_atten: the number of Graphs is NOT reasonable!!!" << endl;
44 numGraphs2 = numGraphs2 + (*iter);
47 cout <<
"tofcalgsec::calib_endcap_atten: the number of Graphs is NOT reasonable!!!" << endl;
51 m_name = string(
"calib_endcap_atten");
54 const double qbegin = 0.0;
55 const double qend = 5000.0;
59 for(
unsigned int i=0; i<
NEndcap; i++ ) {
61 for(
unsigned int k=0; k<nrbin; k++ ) {
62 sprintf( hname,
"Q-id%i-r%i", i, k);
63 m_histograms.push_back(
new TH1F( hname, hname, qbin, qbegin, qend ) );
67 m_histograms.push_back(
new TH1F( hname, hname, qbin, qbegin, qend ) );
72 rposerr.resize( nrbin );
74 for(
unsigned int i=0; i<nrbin; i++ ) {
75 rpos[i] =
rbegin + ( i+0.5 )*rstep;
76 rposerr[i] = 0.5*rstep;
81 for(
unsigned int i=0; i<
NEndcap; i++ ) {
100 std::cout << setiosflags(ios::left) << setw(10) << icounter << setw(8) << data->size() << setw(30) <<
name() << std::endl;
102 if( data->size() > 0 ) {
103 std::vector<Record*>::iterator
iter = data->begin();
104 for( ;
iter!=data->end();
iter++ ) {
105 fillRecord( (*
iter), icounter );
107 fitHistogram( icounter );
108 fillGraph( icounter );
109 fitGraph( icounter );
112 fillGraph( icounter );
115 if( data->size() > 0 ) {
116 std::vector<Record*>::iterator
iter = data->begin();
117 for( ;
iter!=data->end();
iter++ ) {
118 updateData( (*
iter), icounter );
119 fillRecordQ0( (*
iter), icounter );
121 fitHistogramQ0( icounter );
132void calib_endcap_atten::fillRecord(
const Record* r,
unsigned int icounter ) {
134 double rhit = r->
zrhit();
135 if( rhit<rbegin || rhit>
rend )
return;
136 int rbin =
static_cast<int>((rhit-
rbegin)/rstep);
137 if( rbin<0 ) { rbin = 0; }
139 cout <<
"tofcalgsec::calib_endcap_atten:fillRecord: rhit is out of range, rhit=" << rhit <<
" rbin=" << rbin << endl;
150void calib_endcap_atten::fitHistogram(
unsigned int icounter ) {
151 TF1* ld =
new TF1(
"ld",
"landau");
156 std::vector<HepVector>::iterator iter2 = m_fitresult.begin() + icounter*
nKind*
nBinPerCounter;
157 for(
unsigned int j=0; j<
nBinPerCounter-1; j++, iter1++, iter2++ ) {
158 (*iter1)->Fit( ld,
"Q");
159 (*iter2)[0] = ld->GetParameter(1);
160 (*iter2)[1] = ld->GetParError(1);
161 (*iter2)[2] = ld->GetParameter(2);
162 (*iter2)[3] = ld->GetParError(2);
170void calib_endcap_atten::fillGraph(
unsigned int icounter ) {
172 char gname1[256], gname2[256];
178 std::vector<double> toffset, toffseterr;
179 std::vector<double> tsigma, tsigmaerr;
187 toffset[k] = log((*(
iter+k))[0]);
188 toffseterr[k] = log((*(
iter+k))[0])*((*(
iter+k))[1])/((*(
iter+k))[0]);
189 tsigma[k] = (*(
iter+k))[2];
190 tsigmaerr[k] = (*(
iter+k))[3];
193 sprintf( gname1,
"Q MPV-tofid-%i", icounter );
195 std::vector<TH1F*>::iterator itgraph =
m_graphs.end() - 1;
196 (*itgraph)->SetMarkerSize(1.5);
197 (*itgraph)->SetMarkerStyle(20);
198 (*itgraph)->SetMarkerColor(2);
200 (*itgraph)->SetBinContent( k+1, toffset[k] );
201 (*itgraph)->SetBinError( k+1, toffseterr[k] );
204 sprintf( gname2,
"Q sigma-tofid-%i", icounter );
207 (*itgraph)->SetMarkerSize(1.5);
208 (*itgraph)->SetMarkerStyle(21);
209 (*itgraph)->SetMarkerColor(4);
211 (*itgraph)->SetBinContent( k+1, tsigma[k] );
212 (*itgraph)->SetBinError( k+1, tsigmaerr[k] );
219void calib_endcap_atten::fitGraph(
unsigned int icounter ) {
221 TF1 *fsingleq =
new TF1(
"fsingleq", endcapQFunc,
rbegin,
rend, 3 );
222 fsingleq->SetLineColor(1);
223 fsingleq->SetLineWidth(1);
224 fsingleq->SetParameters( 6.5, 0.0, 0.0 );
228 (*itgraph)->Fit(
"fsingleq",
"Q",
"",
rbegin,
rend );
230 X[0] = fsingleq->GetParameter(0);
231 X[1] = fsingleq->GetParameter(1);
232 X[2] = fsingleq->GetParameter(2);
237 std::vector<HepVector>::iterator
iter =
m_result.begin() + icounter;
244void calib_endcap_atten::updateData(
Record* r,
unsigned int icounter ) {
245 double rhit = r->
zrhit();
250 std::vector<HepVector>::iterator
iter =
m_result.begin() + icounter;
251 for(
unsigned int i=0; i<3; i++ ) {
263void calib_endcap_atten::fillRecordQ0(
const Record* r,
unsigned int icounter ) {
265 (*iter)->Fill( r->
q0() );
271void calib_endcap_atten::fitHistogramQ0(
unsigned int icounter ) {
272 TF1* ld =
new TF1(
"ld",
"landau");
278 (*iter1)->Fit( ld,
"Q");
279 (*iter2)[0] = ld->GetParameter(1);
280 (*iter2)[1] = ld->GetParError(1);
281 (*iter2)[2] = ld->GetParameter(2);
282 (*iter2)[3] = ld->GetParError(2);
288void calib_endcap_atten::fillGraphQ0() {
289 char gname1[256], gname2[256];
295 std::vector<double> toffset, toffseterr;
296 std::vector<double> tsigma, tsigmaerr;
302 unsigned int number = 0;
303 std::vector<HepVector>::iterator iter1 = m_fitresult.begin() +
nBinPerCounter - 1;
304 std::vector<HepVector>::iterator iter2 =
m_result.begin();
305 for(
unsigned int i=0; i<
NEndcap; i++ ) {
307 toffset[i] = (*(iter1+number))[0];
308 toffseterr[i] = (*(iter1+number))[1];
309 tsigma[i] = (*(iter1+number))[2];
310 tsigmaerr[i] = (*(iter1+number))[3];
313 (*(iter2+i))[3] = toffset[i]/toffset[0];
314 (*(iter2+i))[4] = toffset[i];
317 sprintf( gname1,
"Q0 MPV vs TOF Counter Number" );
319 std::vector<TH1F*>::iterator itgraph =
m_graphs.end() - 1;
320 (*itgraph)->SetMarkerSize(1.5);
321 (*itgraph)->SetMarkerStyle(20);
322 (*itgraph)->SetMarkerColor(2);
324 (*itgraph)->SetBinContent( k+1, tsigma[k] );
325 (*itgraph)->SetBinError( k+1, tsigmaerr[k] );
327 for(
unsigned int i=0; i<
NEndcap; i++ ) {
328 (*itgraph)->SetBinContent( i+1, toffset[i] );
329 (*itgraph)->SetBinError( i+1, toffseterr[i] );
332 sprintf( gname2,
"Q0 Sigma vs TOF Counter Number" );
335 (*itgraph)->SetTitle(gname2);
336 (*itgraph)->SetMarkerSize(1.5);
337 (*itgraph)->SetMarkerStyle(21);
338 (*itgraph)->SetMarkerColor(4);
339 for(
unsigned int i=0; i<
NEndcap; i++ ) {
340 (*itgraph)->SetBinContent( i+1, tsigma[i] );
341 (*itgraph)->SetBinError( i+1, tsigmaerr[i] );
EvtComplex exp(const EvtComplex &c)
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
std::vector< Record * > RecordSet
const unsigned int NEndcap
std::vector< HepVector > m_result
std::vector< TH1F * > m_histograms
unsigned int nBinPerCounter
std::vector< unsigned int > nGraphPerCanvasPerCounter
unsigned int nCanvasPerCounter
unsigned int nHistPerCounter
const string & name() const
std::vector< unsigned int > nGraphPerCanvas
std::vector< string > CanvasName
std::vector< TH1F * > m_graphs
std::vector< string > CanvasPerCounterName
calib_endcap_atten(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)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")