ATLAS Offline Software
ExtractCaloGeoConstants.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 ExtractCaloGeoConstants::ExtractCaloGeoConstants(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
8 {
9 }
10 
12 {
15 
16  CHECK( m_thistSvc.retrieve() );
17 
18  m_h3_w=new TH3F("h3_w","; #it{#eta}; #it{phi}; Sampling",100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
19  m_h3_eta=new TH3F("h3_eta","; #it{#eta}; #it{phi}; Sampling",100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
20  m_h3_phi=new TH3F("h3_phi","; #it{#eta}; #it{phi}; Sampling",100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
21  m_h3_R=new TH3F("h3_R","; #it{#eta}; #it{phi}; Sampling",100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
22  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_w->GetName(), m_h3_w));
23  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_eta->GetName(), m_h3_eta));
24  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_phi->GetName(), m_h3_phi));
25  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_R->GetName(), m_h3_R));
26 
27  return StatusCode::SUCCESS;
28 }
29 
31 {
32  // retrieve the tower container
34  if (!navInColl.isValid()) {
35  ATH_MSG_ERROR("Could not find CaloTowerContainer " << m_tower_container_key);
36  return(StatusCode::FAILURE);
37  }
38 
39  // retrieve cell container
41  if (!cellColl.isValid()) {
42  ATH_MSG_ERROR("Could not find CaloCellContainer " << m_cell_container_key);
43  return(StatusCode::FAILURE);
44  }
45 
46  // loop on towers
47  for(auto towerItr : *navInColl)
48  {
49  // navigate back to cells
50  // Default is to sort the cells by either pointer values leading to irreproducible output
51  // CaloCellIDFcn ensures cells are ordered by their IDs
53  towerItr->fillToken(cellToken,double(1.));
54  if ( cellToken.size() == 0 ) continue;
56  cellItr != cellToken.end(); ++cellItr )
57  {
58  double geoWeight = cellToken.getParameter(*cellItr);
59  int layer = (*cellItr)->caloDDE()->getSampling();
60  double cell_x=(*cellItr)->caloDDE()->x();
61  double cell_y=(*cellItr)->caloDDE()->y();
62  double cell_z=(*cellItr)->caloDDE()->z();
63  double cell_r2=cell_x*cell_x+cell_y*cell_y+cell_z*cell_z;
64  float deta=(*cellItr)->caloDDE()->deta();
65  float dphi=(*cellItr)->caloDDE()->dphi();
66  float area= std::abs(deta*dphi)*geoWeight;
67  m_h3_w->Fill(towerItr->eta(),towerItr->phi(),layer,area);
68  m_h3_eta->Fill(towerItr->eta(),towerItr->phi(),layer,area*(*cellItr)->eta());
69  m_h3_phi->Fill(towerItr->eta(),towerItr->phi(),layer,area*(*cellItr)->phi());
70  m_h3_R->Fill(towerItr->eta(),towerItr->phi(),layer,area*area*cell_r2);
71 
72  }//end cell loop
73  }//end tower loop
74  return StatusCode::SUCCESS;
75 }
76 
78 {
79  return StatusCode::SUCCESS;
80 }
81 
82 
ExtractCaloGeoConstants::m_tower_container_key
SG::ReadHandleKey< CaloTowerContainer > m_tower_container_key
Definition: ExtractCaloGeoConstants.h:31
ExtractCaloGeoConstants::initialize
virtual StatusCode initialize()
Definition: ExtractCaloGeoConstants.cxx:11
ExtractCaloGeoConstants.h
ExtractCaloGeoConstants::m_h3_R
TH3F * m_h3_R
Definition: ExtractCaloGeoConstants.h:40
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ExtractCaloGeoConstants::m_h3_eta
TH3F * m_h3_eta
Definition: ExtractCaloGeoConstants.h:38
ExtractCaloGeoConstants::execute
virtual StatusCode execute()
Definition: ExtractCaloGeoConstants.cxx:30
ExtractCaloGeoConstants::ExtractCaloGeoConstants
ExtractCaloGeoConstants(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ExtractCaloGeoConstants.cxx:7
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ExtractCaloGeoConstants::m_h3_phi
TH3F * m_h3_phi
Definition: ExtractCaloGeoConstants.h:39
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
NavigationToken::begin
const_iterator begin() const
Definition: NavigationToken.h:229
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
NavigationToken
Definition: NavigationToken.h:50
ExtractCaloGeoConstants::m_hist_stream
Gaudi::Property< std::string > m_hist_stream
Definition: ExtractCaloGeoConstants.h:35
NavigationToken::end
const_iterator end() const
Definition: NavigationToken.h:230
ExtractCaloGeoConstants::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition: ExtractCaloGeoConstants.h:34
NavigationToken::NavigationTokenIterator
Definition: NavigationToken.h:72
ExtractCaloGeoConstants::finalize
virtual StatusCode finalize()
Definition: ExtractCaloGeoConstants.cxx:77
ExtractCaloGeoConstants::m_h3_w
TH3F * m_h3_w
Definition: ExtractCaloGeoConstants.h:37
NavigationToken::getParameter
CHILDPAR getParameter(const_child_ptr data) const
area
double area(double R)
Definition: ConvertStaveServices.cxx:42
NavigationToken::size
unsigned int size()
Definition: NavigationToken.h:231
ExtractCaloGeoConstants::m_cell_container_key
SG::ReadHandleKey< CaloCellContainer > m_cell_container_key
Definition: ExtractCaloGeoConstants.h:32