BOSS 8.0.0
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)

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

Detailed Description

Definition at line 13 of file TofCalibration.h.

Constructor & Destructor Documentation

◆ TofCalibration()

TofCalibration::TofCalibration ( const int npar)

Definition at line 11 of file TofCalibration.cxx.

11 : Npar( npar ) {
12 X = HepVector( Npar, 0 );
13 m_name = string( "calibration" );
14}

◆ ~TofCalibration()

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++ ) { delete ( *iter ); }
19 histograms.clear();
20 m_result.clear();
21}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
std::vector< HepVector > m_result
std::vector< TH1F * > histograms

Member Function Documentation

◆ calculate()

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

Definition at line 23 of file TofCalibration.cxx.

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

◆ calculate_record()

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

Referenced by calculate().

◆ calculate_result()

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

Referenced by calculate().

◆ fillRoot()

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

Definition at line 74 of file TofCalibration.cxx.

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

◆ fillTxt()

void TofCalibration::fillTxt ( const char * file)

Definition at line 43 of file TofCalibration.cxx.

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

◆ name()

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

Definition at line 19 of file TofCalibration.h.

19{ return m_name; }

Referenced by calculate(), and fillTxt().

Member Data Documentation

◆ graphs

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

Definition at line 43 of file TofCalibration.h.

Referenced by fillRoot().

◆ histograms

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

Definition at line 42 of file TofCalibration.h.

Referenced by fillRoot(), and ~TofCalibration().

◆ m_name

string TofCalibration::m_name
protected

Definition at line 32 of file TofCalibration.h.

Referenced by name(), and TofCalibration().

◆ m_result

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

Definition at line 44 of file TofCalibration.h.

Referenced by fillTxt(), and ~TofCalibration().

◆ nGraph

unsigned int TofCalibration::nGraph
protected

Definition at line 38 of file TofCalibration.h.

Referenced by fillRoot().

◆ nGraphPerCounter

unsigned int TofCalibration::nGraphPerCounter
protected

Definition at line 36 of file TofCalibration.h.

Referenced by fillRoot().

◆ nHistogram

unsigned int TofCalibration::nHistogram
protected

Definition at line 37 of file TofCalibration.h.

Referenced by fillRoot().

◆ nHistPerCounter

unsigned int TofCalibration::nHistPerCounter
protected

Definition at line 35 of file TofCalibration.h.

Referenced by fillRoot().

◆ Npar

int TofCalibration::Npar
protected

Definition at line 33 of file TofCalibration.h.

Referenced by TofCalibration().

◆ Npar2

unsigned int TofCalibration::Npar2
protected

Definition at line 34 of file TofCalibration.h.

Referenced by fillTxt().

◆ X

HepVector TofCalibration::X
protected

Definition at line 40 of file TofCalibration.h.

Referenced by calculate(), and TofCalibration().


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