6#include "tbb/parallel_reduce.h"
7#include "tbb/blocked_range.h"
10#include "Gaudi/Property.h"
19#define DIFF(_name, _a, _b) if ( _a != _b ) \
20 ATH_MSG_WARNING( "Difference in " << _name << " " << _a << " ref " << _b ); \
22 ATH_MSG_DEBUG( "Identical " << _name << " " << _a << " ref " << _b );
46 if (
m_roi.isFullscan() ){
47 std::cout <<
"wrong RoI descriptor used for RoI" << std::endl;
48 return StatusCode::FAILURE;
58 if (
m_roi.isFullscan() ){
62 std::cout <<
"wrong RoI descriptor used for FS" << std::endl;
63 return StatusCode::FAILURE;
69 Gaudi::Hive::setCurrentContext (
m_context);
70 if (
m_roi.isFullscan() ) {
71 struct timeval t1{},t2{};
72 gettimeofday(&t1,NULL);
75 gettimeofday(&t2,NULL);
77 for (
const auto cell : *
m_colRef ) {
78 if ( !cell )
continue;
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;
90 struct timeval t1{},t2{};
91 gettimeofday(&t1,NULL);
94 gettimeofday(&t2,NULL);
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;
110 Gaudi::Hive::setCurrentContext (
m_context);
116 double maxEta = -100;
118 double maxPhi = -100;
120 if (
m_roi.isFullscan() ) {
124 for (
const auto cell : col ) {
125 if ( !cell )
continue;
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() );
138 for (
const auto cell :
sel ) {
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() );
165 if ( checkStatus ==
false ) {
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() );
199 ISvcLocator* pSvcLocator ) :
201 m_dataAccessSvc(
"TrigCaloDataAccessSvc/TrigCaloDataAccessSvc", name ),
215 return StatusCode::SUCCESS;
220 std::default_random_engine generator;
221 std::normal_distribution<double> N1(0.0, 1.7);
222 std::normal_distribution<double> N2(0.0, 0.2);
223 std::uniform_real_distribution<double> U(0.0, 1.0);
224 std::uniform_real_distribution<double> Uphi(-
M_PI,
M_PI);
226 double RoI_phi1 = Uphi(generator);
227 double RoI_eta1 = N1(generator);
228 if ( RoI_eta1 < -2.5 ) RoI_eta1 = -2.5;
229 if ( RoI_eta1 > 2.5 ) RoI_eta1 = 2.5;
230 double chance = U(generator);
236 allRoIs.push_back( afr );
238 chance = U(generator);
239 if ( chance > 0.6 ) {
240 double RoI_eta2 = -RoI_eta1 + N2(generator);
241 double RoI_phi2 = -RoI_phi1 + N2(generator);
242 if ( RoI_eta2 < -2.5 ) RoI_eta2 = -2.5;
243 if ( RoI_eta2 > 2.5 ) RoI_eta2 = 2.5;
248 allRoIs.push_back( afr );
251 for(
int i=0;i<10;i++){
252 chance = U(generator);
253 if ( chance > 0.75 ) {
254 double RoI_phi3 = Uphi(generator);
255 double RoI_eta3 = N1(generator);
256 if ( RoI_eta3 < -2.5 ) RoI_eta3 = -2.5;
257 if ( RoI_eta3 > 2.5 ) RoI_eta3 = 2.5;
259 if ( chance > 0.8 )
width=0.3;
264 allRoIs.push_back( afr );
268 chance = U(generator);
269 if ( chance > 0.6 ) {
272 allRoIs.push_back( afr );
279 std::vector<TrigRoiDescriptor> rois;
281 0.1, 0.1-0.1, 0.1+0.1,
284 0.2, 0.2-0.2, 0.2+0.2,
287 2.1, 2.1-0.4, 2.1+0.4,
290 1.1, 1.1-1.4, 1.1+1.4,
292 rois.push_back(roi1);
293 rois.push_back(roi2);
294 rois.push_back(roi3);
295 rois.push_back(roi4);
299 allRoIs.push_back(t1);
302 allRoIs.push_back(t6);
310 std::vector<ParallelCallTest*> allRoIs;
317 gettimeofday(&ti1,NULL);
319 gettimeofday(&ti2,NULL);
320 std::cout << ti1.tv_sec <<
" " << ti1.tv_usec << std::endl;
321 std::cout << ti2.tv_sec <<
" " << ti2.tv_usec << std::endl;
322 std::cout << name() <<
"; time : " << 1e-6*( 1e6*(ti2.tv_sec - ti1.tv_sec) + ( ti2.tv_usec - ti1.tv_usec ) ) << std::endl;
326 return StatusCode::SUCCESS;
329 return StatusCode::SUCCESS;
#define ATH_MSG_WARNING(x)
CaloCellContainer that can accept const cell pointers.
#define CHECK(...)
Evaluate an expression and check for errors.
#define DIFF(_name, _a, _b)
The test calls for RoI data access for each RoI returned bunch of quantiries are checked,...
bool callAndCompare() const override
a function that performs request, and compares the results obtained with the result of the first exec...
StatusCode request(LArTT_Selector< LArCellCont > &sel) const
const ServiceHandle< ITrigCaloDataAccessSvc > & m_svc
const EventContext & m_context
StatusCode request(CaloConstCellContainer &c) const
const TrigRoiDescriptor m_roi
void firstCall() override
a method that will be called to obtain first results from the service It should set the reference qua...
LArTT_Selector< LArCellCont > m_selRef
AskForRoI(const EventContext &context, const ServiceHandle< ITrigCaloDataAccessSvc > &svc, const TrigRoiDescriptor &roi)
CaloConstCellContainer * m_colRef
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
An algorithm that can be simultaneously executed in multiple threads.
virtual double phi() const override final
get phi (through CaloDetDescrElement)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
virtual double et() const override final
get et
CaloCellContainer that can accept const cell pointers.
Data object for LAr calorimeter readout cell.
Provides interface and helper functions to perform stress testing of the thread-safe code.
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...
ServiceHandle< ITrigCaloDataAccessSvc > m_dataAccessSvc
virtual StatusCode initialize() override
virtual ~TestCaloDataAccess()
void emulateFixedRoIs(const EventContext &context, std::vector< ParallelCallTest * > &allRoIs) const
void emulateRoIs(const EventContext &context, std::vector< ParallelCallTest * > &allRoIs) const
virtual StatusCode execute(const EventContext &context) const override
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts