GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseEventDisplay.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
24 #ifndef Gw_BaseEventDisplay
25 #include "BaseEventDisplay.h"
26 #endif
27 
28 #ifndef ROOT_TGeoManager
29 #include "TGeoManager.h"
30 #endif
31 
32 #ifndef ROOT_TGeoVolume
33 #include "TGeoVolume.h"
34 #endif
35 
36 #ifndef ROOT_TMath
37 #include "TMath.h"
38 #endif
39 
40 using namespace Gw;
41 
42 //
44 
45 Bool_t BaseEventDisplay::fgIsGeoLoaded = false;
46 Bool_t BaseEventDisplay::fgIsDisplayed = false;
47 
48 //__________________________________________________________
50  : TEveEventManager(),
51  fCurrentEventId(0),
52  fFirstEventDone(false),
53  fMaxEnergy(4000),
54  fLog("BaseEventDisplay")
55 {
56  // default constructor
57 
58 }
59 
60 //__________________________________________________________
62 {
63  // default destructor
64 }
65 
66 //__________________________________________________________
67 void BaseEventDisplay::LoadGeometry(const Char_t* fileName)
68 {
69  if (fgIsGeoLoaded)
70  return;
71 
72  if ( !TGeoManager::Import(fileName) ) {
73  fLog.SetProcessMethod("LoadGeometry(const Char_t* )");
74  fLog << error << "Failed to load geometry" << nline;
75  }
76  fgIsGeoLoaded = true;
77 }
78 
79 //__________________________________________________________
80 void BaseEventDisplay::AddGeometry(TGeoVolume* volume, TGeoMatrix* transf)
81 {
82  fLog.SetProcessMethod("AddGeometry(TGeoVolume*, const Char_t* )");
83 
84  static Int_t nb = 0;
85  TObjArray* list = fTopVolume->GetNodes();
86  if (list) {
87  for (Int_t i = 0; i < list->GetEntries(); ++i) {
88  TGeoNode* vol = (TGeoNode*)list->At(i);
89  TString volName(vol->GetName());
90  if (volName.Contains(volume->GetName())) {
91  fLog << warning << Form("Geometry of %s already loaded",volume->GetName()) << dolog;
92  return;
93  }
94  }
95  }
96 
97  fTopVolume->AddNode(volume, nb++, transf);
98  fLog << dolog;
99 }
100 
101 //__________________________________________________________
102 void BaseEventDisplay::SetTransparency(Char_t transparency)
103 {
104  // refresh must be done by user
105  if (!gGeoManager)
106  return;
107  TObjArray* list = gGeoManager->GetListOfVolumes();
108  if (!list) return;
109  for (Int_t i = 0; i < list->GetEntries(); ++i) {
110  TGeoVolume* vol = (TGeoVolume*)list->At(i);
111  vol->SetTransparency(transparency);
112  }
113 }
void Import(TString Incl="*", TString Excl="*.samp", TString DefaultPath="")
*/
Definition: SpecViewer.C:48
LogMessage & error(LogMessage &)
LogMessage & warning(LogMessage &)
BaseEventDisplay base class to work on event display.
static Bool_t fgIsGeoLoaded
LogMessage & nline(LogMessage &)
LogMessage & dolog(LogMessage &)
virtual void LoadGeometry(const Char_t *fileName)
virtual void AddGeometry(TGeoVolume *volume, TGeoMatrix *matrix=gGeoIdentity)
ClassImp(BaseNucleus)
virtual void SetProcessMethod(const char *)
To set the current method.
virtual void SetTransparency(Char_t transparency=50)