ATLAS Offline Software
Loading...
Searching...
No Matches
AskForRoI Class Reference

The test calls for RoI data access for each RoI returned bunch of quantiries are checked, RoI et, actual RoI span, and cells count. More...

Inheritance diagram for AskForRoI:
Collaboration diagram for AskForRoI:

Public Member Functions

 AskForRoI (const EventContext &context, const ServiceHandle< ITrigCaloDataAccessSvc > &svc, const TrigRoiDescriptor &roi)
 ~AskForRoI ()
StatusCode request (LArTT_Selector< LArCellCont > &sel) const
StatusCode request (CaloConstCellContainer &c) const
void firstCall () override
 a method that will be called to obtain first results from the service It should set the reference quantities
bool callAndCompare () const override
 a function that performs request, and compares the results obtained with the result of the first execution When result differ this function is supposed to return false, otherwise true
bool run (size_t nrepeats)
 runs the stress test by invoking it the firstCall and then repetitively the callAndCompare
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static bool launchTests (size_t nrepeats, const std::vector< ParallelCallTest * > &tests)
 Method to run launch number of tests in parallel (increasing the stress of the calle) It has a potential that also the "first" calls can be launched in parallel and thus be the worse case compared to a situation when the first calls are invoked sequentially while further calls in parallel.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

const EventContext & m_context
const ServiceHandle< ITrigCaloDataAccessSvc > & m_svc
const TrigRoiDescriptor m_roi
LArTT_Selector< LArCellContm_selRef
CaloConstCellContainerm_colRef
StatusCode m_statusRef
double m_etSumRef = 0
size_t m_countRef = 0
double m_minEtaRef = 100
double m_maxEtaRef = -100
double m_minPhiRef = 100
double m_maxPhiRef = -100
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

The test calls for RoI data access for each RoI returned bunch of quantiries are checked, RoI et, actual RoI span, and cells count.

Definition at line 30 of file TestCaloDataAccess.cxx.

Constructor & Destructor Documentation

◆ AskForRoI()

AskForRoI::AskForRoI ( const EventContext & context,
const ServiceHandle< ITrigCaloDataAccessSvc > & svc,
const TrigRoiDescriptor & roi )
inline

Definition at line 32 of file TestCaloDataAccess.cxx.

35 : AthMessaging ("TestCaloDataAccess"),
36 m_context( context ),
37 m_svc( svc ),
38 m_roi ( roi ) {
39 m_colRef = new CaloConstCellContainer(SG::VIEW_ELEMENTS);
40 }
const ServiceHandle< ITrigCaloDataAccessSvc > & m_svc
const EventContext & m_context
const TrigRoiDescriptor m_roi
CaloConstCellContainer * m_colRef
AthMessaging()
Default constructor:
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts

◆ ~AskForRoI()

AskForRoI::~AskForRoI ( )
inline

Definition at line 41 of file TestCaloDataAccess.cxx.

41 {
42 if ( m_colRef ) { m_colRef->clear(); delete m_colRef; }
43 }

Member Function Documentation

◆ callAndCompare()

bool AskForRoI::callAndCompare ( ) const
inlineoverridevirtual

a function that performs request, and compares the results obtained with the result of the first execution When result differ this function is supposed to return false, otherwise true

Implements ParallelCallTest.

Definition at line 108 of file TestCaloDataAccess.cxx.

108 {
109
110 Gaudi::Hive::setCurrentContext (m_context);
111 LArTT_Selector<LArCellCont> sel;
112 CaloConstCellContainer col(SG::VIEW_ELEMENTS);
113 double etSum = 0;
114 size_t count = 0;
115 double minEta = 100;
116 double maxEta = -100;
117 double minPhi = 100;
118 double maxPhi = -100;
120 if ( m_roi.isFullscan() ) {
121 status = request( col );
122 status.ignore();
123
124 for ( const auto cell : col ) {
125 if ( !cell ) continue;
126 etSum += cell->et();
127 count ++;
128 minEta = std::min( minEta, cell->eta() );
129 maxEta = std::max( maxEta, cell->eta() );
130 minPhi = std::min( minPhi, cell->phi() );
131 maxPhi = std::max( maxPhi, cell->phi() );
132 }
133 } else {
134
135 status = request( sel );
136 status.ignore();
137
138 for ( const auto cell : sel ) {
139 etSum += cell->et();
140 count ++;
141 minEta = std::min( minEta, cell->eta() );
142 maxEta = std::max( maxEta, cell->eta() );
143 minPhi = std::min( minPhi, cell->phi() );
144 maxPhi = std::max( maxPhi, cell->phi() );
145 }
146 std::cout << "callAndCompare : " << m_context << " " << count << " " << etSum << " " << minEta << " " << maxEta << " " << minPhi << " " << maxPhi << " " << " " << m_minEtaRef << " " << m_maxEtaRef << " " << m_minPhiRef << " " << m_maxPhiRef << " " << m_etSumRef << " " << m_countRef << std::endl;
147 }
148
149 DIFF( "RoI mask", status.getCode(), m_statusRef.getCode() );
150 DIFF( "RoI count ", count , m_countRef );
151 DIFF( "RoI etSum ", etSum , m_etSumRef );
152 DIFF( "RoI minEta", minEta, m_minEtaRef );
153 DIFF( "RoI maxEta", maxEta, m_maxEtaRef );
154 DIFF( "RoI minPhi", minPhi, m_minPhiRef );
155 DIFF( "RoI maxPhi", maxPhi, m_maxPhiRef );
156
157 bool checkStatus = m_statusRef == status
158 and m_countRef == count
159 and m_etSumRef == etSum
160 and m_minEtaRef == minEta
161 and m_maxEtaRef == maxEta
162 and m_minPhiRef == minPhi
163 and m_maxPhiRef == maxPhi;
164
165 if ( checkStatus == false ) {
166
167 // iterate over two slectors and compare cell by cell
168 for ( LArTT_Selector<LArCellCont>::const_iterator refIter = m_selRef.begin(), thisIter = sel.begin();
169 refIter != m_selRef.end() and thisIter != sel.end(); ++refIter, ++thisIter ) {
170 const LArCell* refCell = *refIter;
171 const LArCell* thisCell = *thisIter;
172 if ( thisCell->et() != refCell->et() ) {
173 ATH_MSG_WARNING( "eta/phi/et Reference cell " << refCell->eta() << "/" << refCell->phi() << "/" << refCell->et()
174 << " differ from the one in this request " << thisCell->eta() << "/" << thisCell->phi() << "/" << thisCell->et() );
175 }
176 }
177 }
178
179 return checkStatus;
180 }
#define ATH_MSG_WARNING(x)
#define DIFF(_name, _a, _b)
StatusCode request(LArTT_Selector< LArCellCont > &sel) const
StatusCode m_statusRef
LArTT_Selector< LArCellCont > m_selRef
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
virtual double et() const override final
get et
Definition CaloCell.h:423
friend class const_iterator
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
::StatusCode StatusCode
StatusCode definition for legacy code.
constexpr float maxEta
status
Definition merge.py:16

◆ firstCall()

void AskForRoI::firstCall ( )
inlineoverridevirtual

a method that will be called to obtain first results from the service It should set the reference quantities

Implements ParallelCallTest.

Definition at line 68 of file TestCaloDataAccess.cxx.

68 {
69 Gaudi::Hive::setCurrentContext (m_context);
70 if ( m_roi.isFullscan() ) {
71 struct timeval t1{},t2{};
72 gettimeofday(&t1,NULL);
74 m_statusRef.ignore();
75 gettimeofday(&t2,NULL);
76
77 for ( const auto cell : *m_colRef ) {
78 if ( !cell ) continue;
79 m_etSumRef += cell->et();
80 m_countRef ++;
81 m_minEtaRef = std::min( m_minEtaRef, cell->eta() );
82 m_maxEtaRef = std::max( m_maxEtaRef, cell->eta() );
83 m_minPhiRef = std::min( m_minPhiRef, cell->phi() );
84 m_maxPhiRef = std::max( m_maxPhiRef, cell->phi() );
85 }
86 std::cout << "t lFC : " << m_context << " " << m_etSumRef << " " << t1.tv_sec << " " << t1.tv_usec << " " << t2.tv_sec << " " << t2.tv_usec << " " << ((t2.tv_sec-t1.tv_sec)*1e6+(t2.tv_usec-t1.tv_usec) )*1e-6 << std::endl;
87
88 } else {
89
90 struct timeval t1{},t2{};
91 gettimeofday(&t1,NULL);
93 m_statusRef.ignore();
94 gettimeofday(&t2,NULL);
95
96 for ( const auto cell : m_selRef ) {
97 m_etSumRef += cell->et();
98 m_countRef ++;
99 m_minEtaRef = std::min( m_minEtaRef, cell->eta() );
100 m_maxEtaRef = std::max( m_maxEtaRef, cell->eta() );
101 m_minPhiRef = std::min( m_minPhiRef, cell->phi() );
102 m_maxPhiRef = std::max( m_maxPhiRef, cell->phi() );
103 }
104 std::cout << "t RoI : " << m_context << " " << m_etSumRef << " " << t1.tv_sec << " " << t1.tv_usec << " " << t2.tv_sec << " " << t2.tv_usec << " " << ((t2.tv_sec-t1.tv_sec)*1e6+(t2.tv_usec-t1.tv_usec) )*1e-6 << std::endl;
105 }
106 }
std::vector< ALFA_RawDataContainer_p1 > t2
std::vector< ALFA_RawDataCollection_p1 > t1

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ launchTests()

bool ParallelCallTest::launchTests ( size_t nrepeats,
const std::vector< ParallelCallTest * > & tests )
staticinherited

Method to run launch number of tests in parallel (increasing the stress of the calle) It has a potential that also the "first" calls can be launched in parallel and thus be the worse case compared to a situation when the first calls are invoked sequentially while further calls in parallel.

Definition at line 83 of file ParallelCallTest.cxx.

83 {
84 // Suppress undefined behavior warning resulting from a tbb bug.
85 // /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/sw/lcg/releases/LCG_88/tbb/44_20160413/x86_64-slc6-gcc62-dbg/include/tbb/parallel_reduce.h:177:32: runtime error: member call on address 0x2aab14047b40 which does not point to an object of type 'task'
86 //0x2aab14047b40: note: object has invalid vptr
87 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0
88 // cf. https://github.com/RcppCore/RcppParallel/issues/36
89 RedirStderr redir;
90
91 //std::vector<ParallelCallTest*> tests( testList.begin(), testList.end() );
92 return tbb::parallel_reduce( tbb::blocked_range< std::vector<ParallelCallTest*>::const_iterator >( tests.begin(), tests.end() ),
93 true, // initial value
94 [&]( tbb::blocked_range< std::vector<ParallelCallTest*>::const_iterator > groupOfTests, bool statusSoFar ) -> bool {
95 bool success = true;
96 for ( auto test : groupOfTests ) {
97 success = test->run( nrepeats ) and success;
98 }
99 return statusSoFar and success;
100 },
101 []( bool allCallsStatus, bool thisCallStatus ) -> bool { // result accumulation
102 return allCallsStatus and thisCallStatus;
103 } );
104}

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ request() [1/2]

StatusCode AskForRoI::request ( CaloConstCellContainer & c) const
inline

Definition at line 57 of file TestCaloDataAccess.cxx.

57 {
58 if ( m_roi.isFullscan() ){
59 return m_svc->loadFullCollections( m_context, c );
60 }
61 else{
62 std::cout << "wrong RoI descriptor used for FS" << std::endl;
63 return StatusCode::FAILURE;
64 }
65 }

◆ request() [2/2]

StatusCode AskForRoI::request ( LArTT_Selector< LArCellCont > & sel) const
inline

Definition at line 45 of file TestCaloDataAccess.cxx.

45 {
46 if ( m_roi.isFullscan() ){
47 std::cout << "wrong RoI descriptor used for RoI" << std::endl;
48 return StatusCode::FAILURE;
49 }
50 else{
51 // keep this for test reasons
52 //usleep (5000);
53 return m_svc->loadCollections( m_context, m_roi, TTEM, 2, sel );
54 }
55 }
@ TTEM
Definition RegSelEnums.h:28

◆ run()

bool ParallelCallTest::run ( size_t nrepeats)
inherited

runs the stress test by invoking it the firstCall and then repetitively the callAndCompare

  • nrepeats times (>=1) A single failure of the callAndCompare would result in the whole execution failed

Definition at line 69 of file ParallelCallTest.cxx.

69 {
70 firstCall();
71
72 return tbb::parallel_reduce( tbb::blocked_range<int>( 0, nrepeats, 1 ),
73 true, // initial value
74 [&]( tbb::blocked_range<int>, bool statusSoFar ) -> bool {
75 return callAndCompare() and statusSoFar;
76 },
77 []( bool allCallsStatus, bool thisCallStatus ) -> bool { // result accumulation
78 return allCallsStatus and thisCallStatus;
79 } );
80}
virtual bool callAndCompare() const =0
a function that performs request, and compares the results obtained with the result of the first exec...
virtual void firstCall()=0
a method that will be called to obtain first results from the service It should set the reference qua...

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_colRef

CaloConstCellContainer* AskForRoI::m_colRef
private

Definition at line 188 of file TestCaloDataAccess.cxx.

◆ m_context

const EventContext& AskForRoI::m_context
private

Definition at line 183 of file TestCaloDataAccess.cxx.

◆ m_countRef

size_t AskForRoI::m_countRef = 0
private

Definition at line 191 of file TestCaloDataAccess.cxx.

◆ m_etSumRef

double AskForRoI::m_etSumRef = 0
private

Definition at line 190 of file TestCaloDataAccess.cxx.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_maxEtaRef

double AskForRoI::m_maxEtaRef = -100
private

Definition at line 193 of file TestCaloDataAccess.cxx.

◆ m_maxPhiRef

double AskForRoI::m_maxPhiRef = -100
private

Definition at line 195 of file TestCaloDataAccess.cxx.

◆ m_minEtaRef

double AskForRoI::m_minEtaRef = 100
private

Definition at line 192 of file TestCaloDataAccess.cxx.

◆ m_minPhiRef

double AskForRoI::m_minPhiRef = 100
private

Definition at line 194 of file TestCaloDataAccess.cxx.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_roi

const TrigRoiDescriptor AskForRoI::m_roi
private

Definition at line 185 of file TestCaloDataAccess.cxx.

◆ m_selRef

LArTT_Selector<LArCellCont> AskForRoI::m_selRef
private

Definition at line 187 of file TestCaloDataAccess.cxx.

◆ m_statusRef

StatusCode AskForRoI::m_statusRef
private

Definition at line 189 of file TestCaloDataAccess.cxx.

◆ m_svc

const ServiceHandle<ITrigCaloDataAccessSvc>& AskForRoI::m_svc
private

Definition at line 184 of file TestCaloDataAccess.cxx.


The documentation for this class was generated from the following file: