ATLAS Offline Software
TBEventInfoStreamerTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "TBEvent/TBEventInfo.h"
7 
8 #include <string>
9 #include <ios>
10 #include <algorithm>
11 
13  const std::string& name,
14  const IInterface* parent)
16  m_selected_events(0)
17 {
18  declareInterface<TBEventStreamerTool>(this);
19  m_acceptTypes.resize(1,"Physics");
20  declareProperty("AcceptedTypes",m_acceptTypes);
21 }
22 
24 { }
25 
27 // Initialize //
29 
31 {
33 
34  for ( unsigned int i=0; i<m_acceptTypes.size(); i++ )
35  {
36  if ( m_acceptTypes[i] == "Physics" )
37  {
38  m_acceptCodes.push_back(1);
39  }
40  else if ( m_acceptTypes[i] == "Special" )
41  {
42  m_acceptCodes.push_back(0);
43  }
44  else if ( m_acceptTypes[i] == "f/e_Calibration" )
45  {
46  m_acceptCodes.push_back(2);
47  }
48  else if ( m_acceptTypes[i] == "Random" )
49  {
50  m_acceptCodes.push_back(3);
51  }
52  else if ( m_acceptTypes[i] == "BPC_Calibration" )
53  {
54  m_acceptCodes.push_back(4);
55  }
56  else
57  {
58  ATH_MSG_FATAL ( "Detector event type not existing " << m_acceptTypes );
59  ATH_MSG_FATAL ( "Possible types are: Special, Physics, f/e_calibration, Random, BPC_Calibration" );
60  return StatusCode::FAILURE;
61  }
62 
63  }
64 
65  if (m_acceptCodes.size()==0) {
66  ATH_MSG_ERROR ( "No detector event type specified! Please specify at least one in the JobOptions" );
67  ATH_MSG_ERROR ( "Possible types are: Special, Physics, f/e_Calibration, Random, BPC_Calibration");
68  }
69  else {
70  for ( unsigned int i=0; i<m_acceptCodes.size(); i++ )
71  {
72  ATH_MSG_DEBUG ( "Detector event code found " << m_acceptCodes[i] );
73  }
74  }
75 
76  return StatusCode::SUCCESS;
77 }
78 
80 // Accept/Reject //
82 
84 {
85  // retrieve Event Info
86  const TBEventInfo* theEventInfo;
87  ATH_CHECK( evtStore()->retrieve(theEventInfo,"TBEventInfo") );
88 
89  int evtType = theEventInfo->getEventType();
90  ATH_MSG_DEBUG ( "Event Type found " << evtType );
91 
92  return (std::find(m_acceptCodes.begin(),m_acceptCodes.end(),evtType) !=
93  m_acceptCodes.end())
94  ? StatusCode::SUCCESS
95  : StatusCode::FAILURE;
96 
97 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TBEventInfoStreamerTool::TBEventInfoStreamerTool
TBEventInfoStreamerTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TBEventInfoStreamerTool.cxx:12
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TBEventInfoStreamerTool::m_acceptTypes
std::vector< std::string > m_acceptTypes
Definition: TBEventInfoStreamerTool.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TBEventInfoStreamerTool.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TBEventInfoStreamerTool::m_acceptCodes
std::vector< int > m_acceptCodes
Definition: TBEventInfoStreamerTool.h:30
TBEventInfo::getEventType
int getEventType() const
Definition: TBEventInfo.h:66
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TBEventInfoStreamerTool::accept
virtual StatusCode accept() override
Definition: TBEventInfoStreamerTool.cxx:83
TBEventInfoStreamerTool::m_selected_events
int m_selected_events
Definition: TBEventInfoStreamerTool.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TBEventInfo
Definition: TBEventInfo.h:27
TBEventStreamerTool
Definition: TBEventStreamerTool.h:15
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TBEventInfoStreamerTool::~TBEventInfoStreamerTool
virtual ~TBEventInfoStreamerTool()
Definition: TBEventInfoStreamerTool.cxx:23
TBEventInfo.h
TBEventInfoStreamerTool::initializeTool
virtual StatusCode initializeTool() override
Definition: TBEventInfoStreamerTool.cxx:30