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