ATLAS Offline Software
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 
12 namespace LVL1
13 {
14  JTowerMappingDataCondAlg::JTowerMappingDataCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
15  : JGTowerMappingDataCondAlgBase(name, pSvcLocator)
16  {
17  }
18 
20 
22  {
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 
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
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PathResolver::find_calib_file
static std::string find_calib_file(const std::string &logical_file_name)
Definition: PathResolver.cxx:384
JTowerMappingDataCondAlg.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LVL1::JTowerMappingDataCondAlg::m_jtowerID
const JTower_ID * m_jtowerID
Definition: JTowerMappingDataCondAlg.h:24
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
LVL1::JGTowerHelper
Definition: JGTowerHelper.h:26
CaloCell_Base_ID::calo_sample
int calo_sample(const Identifier id) const
returns an int taken from Sampling enum and describing the subCalo to which the Id belongs.
Definition: CaloCell_Base_ID.cxx:141
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::JTowerMappingDataCondAlg::JTowerMappingDataCondAlg
JTowerMappingDataCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JTowerMappingDataCondAlg.cxx:14
LVL1::JTowerMappingDataCondAlg::initialize
virtual StatusCode initialize() override
Definition: JTowerMappingDataCondAlg.cxx:21
LVL1::JTowerMappingDataCondAlg::loadTowerAreas
virtual StatusCode loadTowerAreas(JGTowerMappingData &data) const override
Definition: JTowerMappingDataCondAlg.cxx:90
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
CaloSuperCellDetDescrManager
Definition: CaloDetDescrManager.h:490
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
LVL1::JGTowerMappingDataCondAlgBase
Definition: JGTowerMappingDataCondAlgBase.h:20
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::JTowerMappingDataCondAlg::m_towerAreas
std::vector< float > m_towerAreas
Definition: JTowerMappingDataCondAlg.h:30
CaloCell_Base_ID::sampling
int sampling(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::JGTowerMappingDataCondAlgBase::m_ccid
const CaloCell_ID * m_ccid
Definition: JGTowerMappingDataCondAlgBase.h:42
LVL1::JTowerMappingDataCondAlg::buildForwardMapping
virtual StatusCode buildForwardMapping(JGTowerMappingData &data, const CaloSuperCellDetDescrManager *mgr) const override
Definition: JTowerMappingDataCondAlg.cxx:49
TrigConf::name
Definition: HLTChainList.h:35
LVL1::JGTowerMappingData
std::vector< JGTowerHelper > JGTowerMappingData
Definition: JGTowerMappingData.h:13
LVL1::JTowerMappingDataCondAlg::m_towerAreasFile
Gaudi::Property< std::string > m_towerAreasFile
Definition: JTowerMappingDataCondAlg.h:22
PathResolver.h
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
LVL1::JGTowerMappingDataCondAlgBase::initialize
virtual StatusCode initialize() override
Definition: JGTowerMappingDataCondAlgBase.cxx:25
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
CaloSampling::getSamplingName
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
Definition: Calorimeter/CaloGeoHelpers/Root/CaloSampling.cxx:18
LVL1::JTowerMappingDataCondAlg::~JTowerMappingDataCondAlg
virtual ~JTowerMappingDataCondAlg() override
Definition: JTowerMappingDataCondAlg.cxx:19
MooRTT_summarizeCPU.fIn
fIn
Definition: MooRTT_summarizeCPU.py:11
python.LArCondContChannels.detName
detName
Definition: LArCondContChannels.py:665
LVL1::JGTowerMappingDataCondAlgBase::m_scid
const CaloCell_SuperCell_ID * m_scid
Definition: JGTowerMappingDataCondAlgBase.h:41
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
Identifier
Definition: IdentifierFieldParser.cxx:14