DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Calo2DProjection.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include <DDEve/Calo2DProjection.h>
16 #include <DDEve/Annotation.h>
17 #include <DDEve/Factories.h>
18 #include <DD4hep/InstanceCount.h>
19 
20 // Root include files
21 #include <TEveCalo.h>
22 #include <TEveScene.h>
23 #include <TGLViewer.h>
24 #include <TEveArrow.h>
25 
26 using namespace dd4hep;
27 
30 
31 Calo2DProjection::Calo2DProjection(Display* eve, const std::string& nam)
33 : Projection(eve, nam)
34 {
35  InstanceCount::increment(this);
36 }
37 
39 Calo2DProjection::~Calo2DProjection() {
41 }
42 
49  return Map(slot);
50 }
51 
54  DisplayConfiguration::Configurations::const_iterator fit;
55  DisplayConfiguration::Configurations::const_reverse_iterator rit;
57  for(fit = config.subdetectors.begin(); fit != config.subdetectors.end(); ++fit) {
58  const DisplayConfiguration::Config& cfg = *fit;
60  TEveElementList& sens = m_eve->GetGeoTopic("Sensitive");
61  TEveElementList& struc = m_eve->GetGeoTopic("Structure");
62  for(TEveElementList::List_i i=sens.BeginChildren(); i!=sens.EndChildren(); ++i) {
63  TEveElementList* ll = dynamic_cast<TEveElementList*>(*i);
64  if ( ll && cfg.name == ll->GetName() ) {
65  m_projMgr->ImportElements(*i,m_geoScene);
66  goto Done;
67  }
68  }
69  for(TEveElementList::List_i i=struc.BeginChildren(); i!=struc.EndChildren(); ++i) {
70  TEveElementList* ll = dynamic_cast<TEveElementList*>(*i);
71  if ( ll && cfg.name == ll->GetName() ) {
72  m_projMgr->ImportElements(*i,m_geoScene);
73  goto Done;
74  }
75  }
76  Done:
77  continue;
78  }
79  }
80  float depth = 0.0;
81  for(rit = config.subdetectors.rbegin(); rit != config.subdetectors.rend(); ++rit) {
82  const DisplayConfiguration::Config& cfg = *rit;
83  if ( cfg.type == DisplayConfiguration::CALODATA && cfg.use.empty() ) {
84  const char* n = cfg.name.c_str();
86  const DisplayConfiguration::Calo3D& calo3d = ctx.config.data.calo3d;
87  TEveCalo2D* calo2d = (TEveCalo2D*)m_projMgr->ImportElements(ctx.calo3D,m_geoScene);
88  calo2d->SetPlotEt(kFALSE);
89  calo2d->SetDepth(depth += 1.0);
90  calo2d->SetAutoRange(kTRUE);
91  calo2d->SetScaleAbs(kTRUE);
92  calo2d->SetMainColor(calo3d.color);
93  calo2d->SetMaxValAbs(calo3d.emax); // In GeV
94  calo2d->SetMaxTowerH(calo3d.towerH); // In GeV
95  calo2d->SetBarrelRadius(calo3d.rmin);
96  calo2d->SetEndCapPos(calo3d.dz);
97  calo2d->InvalidateCellIdCache();
98  calo2d->AssertCellIdCache();
99  calo2d->ComputeBBox();
100  Color_t col = ctx.calo3D->GetDataSliceColor(ctx.slice);
101  Annotation* a = new Annotation(viewer(),n,Annotation::DefaultMargin(),legend_y,col);
102 #if 0
103  // Tries to add a line indicating the echelle of the energy deposit
104  TEveArrow* a1 = new TEveArrow(100,100, 100,0., 0., 0.);
105  a1->SetMainColor(calo3d.color);
106  a1->SetTubeR(10);
107  a1->SetPickable(kFALSE);
108  m_projMgr->ImportElements(a1,m_geoScene);
109 #endif
110  legend_y += a->GetTextSize();
111  printout(INFO,"Calo2DProjection","+++ %s: add detector %s [%s] rmin=%f towerH:%f emax=%f",
112  name().c_str(),n,ctx.config.hits.c_str(),calo3d.rmin,calo3d.towerH,
113  calo3d.emax);
114  }
115  }
116 }
117 
120  this->View::ConfigureEvent(config);
121 }
122 
124 void Calo2DProjection::ImportGeoTopics(const std::string& /* title */) {
125 }
dd4hep::Display
The main class of the DDEve display.
Definition: Display.h:56
dd4hep::DisplayConfiguration::Calo3D::rmin
float rmin
Definition: DisplayConfiguration.h:64
dd4hep::View::m_eve
Display * m_eve
Definition: View.h:49
DECLARE_VIEW_FACTORY
#define DECLARE_VIEW_FACTORY(x)
Definition: Factories.h:30
dd4hep::Annotation::DefaultTextSize
static float DefaultTextSize()
Default text size.
Definition: Annotation.cpp:50
dd4hep::Display::CalodataContext::calo3D
TEveCalo3D * calo3D
Definition: Display.h:70
dd4hep::Display::GetGeoTopic
virtual TEveElementList & GetGeoTopic(const std::string &name)
Access/Create an geometry topic by name.
Definition: Display.cpp:465
dd4hep::DisplayConfiguration::Config::data
union dd4hep::DisplayConfiguration::Config::Values data
dd4hep::Calo2DProjection::Build
virtual View & Build(TEveWindow *slot) override
Build the projection view and map it to the given slot.
Definition: Calo2DProjection.cpp:44
dd4hep::DisplayConfiguration::Calo3D
Configuration class for 3D calorimeter display.
Definition: DisplayConfiguration.h:63
dd4hep::DisplayConfiguration::ViewConfig::subdetectors
Configurations subdetectors
Definition: DisplayConfiguration.h:122
Factories.h
dd4hep::Calo2DProjection::ConfigureGeometry
virtual void ConfigureGeometry(const DisplayConfiguration::ViewConfig &config) override
Configure a single geometry view.
Definition: Calo2DProjection.cpp:53
dd4hep::Projection::AddAxis
virtual Projection & AddAxis()
Add projection axis to the view.
Definition: Projection.cpp:83
dd4hep::Calo2DProjection::ImportGeoTopics
void ImportGeoTopics(const std::string &title) override
Call to import geometry topics.
Definition: Calo2DProjection.cpp:124
dd4hep::Projection
class Projection Projection.h DDEve/Projection.h
Definition: Projection.h:32
dd4hep::DisplayConfiguration::Defaults::color
int color
Definition: DisplayConfiguration.h:58
TEveElementList
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:13
dd4hep::View::name
const std::string & name() const
Access to the view name/title.
Definition: View.h:81
dd4hep::Display::CalodataContext::slice
int slice
Definition: Display.h:69
dd4hep::Display::GetCaloHistogram
CalodataContext & GetCaloHistogram(const std::string &name)
Access to calo data histograms by name as defined in the configuration.
Definition: Display.cpp:196
dd4hep::View::AddToGlobalItems
virtual TEveElementList * AddToGlobalItems(const std::string &nam)
Add the view to the global list of eve objects.
Definition: View.cpp:81
slot
View TEveWindowSlot * slot
Definition: MultiView.cpp:28
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::View::CreateGeoScene
virtual View & CreateGeoScene()
Create the geometry scene.
Definition: View.cpp:324
dd4hep::View::CreateEventScene
virtual View & CreateEventScene()
Create the event scene.
Definition: View.cpp:314
dd4hep::Annotation::DefaultMargin
static float DefaultMargin()
Default margin for placement in bottom left corner.
Definition: Annotation.cpp:54
dd4hep::DisplayConfiguration::Calo3D::dz
float dz
Definition: DisplayConfiguration.h:64
dd4hep::Display::CalodataContext::config
DisplayConfiguration::Config config
Definition: Display.h:73
dd4hep::View::m_geoScene
TEveScene * m_geoScene
Reference to the geometry scene.
Definition: View.h:53
dd4hep::View::viewer
TEveViewer * viewer() const
Access to the Eve viewer.
Definition: View.h:84
dd4hep::DisplayConfiguration::Config
Container with full display configuration.
Definition: DisplayConfiguration.h:92
dd4hep::DisplayConfiguration::CALODATA
@ CALODATA
Definition: DisplayConfiguration.h:46
dd4hep::DisplayConfiguration::Config::Values::calo3d
Calo3D calo3d
Definition: DisplayConfiguration.h:98
dd4hep::DisplayConfiguration::DETELEMENT
@ DETELEMENT
Definition: DisplayConfiguration.h:47
dd4hep::DisplayConfiguration::Config::name
std::string name
Definition: DisplayConfiguration.h:103
dd4hep::DisplayConfiguration::ViewConfig
View configuration.
Definition: DisplayConfiguration.h:119
dd4hep::Annotation
Class to add annotations to eve viewers.
Definition: Annotation.h:34
dd4hep::Projection::Map
virtual View & Map(TEveWindow *slot) override
Map the projection view to the slot.
Definition: Projection.cpp:115
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::Projection::CreateRhoPhiProjection
virtual Projection & CreateRhoPhiProjection()
Create Rho-Phi projection.
Definition: Projection.cpp:97
dd4hep::DisplayConfiguration::Calo3D::emax
float emax
Definition: DisplayConfiguration.h:64
dd4hep::View
class View View.h DDEve/View.h
Definition: View.h:45
dd4hep::Projection::m_projMgr
TEveProjectionManager * m_projMgr
Reference to the projection manager.
Definition: Projection.h:35
dd4hep::DisplayConfiguration::Config::hits
std::string hits
Definition: DisplayConfiguration.h:104
dd4hep::Display::CalodataContext
Calorimeter data context for the DDEve event display.
Definition: Display.h:68
dd4hep::Calo2DProjection::Calo2DProjection
Calo2DProjection(Display *eve, const std::string &name)
Initializing constructor.
Calo2DProjection.h
InstanceCount.h
dd4hep::DisplayConfiguration::Calo3D::towerH
float towerH
Definition: DisplayConfiguration.h:64
ClassImp
ClassImp(Calo2DProjection) Calo2DProjection
Initializing constructor.
Definition: Calo2DProjection.cpp:28
dd4hep::Calo2DProjection
2D projection operator for calorimeters
Definition: Calo2DProjection.h:35
dd4hep::Calo2DProjection::ConfigureEvent
virtual void ConfigureEvent(const DisplayConfiguration::ViewConfig &config) override
Configure a single event scene view.
Definition: Calo2DProjection.cpp:119
Annotation.h
dd4hep::DisplayConfiguration::Config::use
std::string use
Definition: DisplayConfiguration.h:105
dd4hep::View::ConfigureEvent
virtual void ConfigureEvent(const DisplayConfiguration::ViewConfig &config)
Configure a single event scene view.
Definition: View.cpp:244
dd4hep::DisplayConfiguration::Config::type
int type
Definition: DisplayConfiguration.h:106