1 ////////////////////////////////////////////////////////////////////////////////
3 // Macro to launch Monitoring program for TPC raw data
5 // Author: Stefan Kniege, IKF, Frankfurt
7 ////////////////////////////////////////////////////////////////////////////////
13 #include "TGTextEntry.h"
15 #include "TGFileDialog.h"
17 #include "TGApplication.h"
20 #include "TDirectory.h"
21 #include "TFileMerger.h"
23 #include "AliTPCMonitor.h"
24 #include "AliTPCMonitorMappingHandler.h"
25 //#include "AliTPCMonitorEditor.h"
26 #include "AliTPCMonitorDialog.h"
31 static AliTPCMonitor* fMon = 0;
32 static AliTPCMonitorMappingHandler* fMapHand = 0;
34 static TGMainFrame* fFrameMain = 0;
35 static TGCheckButton* fFrameChDisFit = 0;
36 static TGCheckButton* fFrameCh10bit = 0;
37 static TGCheckButton* fFrameCheckVerb = 0;
38 static TGCheckButton* fFrameCheckProcOne = 0;
39 static TGCheckButton* fFrameCheckPed = 0;
40 static TGCheckButton* fFrameCalcBSL = 0;
42 static Int_t fVerb = 0;
43 static TGTextEntry* fTextEvId = 0;
49 //void ProcessSector(char* fdata,char* ffil, Int_t side, Int_t sector);
50 void ProcessSector(Int_t sid, Int_t sector);
61 void SetPedestalRun(Int_t val);
62 void InitDialog(Int_t id);
63 //void Resize(Int_t update,Int_t doit , Int_t side);
64 void MonitorGui(AliTPCMonitor* fMon);
68 //_________________________________________________________________________
71 // Initialize the monitor
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"));
80 cout << " ALICE_ROOT : " << gSystem->Getenv("ALICE_ROOT") << endl;
81 cout << " DATE_ROOT : " << gSystem->Getenv("DATE_ROOT") << endl;
83 fMapHand = new AliTPCMonitorMappingHandler("maphand","maphand");
84 fMapHand->ReadMapping(fglobalmap);
85 fMapHand->ReadRowMappingGlob(frowmap);
86 fMapHand->ReadFECMapping( ffecmap);
87 if (gDirectory) { gDirectory->Append(fMapHand); }
90 fMon = new AliTPCMonitor("monitor","monitor");
91 fMon->ReadConfig(fnameconf);
92 fMon->SetMappingHandler(fMapHand);
97 //_________________________________________________________________________
98 void MonitorGui(AliTPCMonitor *fMon)
100 // Display the main Window
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();
111 fFrameMain = new TGMainFrame(gClient->GetRoot(),10,10,kMainFrame | kVerticalFrame);
112 fFrameMain->SetLayoutBroken(kTRUE);
114 TGTextButton* fFrameSelForm = new TGTextButton(fFrameMain, "Sel. Format " );
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" );
134 fFrameSelForm->SetCommand( "InitDialog(1)" );
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()" );
152 fFrameCalcBSL->SetDown( 1);
153 fFrameCheckPed->SetDown( 0);
154 fFrameCh10bit->SetDown( 0);
155 fFrameCheckVerb->SetDown(0);
156 fFrameCheckProcOne->SetDown(0);
158 TGLayoutHints* fLayout = new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,5,5);
159 fFrameMain->AddFrame(fFrameSideA , fLayout);
160 fFrameMain->AddFrame(fFrameSideB , fLayout);
161 fFrameMain->AddFrame(fFrameQuit , fLayout);
162 fFrameMain->AddFrame(fFrameCh10bit , fLayout);
163 fFrameMain->AddFrame(fFrameRMS , fLayout);
164 fFrameMain->AddFrame(fFrameSetConf , fLayout);
165 fFrameMain->AddFrame(fFrameSelFil , fLayout);
166 fFrameMain->AddFrame(fFrameSelForm , fLayout);
167 fFrameMain->AddFrame(fFrameFFT , fLayout);
168 // Int_t step = (Int_t)(ysize/2.);
171 fFrameSelForm->MoveResize( 10, (Int_t)(start+ 1.0*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
172 fFrameSelFil->MoveResize( 10, (Int_t)(start+ 2.0*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
174 fFrameSetConf->MoveResize( 10, (Int_t)(start+ 4.5*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
176 fFrameCalcBSL->MoveResize( 10, (Int_t)(start+ 6*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
177 fFrameCheckPed->MoveResize( 10, (Int_t)(start+ 7*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
178 fFrameChDisFit->MoveResize( 10, (Int_t)(start+ 8*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
179 fFrameCh10bit->MoveResize( 10, (Int_t)(start+ 9*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
180 fFrameCheckVerb->MoveResize( 10, (Int_t)(start+ 10*ysize) ,(UInt_t)(mainx-20) ,(UInt_t)ysize);
183 yfirst = start+ 14*ysize;
184 fFrameSideA->MoveResize( (Int_t)xfirst1, (Int_t)yfirst-30 ,(UInt_t)xsize ,(UInt_t)ysize);
185 fFrameSideB->MoveResize( (Int_t)xfirst2, (Int_t)yfirst-30 ,(UInt_t)xsize ,(UInt_t)ysize);
188 TObjArray * fFrameArr = new TObjArray();
189 TGTextButton * fTextButton = 0;
192 for(Int_t i = 0; i<36; i++)
195 if(i<18)sprintf(nameb,"Sector %i",i);
196 else sprintf(nameb,"Sector %i",i-18);
197 fTextButton = new TGTextButton(fFrameMain,nameb);
198 fFrameMain->AddFrame(fTextButton, new TGLayoutHints(kLHintsLeft | kLHintsTop,5,5,5,5));
199 if(i<18)fTextButton->MoveResize((Int_t)xfirst1,(Int_t)(yfirst +i*ysize),(UInt_t)xsize,(UInt_t)ysize);
200 else fTextButton->MoveResize((Int_t)xfirst2,(Int_t)(yfirst+(i-18)*ysize),(UInt_t)xsize,(UInt_t)ysize);
201 if(i<18){ side = 0; sector = i; }
202 else { side = 1; sector = i-18;}
203 char bef[50]; sprintf(bef,"ProcessSector(%i,%i)",side,sector);
204 fTextButton->SetCommand(bef);
205 fFrameArr->Add(fTextButton);
208 TGLabel* flab = new TGLabel(fFrameMain, new TGHotString("Next Ev.ID"));
209 TGTextBuffer* ftbuf = new TGTextBuffer(10); ftbuf->AddText(0, "1");
210 fTextEvId = new TGTextEntry(fFrameMain, ftbuf);
211 fTextEvId->SetTextColor(200);
213 fFramesel->MoveResize( 10 , (Int_t)(mainy- 15.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
214 fFrameRMS->MoveResize( 10 , (Int_t)(mainy- 14.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
216 fFrameFFT->MoveResize( 10 , (Int_t)(mainy- 12.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
217 fFramewrite->MoveResize( 10 , (Int_t)(mainy- 11.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
219 fFrameWRITE->MoveResize( 10 , (Int_t)(mainy- 9.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
220 fFrameres->MoveResize( 10 , (Int_t)(mainy- 8.0*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
223 fFrameCheckProcOne->MoveResize(10 , (Int_t)(mainy- 6.5*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
225 flab->MoveResize( 10 , (Int_t)(mainy- 5.0*ysize) ,(UInt_t)xsize+5 ,(UInt_t)ysize);
226 fTextEvId->MoveResize( (Int_t)(mainx/2 +10) , (Int_t)(mainy- 5.0*ysize) ,(UInt_t)xsize-10 ,(UInt_t)ysize);
228 fFrameNextEvent->MoveResize( 10 , (Int_t)(mainy- 3.5*ysize) ,(UInt_t)mainx-20 ,(UInt_t)ysize);
230 fFrameQuit->MoveResize( 30 , (Int_t)(mainy- 1.5*ysize) ,(UInt_t)mainx-60 ,(UInt_t)ysize);
232 fFrameMain->MapSubwindows();
233 fFrameMain->MapWindow();
234 fFrameMain->SetWindowName("OM");
235 fFrameMain->MoveResize(0,0,(UInt_t)mainx,(UInt_t)mainy);
238 //_________________________________________________________________________
241 // Write Monitor Histos to file
242 fMon->WriteHistos() ;
245 //_________________________________________________________________________
248 // Write 10 bit words to file for current channel
249 fMon->Write10bitChannel();
252 //_________________________________________________________________________
255 // Make Fourier Transformation for current channel
256 fMon->ExecTransform();
259 //_________________________________________________________________________
262 // Process next event
263 fMon->SetProcNextEvent(1);
265 TString s1 = fTextEvId->GetDisplayText();
266 if(!s1.IsDigit()) { cout << " Invalid EventID " << endl; return ;}
267 else eventid = s1.Atoi();
268 fMon->SetEventID(eventid);
270 fMon->ProcessEvent();
271 fMon->SetProcNextEvent(0);
272 char tenttext[20] ; sprintf(tenttext,"%i",fMon->GetEventID()+1);
273 fTextEvId->SetText(tenttext);
276 //_________________________________________________________________________
279 // Change verbose mode
280 if(fFrameCheckVerb->IsDown()) { fVerb = 1; fMon->SetVerbose(1); }
281 else { fVerb = 0; fMon->SetVerbose(0); }
283 //_________________________________________________________________________
284 void SetPedestalRun(Int_t val)
286 // Set Pedestal calculation mode
289 // check pedestal run button
290 if(fFrameCheckPed->IsDown()) { fMon->SetPedestals(0); fFrameCalcBSL->SetDown(0); }
291 else { fMon->SetPedestals(1); fFrameCalcBSL->SetDown(1); }
295 // check online calc button
296 if(fFrameCalcBSL->IsDown()) { fMon->SetPedestals(1); fFrameCheckPed->SetDown(0); }
297 else { fMon->SetPedestals(2); fFrameCheckPed->SetDown(0); }
301 //_________________________________________________________________________
304 // Set Write 10Bit mode
305 // 10 bit words will be written in AliTPCMonitorAltro for each equipment
306 if(fMon->GetWrite10Bit()==1) fMon->SetWrite10Bit(0);
307 else fMon->SetWrite10Bit(1);
310 //_________________________________________________________________________
313 // Disable Gamma4 fit to maximum peak
314 if(fMon->GetFitPulse()) fMon->SetFitPulse(0);
315 else fMon->SetFitPulse(1);
318 //_________________________________________________________________________
321 // Draw RMS map for IROC and OROC
322 if(fMon->GetLastSector()==-1) cout << " no sector written yet " << endl;
323 else fMon->DrawRMSMap();
327 //_________________________________________________________________________
328 void ProcessSector(Int_t sid, Int_t sec)
330 // Process specific sector. Initiated by button
331 if(fMon->GetSectorFilled(sec,sid))
333 fMon->SetLastSector(sec +sid*18);
334 fMon->SetProcNextEvent(0);
335 fMon->ProcessEvent();
339 cout << " Sector not filled " << endl;
343 //_________________________________________________________________________
347 TString lastfile(fMon->GetLastProcFile());
348 if ( lastfile == "" ) dir=gSystem->pwd();
349 else dir=gSystem->DirName(lastfile);
351 TGFileInfo* fi = new TGFileInfo();
352 fi->fIniDir = StrDup(dir);
353 fi->fFilename = StrDup(lastfile);
354 if(fVerb) printf("fIniDir = %s\n", fi->fIniDir);
356 new TGFileDialog(gClient->GetRoot(), fFrameMain, kFDOpen, fi);
357 if(!fi->fFilename) return;
358 if(!strcmp(fi->fFilename,"")) return;
359 string fname(fi->fFilename);
360 Int_t ffirst = fname.find_first_not_of("/",0);
362 string firsts = fname.substr(ffirst,1);
363 Int_t firstsl = strcmp(firsts.data(),":");
364 Int_t firstcol = strcmp(firsts.data(),"@");
365 if(fname.find("rfio")!=string::npos|| fname.find("http")!=string::npos || !firstsl || !firstcol ) fstart= ffirst ;
366 else fstart= ffirst-1;
368 if(fstart <0){ cout << " return : missing slash at beginning of file " << endl ; return ;}
370 string fsubname = fname.substr(fstart,fname.length()-fstart);
371 fMon->SetFile((Char_t *)fsubname.data());
375 cout << "Monitor.C OpenDir:: dir : " << fi->fIniDir << endl;
376 cout << "Monitor.C OpenDir:: file : " << fsubname.data() << endl;
377 cout << "Monitor.C OpenDir:: format : " << fMon->GetFormat() << endl;
381 //_________________________________________________________________________
382 void InitDialog(Int_t id)
384 if(id>0&&id<4) new AliTPCMonitorDialog((TGWindow*)gClient->GetRoot(), fFrameMain, 400, 400,0,id,fMon);
385 else cout << "Error : Invalid Id " << endl;
389 //_________________________________________________________________________
396 //_________________________________________________________________________
402 //_________________________________________________________________________
409 //_________________________________________________________________________
412 gStyle->SetScreenFactor(1);
413 gStyle->SetPadTopMargin(0.17);
414 gStyle->SetPadBottomMargin(0.17);
415 gStyle->SetPadLeftMargin(0.17);
416 gStyle->SetPadRightMargin(0.19);
417 gStyle->SetStatColor(kWhite);
418 gStyle->SetPadColor(kWhite);
419 gStyle->SetCanvasColor(kWhite);
420 gStyle->SetPadBorderMode(0);
421 gStyle->SetPadBorderSize(0);
422 gStyle->SetCanvasBorderMode(0);
423 gStyle->SetCanvasBorderSize(0);
424 gStyle->SetFrameBorderMode(0);
425 gStyle->SetFrameBorderSize(1);
426 gStyle->SetOptStat(0);
427 gStyle->SetPalette(1);
428 gStyle->SetTitleFillColor(0);
429 gStyle->SetTitleOffset(1.3,"X");
430 gStyle->SetTitleOffset(1.9,"Y");
431 gStyle->SetTitleOffset(1.7,"Z");
432 gStyle->SetPalette(1);
436 //_________________________________________________________________________
439 // AliTPCMonitorEditor *ed = new AliTPCMonitorEditor(fFrameMain, 700, 400);
440 // char nameread[256]; sprintf(nameread,"%s/TPC/AliTPCMonitorReadMe.txt",gSystem->Getenv("ALICE_ROOT"));
441 // ed->LoadFile(nameread);
445 //_________________________________________________________________________
448 if(fFrameCheckProcOne->IsDown()) { fMon->SetProcOneSector(1); }
449 else { fMon->SetProcOneSector(0); }
452 //_________________________________________________________________________
455 gApplication->Terminate(0);