ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TestBeam
TBRec
src
TBBeamQuality.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//#####################################################
6
//# #
7
//# File : TBBeamQuality.cxx #
8
//# Package: TBRec #
9
//# #
10
//# Author : Marco Bieri <mbieri@sfu.ca> #
11
//# #
12
//# Last Modified: Feb 7/2005 #
13
//#####################################################
14
15
16
#include "
TBBeamQuality.h
"
17
#include "
TBBeamQualityTool.h
"
18
#include "
TBEvent/TBEventInfo.h
"
19
20
21
TBBeamQuality::TBBeamQuality
(
const
std::string& name,
22
ISvcLocator* pService)
23
:
AthAlgorithm
(name,pService)
24
{
//properties
25
declareProperty
(
"BQParticles"
,
m_bqparticle
=std::vector<std::string>(1,
"noselect"
));
26
declareProperty
(
"BQToolNames"
,
m_bqtools
);
27
}
//properties
28
29
TBBeamQuality::~TBBeamQuality
()
30
{ }
31
32
/*--------------- INITIALIZE ---------------*/
33
34
StatusCode
TBBeamQuality::initialize
()
35
{
//init
36
// message service
37
ATH_MSG_DEBUG
(
"Initialize"
);
38
39
ATH_CHECK
(
m_bqtools
.retrieve() );
40
41
// check tools
42
if
(
m_bqtools
.size() == 0 ) {
43
ATH_MSG_ERROR
(
"TBBeamQuality: No Tools found"
);
44
return
StatusCode::FAILURE;
45
}
else
{
46
for
(
unsigned
int
i = 0; i <
m_bqtools
.size(); ++i) {
47
m_bqacceptCounter
[
m_bqtools
[i]] = 0;
48
m_bqrejectCounter
[
m_bqtools
[i]] = 0;
49
m_bqtotalCounter
[
m_bqtools
[i]] =0;
50
}
51
}
52
53
// print out list of tools
54
ATH_MSG_INFO
(
" "
);
55
ATH_MSG_INFO
(
" TBBeamQuality: List of Tools:"
);
56
ATH_MSG_INFO
(
"-----------------------------------"
);
57
58
for
(ToolHandle<TBBeamQualityTool>& tool :
m_bqtools
)
59
{
60
ATH_MSG_INFO
61
(
" Tool Name: "
62
<<tool->name()
63
<<
" Tool Type: "
64
<<tool->type() );
65
}
66
return
StatusCode::SUCCESS;
67
}
//init
68
69
/*---------------EXECUTE---------------*/
70
StatusCode
TBBeamQuality::execute
(
const
EventContext& ctx)
71
{
// execute
72
ATH_MSG_DEBUG
(
"Execute"
);
73
74
if
(
m_bqparticle
[0]==
"noselect"
) {
//obtain particle type
75
// determining particel type
76
const
TBEventInfo
* eventInfo;
77
StatusCode
sc
=
evtStore
()->retrieve(eventInfo);
78
if
(
sc
.isFailure())
79
{
80
ATH_MSG_ERROR
(
"TBBeamQuality Algo Tool: Could not retrieve event info"
);
81
}
82
std::string particle=eventInfo->
getBeamParticle
();
83
m_bqparticle
=std::vector<std::string>(1,particle);
84
ATH_MSG_INFO
(
"Beam Quality selected default particle: "
<<
m_bqparticle
[0]);
85
}
86
87
// invoke tools
88
89
// setting event to success
90
bool
successFlag =
true
;
91
for
(ToolHandle<TBBeamQualityTool>& tool :
m_bqtools
)
92
{
93
m_bqtotalCounter
[tool]++;
94
if
( tool->accept(
m_bqparticle
) == StatusCode::SUCCESS )
95
{
96
m_bqacceptCounter
[tool]++;
97
}
98
else
99
{
100
m_bqrejectCounter
[tool]++;
101
successFlag =
false
;
102
break
;
103
}
104
}
105
106
setFilterPassed
(successFlag, ctx);
107
return
StatusCode::SUCCESS;
108
}
//execute
109
110
/*---------------FINALIZE---------------*/
111
StatusCode
TBBeamQuality::finalize
()
112
{
//finalize
113
// print summary
114
ATH_MSG_INFO
115
(
"************ Beam Quality Tool ************"
);
116
for
(ToolHandle<TBBeamQualityTool>& tool :
m_bqtools
)
117
{
118
ATH_MSG_INFO
119
(tool->name() <<
" : "
120
<<
"(Total/Accept/Rejected)"
121
<<
" ("
122
<<
m_bqtotalCounter
[tool] <<
"/"
123
<<
m_bqacceptCounter
[tool] <<
"/"
124
<<
m_bqrejectCounter
[tool]
125
<<
")"
);
126
}
127
return
StatusCode::SUCCESS;
128
}
//finalize
129
130
131
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
TBBeamQualityTool.h
TBBeamQuality.h
TBEventInfo.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Definition
AthCommonAlgorithm.h:99
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
TBBeamQuality::initialize
virtual StatusCode initialize() override
Definition
TBBeamQuality.cxx:34
TBBeamQuality::m_bqrejectCounter
std::map< ToolHandle< TBBeamQualityTool >, unsigned int > m_bqrejectCounter
Definition
TBBeamQuality.h:49
TBBeamQuality::m_bqtools
ToolHandleArray< TBBeamQualityTool > m_bqtools
Definition
TBBeamQuality.h:45
TBBeamQuality::m_bqparticle
std::vector< std::string > m_bqparticle
Definition
TBBeamQuality.h:42
TBBeamQuality::m_bqtotalCounter
std::map< ToolHandle< TBBeamQualityTool >, unsigned int > m_bqtotalCounter
Definition
TBBeamQuality.h:50
TBBeamQuality::finalize
virtual StatusCode finalize() override
Definition
TBBeamQuality.cxx:111
TBBeamQuality::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
TBBeamQuality.cxx:70
TBBeamQuality::m_bqacceptCounter
std::map< ToolHandle< TBBeamQualityTool >, unsigned int > m_bqacceptCounter
Definition
TBBeamQuality.h:48
TBBeamQuality::TBBeamQuality
TBBeamQuality(const std::string &name, ISvcLocator *pService)
Definition
TBBeamQuality.cxx:21
TBBeamQuality::~TBBeamQuality
virtual ~TBBeamQuality()
Definition
TBBeamQuality.cxx:29
TBEventInfo
Definition
TBEventInfo.h:27
TBEventInfo::getBeamParticle
const std::string & getBeamParticle() const
Definition
TBEventInfo.h:74
Generated on
for ATLAS Offline Software by
1.17.0