ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
ByteStreamCnvSvcBase
src
ROBDataProviderMTTest.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include <algorithm>
5
#include "Gaudi/Property.h"
6
#include "
TestTools/ParallelCallTest.h
"
7
#include "
TestTools/random.h
"
8
#include "
ROBDataProviderMTTest.h
"
9
10
11
12
ROBDataProviderMTTest::ROBDataProviderMTTest
(
const
std::string& name,
13
ISvcLocator* pSvcLocator ) :
14
::
AthReentrantAlgorithm
( name, pSvcLocator ) {
15
}
16
17
ROBDataProviderMTTest::~ROBDataProviderMTTest
() {}
18
19
StatusCode
ROBDataProviderMTTest::initialize
() {
20
CHECK
(
m_robDataProvider
.retrieve() );
21
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
ROBDataProviderMTTest::finalize
() {
26
return
StatusCode::SUCCESS;
27
}
28
29
class
AskForROBs
:
public
ParallelCallTest
{
30
public
:
31
AskForROBs
(
const
EventContext& context,
const
ServiceHandle<IROBDataProviderSvc>
& svc, uint32_t lvl1ID,
const
std::vector<eformat::read::ROBFragment>& robs,
size_t
frac=8 )
32
:
m_lvl1ID
( lvl1ID ),
33
m_context
( context ),
34
m_svc
( svc ) {
35
// pick some fraction of robs at random
36
for
(
size_t
el = 0; el < robs.size()/frac; ++el ) {
37
m_ROBIDs
.push_back( robs[el].rob_source_id() );
38
}
39
}
40
size_t
nrobs
()
const
{
return
m_ROBIDs
.size(); }
41
virtual
void
firstCall
()
override
{}
42
virtual
bool
callAndCompare
()
const override
{
43
IROBDataProviderSvc::VROBFRAG
robs;
44
m_svc
->getROBData(
m_context
,
m_ROBIDs
, robs );
45
for
(
auto
& rob: robs ) {
46
if
( rob->rod_lvl1_id() !=
m_lvl1ID
)
47
return
false
;
48
}
49
return
true
;
50
}
51
52
private
:
53
uint32_t
m_lvl1ID
;
54
std::vector<uint32_t>
m_ROBIDs
;
55
EventContext
m_context
;
56
const
ServiceHandle<IROBDataProviderSvc>
&
m_svc
;
57
};
58
59
60
61
StatusCode
ROBDataProviderMTTest::execute
(
const
EventContext& context )
const
62
{
63
// will be asking for many ROBs from the list and check if all of them come from the same physical event
64
const
RawEvent
*
ev
=
m_robDataProvider
->getEvent( context );
65
ATH_MSG_DEBUG
(
"Obtained event, global id: "
<<
ev
->global_id() <<
" lvl1 id: "
<<
ev
->lvl1_id() );
66
uint32_t lvl1ID =
ev
->lvl1_id();
67
68
69
// we try now the other method, getROBData, in 8 steps, concurrently
70
std::vector<ParallelCallTest*> requests;
71
std::vector<eformat::read::ROBFragment> robs;
72
ev
->robs( robs );
73
74
Athena_test::URNG
rng;
75
rng.seed = context.evt();
76
for
(
size_t
i = 0; i < 8; ++i ) {
77
std::shuffle
( robs.begin(), robs.end(), rng );
78
auto
r
=
new
AskForROBs
( context,
m_robDataProvider
, lvl1ID, robs );
79
ATH_MSG_DEBUG
(
"Prepared parallel request with "
<<
r
->nrobs() <<
" robs"
);
80
requests.push_back(
r
);
81
}
82
83
84
bool
status =
ParallelCallTest::launchTests
( 100, requests );
85
if
( status ==
false
)
86
ATH_MSG_ERROR
(
"Concurrent ROB requests resulted in inconsistent information"
);
87
88
size_t
count
= 0;
89
m_robDataProvider
->processCachedROBs( context,
90
[&](
const
IROBDataProviderSvc::ROBF
* ){
count
++; } );
91
ATH_MSG_DEBUG
(
"Size of the cache "
<<
count
);
92
93
m_robDataProvider
->processCachedROBs( context,
94
[&](
const
IROBDataProviderSvc::ROBF
* rob ){
95
if
( 1120005 == rob->rob_source_id() )
96
ATH_MSG_DEBUG
(
"rob in the cache "
<< rob->rob_source_id() ); }
97
);
98
99
100
101
return
StatusCode::SUCCESS;
102
}
103
104
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ParallelCallTest.h
ROBDataProviderMTTest.h
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition
RawEvent.h:37
AskForROBs
Definition
ROBDataProviderMTTest.cxx:29
AskForROBs::m_context
EventContext m_context
Definition
ROBDataProviderMTTest.cxx:55
AskForROBs::m_lvl1ID
uint32_t m_lvl1ID
Definition
ROBDataProviderMTTest.cxx:53
AskForROBs::m_svc
const ServiceHandle< IROBDataProviderSvc > & m_svc
Definition
ROBDataProviderMTTest.cxx:56
AskForROBs::callAndCompare
virtual bool callAndCompare() const override
a function that performs request, and compares the results obtained with the result of the first exec...
Definition
ROBDataProviderMTTest.cxx:42
AskForROBs::m_ROBIDs
std::vector< uint32_t > m_ROBIDs
Definition
ROBDataProviderMTTest.cxx:54
AskForROBs::firstCall
virtual void firstCall() override
a method that will be called to obtain first results from the service It should set the reference qua...
Definition
ROBDataProviderMTTest.cxx:41
AskForROBs::nrobs
size_t nrobs() const
Definition
ROBDataProviderMTTest.cxx:40
AskForROBs::AskForROBs
AskForROBs(const EventContext &context, const ServiceHandle< IROBDataProviderSvc > &svc, uint32_t lvl1ID, const std::vector< eformat::read::ROBFragment > &robs, size_t frac=8)
Definition
ROBDataProviderMTTest.cxx:31
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
IROBDataProviderSvc::ROBF
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF
Definition
IROBDataProviderSvc.h:24
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition
IROBDataProviderSvc.h:25
ParallelCallTest
Provides interface and helper functions to perform stress testing of the thread-safe code.
Definition
ParallelCallTest.h:30
ParallelCallTest::launchTests
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 potent...
Definition
ParallelCallTest.cxx:83
ROBDataProviderMTTest::initialize
StatusCode initialize() override
Definition
ROBDataProviderMTTest.cxx:19
ROBDataProviderMTTest::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Definition
ROBDataProviderMTTest.h:36
ROBDataProviderMTTest::execute
StatusCode execute(const EventContext &context) const override
Definition
ROBDataProviderMTTest.cxx:61
ROBDataProviderMTTest::ROBDataProviderMTTest
ROBDataProviderMTTest()
ROBDataProviderMTTest::~ROBDataProviderMTTest
virtual ~ROBDataProviderMTTest()
Definition
ROBDataProviderMTTest.cxx:17
ROBDataProviderMTTest::finalize
StatusCode finalize() override
Definition
ROBDataProviderMTTest.cxx:25
ServiceHandle
Definition
ClusterMakerTool.h:36
r
int r
Definition
globals.cxx:22
ev
int ev
Definition
globals.cxx:25
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
std::shuffle
void shuffle(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, UniformRandom &g)
Specialization of shuffle for DataVector/List.
Definition
DVL_algorithms.h:839
random.h
Very simple random numbers for regression testing.
Athena_test::URNG
Generator compatible with the C++11 STL UniformRandomNumberGenerator.
Definition
random.h:78
Generated on
for ATLAS Offline Software by
1.17.0