]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCMonitorConfig.cxx
In vmctest:
[u/mrichter/AliRoot.git] / TPC / AliTPCMonitorConfig.cxx
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$
18 Revision 1.2  2007/10/12 13:36:27  cvetan
19 Coding convention fixes from Stefan
20
21 Revision 1.1  2007/09/17 10:23:31  cvetan
22 New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
23
24 */ 
25
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 ////
40 /////////////////////////////////////////////////////////////////////////
41
42
43 #include "AliTPCMonitorConfig.h"
44 #include "AliLog.h" 
45 #include <Riostream.h>
46
47 ClassImp(AliTPCMonitorConfig)
48
49 // _______________________________________________________________________________________________________________
50 AliTPCMonitorConfig::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]),
57   fFileLast(),
58   fFileLastSet(0),
59   fFileCurrent(),
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),
92   fProcOneSector(0)
93 {
94   // Constructor 
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;}
97   SetMainSize(130,720,10,26 );
98   
99
100  
101
102 //_______________________________________________________________________________________________________________
103 AliTPCMonitorConfig::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]),
110   fFileLast(config.fFileLast),
111   fFileLastSet(config.fFileLastSet),
112   fFileCurrent(config.fFileCurrent),
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
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 //_______________________________________________________________________________________________________________
155 AliTPCMonitorConfig &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
195     fFileLast             = config.fFileLast;
196     fFileCurrent          = config.fFileCurrent;
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
207 //_______________________________________________________________________________________________________________
208 AliTPCMonitorConfig::~AliTPCMonitorConfig() 
209 {
210   // Destructor
211   delete[] fSectorArr;
212   delete[] fComponents;
213
214
215
216 //_______________________________________________________________________________________________________________
217 void 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 //_______________________________________________________________________________________________________________
254 void AliTPCMonitorConfig::SetBaseConfig(Float_t* confarr)
255 {
256   // Set base configuration stored in array confarr 
257   
258   fRangeBaseMin   = (int)confarr[0];
259   fRangeBaseMax   = (int)confarr[1];
260   
261   fRangeMaxAdcMin = (int)confarr[2];
262   fRangeMaxAdcMax = (int)confarr[3];
263   
264   fRangeSumMin    = (int)confarr[4];
265   fRangeSumMax    = (int)confarr[5];
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 //_______________________________________________________________________________________________________________
275 void AliTPCMonitorConfig::ReadConfig(const Char_t* nameconf) 
276 {
277   // Read base configuration from file
278   // Update main window size
279
280   //  string line;
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 //_______________________________________________________________________________________________________________
343 void 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   
358   if(fFileLastSet)  {      cout << " File last           :: " <<  fFileLast.Data() << endl;    }
359   return;                                                                                 
360   
361 }
362
363 //______________________________________________________________________________________________________________
364 const Char_t* AliTPCMonitorConfig::GetLastProcFile()
365 {
366   // Return name of last processed file
367   // Get from file if written  
368   if(!fFileLastSet)
369     {
370       ifstream datin("AliTPCMonitorLastFile.txt");
371       if(!datin.is_open()) {
372         AliWarning("Could not read file containing  name of last processed file: Check permissions and path");
373         fFileLast="";
374         fFileLastSet=0;
375         return fFileLast.Data();
376       }
377       datin >> fFileLast;
378       datin.close(); 
379       fFileLastSet=1;
380     }
381   return fFileLast;
382 }
383
384 //_______________________________________________________________________________________________________________
385 void AliTPCMonitorConfig::SetLastProcFile(const Char_t* file)
386 {
387   // Set name of last processed file 
388   // Write name to a file 
389   
390   fFileLast=file;
391   ofstream datout("AliTPCMonitorLastFile.txt");
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 }