]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCMonitorConfig.cxx
Fixing Coverity 10889 (B.Hippolyte)
[u/mrichter/AliRoot.git] / TPC / AliTPCMonitorConfig.cxx
CommitLineData
48265b32 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
fb3305d1 18Revision 1.2 2007/10/12 13:36:27 cvetan
19Coding convention fixes from Stefan
20
ca7b8371 21Revision 1.1 2007/09/17 10:23:31 cvetan
22New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
23
48265b32 24*/
25
fb3305d1 26//////////////////////////////////////////////////////////////////////////
27////
28//// AliTPCMonitorConfig class
29////
30//// Configuration handler class for AliTPCMonitor
31////
32//// The basic configuration will be read from the file AliTPCMonitorConfig.txt
33//// and can be changed online via the Button "Conf. Ranges"
34//// Basic configuration settings are e.g. the range for the determination
35//// of the baseline, maximum adc value and the settings for the pedestal calculation.
36////
37//// Author: Stefan Kniege, IKF, Frankfurt
38////
39////
ca7b8371 40/////////////////////////////////////////////////////////////////////////
41
42
48265b32 43#include "AliTPCMonitorConfig.h"
ca7b8371 44#include "AliLog.h"
45#include <Riostream.h>
46
48265b32 47ClassImp(AliTPCMonitorConfig)
48
ca7b8371 49// _______________________________________________________________________________________________________________
50AliTPCMonitorConfig::AliTPCMonitorConfig(const Char_t* name, const Char_t* title) :
51 TNamed(name,title),
52 fFormat(-1),
53 fSector(0),
54 fSectorLast(-1),
55 fSectorLastDisplayed(-1),
56 fSectorArr(new Int_t[36]),
c60053f6 57 fFileLast(),
ca7b8371 58 fFileLastSet(0),
c60053f6 59 fFileCurrent(),
ca7b8371 60 fEventNext(1),
61 fEventNextID(1),
62 fEventProcessed(0),
63 fRangeMaxAdcMin(50),
64 fRangeMaxAdcMax(100),
65 fRangeBaseMin(300),
66 fRangeBaseMax(600),
67 fRangeSumMin(50),
68 fRangeSumMax(100),
69 fCanvasXSize(100),
70 fCanvasYSize(100),
71 fCanvasXSpace(10),
72 fCanvasYSpace(10),
73 fCanvasXOffset(130),
74 fCanvasMainSize(200),
75 fMainXSize(100),
76 fMainYSize(600),
77 fBorderXSize(10),
78 fBorderYSize(10),
79 fButtonXSize(100),
80 fButtonYSize(20),
81 fButtonFirstX1(10),
82 fButtonFirstX2(50),
83 fButtonFirstY(300),
84 fWrite10Bit(0),
85 fComponents(new Float_t[10]),
86 fSamplingFreq(1000000),
87 fPedestals(1),
88 fNumOfChannels(16000),
89 fTimeBins(1024),
90 fMaxHwAddr(24000),
91 fFitPulse(1),
fb3305d1 92 fProcOneSector(0)
48265b32 93{
48265b32 94 // Constructor
ca7b8371 95 for(Int_t i =0; i<36; i++) { fSectorArr[i] = 0;}
96 for(Int_t i =0; i<10;i++) { fComponents[i] =0.0;}
48265b32 97 SetMainSize(130,720,10,26 );
48265b32 98
99}
100
101
ca7b8371 102//_______________________________________________________________________________________________________________
103AliTPCMonitorConfig::AliTPCMonitorConfig(const AliTPCMonitorConfig &config) :
104 TNamed(config.GetName(),config.GetTitle()),
105 fFormat(config.fFormat),
106 fSector(config.fSector),
107 fSectorLast(config.fSectorLast),
108 fSectorLastDisplayed(config.fSectorLastDisplayed),
109 fSectorArr(new Int_t[36]),
c60053f6 110 fFileLast(config.fFileLast),
ca7b8371 111 fFileLastSet(config.fFileLastSet),
c60053f6 112 fFileCurrent(config.fFileCurrent),
ca7b8371 113 fEventNext(config.fEventNext),
114 fEventNextID(config.fEventNextID),
115 fEventProcessed(config.fEventProcessed),
116 fRangeMaxAdcMin(config.fRangeMaxAdcMin),
117 fRangeMaxAdcMax(config.fRangeMaxAdcMax),
118 fRangeBaseMin(config.fRangeBaseMin),
119 fRangeBaseMax(config.fRangeBaseMax),
120 fRangeSumMin(config.fRangeSumMin),
121 fRangeSumMax(config.fRangeSumMax),
122 fCanvasXSize(config.fCanvasXSize),
123 fCanvasYSize(config.fCanvasYSize),
124 fCanvasXSpace(config.fCanvasXSpace),
125 fCanvasYSpace(config.fCanvasYSpace),
126 fCanvasXOffset(config.fCanvasXOffset),
127 fCanvasMainSize(config.fCanvasMainSize),
128 fMainXSize(config.fMainXSize),
129 fMainYSize(config.fMainYSize),
130 fBorderXSize(config.fBorderXSize),
131 fBorderYSize(config.fBorderYSize),
132 fButtonXSize(config.fBorderXSize),
133 fButtonYSize(config.fButtonYSize),
134 fButtonFirstX1(config.fButtonFirstX1),
135 fButtonFirstX2(config.fButtonFirstX2),
136 fButtonFirstY(config.fButtonFirstY),
137 fWrite10Bit(config.fWrite10Bit),
138 fComponents(new Float_t[10]),
139 fSamplingFreq(config.fSamplingFreq),
140 fPedestals(config.fPedestals),
141 fNumOfChannels(config.fNumOfChannels),
142 fTimeBins(config.fTimeBins),
143 fMaxHwAddr(config.fMaxHwAddr),
144 fFitPulse(config.fFitPulse),
145 fProcOneSector(config.fProcOneSector)
146{
147 // copy constructor
ca7b8371 148
149 for(Int_t i =0; i<36; i++) { fSectorArr[i] = 0;}
150 for(Int_t i =0; i<10;i++) { fComponents[i] =0.0;}
151
152
153}
154//_______________________________________________________________________________________________________________
155AliTPCMonitorConfig &AliTPCMonitorConfig::operator =(const AliTPCMonitorConfig& config)
156{
157 // assignement operator
158 if(this!=&config){
159 ((TNamed *)this)->operator=(config);
160 fFormat=config.fFormat;
161 fSector=config.fSector;
162 fSectorLast=config.fSectorLast;
163 fSectorLastDisplayed=config.fSectorLastDisplayed;
164 fFileLastSet=config.fFileLastSet;
165 fEventNext=config.fEventNext;
166 fEventNextID=config.fEventNextID;
167 fEventProcessed=config.fEventProcessed;
168 fRangeMaxAdcMin=config.fRangeMaxAdcMin;
169 fRangeMaxAdcMax=config.fRangeMaxAdcMax;
170 fRangeBaseMin=config.fRangeBaseMin;
171 fRangeBaseMax=config.fRangeBaseMax;
172 fRangeSumMin=config.fRangeSumMin;
173 fRangeSumMax=config.fRangeSumMax;
174 fCanvasXSize=config.fCanvasXSize;
175 fCanvasYSize=config.fCanvasYSize;
176 fCanvasXSpace=config.fCanvasXSpace;
177 fCanvasYSpace=config.fCanvasYSpace;
178 fCanvasXOffset=config.fCanvasXOffset;
179 fCanvasMainSize=config.fCanvasMainSize;
180 fMainXSize=config.fMainXSize;
181 fMainYSize=config.fMainYSize;
182 fBorderXSize=config.fBorderXSize;
183 fButtonYSize=config.fButtonYSize;
184 fButtonFirstX1=config.fButtonFirstX1;
185 fButtonFirstX2=config.fButtonFirstX2;
186 fButtonFirstY=config.fButtonFirstY;
187 fWrite10Bit=config.fWrite10Bit;
188 fPedestals=config.fPedestals;
189 fNumOfChannels=config.fNumOfChannels;
190 fTimeBins=config.fTimeBins;
191 fMaxHwAddr=config.fMaxHwAddr;
192 fFitPulse=config.fFitPulse;
193 fProcOneSector=config.fProcOneSector;
194
c60053f6 195 fFileLast = config.fFileLast;
196 fFileCurrent = config.fFileCurrent;
ca7b8371 197
198 fSectorArr = new Int_t[36]; for(Int_t i =0; i<36; i++) { fSectorArr[i] = 0;}
199 fComponents = new Float_t[10]; for(Int_t i =0; i<10;i++) { fComponents[i] =0.0;}
200
201
202 }
203 return *this;
204}
205
206
48265b32 207//_______________________________________________________________________________________________________________
208AliTPCMonitorConfig::~AliTPCMonitorConfig()
209{
210 // Destructor
ca7b8371 211 delete[] fSectorArr;
212 delete[] fComponents;
48265b32 213}
214
215
216//_______________________________________________________________________________________________________________
217void AliTPCMonitorConfig::SetMainSize(Int_t mainx, Int_t mainy, Int_t borderx=10, Int_t bordery=26)
218{
219 // Set Size of Main window, buttons and canvases
220
221
222 // size of main frame ///////////////////////
223 fMainXSize = mainx;
224 fMainYSize = mainy;
225
226 // border size depending on window manager///
227 fBorderXSize = borderx;
228 fBorderYSize = bordery;
229
230 // y-pos of first sector button /////////////
231 fButtonFirstY = (int) (0.50*fMainYSize);
232
233 // canvas size for Minitor Canvases ///////////////////////
234 fCanvasMainSize = (Int_t)(fMainYSize/3);
235
236 fCanvasXSize = (int)fCanvasMainSize;
237 fCanvasYSize = (int)fCanvasMainSize;
238 fCanvasXSpace = (int)(-1*(fCanvasMainSize+ fBorderXSize ));
239 fCanvasYSpace = (int)( fCanvasMainSize+ fBorderYSize );
240 fCanvasXOffset = (int)(-1*(fMainXSize + fBorderXSize ));
241
242 // adjust main size in y ////////////////////
243 fMainYSize = fMainYSize+fBorderYSize;
244
245 // y-size of the main window also defines ///
246 fButtonXSize = (Int_t)(fMainXSize/2-10);
247 fButtonYSize = (Int_t)fMainYSize/47;
248 fButtonFirstX1 = 5;
249 fButtonFirstX2 = fMainXSize/2+5;
250
251}
252
253//_______________________________________________________________________________________________________________
ca7b8371 254void AliTPCMonitorConfig::SetBaseConfig(Float_t* confarr)
48265b32 255{
ca7b8371 256 // Set base configuration stored in array confarr
48265b32 257
ca7b8371 258 fRangeBaseMin = (int)confarr[0];
259 fRangeBaseMax = (int)confarr[1];
48265b32 260
ca7b8371 261 fRangeMaxAdcMin = (int)confarr[2];
262 fRangeMaxAdcMax = (int)confarr[3];
48265b32 263
ca7b8371 264 fRangeSumMin = (int)confarr[4];
265 fRangeSumMax = (int)confarr[5];
48265b32 266
267 cout << " Set Ranges to : " << endl;
268 cout << " range base :: " << fRangeBaseMin << "\t : " << fRangeBaseMax << endl;
269 cout << " range adc max :: " << fRangeMaxAdcMin << "\t : " << fRangeMaxAdcMax << endl;
270 cout << " range sum :: " << fRangeSumMin << "\t : " << fRangeSumMax << endl;
271
272}
273
274//_______________________________________________________________________________________________________________
c60053f6 275void AliTPCMonitorConfig::ReadConfig(const Char_t* nameconf)
48265b32 276{
277 // Read base configuration from file
278 // Update main window size
279
77f88633 280 // string line;
48265b32 281 ifstream datin;
282 datin.open(nameconf);
283
284 if(!datin) { AliWarning("Could not read configfile");}
285
286 cout << "//// Read Configuration ///////// " << endl;
287 while(!datin.eof())
288 {
289 string line;
290 getline(datin,line);
291 if(line.find("max adc")!=string::npos)
292 {
293 datin >> fRangeMaxAdcMin ;
294 datin >> fRangeMaxAdcMax ;
295 cout << " range max :: " << fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
296 }
297
298 if(line.find("baseline")!=string::npos)
299 {
300 datin >> fRangeBaseMin ;
301 datin >> fRangeBaseMax ;
302 cout << " range base :: " << fRangeBaseMin << " : " << fRangeBaseMax << endl;
303 }
304 if(line.find("adc sum")!=string::npos)
305 {
306 datin >> fRangeSumMin ;
307 datin >> fRangeSumMax ;
308 cout << " range sum :: " << fRangeSumMin << " : " << fRangeSumMax << endl;
309 }
310 if(line.find("frequency")!=string::npos)
311 {
312 datin >> fSamplingFreq ;
313 cout << " sampling frequency :: " << fSamplingFreq << endl;
314 }
315 if(line.find("timebins")!=string::npos)
316 {
317 datin >> fTimeBins ;
318 cout << " timebins :: " << fTimeBins << endl;
319 }
320 if(line.find("pedestal")!=string::npos)
321 {
322 datin >> fPedestals ;
323 cout << " pedestal scheme :: " << fPedestals << endl;
324 }
325 if(line.find("main window size")!=string::npos)
326 {
327 datin >> fMainXSize ;
328 datin >> fMainYSize ;
329 cout << " main window size :: " << fMainXSize << " , " << fMainYSize << endl;
330 }
331 if(line.find("border size")!=string::npos)
332 {
333 datin >> fBorderXSize ;
334 datin >> fBorderYSize ;
335 cout << " border size :: " << fBorderXSize << " , " << fBorderYSize << endl;
336 }
337 }
338 cout << "//// Read Configuration done //// " << endl;
339 SetMainSize(fMainXSize,fMainYSize,fBorderXSize,fBorderYSize) ;
340}
341
342//_______________________________________________________________________________________________________________
343void AliTPCMonitorConfig::PrintConfig()
344{
345 // Print base configuration
346
347 cout << " /////// Configuration /////////////////////////////// " << endl;
348 cout << " Timebins :: " << fTimeBins << endl;
349 cout << " Range to det ADC max :: " << fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
350 cout << " Range to det Baseline :: " << fRangeBaseMin << " : " << fRangeBaseMax << endl;
351 cout << " Range to det ADC sum :: " << fRangeSumMin << " : " << fRangeSumMax << endl;
352 cout << " Pedestal setting :: " << fPedestals << endl;
353 cout << " Sampling Frequency :: " << fSamplingFreq << endl;
354 cout << " Sector (Last) :: " << fSector <<" ("<< fSectorLast <<")" << endl;
355 cout << " Data Format :: " << fFormat << endl;
356 cout << " File current :: " << fFileCurrent << endl;
357
c60053f6 358 if(fFileLastSet) { cout << " File last :: " << fFileLast.Data() << endl; }
48265b32 359 return;
360
361}
362
363//______________________________________________________________________________________________________________
c60053f6 364const Char_t* AliTPCMonitorConfig::GetLastProcFile()
48265b32 365{
366 // Return name of last processed file
367 // Get from file if written
368 if(!fFileLastSet)
369 {
c60053f6 370 ifstream datin("AliTPCMonitorLastFile.txt");
ac940b58 371 if(!datin.is_open()) {
372 AliWarning("Could not read file containing name of last processed file: Check permissions and path");
c60053f6 373 fFileLast="";
374 fFileLastSet=0;
375 return fFileLast.Data();
ac940b58 376 }
48265b32 377 datin >> fFileLast;
378 datin.close();
379 fFileLastSet=1;
380 }
381 return fFileLast;
382}
383
384//_______________________________________________________________________________________________________________
c60053f6 385void AliTPCMonitorConfig::SetLastProcFile(const Char_t* file)
48265b32 386{
387 // Set name of last processed file
388 // Write name to a file
389
c60053f6 390 fFileLast=file;
391 ofstream datout("AliTPCMonitorLastFile.txt");
48265b32 392 if(!datout) { AliWarning("Could not write file containing name of last processed file: Check permissions and path");}
393 datout << fFileLast << endl;
394 datout.close();
395 fFileLastSet =1;
396}