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  m_h1_events=new TH1F("h1_events","; Processed Events",1,0,1);
23  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_w->GetName(), m_h3_w));
24  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_eta->GetName(), m_h3_eta));
25  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_phi->GetName(), m_h3_phi));
26  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h3_R->GetName(), m_h3_R));
27  CHECK(m_thistSvc->regHist("/" + m_hist_stream + "/" + m_h1_events->GetName(), m_h1_events));
28 
29  return StatusCode::SUCCESS;
30 }
31 
33 {
34  // retrieve the tower container
36  if (!navInColl.isValid()) {
37  ATH_MSG_ERROR("Could not find CaloTowerContainer " << m_tower_container_key);
38  return(StatusCode::FAILURE);
39  }
40 
41  // retrieve cell container
43  if (!cellColl.isValid()) {
44  ATH_MSG_ERROR("Could not find CaloCellContainer " << m_cell_container_key);
45  return(StatusCode::FAILURE);
46  }
47 
48  // record number of processed events
49  m_h1_events->Fill(0.5);
50 
51  // loop on towers
52  for(auto towerItr : *navInColl)
53  {
54  // navigate back to cells
55  // Default is to sort the cells by either pointer values leading to irreproducible output
56  // CaloCellIDFcn ensures cells are ordered by their IDs
58  towerItr->fillToken(cellToken,double(1.));
59  if ( cellToken.size() == 0 ) continue;
61  cellItr != cellToken.end(); ++cellItr )
62  {
63  double geoWeight = cellToken.getParameter(*cellItr);
64  int layer = (*cellItr)->caloDDE()->getSampling();
65  double cell_x=(*cellItr)->caloDDE()->x();
66  double cell_y=(*cellItr)->caloDDE()->y();
67  double cell_z=(*cellItr)->caloDDE()->z();
68  double cell_r2=cell_x*cell_x+cell_y*cell_y+cell_z*cell_z;
69  float deta=(*cellItr)->caloDDE()->deta();
70  float dphi=(*cellItr)->caloDDE()->dphi();
71  float area= std::abs(deta*dphi)*geoWeight;
72  m_h3_w->Fill(towerItr->eta(),towerItr->phi(),layer,area);
73  m_h3_eta->Fill(towerItr->eta(),towerItr->phi(),layer,area*(*cellItr)->eta());
74  m_h3_phi->Fill(towerItr->eta(),towerItr->phi(),layer,area*(*cellItr)->phi());
75  m_h3_R->Fill(towerItr->eta(),towerItr->phi(),layer,area*area*cell_r2);
76 
77  }//end cell loop
78  }//end tower loop
79  return StatusCode::SUCCESS;
80 }
81 
83 {
84  return StatusCode::SUCCESS;
85 }
86 
87 
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:67
ExtractCaloGeoConstants::m_h3_eta
TH3F * m_h3_eta
Definition: ExtractCaloGeoConstants.h:38
ExtractCaloGeoConstants::m_h1_events
TH1F * m_h1_events
Definition: ExtractCaloGeoConstants.h:41
ExtractCaloGeoConstants::execute
virtual StatusCode execute()
Definition: ExtractCaloGeoConstants.cxx:32
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:240
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:82
ExtractCaloGeoConstants::m_h3_w
TH3F * m_h3_w
Definition: ExtractCaloGeoConstants.h:37
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
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