DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Calo2DProjection.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DDEve/Calo2DProjection.h"
17 #include "DDEve/Annotation.h"
18 #include "DDEve/Factories.h"
19 #include "DD4hep/InstanceCount.h"
20 
21 // Root include files
22 #include "TEveCalo.h"
23 #include "TEveScene.h"
24 #include "TGLViewer.h"
25 #include "TEveArrow.h"
26 
27 using namespace std;
28 using namespace DD4hep;
29 
32 
34 Calo2DProjection::Calo2DProjection(Display* eve, const std::string& nam)
35 : Projection(eve, nam)
36 {
37  InstanceCount::increment(this);
38 }
39 
41 Calo2DProjection::~Calo2DProjection() {
42  InstanceCount::decrement(this);
43 }
44 
46 View& Calo2DProjection::Build(TEveWindow* slot) {
47  CreateGeoScene();
48  CreateEventScene();
49  CreateRhoPhiProjection().AddAxis();
50  AddToGlobalItems(name());
51  return Map(slot);
52 }
53 
55 void Calo2DProjection::ConfigureGeometry(const DisplayConfiguration::ViewConfig& config) {
56  DisplayConfiguration::Configurations::const_iterator fit;
57  DisplayConfiguration::Configurations::const_reverse_iterator rit;
58  float legend_y = Annotation::DefaultTextSize()+Annotation::DefaultMargin();
59  for(fit = config.subdetectors.begin(); fit != config.subdetectors.end(); ++fit) {
60  const DisplayConfiguration::Config& cfg = *fit;
61  if ( cfg.type == DisplayConfiguration::DETELEMENT ) {
62  TEveElementList& sens = m_eve->GetGeoTopic("Sensitive");
63  TEveElementList& struc = m_eve->GetGeoTopic("Structure");
64  for(TEveElementList::List_i i=sens.BeginChildren(); i!=sens.EndChildren(); ++i) {
65  TEveElementList* ll = dynamic_cast<TEveElementList*>(*i);
66  if ( ll && cfg.name == ll->GetName() ) {
67  m_projMgr->ImportElements(*i,m_geoScene);
68  goto Done;
69  }
70  }
71  for(TEveElementList::List_i i=struc.BeginChildren(); i!=struc.EndChildren(); ++i) {
72  TEveElementList* ll = dynamic_cast<TEveElementList*>(*i);
73  if ( ll && cfg.name == ll->GetName() ) {
74  m_projMgr->ImportElements(*i,m_geoScene);
75  goto Done;
76  }
77  }
78  Done:
79  continue;
80  }
81  }
82  float depth = 0.0;
83  for(rit = config.subdetectors.rbegin(); rit != config.subdetectors.rend(); ++rit) {
84  const DisplayConfiguration::Config& cfg = *rit;
85  if ( cfg.type == DisplayConfiguration::CALODATA && cfg.use.empty() ) {
86  const char* n = cfg.name.c_str();
87  const Display::CalodataContext& ctx = m_eve->GetCaloHistogram(cfg.name);
88  const DisplayConfiguration::Calo3D& calo3d = ctx.config.data.calo3d;
89  TEveCalo2D* calo2d = (TEveCalo2D*)m_projMgr->ImportElements(ctx.calo3D,m_geoScene);
90  calo2d->SetPlotEt(kFALSE);
91  calo2d->SetDepth(depth += 1.0);
92  calo2d->SetAutoRange(kTRUE);
93  calo2d->SetScaleAbs(kTRUE);
94  calo2d->SetMainColor(calo3d.color);
95  calo2d->SetMaxValAbs(calo3d.emax); // In GeV
96  calo2d->SetMaxTowerH(calo3d.towerH); // In GeV
97  calo2d->SetBarrelRadius(calo3d.rmin);
98  calo2d->SetEndCapPos(calo3d.dz);
99  calo2d->InvalidateCellIdCache();
100  calo2d->AssertCellIdCache();
101  calo2d->ComputeBBox();
102  Color_t col = ctx.calo3D->GetDataSliceColor(ctx.slice);
103  Annotation* a = new Annotation(viewer(),n,Annotation::DefaultMargin(),legend_y,col);
104 #if 0
105  // Tries to add a line indicating the echelle of the energy deposit
106  TEveArrow* a1 = new TEveArrow(100,100, 100,0., 0., 0.);
107  a1->SetMainColor(calo3d.color);
108  a1->SetTubeR(10);
109  a1->SetPickable(kFALSE);
110  m_projMgr->ImportElements(a1,m_geoScene);
111 #endif
112  legend_y += a->GetTextSize();
113  printout(INFO,"Calo2DProjection","+++ %s: add detector %s [%s] rmin=%f towerH:%f emax=%f",
114  name().c_str(),n,ctx.config.hits.c_str(),calo3d.rmin,calo3d.towerH,
115  calo3d.emax);
116  }
117  }
118 }
119 
121 void Calo2DProjection::ConfigureEvent(const DisplayConfiguration::ViewConfig& config) {
122  this->View::ConfigureEvent(config);
123 }
124 
126 void Calo2DProjection::ImportGeoTopics(const string& /* title */) {
127 }
#define DECLARE_VIEW_FACTORY(x)
Definition: Factories.h:31
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:10
DisplayConfiguration::Config config
Definition: Display.h:73
union DD4hep::DisplayConfiguration::Config::Values data
View TEveWindowSlot * slot
Definition: MultiView.cpp:30
class View View.h DDEve/View.h
Definition: View.h:46
class Projection Projection.h DDEve/Projection.h
Definition: Projection.h:33
ClassImp(Calo2DProjection) Calo2DProjection
Initializing constructor.
2D projection operator for calorimeters
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
Definition: Printout.cpp:111
The main class of the DDEve display.
Definition: Display.h:57
Class to add annotations to eve viewers.
Definition: Annotation.h:35