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 ) );
66 sprintf( hname,
"Q0-id%i", i );
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();
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();
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 );
194 m_graphs.push_back(
new TGraphErrors(
nBinPerCounter-1, &rpos[0], &toffset[0], &rposerr[0], &toffseterr[0]) );
195 std::vector<TGraphErrors*>::iterator itgraph =
m_graphs.end() - 1;
196 (*itgraph)->SetTitle(gname1);
197 (*itgraph)->SetMarkerSize(1.5);
198 (*itgraph)->SetMarkerStyle(20);
199 (*itgraph)->SetMarkerColor(2);
201 sprintf( gname2,
"Q sigma-tofid-%i", icounter );
202 m_graphs.push_back(
new TGraphErrors(
nBinPerCounter-1, &rpos[0], &tsigma[0], &rposerr[0], &tsigmaerr[0]) );
204 (*itgraph)->SetTitle(gname2);
205 (*itgraph)->SetMarkerSize(1.5);
206 (*itgraph)->SetMarkerStyle(21);
207 (*itgraph)->SetMarkerColor(4);
213void calib_endcap_atten::fitGraph(
unsigned int icounter ) {
215 TF1 *fsingleq =
new TF1(
"fsingleq", endcapQFunc,
rbegin,
rend, 3 );
216 fsingleq->SetLineColor(1);
217 fsingleq->SetLineWidth(1);
218 fsingleq->SetParameters( 6.5, 0.0, 0.0 );
222 (*itgraph)->Fit(
"fsingleq",
"Q",
"",
rbegin,
rend );
224 X[0] = fsingleq->GetParameter(0);
225 X[1] = fsingleq->GetParameter(1);
226 X[2] = fsingleq->GetParameter(2);
231 std::vector<HepVector>::iterator
iter =
m_result.begin() + icounter;
238void calib_endcap_atten::updateData(
Record* r,
unsigned int icounter ) {
239 double rhit = r->
zrhit();
244 std::vector<HepVector>::iterator
iter =
m_result.begin() + icounter;
245 for(
unsigned int i=0; i<3; i++ ) {
250 double q0 =
q*costheta/
exp(endcapQFunc(&rhit,par));
257void calib_endcap_atten::fillRecordQ0(
const Record* r,
unsigned int icounter ) {
259 (*iter)->Fill( r->
q0() );
265void calib_endcap_atten::fitHistogramQ0(
unsigned int icounter ) {
266 TF1* ld =
new TF1(
"ld",
"landau");
272 (*iter1)->Fit( ld,
"Q");
273 (*iter2)[0] = ld->GetParameter(1);
274 (*iter2)[1] = ld->GetParError(1);
275 (*iter2)[2] = ld->GetParameter(2);
276 (*iter2)[3] = ld->GetParError(2);
282void calib_endcap_atten::fillGraphQ0() {
283 char gname1[256], gname2[256];
289 std::vector<double> toffset, toffseterr;
290 std::vector<double> tsigma, tsigmaerr;
296 unsigned int number = 0;
297 std::vector<HepVector>::iterator iter1 = m_fitresult.begin() +
nBinPerCounter - 1;
298 std::vector<HepVector>::iterator iter2 =
m_result.begin();
299 for(
unsigned int i=0; i<
NEndcap; i++ ) {
301 toffset[i] = (*(iter1+number))[0];
302 toffseterr[i] = (*(iter1+number))[1];
303 tsigma[i] = (*(iter1+number))[2];
304 tsigmaerr[i] = (*(iter1+number))[3];
307 (*(iter2+i))[3] = toffset[i]/toffset[0];
308 (*(iter2+i))[4] = toffset[i];
311 sprintf( gname1,
"Q0 MPV vs TOF Counter Number" );
312 m_graphs.push_back(
new TGraphErrors(
NEndcap, &itofid[0], &toffset[0], &itofiderr[0], &toffseterr[0]) );
313 std::vector<TGraphErrors*>::iterator itgraph =
m_graphs.end() - 1;
314 (*itgraph)->SetTitle(gname1);
315 (*itgraph)->SetMarkerSize(1.5);
316 (*itgraph)->SetMarkerStyle(20);
317 (*itgraph)->SetMarkerColor(2);
319 sprintf( gname2,
"Q0 Sigma vs TOF Counter Number" );
320 m_graphs.push_back(
new TGraphErrors(
NEndcap, &itofid[0], &tsigma[0], &itofiderr[0], &tsigmaerr[0]) );
322 (*itgraph)->SetTitle(gname2);
323 (*itgraph)->SetMarkerSize(1.5);
324 (*itgraph)->SetMarkerStyle(21);
325 (*itgraph)->SetMarkerColor(4);
EvtComplex exp(const EvtComplex &c)
double abs(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< TGraphErrors * > m_graphs
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< string > CanvasPerCounterName
calib_endcap_atten(const unsigned int nrbin)
void calculate(RecordSet *&data, unsigned int icounter)