CbmRoot
Loading...
Searching...
No Matches
CbmTimesliceManager.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau[committer], Norbert Herrmann */
4
6
7#include "CbmEvent.h" // For CbmEvent
8#include "CbmTimeslicePixelHitSetDraw.h" // For CbmTimeslicePixelHitSetDraw
9#include "CbmTimesliceRecoTracks.h" // For CbmTimesliceRecoTracks
10#include "CbmTsDisTofTracklets.h" // for CbmTofTracklets
11#include "CbmTsPointSetArrayDraw.h" // For CbmTsPointSetArrayDraw
12#include "FairRootManager.h" // for FairRootManager
13#include "FairTask.h" // for FairTask
14#include "FairXMLNode.h" // for FairXMLNode and FairXMLFile
15
16#include <TClonesArray.h> // for TClonesArray
17#include <TDatabasePDG.h> // for TDatabasePDG
18#include <TEveBrowser.h>
19#include <TEveGeoNode.h> // for TEveGeoTopNode
20#include <TEveManager.h> // for TEveManager, gEve
21#include <TEveProjectionManager.h>
22#include <TEveProjections.h> // for TEveProjection, TEveProjection::k...
23#include <TEveScene.h>
24#include <TEveText.h>
25#include <TEveTrans.h>
26#include <TEveViewer.h>
27#include <TEveWindow.h> // for TEveWindowPack, TEveWindowSlot
28#include <TGFileDialog.h>
29#include <TGLAnnotation.h>
30#include <TGLCameraOverlay.h>
31#include <TGLClip.h> // for TGLClip, TGLClip::kClipPlane, TGL...
32#include <TGLFontManager.h>
33#include <TGLLightSet.h>
34#include <TGLViewer.h>
35#include <TGeoBBox.h>
36#include <TGeoManager.h> // for gGeoManager, TGeoManager
37#include <TGeoNode.h>
38#include <TGeoVolume.h> // for TGeoVolume
39#include <TVector3.h>
40
41// +++++++++++++++++++++++++++++++++++++++++++++ Public +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
43
45
46CbmTimesliceManager::CbmTimesliceManager() : TEveEventManager("CbmTimesliceManager", "")
47{
49 gRinstanceTsMan = this;
50
51 fRunAna = FairRunAna::Instance();
52 fRootManager = FairRootManager::Instance();
53
56}
57
59{
60 CbmTimeslicePixelHitSetDraw* drawStsHit = new CbmTimeslicePixelHitSetDraw("StsHit", kBlue, kFullSquare);
61 CbmTimeslicePixelHitSetDraw* drawRichHit = new CbmTimeslicePixelHitSetDraw("RichHit", kCyan, kFullSquare);
62 CbmTimeslicePixelHitSetDraw* drawTrdHit = new CbmTimeslicePixelHitSetDraw("TrdHit", kYellow, kFullSquare);
63 CbmTimeslicePixelHitSetDraw* drawTofHit = new CbmTimeslicePixelHitSetDraw("TofHit", kRed, kFullCircle);
64 CbmTimeslicePixelHitSetDraw* drawPsdHit = new CbmTimeslicePixelHitSetDraw("PsdHit", kOrange, kFullSquare);
65
67
68 AddTask(drawStsHit);
69 AddTask(drawRichHit);
70 AddTask(drawTrdHit);
71 AddTask(drawTofHit);
72 AddTask(drawPsdHit);
73
74 AddTask(drawTrack);
75}
76
78{
79 CbmTimeslicePixelHitSetDraw* drawMvdHit = new CbmTimeslicePixelHitSetDraw("MvdHit", kBlue, kFullSquare);
80 CbmTimeslicePixelHitSetDraw* drawStsHit = new CbmTimeslicePixelHitSetDraw("StsHit", kBlue, kFullSquare);
81 CbmTimeslicePixelHitSetDraw* drawMuchHit = new CbmTimeslicePixelHitSetDraw("MuchHit", kCyan, kFullSquare);
82 CbmTimeslicePixelHitSetDraw* drawTrdHit = new CbmTimeslicePixelHitSetDraw("TrdHit", kYellow, kFullSquare);
83 CbmTimeslicePixelHitSetDraw* drawTofHit = new CbmTimeslicePixelHitSetDraw("TofHit", kRed, kFullSquare);
84 CbmTimeslicePixelHitSetDraw* drawPsdHit = new CbmTimeslicePixelHitSetDraw("PsdHit", kOrange, kFullSquare);
85
86 AddTask(drawMvdHit);
87 AddTask(drawStsHit);
88 AddTask(drawMuchHit);
89 AddTask(drawTrdHit);
90 AddTask(drawTofHit);
91 AddTask(drawPsdHit);
92
94 AddTask(drawTrack);
95}
96
97void CbmTimesliceManager::SetDisplayMcbm(bool bLowRate, bool bMuch)
98{
99 CbmTimeslicePixelHitSetDraw* drawStsHit = new CbmTimeslicePixelHitSetDraw("StsHit", kBlue, kFullSquare);
100 CbmTimeslicePixelHitSetDraw* drawMuchHit = new CbmTimeslicePixelHitSetDraw("MuchHit", kCyan, kFullSquare);
101 CbmTimeslicePixelHitSetDraw* drawTrdHit = new CbmTimeslicePixelHitSetDraw("TrdHit", kYellow, kFullSquare);
102 CbmTimeslicePixelHitSetDraw* drawTofHit = new CbmTimeslicePixelHitSetDraw("TofHit", kRed, kFullCircle);
103 CbmTimeslicePixelHitSetDraw* drawRichHit = new CbmTimeslicePixelHitSetDraw("RichHit", kOrange, kFullSquare);
104
105 AddTask(drawStsHit);
106 if (bMuch) { //
107 AddTask(drawMuchHit);
108 }
109 AddTask(drawTrdHit);
110 AddTask(drawTofHit);
111 if (bLowRate) { //
112 AddTask(drawRichHit);
113 }
114
116 AddTask(drawTrack);
117
118 CbmTsDisTofTracklets* TofTracks =
119 new CbmTsDisTofTracklets("TofTracks", 1, kFALSE, kTRUE); //name, verbosity, RnrChildren points, RnrChildren track
120 AddTask(TofTracks);
121
123 "TofUHit", kBlue, kCross, 1, kTRUE); //name, colorMode, markerMode, verbosity, RnrChildren
124 //CbmTimeslicePixelHitSetDraw* drawTofUHit = new CbmTimeslicePixelHitSetDraw("TofUHit", kBlue, kCross);
125 AddTask(drawTofUHit);
126
127 fbMcbmViewersEna = true;
128}
129
131{
132 CbmTimeslicePixelHitSetDraw* drawTofHit = new CbmTimeslicePixelHitSetDraw("TofHit", kRed, kFullSquare);
133 AddTask(drawTofHit);
134
135 CbmTsDisTofTracklets* TofTracks =
136 new CbmTsDisTofTracklets("TofTracks", 1, kFALSE, kTRUE); //name, verbosity, RnrChildren points, RnrChildren track
137 AddTask(TofTracks);
138
139 //CbmTsPointSetArrayDraw* drawTofUHit = new CbmTsPointSetArrayDraw("TofUHit", kBlue, kCross, 1, kTRUE); //name, colorMode, markerMode, verbosity, RnrChildren
140 //AddTask(drawTofUHit);
141
142 // Display L1 tracks
143 //CbmTimesliceRecoTracks* drawTrack = new CbmTimesliceRecoTracks();
144 //AddTask(drawTrack);
145
146 fbMcbmViewersEna = true;
147}
148
149void CbmTimesliceManager::SetTransparency(Bool_t use_xml, Int_t trans)
150{
151 if (use_xml == kFALSE) {
152 // high transparency
153 Int_t vis_level = gGeoManager->GetVisLevel();
154 TGeoNode* top = gGeoManager->GetTopNode();
155 SetTransparencyForLayer(top, vis_level, trans);
156 }
157 else {
158 // normal transparency
159 if (fXMLConfig != "") { //
161 }
162 else {
163 Int_t vis_level = gGeoManager->GetVisLevel();
164 TGeoNode* top = gGeoManager->GetTopNode();
165 SetTransparencyForLayer(top, vis_level, 0);
166 }
167 }
168 if (gEve->GetGlobalScene()->GetRnrState()) {
169 gEve->GetGlobalScene()->SetRnrState(kFALSE);
170 gEve->GetGlobalScene()->SetRnrState(kTRUE);
171 gEve->Redraw3D();
172 }
173}
174
176{
178 gEve->GetViewers()->SwitchColorSet();
179}
180
182{
184 TList* taskList = FairRunAna::Instance()->GetMainTask()->GetListOfTasks();
185
187 for (TObject* task : *taskList) {
188 if (nullptr != dynamic_cast<CbmTimesliceRecoTracks*>(task)) {
189 dynamic_cast<CbmTimesliceRecoTracks*>(task)->SwitchPdgColorTrack(pdg_color);
190 }
191 }
192}
193
194void CbmTimesliceManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
195{
196 TEveManager::Create();
197 fRunAna->Init();
198
199 if (!InitializeMainView(visopt, vislvl, maxvisnds)) {
200 LOG(fatal) << "CbmTimesliceManager::Init() => Failed main view initialization";
201 }
202
203 if (fbMcbmViewersEna) { //
205 }
206 else {
208 }
209
210 fCbmEvents = dynamic_cast<TClonesArray*>(FairRootManager::Instance()->GetObject("CbmEvent"));
211
212 if (nullptr == fCbmEvents) {
213 LOG(fatal) << "CbmTimesliceManager::Init() => CbmEvents branch not found! Task will be deactivated";
214 }
215}
216
221
223{
224 if (fPDGToColor.find(pdg) != fPDGToColor.end()) { //
225 return fPDGToColor[pdg];
226 }
227 return 0;
228}
229
231{
232 fTimesliceIdx = event;
234 FairRunAna::Instance()->Run(static_cast<Long64_t>(fTimesliceIdx));
235}
236
238{
240
242 int NbEventsInTs = 0;
243 while (NbEventsInTs == 0) {
245 NbEventsInTs = fCbmEvents->GetEntriesFast();
246 }
247 LOG(debug) << "Display TS " << GetCurrentTimeslice() << " with " << NbEventsInTs << " events";
252}
253
261
263{
264 fEventIdx = event;
265
266 CbmEvent* pEvent = dynamic_cast<CbmEvent*>(fCbmEvents->At(fEventIdx));
267 Int_t nofTofTracks = pEvent->GetNofData(ECbmDataType::kTofTracklet);
268 LOG(debug) << GetName() << " : Ts_nofTofTracks " << nofTofTracks << " in event " << fEventIdx;
269
271 TList* taskList = FairRunAna::Instance()->GetMainTask()->GetListOfTasks();
272
274 for (TObject* task : *taskList) {
275 if (nullptr != dynamic_cast<CbmTimesliceRecoTracks*>(task)) {
276 dynamic_cast<CbmTimesliceRecoTracks*>(task)->GotoEvent(event);
277 }
278 else if (nullptr != dynamic_cast<CbmTimeslicePixelHitSetDraw*>(task)) {
279 LOG(debug) << GetName() << ": call " << task->GetName();
280 dynamic_cast<CbmTimeslicePixelHitSetDraw*>(task)->GotoEvent(event);
281 }
282 else if (nullptr != dynamic_cast<CbmTsPointSetArrayDraw*>(task)) {
283 LOG(debug) << GetName() << ": call " << task->GetName();
284 //dynamic_cast<CbmTsPointSetArrayDraw*>(task)->GotoEvent(event); // FIXME: does not work yet
285 }
286 else if (nullptr != dynamic_cast<CbmTsDisTofTracklets*>(task)) {
287 LOG(debug) << GetName() << ": call " << task->GetName();
288 dynamic_cast<CbmTsDisTofTracklets*>(task)->GotoEvent(event);
289 }
290 }
291}
292
300
308
310{
311 fTimeTimeslice = FairRootManager::Instance()->GetEventTime();
312 return fTimeTimeslice;
313}
314
316{
317 const CbmEvent* event = dynamic_cast<const CbmEvent*>(fCbmEvents->At(fEventIdx));
318 fTimeEvent = event->GetTzero();
319 return fTimeEvent;
320}
321
323{
324 TString stime;
325 stime.Form("TS Time: %.2f", time);
326 stime += " ns";
327 fTimesliceTimeText->SetText(stime);
328}
329
331{
332 TString text = "TS: ";
333 text += evtNumber;
334 fTimesliceNumberText->SetText(text);
335}
336
338{
339 TString stime;
340 stime.Form("Event Time: %.2f", time);
341 stime += " ns";
342 fEventTimeText->SetText(stime);
343}
344
346{
347 TString text = "Event: ";
348 text += evtNumber;
349 fEventNumberText->SetText(text);
350}
351
353{
354 TString filename;
355 if (path == "") {
356 const char* filetypes[] = {"PNG", "*.png", "JPG", "*.jpg", 0, 0};
357 TGFileInfo fi;
358 fi.fFileTypes = filetypes;
359 fi.fIniDir = StrDup(".");
360 new TGFileDialog(gClient->GetRoot(), gEve->GetMainWindow(), kFDSave, &fi);
361 if (fi.fFilename == nullptr) { //
362 return;
363 }
364 filename = fi.fFilename;
365 }
366 else {
367 filename = path;
368 }
369
370 if (fbMcbmViewersEna) {
371 switch (screenshotType) {
373 gEve->GetDefaultGLViewer()->SavePicture(filename);
374 break;
375 }
377 TGLViewer* gl = fViewZX->GetGLViewer();
378 gl->SavePicture(filename);
379 break;
380 }
382 TGLViewer* gl = fViewZY->GetGLViewer();
383 gl->SavePicture(filename);
384 break;
385 }
387 TString filename_path = filename(0, filename.Last('.'));
388 TString filename_ext = filename(filename.Last('.') + 1, 3);
389 TString filename3d = Form("%s_3d.%s", filename_path.Data(), filename_ext.Data());
390 TString filenameZY = Form("%s_ZY.%s", filename_path.Data(), filename_ext.Data());
391 TString filenameZX = Form("%s_ZX.%s", filename_path.Data(), filename_ext.Data());
392 gEve->GetDefaultGLViewer()->SavePicture(filename3d);
393 TGLViewer* gl = fViewZY->GetGLViewer();
394 gl->SavePicture(filenameZY);
395 gl = fViewZX->GetGLViewer();
396 gl->SavePicture(filenameZX);
397 break;
398 }
399 default:
401 break;
402 }
403 }
404 else {
405 switch (screenshotType) {
407 gEve->GetDefaultGLViewer()->SavePicture(filename);
408 break;
409 }
411 TGLViewer* gl = fRPhiView->GetGLViewer();
412 gl->SavePicture(filename);
413 break;
414 }
416 TGLViewer* gl = fRhoZView->GetGLViewer();
417 gl->SavePicture(filename);
418 break;
419 }
421 TString filename_path = filename(0, filename.Last('.'));
422 TString filename_ext = filename(filename.Last('.') + 1, 3);
423 TString filename3d = Form("%s_3d.%s", filename_path.Data(), filename_ext.Data());
424 TString filenameRphi = Form("%s_XY.%s", filename_path.Data(), filename_ext.Data());
425 TString filenameRhoz = Form("%s_Z.%s", filename_path.Data(), filename_ext.Data());
426 gEve->GetDefaultGLViewer()->SavePicture(filename3d);
427 TGLViewer* gl = fRPhiView->GetGLViewer();
428 gl->SavePicture(filenameRphi);
429 gl = fRhoZView->GetGLViewer();
430 gl->SavePicture(filenameRhoz);
431 break;
432 }
433 default:
435 break;
436 }
437 }
438}
439// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
440
441// ++++++++++++++++++++++++++++++++++++++++++++ Protected +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
443{
445 FairXMLFile xmlfile(fXMLConfig, "read");
446 FairXMLNode* xml = xmlfile.GetRootNode();
447 for (int i = 0; i < xml->GetNChildren(); i++) {
448 TString nodename = xml->GetChild(i)->GetName();
449 if (nodename.EqualTo("Detectors")) {
450 TGeoNode* top = gGeoManager->GetTopNode();
451 FairXMLNode* top_xml = xml->GetChild(i)->GetChild(0);
452 if (top_xml != nullptr) { //
453 LoadXMLDetector(top, top_xml);
454 }
455 }
456 else if (nodename.EqualTo("MCTracksColors")) {
457 FairXMLNode* colors = xml->GetChild(i);
458 for (int j = 0; j < colors->GetNChildren(); j++) {
459 FairXMLNode* color = colors->GetChild(j);
460 TString pgd_code = color->GetAttrib("pdg")->GetValue();
461 TString color_code = color->GetAttrib("color")->GetValue();
462 //fPDGToColor[pgd_code.Atoi()] = StringToColor(color_code);
463 }
464 }
465 }
466 if (gEve->GetGlobalScene()->GetRnrState()) {
467 gEve->GetGlobalScene()->SetRnrState(kFALSE);
468 gEve->GetGlobalScene()->SetRnrState(kTRUE);
469 gEve->Redraw3D();
470 }
471}
472
473void CbmTimesliceManager::LoadXMLDetector(TGeoNode* node, FairXMLNode* xml, Int_t depth)
474{
476 TString name = xml->GetAttrib("name")->GetValue();
477 TString node_name = node->GetName();
478 Bool_t recursive = (xml->GetAttrib("recursive")->GetValue().Length() != 0 && !name.EqualTo(node_name));
479 if (recursive && depth == 0) { //
480 return;
481 }
482 TString transparency = xml->GetAttrib("transparency")->GetValue();
483 TString color = xml->GetAttrib("color")->GetValue();
484 TString visibility = xml->GetAttrib("visibility")->GetValue();
485 TString recursive_val = xml->GetAttrib("recursive")->GetValue();
486 if (!recursive && "0" != recursive_val) { //
487 LOG(info) << "LoadXMLDetector called for " << node_name;
488 }
489 if (!color.EqualTo("")) {
490 node->GetVolume()->SetFillColor(StringToColor(color));
491 node->GetVolume()->SetLineColor(StringToColor(color));
492 }
493 if (!transparency.EqualTo("")) { //
494 node->GetVolume()->SetTransparency((Char_t)(transparency.Atoi()));
495 }
496 if (!visibility.EqualTo("")) {
497 bool bVisVal = (0 < visibility.Atoi());
498 node->SetVisibility(bVisVal); // Declared as deprecated in the ROOT documentation, but needed for real invisibility
499 node->GetVolume()->SetVisibility(bVisVal);
500 if (!recursive) { //
501 LOG(info) << "Setting " << node_name << (bVisVal ? " Visible" : " Invisible") //
502 << ("0" != recursive_val ? " and its daughters also" : "");
503 }
504 }
505 if (recursive_val.Length() > 0) {
506 Int_t xml_depth = recursive_val.Atoi();
507 /*
509 if (recursive) {
510 xml_depth = depth - 1;
511 }
512 */
513 if (0 < xml_depth) {
514 for (int i = 0; i < node->GetNdaughters(); i++) {
515 TGeoNode* daughter_node = node->GetDaughter(i);
516 LoadXMLDetector(daughter_node, xml, xml_depth);
517 }
518 }
519 }
520 if (xml->GetNChildren() > 0 && !recursive) {
521 for (int i = 0; i < node->GetNdaughters(); i++) {
522 TString subdetector_name = node->GetDaughter(i)->GetName();
523 for (int j = 0; j < xml->GetNChildren(); j++) {
524 FairXMLNode* subnode = xml->GetChild(j);
525 TString subnode_name = subnode->GetAttrib("name")->GetValue();
526 if (subnode_name == subdetector_name) { //
527 LoadXMLDetector(node->GetDaughter(i), subnode);
528 }
529 }
530 }
531 }
532}
533
534Int_t CbmTimesliceManager::StringToColor(TString color) const
535{
536 if (color.Contains("k")) {
537 Int_t plus_index = color.First('+');
538 Int_t minus_index = color.First('-');
539 Int_t cut = plus_index;
540 if (cut == -1) { //
541 cut = minus_index;
542 }
543 if (cut == -1) { //
544 cut = color.Length();
545 }
546 TString col_name(color(0, cut));
547 Int_t col_val = 0;
548 if (col_name.EqualTo("kWhite")) { //
549 col_val = 0;
550 }
551 else if (col_name.EqualTo("kBlack")) {
552 col_val = 1;
553 }
554 else if (col_name.EqualTo("kGray")) {
555 col_val = 920;
556 }
557 else if (col_name.EqualTo("kRed")) {
558 col_val = 632;
559 }
560 else if (col_name.EqualTo("kGreen")) {
561 col_val = 416;
562 }
563 else if (col_name.EqualTo("kBlue")) {
564 col_val = 600;
565 }
566 else if (col_name.EqualTo("kYellow")) {
567 col_val = 400;
568 }
569 else if (col_name.EqualTo("kMagenta")) {
570 col_val = 616;
571 }
572 else if (col_name.EqualTo("kCyan")) {
573 col_val = 432;
574 }
575 else if (col_name.EqualTo("kOrange")) {
576 col_val = 800;
577 }
578 else if (col_name.EqualTo("kSpring")) {
579 col_val = 820;
580 }
581 else if (col_name.EqualTo("kTeal")) {
582 col_val = 840;
583 }
584 else if (col_name.EqualTo("kAzure")) {
585 col_val = 860;
586 }
587 else if (col_name.EqualTo("kViolet")) {
588 col_val = 880;
589 }
590 else if (col_name.EqualTo("kPink")) {
591 col_val = 900;
592 }
593 TString col_num(color(cut + 1, color.Length()));
594 if (col_num.Length() > 0) { //
595 if (color.Contains("+")) { //
596 col_val += col_num.Atoi();
597 }
598 else {
599 col_val -= col_num.Atoi();
600 }
601 }
602 return col_val;
603 }
604 else {
605 return color.Atoi();
606 }
607}
608// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
609
610// +++++++++++++++++++++++++++++++++++++++++++++ Private ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
612{
613 // Add particles to the PDG data base
614 TDatabasePDG* pdgDB = TDatabasePDG::Instance();
615
616 const Double_t kAu2Gev = 0.9314943228;
617 const Double_t khSlash = 1.0545726663e-27;
618 const Double_t kErg2Gev = 1 / 1.6021773349e-3;
619 const Double_t khShGev = khSlash * kErg2Gev;
620 const Double_t kYear2Sec = 3600 * 24 * 365.25;
621
622 // Ions
623 if (!pdgDB->GetParticle(1000010020)) { //
624 pdgDB->AddParticle("Deuteron", "Deuteron", 2 * kAu2Gev + 8.071e-3, kTRUE, 0, 3, "Ion", 1000010020);
625 }
626
627 if (!pdgDB->GetParticle(1000010030)) { //
628 pdgDB->AddParticle("Triton", "Triton", 3 * kAu2Gev + 14.931e-3, kFALSE, khShGev / (12.33 * kYear2Sec), 3, "Ion",
629 1000010030);
630 }
631
632 if (!pdgDB->GetParticle(1000020040)) { //
633 pdgDB->AddParticle("Alpha", "Alpha", 4 * kAu2Gev + 2.424e-3, kTRUE, khShGev / (12.33 * kYear2Sec), 6, "Ion",
634 1000020040);
635 }
636
637 if (!pdgDB->GetParticle(1000020030)) { //
638 pdgDB->AddParticle("He3", "He3", 3 * kAu2Gev + 14.931e-3, kFALSE, 0, 6, "Ion", 1000020030);
639 }
640
641 // Special particles
642 if (!pdgDB->GetParticle(50000050)) { //
643 pdgDB->AddParticle("Cherenkov", "Cherenkov", 0, kFALSE, 0, 0, "Special", 50000050);
644 }
645
646 if (!pdgDB->GetParticle(50000051)) { //
647 pdgDB->AddParticle("FeedbackPhoton", "FeedbackPhoton", 0, kFALSE, 0, 0, "Special", 50000051);
648 }
649}
650
652{
653 fPDGToColor[22] = 623; // photon
654 fPDGToColor[-2112] = 2; // anti-neutron
655 fPDGToColor[-11] = 3; // e+
656 fPDGToColor[-3122] = 4; // anti-lambda
657 fPDGToColor[11] = 5; // e-
658 fPDGToColor[-3222] = 6; // Sigma -
659 fPDGToColor[12] = 7; // e-neutrino
660 fPDGToColor[-3212] = 8; // Sigma0
661 fPDGToColor[-13] = 9; // mu+
662 fPDGToColor[-3112] = 10; // Sigma+ (PB
663 fPDGToColor[13] = 11; // mu-
664 fPDGToColor[-3322] = 12; // Xi0
665 fPDGToColor[111] = 13; // pi0
666 fPDGToColor[-3312] = 14; // Xi+
667 fPDGToColor[211] = 15; // pi+
668 fPDGToColor[-3334] = 16; // Omega+ (PB)
669 fPDGToColor[-211] = 17; // pi-
670 fPDGToColor[-15] = 18; // tau+
671 fPDGToColor[130] = 19; // K long
672 fPDGToColor[15] = 20; // tau -
673 fPDGToColor[321] = 21; // K+
674 fPDGToColor[411] = 22; // D+
675 fPDGToColor[-321] = 23; // K-
676 fPDGToColor[-411] = 24; // D-
677 fPDGToColor[2112] = 25; // n
678 fPDGToColor[421] = 26; // D0
679 fPDGToColor[2212] = 27; // p
680 fPDGToColor[-421] = 28; // D0
681 fPDGToColor[-2212] = 29; // anti-proton
682 fPDGToColor[431] = 30; // Ds+
683 fPDGToColor[310] = 31; // K short
684 fPDGToColor[-431] = 32; // anti Ds-
685 fPDGToColor[221] = 33; // eta
686 fPDGToColor[4122] = 34; // Lambda_C+
687 fPDGToColor[3122] = 35; // Lambda
688 fPDGToColor[24] = 36; // W+
689 fPDGToColor[3222] = 37; // Sigma+
690 fPDGToColor[-24] = 38; // W-
691 fPDGToColor[3212] = 39; // Sigma0
692 fPDGToColor[23] = 40; // Z
693 fPDGToColor[3112] = 41; // Sigma -
694 fPDGToColor[3322] = 42; // Xi0
695 fPDGToColor[3312] = 43; // Xi-
696 fPDGToColor[3334] = 44; // Omega- (PB)
697
698 fPDGToColor[50000050] = 801; // Cerenkov
699
700 fPDGToColor[1000010020] = 45; // PAL 31/05/2023: ???
701 fPDGToColor[1000010030] = 48; // PAL 31/05/2023: ???
702 fPDGToColor[1000020040] = 50; // PAL 31/05/2023: ???
703 fPDGToColor[1000020030] = 55; // PAL 31/05/2023: ???
704}
705
706void CbmTimesliceManager::SetTransparencyForLayer(TGeoNode* node, Int_t depth, Char_t transparency)
707{
708 node->GetVolume()->SetTransparency(transparency);
709 if (depth <= 0) { //
710 return;
711 }
712 for (int i = 0; i < node->GetNdaughters(); i++) {
713 TGeoNode* dau = node->GetDaughter(i);
714 SetTransparencyForLayer(dau, depth - 1, transparency);
715 }
716}
717
718bool CbmTimesliceManager::InitializeMainView(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
719{
720 if (gGeoManager == nullptr) { //
721 return false;
722 }
723 TGeoNode* N = gGeoManager->GetTopNode();
724 TEveGeoTopNode* TNod = new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds);
725
726 if (!fXMLConfig.EqualTo("")) { //
728 }
729
730 gEve->AddGlobalElement(TNod);
731
732 gEve->FullRedraw3D(kTRUE);
733 fEvent = gEve->AddEvent(this);
734
735 fTimesliceNumberText = new TGLAnnotation(gEve->GetDefaultGLViewer(), "TS Number: ", 0.01, 0.94);
736 fTimesliceNumberText->SetTextSize(0.03); // % of window diagonal
737 fTimesliceNumberText->SetTextColor(kOrange - 2);
738
739 fTimesliceTimeText = new TGLAnnotation(gEve->GetDefaultGLViewer(), "TS Time: ", 0.01, 0.90);
740 fTimesliceTimeText->SetTextSize(0.03); // % of window diagonal
741 fTimesliceTimeText->SetTextColor(kOrange - 2);
742
743 fEventNumberText = new TGLAnnotation(gEve->GetDefaultGLViewer(), "Event Number: ", 0.01, 0.86);
744 fEventNumberText->SetTextSize(0.03); // % of window diagonal
745 fEventNumberText->SetTextColor(kOrange - 2);
746
747 fEventTimeText = new TGLAnnotation(gEve->GetDefaultGLViewer(), "Event Time: ", 0.01, 0.82);
748 fEventTimeText->SetTextSize(0.03); // % of window diagonal
749 fEventTimeText->SetTextColor(kOrange - 2);
750
751 return true;
752}
753
755{
756 fRPhiProjManager = new TEveProjectionManager(TEveProjection::kPT_RPhi);
757 fRhoZProjManager = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
758 gEve->AddToListTree(fRPhiProjManager, kFALSE);
759 gEve->AddToListTree(fRhoZProjManager, kFALSE);
760 fAxesPhi = new TEveProjectionAxes(fRPhiProjManager);
761 fAxesRho = new TEveProjectionAxes(fRhoZProjManager);
762
763 fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
764 fRPhiScene = gEve->SpawnNewScene("RPhi", "Scene holding axis.");
765 fRPhiScene->AddElement(fAxesPhi);
766
767 fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
768 fRhoZScene = gEve->SpawnNewScene("RhoZ", "Scene holding axis.");
769 fRhoZScene->AddElement(fAxesRho);
770
772
773 TEveWindowSlot* MultiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
774 TEveWindowPack* MultiPack = MultiSlot->MakePack();
775 MultiPack->SetElementName("Multi View");
776 MultiPack->SetHorizontal();
777 MultiPack->SetShowTitleBar(kFALSE);
778 MultiPack->NewSlot()->MakeCurrent();
779 fMultiView = gEve->SpawnNewViewer("3D View (multi)", "");
780 // switch off left and right light sources for 3D MultiView
781 // TODO: investigate and tune which light source directions should be used for best visibility
782 fMultiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
783 fMultiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
784 // add 3D scenes (first tab) to 3D MultiView
785 fMultiView->AddScene(gEve->GetGlobalScene());
786 fMultiView->AddScene(gEve->GetEventScene());
787
788 // add slot for RPhi projection on Multi View tab
789 MultiPack = MultiPack->NewSlot()->MakePack();
790 MultiPack->SetShowTitleBar(kFALSE);
791 MultiPack->NewSlot()->MakeCurrent();
792 fMultiRPhiView = gEve->SpawnNewViewer("RPhi View (multi)", "");
793 MultiPack->NewSlot()->MakeCurrent();
794 fMultiRhoZView = gEve->SpawnNewViewer("RhoZ View (multi)", "");
795
797
798 // don't change reposition camera on each update
799 fRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
800 fRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
801 fMultiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
802 fMultiRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
803 fMultiRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
804 fMultiView->GetEveFrame()->HideAllDecorations();
805 fMultiRPhiView->GetEveFrame()->HideAllDecorations();
806 fMultiRhoZView->GetEveFrame()->HideAllDecorations();
807}
808
809void CbmTimesliceManager::SetViewers(TEveViewer* RPhi, TEveViewer* RhoZ)
810{
811 RPhi->GetGLViewer()->SetCurrentCamera(fRphiCam);
812 // set camera parameters
813 RPhi->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
814 RPhi->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
815 // switch off left, right, top and bottom light sources
816 // TODO: investigate and tune which light source directions should be used for best visibility
817 RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
818 RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
819 RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightTop, false);
820 RPhi->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightBottom, false);
821
822 RhoZ->GetGLViewer()->SetCurrentCamera(fRhoCam);
823 // set camera parameters
824 RhoZ->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
825 RhoZ->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
826 // switch off left, right and front light sources
827 // TODO: investigate and tune which light source directions should be used for best visibility
828 RhoZ->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
829 RhoZ->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
830 RhoZ->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightFront, false);
831
832 RPhi->AddScene(fRPhiScene);
833 RPhi->AddScene(gEve->GetGlobalScene());
834 RPhi->AddScene(gEve->GetEventScene());
835 RhoZ->AddScene(fRhoZScene);
836 RhoZ->AddScene(gEve->GetGlobalScene());
837 RhoZ->AddScene(gEve->GetEventScene());
838}
839
841{
842 // FIXME: available only starting from Fairsoft apr22 (did not check in which ROOT version it was introduced)
843 //fProjManagerZY = new TEveProjectionManager(TEveProjection::kPT_ZY);
844 fProjManagerZY = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
845 //fProjManagerZX = new TEveProjectionManager(TEveProjection::kPT_ZX);
846 fProjManagerZX = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
847 gEve->AddToListTree(fProjManagerZY, kFALSE);
848 gEve->AddToListTree(fProjManagerZX, kFALSE);
849 fAxesZY = new TEveProjectionAxes(fProjManagerZY);
850 fAxesZX = new TEveProjectionAxes(fProjManagerZX);
851
852 fViewZY = gEve->SpawnNewViewer("ZY View", "");
853 fSceneZY = gEve->SpawnNewScene("ZY", "Scene holding axis.");
854 fSceneZY->AddElement(fAxesZY);
855
856 fViewZX = gEve->SpawnNewViewer("ZX View", "");
857 fSceneZX = gEve->SpawnNewScene("ZX", "Scene holding axis.");
858 fSceneZX->AddElement(fAxesZX);
859
861
862 TEveWindowSlot* McbmSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
863 TEveWindowPack* McbmPack = McbmSlot->MakePack();
864 McbmPack->SetElementName("mCBM View");
865 McbmPack->SetHorizontal();
866 McbmPack->SetShowTitleBar(kFALSE);
867 McbmPack->NewSlot()->MakeCurrent();
868 fMcbmView = gEve->SpawnNewViewer("3D View (multi)", "");
869 // switch off left and right light sources for 3D MultiView
870 // TODO: investigate and tune which light source directions should be used for best visibility
871 //fMcbmView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
872 //fMcbmView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
873 // add 3D scenes (first tab) to 3D MultiView
874 fMcbmView->AddScene(gEve->GetGlobalScene());
875 fMcbmView->AddScene(gEve->GetEventScene());
876 // Center the 3D MultiView
877 fMcbmView->GetGLViewer()->CurrentCamera().SetCenterVecWarp(0.0, 0.0, 150.0);
878
879 // add slot for XY projection on Multi View tab
880 McbmPack = McbmPack->NewSlot()->MakePack();
881 McbmPack->SetShowTitleBar(kFALSE);
882 McbmPack->NewSlot()->MakeCurrent();
883 fMcbmViewZY = gEve->SpawnNewViewer("ZY View (multi)", "");
884 McbmPack->NewSlot()->MakeCurrent();
885 fMcbmViewZX = gEve->SpawnNewViewer("ZX View (multi)", "");
886
888
889 // don't change reposition camera on each update
890 fViewZY->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
891 fViewZX->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
892 fMcbmView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
893 fMcbmViewZY->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
894 fMcbmViewZX->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
895 fMcbmView->GetEveFrame()->HideAllDecorations();
896 fMcbmViewZY->GetEveFrame()->HideAllDecorations();
897 fMcbmViewZX->GetEveFrame()->HideAllDecorations();
898
899 // Set clear background
900 fViewZY->GetGLViewer()->SetClearColor(kYellow - 10);
901 fViewZX->GetGLViewer()->SetClearColor(kYellow - 10);
902 fMcbmView->GetGLViewer()->SetClearColor(kYellow - 10);
903 fMcbmViewZY->GetGLViewer()->SetClearColor(kYellow - 10);
904 fMcbmViewZX->GetGLViewer()->SetClearColor(kYellow - 10);
905}
906
907void CbmTimesliceManager::SetMcbmViewers(TEveViewer* ZY, TEveViewer* ZX)
908{
909 ZY->GetGLViewer()->SetCurrentCamera(fCamZY);
910 // set camera parameters
911 ZY->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
912 ZY->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
913 // switch off left, right and front light sources
914 // TODO: investigate and tune which light source directions should be used for best visibility
915 ZY->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
916 //ZY->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
917 ZY->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightFront, false);
918 // Set Camera Center
919 ZY->GetGLViewer()->CurrentCamera().SetCenterVecWarp(0.0, 0.0, 150.0);
920
921 ZY->AddScene(fSceneZY);
922 ZY->AddScene(gEve->GetGlobalScene());
923 ZY->AddScene(gEve->GetEventScene());
924
925 ZX->GetGLViewer()->SetCurrentCamera(fCamZX);
926 // set camera parameters
927 ZX->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
928 ZX->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
929 // switch off left, right, top and bottom light sources
930 // TODO: investigate and tune which light source directions should be used for best visibility
931 ZX->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
932 //ZX->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
933 ZX->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightTop, false);
934 ZX->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightBottom, false);
935 // Set Camera Center
936 ZX->GetGLViewer()->CurrentCamera().SetCenterVecWarp(0.0, 0.0, 150.0);
937
938 ZX->AddScene(fSceneZX);
939 ZX->AddScene(gEve->GetGlobalScene());
940 ZX->AddScene(gEve->GetEventScene());
941}
942// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
943
ClassImp(CbmConverterManager)
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
size_t GetNofData() const
Definition CbmEvent.cxx:58
double GetTzero() const
Definition CbmEvent.h:146
TBrowser Event display for Timeslices as Tree entry with CbmEvents in container. Function as unique I...
void SetMcbmViewers(TEveViewer *ZY, TEveViewer *ZX)
TEveProjectionAxes * fAxesZX
void LoadXMLDetector(TGeoNode *node, FairXMLNode *xml, Int_t depth=0)
void SetDisplayMcbm(bool bLowRate=true, bool bMuch=false)
Select/add default set of views and some Hit and Tracks drawing classes for the mCBM 2022+ setups.
FairRootManager * fRootManager
Int_t StringToColor(TString color) const
TEveViewer * fRPhiView
CBM views.
TGLAnnotation * fTimesliceNumberText
virtual void GotoTimeslice(uint32_t timeslice)
TEveProjectionAxes * fAxesRho
TEveProjectionManager * fProjManagerZY
virtual void SetEvtNumberText(Int_t evtNumber)
TGLAnnotation * fEventTimeText
void SwitchPdgColorTrack(Bool_t pdg_color)
TGLViewer::ECameraType fCamZX
TGLAnnotation * fEventNumberText
bool InitializeMainView(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
void SetTransparencyForLayer(TGeoNode *node, Int_t depth, Char_t transparency)
virtual uint32_t GetCurrentTimeslice() const
void SetDisplayCbmMuon()
Select/add default set of views and some Hit and Tracks drawing classes for the CBM SIS100 muon setup...
TEveProjectionManager * fRhoZProjManager
bool fbMcbmViewersEna
mCBM views
virtual Int_t Color(Int_t pdg)
virtual void SwitchBackground(Bool_t)
TEveProjectionManager * fRPhiProjManager
void SetDisplayTofCosmicsHd()
Select/add default set of views and some Hit and Tracks drawing classes for the HD 2023+ cosmics setu...
virtual Int_t GetCurrentEvent() const
TEveProjectionManager * fProjManagerZX
TGLViewer::ECameraType fCamZY
void SetDisplayCbmElectron()
Select/add default set of views and some Hit and Tracks drawing classes for the CBM SIS100 electron s...
void AddTask(FairTask *t)
virtual void SetTsNumberText(Int_t tsNumber)
virtual void GotoEvent(Int_t event)
void SetViewers(TEveViewer *RPhi, TEveViewer *RhoZ)
virtual void SetEvtTimeText(Double_t time)
virtual void SetTransparency(Bool_t use_xml, Int_t trans)
static CbmTimesliceManager * gRinstanceTsMan
static CbmTimesliceManager * Instance()
TGLViewer::ECameraType fRhoCam
double_t GetTimesliceTime()
current time in ns to display in the event display.
virtual void Init(Int_t visopt=1, Int_t vislvl=3, Int_t maxvisnds=10000)
TGLViewer::ECameraType fRphiCam
TEveProjectionAxes * fAxesPhi
void MakeScreenshot(CbmTsEveAnimationControl::eScreenshotType screenshotType, TString def_path="")
Screenshot(s) generation: to be called by GUI element.
double_t GetEventTime()
current time in ns to display in the event display.
std::map< int, int > fPDGToColor
virtual void SetTsTimeText(Double_t time)
TEveProjectionAxes * fAxesZY
TGLAnnotation * fTimesliceTimeText
Interface class to add Cbm Hits drawing (derived from PixelHit) to CbmTimesliceManager....