The Gaudi Framework
master (53dee381)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
Accumulators.h
MCHit.h
MCTrack.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
Transformer.h
Gaudi::Example::TinyExperiment::SimulationAlg::n_hits
Gaudi::Accumulators::Counter n_hits
Definition
SimulationAlg.cpp:50
Gaudi::Example::TinyExperiment::SimulationAlg::SimulationAlg
SimulationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SimulationAlg.cpp:31
Gaudi::Example::TinyExperiment::SimulationAlg::m_nbHitsPerTrack
Gaudi::Property< unsigned int > m_nbHitsPerTrack
Definition
SimulationAlg.cpp:49
Gaudi::Example::TinyExperiment::SimulationAlg::operator()
MCHits operator()(MCTracks const &tracks) const override
Definition
SimulationAlg.cpp:35
Gaudi::Property
Implementation of property with value of concrete type.
Definition
Property.h:35
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
Gaudi::Example::TinyExperiment
Definition
CheckerAlg.cpp:20
Gaudi::Example::TinyExperiment::MCTracks
std::vector< MCTrack > MCTracks
Definition
MCTrack.h:28
Gaudi::Example::TinyExperiment::MCHits
std::vector< MCHit > MCHits
Definition
MCHit.h:27
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition
Accumulators.h:962
GaudiExamples
TinyExperiment
src
SimulationAlg.cpp
Generated on
for The Gaudi Framework by
1.17.0