ATLAS Offline Software
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
LVL1::eFEXFPGATowerIdProvider Class Reference

Provide tower-FPGA mapping Load information stored in a .csv file and provide the IDs of all towers in an FPGA or an eFEX module. More...

#include <eFEXFPGATowerIdProvider.h>

Inheritance diagram for LVL1::eFEXFPGATowerIdProvider:
Collaboration diagram for LVL1::eFEXFPGATowerIdProvider:

Classes

struct  towerinfo
 Sturcture defines the id, eta and phi position of a tower. More...
 

Public Member Functions

 eFEXFPGATowerIdProvider (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor. More...
 
 ~eFEXFPGATowerIdProvider ()
 Destructor. More...
 
StatusCode initialize () override
 initialize the tool More...
 
StatusCode setAddress (const std::string &inputaddress) override
 set path to the csv file and load More...
 
StatusCode getRankedTowerIDinFPGA (int eFEXID, int FPGAID, int(&towerlist)[10][6]) const override
 obtain ordered tower IDs in an FPGA More...
 
StatusCode getRankedTowerIDineFEX (int eFEXID, int(&towerlist)[10][18]) const override
 obtain ordered tower IDs in an eFEX More...
 
bool ifhaveinputfile () const override
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

StatusCode rankTowerinFPGA (int FPGAindex) override
 rank the tower ids in an FPGA This function determines the order of towers in an FPGA. More...
 
bool hasFPGA (int) const override
 check if an FPGA exists in the csv file More...
 
StatusCode loadcsv () override
 load the mapping info in the csv file More...
 
int getFPGAIndex (int eFEXid, int FPGAid) const override
 determine the index of an FPGA More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

bool m_hascsvfile
 if the csv file is valid More...
 
std::vector< std::vector< int > * > m_towerrankingcache
 Ordered tower Ids in each FPGAs. The index is the index of the FPGA. More...
 
std::unordered_map< int, std::vector< towerinfo > * > m_alltowers
 Unordered tower Ids in each FPGAs. The index is the index of the FPGA. More...
 
std::string m_csvaddress
 path to the input csv file More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Provide tower-FPGA mapping Load information stored in a .csv file and provide the IDs of all towers in an FPGA or an eFEX module.

Definition at line 31 of file eFEXFPGATowerIdProvider.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ eFEXFPGATowerIdProvider()

LVL1::eFEXFPGATowerIdProvider::eFEXFPGATowerIdProvider ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Constructor.

Definition at line 12 of file eFEXFPGATowerIdProvider.cxx.

12  :
14 {
15  declareInterface<IeFEXFPGATowerIdProvider>(this);
16 }

◆ ~eFEXFPGATowerIdProvider()

LVL1::eFEXFPGATowerIdProvider::~eFEXFPGATowerIdProvider ( )

Destructor.

Definition at line 28 of file eFEXFPGATowerIdProvider.cxx.

29 {
30  for (auto each : m_alltowers) {
31  delete each.second;
32  }
33  m_alltowers.clear();
34  for (auto each : m_towerrankingcache) {
35  delete each;
36  each = nullptr;
37  }
38  m_hascsvfile = false;
39 }

Member Function Documentation

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getFPGAIndex()

int LVL1::eFEXFPGATowerIdProvider::getFPGAIndex ( int  eFEXid,
int  FPGAid 
) const
overrideprivatevirtual

determine the index of an FPGA

Parameters
eFEXIDId of the eFEX module (0-23)
FPGAIDId of the FPGA (0-3)
Returns
FPGA index

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 288 of file eFEXFPGATowerIdProvider.cxx.

289 {
290  // check the range of eFEX ID and FPGA ID
291  // There is supposed to be 24 eFex and each eFex
292  // contains 4 FPGAs.
293  if (FPGAid < 0 or FPGAid > 3) {
294  return -1;
295  }
296  if (eFEXid < 0 or FPGAid > 23) {
297  return -1;
298  }
299  return eFEXid * 4 + FPGAid;
300 }

◆ getRankedTowerIDineFEX()

StatusCode LVL1::eFEXFPGATowerIdProvider::getRankedTowerIDineFEX ( int  eFEXID,
int(&)  towerlist[10][18] 
) const
overridevirtual

obtain ordered tower IDs in an eFEX

Parameters
eFEXIDId of the eFEX module (0-23)
towerlista 10*18 (phi*eta) array to store the output tower Ids
Returns
status code

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 90 of file eFEXFPGATowerIdProvider.cxx.

90  {
91  int FPGA0index{ getFPGAIndex(eFEXID, 0) };
92  int FPGA1index{ getFPGAIndex(eFEXID, 1) };
93  int FPGA2index{ getFPGAIndex(eFEXID, 2) };
94  int FPGA3index{ getFPGAIndex(eFEXID, 3) };
95 
96  if (!m_towerrankingcache[FPGA0index] || !m_towerrankingcache[FPGA1index] ||
97  !m_towerrankingcache[FPGA2index] || !m_towerrankingcache[FPGA3index]) {
98  for (int i{ 0 }; i < 10; i++) {
99  for (int j{ 0 }; j < 18; j++) {
100  towerlist[i][j] = 0;
101  }
102  }
103  ATH_MSG_ERROR("FPGA mapping info missing.");
104  return StatusCode::FAILURE;
105  }
106 
107  // FPGA0
108  int vectorindex{ 0 };
109  for (int i{ 0 }; i < 10; i++) {
110  for (int j{ 0 }; j < 6; j++) {
111  towerlist[i][j] = (*m_towerrankingcache[FPGA0index]).at(vectorindex++);
112  }
113  }
114 
115  // fPGA1 skipping overlap with FPGA0 and FPGA2
116  vectorindex = 0;
117  for (int i{ 0 }; i < 10; i++) {
118  vectorindex += 2;
119  for (int j{ 2 }; j < 4; j++) {
120  towerlist[i][j + 4] = (*m_towerrankingcache[FPGA1index]).at(vectorindex++);
121  }
122  vectorindex += 2;
123  }
124 
125  // FPGA2
126  vectorindex = 0;
127  for (int i{ 0 }; i < 10; i++) {
128  for (int j{ 0 }; j < 6; j++) {
129  towerlist[i][j + 8] = (*m_towerrankingcache[FPGA2index]).at(vectorindex++);
130  }
131  }
132 
133  // FPGA4 skipping overlap with FPGA2
134  vectorindex = 0;
135  for (int i{ 0 }; i < 10; i++) {
136  vectorindex += 2;
137  for (int j{ 2 }; j < 6; j++) {
138  towerlist[i][j + 12] = (*m_towerrankingcache[FPGA3index]).at(vectorindex++);
139  }
140  }
141  return StatusCode::SUCCESS;
142 }

◆ getRankedTowerIDinFPGA()

StatusCode LVL1::eFEXFPGATowerIdProvider::getRankedTowerIDinFPGA ( int  eFEXID,
int  FPGAID,
int(&)  towerlist[10][6] 
) const
overridevirtual

obtain ordered tower IDs in an FPGA

Parameters
eFEXIDId of the eFEX module (0-23)
FPGAIDId of the FPGA (0-3)
towerlista 10*6 (phi*eta) array to store the output tower Ids
Returns
status code

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 66 of file eFEXFPGATowerIdProvider.cxx.

66  {
67  int FPGAindex{ getFPGAIndex(eFEXID, FPGAID) };
68  if (m_towerrankingcache[FPGAindex]) {
69  // obtain the tower order from cache
70  int vectorindex{ 0 };
71  for (int i{ 0 }; i < 10; i++) {
72  for (int j{ 0 }; j < 6; j++) {
73  towerlist[i][j] = (*m_towerrankingcache[FPGAindex]).at(vectorindex++);
74  }
75  }
76  }
77  // set tower ids to 0 if the information about the FPGA stored in the .csv file is damaged
78  else {
79  for (int i{ 0 }; i < 10; i++) {
80  for (int j{ 0 }; j < 6; j++) {
81  towerlist[i][j] = 0;
82  }
83  }
84  ATH_MSG_ERROR("FPGA mapping info missing.");
85  return StatusCode::FAILURE;
86  }
87  return StatusCode::SUCCESS;
88 }

◆ hasFPGA()

bool LVL1::eFEXFPGATowerIdProvider::hasFPGA ( int  FPGAindex) const
overrideprivatevirtual

check if an FPGA exists in the csv file

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 189 of file eFEXFPGATowerIdProvider.cxx.

190 {
191  // check if the info of a speific FPGA has been loaded or not
192  std::unordered_map<int, std::vector<towerinfo>*>::const_iterator haskey = m_alltowers.find(FPGAindex);
193  if (haskey == m_alltowers.end()) {
194  return false;
195  }
196  return true;
197 }

◆ ifhaveinputfile()

bool LVL1::eFEXFPGATowerIdProvider::ifhaveinputfile ( ) const
overridevirtual

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 144 of file eFEXFPGATowerIdProvider.cxx.

144  {
145  return m_hascsvfile;
146 }

◆ initialize()

StatusCode LVL1::eFEXFPGATowerIdProvider::initialize ( )
override

initialize the tool

Definition at line 18 of file eFEXFPGATowerIdProvider.cxx.

19 {
20  m_hascsvfile = false;
21  std::string csvpath = PathResolver::find_file("tower_fpga_efex_map.csv", "DATAPATH");
22  if (setAddress(csvpath) == StatusCode::FAILURE) {
23  ATH_MSG_WARNING("tower_fpga_efex_map.csv missing or invalid. Swiching to hard-coded mapping.");
24  };
25  return StatusCode::SUCCESS;
26 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

static const InterfaceID& LVL1::IeFEXFPGATowerIdProvider::interfaceID ( )
inlinestaticinherited

Definition at line 18 of file IeFEXFPGATowerIdProvider.h.

18 { return IID_IIeFEXFPGATowerIdProvider; };

◆ loadcsv()

StatusCode LVL1::eFEXFPGATowerIdProvider::loadcsv ( )
overrideprivatevirtual

load the mapping info in the csv file

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 199 of file eFEXFPGATowerIdProvider.cxx.

200 {
201  // read the .csv file line by line
202  std::string eachline;
203  std::ifstream myfile(m_csvaddress);
204  if (myfile.is_open()) {
205  while (std::getline(myfile, eachline)) {
206  // ignore text after #
207  std::string::size_type ipos = eachline.find("#");
208  if (ipos!=std::string::npos) eachline.resize(ipos);
209 
210  // prevent reading lines with only white spaces
211  if (std::all_of(eachline.begin(), eachline.end(), ::isspace)) {
212  continue;
213  }
214 
215  // ignore lines with non-digit characters
216  auto validchar = [](char ch) { return (::isspace(ch) || ::isdigit(ch) || ch==','); };
217  if (!std::all_of(eachline.begin(), eachline.end(), validchar)) {
218  ATH_MSG_INFO("invalid line '" << eachline << "'");
219  break;
220  }
221 
222  // split lines in the .csv file by comma
223  std::stringstream eachline_stream(eachline);
224  std::vector<int> numbers_in_eachline;
225  while (eachline_stream.good()) {
226  std::string tem_string;
227  std::getline(eachline_stream, tem_string, ',');
228  try {
229  numbers_in_eachline.push_back(std::stoi(tem_string));
230  }
231  catch (...) {
232  ATH_MSG_WARNING( "Invalid input in tower_fpga_efex_map.csv." );
233  return StatusCode::FAILURE;
234  }
235  }
236 
237  // There is supposed to be 5 numbers in each line:
238  // eFEX ID, FPGA ID, eTower ID, eta, phi
239  if (numbers_in_eachline.size() != 5) {
240  ATH_MSG_WARNING( "Invalid input in tower_fpga_efex_map.csv." );
241  return StatusCode::FAILURE;
242  }
243  // eta and phi are supposed to be positive
244  if (numbers_in_eachline[3] < 0 || numbers_in_eachline[4] < 0) {
245  ATH_MSG_WARNING("Invalid input in tower_fpga_efex_map.csv.");
246  // return scodefail
247  return StatusCode::FAILURE;
248  }
249  int FPGAindex = getFPGAIndex(numbers_in_eachline[0], numbers_in_eachline[1]);
250  // check the range of eFEX ID and FPGA ID
251  if (FPGAindex == -1) {
252  ATH_MSG_WARNING("Invalid input in tower_fpga_efex_map.csv.");
253  return StatusCode::FAILURE;
254  }
255  towerinfo tem_towerinfo;
256  tem_towerinfo.eTowerID = numbers_in_eachline[2];
257  // determine the sign of eta using the tower id
258  // positive: 200000-299999, 400000-499999, 600000-699999
259  // negative: 100000-199999, 300000-399999, 500000-599999
260  int etasign;
261  if (int(numbers_in_eachline[2] / 100000) % 2 != 0) {
262  etasign = -1;
263  } else {
264  etasign = 1;
265  }
266  tem_towerinfo.eTowerEta = etasign * (numbers_in_eachline[3]);
267  tem_towerinfo.eTowerPhi = numbers_in_eachline[4];
268 
269  // Create a key for the FPGA if the the FPGA key is not
270  // avaliable in the m_alltowers hash table object yet.
271  // Otherwise append the tower to the existing bucket.
272  if (hasFPGA(FPGAindex)) {
273  m_alltowers[FPGAindex]->push_back(tem_towerinfo);
274  } else {
275  std::vector<towerinfo>* FPGAinfovector = new std::vector<towerinfo>;
276  FPGAinfovector->push_back(tem_towerinfo);
277  m_alltowers[FPGAindex] = FPGAinfovector;
278  }
279  }
280  myfile.close();
281  } else {
282  ATH_MSG_WARNING("Unable to open share/tower_fpga_efex_map.csv.");
283  return StatusCode::FAILURE;
284  }
285  return StatusCode::SUCCESS;
286 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ rankTowerinFPGA()

StatusCode LVL1::eFEXFPGATowerIdProvider::rankTowerinFPGA ( int  FPGAindex)
overrideprivatevirtual

rank the tower ids in an FPGA This function determines the order of towers in an FPGA.

Towers are sorted using eta and phi, and then store the result in m_towerrankingcache object for future use.

Parameters
FPGAindexindex of the FPGA
Returns
status code
See also
getFPGAIndex

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 148 of file eFEXFPGATowerIdProvider.cxx.

149 {
150  // This function determines the order of towers in an FPGA.
151  // Towers are sorted using eta and phi, and
152  // then store the result in m_towerrankingcache object for future use.
153 
154  // If the tower order of an FPGA has not been determined yet, start sorting.
155  if (!m_towerrankingcache[FPGAindex]) {
156  std::vector<std::pair<int, int>> rankingmap;
157  // the row order is determined by eta while the column order is determined by phi
158  for (auto each : *m_alltowers[FPGAindex]) {
159  if (each.eTowerPhi < 3 && each.eTowerPhi > -1 && FPGAindex >= getFPGAIndex(21, 0)) {
160  rankingmap.push_back(std::pair<int, int>(-each.eTowerEta - (90 + each.eTowerPhi) * 100, each.eTowerID));
161  } else {
162  rankingmap.push_back(std::pair<int, int>(-each.eTowerEta - each.eTowerPhi * 100, each.eTowerID));
163  }
164  }
165  // There is supposed to be 60 towers in each FPGA
166  if (rankingmap.size() != 60) {
167  return StatusCode::FAILURE;
168  }
169  std::sort(rankingmap.begin(), rankingmap.end(),
170  [](std::pair<int, int> a, std::pair<int, int> b) {
171  // tower around eta == 0 has the same eta.
172  if (a.first == b.first) {
173  return (a.second < b.second);
174  }
175  return (a.first > b.first);
176  });
177  std::vector<int>* output = new std::vector<int>;
178  int vectorindex = 0;
179  for (int i{ 0 }; i < 10; i++) {
180  for (int j{ 0 }; j < 6; j++) {
181  output->push_back(rankingmap[vectorindex++].second);
182  }
183  }
184  m_towerrankingcache[FPGAindex] = output;
185  }
186  return StatusCode::SUCCESS;
187 }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ setAddress()

StatusCode LVL1::eFEXFPGATowerIdProvider::setAddress ( const std::string &  inputaddress)
overridevirtual

set path to the csv file and load

Implements LVL1::IeFEXFPGATowerIdProvider.

Definition at line 41 of file eFEXFPGATowerIdProvider.cxx.

42 {
43  if (inputaddress.empty()) {
44  m_hascsvfile = false;
45  return StatusCode::FAILURE;
46  }
47  m_hascsvfile = true;
48  m_csvaddress = inputaddress;
49  if (loadcsv() == StatusCode::FAILURE) {
50  m_hascsvfile = false;
51  return StatusCode::FAILURE;
52  }
53  m_towerrankingcache = std::vector<std::vector<int>*>(96, nullptr);
54  // sort the towers in each FPGA
55  for (int efex{ 0 }; efex < 24; efex++) {
56  for (int fpga{ 0 }; fpga < 4; fpga++) {
57  if (rankTowerinFPGA(getFPGAIndex(efex, fpga)) == StatusCode::FAILURE) {
58  m_hascsvfile = false;
59  return StatusCode::FAILURE;
60  }
61  }
62  }
63  return StatusCode::SUCCESS;
64 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_alltowers

std::unordered_map<int, std::vector<towerinfo>* > LVL1::eFEXFPGATowerIdProvider::m_alltowers
private

Unordered tower Ids in each FPGAs. The index is the index of the FPGA.

See also
getFPGAIndex

Definition at line 102 of file eFEXFPGATowerIdProvider.h.

◆ m_csvaddress

std::string LVL1::eFEXFPGATowerIdProvider::m_csvaddress
private

path to the input csv file

Definition at line 121 of file eFEXFPGATowerIdProvider.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_hascsvfile

bool LVL1::eFEXFPGATowerIdProvider::m_hascsvfile
private

if the csv file is valid

Definition at line 81 of file eFEXFPGATowerIdProvider.h.

◆ m_towerrankingcache

std::vector<std::vector<int>*> LVL1::eFEXFPGATowerIdProvider::m_towerrankingcache
private

Ordered tower Ids in each FPGAs. The index is the index of the FPGA.

See also
getFPGAIndex

Definition at line 99 of file eFEXFPGATowerIdProvider.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
LVL1::eFEXFPGATowerIdProvider::setAddress
StatusCode setAddress(const std::string &inputaddress) override
set path to the csv file and load
Definition: eFEXFPGATowerIdProvider.cxx:41
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge.output
output
Definition: merge.py:17
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
LVL1::eFEXFPGATowerIdProvider::m_alltowers
std::unordered_map< int, std::vector< towerinfo > * > m_alltowers
Unordered tower Ids in each FPGAs. The index is the index of the FPGA.
Definition: eFEXFPGATowerIdProvider.h:102
LVL1::eFEXFPGATowerIdProvider::getFPGAIndex
int getFPGAIndex(int eFEXid, int FPGAid) const override
determine the index of an FPGA
Definition: eFEXFPGATowerIdProvider.cxx:288
LVL1::eFEXFPGATowerIdProvider::rankTowerinFPGA
StatusCode rankTowerinFPGA(int FPGAindex) override
rank the tower ids in an FPGA This function determines the order of towers in an FPGA.
Definition: eFEXFPGATowerIdProvider.cxx:148
a
TList * a
Definition: liststreamerinfos.cxx:10
h
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1::eFEXFPGATowerIdProvider::loadcsv
StatusCode loadcsv() override
load the mapping info in the csv file
Definition: eFEXFPGATowerIdProvider.cxx:199
LVL1::eFEXFPGATowerIdProvider::hasFPGA
bool hasFPGA(int) const override
check if an FPGA exists in the csv file
Definition: eFEXFPGATowerIdProvider.cxx:189
LVL1::eFEXFPGATowerIdProvider::m_csvaddress
std::string m_csvaddress
path to the input csv file
Definition: eFEXFPGATowerIdProvider.h:121
LVL1::eFEXFPGATowerIdProvider::m_hascsvfile
bool m_hascsvfile
if the csv file is valid
Definition: eFEXFPGATowerIdProvider.h:81
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
LVL1::eFEXFPGATowerIdProvider::m_towerrankingcache
std::vector< std::vector< int > * > m_towerrankingcache
Ordered tower Ids in each FPGAs. The index is the index of the FPGA.
Definition: eFEXFPGATowerIdProvider.h:99
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
fitman.k
k
Definition: fitman.py:528