ATLAS Offline Software
Loading...
Searching...
No Matches
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
21TBBeamQuality::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
31
32/*--------------- INITIALIZE ---------------*/
33
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) {
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 {
61 (" Tool Name: "
62 <<tool->name()
63 <<" Tool Type: "
64 <<tool->type() );
65 }
66 return StatusCode::SUCCESS;
67}//init
68
69/*---------------EXECUTE---------------*/
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);
107 return StatusCode::SUCCESS;
108} //execute
109
110/*---------------FINALIZE---------------*/
112{ //finalize
113 // print summary
115 ( "************ Beam Quality Tool ************" );
116 for (ToolHandle<TBBeamQualityTool>& tool : m_bqtools)
117 {
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode initialize() override
std::map< ToolHandle< TBBeamQualityTool >, unsigned int > m_bqrejectCounter
ToolHandleArray< TBBeamQualityTool > m_bqtools
std::vector< std::string > m_bqparticle
std::map< ToolHandle< TBBeamQualityTool >, unsigned int > m_bqtotalCounter
virtual StatusCode finalize() override
std::map< ToolHandle< TBBeamQualityTool >, unsigned int > m_bqacceptCounter
TBBeamQuality(const std::string &name, ISvcLocator *pService)
virtual StatusCode execute() override
virtual ~TBBeamQuality()
const std::string & getBeamParticle() const
Definition TBEventInfo.h:74