VMC Examples Version 6.6
Loading...
Searching...
No Matches
SensitiveDetector.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2007 - 2015 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
10/// \file TR/src/SensitiveDetector.cxx
11/// \brief Implementation of the SensitiveDetector class
12///
13/// Geant4 TestEm10 adapted to Virtual Monte Carlo.
14///
15/// \date 18/12/2015
16/// \author I. Hrivnacova; IPN, Orsay
17
18#include "SensitiveDetector.h"
19
20#include <Riostream.h>
21#include <TVirtualMC.h>
22
23/// \cond CLASSIMP
25 /// \endcond
26
27 using namespace std;
28
29namespace VMC
30{
31namespace TR
32{
33
34//_____________________________________________________________________________
36 : TNamed(name, ""), fEdep(0.), fAbsorberVolId(0), fVerboseLevel(1)
37{
38 /// Standard constructor.
39 /// \param name The sensitive detector name
40}
41
42//_____________________________________________________________________________
44 : TNamed(origin),
45 fEdep(0.),
46 fAbsorberVolId(origin.fAbsorberVolId),
47 fVerboseLevel(origin.fVerboseLevel)
48{
49 /// Copy constructor (for clonig on worker thread in MT mode).
50 /// Create hits collection.
51 /// \param origin The source object (on master).
52}
53
54//_____________________________________________________________________________
56 : TNamed(), fEdep(0.), fAbsorberVolId(0), fVerboseLevel(1)
57{
58 /// Default constructor
59}
60
61//_____________________________________________________________________________
63{
64 /// Destructor
65}
66
67//
68// public methods
69//
70
71//_____________________________________________________________________________
73{
74 /// Set sensitive volumes.
75
76 fAbsorberVolId = gMC->VolId("Absorber");
77}
78
79//_____________________________________________________________________________
81{
82 /// Account energy deposit.
83
84 Int_t copyNo;
85 Int_t id = gMC->CurrentVolID(copyNo);
86
87 if (id != fAbsorberVolId) return false;
88
89 fEdep += gMC->Edep();
90
91 return true;
92}
93
94//_____________________________________________________________________________
96{
97 /// Print the enrgy deposit (if verbose) and reset hits afterwards.
98
99 if (fVerboseLevel > 1) Print();
100
101 // Reset the accumulated values.
102 fEdep = 0.;
103}
104
105//_____________________________________________________________________________
106void SensitiveDetector::Print(Option_t* /*option*/) const
107{
108 /// Print the energy deposit.
109
110 cout << "\n-------->Edep: in this event [MeV]: " << fEdep * 1e+03 << endl
111 << endl;
112}
113
114} // namespace TR
115} // namespace VMC
The absorber sensitive detector.
Int_t fVerboseLevel
Verbosity level.
virtual void Print(Option_t *option="") const
Double_t fEdep
Energy deposit.
Int_t fAbsorberVolId
The absorber volume Id.