BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
Emc/EmcCalib/EmcBhaCalib/EmcBhaCalib-00-00-34/EmcBhaCalib/EmcBhaCalib.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// Environment:
3// This software was developed for the BESIII collaboration. If you
4// use all or part of it, please give an appropriate acknowledgement.
5//
6// Copyright Information:
7// Copyright (C) 2005 IHEP
8//
9//------------------------------------------------------------------------
10
11#ifndef EMCBHACALIB_H
12#define EMCBHACALIB_H
13
14//-------------
15// C Headers --
16//-------------
17#include <ctime>
18
19#include <cstring>
20
21
22#include "GaudiKernel/Algorithm.h"
23
24#include "EmcBhaCalib/EmcLSSMatrix.h"
25#include "EmcBhaCalib/EmcBhaCalibData.h"
26
27#include "EmcCalibConstSvc/IEmcCalibConstSvc.h"
28#include "EmcCalibConstSvc/EmcCalibConstSvc.h"
29#include "GaudiKernel/Bootstrap.h"
30#include "GaudiKernel/ISvcLocator.h"
31
32//Ntuple
33#include "GaudiKernel/NTuple.h"
34
35using namespace std;
36
37//------------------------------------
38// Collaborating Class Declarations --
39//------------------------------------
40
41// ---------------------
42// -- Class Interface --
43// ---------------------
44/**
45 * class EmcBhaCalib Algorithm - performs calibration of EMC Xtals with Bhabha
46 * events and Chi^2 fit, the resulting system of linear equations
47 * of the fit is solved with the SLAP Algebra package
48 *
49 * The matrix and the vector can either be fetched from file(s).
50 * If they are read from files the file names are supposed to have the name
51 * CalibVector.dat and calibMatrix.dat with an extension at the beginning.
52 * Only these extensions (usually the runnumbers) need to be listed in the read-in-file
53 * that is specified with runNumberFile.
54 *
55 * @author Chunxiu Liu (originator/contributor etc.);
56 */
57
58class EmcBhaCalib:public Algorithm{
59
60
61 public:
62
63 EmcBhaCalib(const std::string& name, ISvcLocator* pSvcLocator);
64
65
66 //--------------
67 // Destructor
68 //--------------
69 virtual ~EmcBhaCalib();
70
71 StatusCode initialize();
72 StatusCode execute();
73 StatusCode finalize();
74
75 virtual void help( );
76
77 //------------------
78 // Helper functions
79 //------------------
80
81 private:
82
83
84 // read in calibration constants from file or initialize them to 1
85 void initCalibConst();
86
87 // solve system of linear equations with SLAP package
88 bool solveEqua();
89
90 //output constants to file
91 void writeOutConst();
92
93 //output matrix and vector to file
94 void writeOut();
95
96 //read in matrix and vector from file
97 bool readInFromFile();
98
99 //read in matrix and vector from the database
100 bool readInFromDB();
101
102 //make the absolute constants and fit constants vs theta to get values
103 //where we did not find some
104 bool prepareConstants();
105
106 // fill nutuple
107 void ntupleOut();
108
109 //print data information and only used in testing
110 void printInfo(std::string xtalHitsDirFile);
111 //
112
113 void digiConstCor();
114 //--------------
115 // Data
116 //--------------
117
118private:
119
120 double m_peakCor[6240];
121
122 //cut on minimum number of direct hits needed per xtal
123 int m_dirHitsCut;
124
125 //convergence criterion
126 double m_convCrit;
127
128 //ask before doing the matrix inversion
129 bool m_askForMatrixInversion;
130
131 //fit a polynom second order to the constants theta distribution
132 //to get constants where we did not find one
133 bool m_fitPolynom; // now not been used
134
135 //write the whole matrix, the vector and the constants to file ?
136 bool m_writeToFile;
137
138 //read calibration data (matrix) from the database (or from files)
139 bool m_readDataFromDB;
140
141 //which method for solving the matrix equation
142 std::string m_equationSolver;
143
144 //file name extensions for different output files
145 std::string m_fileExt;
146
147 //file directory
148 std::string m_fileDir;
149
150 // collected calibration data
151 EmcBhaCalibData* m_myCalibData;
152
153 //was calibration successful ?
154 bool m_calibrationSuccessful;
155
156 //array of relative calibration constants, will be reduced to only
157 //living xtals for the matrix inversion (no zero hit entries)
158 double* m_calibConst;
159
160 //relative calibration constants, full list including zero entries
161 double* m_calibConstUnred;
162
163 //absolute calibration constants (new relative * old constants)
164 double* m_absoluteConstants;
165
166 //the old absolute constants the new once are relative to
167 double* m_oldConstants;
168
169 //number of non zeros in matrix M
170 long int m_nrNonZeros;
171
172 //number of xtals with minimum required direct hits
173 int m_nrXtalsEnoughHits;
174
175 //file with a list of runnumbers to read in for which runs matrix file
176 // to load (Default: ./runnumber.dat)
177 std::string m_runNumberFile;
178
179 //message output in the tool classes
180 int m_MsgFlag;
181
182 // ntuple for analysis
183 NTuple::Tuple* m_tuple1;
184 NTuple::Item<long> ixtal;
185 NTuple::Item<float> gi0;
186 NTuple::Item<float> calibConst;
187 NTuple::Item<float> err;
188 NTuple::Item<long> nhitxtal;
189
190 double DigiCalibConst;
191
192 IEmcCalibConstSvc* m_emcCalibConstSvc;
193
194};
195
196#endif // EMCBHACALIB_H
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
StatusCode execute()
virtual void help()
StatusCode finalize()
virtual ~EmcBhaCalib()
StatusCode initialize()