ATLAS Offline Software
Loading...
Searching...
No Matches
JTowerMappingDataCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "TH1F.h"
7#include "TFile.h"
8#include <memory>
10#include "CaloDetDescr/CaloDetDescrElement.h"
11
12namespace LVL1
13{
14 JTowerMappingDataCondAlg::JTowerMappingDataCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
16 {
17 }
18
20
22 {
24 ATH_CHECK(detStore()->retrieve(m_jtowerID));
25
26 std::unique_ptr<TFile> fIn(TFile::Open(
28 if (!fIn || fIn->IsZombie())
29 {
30 ATH_MSG_ERROR("Failed to open tower areas file " << m_towerAreasFile);
31 return StatusCode::FAILURE;
32 }
33 TH1F *areaHist = (TH1F *)fIn->Get("jTowerArea_final_hist");
34 if (!areaHist)
35 {
36 ATH_MSG_ERROR("Failed to read area histogram!");
37 return StatusCode::FAILURE;
38 }
39 m_towerAreas.clear();
40 m_towerAreas.reserve(areaHist->GetNbinsX());
41 // Normalise the areas so that the first tower has an area of 1
42 float scale = 1.0 / areaHist->GetBinContent(1);
43 for (int towerIdx = 0; towerIdx < areaHist->GetNbinsX(); ++towerIdx)
44 m_towerAreas.push_back(areaHist->GetBinContent(towerIdx + 1) * scale);
45
46 return StatusCode::SUCCESS;
47 }
48
51 const CaloSuperCellDetDescrManager *scDetMgr) const
52 {
53 ATH_MSG_INFO("# central JTowers " << data.size());
54 // Create a single JTower per forward supercell
55 for (std::size_t scHashIdx = 0; scHashIdx < m_scid->calo_cell_hash_max(); ++scHashIdx)
56 {
57 Identifier scID = m_scid->cell_id(scHashIdx);
58 if (m_scid->is_tile(scID) && m_scid->sampling(scID) != 2)
59 continue; // skipping tile SCs for now
60 const CaloDetDescrElement *dde = scDetMgr->get_element(scID);
61 if (!dde)
62 {
63 ATH_MSG_ERROR("Error loading CaloDetDescrElement");
64 return StatusCode::FAILURE;
65 }
66 float superCellEta = dde->eta_raw();
67 float superCellPhi = dde->phi_raw();
68 if (std::abs(superCellEta) < 3.1)
69 continue;
70 float superCellDEta = dde->deta();
71 float superCellDPhi = dde->dphi();
72 JGTowerHelper helper(superCellEta, superCellDEta, superCellPhi, superCellDPhi);
73 helper.SetSCIndices(scHashIdx);
74
75 std::string detName = CaloSampling::getSamplingName(m_ccid->calo_sample(scID));
76 if (detName.find("FCAL0") != std::string::npos)
77 helper.SetSampling(2);
78 else if (detName.find("FCAL1") != std::string::npos)
79 helper.SetSampling(3);
80 else if (detName.find("FCAL2") != std::string::npos)
81 helper.SetSampling(4);
82 else
83 helper.SetSampling(0);
84 data.push_back(std::move(helper));
85 }
86 ATH_MSG_INFO("# towers (including forward)");
87 return StatusCode::SUCCESS;
88 }
89
91 {
92 if (data.size() != m_towerAreas.size())
93 {
94 ATH_MSG_ERROR("Number of towers (" << data.size() << ") and number of tower areas (" << m_towerAreas.size() << ") do not match!");
95 return StatusCode::FAILURE;
96 }
97
98 for (std::size_t idx = 0; idx < m_towerAreas.size(); ++idx)
99 data.at(idx).setArea(m_towerAreas.at(idx));
100 return StatusCode::SUCCESS;
101 }
102} // namespace LVL1
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const ServiceHandle< StoreGateSvc > & detStore() const
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
JGTowerMappingDataCondAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode loadTowerAreas(JGTowerMappingData &data) const override
virtual StatusCode buildForwardMapping(JGTowerMappingData &data, const CaloSuperCellDetDescrManager *mgr) const override
JTowerMappingDataCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::string > m_towerAreasFile
virtual StatusCode initialize() override
static std::string find_calib_file(const std::string &logical_file_name)
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
std::vector< JGTowerHelper > JGTowerMappingData