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.2 2007/10/12 13:36:27 cvetan
19 Coding convention fixes from Stefan
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.
26 //////////////////////////////////////////////////////////////////////////
28 //// AliTPCMonitorConfig class
30 //// Configuration handler class for AliTPCMonitor
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.
37 //// Author: Stefan Kniege, IKF, Frankfurt
40 /////////////////////////////////////////////////////////////////////////
43 #include "AliTPCMonitorConfig.h"
45 #include <Riostream.h>
47 ClassImp(AliTPCMonitorConfig)
49 // _______________________________________________________________________________________________________________
50 AliTPCMonitorConfig::AliTPCMonitorConfig(const Char_t* name, const Char_t* title) :
55 fSectorLastDisplayed(-1),
56 fSectorArr(new Int_t[36]),
57 fFileLast(new Char_t[256]),
59 fFileCurrent(new Char_t[256]),
85 fComponents(new Float_t[10]),
86 fSamplingFreq(1000000),
88 fNumOfChannels(16000),
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 );
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)
148 strcpy(fFileLast,config.fFileLast);
149 strcpy(fFileCurrent,config.fFileCurrent);
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;}
156 //_______________________________________________________________________________________________________________
157 AliTPCMonitorConfig &AliTPCMonitorConfig::operator =(const AliTPCMonitorConfig& config)
159 // assignement operator
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;
197 fFileLast = new Char_t[strlen(config.fFileLast)+1];
198 strcpy(fFileLast,config.fFileLast);
201 fFileCurrent = new Char_t[strlen(config.fFileCurrent)+1];
202 strcpy(fFileCurrent,config.fFileCurrent);
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;}
213 //_______________________________________________________________________________________________________________
214 AliTPCMonitorConfig::~AliTPCMonitorConfig()
218 delete[] fFileCurrent;
220 delete[] fComponents;
224 //_______________________________________________________________________________________________________________
225 void AliTPCMonitorConfig::SetMainSize(Int_t mainx, Int_t mainy, Int_t borderx=10, Int_t bordery=26)
227 // Set Size of Main window, buttons and canvases
230 // size of main frame ///////////////////////
234 // border size depending on window manager///
235 fBorderXSize = borderx;
236 fBorderYSize = bordery;
238 // y-pos of first sector button /////////////
239 fButtonFirstY = (int) (0.50*fMainYSize);
241 // canvas size for Minitor Canvases ///////////////////////
242 fCanvasMainSize = (Int_t)(fMainYSize/3);
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 ));
250 // adjust main size in y ////////////////////
251 fMainYSize = fMainYSize+fBorderYSize;
253 // y-size of the main window also defines ///
254 fButtonXSize = (Int_t)(fMainXSize/2-10);
255 fButtonYSize = (Int_t)fMainYSize/47;
257 fButtonFirstX2 = fMainXSize/2+5;
261 //_______________________________________________________________________________________________________________
262 void AliTPCMonitorConfig::SetBaseConfig(Float_t* confarr)
264 // Set base configuration stored in array confarr
266 fRangeBaseMin = (int)confarr[0];
267 fRangeBaseMax = (int)confarr[1];
269 fRangeMaxAdcMin = (int)confarr[2];
270 fRangeMaxAdcMax = (int)confarr[3];
272 fRangeSumMin = (int)confarr[4];
273 fRangeSumMax = (int)confarr[5];
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;
282 //_______________________________________________________________________________________________________________
283 void AliTPCMonitorConfig::ReadConfig(Char_t* nameconf)
285 // Read base configuration from file
286 // Update main window size
290 datin.open(nameconf);
292 if(!datin) { AliWarning("Could not read configfile");}
294 cout << "//// Read Configuration ///////// " << endl;
299 if(line.find("max adc")!=string::npos)
301 datin >> fRangeMaxAdcMin ;
302 datin >> fRangeMaxAdcMax ;
303 cout << " range max :: " << fRangeMaxAdcMin << " : " << fRangeMaxAdcMax << endl;
306 if(line.find("baseline")!=string::npos)
308 datin >> fRangeBaseMin ;
309 datin >> fRangeBaseMax ;
310 cout << " range base :: " << fRangeBaseMin << " : " << fRangeBaseMax << endl;
312 if(line.find("adc sum")!=string::npos)
314 datin >> fRangeSumMin ;
315 datin >> fRangeSumMax ;
316 cout << " range sum :: " << fRangeSumMin << " : " << fRangeSumMax << endl;
318 if(line.find("frequency")!=string::npos)
320 datin >> fSamplingFreq ;
321 cout << " sampling frequency :: " << fSamplingFreq << endl;
323 if(line.find("timebins")!=string::npos)
326 cout << " timebins :: " << fTimeBins << endl;
328 if(line.find("pedestal")!=string::npos)
330 datin >> fPedestals ;
331 cout << " pedestal scheme :: " << fPedestals << endl;
333 if(line.find("main window size")!=string::npos)
335 datin >> fMainXSize ;
336 datin >> fMainYSize ;
337 cout << " main window size :: " << fMainXSize << " , " << fMainYSize << endl;
339 if(line.find("border size")!=string::npos)
341 datin >> fBorderXSize ;
342 datin >> fBorderYSize ;
343 cout << " border size :: " << fBorderXSize << " , " << fBorderYSize << endl;
346 cout << "//// Read Configuration done //// " << endl;
347 SetMainSize(fMainXSize,fMainYSize,fBorderXSize,fBorderYSize) ;
350 //_______________________________________________________________________________________________________________
351 void AliTPCMonitorConfig::PrintConfig()
353 // Print base configuration
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;
366 if(fFileLastSet) { cout << " File last :: " << fFileLast << endl; }
371 //______________________________________________________________________________________________________________
372 Char_t* AliTPCMonitorConfig::GetLastProcFile()
374 // Return name of last processed file
375 // Get from file if written
379 sprintf(fnlast,"AliTPCMonitorLastFile.txt");
380 ifstream datin(fnlast);
381 if(!datin.is_open()) {
382 AliWarning("Could not read file containing name of last processed file: Check permissions and path");
383 sprintf(fFileLast,"%s","");
394 //_______________________________________________________________________________________________________________
395 void AliTPCMonitorConfig::SetLastProcFile(Char_t* file)
397 // Set name of last processed file
398 // Write name to a file
400 sprintf(fFileLast,file);
402 sprintf(fnlast,"AliTPCMonitorLastFile.txt");
403 ofstream datout(fnlast);
404 if(!datout) { AliWarning("Could not write file containing name of last processed file: Check permissions and path");}
405 datout << fFileLast << endl;