ATLAS Offline Software
Loading...
Searching...
No Matches
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
7ExtractCaloGeoConstants::ExtractCaloGeoConstants(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
8{
9}
10
12{
13 ATH_CHECK(m_tower_container_key.initialize());
14 ATH_CHECK(m_cell_container_key.initialize());
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define CHECK(...)
Evaluate an expression and check for errors.
double area(double R)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ServiceHandle< ITHistSvc > m_thistSvc
SG::ReadHandleKey< CaloTowerContainer > m_tower_container_key
Gaudi::Property< std::string > m_hist_stream
SG::ReadHandleKey< CaloCellContainer > m_cell_container_key
ExtractCaloGeoConstants(const std::string &name, ISvcLocator *pSvcLocator)
const_iterator begin() const
CHILDPAR getParameter(const_child_ptr data) const
NavigationTokenIterator const_iterator
const_iterator end() const
unsigned int size()
virtual bool isValid() override final
Can the handle be successfully dereferenced?