]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCMonitorConfig.cxx
New TPC monitoring package from Stefan Kniege. The monitoring package can be started...
[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 */ 
19
20 #include "AliTPCMonitorConfig.h"
21 ClassImp(AliTPCMonitorConfig)
22
23 //_______________________________________________________________________________________________________________
24 AliTPCMonitorConfig::AliTPCMonitorConfig(Char_t* name, Char_t* title) : TNamed(name,title)
25 {
26
27   // Constructor 
28   // Set default values for Size of Window 
29   
30   fRangeMaxAdcMin       = 50  ;
31   fRangeMaxAdcMax       = 100 ;
32   
33   fRangeBaseMin         = 300 ;
34   fRangeBaseMax         = 600 ;
35   
36   fRangeSumMin          = 50  ; 
37   fRangeSumMax          = 100 ;
38   
39   
40   fFormat               = -1;  
41   fSector               = 0;
42   fEventNext            = 1;
43   fEventNextID          = 1;
44
45   SetMainSize(130,720,10,26 );
46
47   fFileLast             = new Char_t[256]       ;
48   fFileLastSet          = 0;
49   fFileCurrent          = new Char_t[256];
50   
51   fSectorLast           =-1;
52   fSectorLastDisplayed  =-1;
53   
54   fWrite10Bit           = 0;
55   
56   fSectorArr            = new Int_t[36];    for(Int_t i =0; i<36; i++) { fSectorArr[i]  =  0;}
57   fComponents           = new Float_t[10];  for(Int_t i =0; i<10;i++)  { fComponents[i] =0.0;}
58   
59   fSamplingFreq         = 1000000;
60   fTimeBins             = 1024;
61   fPedestals            = 1;
62   fNumOfChannels        = 16000;
63   fMaxHwAddr            = 24000;
64
65   fFitPulse             = 1;
66   fEventProcessed       = 0;
67   
68
69  
70
71 //_______________________________________________________________________________________________________________
72 AliTPCMonitorConfig::~AliTPCMonitorConfig() 
73 {
74   // Destructor
75
76
77
78 //_______________________________________________________________________________________________________________
79 void AliTPCMonitorConfig::SetMainSize(Int_t mainx, Int_t mainy, Int_t borderx=10, Int_t bordery=26) 
80 {
81   // Set Size of Main window, buttons and canvases
82
83   
84   // size of main frame ///////////////////////
85   fMainXSize            = mainx;
86   fMainYSize            = mainy;
87   
88   // border size depending on window manager///
89   fBorderXSize          = borderx;
90   fBorderYSize          = bordery;
91   
92   // y-pos of first sector button /////////////
93   fButtonFirstY         = (int) (0.50*fMainYSize);
94  
95   // canvas size for Minitor Canvases ///////////////////////
96   fCanvasMainSize       = (Int_t)(fMainYSize/3);
97   
98   fCanvasXSize          = (int)fCanvasMainSize;
99   fCanvasYSize          = (int)fCanvasMainSize;
100   fCanvasXSpace         = (int)(-1*(fCanvasMainSize+ fBorderXSize ));
101   fCanvasYSpace         = (int)(    fCanvasMainSize+ fBorderYSize );
102   fCanvasXOffset        = (int)(-1*(fMainXSize     + fBorderXSize ));
103   
104   // adjust main size in y ////////////////////
105   fMainYSize            = fMainYSize+fBorderYSize;
106   
107   // y-size of the main window also defines ///
108   fButtonXSize          = (Int_t)(fMainXSize/2-10);
109   fButtonYSize          = (Int_t)fMainYSize/47;
110   fButtonFirstX1        =         5;
111   fButtonFirstX2        = fMainXSize/2+5;
112
113 }
114  
115 //_______________________________________________________________________________________________________________
116 void AliTPCMonitorConfig::SetBaseConfig(Float_t* conf_arr)
117 {
118   // Set base configuration stored in array conf_arr 
119   
120   fRangeBaseMin   = (int)conf_arr[0];
121   fRangeBaseMax   = (int)conf_arr[1];
122   
123   fRangeMaxAdcMin = (int)conf_arr[2];
124   fRangeMaxAdcMax = (int)conf_arr[3];
125   
126   fRangeSumMin    = (int)conf_arr[4];
127   fRangeSumMax    = (int)conf_arr[5];
128   
129   cout << " Set Ranges to : " << endl;
130   cout << " range  base       :: " <<  fRangeBaseMin   << "\t :  " << fRangeBaseMax   << endl;
131   cout << " range  adc max    :: " <<  fRangeMaxAdcMin << "\t :  " << fRangeMaxAdcMax << endl;
132   cout << " range  sum        :: " <<  fRangeSumMin    << "\t :  " << fRangeSumMax    << endl;
133   
134 }
135
136 //_______________________________________________________________________________________________________________
137 void AliTPCMonitorConfig::ReadConfig(Char_t* nameconf) 
138 {
139   // Read base configuration from file
140   // Update main window size
141
142   string line;
143   ifstream datin;
144   datin.open(nameconf);
145   
146   if(!datin) {  AliWarning("Could not read configfile");}
147   
148   cout << "////  Read Configuration ///////// " << endl;
149   while(!datin.eof())
150     {
151       string line;
152       getline(datin,line);
153       if(line.find("max adc")!=string::npos)
154         { 
155           datin >> fRangeMaxAdcMin     ; 
156           datin >> fRangeMaxAdcMax     ;
157           cout << " range max          :: " << fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
158         }
159       
160       if(line.find("baseline")!=string::npos)
161         { 
162           datin >> fRangeBaseMin  ;
163           datin >> fRangeBaseMax  ;
164           cout << " range  base        :: " <<  fRangeBaseMin << " : " <<  fRangeBaseMax  << endl;
165         }
166       if(line.find("adc sum")!=string::npos)
167         { 
168           datin >> fRangeSumMin  ;
169           datin >> fRangeSumMax  ;
170           cout << " range sum          :: " <<  fRangeSumMin << " : " << fRangeSumMax  << endl;
171         }
172       if(line.find("frequency")!=string::npos)
173         { 
174           datin >> fSamplingFreq  ;
175           cout << " sampling frequency :: " <<  fSamplingFreq << endl;
176         }
177       if(line.find("timebins")!=string::npos)
178         { 
179           datin >> fTimeBins  ;
180           cout << " timebins           :: " <<  fTimeBins << endl;
181         }
182       if(line.find("pedestal")!=string::npos)
183         { 
184           datin >> fPedestals  ;
185           cout << " pedestal scheme    :: " <<  fPedestals << endl;
186         }
187       if(line.find("main window size")!=string::npos)
188         { 
189           datin >> fMainXSize  ;
190           datin >> fMainYSize  ;
191           cout << " main window size   :: " <<  fMainXSize  << "  , " << fMainYSize <<  endl;
192         }
193       if(line.find("border size")!=string::npos)
194         { 
195           datin >> fBorderXSize  ; 
196           datin >> fBorderYSize  ;
197           cout << " border size        :: " <<  fBorderXSize  << "  , " << fBorderYSize <<  endl;
198         }
199     }
200   cout << "////  Read Configuration done //// " << endl;
201   SetMainSize(fMainXSize,fMainYSize,fBorderXSize,fBorderYSize) ;
202 }
203
204 //_______________________________________________________________________________________________________________
205 void AliTPCMonitorConfig::PrintConfig()
206 {
207   // Print base configuration 
208   
209   cout << " /////// Configuration /////////////////////////////// " << endl;
210   cout << " Timebins                :: " <<  fTimeBins                                   << endl;
211   cout << " Range to det ADC max    :: " <<  fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
212   cout << " Range to det Baseline   :: " <<  fRangeBaseMin   << " : " << fRangeBaseMax   << endl;
213   cout << " Range to det ADC sum    :: " <<  fRangeSumMin    << " : " << fRangeSumMax    << endl;
214   cout << " Pedestal setting        :: " <<  fPedestals                                  << endl;
215   cout << " Sampling Frequency      :: " <<  fSamplingFreq                               << endl;
216   cout << " Sector (Last)           :: " <<  fSector <<"  ("<< fSectorLast   <<")"       << endl; 
217   cout << " Data Format             :: " <<  fFormat                                     << endl;
218   cout << " File current            :: " <<  fFileCurrent                                << endl;
219   
220   if(fFileLastSet)  {      cout << " File last           :: " <<  fFileLast << endl;    }
221   return;                                                                                 
222   
223 }
224
225 //______________________________________________________________________________________________________________
226 Char_t* AliTPCMonitorConfig::GetLastProcFile()
227 {
228   // Return name of last processed file
229   // Get from file if written  
230   if(!fFileLastSet)
231     {
232       Char_t fnlast[256];
233       sprintf(fnlast,"AliTPCMonitorLastFile.txt");
234       ifstream datin(fnlast);
235       if(!datin) {  AliWarning("Could not read file containing  name of last processed file: Check permissions and path");}
236       datin >> fFileLast;
237       datin.close(); 
238       fFileLastSet=1;
239     }
240   return fFileLast;
241 }
242
243 //_______________________________________________________________________________________________________________
244 void AliTPCMonitorConfig::SetLastProcFile(Char_t* file)
245 {
246   // Set name of last processed file 
247   // Write name to a file 
248   
249   sprintf(fFileLast,file);
250   Char_t fnlast[256];
251   sprintf(fnlast,"AliTPCMonitorLastFile.txt");
252   ofstream datout(fnlast);
253   if(!datout) {  AliWarning("Could not write file containing name of last processed file: Check permissions and path");}
254   datout << fFileLast << endl;
255   datout.close();
256   fFileLastSet =1;
257 }