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