The Gaudi Framework
master (181af51f)
Loading...
Searching...
No Matches
DigitizationAlg.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
12
#include "
Hit.h
"
13
#include "
IRandomGenSvc.h
"
14
#include "
MCHit.h
"
15
16
#include <
Gaudi/Accumulators.h
>
17
#include <
Gaudi/Functional/Transformer.h
>
18
19
#include <random>
20
21
namespace
Gaudi::Example::TinyExperiment
{
22
26
class
DigitizationAlg
:
public
Functional::Transformer<Hits( EventContext const&, MCHits const& )> {
27
public
:
28
DigitizationAlg
(
const
std::string& name,
ISvcLocator
* pSvcLocator )
29
: Transformer( name, pSvcLocator, { {
"MCHitsLocation"
,
"/Event/MCHits"
} },
30
{
"HitsLocation"
,
"/Event/Hits"
} ) {}
31
32
Hits
operator()
(
const
EventContext
& ctx,
MCHits
const
& mcHits )
const override
{
33
Hits
hits;
34
hits.reserve( mcHits.size() );
35
std::normal_distribution dist( 0.0f,
m_sigmaNoise
.value() );
// µ, σ
36
auto
engine =
m_rndSvc
->getEngine( ctx.evt() );
37
for
(
auto
const
& mcHit : mcHits ) {
38
auto
nx = mcHit.x + dist( engine );
39
auto
ny = mcHit.y + dist( engine );
40
// ignore negative axis.
41
// Simplifies reconstruction and simulate the apperture of the detector
42
if
( nx > 0 ) {
43
hits.emplace_back( nx, ny );
44
++
n_hits
;
45
}
46
}
47
return
hits;
48
};
49
50
private
:
51
ServiceHandle<IRandomGenSvc>
m_rndSvc
{
this
,
"RandomGenSvc"
,
"RandomGenSvc"
,
52
"A service providing a thread safe random number generator"
};
53
Gaudi::Property<float>
m_sigmaNoise
{
this
,
"SigmaNoise"
, 1.f,
54
"Sigma of the noise (a normal distribution centered on 0)"
};
55
mutable
Gaudi::Accumulators::Counter<>
n_hits
{
this
,
"Number of Hits"
};
56
};
57
58
DECLARE_COMPONENT
( DigitizationAlg )
59
60
}
// namespace Gaudi::Example::TinyExperiment
Accumulators.h
Hit.h
IRandomGenSvc.h
MCHit.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
Transformer.h
EventContext
This class represents an entry point to all the event specific data.
Definition
EventContext.h:34
Gaudi::Example::TinyExperiment::DigitizationAlg::DigitizationAlg
DigitizationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
DigitizationAlg.cpp:28
Gaudi::Example::TinyExperiment::DigitizationAlg::operator()
Hits operator()(const EventContext &ctx, MCHits const &mcHits) const override
Definition
DigitizationAlg.cpp:32
Gaudi::Example::TinyExperiment::DigitizationAlg::m_sigmaNoise
Gaudi::Property< float > m_sigmaNoise
Definition
DigitizationAlg.cpp:53
Gaudi::Example::TinyExperiment::DigitizationAlg::m_rndSvc
ServiceHandle< IRandomGenSvc > m_rndSvc
Definition
DigitizationAlg.cpp:51
Gaudi::Example::TinyExperiment::DigitizationAlg::n_hits
Gaudi::Accumulators::Counter n_hits
Definition
DigitizationAlg.cpp:55
Gaudi::Property
Implementation of property with value of concrete type.
Definition
PropertyFwd.h:27
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
ServiceHandle
Handle to be used in lieu of naked pointers to services.
Definition
ServiceHandle.h:38
Gaudi::Example::TinyExperiment
Definition
CheckerAlg.cpp:20
Gaudi::Example::TinyExperiment::MCHits
std::vector< MCHit > MCHits
Definition
MCHit.h:27
Gaudi::Example::TinyExperiment::Hits
std::vector< Hit > Hits
Definition
Hit.h:27
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition
Accumulators.h:930
GaudiExamples
TinyExperiment
src
DigitizationAlg.cpp
Generated on Wed Oct 8 2025 09:53:36 for The Gaudi Framework by
1.13.1