]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCMonitorConfig.cxx
b1bf8926def522d551bb48da57846f4ba7dbfbbb
[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.fButtonXSize),
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) return *this;
159   
160   TNamed::operator=(config);
161   fFormat=config.fFormat;
162   fSector=config.fSector;
163   fSectorLast=config.fSectorLast;
164   fSectorLastDisplayed=config.fSectorLastDisplayed;
165   if (!fSectorArr) fSectorArr= new Int_t[36];
166   fFileLast= config.fFileLast;
167   fFileLastSet=config.fFileLastSet;
168   fFileCurrent=config.fFileCurrent;
169   fEventNext=config.fEventNext;
170   fEventNextID=config.fEventNextID;
171   fEventProcessed=config.fEventProcessed;
172   fRangeMaxAdcMin=config.fRangeMaxAdcMin;
173   fRangeMaxAdcMax=config.fRangeMaxAdcMax;
174   fRangeBaseMin=config.fRangeBaseMin;
175   fRangeBaseMax=config.fRangeBaseMax;
176   fRangeSumMin=config.fRangeSumMin;
177   fRangeSumMax=config.fRangeSumMax;
178   fCanvasXSize=config.fCanvasXSize;
179   fCanvasYSize=config.fCanvasYSize;
180   fCanvasXSpace=config.fCanvasXSpace;
181   fCanvasYSpace=config.fCanvasYSpace;
182   fCanvasXOffset=config.fCanvasXOffset;
183   fCanvasMainSize=config.fCanvasMainSize;
184   fMainXSize=config.fMainXSize;
185   fMainYSize=config.fMainYSize;
186   fBorderXSize=config.fBorderXSize;
187   fBorderYSize=config.fBorderYSize;
188   fButtonXSize=config.fButtonXSize;
189   fButtonYSize=config.fButtonYSize;
190   fButtonFirstX1=config.fButtonFirstX1;
191   fButtonFirstX2=config.fButtonFirstX2;
192   fButtonFirstY=config.fButtonFirstY;
193   fWrite10Bit=config.fWrite10Bit;
194   if (!fComponents) fComponents= new Float_t[10];
195   fSamplingFreq=config.fSamplingFreq;
196   fPedestals=config.fPedestals;
197   fNumOfChannels=config.fNumOfChannels;
198   fTimeBins=config.fTimeBins;
199   fMaxHwAddr=config.fMaxHwAddr;
200   fFitPulse=config.fFitPulse;
201   fProcOneSector=config.fProcOneSector;
202
203   for(Int_t i =0; i<36; i++) { fSectorArr[i]  = 0;}
204   for(Int_t i =0; i<10;i++)  { fComponents[i] = 0.;}
205     
206   return *this;
207 }
208
209
210 //_______________________________________________________________________________________________________________
211 AliTPCMonitorConfig::~AliTPCMonitorConfig() 
212 {
213   // Destructor
214   delete[] fSectorArr;
215   delete[] fComponents;
216
217
218
219 //_______________________________________________________________________________________________________________
220 void AliTPCMonitorConfig::SetMainSize(Int_t mainx, Int_t mainy, Int_t borderx=10, Int_t bordery=26) 
221 {
222   // Set Size of Main window, buttons and canvases
223
224   
225   // size of main frame ///////////////////////
226   fMainXSize            = mainx;
227   fMainYSize            = mainy;
228   
229   // border size depending on window manager///
230   fBorderXSize          = borderx;
231   fBorderYSize          = bordery;
232   
233   // y-pos of first sector button /////////////
234   fButtonFirstY         = (int) (0.50*fMainYSize);
235  
236   // canvas size for Minitor Canvases ///////////////////////
237   fCanvasMainSize       = (Int_t)(fMainYSize/3);
238   
239   fCanvasXSize          = (int)fCanvasMainSize;
240   fCanvasYSize          = (int)fCanvasMainSize;
241   fCanvasXSpace         = (int)(-1*(fCanvasMainSize+ fBorderXSize ));
242   fCanvasYSpace         = (int)(    fCanvasMainSize+ fBorderYSize );
243   fCanvasXOffset        = (int)(-1*(fMainXSize     + fBorderXSize ));
244   
245   // adjust main size in y ////////////////////
246   fMainYSize            = fMainYSize+fBorderYSize;
247   
248   // y-size of the main window also defines ///
249   fButtonXSize          = (Int_t)(fMainXSize/2-10);
250   fButtonYSize          = (Int_t)fMainYSize/47;
251   fButtonFirstX1        =         5;
252   fButtonFirstX2        = fMainXSize/2+5;
253
254 }
255  
256 //_______________________________________________________________________________________________________________
257 void AliTPCMonitorConfig::SetBaseConfig(Float_t* confarr)
258 {
259   // Set base configuration stored in array confarr 
260   
261   fRangeBaseMin   = (int)confarr[0];
262   fRangeBaseMax   = (int)confarr[1];
263   
264   fRangeMaxAdcMin = (int)confarr[2];
265   fRangeMaxAdcMax = (int)confarr[3];
266   
267   fRangeSumMin    = (int)confarr[4];
268   fRangeSumMax    = (int)confarr[5];
269   
270   cout << " Set Ranges to : " << endl;
271   cout << " range  base       :: " <<  fRangeBaseMin   << "\t :  " << fRangeBaseMax   << endl;
272   cout << " range  adc max    :: " <<  fRangeMaxAdcMin << "\t :  " << fRangeMaxAdcMax << endl;
273   cout << " range  sum        :: " <<  fRangeSumMin    << "\t :  " << fRangeSumMax    << endl;
274   
275 }
276
277 //_______________________________________________________________________________________________________________
278 void AliTPCMonitorConfig::ReadConfig(const Char_t* nameconf) 
279 {
280   // Read base configuration from file
281   // Update main window size
282
283   //  string line;
284   ifstream datin;
285   datin.open(nameconf);
286   
287   if(!datin) {  AliWarning("Could not read configfile");}
288   
289   cout << "////  Read Configuration ///////// " << endl;
290   while(!datin.eof())
291     {
292       string line;
293       getline(datin,line);
294       if(line.find("max adc")!=string::npos)
295         { 
296           datin >> fRangeMaxAdcMin     ; 
297           datin >> fRangeMaxAdcMax     ;
298           cout << " range max          :: " << fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
299         }
300       
301       if(line.find("baseline")!=string::npos)
302         { 
303           datin >> fRangeBaseMin  ;
304           datin >> fRangeBaseMax  ;
305           cout << " range  base        :: " <<  fRangeBaseMin << " : " <<  fRangeBaseMax  << endl;
306         }
307       if(line.find("adc sum")!=string::npos)
308         { 
309           datin >> fRangeSumMin  ;
310           datin >> fRangeSumMax  ;
311           cout << " range sum          :: " <<  fRangeSumMin << " : " << fRangeSumMax  << endl;
312         }
313       if(line.find("frequency")!=string::npos)
314         { 
315           datin >> fSamplingFreq  ;
316           cout << " sampling frequency :: " <<  fSamplingFreq << endl;
317         }
318       if(line.find("timebins")!=string::npos)
319         { 
320           datin >> fTimeBins  ;
321           cout << " timebins           :: " <<  fTimeBins << endl;
322         }
323       if(line.find("pedestal")!=string::npos)
324         { 
325           datin >> fPedestals  ;
326           cout << " pedestal scheme    :: " <<  fPedestals << endl;
327         }
328       if(line.find("main window size")!=string::npos)
329         { 
330           datin >> fMainXSize  ;
331           datin >> fMainYSize  ;
332           cout << " main window size   :: " <<  fMainXSize  << "  , " << fMainYSize <<  endl;
333         }
334       if(line.find("border size")!=string::npos)
335         { 
336           datin >> fBorderXSize  ; 
337           datin >> fBorderYSize  ;
338           cout << " border size        :: " <<  fBorderXSize  << "  , " << fBorderYSize <<  endl;
339         }
340     }
341   cout << "////  Read Configuration done //// " << endl;
342   SetMainSize(fMainXSize,fMainYSize,fBorderXSize,fBorderYSize) ;
343 }
344
345 //_______________________________________________________________________________________________________________
346 void AliTPCMonitorConfig::PrintConfig()
347 {
348   // Print base configuration 
349   
350   cout << " /////// Configuration /////////////////////////////// " << endl;
351   cout << " Timebins                :: " <<  fTimeBins                                   << endl;
352   cout << " Range to det ADC max    :: " <<  fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
353   cout << " Range to det Baseline   :: " <<  fRangeBaseMin   << " : " << fRangeBaseMax   << endl;
354   cout << " Range to det ADC sum    :: " <<  fRangeSumMin    << " : " << fRangeSumMax    << endl;
355   cout << " Pedestal setting        :: " <<  fPedestals                                  << endl;
356   cout << " Sampling Frequency      :: " <<  fSamplingFreq                               << endl;
357   cout << " Sector (Last)           :: " <<  fSector <<"  ("<< fSectorLast   <<")"       << endl; 
358   cout << " Data Format             :: " <<  fFormat                                     << endl;
359   cout << " File current            :: " <<  fFileCurrent                                << endl;
360   
361   if(fFileLastSet)  {      cout << " File last           :: " <<  fFileLast.Data() << endl;    }
362   return;                                                                                 
363   
364 }
365
366 //______________________________________________________________________________________________________________
367 const Char_t* AliTPCMonitorConfig::GetLastProcFile()
368 {
369   // Return name of last processed file
370   // Get from file if written  
371   if(!fFileLastSet)
372     {
373       ifstream datin("AliTPCMonitorLastFile.txt");
374       if(!datin.is_open()) {
375         AliWarning("Could not read file containing  name of last processed file: Check permissions and path");
376         fFileLast="";
377         fFileLastSet=0;
378         return fFileLast.Data();
379       }
380       datin >> fFileLast;
381       datin.close(); 
382       fFileLastSet=1;
383     }
384   return fFileLast;
385 }
386
387 //_______________________________________________________________________________________________________________
388 void AliTPCMonitorConfig::SetLastProcFile(const Char_t* file)
389 {
390   // Set name of last processed file 
391   // Write name to a file 
392   
393   fFileLast=file;
394   ofstream datout("AliTPCMonitorLastFile.txt");
395   if(!datout) {  AliWarning("Could not write file containing name of last processed file: Check permissions and path");}
396   datout << fFileLast << endl;
397   datout.close();
398   fFileLastSet =1;
399 }