VMC Examples
Version 6.6
Loading...
Searching...
No Matches
examples
TR
src
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
24
ClassImp(
VMC::TR::SensitiveDetector
)
25
/// \endcond
26
27
using namespace
std;
28
29
namespace
VMC
30
{
31
namespace
TR
32
{
33
34
//_____________________________________________________________________________
35
SensitiveDetector::SensitiveDetector
(
const
char
* name)
36
:
TNamed
(name,
""
), fEdep(0.), fAbsorberVolId(0), fVerboseLevel(1)
37
{
38
/// Standard constructor.
39
/// \param name The sensitive detector name
40
}
41
42
//_____________________________________________________________________________
43
SensitiveDetector::SensitiveDetector
(
const
SensitiveDetector
& origin)
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
//_____________________________________________________________________________
55
SensitiveDetector::SensitiveDetector
()
56
:
TNamed
(), fEdep(0.), fAbsorberVolId(0), fVerboseLevel(1)
57
{
58
/// Default constructor
59
}
60
61
//_____________________________________________________________________________
62
SensitiveDetector::~SensitiveDetector
()
63
{
64
/// Destructor
65
}
66
67
//
68
// public methods
69
//
70
71
//_____________________________________________________________________________
72
void
SensitiveDetector::Initialize
()
73
{
74
/// Set sensitive volumes.
75
76
fAbsorberVolId
= gMC->VolId(
"Absorber"
);
77
}
78
79
//_____________________________________________________________________________
80
Bool_t
SensitiveDetector::ProcessHits
()
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
//_____________________________________________________________________________
95
void
SensitiveDetector::EndOfEvent
()
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
//_____________________________________________________________________________
106
void
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
TNamed
VMC::TR::SensitiveDetector
The absorber sensitive detector.
Definition
SensitiveDetector.h:35
VMC::TR::SensitiveDetector::Initialize
void Initialize()
Definition
SensitiveDetector.cxx:72
VMC::TR::SensitiveDetector::~SensitiveDetector
virtual ~SensitiveDetector()
Definition
SensitiveDetector.cxx:62
VMC::TR::SensitiveDetector::fVerboseLevel
Int_t fVerboseLevel
Verbosity level.
Definition
SensitiveDetector.h:58
VMC::TR::SensitiveDetector::SensitiveDetector
SensitiveDetector()
Definition
SensitiveDetector.cxx:55
VMC::TR::SensitiveDetector::EndOfEvent
void EndOfEvent()
Definition
SensitiveDetector.cxx:95
VMC::TR::SensitiveDetector::Print
virtual void Print(Option_t *option="") const
Definition
SensitiveDetector.cxx:106
VMC::TR::SensitiveDetector::fEdep
Double_t fEdep
Energy deposit.
Definition
SensitiveDetector.h:56
VMC::TR::SensitiveDetector::ProcessHits
Bool_t ProcessHits()
Definition
SensitiveDetector.cxx:80
VMC::TR::SensitiveDetector::fAbsorberVolId
Int_t fAbsorberVolId
The absorber volume Id.
Definition
SensitiveDetector.h:57
VMC
Definition
FastSimulation.h:26
Generated on Thu Nov 28 2024 11:31:18 for VMC Examples by
1.12.0