1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.1 2007/09/17 10:23:31 cvetan
19 New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
23 ////////////////////////////////////////////////////////////////////////
25 // AliTPCMonitorConfig class
27 // Configuration handler class for AliTPCMonitor
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.
34 // Author: Stefan Kniege, IKF, Frankfurt
37 /////////////////////////////////////////////////////////////////////////
40 #include "AliTPCMonitorConfig.h"
42 #include <Riostream.h>
44 ClassImp(AliTPCMonitorConfig)
46 // _______________________________________________________________________________________________________________
47 AliTPCMonitorConfig::AliTPCMonitorConfig(const Char_t* name, const Char_t* title) :
52 fSectorLastDisplayed(-1),
53 fSectorArr(new Int_t[36]),
54 fFileLast(new Char_t[256]),
56 fFileCurrent(new Char_t[256]),
82 fComponents(new Float_t[10]),
83 fSamplingFreq(1000000),
85 fNumOfChannels(16000),
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;}
94 SetMainSize(130,720,10,26 );
99 //_______________________________________________________________________________________________________________
100 AliTPCMonitorConfig::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)
145 strcpy(fFileLast,config.fFileLast);
146 strcpy(fFileCurrent,config.fFileCurrent);
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;}
153 //_______________________________________________________________________________________________________________
154 AliTPCMonitorConfig &AliTPCMonitorConfig::operator =(const AliTPCMonitorConfig& config)
156 // assignement operator
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;
194 fFileLast = new Char_t[strlen(config.fFileLast)+1];
195 strcpy(fFileLast,config.fFileLast);
198 fFileCurrent = new Char_t[strlen(config.fFileCurrent)+1];
199 strcpy(fFileCurrent,config.fFileCurrent);
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;}
210 //_______________________________________________________________________________________________________________
211 AliTPCMonitorConfig::~AliTPCMonitorConfig()
215 delete[] fFileCurrent;
217 delete[] fComponents;
221 //_______________________________________________________________________________________________________________
222 void AliTPCMonitorConfig::SetMainSize(Int_t mainx, Int_t mainy, Int_t borderx=10, Int_t bordery=26)
224 // Set Size of Main window, buttons and canvases
227 // size of main frame ///////////////////////
231 // border size depending on window manager///
232 fBorderXSize = borderx;
233 fBorderYSize = bordery;
235 // y-pos of first sector button /////////////
236 fButtonFirstY = (int) (0.50*fMainYSize);
238 // canvas size for Minitor Canvases ///////////////////////
239 fCanvasMainSize = (Int_t)(fMainYSize/3);
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 ));
247 // adjust main size in y ////////////////////
248 fMainYSize = fMainYSize+fBorderYSize;
250 // y-size of the main window also defines ///
251 fButtonXSize = (Int_t)(fMainXSize/2-10);
252 fButtonYSize = (Int_t)fMainYSize/47;
254 fButtonFirstX2 = fMainXSize/2+5;
258 //_______________________________________________________________________________________________________________
259 void AliTPCMonitorConfig::SetBaseConfig(Float_t* confarr)
261 // Set base configuration stored in array confarr
263 fRangeBaseMin = (int)confarr[0];
264 fRangeBaseMax = (int)confarr[1];
266 fRangeMaxAdcMin = (int)confarr[2];
267 fRangeMaxAdcMax = (int)confarr[3];
269 fRangeSumMin = (int)confarr[4];
270 fRangeSumMax = (int)confarr[5];
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;
279 //_______________________________________________________________________________________________________________
280 void AliTPCMonitorConfig::ReadConfig(Char_t* nameconf)
282 // Read base configuration from file
283 // Update main window size
287 datin.open(nameconf);
289 if(!datin) { AliWarning("Could not read configfile");}
291 cout << "//// Read Configuration ///////// " << endl;
296 if(line.find("max adc")!=string::npos)
298 datin >> fRangeMaxAdcMin ;
299 datin >> fRangeMaxAdcMax ;
300 cout << " range max :: " << fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
303 if(line.find("baseline")!=string::npos)
305 datin >> fRangeBaseMin ;
306 datin >> fRangeBaseMax ;
307 cout << " range base :: " << fRangeBaseMin << " : " << fRangeBaseMax << endl;
309 if(line.find("adc sum")!=string::npos)
311 datin >> fRangeSumMin ;
312 datin >> fRangeSumMax ;
313 cout << " range sum :: " << fRangeSumMin << " : " << fRangeSumMax << endl;
315 if(line.find("frequency")!=string::npos)
317 datin >> fSamplingFreq ;
318 cout << " sampling frequency :: " << fSamplingFreq << endl;
320 if(line.find("timebins")!=string::npos)
323 cout << " timebins :: " << fTimeBins << endl;
325 if(line.find("pedestal")!=string::npos)
327 datin >> fPedestals ;
328 cout << " pedestal scheme :: " << fPedestals << endl;
330 if(line.find("main window size")!=string::npos)
332 datin >> fMainXSize ;
333 datin >> fMainYSize ;
334 cout << " main window size :: " << fMainXSize << " , " << fMainYSize << endl;
336 if(line.find("border size")!=string::npos)
338 datin >> fBorderXSize ;
339 datin >> fBorderYSize ;
340 cout << " border size :: " << fBorderXSize << " , " << fBorderYSize << endl;
343 cout << "//// Read Configuration done //// " << endl;
344 SetMainSize(fMainXSize,fMainYSize,fBorderXSize,fBorderYSize) ;
347 //_______________________________________________________________________________________________________________
348 void AliTPCMonitorConfig::PrintConfig()
350 // Print base configuration
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;
363 if(fFileLastSet) { cout << " File last :: " << fFileLast << endl; }
368 //______________________________________________________________________________________________________________
369 Char_t* AliTPCMonitorConfig::GetLastProcFile()
371 // Return name of last processed file
372 // Get from file if written
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");}
386 //_______________________________________________________________________________________________________________
387 void AliTPCMonitorConfig::SetLastProcFile(Char_t* file)
389 // Set name of last processed file
390 // Write name to a file
392 sprintf(fFileLast,file);
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;