ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::HICentralityDecorationTool Class Reference

#include <HICentralityDecorationTool.h>

Inheritance diagram for DerivationFramework::HICentralityDecorationTool:
Collaboration diagram for DerivationFramework::HICentralityDecorationTool:

Public Member Functions

 HICentralityDecorationTool (const std::string &type, const std::string &name, const IInterface *parent)
 
StatusCode initialize () override final
 
virtual StatusCode addBranches (const EventContext &ctx) const override
 

Private Attributes

SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey { this, "EventInfoKey", "EventInfo", "" }
 
Gaudi::Property< std::string > m_centralityDefinitionFile {this, "centralityDefinitionFile", "HIEventUtils/HeavyIonAnalysis2015_centrality_cuts_Gv32_proposed.txt", "File for centrality definitions"}
 
std::vector< float > m_centralityPercentiles
 
std::vector< float > m_fCalValues
 

Detailed Description

Definition at line 19 of file HICentralityDecorationTool.h.

Constructor & Destructor Documentation

◆ HICentralityDecorationTool()

DerivationFramework::HICentralityDecorationTool::HICentralityDecorationTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 13 of file HICentralityDecorationTool.cxx.

14  : base_class(type, name, parent) {
15  }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::HICentralityDecorationTool::addBranches ( const EventContext &  ctx) const
overridevirtual

Definition at line 60 of file HICentralityDecorationTool.cxx.

61  {
62  // Load event EventInfo
64 
65  // Set up the decorators for centrality
66  const static SG::AuxElement::Decorator< float > ecCentralityMin("CentralityMin") ;
67  const static SG::AuxElement::Decorator< float > ecCentralityMax("CentralityMax") ;
68 
69  const static SG::AuxElement::ConstAccessor<float> acc_FCalEtA("FCalEtA");
70  const static SG::AuxElement::ConstAccessor<float> acc_FCalEtC("FCalEtC");
71 
72  // Calculate total FCal ET
73  float total_fcal_et = (acc_FCalEtA(*eventInfo) + acc_FCalEtC(*eventInfo)) / 1.e6;
74 
75  float centralityMin = 0.0;
76  float centralityMax = 100.0;
77  bool foundRange = false;
78  for (size_t i = 0; i < m_fCalValues.size(); ++i) {
79  if (total_fcal_et < m_fCalValues[i]) {
80  centralityMin = m_centralityPercentiles[i];
81  foundRange = true;
82  break;
83  }
84  centralityMax = m_centralityPercentiles[i];
85  }
86  if (!foundRange) {
87  // Top possible range
88  centralityMin = 0.;
89  }
90 
91  // Decorate eventInfo with centrality values
92  ecCentralityMin(*eventInfo) = centralityMin;
93  ecCentralityMax(*eventInfo) = centralityMax;
94 
95  return StatusCode::SUCCESS;
96  }

◆ initialize()

StatusCode DerivationFramework::HICentralityDecorationTool::initialize ( )
finaloverride

Definition at line 18 of file HICentralityDecorationTool.cxx.

18  {
19 
21  // Resolve the path to the centrality definition file
22  std::string resolvedPath = PathResolver::find_file(m_centralityDefinitionFile, "CALIBPATH");
23 
24  // Debug message to print the resolved path or indicate failure
25  if (resolvedPath.empty()) {
26  ATH_MSG_ERROR("Could not find centrality definition file: " << m_centralityDefinitionFile);
27  return StatusCode::FAILURE;
28  }
29 
30  std::ifstream infile(resolvedPath);
31  if (!infile.is_open()) {
32  ATH_MSG_ERROR("Could not open centrality definition file: " << resolvedPath);
33  return StatusCode::FAILURE;
34  }
35 
36  std::string line;
37  for (int i = 0; i < 3; ++i) {
38  std::getline(infile, line); // Skip header lines
39  }
40 
41  while (std::getline(infile, line)) {
42  std::istringstream iss(line);
43  std::string centileStr;
44  float fCal, centile;
45 
46  if (iss >> centileStr >> std::skipws >> fCal) {
47  centileStr.pop_back(); // Remove '%' character
48  centile = std::stof(centileStr);
49  m_centralityPercentiles.push_back(centile);
50  m_fCalValues.push_back(fCal);
51  } else {
52  ATH_MSG_WARNING("Could not parse line: " << line);
53  }
54  }
55 
56  infile.close();
57  return StatusCode::SUCCESS;
58  }

Member Data Documentation

◆ m_centralityDefinitionFile

Gaudi::Property<std::string> DerivationFramework::HICentralityDecorationTool::m_centralityDefinitionFile {this, "centralityDefinitionFile", "HIEventUtils/HeavyIonAnalysis2015_centrality_cuts_Gv32_proposed.txt", "File for centrality definitions"}
private

Definition at line 31 of file HICentralityDecorationTool.h.

◆ m_centralityPercentiles

std::vector<float> DerivationFramework::HICentralityDecorationTool::m_centralityPercentiles
private

Definition at line 33 of file HICentralityDecorationTool.h.

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> DerivationFramework::HICentralityDecorationTool::m_eventInfoKey { this, "EventInfoKey", "EventInfo", "" }
private

Definition at line 30 of file HICentralityDecorationTool.h.

◆ m_fCalValues

std::vector<float> DerivationFramework::HICentralityDecorationTool::m_fCalValues
private

Definition at line 34 of file HICentralityDecorationTool.h.


The documentation for this class was generated from the following files:
DerivationFramework::HICentralityDecorationTool::m_fCalValues
std::vector< float > m_fCalValues
Definition: HICentralityDecorationTool.h:34
run.infile
string infile
Definition: run.py:13
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::HICentralityDecorationTool::m_centralityPercentiles
std::vector< float > m_centralityPercentiles
Definition: HICentralityDecorationTool.h:33
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
dq_defect_bulk_create_defects.line
line
Definition: dq_defect_bulk_create_defects.py:27
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DerivationFramework::HICentralityDecorationTool::m_centralityDefinitionFile
Gaudi::Property< std::string > m_centralityDefinitionFile
Definition: HICentralityDecorationTool.h:31
DerivationFramework::HICentralityDecorationTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: HICentralityDecorationTool.h:30
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Definition: PathResolver.cxx:221