#include <TofCalibration.h>
Public Member Functions | |
TofCalibration (const int npar) | |
~TofCalibration () | |
virtual const string & | name () const |
virtual void | calculate (RecordSet *&data, unsigned int icounter) |
void | fillTxt (const char *file) |
void | fillRoot (const char *file, bool isbarrel) |
Protected Member Functions | |
virtual void | calculate_record (const Record *r, unsigned int icounter)=0 |
virtual void | calculate_result (unsigned int icounter)=0 |
Protected Attributes | |
string | m_name |
int | Npar |
unsigned int | Npar2 |
unsigned int | nHistPerCounter |
unsigned int | nGraphPerCounter |
unsigned int | nHistogram |
unsigned int | nGraph |
HepVector | X |
std::vector< TH1F * > | histograms |
std::vector< TGraph * > | graphs |
std::vector< HepVector > | m_result |
Definition at line 13 of file TofCalibration.h.
TofCalibration::TofCalibration | ( | const int | npar | ) |
TofCalibration::~TofCalibration | ( | ) |
Definition at line 16 of file TofCalibration.cxx.
References histograms, iter(), and m_result.
00016 { 00017 std::vector<TH1F*>::iterator iter = histograms.begin(); 00018 for( ; iter != histograms.end(); iter++ ) { 00019 delete (*iter); 00020 } 00021 histograms.clear(); 00022 m_result.clear(); 00023 }
void TofCalibration::calculate | ( | RecordSet *& | data, | |
unsigned int | icounter | |||
) | [virtual] |
Definition at line 26 of file TofCalibration.cxx.
References calculate_record(), calculate_result(), genRecEmupikp::i, iter(), name(), and X.
00026 { 00027 00028 std::cout << setiosflags(ios::left) << setw(10) << icounter << setw(8) << data->size() << setw(30) << name() << std::endl; 00029 00030 if( data->size() <= 0 ) { 00031 for( int i=0; i<X.num_row(); i++ ) { 00032 X[i] = 1.0; 00033 } 00034 } 00035 else { 00036 std::vector<Record*>::iterator iter = data->begin(); 00037 for( ; iter!=data->end(); iter++ ) { 00038 calculate_record( (*iter), icounter ); 00039 } 00040 00041 calculate_result( icounter ); 00042 } 00043 00044 return; 00045 }
virtual void TofCalibration::calculate_record | ( | const Record * | r, | |
unsigned int | icounter | |||
) | [protected, pure virtual] |
Referenced by calculate().
virtual void TofCalibration::calculate_result | ( | unsigned int | icounter | ) | [protected, pure virtual] |
Referenced by calculate().
void TofCalibration::fillRoot | ( | const char * | file, | |
bool | isbarrel | |||
) |
Definition at line 78 of file TofCalibration.cxx.
References delete_small_size::dirname, graphs, histograms, genRecEmupikp::i, iter(), NBarrel, NEndcap, nGraph, nGraphPerCounter, nHistogram, and nHistPerCounter.
00078 { 00079 00080 unsigned int ncounter = 1; 00081 if( isbarrel ) { 00082 ncounter = NBarrel; 00083 } 00084 else { 00085 ncounter = NEndcap; 00086 } 00087 00088 unsigned int nhist = histograms.size(); 00089 if( nhist != (ncounter*nHistPerCounter + nHistogram) ) { 00090 std::cout<<" tofcalgsec::TofCalibration: the number of histograms is NOT integral number of times of counter number!"<<std::endl; 00091 exit(0); 00092 } 00093 unsigned int ngraph = graphs.size(); 00094 if( ngraph != (ncounter*nGraphPerCounter + nGraph) ) { 00095 std::cout<<" tofcalgsec::TofCalibration: the number of histograms is NOT integral number of times of counter number!"<<std::endl; 00096 exit(0); 00097 } 00098 00099 TFile f(file,"RECREATE"); 00100 00101 gStyle->SetOptFit(1111); 00102 gStyle->SetOptStat(1111); 00103 gStyle->SetLabelSize(0.03,"x"); 00104 gStyle->SetLabelSize(0.03,"y"); 00105 00106 char dirname[256]; 00107 if( nHistPerCounter>1 ) { 00108 std::vector<TH1F*>::iterator iter = histograms.begin(); 00109 for( unsigned int i=0; i<ncounter; i++ ) { 00110 sprintf( dirname, "tofid%i", i ); 00111 TDirectory* cdresult = f.mkdir( dirname ); 00112 cdresult->cd(); 00113 00114 for( unsigned int i=0; i<nHistPerCounter; i++ ) { 00115 (*(iter+i))->Write(); 00116 } 00117 iter = iter + nHistPerCounter; 00118 } 00119 } 00120 else { 00121 sprintf( dirname, "tofid" ); 00122 TDirectory* cdresult = f.mkdir( dirname ); 00123 cdresult->cd(); 00124 00125 std::vector<TH1F*>::iterator iter = histograms.begin(); 00126 for( ; iter != histograms.end(); iter++ ) { 00127 (*iter)->Write(); 00128 } 00129 } 00130 00131 f.Close(); 00132 00133 return; 00134 }
void TofCalibration::fillTxt | ( | const char * | file | ) |
Definition at line 48 of file TofCalibration.cxx.
References genRecEmupikp::i, m_result, name(), and Npar2.
00048 { 00049 std::ofstream out(file,ios::out); 00050 if( out ) { 00051 std::vector<HepVector>::iterator it; 00052 for( it=m_result.begin(); it!=m_result.end(); it++ ) { 00053 // for( unsigned int i=0; i<(*it).num_row(); i++ ) { 00054 for( unsigned int i=0; i<Npar2; i++ ) { 00055 out << (*it)[i] << " "; 00056 } 00057 out << std::endl; 00058 } 00059 out.close(); 00060 } 00061 else{ 00062 cerr << "error when open file " << file << " for write in " << name() << "::fillTxt()" << std::endl; 00063 cout << "print all parameters to srceen: in total " << m_result.size() << " items" << std::endl; 00064 std::vector<HepVector>::iterator it; 00065 for( it=m_result.begin(); it!=m_result.end(); it++ ) { 00066 // for( unsigned int i=0; i<(*it).num_row(); i++ ) { 00067 for( unsigned int i=0; i<Npar2; i++ ) { 00068 cout << (*it)[i] << " "; 00069 } 00070 cout << std::endl; 00071 } 00072 } 00073 00074 return; 00075 }
virtual const string& TofCalibration::name | ( | void | ) | const [inline, virtual] |
Definition at line 19 of file TofCalibration.h.
References m_name.
Referenced by calculate(), and fillTxt().
00019 { return m_name; }
std::vector<TGraph*> TofCalibration::graphs [protected] |
std::vector<TH1F*> TofCalibration::histograms [protected] |
string TofCalibration::m_name [protected] |
std::vector<HepVector> TofCalibration::m_result [protected] |
unsigned int TofCalibration::nGraph [protected] |
unsigned int TofCalibration::nGraphPerCounter [protected] |
unsigned int TofCalibration::nHistogram [protected] |
unsigned int TofCalibration::nHistPerCounter [protected] |
int TofCalibration::Npar [protected] |
unsigned int TofCalibration::Npar2 [protected] |
HepVector TofCalibration::X [protected] |