BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcBhaCalibData.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3//
4//
5// Description:
6// Class EmcBhaCalibData - see header
7//
8// Environment:
9// Software developed for the BESIII Detector at the BEPCII.
10//
11// Author List:
12// Chunxiu Liu
13//
14// Copyright Information:
15// Copyright (C) 2005 IHEP
16//
17//------------------------------------------------------------------------
18
19//-----------------------
20// This Class's Header --
21//-----------------------
23
24//-------------
25// C Headers --
26//-------------
27extern "C" {
28}
29
30//---------------
31// C++ Headers --
32//---------------
33
34#include <cstring>
35
36using namespace std;
37//-------------------------------
38// Collaborating Class Headers --
39//-------------------------------
40
41// ----------------------------------------
42// -- Public Function Member Definitions --
43// ----------------------------------------
44
45//----------------
46// Constructors --
47//----------------
49 : _nXtals(numxtals),
50 _nXtalsHit(0)
51{
52 // _matrixM = new EmcLSSMatrix(_nXtals,600);
53 _matrixM = new EmcLSSMatrix(_nXtals,_nXtals);
54 _vectorR = new double[_nXtals];
55 _xtalInd = new int[_nXtals];
56 _xtalHits = new int[_nXtals];
57 _xtalHitsMax = new int[_nXtals];
58 for (int i=0;i<_nXtals;i++) {
59 _vectorR[i] = 0.;
60 _xtalInd[i] = i;
61 _xtalHits[i] = 0;
62 _xtalHitsMax[i] = 0;
63 }
64 _MsgFlag =0;
65}
66
67//----------------
68// Constructors --
69//----------------
70EmcBhaCalibData::EmcBhaCalibData(int numxtals, int MsgFlag)
71 : _nXtals(numxtals),
72 _nXtalsHit(0)
73{
74 // _matrixM = new EmcLSSMatrix(_nXtals,600);
75 _matrixM = new EmcLSSMatrix(_nXtals,_nXtals, MsgFlag);
76 _vectorR = new double[_nXtals];
77 _xtalInd = new int[_nXtals];
78 _xtalHits = new int[_nXtals];
79 _xtalHitsMax = new int[_nXtals];
80 for (int i=0;i<_nXtals;i++) {
81 _vectorR[i] = 0.;
82 _xtalInd[i] = i;
83 _xtalHits[i] = 0;
84 _xtalHitsMax[i] = 0;
85 }
86
87 _MsgFlag = MsgFlag;
88}
89
90//--------------
91// Destructor --
92//--------------
94 if ( 0 != _matrixM) {
95 delete _matrixM;
96 _matrixM = 0;
97 }
98 if ( 0 != _vectorR) {
99 delete[] _vectorR;
100 _vectorR = 0;
101 }
102 if ( 0 != _xtalInd) {
103 delete[] _xtalInd;
104 _xtalInd = 0;
105 }
106 if ( 0 != _xtalHits) {
107 delete[] _xtalHits;
108 _xtalHits = 0;
109 }
110 if ( 0 != _xtalHitsMax) {
111 delete[] _xtalHitsMax;
112 _xtalHitsMax = 0;
113 }
114}
115//-------------
116// Operators --
117//-------------
118
119
120//-------------
121// Selectors --
122//-------------
123
124
125//-------------
126// Modifiers --
127//-------------
128
129void
130EmcBhaCalibData::writeOut( ostream& OutM, ostream& OutV) {
131
132 //write only non zero elements to file
133 OutM.setf(ios::scientific,ios::floatfield);
134 OutV.setf(ios::scientific,ios::floatfield);
135 OutV.precision(12);
136 OutM.precision(12);
137
138 _matrixM->writeOut( OutM );
139
140 _nXtalsHit = 0;
141
142 double* vect_ele = _vectorR;
143 double* vect_end = _vectorR + _nXtals;
144 int* xtal_ind = _xtalInd;
145 int* hits_max = _xtalHitsMax;
146 int* hits = _xtalHits;
147
148 while ( vect_ele < vect_end ) {
149 if ( *vect_ele != 0. ){
150 _nXtalsHit++;
151 }
152 vect_ele++;
153 }
154
155 OutV << _nXtalsHit << " ";
156
157 vect_ele = _vectorR;
158
159 while ( vect_ele < vect_end ) {
160 if ( *vect_ele != 0. ) {
161 OutV << *xtal_ind << " " << *hits << " " << *hits_max << " "
162 << *vect_ele << " ";
163 }
164 xtal_ind++;
165 vect_ele++;
166 hits_max++;
167 hits++;
168 }
169
170}
171
172
173void
174EmcBhaCalibData::readIn( istream& InM, istream& InV) {
175
176 _matrixM->readIn( InM );
177
178 _matrixM->print_NonZeros();
179
180 //cout<<"num_filled_rows(48)="<<_matrixM->num_filled_rows(48)<<endl;
181 //cout<<"num_filled_cols(48)="<<_matrixM->num_filled_cols(48)<<endl;
182
183 //cout<<"matrix(47,47)"<<_matrixM->operator()(47,47)<<endl;
184
185 double vect_ele;
186 int nr_ele;
187 int xtal_ind;
188 int hits;
189 int hits_max;
190
191 InV >> nr_ele;
192
193 for (int i=0; i<nr_ele; i++) {
194
195 InV >> xtal_ind >> hits >> hits_max
196 >> vect_ele ;
197
198 if (_vectorR[xtal_ind] == 0. ) {
199 _nXtalsHit++;
200 }
201
202 _vectorR[xtal_ind] += vect_ele ;
203 _xtalInd[xtal_ind] = xtal_ind;
204 _xtalHits[xtal_ind] += hits;
205 _xtalHitsMax[xtal_ind] += hits_max;
206
207 }
208
209}
210
211bool
213
214 bool successful = true;
215
216 //delete all zero elements in matrix and vector R
217 //save only non zero elements (this format is needed by slap),
218 //keep the original xtal index in array xtalInd
219
220 //array to store the new row/column reference for later matrix reduction
221 int* xRef = new int[_nXtals];
222 memset(xRef, -1, (_nXtals*sizeof(int)));
223
224 _nXtalsHit = 0;
225 for ( int _arrayIndx = 0;
226 _arrayIndx < _nXtals; _arrayIndx++) {
227
228 if ( _vectorR[_arrayIndx] > 0. ) {
229
230 _vectorR[_nXtalsHit] = _vectorR[_arrayIndx];
231 _xtalInd[_nXtalsHit] = _xtalInd[_arrayIndx];
232 _xtalHits[_nXtalsHit] = _xtalHits[_arrayIndx];
233 _xtalHitsMax[_nXtalsHit] = _xtalHitsMax[_arrayIndx];
234 xRef[_arrayIndx] = _nXtalsHit;
235
236 _nXtalsHit++;
237 }
238 }
239
240 successful = _matrixM->reduce_Matrix( xRef );
241
242 delete [] xRef;
243
244 return successful;
245}
246
247
248void
250{
251 _nXtalsHit = 0;
252 _matrixM->reset();
253
254 for (int i=0;i<_nXtals;i++) {
255 _vectorR[i]= 0.;
256 _xtalInd[i] = i;
257 _xtalHits[i] = 0;
258 _xtalHitsMax[i] = 0;
259 }
260
261}
262
263
264void
266
267 if (_MsgFlag <= 3) {
268 std::cout << "EmcBhaCalibData:: INFO "<< "R ( " << number << " ): " << _vectorR[number]
269 << " hits: " << _xtalHits[number]
270 << " direct hits: " << _xtalHitsMax[number]
271 << endl;
272 }
273}
274
275
276
const double hits_max
void printVec(int number)
void writeOut(ostream &OutM, ostream &outV)
EmcBhaCalibData(int numxtals)
void readIn(istream &InM, istream &InV)
bool reduce_Matrix(int *xRef_list)
void print_NonZeros()
void writeOut(ostream &Out)
void readIn(istream &In)