ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCoolIdTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "GaudiKernel/MsgStream.h"
7#include "Identifier/Identifier.h"
11
12//_______________________________________________________________
14 const std::string& name,
15 const IInterface* parent) :
16 AthAlgTool(type, name, parent),
17 m_calo_id(nullptr)
18{
19declareInterface<ICaloCoolIdTool>( this );
20}
21
22//
23//_______________________________________________________________
25= default;
26
27//
28//_______________________________________________________________
29StatusCode
31{
32 StatusCode sc=detStore()->retrieve(m_calo_id,"CaloCell_ID");
33 if (sc.isFailure()) {
34 msg(MSG::ERROR) << "Failed to retrieve CaloCell_ID" << endmsg;
35 return sc;
36 }
37
38 return StatusCode::SUCCESS;
39}
40
41//
42//_______________________________________________________________
43unsigned int
44CaloCoolIdTool::getCoolChannelId(unsigned int cellHash, unsigned int& subHash) const
45{
46 int subCalo(0);
47 subHash = m_calo_id->subcalo_cell_hash(cellHash, subCalo);
48 //std::cout << "Starting with hash=" << cellHash << ", SubCalo=" << subCalo << " subHash=" << subHash << std::endl;
49 //=== EM calo
50 if (subCalo==CaloCell_ID::LAREM) {
51 //Sub-Calo hash gymastics to get sub-sub-calo hash (EMECA, EMBA, EMBC EMEC)
52 //(faster than converting hash to identfier and dealing with identifier)
53 //Here are the magic numbers:
54 // Hash order in LAREMCAL:
55 //Calo Offset
56 //EMEC NEG 0
57 //EMB NEG 31872
58 //EMB POS 31872 + 54784 = 86656
59 //EMEC POS 31872 + 54784 + 54784 =141440
60
61 if (subHash >= 141440) {
62 subHash-=141440;
63 return static_cast<unsigned int>(CaloCondUtils::EMECZPOS);
64 }
65 else if (subHash>=86656) {
66 subHash-=86656;
67 return static_cast<unsigned int>(CaloCondUtils::EMBZPOS);
68 }
69 else if (subHash>=31872) {
70 subHash-=31872;
71 return static_cast<unsigned int>(CaloCondUtils::EMBZNEG);
72 }
73 else
74 return static_cast<unsigned int>(CaloCondUtils::EMECZNEG);
75 }// end if LAr EM
76 else if(subCalo==CaloCell_ID::LARHEC){
77 return static_cast<unsigned int>(CaloCondUtils::HEC);
78 }
79 //=== FCAL
80 else if(subCalo==CaloCell_ID::LARFCAL){
81 return static_cast<unsigned int>(CaloCondUtils::FCAL);
82 }
83 //=== TILE
84 else if(subCalo==CaloCell_ID::TILE) {
85 return static_cast<unsigned int>(CaloCondUtils::TILE);
86 }
87
88 //=== we should never go here
89
90 msg(MSG::ERROR) << "cellHash is neither LAr nor Tile, something is deeply wrong" << endmsg;
91 std::abort();
92}
#define endmsg
static Double_t sc
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
virtual ~CaloCoolIdTool()
Dtor.
StatusCode initialize()
Initializes the tool.
unsigned int getCoolChannelId(unsigned int cellHash, unsigned int &subHash) const
Returns the cool channel id and subHash for a given calorimter cell.
const CaloCell_ID * m_calo_id
CaloCoolIdTool(const std::string &type, const std::string &name, const IInterface *parent)
Ctor.