ATLAS Offline Software
Loading...
Searching...
No Matches
LArFCalTowerStore.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7NAME: LArFCalTowerStore
8PACKAGE: offline/LArCalorimeter/LArRecUtils
9
10AUTHORS: P. Loch
11CREATED: May 2001
12
13PURPOSE: Intermediate store for cell/tower maps
14
15Updated:
16
17********************************************************************/
18#include "LArFCalTowerStore.h"
19
20// include header files
23
26
29
30#include "CaloEvent/CaloTowerContainer.h"
31#include "GaudiKernel/Bootstrap.h"
32#include "GaudiKernel/Service.h"
33
34#include <cmath>
35
37// Constructor and Destructor //
39
40// constructor
42 : m_indxOffset (0),
43 m_indxBound (0)
44{
45 // some parameters
46 m_ndxFCal.resize(3);
47 m_ndyFCal.resize(3);
48 // set default
49 m_ndxFCal[0] = 4;
50 m_ndxFCal[1] = 4;
51 m_ndxFCal[2] = 6;
52 m_ndyFCal[0] = 4;
53 m_ndyFCal[1] = 6;
54 m_ndyFCal[2] = 6;
55
56 }
57
58// destructor
60// m_dataMatrix.clear();
61 m_TTCmatrix.clear();
62}
63
65// Build LookUp Table //
67
69 const CaloDetDescrManager& theManager,
70 CaloTowerContainer* theTowers)
71{
73 // Store Preparation //
75
76 // get cell id helper
77 const LArFCAL_ID& fcalIdHelper = *cellIdHelper.fcal_idHelper();
78
79 // find numerical ranges
80 IdentifierHash firstIndex, lastIndex;
81 cellIdHelper.calo_cell_hash_range((int)CaloCell_ID::LARFCAL, firstIndex, lastIndex);
82 m_indxOffset = (size_t)firstIndex;
83 m_indxBound = (size_t)lastIndex;
84
85 // check
86 if ( m_indxBound <= m_indxOffset ){
87 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "LArFCalTowerStore")
88 << "cannot initialize internal store properly, index offset = "
89 << m_indxOffset << ", index boundary = " << m_indxBound<< " -> module inactivated!"
90 << endmsg;
91 return false;
92 }
93
94 // calculate number of rows in store matrix an initialize
95// m_rowsMatrix = m_indxBound - m_indxOffset + 1;
96// for ( size_t iRow=0; iRow < m_rowsMatrix; iRow++ ){
97// m_dataMatrix.push_back(tower_data_store());
98// }
99
100 // report data store size
101// msg << MSG::INFO << "internal matrix set up with " << m_dataMatrix.size()
102 // << " rows: Index Offset: " << m_indxOffset << " Index Boundary: "<< m_indxBound << endmsg;
103
104// m_weightInModule.resize(m_rowsMatrix);
105// m_binDescriptor.resize(m_rowsMatrix);
106
107 m_TTCmatrix.clear();
108 m_TTCmatrix.resize(theTowers->size());
109
111 // Cell Loop //
113
114 // consistent phi convention
115 CaloPhiRange correctPhi;
116
117 // some stats
118/* unsigned int aveTowers = 0;
119 unsigned int maxTowers = 0;
120 unsigned int minTowers = size_t(-1); */
121
122 for( size_t cellIndex = m_indxOffset; cellIndex <= m_indxBound; cellIndex++){
123
124
125 // get cell geometry
126 const CaloDetDescrElement* theElement = theManager.get_element(cellIndex);
127 if (!theElement) {
128 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "LArFCalTowerStore")
129 << "Can't find element for index " << cellIndex << endmsg;
130 return false;
131 }
132 double xCell = theElement->x();
133 double yCell = theElement->y();
134 double zCell = theElement->z();
135 double dxCell = theElement->dx();
136 double dyCell = theElement->dy();
137
138 // get cell logical location
139 int thisModule = fcalIdHelper.module(theElement->identify());
140 // get cell splitting
141 thisModule--;
142 double theXBin = dxCell / (double)m_ndxFCal[thisModule];
143 double theYBin = dyCell / (double)m_ndyFCal[thisModule];
144 double theWeight = 1. / ((double) m_ndxFCal[thisModule] * m_ndyFCal[thisModule]);
145
146// std::pair<size_t,double> wMod(thisModule,theWeight);
147// m_weightInModule[anIndex] = wMod;
148// std::pair<size_t,size_t> iBin(m_ndxFCal[thisModule],m_ndyFCal[thisModule]);
149// m_binDescriptor[anIndex] = iBin;
150
151 // loop the cell fragments
152 for ( double x = xCell-dxCell/2.; x < xCell+(dxCell-theXBin/8.)/2.; x += theXBin ){
153 for ( double y = yCell-dyCell/2.;y < yCell+(dyCell-theYBin/8.)/2.;y += theYBin ){
154 // eta,phi of fragment
155 double r = sqrt( x * x + y * y + zCell * zCell );
156 double eta = -0.5 * log((r-zCell)/(r+zCell));
157 double phi = correctPhi.fix(atan2(y,x));
158 // get indices
159 // cppcheck-suppress duplicateAssignExpression
160 CaloTowerContainer::index_t etaIndex = theTowers->flagOutOfRange();
161 CaloTowerContainer::index_t phiIndex =theTowers->flagOutOfRange();
162 if ( theTowers->getTowerIndices(eta,phi,etaIndex,phiIndex) ){
163
164 CaloTowerContainer::index_t towerIndex = theTowers->getTowerIndex(etaIndex,phiIndex);
165 std::vector<std::pair<unsigned int,double> >::iterator i = m_TTCmatrix[towerIndex].begin();
166 std::vector<std::pair<unsigned int,double> >::iterator e = m_TTCmatrix[towerIndex].end();
167 bool found=false;
168 for (;i<e;++i){
169 if (i->first==cellIndex){
170 i->second+=theWeight;
171 found=true;
172 break;
173 }
174 }
175 if (!found)
176 m_TTCmatrix[towerIndex].push_back(std::make_pair(cellIndex,theWeight));
177
178 /*
179 // check indices in look-up
180 if ( (m_dataMatrix[anIndex]).find(towerIndex) != (m_dataMatrix[anIndex]).end() ){
181 (m_dataMatrix[anIndex])[towerIndex] += theWeight;
182 }
183 else{
184 (m_dataMatrix[anIndex])[towerIndex] = theWeight;
185 }
186 */
187
188 } // index retrieval check
189
190 } // cell y loop
191 } // cell x loop
192
193/* // collect some stats
194 if ( (m_dataMatrix[anIndex]).size() < minTowers ) minTowers = (m_dataMatrix[anIndex]).size();
195 if ( (m_dataMatrix[anIndex]).size() > maxTowers )maxTowers = (m_dataMatrix[anIndex]).size();
196 aveTowers += (m_dataMatrix[anIndex]).size(); */
197
198 } // cell index loop
199
200/* // report
201 double cellTowers = (double)aveTowers / (double)m_dataMatrix.size();
202 msg << MSG::INFO
203 << "FCal cell/tower lookup done - min/ave/max towers/cell: "
204 << minTowers << "/" << cellTowers << "/" << maxTowers
205 << ", total number of cell fragments "
206 << aveTowers
207 << endmsg; */
208
209
210
211 return 1;
212
213}
214
215
216
219{
220 return tower_subseg_iterator::make (towers(), subseg);
221}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
Definition of CaloDetDescrManager.
CaloPhiRange class declaration.
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
#define y
#define x
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Definition CaloCell_ID.h:75
This class groups all DetDescr information related to a CaloCell.
Identifier identify() const override final
cell identifier
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
This class defines the phi convention for Calorimeters.
static double fix(double phi)
Storable container class for CaloTower.
index_t getTowerIndex(const CaloTower *aTower) const
Returns the combined index of a tower on the grid.
index_t flagOutOfRange() const
Returns the index out-of-range indicator.
bool getTowerIndices(const CaloTower *aTower, index_t &indexEta, index_t &indexPhi) const
Returns both and indices for a given tower.
static SubSegIterator make(tower_iterator beg, const SubSeg &subseg)
A rectangular window within the segmentation.
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
Helper class for LArFCAL offline identifiers.
Definition LArFCAL_ID.h:49
LArFCalTowerStore()
constructor
tower_iterator towers() const
bool buildLookUp(const CaloCell_ID &cellIdHelper, const CaloDetDescrManager &theManager, CaloTowerContainer *theTowers)
setup trigger
std::vector< unsigned int > m_ndxFCal
CaloTowerSeg::SubSegIterator< tower_iterator > tower_subseg_iterator
tower_table_t m_TTCmatrix
std::vector< unsigned int > m_ndyFCal
~LArFCalTowerStore()
destructor
int r
Definition globals.cxx:22