Public Member Functions | Private Attributes | List of all members
EDep::TG4HitChangeHandler Class Reference

Handle drawing the GEANT4 (truth) hits. More...

#include <TG4HitChangeHandler.hxx>

Inheritance diagram for EDep::TG4HitChangeHandler:
EDep::TVEventChangeHandler

Public Member Functions

 TG4HitChangeHandler ()
 
 ~TG4HitChangeHandler ()
 
virtual void Apply ()
 Draw the trajectories into the current scene. More...
 
- Public Member Functions inherited from EDep::TVEventChangeHandler
 TVEventChangeHandler ()
 
virtual ~TVEventChangeHandler ()
 

Private Attributes

TEveElementList * fG4HitList
 The GEANT4 hits to draw in the event. More...
 

Detailed Description

Handle drawing the GEANT4 (truth) hits.

Definition at line 13 of file TG4HitChangeHandler.hxx.

Constructor & Destructor Documentation

EDep::TG4HitChangeHandler::TG4HitChangeHandler ( )

Definition at line 17 of file TG4HitChangeHandler.cxx.

17  {
18  fG4HitList = new TEveElementList("g4HitList","Geant4 Truth Hits");
19  fG4HitList->SetMainColor(kCyan);
20  fG4HitList->SetMainAlpha(1.0);
21  gEve->AddElement(fG4HitList);
22 }
TEveElementList * fG4HitList
The GEANT4 hits to draw in the event.
EDep::TG4HitChangeHandler::~TG4HitChangeHandler ( )

Definition at line 24 of file TG4HitChangeHandler.cxx.

24  {
25 }

Member Function Documentation

void EDep::TG4HitChangeHandler::Apply ( )
virtual

Draw the trajectories into the current scene.

Implements EDep::TVEventChangeHandler.

Definition at line 27 of file TG4HitChangeHandler.cxx.

27  {
28 
29  fG4HitList->DestroyElements();
30 
31  if (!EDep::TEventDisplay::Get().GUI().GetShowG4HitsButton()->IsOn()) {
32  std::cout << "G4 hits disabled" << std::endl;
33  return;
34  }
35 
36  std::cout << "Handle the geant4 truth hits" << std::endl;
37  if (!gEDepSimEvent) return;
38 
39  double minEnergy = 0.18;
40  double maxEnergy = 3.0;
41 
44  detector != gEDepSimEvent->SegmentDetectors.end();
45  ++detector) {
46  std::cout << "Show hits for " << detector->first
47  << " (" << detector->second.size() << " hits)"<< std::endl;
48  TEveElementList* hitList
49  = new TEveElementList(
50  detector->first.c_str(),
51  ("Energy Deposit for " + detector->first).c_str());
52  for (TG4HitSegmentContainer::iterator g4Hit = detector->second.begin();
53  g4Hit != detector->second.end();
54  ++g4Hit) {
55  double energy = g4Hit->GetEnergyDeposit();
56  double length = g4Hit->GetTrackLength();
57  double dEdX = energy;
58  if (length>0.01) dEdX /= length;
59 
60  int contrib = g4Hit->Contrib.front();
61  std::string particle = gEDepSimEvent->Trajectories[contrib].GetName();
62 
63  TEveLine* eveHit = new TEveLine(2);
64  eveHit->SetName(detector->first.c_str());
65  std::ostringstream title;
66  title << "Hit(" << particle << ")";
67  title << std::fixed << std::setprecision(1)
68  << " " << dEdX*1000.0 << " keV/mm";
69  title << " for " << length << " mm"
70  << " at (" << g4Hit->GetStart().X() << " mm"
71  << "," << g4Hit->GetStart().Y() << " mm"
72  << "," << g4Hit->GetStart().Z() << " mm"
73  << ")";
74 
75  eveHit->SetTitle(title.str().c_str());
76  eveHit->SetLineWidth(5);
77  eveHit->SetLineColor(TEventDisplay::Get().LogColor(
78  dEdX,
79  minEnergy,
80  maxEnergy,
81  3));
82  eveHit->SetPoint(0,
83  g4Hit->GetStart().X(),
84  g4Hit->GetStart().Y(),
85  g4Hit->GetStart().Z());
86  eveHit->SetPoint(1,
87  g4Hit->GetStop().X(),
88  g4Hit->GetStop().Y(),
89  g4Hit->GetStop().Z());
90  hitList->AddElement(eveHit);
91  }
92  fG4HitList->AddElement(hitList);
93  }
94 
95 }
intermediate_table::iterator iterator
std::string string
Definition: nybbler.cc:12
TG4TrajectoryContainer Trajectories
Definition: TG4Event.h:35
TEveElementList * fG4HitList
The GEANT4 hits to draw in the event.
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
double dEdX(double KE, const simb::MCParticle *part)
TG4HitSegmentDetectors SegmentDetectors
Definition: TG4Event.h:39
static TEventDisplay & Get(void)
TG4Event * gEDepSimEvent
The event being displayed.
QTextStream & endl(QTextStream &s)

Member Data Documentation

TEveElementList* EDep::TG4HitChangeHandler::fG4HitList
private

The GEANT4 hits to draw in the event.

Definition at line 24 of file TG4HitChangeHandler.hxx.


The documentation for this class was generated from the following files: