BOSS 7.0.6
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++ ) {
19 delete (*iter);
20 }
21 histograms.clear();
22 m_result.clear();
23}
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 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}
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 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
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
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")

◆ fillTxt()

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}
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: