The Gaudi Framework
master (37c0b60a)
SimulationAlg.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 "
MCHit.h
"
13
#include "
MCTrack.h
"
14
15
#include <
Gaudi/Accumulators.h
>
16
#include <
Gaudi/Functional/Transformer.h
>
17
18
#include <cmath>
19
20
namespace
{
21
std::pair<float, float>
sincos(
float
arg ) {
return
{
std::sin
( arg ),
std::cos
( arg ) }; }
22
}
// namespace
23
24
namespace
Gaudi::Example::TinyExperiment
{
25
29
class
SimulationAlg
:
public
Functional::Transformer
<MCHits( MCTracks const& )> {
30
public
:
31
SimulationAlg
(
const
std::string
&
name
,
ISvcLocator
* pSvcLocator )
32
:
Transformer
(
name
, pSvcLocator, { {
"MCTracksLocation"
,
"/Event/MCTracks"
} },
33
{
"MCHitsLocation"
,
"/Event/MCHits"
} ) {}
34
35
MCHits
operator()
(
MCTracks
const
& tracks )
const override
{
36
MCHits
hits;
37
hits.
reserve
( tracks.
size
() *
m_nbHitsPerTrack
);
38
for
(
auto
const
& track : tracks ) {
39
auto
[
s
,
c
] = sincos( track.theta );
40
for
(
unsigned
int
i = 0; i <
m_nbHitsPerTrack
; i++ ) {
41
hits.
emplace_back
( i *
c
, i *
s
);
42
++
n_hits
;
43
}
44
}
45
return
hits;
46
};
47
48
private
:
49
Gaudi::Property<unsigned int>
m_nbHitsPerTrack
{
this
,
"NbHitsPerTrack"
, 10 };
50
mutable
Gaudi::Accumulators::Counter<>
n_hits
{
this
,
"Number of MCHits"
};
51
};
52
53
DECLARE_COMPONENT
( SimulationAlg )
54
55
}
// namespace Gaudi::Example::TinyExperiment
std::string
STL class.
std::pair
std::vector::reserve
T reserve(T... args)
Gaudi::Accumulators::Counter<>
std::cos
T cos(T... args)
gaudirun.s
string s
Definition:
gaudirun.py:346
std::vector
STL class.
std::vector::size
T size(T... args)
ISvcLocator
Definition:
ISvcLocator.h:46
Gaudi::Example::TinyExperiment::SimulationAlg::SimulationAlg
SimulationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
SimulationAlg.cpp:31
gaudirun.c
c
Definition:
gaudirun.py:525
Gaudi::Example::TinyExperiment::SimulationAlg::operator()
MCHits operator()(MCTracks const &tracks) const override
Definition:
SimulationAlg.cpp:35
Gaudi::Example::TinyExperiment::SimulationAlg
Simulation algorithm creating MC Hits from a set of tracks.
Definition:
SimulationAlg.cpp:29
Gaudi::Example::TinyExperiment::SimulationAlg::m_nbHitsPerTrack
Gaudi::Property< unsigned int > m_nbHitsPerTrack
Definition:
SimulationAlg.cpp:49
Transformer.h
MCHit.h
MCTrack.h
std::sin
T sin(T... args)
Accumulators.h
std::vector::emplace_back
T emplace_back(T... args)
ConditionsStallTest.name
name
Definition:
ConditionsStallTest.py:77
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition:
PluginServiceV1.h:46
Gaudi::Example::TinyExperiment
Definition:
CheckerAlg.cpp:20
Gaudi ::Functional::Transformer
details::Transformer< Signature, Traits_, details::isLegacy< Traits_ > > Transformer
Definition:
Transformer.h:237
Gaudi::Property< unsigned int >
Gaudi::Example::TinyExperiment::SimulationAlg::n_hits
Gaudi::Accumulators::Counter n_hits
Definition:
SimulationAlg.cpp:50
GaudiExamples
TinyExperiment
src
SimulationAlg.cpp
Generated on Thu Dec 19 2024 15:34:58 for The Gaudi Framework by
1.8.18