MpdEventManager.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. //MpdEventManager: class for event management and navigation
  2. #ifndef MPDEVENTMANAGER_H
  3. #define MPDEVENTMANAGER_H
  4. #include "FairRunAna.h"
  5. #include "FairTask.h"
  6. #include "MpdXMLNode.h"
  7. #include <TEveViewer.h>
  8. #include "TEveEventManager.h"
  9. #include <TEveScene.h>
  10. #include <TGeoNode.h>
  11. #include <TEveProjectionManager.h>
  12. #include "TGListTree.h"
  13. #include <TEveProjectionAxes.h>
  14. #include <vector>
  15. using namespace std;
  16. enum ElementList {MCPointList, MCTrackList, RecoPointList, RecoTrackList}; // enum for Event Element lists
  17. class MpdEventManagerEditor;
  18. class MpdEventManager : public TEveEventManager
  19. {
  20. public:
  21. struct structSelectedColoring
  22. {
  23. TString detector_name;
  24. TString detector_color;
  25. int detector_transparency;
  26. bool isRecursiveColoring;
  27. structSelectedColoring()
  28. {
  29. }
  30. structSelectedColoring(TString det_name, TString det_color, int det_transparency, bool isRecursive)
  31. {
  32. detector_name = det_name;
  33. detector_color = det_color;
  34. detector_transparency = det_transparency;
  35. isRecursiveColoring = isRecursive;
  36. }
  37. };
  38. struct structLevelColoring
  39. {
  40. TString fill_color;
  41. bool isFillLine;
  42. bool visibility;
  43. int transparency;
  44. structLevelColoring()
  45. {
  46. }
  47. structLevelColoring(TString fill, bool isLine, bool vis, int transp)
  48. {
  49. fill_color = fill;
  50. isFillLine = isLine;
  51. visibility = vis;
  52. transparency = transp;
  53. }
  54. };
  55. static MpdEventManager* Instance();
  56. MpdEventManager();
  57. virtual ~MpdEventManager();
  58. virtual void Open();
  59. virtual void GotoEvent(Int_t event); // *MENU*
  60. virtual void NextEvent(); // *MENU*
  61. virtual void PrevEvent(); // *MENU*
  62. virtual void DisplaySettings(); // *Menu*
  63. virtual void Close();
  64. void UpdateEditor();
  65. virtual void Init(Int_t visopt = 1, Int_t vislvl = 3, Int_t maxvisnds = 10000);
  66. void SetEventEditor(MpdEventManagerEditor* event_editor) { fEventEditor = event_editor; }
  67. MpdEventManagerEditor* GetEventEditor() { return fEventEditor; }
  68. // FairRunAna to init and to execute visualization tasks
  69. FairRunAna* fRunAna; //!
  70. void AddTask(FairTask* t) { fRunAna->AddTask(t); }
  71. // assign different colors for differrent particles
  72. // return integer value of color for track by particle pdg (default, white)
  73. virtual Int_t Color(Int_t pdg);
  74. virtual void AddParticlesToPdgDataBase();
  75. virtual void SetCurrentEvent(Int_t event_number) { iCurrentEvent = event_number; }
  76. virtual Int_t GetCurrentEvent() { return iCurrentEvent; }
  77. virtual void SetPriOnly(Bool_t Pri) { fPriOnly = Pri; }
  78. virtual Bool_t IsPriOnly() { return fPriOnly; }
  79. virtual void SelectPDG(Int_t PDG) { fCurrentPDG = PDG; }
  80. virtual Int_t GetCurrentPDG() { return fCurrentPDG; }
  81. virtual void SetMaxEnergy(Float_t max) { fMaxEnergy = max; }
  82. virtual void SetMinEnergy(Float_t min) { fMinEnergy = min; }
  83. virtual void SetEvtMaxEnergy(Float_t max) { fEvtMaxEnergy = max; }
  84. virtual void SetEvtMinEnergy(Float_t min) { fEvtMinEnergy = min; }
  85. virtual Float_t GetEvtMaxEnergy() { return fEvtMaxEnergy; }
  86. virtual Float_t GetEvtMinEnergy() { return fEvtMinEnergy; }
  87. virtual Float_t GetMaxEnergy() { return fMaxEnergy; }
  88. virtual Float_t GetMinEnergy() { return fMinEnergy; }
  89. TEveScene* GetRPhiScene() { return fRPhiGeomScene; }
  90. TEveScene* GetRhoZScene() { return fRhoZGeomScene; }
  91. virtual void SetRPhiPlane(Double_t a, Double_t b, Double_t c, Double_t d)
  92. { fRPhiPlane[0] = a; fRPhiPlane[1] = b; fRPhiPlane[2] = c; fRPhiPlane[3] = d; }
  93. virtual void SetRhoZPlane(Double_t a, Double_t b, Double_t c, Double_t d)
  94. { fRhoZPlane[0] = a; fRhoZPlane[1] = b; fRhoZPlane[2] = c; fRhoZPlane[3] = d; }
  95. // Event Elements of Event Scene
  96. TEveElementList* EveMCPoints, *EveMCTracks, *EveRecoPoints, *EveRecoTracks;
  97. void AddEventElement(TEveElement* element, ElementList element_list);
  98. // coloring method
  99. enum VisualizationColoring {selectedColoring, levelColoring, defaultColoring};
  100. VisualizationColoring gVisualizationColoring;
  101. // set high transparency for detector geometry
  102. void SetTransparentGeometry(bool is_on);
  103. virtual void SetXMLConfig(TString xml_config) { fXMLConfig = xml_config; }
  104. // background color of EVE Viewers
  105. int background_color;
  106. // whether background color is dark
  107. bool isDarkColor;
  108. // whether Online of Offline mode
  109. bool isOnline;
  110. // data source: 0 - simulation data; 1 - raw detector data
  111. int iDataSource;
  112. // ZDC module visibility flags. NULL if there are no ZDC modules to show
  113. bool* isZDCModule; //!
  114. // current value of "reco points" checkbox - FOR CALORIMETER TOWERS
  115. bool fgShowRecoPointsIsShow;
  116. // require event redraw after "reco points" checkbox value is changed - FOR CALORIMETER TOWERS
  117. bool fgRedrawRecoPointsReqired;
  118. protected:
  119. TEveViewer* GetRPhiView() const { return fRPhiView; }
  120. TEveViewer* GetRhoZView() const { return fRhoZView; }
  121. TEveViewer* GetMultiView() const { return fMulti3DView; }
  122. TEveViewer* GetMultiRPhiView() const { return fMultiRPhiView; }
  123. TEveViewer* GetMultiRhoZView() const { return fMultiRhoZView; }
  124. TEveProjectionManager* GetRhoZProjManager() const { return fRhoZMng; }
  125. TEveProjectionManager* GetRPhiProjManager() const { return fRPhiMng; }
  126. TEveProjectionAxes* GetRPhiAxes() const { return fAxesPhi; }
  127. TEveProjectionAxes* GetRhoZAxes() const { return fAxesRho; }
  128. virtual void LoadXMLSettings();
  129. void LoadXMLDetector(TGeoNode *node, MpdXMLNode *xml, Int_t depth=0);
  130. private:
  131. MpdEventManagerEditor* fEventEditor; //!
  132. // skeleton Singleton Instance
  133. static MpdEventManager* fgRinstance; //!
  134. MpdEventManager(const MpdEventManager&);
  135. MpdEventManager& operator=(const MpdEventManager&);
  136. // VIEWERS for RPhi and RPhoZ projections, 3D view in multi-viewer, RPhi and RPhoZ projections in multi-viewer
  137. TEveViewer *fRPhiView, *fRhoZView, *fMulti3DView, *fMultiRPhiView, *fMultiRhoZView;
  138. // projection managers for RPhi and Rho views
  139. TEveProjectionManager *fRPhiMng, *fRhoZMng;
  140. // scenes for geometry presentation in RPhi plane and RPhoZ plane
  141. TEveScene *fRPhiGeomScene, *fRhoZGeomScene;
  142. TEveProjectionAxes *fAxesPhi, *fAxesRho;
  143. Double_t fRPhiPlane[4]; Double_t fRhoZPlane[4];
  144. TGListTreeItem* fEvent; //!
  145. // current event number
  146. Int_t iCurrentEvent;
  147. Bool_t fPriOnly;
  148. Int_t fCurrentPDG;
  149. // the most minimum particle energy for selected event
  150. Float_t fMinEnergy;
  151. // the most maximum particle energy for selected event
  152. Float_t fMaxEnergy;
  153. // minimum energy to cut particles by energy in selected event
  154. Float_t fEvtMinEnergy;
  155. // maximum energy to cut particles by energy in selected event
  156. Float_t fEvtMaxEnergy;
  157. // the last color indice of Color Creating from rgb triple
  158. Int_t fLastUsedColor;
  159. TString fXMLConfig;
  160. map<int,int> fPDGToColor;
  161. // arrays with color sturctures for detector and hierarchical coloring
  162. vector<structSelectedColoring*> vecSelectedColoring; //!
  163. vector<structLevelColoring*> vecLevelColoring; //!
  164. void SetViewers(TEveViewer* RPhi, TEveViewer* RhoZ);
  165. // changing color and visibility of geometry nodes
  166. void InitColorStructure();
  167. // get color id by color name or RGB triple
  168. Int_t StringToColor(TString color);
  169. // returns loaded xml if successful of NULL if validation failed
  170. bool ValidateXml(const char *XMLFileName, const char *XSDFileName);
  171. void LevelChangeNodeProperty(TGeoNode* node, int level);
  172. void SelectedGeometryColoring();
  173. void RecursiveChangeNodeProperty(TGeoNode* parentNode, Int_t color, int transparency);
  174. void RecursiveChangeNodeTransparent(TGeoNode* parentNode, int transparency);
  175. ClassDef(MpdEventManager,1);
  176. };
  177. #endif