ATLAS Offline Software
Loading...
Searching...
No Matches
TileCellToTTL1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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//
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]; // array of TT occupancy
97 Identifier ttId[32][64]; // array of TT identifiers
98 float ttAmp[32][64]; // array of all TT amplitudes
99 uint16_t ttStatusCells[32][64]; // array of TT status of cells
100 uint16_t ttStatusChans[32][64]; // array of TT status of channels
101 float ttTimeAve[32][64]; // array of TT time average
102 float ttCorrFact[32][64]; // 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->ttNpmt[i][j] = 0;
110 a->ttId[i][j] = 0;
111 a->ttAmp[i][j] = 0.0;
112 a->ttStatusCells[i][j] = 0;
113 a->ttStatusChans[i][j] = 0;
114 a->ttTimeAve[i][j] = 0.0;
115 a->ttCorrFact[i][j] = 1.0; // this is a place holder for now, set to 1.0
116 }
117 }
118
119 // -------------------------------------------------
120 // Loop over all cells
121 // -------------------------------------------------
122
123 for (const CaloCell* cell : *cellContainer) {
124
125 // keep only cells from TileCal calorimeter barrel or extended barrel
126 Identifier cell_id = cell->ID();
127 if (!(m_tileID->is_tile(cell_id))) continue;
128
129 const TileCell* tilecell = dynamic_cast<const TileCell*>(cell);
130 if (!tilecell) continue;
131
132 float cell_ene = cell->energy();
133 float cell_time = cell->time();
134
135 int bad_cell = tilecell->badcell();
136 int bad_chan[2];
137 bad_chan[0] = tilecell->badch1();
138 bad_chan[1] = tilecell->badch2();
139
140 // In order to make sure that the D-cells are correctly added
141 // across two towers. Loop over the two PMTs in each cell
142 // for each PMT reduce the cell energy by 50%.
143
144 for (int ipmt = 0; ipmt < 2; ipmt++) {
145 Identifier pmt_id = m_tileID->pmt_id(cell_id, ipmt);
146 Identifier tt_id = m_tileCablingService->pmt2tt_id(pmt_id);
147
148 // remove the E-cells
149 int sample = m_tileID->sample(pmt_id);
150 if (sample == TileID::SAMP_E) continue;
151
152 // if in the negative eta region add 16 to the ieta offset arrays
153 int eta_offset = 0;
154 if (m_tileID->is_negative(pmt_id))
155 eta_offset = 16;
156
157 // the D0 cell is not being split correctly across cells
158 int ieta = m_TT_ID->eta(tt_id);
159 if (sample == TileID::SAMP_D && ieta == 0 && ipmt == 1)
160 eta_offset = 16;
161
162 ieta += eta_offset;
163 int iphi = m_TT_ID->phi(tt_id);
164
165 // Sum the tower energy
166 // already exists - just add charge
167 // reduce cell energy by 50% because we are loop over both pmts in cell
168 if (a->ttNpmt[ieta][iphi] > 0) {
169 a->ttAmp[ieta][iphi] += cell_ene * 0.5;
170 a->ttNpmt[ieta][iphi]++;
171 a->ttStatusCells[ieta][iphi] += (uint16_t) bad_cell;
172 a->ttStatusChans[ieta][iphi] += (uint16_t) bad_chan[ipmt];
173 a->ttTimeAve[ieta][iphi] += cell_time;
174
175 // rawChannel in new TT
176 } else {
177 a->ttId[ieta][iphi] = tt_id;
178 a->ttNpmt[ieta][iphi]++;
179 a->ttAmp[ieta][iphi] = cell_ene * 0.5;
180 a->ttStatusCells[ieta][iphi] = (uint16_t) bad_cell;
181 a->ttStatusChans[ieta][iphi] = (uint16_t) bad_chan[ipmt];
182 a->ttTimeAve[ieta][iphi] = cell_time;
183 }
184
185 } // end of loop over pmts in the cell
186 } // end loop over cells
187
188 for (int ieta = 0; ieta < 32; ieta++) {
189 for (int iphi = 0; iphi < 64; iphi++) {
190
191 // don't load towers that are empty
192 if (a->ttNpmt[ieta][iphi] == 0) continue;
193
194 float time_ave = a->ttTimeAve[ieta][iphi] / ((float) a->ttNpmt[ieta][iphi]);
195
196 uint16_t qual = 0;
197 if (a->ttStatusChans[ieta][iphi] == a->ttNpmt[ieta][iphi])
199 if (a->ttStatusCells[ieta][iphi] > 0)
201 if (a->ttStatusChans[ieta][iphi] > 0)
203
204 ttl1CellContainer->push_back(std::make_unique<TileTTL1Cell>(a->ttId[ieta][iphi],
205 a->ttAmp[ieta][iphi],
206 time_ave,
207 a->ttCorrFact[ieta][iphi],
208 qual));
209
210 }
211 }
212
213
214 // Execution completed
215 ATH_MSG_DEBUG( "TileCellToTTL1 execution completed.");
216
217 return StatusCode::SUCCESS;
218}
219
221
222 ATH_MSG_INFO( "TileCellToTTL1::finalize() end");
223
224 return StatusCode::SUCCESS;
225}
226
#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
StatusCode execute()
TileCellToTTL1(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
SG::WriteHandleKey< TileTTL1CellContainer > m_ttl1CellContainerKey
const TileID * m_tileID
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