ATLAS Offline Software
Loading...
Searching...
No Matches
TileCellToTTL1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//*****************************************************************************
6// Filename : TileCellToTTL1.cxx
7// Author : Monica Dunford
8// Created : Oct, 2009
9//
10// DESCRIPTION:
11// This is a tool which builds the L1 tower energy from the energy measured
12// by the tile cells. This tool is useful for L1Calo to compare their
13// tower energy to that measured by the digital readout in tile
14//
15//
16// HISTORY:
17//
18// BUGS:
19//
20//*****************************************************************************
21
22// Tile includes
23#include "TileCellToTTL1.h"
25
26// Calo includes
29
30// Atlas includes
34
35//C++ STL includes
36#include <vector>
37
38//
39// Constructor
40//
41TileCellToTTL1::TileCellToTTL1(const std::string& name, ISvcLocator* pSvcLocator)
42 : AthAlgorithm(name, pSvcLocator)
43 , m_tileID(0)
44 , m_TT_ID(0)
46{
47
48}
49
52
53//
54// Alg standard initialize function
55//
57
58 // retrieve CaloLVL1_ID, TileID, from det store
59 CHECK( detStore()->retrieve(m_TT_ID));
60 CHECK( detStore()->retrieve(m_tileID));
61
63
64 ATH_CHECK( m_cellContainerKey.initialize() );
65 ATH_CHECK( m_ttl1CellContainerKey.initialize() );
66
67 ATH_MSG_INFO( "TileCellToTTL1 initialization completed");
68
69 return StatusCode::SUCCESS;
70}
71/*==========================================================================*/
72//
73// Begin Execution Phase.
74//
75StatusCode TileCellToTTL1::execute(const EventContext& ctx) {
76
77 ATH_MSG_DEBUG( "Executing TileCellToTTL1");
78
79 // -------------------------------------------------
80 // Load the TileCell container
81 // -------------------------------------------------
82
84 ATH_CHECK( cellContainer.isValid() );
85
86 // -------------------------------------------------
87 // Create TTL1 container and other arrays
88 // -------------------------------------------------
90
91 // Register the TTL1 container in the TES
92 ATH_CHECK( ttl1CellContainer.record(std::make_unique<TileTTL1CellContainer>()) );
93 ATH_MSG_DEBUG( "TileTTL1Container registered successfully (" << m_ttl1CellContainerKey.key() << ")");
94
95 struct Arrays {
96 int ttNpmt[32][64] = {{0}}; // array of TT occupancy
97 Identifier ttId[32][64]; // array of TT identifiers
98 float ttAmp[32][64] = {{0}}; // array of all TT amplitudes
99 uint16_t ttStatusCells[32][64] = {{0}}; // array of TT status of cells
100 uint16_t ttStatusChans[32][64] = {{0}}; // array of TT status of channels
101 float ttTimeAve[32][64] = {{0}}; // array of TT time average
102 float ttCorrFact[32][64] = {{0}}; // array of TT correction factor
103 };
104 auto a = std::make_unique<Arrays>();
105
106 // clear the arrays
107 for (int i = 0; i < 32; i++) {
108 for (int j = 0; j < 64; j++) {
109 a->ttCorrFact[i][j] = 1.0; // this is a place holder for now, set to 1.0
110 }
111 }
112
113 // -------------------------------------------------
114 // Loop over all cells
115 // -------------------------------------------------
116
117 for (const CaloCell* cell : *cellContainer) {
118
119 // keep only cells from TileCal calorimeter barrel or extended barrel
120 Identifier cell_id = cell->ID();
121 if (!(m_tileID->is_tile(cell_id))) continue;
122
123 const TileCell* tilecell = dynamic_cast<const TileCell*>(cell);
124 if (!tilecell) continue;
125
126 float cell_ene = cell->energy();
127 float cell_time = cell->time();
128
129 int bad_cell = tilecell->badcell();
130 int bad_chan[2];
131 bad_chan[0] = tilecell->badch1();
132 bad_chan[1] = tilecell->badch2();
133
134 // In order to make sure that the D-cells are correctly added
135 // across two towers. Loop over the two PMTs in each cell
136 // for each PMT reduce the cell energy by 50%.
137
138 for (int ipmt = 0; ipmt < 2; ipmt++) {
139 Identifier pmt_id = m_tileID->pmt_id(cell_id, ipmt);
140 Identifier tt_id = m_tileCablingService->pmt2tt_id(pmt_id);
141
142 // remove the E-cells
143 int sample = m_tileID->sample(pmt_id);
144 if (sample == TileID::SAMP_E) continue;
145
146 // if in the negative eta region add 16 to the ieta offset arrays
147 int eta_offset = 0;
148 if (m_tileID->is_negative(pmt_id))
149 eta_offset = 16;
150
151 // the D0 cell is not being split correctly across cells
152 int ieta = m_TT_ID->eta(tt_id);
153 if (sample == TileID::SAMP_D && ieta == 0 && ipmt == 1)
154 eta_offset = 16;
155
156 ieta += eta_offset;
157 int iphi = m_TT_ID->phi(tt_id);
158
159 // Sum the tower energy
160 // already exists - just add charge
161 // reduce cell energy by 50% because we are loop over both pmts in cell
162 if (a->ttNpmt[ieta][iphi] > 0) {
163 a->ttAmp[ieta][iphi] += cell_ene * 0.5;
164 a->ttNpmt[ieta][iphi]++;
165 a->ttStatusCells[ieta][iphi] += (uint16_t) bad_cell;
166 a->ttStatusChans[ieta][iphi] += (uint16_t) bad_chan[ipmt];
167 a->ttTimeAve[ieta][iphi] += cell_time;
168
169 // rawChannel in new TT
170 } else {
171 a->ttId[ieta][iphi] = tt_id;
172 a->ttNpmt[ieta][iphi]++;
173 a->ttAmp[ieta][iphi] = cell_ene * 0.5;
174 a->ttStatusCells[ieta][iphi] = (uint16_t) bad_cell;
175 a->ttStatusChans[ieta][iphi] = (uint16_t) bad_chan[ipmt];
176 a->ttTimeAve[ieta][iphi] = cell_time;
177 }
178
179 } // end of loop over pmts in the cell
180 } // end loop over cells
181
182 for (int ieta = 0; ieta < 32; ieta++) {
183 for (int iphi = 0; iphi < 64; iphi++) {
184
185 // don't load towers that are empty
186 if (a->ttNpmt[ieta][iphi] == 0) continue;
187
188 float time_ave = a->ttTimeAve[ieta][iphi] / ((float) a->ttNpmt[ieta][iphi]);
189
190 uint16_t qual = 0;
191 if (a->ttStatusChans[ieta][iphi] == a->ttNpmt[ieta][iphi])
193 if (a->ttStatusCells[ieta][iphi] > 0)
195 if (a->ttStatusChans[ieta][iphi] > 0)
197
198 ttl1CellContainer->push_back(std::make_unique<TileTTL1Cell>(a->ttId[ieta][iphi],
199 a->ttAmp[ieta][iphi],
200 time_ave,
201 a->ttCorrFact[ieta][iphi],
202 qual));
203
204 }
205 }
206
207
208 // Execution completed
209 ATH_MSG_DEBUG( "TileCellToTTL1 execution completed.");
210
211 return StatusCode::SUCCESS;
212}
213
215
216 ATH_MSG_INFO( "TileCellToTTL1::finalize() end");
217
218 return StatusCode::SUCCESS;
219}
220
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t a
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
static const TileCablingService * getInstance()
get pointer to service instance
TileCellToTTL1(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
SG::WriteHandleKey< TileTTL1CellContainer > m_ttl1CellContainerKey
const TileID * m_tileID
StatusCode execute(const EventContext &ctx)
Execute method.
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
const CaloLVL1_ID * m_TT_ID
virtual ~TileCellToTTL1()
const TileCablingService * m_tileCablingService
StatusCode finalize()
virtual bool badcell(void) const override final
check if whole cell is bad (i.e.
Definition TileCell.h:214
bool badch1(void) const
check if first PMT is in bad channel list and masked
Definition TileCell.h:209
bool badch2(void) const
check if second PMT is in bad channel list and masked
Definition TileCell.h:212