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