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
HitActors.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/HitActors.h"
17 #include "DD4hep/Objects.h"
18 
19 // ROOT include files
20 #include "TH2.h"
21 #include "TVector3.h"
22 #include "TEveBoxSet.h"
23 #include "TEvePointSet.h"
24 #include "TEveCompound.h"
25 
26 using namespace std;
27 using namespace DD4hep;
28 
29 
31 void EtaPhiHistogramActor::operator()(const DDEveHit& hit) {
32  const Geometry::Position pos(hit.x/MM_2_CM,hit.y/MM_2_CM,hit.z/MM_2_CM);
33  histogram->Fill(pos.Eta(),pos.Phi(),hit.deposit);
34 }
35 
37 PointsetCreator::PointsetCreator(const std::string& collection, size_t length)
38  : pointset(0), deposit(0), count(0)
39 {
40  pointset = new TEvePointSet(collection.c_str(),length);
41  pointset->SetMarkerSize(0.2);
42 }
43 
45 PointsetCreator::PointsetCreator(const std::string& collection, size_t length, const DisplayConfiguration::Config& cfg)
46  : pointset(0), deposit(0), count(0)
47 {
48  pointset = new TEvePointSet(collection.c_str(),length);
49  pointset->SetMarkerSize(cfg.data.hits.size);
50  pointset->SetMarkerStyle(cfg.data.hits.type);
51  //pointset->SetMarkerAlpha(cfg.data.hits.alpha);
52  pointset->SetMainColor(cfg.data.hits.color);
53 }
55 TEveElement* PointsetCreator::element() const {
56  return pointset;
57 }
58 
61  if ( pointset ) {
62  pointset->SetTitle(Form("Hit collection:\n"
63  "Container%s\n"
64  "with %d hits\n"
65  "total deposit:%.3f GeV",
66  pointset->GetName(), count, deposit));
67  }
68 }
69 
72  pointset->SetPoint(count++, hit.x*MM_2_CM, hit.y*MM_2_CM, hit.z*MM_2_CM);
73 }
74 
76 BoxsetCreator::BoxsetCreator(const std::string& collection, size_t /*length */, const DisplayConfiguration::Config& cfg)
77  : boxset(0), emax(1e12), towerH(1e12), deposit(0.0), count(0)
78 {
79  emax = cfg.data.hits.emax;
80  towerH = cfg.data.hits.towerH;
81  boxset = new TEveBoxSet(collection.c_str());
82  boxset->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64);
83  boxset->SetMainTransparency(0);
84  boxset->SetMainColor(cfg.data.hits.color);
85  boxset->SetRenderMode(TEveBoxSet::kRM_Fill);
86  boxset->CSCApplyMainColorToAllChildren();
87  boxset->CSCApplyMainTransparencyToAllChildren();
88 }
89 
91 BoxsetCreator::BoxsetCreator(const std::string& collection, size_t /*length */)
92  : boxset(0), emax(1e12), towerH(1e12), deposit(0.0), count(0)
93 {
94  boxset = new TEveBoxSet(collection.c_str());
95  boxset->SetMainTransparency(0);
96  boxset->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64);
97  boxset->CSCApplyMainColorToAllChildren();
98  boxset->CSCApplyMainTransparencyToAllChildren();
99 }
100 
103  if ( boxset ) {
104  boxset->SetTitle(Form("Hit collection:\n"
105  "Container%s\n"
106  "with %d hits\n"
107  "total deposit:%.3f GeV",
108  boxset->GetName(), count, deposit));
109  }
110 }
111 
113 TEveElement* BoxsetCreator::element() const {
114  return boxset;
115 }
116 
119  double ene = hit.deposit*MEV_2_GEV <= emax ? hit.deposit*MEV_2_GEV : emax;
120  TVector3 scale(ene/towerH,ene/towerH,ene/towerH);
121  cout << "Hit:" << ene << " deposit:" << hit.deposit << " " << " emax:" << emax << " towerH:" << towerH << endl;
122  TVector3 p(hit.x*MM_2_CM, hit.y*MM_2_CM, hit.z*MM_2_CM);
123  double phi = p.Phi();
124  float s1X = -0.5*(scale(0)*std::sin(phi)+scale(2)*std::cos(phi));
125  float s1Y = 0.5*(scale(0)*std::cos(phi)-scale(2)*std::sin(phi));
126  float s2X = -0.5*(scale(0)*std::sin(phi)-scale(2)*std::cos(phi));
127  float s2Y = 0.5*(scale(0)*std::cos(phi)+scale(2)*std::sin(phi));
128  float s1Z = scale(1)/2.0;
129  float s2Z = s1Z;
130  float coords[24]= { float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()-s1Z),
131  float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()+s1Z),
132  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()+s2Z),
133  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()-s2Z),
134  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()-s2Z),
135  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()+s2Z),
136  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()+s1Z),
137  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()-s1Z) };
138  ++count;
139  deposit += hit.deposit*MEV_2_GEV;
140  boxset->AddBox(coords);
141  boxset->DigitColor(boxset->GetMainColor());
142 }
143 
146  double ene = hit.deposit*MEV_2_GEV <= emax ? hit.deposit*MEV_2_GEV : emax;
147  TVector3 scale(1,1,ene/towerH);
148  TVector3 p(hit.x*MM_2_CM, hit.y*MM_2_CM, hit.z*MM_2_CM);
149  double phi = p.Phi();
150  float s1X = -0.5*(scale(0)*std::sin(phi)+scale(2)*std::cos(phi));
151  float s1Y = 0.5*(scale(0)*std::cos(phi)-scale(2)*std::sin(phi));
152  float s2X = -0.5*(scale(0)*std::sin(phi)-scale(2)*std::cos(phi));
153  float s2Y = 0.5*(scale(0)*std::cos(phi)+scale(2)*std::sin(phi));
154  float s1Z = scale(1)/2.0;
155  float s2Z = s1Z;
156  p = TVector3(hit.x*MM_2_CM-s1X, hit.y*MM_2_CM-s1Y, hit.z*MM_2_CM-s1Z);
157  float coords[24]= { float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()-s1Z),
158  float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()+s1Z),
159  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()+s2Z),
160  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()-s2Z),
161  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()-s2Z),
162  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()+s2Z),
163  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()+s1Z),
164  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()-s1Z) };
165  ++count;
166  deposit += hit.deposit*MEV_2_GEV;
167  boxset->AddBox(coords);
168  boxset->DigitColor(boxset->GetMainColor());
169 }
virtual void operator()(const DDEveHit &hit)
Action callback of this functor:
Definition: HitActors.cpp:145
float deposit
Energy deposit.
TEveElement * element() const
Return eve element.
Definition: HitActors.cpp:113
#define MEV_2_GEV
Definition: EventHandler.h:28
virtual ~PointsetCreator()
Standard destructor.
Definition: HitActors.cpp:60
union DD4hep::DisplayConfiguration::Config::Values data
PointsetCreator(const std::string &collection, size_t length)
Standard initializing constructor.
Definition: HitActors.cpp:37
DDEve event classes: Basic hit.
TEvePointSet * pointset
Definition: HitActors.h:51
TEveElement * element() const
Return eve element.
Definition: HitActors.cpp:55
virtual void operator()(const DDEveHit &hit)
Action callback of this functor:
Definition: HitActors.cpp:71
#define MM_2_CM
Definition: Handle.h:35
TEveBoxSet * boxset
Definition: HitActors.h:73
ROOT::Math::XYZVector Position
Definition: Objects.h:75
virtual ~BoxsetCreator()
Standard destructor.
Definition: HitActors.cpp:102
virtual void operator()(const DDEveHit &hit)
Action callback of this functor:
Definition: HitActors.cpp:118
BoxsetCreator(const std::string &collection, size_t length)
Standard initializing constructor.
Definition: HitActors.cpp:91
float x
Hit position.