BmnRoot
Loading...
Searching...
No Matches
MpdEventManagerEditor.cxx
Go to the documentation of this file.
1// MpdEventManagerEditor
2//
3// Specialization of TGedEditor for proper update propagation to TEveManager
4
6#include "FairRootManager.h"
7#include "FairRunAna.h"
8
9#include "TChain.h"
10#include "TFile.h"
11#include "TGLayout.h"
12#include "TGeoManager.h"
13#include "TString.h"
14#include "TEveManager.h"
15#include "TEveElement.h"
16#include "TGWindow.h"
17#include <TGLViewer.h>
18#include <TGLScenePad.h>
19#include "TEveBrowser.h"
20#include "TEveGedEditor.h"
21#include "TGFileDialog.h"
22#include "TThread.h"
23#include "TDatabasePDG.h"
24#include "TVirtualX.h"
25
26#include <iostream>
27#include <vector>
28#include <regex>
29
30using namespace std;
31
32//______________________________________________________________________________
33MpdEventManagerEditor::MpdEventManagerEditor(const TGWindow* p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
34: TGedFrame(p, width, height, options | kVerticalFrame, back),
35 iThreadState(0),
36 iEventCount(-1),
37 isStreamSource(false),
38 fSave(nullptr),
39 fUpdate(nullptr),
40 fCurrentEvent(nullptr),
41 fGeometry(nullptr),
42 fShowMCPoints(nullptr),
43 fShowMCTracks(nullptr),
44 fShowRecoPoints(nullptr),
45 fShowRecoTracks(nullptr),
46
47 fObject(nullptr),
48 fEventManager(MpdEventManager::Instance()),
49 fEventTime(nullptr),
50 fCurrentPDGTextEntry(nullptr),
51 fCurrentPDGString(""),
52 fVizPri(nullptr),
53 sliderMinEnergy(nullptr),
54 sliderMaxEnergy(nullptr),
55 fGeometryFrame(nullptr),
56 ShowMagnetButton(nullptr),
57 isMagnetFound(false)
58{
60 Init();
61}
62
64{
65 FairRootManager* fRootManager = FairRootManager::Instance();
66 TChain* chain = fRootManager->GetInChain();
67
68 // create tab for event visualization
69 MakeTitle("EventManager Editor");
70 TGVerticalFrame* fInfoFrame = CreateEditorTabSubFrame("Event Info");
71 TGCompositeFrame* title1 = new TGCompositeFrame(fInfoFrame, 250, 10, kVerticalFrame | kLHintsExpandX | kFixedWidth | kOwnBackground);
72
73 // display file name (or stream name if no input file)
74 TString InSource = "File: ";
75 TFile* pChainFile = chain->GetFile();
76 if (pChainFile == NULL)
77 {
78 InSource = "Data Stream";
79 isStreamSource = true;
80 }
81 else
82 InSource += pChainFile->GetName();
83 TGLabel* TFName = new TGLabel(title1, InSource.Data());
84 title1->AddFrame(TFName);
85
86 // textbox for Run ID and time cutting
87 TGHorizontalFrame* f2 = new TGHorizontalFrame(title1);
88 // Run Id
89 UInt_t RunId = FairRunAna::Instance()->getRunId();
90 TString run = TString::Format("Run Id: %d. ", RunId);
91 TGLabel* TRunId = new TGLabel(f2, run.Data());
92 // time cutting
93 TGLabel* EventTimeLabel = new TGLabel(f2, " Event Time: ");
94 fEventTime = new TGLabel(f2,"");
95 f2->AddFrame(TRunId);
96 f2->AddFrame(EventTimeLabel);
97 f2->AddFrame(fEventTime);
98 title1->AddFrame(f2);
99 // display event time
100 TString time = TString::Format("%.2f ns", FairRootManager::Instance()->GetEventTime());
101 fEventTime->SetText(time.Data());
102
103 // display event count and count of geometry nodes
104 iEventCount = chain->GetEntriesFast();
105 Int_t nodes = gGeoManager->GetNNodes();
106 TString nevent = TString::Format("No of events: %d. No. of nodes: %d", iEventCount, nodes);
107 TGLabel* TEvent = new TGLabel(title1, nevent.Data());
108 title1->AddFrame(TEvent);
109
110 // setting textbox for event number
111 TGHorizontalFrame* f = new TGHorizontalFrame(title1);
112 TGLabel* l = new TGLabel(f, "Current Event:");
113 f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
114 fCurrentEvent = new TGNumberEntry(f, 0., 6, -1,
115 TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, iEventCount-1);
116 f->AddFrame(fCurrentEvent, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
117 fCurrentEvent->Connect("ValueSet(Long_t)","MpdEventManagerEditor", this, "SelectEvent()");
118 // if event count is 0 then deactivate the field for event number
119 if (iEventCount < 1)
120 fCurrentEvent->SetState(kFALSE);
121
122 // button for saving the current image (EVE screenshot)
123 fSave = new TGPictureButton(f, gClient->GetPicture("save.xpm"), 5);
124 f->AddFrame(fSave, new TGLayoutHints(kLHintsLeft| kLHintsCenterY, 1, 2, 1, 1));
125 fSave->Connect("Clicked()", "MpdEventManagerEditor", this, "SaveImage()");
126 title1->AddFrame(f);
127
128 // checkbox to display only primary particles in event
129 fVizPri = new TGCheckButton(title1, "Primary Only");
130 AddFrame(fVizPri, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
131 fVizPri->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "DoVizPri()");
132 title1->AddFrame(fVizPri);
133
134 // textbox to display only particles with given PDG
135 TGHorizontalFrame* f1 = new TGHorizontalFrame(title1);
136 TGLabel* L1 = new TGLabel(f1, "Select Particles: ");
137 f1->AddFrame(L1, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 1, 2, 1, 1));
138 fCurrentPDGTextEntry = new TGTextEntry(f1);
139 f1->AddFrame(fCurrentPDGTextEntry, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
140 fCurrentPDGTextEntry->Connect("TextChanged(char*)","MpdEventManagerEditor", this, "SelectPDG()");
141 title1->AddFrame(f1);
142
143 // textbox for min energy cutting
144 sliderMinEnergy = new TEveGValuator(title1, "Min Energy:", 90, 0);
145 sliderMinEnergy->SetNELength(5);
146 sliderMinEnergy->SetLabelWidth(80);
147 sliderMinEnergy->Build();
148 sliderMinEnergy->SetLimits(fEventManager->GetMinEnergyLimit(), fEventManager->GetMaxEnergyLimit(), 2001, TGNumberFormat::kNESRealOne);
149 sliderMinEnergy->SetToolTip("Minimum energy of displayed tracks");
151 sliderMinEnergy->Connect("ValueSet(Double_t)", "MpdEventManagerEditor", this, "SetMinEnergyCut()");
152 title1->AddFrame(sliderMinEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
153
154 // textbox with slider for max energy cutting
155 sliderMaxEnergy = new TEveGValuator(title1, "Max Energy:", 90, 0);
156 sliderMaxEnergy->SetNELength(5);
157 sliderMaxEnergy->SetLabelWidth(80);
158 sliderMaxEnergy->Build();
159 sliderMaxEnergy->SetLimits(fEventManager->GetMinEnergyLimit(), fEventManager->GetMaxEnergyLimit(), 2001, TGNumberFormat::kNESRealOne);
160 sliderMaxEnergy->SetToolTip("Maximum energy of displayed tracks");
162 sliderMaxEnergy->Connect("ValueSet(Double_t)", "MpdEventManagerEditor", this, "SetMaxEnergyCut()");
163 title1->AddFrame(sliderMaxEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
164
165 fGeometryFrame = new TGHorizontalFrame(title1);
166 // button: whether show detector geometry or not
167 fGeometry = new TGCheckButton(fGeometryFrame, "show geometry");
168 fGeometryFrame->AddFrame(fGeometry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5,5,1,1));
169 fGeometry->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "ShowGeometry(Bool_t)");
170 fGeometry->SetOn();
171 // button: whether show magnet or not
172 TGeoVolume* magnet = gGeoManager->FindVolumeFast("Magnet");
173 if (magnet)
174 {
175 isMagnetFound = true;
176 ShowMagnetButton = new TGCheckButton(fGeometryFrame, "show magnet");
177 fGeometryFrame->AddFrame(ShowMagnetButton, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5,5,1,1));
178 ShowMagnetButton->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "ShowMagnet(Bool_t)");
179 ShowMagnetButton->SetOn();
180 }
181 title1->AddFrame(fGeometryFrame);
182
183 // button for high transparency of detectors' geometry to highlight event objects
184 TGCheckButton* fTransparency = new TGCheckButton(title1, "high transparency");
185 title1->AddFrame(fTransparency, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 5,5,1,1));
186 fTransparency->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "SwitchTransparency(Bool_t)");
187
188 // button for switching from black to white background
189 TGCheckButton* backgroundButton = new TGCheckButton(title1, "light background");
190 title1->AddFrame(backgroundButton, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 5,5,1,1));
191 backgroundButton->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "SwitchBackground(Bool_t)");
193 {
194 backgroundButton->SetOn();
195 gEve->GetViewers()->SwitchColorSet();
196 }
197
198 // group for displaying simulation and reconstruction data
199 TGGroupFrame* groupData = new TGGroupFrame(title1, "Show MC and reco data");
200 groupData->SetTitlePos(TGGroupFrame::kCenter);
201
202 TGHorizontalFrame* framePointsInfo = new TGHorizontalFrame(groupData);
203 // button for show|hide MC points
204 fShowMCPoints = new TGCheckButton(framePointsInfo, "MC points");
205 framePointsInfo->AddFrame(fShowMCPoints, new TGLayoutHints(kLHintsNormal, 0,0,0,0));
206 fShowMCPoints->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "ShowMCPoints(Bool_t)");
207 fShowMCPoints->SetDisabledAndSelected(kFALSE);
208
209 // button for show|hide reconstructed points
210 fShowRecoPoints = new TGCheckButton(framePointsInfo, "Reco points");
211 framePointsInfo->AddFrame(fShowRecoPoints, new TGLayoutHints(kLHintsRight, 0,0,1,0));
212 fShowRecoPoints->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "ShowRecoPoints(Bool_t)");
213 fShowRecoPoints->SetDisabledAndSelected(kFALSE);
214 groupData->AddFrame(framePointsInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1,1,5,0));
215
216 TGHorizontalFrame* frameTracksInfo = new TGHorizontalFrame(groupData);
217 // button for show|hide MC tracks
218 fShowMCTracks = new TGCheckButton(frameTracksInfo, "MC tracks");
219 frameTracksInfo->AddFrame(fShowMCTracks, new TGLayoutHints(kLHintsNormal, 0,0,0,0));
220 fShowMCTracks->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "ShowMCTracks(Bool_t)");
221 fShowMCTracks->SetDisabledAndSelected(kFALSE);
222
223 // button for show|hide reco tracks
224 fShowRecoTracks = new TGCheckButton(frameTracksInfo, "Reco tracks");
225 frameTracksInfo->AddFrame(fShowRecoTracks, new TGLayoutHints(kLHintsRight, 0,0,1,0));
226 fShowRecoTracks->Connect("Toggled(Bool_t)", "MpdEventManagerEditor", this, "ShowRecoTracks(Bool_t)");
227 fShowRecoTracks->SetDisabledAndSelected(kFALSE);
228
229 groupData->AddFrame(frameTracksInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1,1,5,0));
230 title1->AddFrame(groupData, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 3,15,1,1));
231
232 // button for update of event visualization
234 fUpdate = new TGTextButton(title1, "Start online display");
235 else
236 fUpdate = new TGTextButton(title1, "Update event");
237 title1->AddFrame(fUpdate, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 3,15,1,1));
238 fUpdate->Connect("Clicked()", "MpdEventManagerEditor", this, "UpdateEvent()");
239
240 // add all frame above to "event info" tab
241 fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
242
243 if ((iEventCount < 1) && (!isStreamSource))
244 {
245 fUpdate->SetEnabled(kFALSE);
246 return;
247 }
248
249 // read first event in Offline mode
251
252 // update tab controls
253 Update();
254}
255
256// set flag: show all particles or only primary
258{
259 if (fVizPri->IsOn())
261 else
262 fEventManager->SetPriOnly(kFALSE);
263}
264
265// select displaying particle by PDG code
270
271//______________________________________________________________________________
276
277//______________________________________________________________________________
282
283// show or hide detector geometry
285{
286 // set cursor HourClock
287 gVirtualX->SetCursor(gEve->GetMainWindow()->GetId(), gVirtualX->CreateCursor(kWatch));
288 gVirtualX->SetCursor(gEve->GetLTEFrame()->GetListTree()->GetId(), gVirtualX->CreateCursor(kWatch));
289 gVirtualX->SetCursor(gEve->GetLTEFrame()->GetEditor()->GetId(), gVirtualX->CreateCursor(kWatch));
290
291 gEve->GetGlobalScene()->SetRnrState(is_show);
293 {
294 fEventManager->GetRPhiScene()->SetRnrState(is_show);
295 fEventManager->GetRhoZScene()->SetRnrState(is_show);
296 }
297
298 // disable "Magnet Show" box after hiding of detector geometry
299 if (isMagnetFound)
300 {
301 if (!is_show)
303 else
305 }
306
307 gEve->Redraw3D();
308
309 // set cursor Pointer
310 gSystem->ProcessEvents();
311 gVirtualX->SetCursor(gEve->GetMainWindow()->GetId(), gVirtualX->CreateCursor(kPointer));
312 gVirtualX->SetCursor(gEve->GetLTEFrame()->GetListTree()->GetId(), gVirtualX->CreateCursor(kPointer));
313 gVirtualX->SetCursor(gEve->GetLTEFrame()->GetEditor()->GetId(), gVirtualX->CreateCursor(kPointer));
314}
315
316// show or hide magnet
318{
319 TGeoVolume* magnet = gGeoManager->FindVolumeFast("Magnet");
320 if (!magnet)
321 {
322 cout<<"ERROR: There is no magnet with given name: Magnet"<<endl;
323 return;
324 }
325
326 magnet->SetVisibility(is_show);
327 magnet->VisibleDaughters(is_show);
328
329 if (gEve->GetGlobalScene()->GetRnrState())
330 {
331 gEve->GetGlobalScene()->SetRnrState(kFALSE);
332 gEve->GetGlobalScene()->SetRnrState(kTRUE);
333 gEve->Redraw3D();
334 }
335}
336
337// switch between light and dark background
339{
340 gEve->GetViewers()->SwitchColorSet();
341}
342
343// set transparency to high value (80%)
345{
347
348 if (gEve->GetGlobalScene()->GetRnrState())
349 {
350 gEve->GetGlobalScene()->SetRnrState(kFALSE);
351 gEve->GetGlobalScene()->SetRnrState(kTRUE);
352 gEve->Redraw3D();
353 }
354}
355
356// show|hide MC points
358{
359 /*
360 TEveElement::List_t matches;
361 TPRegexp* regexp = new TPRegexp("(\\w+)Point\\b");
362 Int_t numFound = fEventManager->FindChildren(matches, *regexp);
363 if (numFound > 0)
364 {
365 for (TEveElement::List_i p = matches.begin(); p != matches.end(); ++p)
366 (*p)->SetRnrState(is_show);
367 }
368 */
369
370 TEveElement* points = fEventManager->FindChild("MC points");
371 if (points == NULL)
372 {
373 cout<<"There is no information about MC points"<<endl;
374 fShowMCPoints->SetDisabledAndSelected(kFALSE);
375 return;
376 }
377
378 points->SetRnrState(is_show);
379
381 {
382 if (is_show)
383 RedrawZDC(false);
384 else
385 RedrawZDC(true);
386 }
387
389 // exec event visualization of selected event
391 fEventManager->GotoEvent(fCurrentEvent->GetIntNumber());
392
393 // redraw points
394 gEve->Redraw3D();
395}
396
397bool MpdEventManagerEditor::RedrawZDC(bool isFull, bool isRedraw)
398{
399 TGeoVolume* curVolume = gGeoManager->GetVolume("VETO");
400 if (!curVolume)
401 {
402 cout<<"ERROR: There is no volume with given name: VETO"<<endl;
403 return false;
404 }
405 else
406 {
407 int i = 0;
408 for (; i < 68; i++)
409 {
410 TGeoNode* child = curVolume->FindNode(Form("VMDL_%d", i+1));
411 if (child == NULL)
412 continue;
413 //cout<<"Node: "<<child->GetName()<<". Number is equal "<<i<<endl;
414
415 if (isFull)
416 {
417 if (fEventManager->isZDCModule[i] == false)
418 {
419 child->SetVisibility(true);
420 child->VisibleDaughters(true);
421 }
422 }
423 else
424 {
425 child->SetVisibility(fEventManager->isZDCModule[i]);
426 child->VisibleDaughters(fEventManager->isZDCModule[i]);
427 }
428 }
429
430 for (; i < 104; i++)
431 {
432 TGeoNode* child = curVolume->FindNode(Form("UMDL_%d", i+1-68));
433 if (child == NULL)
434 continue;
435 //cout<<"Node: "<<child->GetName()<<". Number is equal "<<i<<endl;
436
437 if (isFull)
438 {
439 if (fEventManager->isZDCModule[i] == false)
440 {
441 child->SetVisibility(true);
442 child->VisibleDaughters(true);
443 }
444 }
445 else
446 {
447 child->SetVisibility(fEventManager->isZDCModule[i]);
448 child->VisibleDaughters(fEventManager->isZDCModule[i]);
449 }
450 }
451
452 if ((isFull || isRedraw) && (gEve->GetGlobalScene()->GetRnrState()))
453 {
454 gEve->GetGlobalScene()->SetRnrState(kFALSE);
455 gEve->GetGlobalScene()->SetRnrState(kTRUE);
456
457 return true;
458 }
459 }// else - ZDC detector was found
460
461 return false;
462}
463
465{
466 // display new min and max energy limits given by event energy range
471}
472
473//______________________________________________________________________________
475{
476 TEveElement* tracks = fEventManager->FindChild("MC tracks");
477 if (tracks == NULL)
478 {
479 cout<<"There is no information about MC tracks"<<endl;
480 fShowMCTracks->SetDisabledAndSelected(kFALSE);
481 return;
482 }
483
484 tracks->SetRnrState(is_show);
485 gEve->Redraw3D();
486}
487
488//______________________________________________________________________________
490{
491 TEveElement* points = fEventManager->FindChild("Reco points");
492 if (points == NULL)
493 {
494 cout<<"There is no information about reconstructed points"<<endl;
495 fShowRecoPoints->SetDisabledAndSelected(kFALSE);
496 return;
497 }
498
500 // exec event visualization of selected event
502 fEventManager->GotoEvent(fCurrentEvent->GetIntNumber());
503
504 points->SetRnrState(is_show);
505 gEve->Redraw3D();
506}
507
508//______________________________________________________________________________
510{
511 TEveElement* tracks = fEventManager->FindChild("Reco tracks");
512 if (tracks == NULL)
513 {
514 cout<<"There is no information about reconstructed tracks"<<endl;
515 fShowRecoTracks->SetDisabledAndSelected(kFALSE);
516 return;
517 }
518
520 // exec event visualization of selected event
522 fEventManager->GotoEvent(fCurrentEvent->GetIntNumber());
523
524 tracks->SetRnrState(is_show);
525 gEve->Redraw3D();
526}
527
529{
530 const char* filetypes[] = {"PNG", "*.png", "JPG", "*.jpg", 0, 0};
531 TGFileInfo fi;
532 fi.fFileTypes = filetypes;
533 fi.fIniDir = StrDup(".");
534 new TGFileDialog(gClient->GetRoot(), gEve->GetMainWindow(), kFDSave, &fi);
535
536 printf("Saving file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
537 gEve->GetDefaultGLViewer()-> SavePicture(fi.fFilename);
538
539 return;
540}
541
542// update event display when setting event number in textbox
544{
545 // if OFFLINE mode
547 {
548 int iOldEvent = fEventManager->GetCurrentEvent(), iNewEvent = fCurrentEvent->GetIntNumber();
549 // exec event visualization of selected event
550 fEventManager->GotoEvent(iNewEvent);
551
552 if ((fEventManager->isZDCModule) && (fShowMCPoints->IsOn()))
553 RedrawZDC(false);
554
555 if (iOldEvent != iNewEvent)
556 {
557 // display event time
558 TString time = TString::Format("%.2f ns", FairRootManager::Instance()->GetEventTime());
559 fEventTime->SetText(time.Data());
560
562 }
563
564 // update tab controls
565 Update();
566
567 return;
568 }
569
570 /*// update all scenes
571 fEventManager->fRPhiView->GetGLViewer()->UpdateScene(kTRUE);
572 fEventManager->fRhoZView->GetGLViewer()->UpdateScene(kTRUE);
573 fEventManager->fMulti3DView->GetGLViewer()->UpdateScene(kTRUE);
574 fEventManager->fMultiRPhiView->GetGLViewer()->UpdateScene(kTRUE);
575 fEventManager->fMultiRhoZView->GetGLViewer()->UpdateScene(kTRUE);*/
576}
577
578
579// clicking 'Update event' button to update event display OR 'Start online display' button to start/stop online event display
581{
582 if (iThreadState == 1)
583 {
584 iThreadState = 0;
585 return;
586 }
587
588 fEventManager->fCurrentPDG.clear();
589 istringstream iss(fCurrentPDGString);
590 auto databasePDG = TDatabasePDG::Instance();
591 regex rgx("[\\s,]+");
592 sregex_token_iterator iter(fCurrentPDGString.begin(), fCurrentPDGString.end(), rgx, -1);
593 sregex_token_iterator end;
594 for ( ; iter != end; ++iter)
595 {
596 string s = (*iter).str();
597 if (s != "")
598 {
599 auto pdg = atoi(s.c_str());
600 if (pdg)
601 fEventManager->fCurrentPDG.insert(pdg);
602 else
603 {
604 auto particle = databasePDG->GetParticle(s.c_str());
605 if (particle)
606 fEventManager->fCurrentPDG.insert(particle->PdgCode());
607 }
608 }
609 }
610
611 // if OFFLINE mode
613 {
614 int iOldEvent = fEventManager->GetCurrentEvent(), iNewEvent = fCurrentEvent->GetIntNumber();
615 // exec event visualization of selected event
616 fEventManager->GotoEvent(iNewEvent);
617
618 if ((fEventManager->isZDCModule) && (fShowMCPoints->IsOn()))
619 RedrawZDC(false);
620
621 if (iOldEvent != iNewEvent)
622 {
623 // display event time
624 TString time = TString::Format("%.2f ns", FairRootManager::Instance()->GetEventTime());
625 fEventTime->SetText(time.Data());
626
628 }
629
630 // update tab controls
631 Update();
632
633 return;
634 }
635 // if ONLINE mode
636 else
637 {
638 // block user interface to exclude sharing of Redraw access
639 BlockUI();
640
641 // Run separate thread for Online Display
642 ThreadParam_OnlineDisplay* par_online_display = new ThreadParam_OnlineDisplay();
643 par_online_display->fEventManager = fEventManager;
644 par_online_display->fManagerEditor = this;
645 par_online_display->fRootManager = FairRootManager::Instance();
646 par_online_display->isZDCRedraw = false;
647 if ((fEventManager->isZDCModule) && (fShowMCPoints->IsOn()))
648 par_online_display->isZDCRedraw = true;
649 par_online_display->iCurrentEvent = fCurrentEvent->GetIntNumber();
650 par_online_display->isStreamSource = isStreamSource;
651
652 TThread* thread_run_online = new TThread(RunOnlineDisplay, (void*)par_online_display);
653 iThreadState = 1;
654 thread_run_online->Run();
655
656 return;
657 }
658}
659
661{
662 //fCurrentEvent->SetState(kFALSE);
663 //fUpdate->SetEnabled(kFALSE);
664 fUpdate->SetText("Stop online display");
665 //fGeometry->SetEnabled(kFALSE);
666}
667
669{
670 //fCurrentEvent->SetState(kTRUE);
671 //fUpdate->SetEnabled(kTRUE);
672 fUpdate->SetText("Start online display");
673 //fGeometry->SetEnabled(kTRUE);
674}
675
676// thread function for Online Display
677void* RunOnlineDisplay(void* ptr)
678{
680 MpdEventManager* fEventManager = thread_par->fEventManager;
681 MpdEventManagerEditor* fEditor = thread_par->fManagerEditor;
682 FairRootManager* fRootManager = thread_par->fRootManager;
683 int current_event = thread_par->iCurrentEvent;
684 bool stream_source = thread_par->isStreamSource;
685 bool isZDCRedraw = thread_par->isZDCRedraw;
686
687 // get all tasks from FairRunAna
688 FairRunAna* pRun = fEventManager->fRunAna;
689 FairTask* pMainTask = pRun->GetMainTask();
690 TList* taskList = pMainTask->GetListOfTasks();
691
692 for (int i = current_event+1; ((stream_source) || (i < fEditor->iEventCount)); i++)
693 {
694 if (fEditor->iThreadState == 0)
695 break;
696 do
697 {
698 TThread::Sleep(0, 200000000);
699 } while ((gEve->GetGlobalScene()->GetGLScene()->IsLocked()) || (gEve->GetEventScene()->GetGLScene()->IsLocked()));
700
701 fRootManager->ReadEvent(i);
702 fEventManager->SetCurrentEvent(i);
703
704 // run all tasks
705 TObjLink* lnk = taskList->FirstLink();
706 while (lnk)
707 {
708 FairTask* pCurTask = (FairTask*) lnk->GetObject();
709 pCurTask->ExecuteTask("");
710 lnk = lnk->Next();
711 }
712
713 //fEditor->fCurrentEvent->SetIntNumber(i);
714
715 // highlight ZDC modules if ZDC present
716 if (isZDCRedraw)
717 fEditor->RedrawZDC();
718
719 // redraw points
720 cout<<"Redrawing event #"<<i<<"..."<<endl<<endl;
721 gEve->Redraw3D();
722 //TThread::Sleep(1,0);
723 //gSystem->ProcessEvents();
724 }
725
726 fEditor->UnblockUI();
727 fEditor->iThreadState = 0;
728
729 return NULL;
730}
void * RunOnlineDisplay(void *ptr)
int i
Definition P4_F32vec4.h:22
float f
Definition P4_F32vec4.h:21
MpdEventManager * fEventManager
virtual void ShowMCTracks(Bool_t is_show)
virtual void ShowRecoTracks(Bool_t is_show)
virtual void ShowMagnet(Bool_t is_show)
virtual void SwitchTransparency(Bool_t is_on)
virtual void ShowGeometry(Bool_t is_show)
virtual void SwitchBackground(Bool_t is_on)
bool RedrawZDC(bool isFull=false, bool isRedraw=true)
MpdEventManagerEditor(const TGWindow *p=0, Int_t width=170, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
virtual void ShowRecoPoints(Bool_t is_show)
virtual void ShowMCPoints(Bool_t is_show)
TGHorizontalFrame * fGeometryFrame
virtual void SetCurrentEvent(Int_t event_number)
FairRunAna * fRunAna
virtual void SetMaxEnergyCut(Float_t max)
virtual void SetMinEnergyCut(Float_t min)
virtual void SetPriOnly(Bool_t Pri)
virtual void GotoEvent(Int_t event)
void SetEventEditor(MpdEventManagerEditor *event_editor)
TEveScene * GetRPhiScene()
void SetTransparentGeometry(bool is_on)
virtual Int_t GetCurrentEvent()
virtual Float_t GetMinEnergyLimit()
unordered_set< Int_t > fCurrentPDG
virtual Float_t GetMinEnergyCut()
TEveScene * GetRhoZScene()
virtual Float_t GetMaxEnergyCut()
virtual Float_t GetMaxEnergyLimit()
void * RunOnlineDisplay(void *ptr)
-clang-format
STL namespace.
#define L1
MpdEventManagerEditor * fManagerEditor