BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
MpdEventManager.cxx
Go to the documentation of this file.
1// MpdEventManager: class for event management and navigation.
2
3#include "MpdEventManager.h"
4
6#include "TDOMParser.h"
7#include "TDatabasePDG.h"
8#include "TEveGeoNode.h"
9#include "TEveManager.h"
10#include "TGeoManager.h"
11#include "TObjString.h"
12#include "TXMLAttr.h"
13#include "TXMLEngine.h"
14#include "TXMLNode.h"
15#include "constants.h"
16#include "nlohmann/json.hpp"
17
18#include <TColor.h>
19#include <TEveBrowser.h>
20#include <TGLCameraOverlay.h>
21#include <TGLLightSet.h>
22#include <TGLViewer.h>
23#include <cerrno>
24#include <fstream>
25#include <iostream>
26#include <sstream>
27#include <unistd.h>
28
34
35using json = nlohmann::json;
36
37// convert string with hexadecimal presentation without "0x" to integer
38int hex_string_to_int(string hex_string)
39{
40 int x;
41 stringstream stream;
42 stream << hex << hex_string;
43 stream >> x;
44 return x;
45}
46
47//______________________________________________________________________________
49 : TEveEventManager("EventManager", "")
50 , fRunAna(FairRunAna::Instance())
51 , EveMCPoints(NULL)
52 , EveMCTracks(NULL)
53 , EveRecoPoints(NULL)
54 , EveRecoTracks(NULL)
56 , isDarkColor(true)
57 , isOnline(false)
58 , iDataSource(0)
59 , isZDCModule(NULL)
60 , fgShowShowMCPoints(false)
64 , fCurrentPDG(0)
65 , fEventEditor(NULL)
66 , fRPhiView(0)
67 , fRhoZView(0)
68 , fMulti3DView(0)
71 , fRPhiMng(NULL)
72 , fRhoZMng(NULL)
75 , fAxesPhi(NULL)
76 , fAxesRho(NULL)
77 , fRPhiPlane{0, 0, 1, 0}
78 , fRhoZPlane{-1, 0, 0, 0}
79 , fEvent(0)
80 , iCurrentEvent(0)
83 , fMaxEnergyLimit(13)
84 , fMinEnergyCut(0)
85 , fMaxEnergyCut(13)
86 , fLastUsedColor(2001)
87 , fXMLConfig("")
88{
89 fgRinstance = this;
90
92
93 // set colors for particles
94 fPDGToColor[22] = 623; // photon
95 fPDGToColor[-2112] = 2; // anti-neutron
96 fPDGToColor[-11] = 3; // e+
97 fPDGToColor[-3122] = 4; // anti-lambda
98 fPDGToColor[11] = 5; // e-
99 fPDGToColor[-3222] = 6; // Sigma -
100 fPDGToColor[12] = 7; // e-neutrino
101 fPDGToColor[-3212] = 8; // Sigma0
102 fPDGToColor[-13] = 9; // mu+
103 fPDGToColor[-3112] = 10; // Sigma+ (PB
104 fPDGToColor[13] = 11; // mu-
105 fPDGToColor[-3322] = 12; // Xi0
106 fPDGToColor[111] = 13; // pi0
107 fPDGToColor[-3312] = 14; // Xi+
108 fPDGToColor[211] = 15; // pi+
109 fPDGToColor[-3334] = 16; // Omega+ (PB)
110 fPDGToColor[-211] = 17; // pi-
111 fPDGToColor[-15] = 18; // tau+
112 fPDGToColor[130] = 19; // K long
113 fPDGToColor[15] = 20; // tau -
114 fPDGToColor[321] = 21; // K+
115 fPDGToColor[411] = 22; // D+
116 fPDGToColor[-321] = 23; // K-
117 fPDGToColor[-411] = 24; // D-
118 fPDGToColor[2112] = 25; // n
119 fPDGToColor[421] = 26; // D0
120 fPDGToColor[2212] = 27; // p
121 fPDGToColor[-421] = 28; // D0
122 fPDGToColor[-2212] = 29; // anti-proton
123 fPDGToColor[431] = 30; // Ds+
124 fPDGToColor[310] = 31; // K short
125 fPDGToColor[-431] = 32; // anti Ds-
126 fPDGToColor[221] = 33; // eta
127 fPDGToColor[4122] = 34; // Lambda_C+
128 fPDGToColor[3122] = 35; // Lambda
129 fPDGToColor[24] = 36; // W+
130 fPDGToColor[3222] = 37; // Sigma+
131 fPDGToColor[-24] = 38; // W-
132 fPDGToColor[3212] = 39; // Sigma0
133 fPDGToColor[23] = 40; // Z
134 fPDGToColor[3112] = 41; // Sigma -
135 fPDGToColor[3322] = 42; // Xi0
136 fPDGToColor[3312] = 43; // Xi-
137 fPDGToColor[3334] = 44; // Omega- (PB)
138 fPDGToColor[50000050] = 801; // Cerenkov
139 fPDGToColor[1000010020] = 45;
140 fPDGToColor[1000010030] = 48;
141 fPDGToColor[1000020040] = 50;
142 fPDGToColor[1000020030] = 55;
143
145}
146
147// return integer value of color by string storing color number, RGB triple or color name (e.g. kBlue, RGB(51,63,73),
148// RGB(#0039E1)) support following MAIN COLOR NAMESET + some additional colors as examples: kWhite, kBlack, kGgray,
149// kBlue, kAzure (темно-синий), kCyan (морской волны), kTeal (бирюзовый),
150// kGreen, kSpring (светло-зеленый), kGreen+2 (темно-зеленый), kSpring+2 (темно-зеленый), kKhaki
151// kYellow, kOrange (желтый с оттенком), kOrange+2 (оранжевый кор.), kOrange+1 (светло-оранжевый кор.), kOrange+7
152// (выделенно-оранжевый) kRed, kViolet, kMagenta (бардовый), kMagenta-6 (светло-бардовый), kPink (темно-розовый)
154{
155 color = color.ReplaceAll(" ", "");
156 color.ToLower();
157
158 // check if color is a RGB triple
159 if (color.BeginsWith("rgb")) {
160 // parse RGB triple
161 if (color.Length() < 6) {
162 cout << color << " - RGB triple isn't correct. Color set to default blue" << endl;
163 return 600;
164 }
165 TString triple = color(3, color.Length() - 3);
166 triple.Remove(TString::kLeading, '(');
167 triple.Remove(TString::kTrailing, ')');
168
169 int red_rgb = -1, green_rgb = -1, blue_rgb = -1;
170 if (triple[0] == '#') {
171 if (triple.Length() < 7) {
172 cout << triple
173 << " - hex triple size after '#' isn't correct (should have 6 symbols). Color set to default blue"
174 << endl;
175 return 600;
176 }
177
178 TString str_red = triple(1, 2);
179 TString str_green = triple(3, 2);
180 TString str_blue = triple(5, 2);
181 if ((!str_red.IsHex()) || (!str_green.IsHex()) || (!str_blue.IsHex())) {
182 cout << triple << " - hex triple after '#' has not hex format. Color set to default blue" << endl;
183 return 600;
184 }
185
186 red_rgb = hex_string_to_int(str_red.Data());
187 green_rgb = hex_string_to_int(str_green.Data());
188 blue_rgb = hex_string_to_int(str_blue.Data());
189 } else {
190 TObjArray* pRGB = triple.Tokenize(",");
191 if (pRGB->GetEntriesFast() < 3) {
192 cout << triple << " - RGB string doesn't include color triple. Color set to default blue" << endl;
193 return 600;
194 }
195 red_rgb = ((TObjString*)pRGB->At(0))->GetString().Atoi();
196 green_rgb = ((TObjString*)pRGB->At(1))->GetString().Atoi();
197 blue_rgb = ((TObjString*)pRGB->At(2))->GetString().Atoi();
198 delete pRGB;
199 }
200
201 Int_t ci = fLastUsedColor++;
202 new TColor(ci, red_rgb / 255.0F, green_rgb / 255.0F, blue_rgb / 255.0F);
203 return ci;
204 }
205
206 if (color.Contains("k")) {
207 Ssiz_t sign_index = color.First('+');
208 if (sign_index == kNPOS)
209 sign_index = color.First('-');
210
211 TString color_name = "";
212 if (sign_index == kNPOS)
213 color_name = color;
214 else
215 color_name = color(0, sign_index);
216
217 Int_t color_value;
218 if (color_name.EqualTo("kwhite"))
219 color_value = 0;
220 else if (color_name.EqualTo("kblack"))
221 color_value = 1;
222 else if (color_name.EqualTo("kgray"))
223 color_value = 920;
224 else if (color_name.EqualTo("kred"))
225 color_value = 632;
226 else if (color_name.EqualTo("kgreen"))
227 color_value = 416;
228 else if (color_name.EqualTo("kblue"))
229 color_value = 600;
230 else if (color_name.EqualTo("kyellow"))
231 color_value = 400;
232 else if (color_name.EqualTo("kmagenta"))
233 color_value = 616;
234 else if (color_name.EqualTo("kcyan"))
235 color_value = 432;
236 else if (color_name.EqualTo("korange"))
237 color_value = 800;
238 else if (color_name.EqualTo("kspring"))
239 color_value = 820;
240 else if (color_name.EqualTo("kteal"))
241 color_value = 840;
242 else if (color_name.EqualTo("kazure"))
243 color_value = 860;
244 else if (color_name.EqualTo("kviolet"))
245 color_value = 880;
246 else if (color_name.EqualTo("kpink"))
247 color_value = 900;
248 else if (color_name.EqualTo("kkhaki"))
249 color_value = 403;
250 else {
251 cout << color_name << " not found. Color set to default blue" << endl;
252 color_value = 600;
253 }
254
255 if ((sign_index != kNPOS) && (color.Length() > sign_index + 2)) {
256 TString strNumber = color(sign_index + 1, color.Length() - sign_index - 1);
257 if (strNumber.IsDigit()) {
258 if (color(sign_index) == '+')
259 color_value += strNumber.Atoi();
260 else
261 color_value -= strNumber.Atoi();
262 }
263 }
264
265 return color_value;
266 } else
267 return color.Atoi();
268}
269
271{
272 auto file_path = gSystem->ExpandPathName("$VMCWORKDIR/config/eventdisplay.json");
273 ifstream file(file_path);
274 if (file.is_open()) {
275 json data;
276 file >> data;
277
278 try {
279 for (auto& particle : data["coloring"]["particles"])
280 fPDGToColor[(int)particle["pdg"]] = StringToColor((string)particle["color"]);
281 } catch (const json::type_error& e) {
282 cout << "MpdEventManager::InitColorStructure() Using default coloring for particles!" << endl;
283 }
284
285 try {
286 structSelectedColoring* selected_coloring;
287 structLevelColoring* level_coloring;
288
289 string type = data["coloring"]["type"];
290
291 if (type == "detectors") {
293
294 string scheme = data["coloring"][type]["scheme"];
295
296 for (auto& detector : data["coloring"][type][scheme]) {
297 selected_coloring = new structSelectedColoring(
298 ((string)detector["name"]), ((string)detector["color"]), detector.value("transparency", 0),
299 detector.value("isRecursiveColoring", kTRUE));
300 vecSelectedColoring.push_back(selected_coloring);
301 }
302 } else {
304
305 for (auto& level : data["coloring"][type]) {
306 level_coloring =
307 new structLevelColoring((string)level["color"], level["isFillLine"],
308 level.value("visibility", kFALSE), level.value("transparency", 0));
309 vecLevelColoring.push_back(level_coloring);
310 }
311 }
312 } catch (const json::type_error& e) {
313 cout << "MpdEventManager::InitColorStructure() Using default ROOT coloring for detectors!" << endl;
315 }
316 } else {
317 cout << "MpdEventManager::InitColorStructure() File " << file_path << "not found! Using default coloring!"
318 << endl;
320 }
321 file.close();
322}
323
324//______________________________________________________________________________
325void MpdEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
326{
328 fRunAna->Init();
329
330 if (gGeoManager == NULL)
331 return;
332 TGeoNode* N = gGeoManager->GetTopNode();
333 TEveGeoTopNode* TNod = new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds);
334
335 // change color and visibility of geometry nodes
336 if (!fXMLConfig.EqualTo(""))
338 else {
342 else
344 }
345 }
346
347 gEve->AddGlobalElement(TNod);
348 gEve->FullRedraw3D(kTRUE);
349 fEvent = gEve->AddEvent(this);
350
351 // create projection managers
354 gEve->AddToListTree(fRPhiMng, kFALSE);
355 gEve->AddToListTree(fRhoZMng, kFALSE);
356
357 // create axes for viewers
359 fAxesPhi->SetMainColor(kRed);
361 fAxesRho->SetMainColor(kRed);
362
363 // first 3D viewer
364 gEve->GetDefaultViewer()->SetElementName("3D View");
365 // display axes
366 // gEve->GetDefaultViewer()->GetGLViewer()->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0);
367 // switch off left and right light sources for first window
368 gEve->GetDefaultViewer()->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
369 gEve->GetDefaultViewer()->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
370 if (!isDarkColor)
371 gEve->GetDefaultViewer()->GetGLViewer()->UseLightColorSet();
372 gEve->GetDefaultViewer()->GetGLViewer()->SetClearColor(background_color);
373
374 // use only one View in Online mode
375 if (isOnline)
376 return;
377
378 // ADD WINDOW in EventDisplay for RPhi projection
379 TEveWindowSlot* RPhiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
380 TEveWindowPack* RPhiPack = RPhiSlot->MakePack();
381 RPhiPack->SetElementName("RPhi View");
382 RPhiPack->SetShowTitleBar(kFALSE);
383 RPhiPack->NewSlot()->MakeCurrent();
384 fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
385 // create scene holding projected geometry for the RPhi view
386 fRPhiGeomScene = gEve->SpawnNewScene("RPhi", "Scene holding geometry for RPhi.");
387 // add axes for scene of RPhi view
388 fRPhiGeomScene->AddElement(fAxesPhi);
389
390 // ADD WINDOW in EvenDisplay for RhoZ projection
391 TEveWindowSlot* RhoZSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
392 TEveWindowPack* RhoZPack = RhoZSlot->MakePack();
393 RhoZPack->SetElementName("RhoZ View");
394 RhoZPack->SetShowTitleBar(kFALSE);
395 RhoZPack->NewSlot()->MakeCurrent();
396 fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
397 // create scene holding projected geometry for the RhoZ view.
398 fRhoZGeomScene = gEve->SpawnNewScene("RhoZ", "Scene holding geometry for RhoZ.");
399 // add axes for scene of RPhoZ view
400 fRhoZGeomScene->AddElement(fAxesRho);
401
403
404 // ADD WINDOW in EvenDisplay for MultiView
405 TEveWindowSlot* MultiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
406 TEveWindowPack* MultiPack = MultiSlot->MakePack();
407 MultiPack->SetElementName("Multi View");
408 MultiPack->SetHorizontal();
409 MultiPack->SetShowTitleBar(kFALSE);
410 MultiPack->NewSlot()->MakeCurrent();
411 fMulti3DView = gEve->SpawnNewViewer("3D View (multi)", "");
412 // switch off left and right light sources for 3D MultiView
413 fMulti3DView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
414 fMulti3DView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
415 if (!isDarkColor)
416 fMulti3DView->GetGLViewer()->UseLightColorSet();
417 fMulti3DView->GetGLViewer()->SetClearColor(background_color);
418 // add 3D scenes (first tab) to 3D MultiView
419 fMulti3DView->AddScene(gEve->GetGlobalScene());
420 fMulti3DView->AddScene(gEve->GetEventScene());
421
422 // add slots for RPhi and RhoZ projections on Multi View tab
423 MultiPack = MultiPack->NewSlot()->MakePack();
424 MultiPack->SetShowTitleBar(kFALSE);
425 MultiPack->NewSlot()->MakeCurrent();
426 fMultiRPhiView = gEve->SpawnNewViewer("RPhi View (multi)", "");
427 MultiPack->NewSlot()->MakeCurrent();
428 fMultiRhoZView = gEve->SpawnNewViewer("RhoZ View (multi)", "");
429
431
432 // don't change reposition camera on each update
433 fRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
434 fRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
435 fMulti3DView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
436 fMultiRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
437 fMultiRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
438
439 // from FairRoot (not checked yet)
440 fMulti3DView->GetEveFrame()->HideAllDecorations();
441 fMultiRPhiView->GetEveFrame()->HideAllDecorations();
442 fMultiRhoZView->GetEveFrame()->HideAllDecorations();
443} // MpdEventManager::Init
444
446{
448 // set camera parameters
451 // switch off left, right, top and bottom light sources
456 if (!isDarkColor)
457 RPhi->GetGLViewer()->UseLightColorSet();
459
461 // set camera parameters
464 // switch off left, right and front light sources
468 if (!isDarkColor)
469 RhoZ->GetGLViewer()->UseLightColorSet();
471
473 RPhi->AddScene(gEve->GetGlobalScene());
474 RPhi->AddScene(gEve->GetEventScene());
476 RhoZ->AddScene(gEve->GetGlobalScene());
477 RhoZ->AddScene(gEve->GetEventScene());
478
479 // set clip planes
484}
485
486// setting of geometry colors for DETECTOR COLORING MODE
488{
489 TGeoVolume* curVolume;
490 for (size_t i = 0; i < vecSelectedColoring.size(); i++) {
491 structSelectedColoring* selected_coloring = vecSelectedColoring[i];
492 curVolume = gGeoManager->GetVolume(selected_coloring->detector_name);
493 if (!curVolume) {
494 cout << "There is no volume with given name: " << selected_coloring->detector_name << endl;
495 // delete wrong detector name from the array
497 i--;
498 continue;
499 }
500 Int_t curColor = StringToColor(selected_coloring->detector_color);
501 Int_t curTransparency = selected_coloring->detector_transparency;
502
503 curVolume->SetFillColor(curColor);
504 curVolume->SetLineColor(curColor);
505 curVolume->SetTransparency(curTransparency);
506
507 if (selected_coloring->isRecursiveColoring) {
508 for (int j = 0; j < curVolume->GetNdaughters(); j++) {
509 TGeoNode* child = curVolume->GetNode(j);
510 TGeoVolume* subVolume = child->GetVolume();
511
512 subVolume->SetFillColor(curColor);
513 subVolume->SetLineColor(curColor);
514 subVolume->SetTransparency(curTransparency);
515
516 if (child->GetNdaughters() != 0)
517 RecursiveChangeNodeProperty(child, curColor, curTransparency);
518 } // for (int j = 0; j < curVolume->GetNdaughters(); j++)
519 } // if (selected_coloring->isRecursiveColoring)
520 } // for (int i = 0; i < vecSelectedColoring.size(); i++)
521
522 return;
523}
524
526{
527 for (int i = 0; i < node->GetNdaughters(); i++) {
528 TGeoNode* child = node->GetDaughter(i);
529 TGeoVolume* curVolume = child->GetVolume();
530
531 curVolume->SetFillColor(color);
532 curVolume->SetLineColor(color);
533 curVolume->SetTransparency(transparency);
534
535 if (child->GetNdaughters() != 0)
536 RecursiveChangeNodeProperty(child, color, transparency);
537 }
538}
539
540// set transparent geometry
542{
543 switch (gVisualizationColoring) {
544 case selectedColoring: {
545 TGeoVolume* curVolume;
546 for (size_t i = 0; i < vecSelectedColoring.size(); i++) {
547 structSelectedColoring* selected_coloring = vecSelectedColoring[i];
548 curVolume = gGeoManager->GetVolume(selected_coloring->detector_name);
549 if (!curVolume) {
550 cout << "There is no volume with given name: " << selected_coloring->detector_name << endl;
551 // delete wrong detector name from the array
553 i--;
554 continue;
555 }
556
557 Int_t curTransparency = 80;
558 if (!is_on)
559 curTransparency = selected_coloring->detector_transparency;
560
561 curVolume->SetTransparency(curTransparency);
562
563 for (int j = 0; j < curVolume->GetNdaughters(); j++) {
564 TGeoNode* child = curVolume->GetNode(j);
565 TGeoVolume* subVolume = child->GetVolume();
566
567 subVolume->SetTransparency(curTransparency);
568
569 if (child->GetNdaughters() != 0)
570 RecursiveChangeNodeTransparent(child, curTransparency);
571 } // or (int j = 0; j < curVolume->GetNdaughters(); j++)
572 } // for (int i = 0; i < vecSelectedColoring.size(); i++)
573
574 break;
575 } // case selectedColoring:
576 case levelColoring: {
577 // NOT IMPLEMENTED
578 break;
579 }
580 case defaultColoring: {
581 // NOT IMPLEMENTED
582 break;
583 }
584 } // switch (gVisualizationColoring)
585
586 return;
587}
588
590{
591 for (int i = 0; i < node->GetNdaughters(); i++) {
592 TGeoNode* child = node->GetDaughter(i);
593 TGeoVolume* curVolume = child->GetVolume();
594
595 curVolume->SetTransparency(transparency);
596
597 if (child->GetNdaughters() != 0)
598 RecursiveChangeNodeTransparent(child, transparency);
599 }
600}
601
602// hierarchical changing of nodes' properties: visibility, transparency, fill color and line color
604{
605 for (Int_t i = 0; i < node->GetNdaughters(); i++) {
606 TGeoNode* child = node->GetDaughter(i);
607 if (level < vecLevelColoring.size()) {
608 TGeoVolume* curVolume = child->GetVolume();
609
610 structLevelColoring* level_coloring = vecLevelColoring[level];
611 curVolume->SetVisibility(level_coloring->visibility);
612 curVolume->SetTransparency(level_coloring->transparency);
613 curVolume->SetFillColor(StringToColor(level_coloring->fill_color));
614 if (level_coloring->isFillLine)
615 curVolume->SetLineColor(StringToColor(level_coloring->fill_color));
616
617 if (child->GetNdaughters() != 0)
618 LevelChangeNodeProperty(child, ++level);
619 } // if (level < arr_size)
620 }
621}
622
624
626
628
630
631// MpdEventManager destructor
633{
634 if (!vecSelectedColoring.empty()) {
635 for (size_t i = 0; i < vecSelectedColoring.size(); i++)
636 delete (vecSelectedColoring[i]);
637 vecSelectedColoring.clear();
638 }
639 if (!vecLevelColoring.empty()) {
640 for (size_t i = 0; i < vecLevelColoring.size(); i++)
641 delete (vecLevelColoring[i]);
642 vecLevelColoring.clear();
643 }
644}
645
646// go to FairRunAna event with given number for scene data getting
648{
649 iCurrentEvent = event;
650 fRunAna->Run((Long64_t)event);
651}
652
653// go to next FairRunAna event for scene data getting
658
659// go to previous FairRunAna event for scene data getting
664
665// assign different colors for differrent particles
666// return integer value of color for track by particle pdg (default, white)
668{
669 if (fPDGToColor.find(pdg) != fPDGToColor.end())
670 return fPDGToColor[pdg];
671
672 return 0;
673}
674
675// add particles to the PDG data base: Deuteron, Triton, Alpha, HE3; Cherenkov, FeedbackPhoton
677{
679
680 const Double_t kAu2Gev = 0.9314943228;
681 const Double_t khSlash = 1.0545726663e-27;
682 const Double_t kErg2Gev = 1 / 1.6021773349e-3;
683 const Double_t khShGev = khSlash * kErg2Gev;
684 const Double_t kYear2Sec = 3600 * 24 * 365.25;
685
686 // Ions
687 if (!pdgDB->GetParticle(1000010020))
688 pdgDB->AddParticle("Deuteron", "Deuteron", 2 * kAu2Gev + 8.071e-3, kTRUE, 0, 3, "Ion", 1000010020);
689
690 if (!pdgDB->GetParticle(1000010030))
691 pdgDB->AddParticle("Triton", "Triton", 3 * kAu2Gev + 14.931e-3, kFALSE, khShGev / (12.33 * kYear2Sec), 3, "Ion",
692 1000010030);
693
694 if (!pdgDB->GetParticle(1000020040))
695 pdgDB->AddParticle("Alpha", "Alpha", 4 * kAu2Gev + 2.424e-3, kTRUE, khShGev / (12.33 * kYear2Sec), 6, "Ion",
696 1000020040);
697
698 if (!pdgDB->GetParticle(1000020030))
699 pdgDB->AddParticle("HE3", "HE3", 3 * kAu2Gev + 14.931e-3, kFALSE, 0, 6, "Ion", 1000020030);
700
701 // Special particles
702 if (!pdgDB->GetParticle(50000050))
703 pdgDB->AddParticle("Cherenkov", "Cherenkov", 0, kFALSE, 0, 0, "Special", 50000050);
704
705 if (!pdgDB->GetParticle(50000051))
706 pdgDB->AddParticle("FeedbackPhoton", "FeedbackPhoton", 0, kFALSE, 0, 0, "Special", 50000051);
707}
708
710{
711 switch (element_list) {
712 case MCPointList: {
713 if (EveMCPoints == NULL) {
714 EveMCPoints = new TEveElementList("MC points");
715 gEve->AddElement(EveMCPoints, this);
716 EveMCPoints->SetRnrState(kFALSE);
718 }
719
720 gEve->AddElement(element, EveMCPoints);
721 break;
722 }
723 case MCTrackList: {
724 if (EveMCTracks == NULL) {
725 EveMCTracks = new TEveElementList("MC tracks");
726 gEve->AddElement(EveMCTracks, this);
727 EveMCTracks->SetRnrState(kFALSE);
729 }
730
731 gEve->AddElement(element, EveMCTracks);
732 break;
733 }
734 case RecoPointList: {
735 if (EveRecoPoints == NULL) {
736 EveRecoPoints = new TEveElementList("Reco points");
737 gEve->AddElement(EveRecoPoints, this);
738 EveRecoPoints->SetRnrState(kFALSE);
740 }
741
742 gEve->AddElement(element, EveRecoPoints);
743 break;
744 }
745 case RecoTrackList: {
746 if (EveRecoTracks == NULL) {
747 EveRecoTracks = new TEveElementList("Reco tracks");
748 gEve->AddElement(EveRecoTracks, this);
749 EveRecoTracks->SetRnrState(kFALSE);
751 }
752
753 gEve->AddElement(element, EveRecoTracks);
754 break;
755 }
756 } // switch (element_list)
757}
758
760{
761 TDOMParser* Parser = new TDOMParser();
762 Parser->SetValidate(kFALSE);
763 Parser->ParseFile(fXMLConfig);
764
765 // TXMLNode* MainNode = Parser->GetXMLDocument()->GetRootNode();
766 MpdXMLFile xmlfile(fXMLConfig, "read");
767 MpdXMLNode* xml = xmlfile.GetRootNode();
768 for (int i = 0; i < xml->GetNChildren(); i++) {
769 TString nodename = xml->GetChild(i)->GetName();
770 if (nodename.EqualTo("Detectors")) {
771 TGeoNode* top = gGeoManager->GetTopNode();
772 MpdXMLNode* top_xml = xml->GetChild(i)->GetChild(0);
773 if (top_xml != nullptr)
774 LoadXMLDetector(top, top_xml);
775 } else if (nodename.EqualTo("MCTracksColors")) {
776 MpdXMLNode* colors = xml->GetChild(i);
777 for (int j = 0; j < colors->GetNChildren(); j++) {
778 MpdXMLNode* color = colors->GetChild(j);
779 TString pgd_code = color->GetAttrib("pdg")->GetValue();
780 TString color_code = color->GetAttrib("color")->GetValue();
781 fPDGToColor[pgd_code.Atoi()] = StringToColor(color_code);
782 }
783 }
784 }
785}
786
788{
789 TString name = xml->GetAttrib("name")->GetValue();
790 TString node_name = node->GetName();
791
792 Bool_t recursive = (xml->GetAttrib("recursive")->GetValue().Length() != 0 && !name.EqualTo(node_name));
793 if (recursive && depth == 0)
794 return;
795
796 TString color = xml->GetAttrib("color")->GetValue();
797 if (!color.EqualTo("")) {
798 node->GetVolume()->SetFillColor(StringToColor(color));
799 node->GetVolume()->SetLineColor(StringToColor(color));
800 }
801
802 TString transparency = xml->GetAttrib("transparency")->GetValue();
803 if (!transparency.EqualTo(""))
804 node->GetVolume()->SetTransparency((Char_t)(transparency.Atoi()));
805
806 if (xml->GetAttrib("recursive")->GetValue().Length() > 0) {
807 TString val = xml->GetAttrib("recursive")->GetValue();
808 Int_t xml_depth = val.Atoi();
809 if (recursive)
810 xml_depth = depth - 1;
811
812 for (int i = 0; i < node->GetNdaughters(); i++) {
813 TGeoNode* daughter_node = node->GetDaughter(i);
814 LoadXMLDetector(daughter_node, xml, xml_depth);
815 }
816 }
817
818 if (xml->GetNChildren() > 0 && !recursive) {
819 for (int i = 0; i < node->GetNdaughters(); i++) {
820 TString subdetector_name = node->GetDaughter(i)->GetName();
821 for (int j = 0; j < xml->GetNChildren(); j++) {
822 MpdXMLNode* subnode = xml->GetChild(j);
823 TString subnode_name = subnode->GetAttrib("name")->GetValue();
824 if (subnode_name == subdetector_name)
825 LoadXMLDetector(node->GetDaughter(i), subnode);
826 }
827 }
828 }
829}
830
831// extend energy limits and modify sliders for energy cut if 'check_energy' is out of the limits
832void MpdEventManager::ExpandEnergyLimits(Float_t check_energy, float add_multiplier)
833{
834 if (check_energy < fMinEnergyLimit)
835 fMinEnergyLimit = check_energy;
836 if (check_energy > fMaxEnergyLimit) {
837 bool isIncreaseCut = false;
839 isIncreaseCut = true;
840 fMaxEnergyLimit = ceil(check_energy * add_multiplier);
841 if (isIncreaseCut)
843 fEventEditor->UpdateEnergySlider();
844 }
845}
int hex_string_to_int(string hex_string)
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
int Ssiz_t
char Char_t
float Float_t
constexpr Bool_t kFALSE
double Double_t
constexpr Ssiz_t kNPOS
long long Long64_t
constexpr Bool_t kTRUE
kRed
R__EXTERN TEveManager * gEve
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TSystem * gSystem
TEveElementList * EveRecoPoints
virtual void Init(Int_t visopt=1, Int_t vislvl=3, Int_t maxvisnds=10000)
static MpdEventManager * fgRinstance
vector< structLevelColoring * > vecLevelColoring
FairRunAna * fRunAna
TEveViewer * fMultiRPhiView
TEveViewer * fRPhiView
TEveProjectionManager * fRhoZMng
void LevelChangeNodeProperty(TGeoNode *node, size_t level)
virtual void NextEvent()
VisualizationColoring gVisualizationColoring
virtual void ExpandEnergyLimits(Float_t check_energy, float add_multiplier=1)
vector< structSelectedColoring * > vecSelectedColoring
static MpdEventManager * Instance()
MpdEventManagerEditor * GetEventEditor()
TEveScene * fRPhiGeomScene
TEveProjectionAxes * fAxesPhi
TEveElementList * EveRecoTracks
virtual void GotoEvent(Int_t event)
virtual Int_t Color(Int_t pdg)
virtual void Open()
TEveViewer * fMulti3DView
void SetViewers(TEveViewer *RPhi, TEveViewer *RhoZ)
MpdEventManagerEditor * fEventEditor
TEveProjectionAxes * fAxesRho
TEveElementList * EveMCTracks
TEveScene * fRhoZGeomScene
void RecursiveChangeNodeTransparent(TGeoNode *parentNode, int transparency)
virtual void Close()
map< int, int > fPDGToColor
TEveViewer * fMultiRhoZView
TGListTreeItem * fEvent
Int_t StringToColor(TString color)
void SetTransparentGeometry(bool is_on)
TEveViewer * fRhoZView
Double_t fRhoZPlane[4]
void LoadXMLDetector(TGeoNode *node, MpdXMLNode *xml, Int_t depth=0)
virtual void PrevEvent()
unordered_set< Int_t > fCurrentPDG
virtual void AddParticlesToPdgDataBase()
void AddEventElement(TEveElement *element, ElementList element_list)
TEveProjectionManager * fRPhiMng
Double_t fRPhiPlane[4]
void RecursiveChangeNodeProperty(TGeoNode *parentNode, Int_t color, int transparency)
virtual void LoadXMLSettings()
TEveElementList * EveMCPoints
virtual void DisplaySettings()
TString GetValue() const
Definition MpdXMLNode.h:43
class for opening XML files
Definition MpdXMLNode.h:153
MpdXMLNode * GetRootNode() const
Definition MpdXMLNode.h:180
class for representing XML node
Definition MpdXMLNode.h:56
MpdXMLNode * GetChild(TString name, Int_t count=0) const
search for node with given name
MpdXMLAttrib * GetAttrib(TString name) const
Int_t GetNChildren() const
Definition MpdXMLNode.h:103
virtual void SetFillColor(Color_t fcolor)
Int_t ParseFile(const char *filename) override
static TDatabasePDG * Instance()
TParticlePDG * GetParticle(const char *name) const
virtual TParticlePDG * AddParticle(const char *Name, const char *Title, Double_t Mass, Bool_t Stable, Double_t DecayWidth, Double_t Charge, const char *ParticleClass, Int_t PdgCode, Int_t Anti=-1, Int_t TrackingCode=0)
TEveElementList(const char *n="TEveElementList", const char *t="", Bool_t doColor=kFALSE, Bool_t doTransparency=kFALSE)
void SetElementName(const char *name) override
TEveEventManager(const char *n="TEveEventManager", const char *t="")
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
TGLViewer * GetGLViewer() const
virtual void AddScene(TEveScene *scene)
void SetHorizontal()
TEveWindowSlot * NewSlot() override
TEveWindowPack * MakePack()
void MakeCurrent()
static TEveWindowSlot * CreateWindowInTab(TGTab *tab, TEveWindow *eve_parent=nullptr)
void SetShowTitleBar(Bool_t x)
virtual void SetEnabled(Bool_t e=kTRUE)
void SetShowOrthographic(Bool_t x)
void SetOrthographicMode(EMode m)
void SetClipState(TGLClip::EType type, const Double_t data[6])
void SetClipType(TGLClip::EType type)
void SetLight(ELight light, Bool_t on)
TGLCameraOverlay * GetCameraOverlay() const
TGLLightSet * GetLightSet() const
void SetCurrentCamera(ECameraType camera)
TGLClipSet * GetClipSet() const
void UseLightColorSet()
void SetClearColor(Color_t col)
TGeoVolume * GetVolume() const
Int_t GetNdaughters() const
TGeoNode * GetDaughter(Int_t ind) const
void SetVisibility(Bool_t vis=kTRUE) override
Int_t GetNdaughters() const
void SetTransparency(Char_t transparency=0)
TGeoNode * GetNode(const char *name) const
void SetLineColor(Color_t lcolor) override
const char * GetName() const override
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
Ssiz_t Length() const
void ToLower()
Int_t Atoi() const
Bool_t IsHex() const
Ssiz_t First(char c) const
const char * Data() const
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
Bool_t IsDigit() const
TObjArray * Tokenize(const TString &delim) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
void SetValidate(Bool_t val=kTRUE)
RVec< PromoteType< T > > ceil(const RVec< T > &v)
ElementList
@ RecoPointList
@ MCPointList
@ MCTrackList
@ RecoTrackList
basic_json<> json
default specialization
Definition json.hpp:3365