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