DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
HitActors.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/HitActors.h>
16 #include <DD4hep/Objects.h>
17 #include <DD4hep/DD4hepUnits.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 dd4hep;
27 
28 #ifdef DD4HEP_USE_GEANT4_UNITS
29 #define MM_2_CM 1.0
30 #define MEV_TO_GEV 1000.0
31 #else
32 #define MM_2_CM 0.1
33 #define MEV_TO_GEV 1.0
34 #endif
35 
38  const Position pos(hit.x/MM_2_CM,hit.y/MM_2_CM,hit.z/MM_2_CM);
39  histogram->Fill(pos.Eta(),pos.Phi(),hit.deposit);
40 }
41 
43 PointsetCreator::PointsetCreator(const std::string& collection, size_t length)
44 {
45  pointset = new TEvePointSet(collection.c_str(),length);
46  pointset->SetMarkerSize(0.2);
47 }
48 
50 PointsetCreator::PointsetCreator(const std::string& collection, size_t length, const DisplayConfiguration::Config& cfg)
51 {
52  pointset = new TEvePointSet(collection.c_str(),length);
53  pointset->SetMarkerSize(cfg.data.hits.size);
54  pointset->SetMarkerStyle(cfg.data.hits.type);
55  //pointset->SetMarkerAlpha(cfg.data.hits.alpha);
56  pointset->SetMainColor(cfg.data.hits.color);
58 }
60 TEveElement* PointsetCreator::element() const {
61  return pointset;
62 }
63 
66  if ( pointset ) {
67  pointset->SetTitle(Form("Hit collection:\n"
68  "Container%s\n"
69  "with %d hits\n"
70  "total deposit:%.3f GeV",
71  pointset->GetName(), count, deposit));
72  }
73 }
74 
77  if ( hit.deposit > threshold ) {
78  deposit += hit.deposit;
79  pointset->SetPoint(count++, hit.x*MM_2_CM, hit.y*MM_2_CM, hit.z*MM_2_CM);
80  }
81 }
82 
84 BoxsetCreator::BoxsetCreator(const std::string& collection, size_t /*length */, const DisplayConfiguration::Config& cfg)
85 {
86  emax = cfg.data.hits.emax;
87  towerH = cfg.data.hits.towerH;
88  boxset = new TEveBoxSet(collection.c_str());
89  boxset->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64);
90  boxset->SetMainTransparency(0);
91  boxset->SetMainColor(cfg.data.hits.color);
92  boxset->SetRenderMode(TEveBoxSet::kRM_Fill);
93  boxset->CSCApplyMainColorToAllChildren();
94  boxset->CSCApplyMainTransparencyToAllChildren();
95 }
96 
98 BoxsetCreator::BoxsetCreator(const std::string& collection, size_t /*length */)
99 {
100  boxset = new TEveBoxSet(collection.c_str());
101  boxset->SetMainTransparency(0);
102  boxset->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64);
103  boxset->CSCApplyMainColorToAllChildren();
104  boxset->CSCApplyMainTransparencyToAllChildren();
105 }
106 
109  if ( boxset ) {
110  boxset->SetTitle(Form("Hit collection:\n"
111  "Container%s\n"
112  "with %d hits\n"
113  "total deposit:%.3f GeV",
114  boxset->GetName(), count, deposit));
115  }
116 }
117 
119 TEveElement* BoxsetCreator::element() const {
120  return boxset;
121 }
122 
125  double ene = hit.deposit*MEV_2_GEV <= emax ? hit.deposit*MEV_2_GEV : emax;
126  TVector3 scale(ene/towerH,ene/towerH,ene/towerH);
127  std::cout << "Hit:" << ene << " deposit:" << hit.deposit << " "
128  << " emax:" << emax << " towerH:" << towerH << std::endl;
129  TVector3 p(hit.x*MM_2_CM, hit.y*MM_2_CM, hit.z*MM_2_CM);
130  double phi = p.Phi();
131  float s1X = -0.5*(scale(0)*std::sin(phi)+scale(2)*std::cos(phi));
132  float s1Y = 0.5*(scale(0)*std::cos(phi)-scale(2)*std::sin(phi));
133  float s2X = -0.5*(scale(0)*std::sin(phi)-scale(2)*std::cos(phi));
134  float s2Y = 0.5*(scale(0)*std::cos(phi)+scale(2)*std::sin(phi));
135  float s1Z = scale(1)/2.0;
136  float s2Z = s1Z;
137  float coords[24]= { float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()-s1Z),
138  float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()+s1Z),
139  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()+s2Z),
140  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()-s2Z),
141  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()-s2Z),
142  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()+s2Z),
143  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()+s1Z),
144  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()-s1Z) };
145  ++count;
146  deposit += hit.deposit*MEV_2_GEV;
147  boxset->AddBox(coords);
148  boxset->DigitColor(boxset->GetMainColor());
149 }
150 
153  double ene = hit.deposit*MEV_2_GEV <= emax ? hit.deposit*MEV_2_GEV : emax;
154  TVector3 scale(1,1,ene/towerH);
155  TVector3 p(hit.x*MM_2_CM, hit.y*MM_2_CM, hit.z*MM_2_CM);
156  double phi = p.Phi();
157  float s1X = -0.5*(scale(0)*std::sin(phi)+scale(2)*std::cos(phi));
158  float s1Y = 0.5*(scale(0)*std::cos(phi)-scale(2)*std::sin(phi));
159  float s2X = -0.5*(scale(0)*std::sin(phi)-scale(2)*std::cos(phi));
160  float s2Y = 0.5*(scale(0)*std::cos(phi)+scale(2)*std::sin(phi));
161  float s1Z = scale(1)/2.0;
162  float s2Z = s1Z;
163  p = TVector3(hit.x*MM_2_CM-s1X, hit.y*MM_2_CM-s1Y, hit.z*MM_2_CM-s1Z);
164  float coords[24]= { float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()-s1Z),
165  float(p.X()+s1X), float(p.Y()+s1Y), float(p.Z()+s1Z),
166  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()+s2Z),
167  float(p.X()-s2X), float(p.Y()-s2Y), float(p.Z()-s2Z),
168  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()-s2Z),
169  float(p.X()+s2X), float(p.Y()+s2Y), float(p.Z()+s2Z),
170  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()+s1Z),
171  float(p.X()-s1X), float(p.Y()-s1Y), float(p.Z()-s1Z) };
172  ++count;
173  deposit += hit.deposit*MEV_2_GEV;
174  boxset->AddBox(coords);
175  boxset->DigitColor(boxset->GetMainColor());
176 }
dd4hep::DDEveHit
DDEve event classes: Basic hit.
Definition: DDEveEventData.h:29
dd4hep::EtaPhiHistogramActor::histogram
TH2F * histogram
Definition: HitActors.h:36
Objects.h
dd4hep::BoxsetCreator::deposit
float deposit
Definition: HitActors.h:74
dd4hep::DisplayConfiguration::Config::Values::hits
Hits hits
Definition: DisplayConfiguration.h:101
dd4hep::PointsetCreator::deposit
float deposit
Definition: HitActors.h:52
dd4hep::PointsetCreator::element
TEveElement * element() const
Return eve element.
Definition: HitActors.cpp:60
dd4hep::DisplayConfiguration::Config::data
union dd4hep::DisplayConfiguration::Config::Values data
dd4hep::BoxsetCreator::boxset
TEveBoxSet * boxset
Definition: HitActors.h:73
MEV_2_GEV
#define MEV_2_GEV
Definition: EventHandler.h:27
dd4hep::BoxsetCreator::count
int count
Definition: HitActors.h:75
dd4hep::BoxsetCreator::operator()
virtual void operator()(const DDEveHit &hit)
Action callback of this functor:
Definition: HitActors.cpp:124
MEV_TO_GEV
#define MEV_TO_GEV
Definition: HitActors.cpp:33
dd4hep::BoxsetCreator::BoxsetCreator
BoxsetCreator(const std::string &collection, size_t length)
Standard initializing constructor.
Definition: HitActors.cpp:98
dd4hep::PointsetCreator::count
int count
Definition: HitActors.h:53
dd4hep::DisplayConfiguration::Defaults::color
int color
Definition: DisplayConfiguration.h:58
dd4hep::DisplayConfiguration::Hits::towerH
float towerH
Definition: DisplayConfiguration.h:86
dd4hep::BoxsetCreator::~BoxsetCreator
virtual ~BoxsetCreator()
Standard destructor.
Definition: HitActors.cpp:108
dd4hep::DDEveHit::x
float x
Hit position.
Definition: DDEveEventData.h:34
dd4hep::PointsetCreator::pointset
TEvePointSet * pointset
Definition: HitActors.h:50
dd4hep::DDEveHit::deposit
float deposit
Energy deposit.
Definition: DDEveEventData.h:36
dd4hep::EtaPhiHistogramActor::operator()
virtual void operator()(const DDEveHit &hit)
Action callback of this functor:
Definition: HitActors.cpp:37
dd4hep::BoxsetCreator::element
TEveElement * element() const
Return eve element.
Definition: HitActors.cpp:119
dd4hep::BoxsetCreator::emax
float emax
Definition: HitActors.h:74
dd4hep::DisplayConfiguration::Hits::type
int type
Definition: DisplayConfiguration.h:88
dd4hep::DisplayConfiguration::Hits::threshold
float threshold
Definition: DisplayConfiguration.h:85
dd4hep::DisplayConfiguration::Config
Container with full display configuration.
Definition: DisplayConfiguration.h:92
dd4hep::TowersetCreator::operator()
virtual void operator()(const DDEveHit &hit)
Action callback of this functor:
Definition: HitActors.cpp:152
dd4hep::PointsetCreator::threshold
float threshold
Definition: HitActors.h:51
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
dd4hep::DisplayConfiguration::Hits::size
float size
Definition: DisplayConfiguration.h:83
MM_2_CM
#define MM_2_CM
Definition: HitActors.cpp:32
dd4hep::DisplayConfiguration::Hits::emax
float emax
Definition: DisplayConfiguration.h:87
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::PointsetCreator::operator()
virtual void operator()(const DDEveHit &hit)
Action callback of this functor:
Definition: HitActors.cpp:76
dd4hep::DDEveHit::y
float y
Definition: DDEveEventData.h:34
dd4hep::PointsetCreator::PointsetCreator
PointsetCreator(const std::string &collection, size_t length)
Standard initializing constructor.
Definition: HitActors.cpp:43
dd4hep::DDEveHit::z
float z
Definition: DDEveEventData.h:34
dd4hep::PointsetCreator::~PointsetCreator
virtual ~PointsetCreator()
Standard destructor.
Definition: HitActors.cpp:65
DD4hepUnits.h
dd4hep::BoxsetCreator::towerH
float towerH
Definition: HitActors.h:74
HitActors.h