BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
TofCalibration Class Referenceabstract

#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)
 
 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
 
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
 

Detailed Description

Constructor & Destructor Documentation

◆ TofCalibration() [1/2]

TofCalibration::TofCalibration ( const int  npar)

◆ ~TofCalibration() [1/2]

TofCalibration::~TofCalibration ( )

Definition at line 16 of file TofCalibration.cxx.

16 {
17 std::vector<TH1F*>::iterator iter = histograms.begin();
18 for( ; iter != histograms.end(); iter++ ) {
19 delete (*iter);
20 }
21 histograms.clear();
22 m_result.clear();
23}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)

◆ TofCalibration() [2/2]

TofCalibration::TofCalibration ( const int  npar)

◆ ~TofCalibration() [2/2]

TofCalibration::~TofCalibration ( )

Member Function Documentation

◆ calculate() [1/2]

void TofCalibration::calculate ( RecordSet *&  data,
unsigned int  icounter 
)
virtual

Definition at line 26 of file TofCalibration.cxx.

26 {
27
28 std::cout << setiosflags(ios::left) << setw(10) << icounter << setw(8) << data->size() << setw(30) << name() << std::endl;
29
30 if( data->size() <= 0 ) {
31 for( int i=0; i<X.num_row(); i++ ) {
32 X[i] = 1.0;
33 }
34 }
35 else {
36 std::vector<Record*>::iterator iter = data->begin();
37 for( ; iter!=data->end(); iter++ ) {
38 calculate_record( (*iter), icounter );
39 }
40
41 calculate_result( icounter );
42 }
43
44 return;
45}
TTree * data
virtual void calculate_record(const Record *r, unsigned int icounter)=0
virtual void calculate_result(unsigned int icounter)=0

◆ calculate() [2/2]

virtual void TofCalibration::calculate ( RecordSet *&  data,
unsigned int  icounter 
)
virtual

◆ calculate_record() [1/2]

virtual void TofCalibration::calculate_record ( const Record r,
unsigned int  icounter 
)
protectedpure virtual

Referenced by calculate().

◆ calculate_record() [2/2]

virtual void TofCalibration::calculate_record ( const Record r,
unsigned int  icounter 
)
protectedpure virtual

◆ calculate_result() [1/2]

virtual void TofCalibration::calculate_result ( unsigned int  icounter)
protectedpure virtual

Referenced by calculate().

◆ calculate_result() [2/2]

virtual void TofCalibration::calculate_result ( unsigned int  icounter)
protectedpure virtual

◆ fillRoot() [1/2]

void TofCalibration::fillRoot ( const char *  file,
bool  isbarrel 
)

Definition at line 78 of file TofCalibration.cxx.

78 {
79
80 unsigned int ncounter = 1;
81 if( isbarrel ) {
82 ncounter = NBarrel;
83 }
84 else {
85 ncounter = NEndcap;
86 }
87
88 unsigned int nhist = histograms.size();
89 if( nhist != (ncounter*nHistPerCounter + nHistogram) ) {
90 std::cout<<" tofcalgsec::TofCalibration: the number of histograms is NOT integral number of times of counter number!"<<std::endl;
91 exit(0);
92 }
93 unsigned int ngraph = graphs.size();
94 if( ngraph != (ncounter*nGraphPerCounter + nGraph) ) {
95 std::cout<<" tofcalgsec::TofCalibration: the number of histograms is NOT integral number of times of counter number!"<<std::endl;
96 exit(0);
97 }
98
99 TFile f(file,"RECREATE");
100
101 gStyle->SetOptFit(1111);
102 gStyle->SetOptStat(1111);
103 gStyle->SetLabelSize(0.03,"x");
104 gStyle->SetLabelSize(0.03,"y");
105
106 char dirname[256];
107 if( nHistPerCounter>1 ) {
108 std::vector<TH1F*>::iterator iter = histograms.begin();
109 for( unsigned int i=0; i<ncounter; i++ ) {
110 sprintf( dirname, "tofid%i", i );
111 TDirectory* cdresult = f.mkdir( dirname );
112 cdresult->cd();
113
114 for( unsigned int i=0; i<nHistPerCounter; i++ ) {
115 (*(iter+i))->Write();
116 }
118 }
119 }
120 else {
121 sprintf( dirname, "tofid" );
122 TDirectory* cdresult = f.mkdir( dirname );
123 cdresult->cd();
124
125 std::vector<TH1F*>::iterator iter = histograms.begin();
126 for( ; iter != histograms.end(); iter++ ) {
127 (*iter)->Write();
128 }
129 }
130
131 f.Close();
132
133 return;
134}
char * file
Definition: DQA_TO_DB.cxx:15

◆ fillRoot() [2/2]

void TofCalibration::fillRoot ( const char *  file,
bool  isbarrel 
)

◆ fillTxt() [1/2]

void TofCalibration::fillTxt ( const char *  file)

Definition at line 48 of file TofCalibration.cxx.

48 {
49 std::ofstream out(file,ios::out);
50 if( out ) {
51 std::vector<HepVector>::iterator it;
52 for( it=m_result.begin(); it!=m_result.end(); it++ ) {
53 // for( unsigned int i=0; i<(*it).num_row(); i++ ) {
54 for( unsigned int i=0; i<Npar2; i++ ) {
55 out << (*it)[i] << " ";
56 }
57 out << std::endl;
58 }
59 out.close();
60 }
61 else{
62 cerr << "error when open file " << file << " for write in " << name() << "::fillTxt()" << std::endl;
63 cout << "print all parameters to srceen: in total " << m_result.size() << " items" << std::endl;
64 std::vector<HepVector>::iterator it;
65 for( it=m_result.begin(); it!=m_result.end(); it++ ) {
66 // for( unsigned int i=0; i<(*it).num_row(); i++ ) {
67 for( unsigned int i=0; i<Npar2; i++ ) {
68 cout << (*it)[i] << " ";
69 }
70 cout << std::endl;
71 }
72 }
73
74 return;
75}

◆ fillTxt() [2/2]

void TofCalibration::fillTxt ( const char *  file)

◆ name() [1/2]

virtual const string & TofCalibration::name ( ) const
inlinevirtual

Definition at line 19 of file InstallArea/include/tofcalgsec/tofcalgsec/TofCalibration.h.

19{ return m_name; }

Referenced by calculate(), and fillTxt().

◆ name() [2/2]

virtual const string & TofCalibration::name ( ) const
inlinevirtual

Member Data Documentation

◆ graphs

std::vector< TGraph * > TofCalibration::graphs
protected

Definition at line 43 of file InstallArea/include/tofcalgsec/tofcalgsec/TofCalibration.h.

Referenced by fillRoot().

◆ histograms

std::vector< TH1F * > TofCalibration::histograms
protected

◆ m_name

string TofCalibration::m_name
protected

◆ m_result

std::vector< HepVector > TofCalibration::m_result
protected

◆ nGraph

unsigned int TofCalibration::nGraph
protected

Definition at line 38 of file InstallArea/include/tofcalgsec/tofcalgsec/TofCalibration.h.

Referenced by fillRoot().

◆ nGraphPerCounter

unsigned int TofCalibration::nGraphPerCounter
protected

Definition at line 36 of file InstallArea/include/tofcalgsec/tofcalgsec/TofCalibration.h.

Referenced by fillRoot().

◆ nHistogram

unsigned int TofCalibration::nHistogram
protected

Definition at line 37 of file InstallArea/include/tofcalgsec/tofcalgsec/TofCalibration.h.

Referenced by fillRoot().

◆ nHistPerCounter

unsigned int TofCalibration::nHistPerCounter
protected

Definition at line 35 of file InstallArea/include/tofcalgsec/tofcalgsec/TofCalibration.h.

Referenced by fillRoot().

◆ Npar

int TofCalibration::Npar
protected

◆ Npar2

unsigned int TofCalibration::Npar2
protected

Definition at line 34 of file InstallArea/include/tofcalgsec/tofcalgsec/TofCalibration.h.

Referenced by fillTxt().

◆ X

HepVector TofCalibration::X
protected

The documentation for this class was generated from the following files: