9#include "tofcalgsec/TofCalibFit.h"
10#include "TDirectory.h"
18 if( isbarrel ) { nCounter =
NBarrel; }
31 m_name = string(
"calibfit");
38 std::vector<TH1F*>::iterator iter1 =
m_histograms.begin();
43 std::vector<TH1F*>::iterator iter2 =
m_graphs.begin();
44 for( ; iter2 !=
m_graphs.end(); iter2++ ) {
53 std::ofstream out(
file,ios::out);
55 std::vector<HepVector>::iterator it;
57 for(
int i=0; i<(*it).num_row(); i++ ) {
58 out << (*it)[i] <<
" ";
65 cerr <<
"error when open file " <<
file <<
" for write in " <<
name() <<
"::fillTxt()" << std::endl;
66 cout <<
"print all parameters to srceen: in total " <<
m_result.size() <<
" items" << std::endl;
67 std::vector<HepVector>::iterator it;
69 for(
int i=0; i<(*it).num_row(); i++ ) {
70 cout << (*it)[i] <<
" ";
84 std::cout<<
" tofcalgsec::TofCalibFit:" <<
m_name <<
": the number of histograms is NOT same as the number of histograms saved!" <<
" nhist=" << nhist <<
" calculated=" << (nCounter*
nHistPerCounter +
nHistogram) <<
" nCounter=" << nCounter <<
" nHistPerCounter=" <<
nHistPerCounter <<
" nHistogram=" <<
nHistogram << std::endl;
88 unsigned int numgraph1 = 0;
89 unsigned int numgraph2 = 0;
93 numgraph1 = numgraph1 + (*iter);
99 numgraph2 = numgraph2 + (*iter);
102 unsigned int ngraph =
m_graphs.size();
103 if( ngraph != ( nCounter*numgraph1+numgraph2) ) {
104 std::cout<<
" tofcalgsec::TofCalibFit:"<<
m_name <<
": the number of graphs is NOT same as the number of graphs saved!" <<
" ngraph=" << ngraph <<
" nCounter=" << nCounter <<
" numgraph1=" << numgraph1 <<
" numgraph2=" << numgraph2 << std::endl;
108 TFile
f(
file,
"RECREATE");
110 gStyle->SetOptStat(2211);
111 gStyle->SetOptFit(1111);
112 gStyle->SetLabelSize(0.03,
"x");
113 gStyle->SetLabelSize(0.03,
"y");
116 char canvasname[256];
118 std::vector<TH1F*>::iterator iter1 =
m_histograms.begin();
119 std::vector<TH1F*>::iterator iter2 =
m_graphs.begin();
120 for(
unsigned int i=0; i<nCounter; i++ ) {
121 sprintf( dirname,
"tofid%i", i );
122 TDirectory* cdresult =
f.mkdir( dirname );
126 (*(iter1+j))->Write();
133 sprintf( canvasname,
"%s-tofid-%i", (*it1).c_str(), i );
134 TCanvas* c1 =
new TCanvas( canvasname, canvasname, 1);
135 c1->SetFillColor(10);
136 for(
unsigned int k=0; k<(*it2); k++ ) {
138 (*(iter2+k))->Draw(
"E");
141 (*(iter2+k))->Draw(
"Esame");
144 iter2 = iter2 + (*it2);
152 TDirectory* cdresult =
f.mkdir( dirname );
156 std::vector<TH1F*>::iterator iter2 =
m_graphs.begin() + nCounter*numgraph1;
161 for(
unsigned int j=0; j<
nCanvas; j++ ) {
162 std::vector<string>::iterator it1 =
CanvasName.begin() + j;
164 sprintf( canvasname, (*it1).c_str() );
165 TCanvas* c1 =
new TCanvas( canvasname, canvasname, 1);
166 c1->SetFillColor(10);
167 for(
unsigned int k=0; k<(*it2); k++ ) {
169 (*(iter2+k))->Draw(
"E");
172 (*(iter2+k))->Draw(
"Esame");
175 iter2 = iter2 + (*it2);
const unsigned int NBarrel
const unsigned int NEndcap
std::vector< string > CanvasPerCounterName
std::vector< TH1F * > m_histograms
std::vector< TH1F * > m_graphs
unsigned int nBinPerCounter
std::vector< unsigned int > nGraphPerCanvas
std::vector< string > CanvasName
void fillRoot(const char *file)
unsigned int nCanvasPerCounter
unsigned int nHistPerCounter
const string & name() const
std::vector< HepVector > m_result
TofCalibFit(bool isbarrel, const int npar)
void fillTxt(const char *file)
std::vector< unsigned int > nGraphPerCanvasPerCounter
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")