|
ATLAS Offline Software
|
Go to the documentation of this file.
11 #include "CaloDetDescr/CaloDetDescrElement.h"
17 m_caloTowerContainerKey(
"CmbTowers") {
33 return StatusCode::SUCCESS;
43 if( caloTowerContainer.
record (std::make_unique<xAOD::CaloTowerContainer>(),
44 std::make_unique<xAOD::CaloTowerAuxContainer>()).isSuccess())
50 const int nTowers=caloTowerContainer->
nTowers();
52 for (
int iTower=0;iTower<nTowers;++iTower) {
59 return caloTowerContainer;
67 if(
fillIndexCache(ctx,cellToTower).isFailure()) cellToTower.clear();
80 return StatusCode::FAILURE;
92 const int nTowers=
dummy->nTowers();
95 ATH_MSG_ERROR(
"Something went wrong with tower grid config: Got container with " << nTowers <<
" Towers." );
96 return StatusCode::FAILURE;
99 ATH_MSG_INFO(
"Working on tower container with dEta=" <<
dummy->deltaEta() <<
", dPhi="
100 <<
dummy->deltaPhi() <<
", nTowers=" << nTowers);
106 const std::array<double,3> ndxFCal={{4.,4.,6.}};
107 const std::array<double,3> ndyFCal={{4.,6.,6.}};
116 double xCell = dde->
x();
117 double yCell = dde->
y();
118 double zCell = dde->
z();
119 double dxCell = dde->
dx();
120 double dyCell = dde->
dy();
124 double theXBin = dxCell / ndxFCal[thisModule];
125 double theYBin = dyCell / ndyFCal[thisModule];
126 double theWeight = 1. / (ndxFCal[thisModule] * ndyFCal[thisModule]);
129 for (
int iX=0;
iX<ndxFCal[thisModule];++
iX) {
130 double x=xCell-dxCell/2.0 +
iX*theXBin;
131 for (
int iY=0;
iY<ndyFCal[thisModule];++
iY) {
132 double y=yCell-dyCell/2.0 +
iY*theYBin;
135 double r = sqrt(
x *
x +
y *
y + zCell * zCell );
136 double eta = -0.5 *
log((
r-zCell)/(
r+zCell));
140 if (towerIdx>=nTowers || towerIdx<0) {
141 ATH_MSG_ERROR(
"Found invalid tower index for FCAL cell eta/phi " <<
eta <<
"/" <<
phi <<
", x/y=" <<
x <<
"/" <<
y);
142 return StatusCode::FAILURE;
145 cellToTower[dde->
calo_hash()].emplace_back(towerIdx,theWeight);
146 ATH_MSG_VERBOSE(
"cell hash " << dde->
calo_hash() <<
", goes into tower " << towerIdx <<
" with weight " << theWeight);
153 const double cellDeta = dde->
deta();
154 const double cellDphi = dde->
dphi();
155 const double etaRaw = dde->
eta_raw();
159 size_t ke = (size_t) (cellDeta/
dummy->deltaEta()+0.5);
160 ke = (ke==0) ? 1 : ke;
161 size_t kp = (size_t) (cellDphi/
dummy->deltaPhi()+0.5);
162 kp = (kp==0) ? 1 : kp;
164 if ( ke>1 || kp>1 ) {
166 <<
"] spanning several towers. nEta=" << ke <<
"nPhi="<<kp );
170 double theWeight = 1. / ( (
double) ke * kp );
172 double cellDdeta = cellDeta / (
double) ke;
173 double cellDdphi = cellDphi / (
double) kp;
174 double etaMin = etaRaw - cellDeta / 2.;
175 double phiMin = phiRaw - cellDphi / 2.;
179 for (
size_t ie=1;
ie<=ke;
ie++ ){
181 for (
size_t ip=1;
ip<=kp;
ip++ ){
182 double cellPhi = phiMin + ((
double)
ip - 0.5) * cellDdphi;
183 int towerIdx=
dummy->index(cellEta,cellPhi);
184 if (towerIdx>=nTowers || towerIdx<0) {
185 ATH_MSG_ERROR(
"Found invalid tower index " << towerIdx <<
" for cell eta/phi " << cellEta <<
"/" << cellPhi <<
" coming from " << dde->
calo_hash() <<
"/" <<
ie <<
"/" <<
ip);
186 return StatusCode::FAILURE;
189 ATH_MSG_VERBOSE(
"cell hash " << dde->
calo_hash() <<
", goes into tower " << towerIdx <<
"with weight" << theWeight);
199 for (
size_t i=0;
i<cellToTower.size(); ++
i) {
200 const auto& towerinfo=cellToTower[
i];
201 if (!towerinfo.empty()) {
202 ATH_MSG_DEBUG(
"Cell with index " <<
i <<
" contributes to " << towerinfo.size() <<
" Towers.");
207 << std::hex <<
id.get_identifier32().get_compact() << std::dec
208 <<
"does not contribute to any tower!");
212 if (fabs(sumWeight-1)>0.001) {
215 << std::hex <<
id.get_identifier32().get_compact() << std::dec
216 <<
": Weights don't add up to 1.0, got " << sumWeight );
221 ATH_MSG_DEBUG(
"Built CelltoTower index table. nCells=" << cellToTower.size() <<
", nTowers=" << nTowers);
223 return StatusCode::SUCCESS;
float deta() const
cell deta
def retrieve(aClass, aKey=None)
const T * ptr() const
Return a pointer to the cached value.
Basic container storing all information need for xAOD::CaloTower_v1 objects.
Scalar phi() const
phi method
calo_element_const_iterator element_end() const
end of element vector
~CaloTowerxAODAlgoBase()
destructor
Scalar eta() const
pseudorapidity method
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
bool isValid() const
Test to see if the value is valid.
const CellToTowerVec & getIndexCache(const EventContext &ctx) const
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
bool m_doxCheck
Turn on internal checks (debugging)
value_type get_compact() const
Get the compact id.
#define ATH_MSG_VERBOSE(x)
Definition of CaloDetDescrManager.
float eta_raw() const
cell eta_raw
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
An algorithm that can be simultaneously executed in multiple threads.
Identifier identify() const override final
cell identifier
StatusCode fillIndexCache(const EventContext &ctx, CellToTowerVec &cellToTower) const
IdentifierHash calo_hash() const
cell calo hash
std::vector< std::vector< cellToTower_t > > CellToTowerVec
::StatusCode StatusCode
StatusCode definition for legacy code.
float m_maxEta
Tower-grid: upper eta boundary.
float m_minEta
Tower-grid: lower eta boundary.
SG::WriteHandle< xAOD::CaloTowerContainer > makeContainer(const EventContext &ctx) const
Intialize m_cellToTower cache.
CaloPhiRange class declaration.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Helper class for offline cell identifiers.
int m_nEtaBins
Tower-grid: number of phi bins.
bool is_lar_fcal() const
cell belongs to FCAL
static double fix(double phi)
CaloTowerxAODAlgoBase(const std::string &name, ISvcLocator *pSvcLocator)
Default algorithm constructor.
void setEnergy(double energy)
Sets the energy.
CxxUtils::CachedValue< CellToTowerVec > m_cellToTower
map of cell indices to tower indices and weights
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode initialize(bool used=true)
SG::WriteHandleKey< xAOD::CaloTowerContainer > m_caloTowerContainerKey
Handle to xAOD::CaloTowerContainer.
void set(const T &val) const
Set the value, assuming it is currently invalid.
calo_element_const_iterator element_begin() const
first element
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
float dphi() const
cell dphi
virtual int getLayer() const
cell layer
This class provides the client interface for accessing the detector description information common to...
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
calo_element_vec_size element_size() const
total number of elements
int m_nPhiBins
Tower-grid: number of phi bins.
Tranform iterator over pointers to iterator over const pointers.
bool configureGrid(int nEtaBins, double etaMin, double etaMax, int nPhiBins)
float phi_raw() const
cell phi_raw