ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::HICentralityDecorationTool Class Reference

#include <HICentralityDecorationTool.h>

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

Public Member Functions

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

Member Function Documentation

◆ addBranches()

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

Definition at line 56 of file HICentralityDecorationTool.cxx.

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

◆ initialize()

StatusCode DerivationFramework::HICentralityDecorationTool::initialize ( )
finaloverridevirtual

Definition at line 14 of file HICentralityDecorationTool.cxx.

14 {
15
16 ATH_CHECK( m_eventInfoKey.initialize() );
17 // Resolve the path to the centrality definition file
18 std::string resolvedPath = PathResolver::find_file(m_centralityDefinitionFile, "CALIBPATH");
19
20 // Debug message to print the resolved path or indicate failure
21 if (resolvedPath.empty()) {
22 ATH_MSG_ERROR("Could not find centrality definition file: " << m_centralityDefinitionFile);
23 return StatusCode::FAILURE;
24 }
25
26 std::ifstream infile(resolvedPath);
27 if (!infile.is_open()) {
28 ATH_MSG_ERROR("Could not open centrality definition file: " << resolvedPath);
29 return StatusCode::FAILURE;
30 }
31
32 std::string line;
33 for (int i = 0; i < 3; ++i) {
34 std::getline(infile, line); // Skip header lines
35 }
36
37 while (std::getline(infile, line)) {
38 std::istringstream iss(line);
39 std::string centileStr;
40 float fCal, centile;
41
42 if (iss >> centileStr >> std::skipws >> fCal) {
43 centileStr.pop_back(); // Remove '%' character
44 centile = std::stof(centileStr);
45 m_centralityPercentiles.push_back(centile);
46 m_fCalValues.push_back(fCal);
47 } else {
48 ATH_MSG_WARNING("Could not parse line: " << line);
49 }
50 }
51
52 infile.close();
53 return StatusCode::SUCCESS;
54 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
str infile
Definition run.py:13

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 32 of file HICentralityDecorationTool.h.

32{this, "centralityDefinitionFile", "HIEventUtils/HeavyIonAnalysis2015_centrality_cuts_Gv32_proposed.txt", "File for centrality definitions"};

◆ m_centralityPercentiles

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

Definition at line 34 of file HICentralityDecorationTool.h.

◆ m_eventInfoKey

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

Definition at line 31 of file HICentralityDecorationTool.h.

31{ this, "EventInfoKey", "EventInfo", "" };

◆ m_fCalValues

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

Definition at line 35 of file HICentralityDecorationTool.h.


The documentation for this class was generated from the following files: