ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 More...
 
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 More...
 
bool run (size_t nrepeats)
 runs the stress test by invoking it the firstCall and then repetitively the callAndCompare More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

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. More...
 

Private Member Functions

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

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. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

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 ) {
40  }

◆ ~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);
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  }

◆ 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  }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ 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  }

◆ 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 }

◆ 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.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
AskForRoI::m_context
const EventContext & m_context
Definition: TestCaloDataAccess.cxx:183
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
AskForRoI::m_selRef
LArTT_Selector< LArCellCont > m_selRef
Definition: TestCaloDataAccess.cxx:187
CaloCell::phi
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition: CaloCell.h:359
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
max
#define max(a, b)
Definition: cfImp.cxx:41
AskForRoI::m_svc
const ServiceHandle< ITrigCaloDataAccessSvc > & m_svc
Definition: TestCaloDataAccess.cxx:184
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
LArTT_Selector::end
const_iterator end() const
AskForRoI::m_colRef
CaloConstCellContainer * m_colRef
Definition: TestCaloDataAccess.cxx:188
AskForRoI::m_roi
const TrigRoiDescriptor m_roi
Definition: TestCaloDataAccess.cxx:185
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
AskForRoI::m_minEtaRef
double m_minEtaRef
Definition: TestCaloDataAccess.cxx:192
AskForRoI::m_statusRef
StatusCode m_statusRef
Definition: TestCaloDataAccess.cxx:189
ParallelCallTest::firstCall
virtual void firstCall()=0
a method that will be called to obtain first results from the service It should set the reference qua...
python.setupRTTAlg.tests
list tests
Definition: setupRTTAlg.py:40
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
PUfitVar::maxEta
constexpr float maxEta
Definition: GepMETPufitAlg.cxx:13
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
ConstDataVector::clear
void clear()
Erase all the elements in the collection.
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
TTEM
@ TTEM
Definition: RegSelEnums.h:28
DIFF
#define DIFF(_name, _a, _b)
Definition: TestCaloDataAccess.cxx:19
ParallelCallTest::callAndCompare
virtual bool callAndCompare() const =0
a function that performs request, and compares the results obtained with the result of the first exec...
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
sel
sel
Definition: SUSYToolsTester.cxx:97
CaloCell::et
virtual double et() const override final
get et
Definition: CaloCell.h:407
LArTT_Selector::begin
const_iterator begin() const
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
min
#define min(a, b)
Definition: cfImp.cxx:40
AskForRoI::m_etSumRef
double m_etSumRef
Definition: TestCaloDataAccess.cxx:190
AskForRoI::m_minPhiRef
double m_minPhiRef
Definition: TestCaloDataAccess.cxx:194
LArCell
Data object for LAr calorimeter readout cell.
Definition: LArCell.h:53
LArTT_Selector< LArCellCont >
query_example.col
col
Definition: query_example.py:7
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
AskForRoI::request
StatusCode request(LArTT_Selector< LArCellCont > &sel) const
Definition: TestCaloDataAccess.cxx:45
CaloConstCellContainer
CaloCellContainer that can accept const cell pointers.
Definition: CaloConstCellContainer.h:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
RoiDescriptor::isFullscan
virtual bool isFullscan() const override final
is this a full scan RoI?
Definition: RoiDescriptor.h:132
merge.status
status
Definition: merge.py:17
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
python.compressB64.c
def c
Definition: compressB64.py:93
AskForRoI::m_maxPhiRef
double m_maxPhiRef
Definition: TestCaloDataAccess.cxx:195
AskForRoI::m_maxEtaRef
double m_maxEtaRef
Definition: TestCaloDataAccess.cxx:193
AskForRoI::m_countRef
size_t m_countRef
Definition: TestCaloDataAccess.cxx:191
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366