]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/macros/TPCMonitor.C
Consistency of Filter and Tender restored (D. Caffarri)
[u/mrichter/AliRoot.git] / TPC / macros / TPCMonitor.C
CommitLineData
48265b32 1////////////////////////////////////////////////////////////////////////////////
2//
3// Macro to launch Monitoring program for TPC raw data
4//
5// Author: Stefan Kniege, IKF, Frankfurt
6//
7////////////////////////////////////////////////////////////////////////////////
8
c4607f01 9#include "iostream"
10
11#include "TGFrame.h"
12#include "TGButton.h"
13#include "TGTextEntry.h"
14#include "TGLabel.h"
15#include "TGFileDialog.h"
16#include "TGClient.h"
17#include "TGApplication.h"
18#include "TSystem.h"
19#include "TStyle.h"
20#include "TDirectory.h"
21#include "TFileMerger.h"
22
23#include "AliTPCMonitor.h"
24#include "AliTPCMonitorMappingHandler.h"
25//#include "AliTPCMonitorEditor.h"
26#include "AliTPCMonitorDialog.h"
27
28using namespace std;
29
48265b32 30
31static AliTPCMonitor* fMon = 0;
32static AliTPCMonitorMappingHandler* fMapHand = 0;
33
34static TGMainFrame* fFrameMain = 0;
35static TGCheckButton* fFrameChDisFit = 0;
36static TGCheckButton* fFrameCh10bit = 0;
37static TGCheckButton* fFrameCheckVerb = 0;
38static TGCheckButton* fFrameCheckProcOne = 0;
39static TGCheckButton* fFrameCheckPed = 0;
40static TGCheckButton* fFrameCalcBSL = 0;
41
42static Int_t fVerb = 0;
43static TGTextEntry* fTextEvId = 0;
44
45void WriteChannel();
46void WriteHistos();
47void SetConfig();
48void DisableFit();
c4607f01 49//void ProcessSector(char* fdata,char* ffil, Int_t side, Int_t sector);
50void ProcessSector(Int_t sid, Int_t sector);
51//Int_t DrawFit();
52Int_t DrawRMSMap();
48265b32 53void ShowSelected();
c4607f01 54//void SetSize() ;
48265b32 55void ResizeCanv();
56void ReadMe();
57void OpenDir();
58void SetWrite10Bit();
59void SetCheckVerb();
60void SetProcOne();
c4607f01 61void SetPedestalRun(Int_t val);
48265b32 62void InitDialog(Int_t id);
c4607f01 63//void Resize(Int_t update,Int_t doit , Int_t side);
48265b32 64void MonitorGui(AliTPCMonitor* fMon);
c4607f01 65void SetStyle();
48265b32 66
67
68//_________________________________________________________________________
69void TPCMonitor()
70{
71 // Initialize the monitor
72 SetStyle();
73
74 // MappingHandler
75 Char_t fglobalmap[256] ; sprintf(fglobalmap,"%s/TPC/mapping/MappingGlobal.txt", gSystem->Getenv("ALICE_ROOT"));
76 Char_t frowmap[256] ; sprintf(frowmap, "%s/TPC/mapping/MappingRow.txt", gSystem->Getenv("ALICE_ROOT"));
77 Char_t ffecmap[256] ; sprintf(ffecmap, "%s/TPC/mapping/MappingCards.txt", gSystem->Getenv("ALICE_ROOT"));
78 Char_t fnameconf[256] ; sprintf(fnameconf, "%s/TPC/AliTPCMonitorConfig.txt", gSystem->Getenv("ALICE_ROOT"));
79
80 cout << " ALICE_ROOT : " << gSystem->Getenv("ALICE_ROOT") << endl;
81 cout << " DATE_ROOT : " << gSystem->Getenv("DATE_ROOT") << endl;
82
83 fMapHand = new AliTPCMonitorMappingHandler("maphand","maphand");
84 fMapHand->ReadMapping(fglobalmap);
85 fMapHand->ReadRowMappingGlob(frowmap);
86 fMapHand->ReadFECMapping( ffecmap);
87 if (gDirectory) { gDirectory->Append(fMapHand); }
88
89 // Monitor
90 fMon = new AliTPCMonitor("monitor","monitor");
91 fMon->ReadConfig(fnameconf);
92 fMon->SetMappingHandler(fMapHand);
93 MonitorGui(fMon);
94
95}
96
97//_________________________________________________________________________
c4607f01 98void MonitorGui(AliTPCMonitor *fMon)
48265b32 99{
100 // Display the main Window
101
102 Float_t xsize = fMon->GetButtonXSize();
103 Float_t ysize = fMon->GetButtonYSize();
104 Float_t xfirst1 = fMon->GetButtonXFirst1();
105 Float_t xfirst2 = fMon->GetButtonXFirst2();
106 Float_t yfirst = fMon->GetButtonYFirst();
107 Float_t mainx = fMon->GetMainXSize();
108 Float_t mainy = fMon->GetMainYSize();
109
110 // main frame
111 fFrameMain = new TGMainFrame(gClient->GetRoot(),10,10,kMainFrame | kVerticalFrame);
112 fFrameMain->SetLayoutBroken(kTRUE);
113
1d32f273 114// TGTextButton* fFrameSelForm = new TGTextButton(fFrameMain, "Sel. Format " );
48265b32 115 TGTextButton* fFrameSelFil = new TGTextButton(fFrameMain, "Sel. File/Stream" );
116 TGTextButton* fFrameFFT = new TGTextButton(fFrameMain, "FFT" );
117 TGTextButton* fFrameWRITE = new TGTextButton(fFrameMain, "Write Channel" );
118 fFrameChDisFit = new TGCheckButton(fFrameMain, "Disable G4-fit" );
119 TGTextButton* fFrameRMS = new TGTextButton(fFrameMain, "Show RMS map" );
120 TGTextButton* fFrameSetConf = new TGTextButton(fFrameMain, "Conf. Ranges" );
121 fFrameCh10bit = new TGCheckButton(fFrameMain, "Write 10bit " );
122 fFrameCheckVerb = new TGCheckButton(fFrameMain, "Set Verbose " );
123 fFrameCheckProcOne = new TGCheckButton(fFrameMain, "Proc one Sector " );
124 fFrameCalcBSL = new TGCheckButton(fFrameMain, "Calc BSL (onl) " );
125 fFrameCheckPed = new TGCheckButton(fFrameMain, "No BSL sub. " );
126 TGTextButton* fFrameSideA = new TGTextButton(fFrameMain, "Side A" );
127 TGTextButton* fFrameSideB = new TGTextButton(fFrameMain, "Side C" );
128 TGTextButton* fFrameNextEvent = new TGTextButton(fFrameMain, "Next Event" );
129 TGTextButton* fFramesel = new TGTextButton(fFrameMain, "Show Component" );
130 TGTextButton* fFrameres = new TGTextButton(fFrameMain, "Resize Canvases" );
131 TGTextButton* fFramewrite = new TGTextButton(fFrameMain, "Write Histos" );
132 TGTextButton* fFrameQuit = new TGTextButton(fFrameMain, "Quit" );
133
1d32f273 134// fFrameSelForm->SetCommand( "InitDialog(1)" );
48265b32 135 fFrameSelFil->SetCommand( "OpenDir()" );
136 fFrameFFT->SetCommand( "FFT()" );
137 fFrameWRITE->SetCommand( "WriteChannel()" );
138 fFrameCheckPed->SetCommand( "SetPedestalRun(0)" );
139 fFrameCh10bit->SetCommand( "SetWrite10Bit()" );
140 fFrameCalcBSL->SetCommand( "SetPedestalRun(1)" );
141 fFrameChDisFit->SetCommand( "DisableFit()" );
142 fFrameRMS->SetCommand( "DrawRMSMap()" );
143 fFrameSetConf->SetCommand( "SetConfig()" );
144 fFrameCheckVerb->SetCommand( "SetCheckVerb()" );
145 fFrameCheckProcOne->SetCommand("SetProcOne()" );
146 fFrameNextEvent->SetCommand( "NextEvent()" ); fFrameNextEvent->SetTextColor(200);
147 fFramesel->SetCommand( "ShowSelected()" );
148 fFrameres->SetCommand( "ResizeCanv()" );
149 fFramewrite->SetCommand( "WriteHistos()" );
150 fFrameQuit->SetCommand( "Quit()" );
151
152 fFrameCalcBSL->SetDown( 1);
1d32f273 153 fFrameCheckPed->SetDown( 1);
154 fFrameChDisFit->SetDown( 1);
48265b32 155 fFrameCh10bit->SetDown( 0);
156 fFrameCheckVerb->SetDown(0);
157 fFrameCheckProcOne->SetDown(0);
1d32f273 158 SetPedestalRun(0); // !!
48265b32 159
160 TGLayoutHints* fLayout = new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,5,5);
161 fFrameMain->AddFrame(fFrameSideA , fLayout);
162 fFrameMain->AddFrame(fFrameSideB , fLayout);
163 fFrameMain->AddFrame(fFrameQuit , fLayout);
164 fFrameMain->AddFrame(fFrameCh10bit , fLayout);
165 fFrameMain->AddFrame(fFrameRMS , fLayout);
166 fFrameMain->AddFrame(fFrameSetConf , fLayout);
167 fFrameMain->AddFrame(fFrameSelFil , fLayout);
1d32f273 168// fFrameMain->AddFrame(fFrameSelForm , fLayout);
48265b32 169 fFrameMain->AddFrame(fFrameFFT , fLayout);
c4607f01 170// Int_t step = (Int_t)(ysize/2.);
48265b32 171 Int_t start = 5;
172
1d32f273 173// fFrameSelForm->MoveResize( 10, (Int_t)(start+ 1.0*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
174 fFrameSelFil->MoveResize( 10, (Int_t)(start+ 1.0*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
48265b32 175
1d32f273 176 fFrameSetConf->MoveResize( 10, (Int_t)(start+ 2.5*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
48265b32 177
1d32f273 178 fFrameCalcBSL->MoveResize( 10, (Int_t)(start+ 5*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
179 fFrameCheckPed->MoveResize( 10, (Int_t)(start+ 6*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
180 fFrameChDisFit->MoveResize( 10, (Int_t)(start+ 7*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
181 fFrameCh10bit->MoveResize( 10, (Int_t)(start+ 8*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
182 fFrameCheckVerb->MoveResize( 10, (Int_t)(start+ 9*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
48265b32 183
184
185 yfirst = start+ 14*ysize;
c4607f01 186 fFrameSideA->MoveResize( (Int_t)xfirst1, (Int_t)yfirst-30 ,(UInt_t)xsize ,(UInt_t)ysize);
187 fFrameSideB->MoveResize( (Int_t)xfirst2, (Int_t)yfirst-30 ,(UInt_t)xsize ,(UInt_t)ysize);
48265b32 188
189 // sector buttons
190 TObjArray * fFrameArr = new TObjArray();
191 TGTextButton * fTextButton = 0;
192 Int_t side = 0;
193 Int_t sector = 0;
194 for(Int_t i = 0; i<36; i++)
195 {
196 char nameb[256] ;
197 if(i<18)sprintf(nameb,"Sector %i",i);
198 else sprintf(nameb,"Sector %i",i-18);
199 fTextButton = new TGTextButton(fFrameMain,nameb);
200 fFrameMain->AddFrame(fTextButton, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,5,5));
c4607f01 201 if(i<18)fTextButton->MoveResize((Int_t)xfirst1,(Int_t)(yfirst +i*ysize),(UInt_t)xsize,(UInt_t)ysize);
202 else fTextButton->MoveResize((Int_t)xfirst2,(Int_t)(yfirst+(i-18)*ysize),(UInt_t)xsize,(UInt_t)ysize);
48265b32 203 if(i<18){ side = 0; sector = i; }
204 else { side = 1; sector = i-18;}
205 char bef[50]; sprintf(bef,"ProcessSector(%i,%i)",side,sector);
206 fTextButton->SetCommand(bef);
207 fFrameArr->Add(fTextButton);
208 }
209
210 TGLabel* flab = new TGLabel(fFrameMain, new TGHotString("Next Ev.ID"));
211 TGTextBuffer* ftbuf = new TGTextBuffer(10); ftbuf->AddText(0, "1");
212 fTextEvId = new TGTextEntry(fFrameMain, ftbuf);
213 fTextEvId->SetTextColor(200);
214
c4607f01 215 fFramesel->MoveResize( 10 , (Int_t)(mainy- 15.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
216 fFrameRMS->MoveResize( 10 , (Int_t)(mainy- 14.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
48265b32 217
c4607f01 218 fFrameFFT->MoveResize( 10 , (Int_t)(mainy- 12.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
219 fFramewrite->MoveResize( 10 , (Int_t)(mainy- 11.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
48265b32 220
c4607f01 221 fFrameWRITE->MoveResize( 10 , (Int_t)(mainy- 9.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
222 fFrameres->MoveResize( 10 , (Int_t)(mainy- 8.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
48265b32 223
224
c4607f01 225 fFrameCheckProcOne->MoveResize(10 , (Int_t)(mainy- 6.5*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
48265b32 226
c4607f01 227 flab->MoveResize( 10 , (Int_t)(mainy- 5.0*ysize) ,(UInt_t)xsize+5 ,(UInt_t)ysize);
228 fTextEvId->MoveResize( (Int_t)(mainx/2 +10) , (Int_t)(mainy- 5.0*ysize) ,(UInt_t)xsize-10 ,(UInt_t)ysize);
48265b32 229
c4607f01 230 fFrameNextEvent->MoveResize( 10 , (Int_t)(mainy- 3.5*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
48265b32 231
c4607f01 232 fFrameQuit->MoveResize( 30 , (Int_t)(mainy- 1.5*ysize) ,(UInt_t)mainx-60 ,(UInt_t)ysize);
48265b32 233
234 fFrameMain->MapSubwindows();
235 fFrameMain->MapWindow();
236 fFrameMain->SetWindowName("OM");
c4607f01 237 fFrameMain->MoveResize(0,0,(UInt_t)mainx,(UInt_t)mainy);
48265b32 238}
239
240//_________________________________________________________________________
241void WriteHistos()
242{
243 // Write Monitor Histos to file
244 fMon->WriteHistos() ;
245}
246
247//_________________________________________________________________________
248void WriteChannel()
249{
250 // Write 10 bit words to file for current channel
251 fMon->Write10bitChannel();
252}
253
254//_________________________________________________________________________
255void FFT()
256{
257 // Make Fourier Transformation for current channel
258 fMon->ExecTransform();
259}
260
261//_________________________________________________________________________
262void NextEvent()
263{
264 // Process next event
265 fMon->SetProcNextEvent(1);
266 Int_t eventid =0;
267 TString s1 = fTextEvId->GetDisplayText();
268 if(!s1.IsDigit()) { cout << " Invalid EventID " << endl; return ;}
269 else eventid = s1.Atoi();
270 fMon->SetEventID(eventid);
271 fMon->ResizeCanv();
272 fMon->ProcessEvent();
273 fMon->SetProcNextEvent(0);
274 char tenttext[20] ; sprintf(tenttext,"%i",fMon->GetEventID()+1);
275 fTextEvId->SetText(tenttext);
276}
277
278//_________________________________________________________________________
279void SetCheckVerb()
280{
281 // Change verbose mode
282 if(fFrameCheckVerb->IsDown()) { fVerb = 1; fMon->SetVerbose(1); }
283 else { fVerb = 0; fMon->SetVerbose(0); }
284}
285//_________________________________________________________________________
286void SetPedestalRun(Int_t val)
287{
288 // Set Pedestal calculation mode
289 if(val==0)
290 {
291 // check pedestal run button
292 if(fFrameCheckPed->IsDown()) { fMon->SetPedestals(0); fFrameCalcBSL->SetDown(0); }
293 else { fMon->SetPedestals(1); fFrameCalcBSL->SetDown(1); }
294 }
295 else
296 {
297 // check online calc button
298 if(fFrameCalcBSL->IsDown()) { fMon->SetPedestals(1); fFrameCheckPed->SetDown(0); }
299 else { fMon->SetPedestals(2); fFrameCheckPed->SetDown(0); }
300 }
301}
302
303//_________________________________________________________________________
304void SetWrite10Bit()
305{
306 // Set Write 10Bit mode
307 // 10 bit words will be written in AliTPCMonitorAltro for each equipment
308 if(fMon->GetWrite10Bit()==1) fMon->SetWrite10Bit(0);
309 else fMon->SetWrite10Bit(1);
310}
311
312//_________________________________________________________________________
313void DisableFit()
314{
315 // Disable Gamma4 fit to maximum peak
316 if(fMon->GetFitPulse()) fMon->SetFitPulse(0);
317 else fMon->SetFitPulse(1);
318}
319
320//_________________________________________________________________________
321Int_t DrawRMSMap()
322{
323 // Draw RMS map for IROC and OROC
324 if(fMon->GetLastSector()==-1) cout << " no sector written yet " << endl;
325 else fMon->DrawRMSMap();
c4607f01 326 return 0;
48265b32 327}
328
329//_________________________________________________________________________
330void ProcessSector(Int_t sid, Int_t sec)
331{
332 // Process specific sector. Initiated by button
333 if(fMon->GetSectorFilled(sec,sid))
334 {
335 fMon->SetLastSector(sec +sid*18);
336 fMon->SetProcNextEvent(0);
337 fMon->ProcessEvent();
338 }
339 else
340 {
341 cout << " Sector not filled " << endl;
342 }
343}
344
345//_________________________________________________________________________
346void OpenDir()
347{
348 TString dir ;
349 TString lastfile(fMon->GetLastProcFile());
ac940b58 350 if ( lastfile == "" ) dir=gSystem->pwd();
351 else dir=gSystem->DirName(lastfile);
352 dir="/";
48265b32 353 TGFileInfo* fi = new TGFileInfo();
354 fi->fIniDir = StrDup(dir);
355 fi->fFilename = StrDup(lastfile);
356 if(fVerb) printf("fIniDir = %s\n", fi->fIniDir);
357
358 new TGFileDialog(gClient->GetRoot(), fFrameMain, kFDOpen, fi);
c4607f01 359 if(!fi->fFilename) return;
48265b32 360 if(!strcmp(fi->fFilename,"")) return;
361 string fname(fi->fFilename);
362 Int_t ffirst = fname.find_first_not_of("/",0);
363 Int_t fstart = 0;
364 string firsts = fname.substr(ffirst,1);
365 Int_t firstsl = strcmp(firsts.data(),":");
366 Int_t firstcol = strcmp(firsts.data(),"@");
1d32f273 367 if ( (fname.find("mem:")!=string::npos) || (fname.find("rfio")!=string::npos) || (fname.find("http")!=string::npos)
368 || !firstsl || !firstcol ) fstart= ffirst ;
369 else fstart= ffirst-1;
48265b32 370
371 if(fstart <0){ cout << " return : missing slash at beginning of file " << endl ; return ;}
372
373 string fsubname = fname.substr(fstart,fname.length()-fstart);
c4607f01 374 fMon->SetFile((Char_t *)fsubname.data());
48265b32 375
376 if(fVerb)
377 {
378 cout << "Monitor.C OpenDir:: dir : " << fi->fIniDir << endl;
379 cout << "Monitor.C OpenDir:: file : " << fsubname.data() << endl;
380 cout << "Monitor.C OpenDir:: format : " << fMon->GetFormat() << endl;
381 }
382}
383
384//_________________________________________________________________________
385void InitDialog(Int_t id)
386{
c4607f01 387 if(id>0&&id<4) new AliTPCMonitorDialog((TGWindow*)gClient->GetRoot(), fFrameMain, 400, 400,0,id,fMon);
48265b32 388 else cout << "Error : Invalid Id " << endl;
389 return;
390}
391
392//_________________________________________________________________________
393void ShowSelected()
394{
395 InitDialog(2);
396 return;
397}
398
399//_________________________________________________________________________
400void SetConfig()
401{
402 InitDialog(3);
403}
404
405//_________________________________________________________________________
406void ResizeCanv()
407{
408 fMon->ResizeCanv();
409 return;
410}
411
412//_________________________________________________________________________
413void SetStyle()
414{
415 gStyle->SetScreenFactor(1);
416 gStyle->SetPadTopMargin(0.17);
417 gStyle->SetPadBottomMargin(0.17);
418 gStyle->SetPadLeftMargin(0.17);
419 gStyle->SetPadRightMargin(0.19);
420 gStyle->SetStatColor(kWhite);
421 gStyle->SetPadColor(kWhite);
422 gStyle->SetCanvasColor(kWhite);
423 gStyle->SetPadBorderMode(0);
424 gStyle->SetPadBorderSize(0);
425 gStyle->SetCanvasBorderMode(0);
426 gStyle->SetCanvasBorderSize(0);
427 gStyle->SetFrameBorderMode(0);
428 gStyle->SetFrameBorderSize(1);
429 gStyle->SetOptStat(0);
430 gStyle->SetPalette(1);
431 gStyle->SetTitleFillColor(0);
432 gStyle->SetTitleOffset(1.3,"X");
433 gStyle->SetTitleOffset(1.9,"Y");
434 gStyle->SetTitleOffset(1.7,"Z");
435 gStyle->SetPalette(1);
436
437}
438
439//_________________________________________________________________________
440void ReadMe()
441{
c4607f01 442// AliTPCMonitorEditor *ed = new AliTPCMonitorEditor(fFrameMain, 700, 400);
443// char nameread[256]; sprintf(nameread,"%s/TPC/AliTPCMonitorReadMe.txt",gSystem->Getenv("ALICE_ROOT"));
444// ed->LoadFile(nameread);
445// ed->Popup();
48265b32 446}
447
448//_________________________________________________________________________
449void SetProcOne()
450{
451 if(fFrameCheckProcOne->IsDown()) { fMon->SetProcOneSector(1); }
452 else { fMon->SetProcOneSector(0); }
453
454}
455//_________________________________________________________________________
456void Quit()
457{
458 gApplication->Terminate(0);
459}
460