 |
ATLAS Offline Software
|
Go to the documentation of this file.
29 return StatusCode::SUCCESS;
36 unsigned int total = 0, seed = 0, grow = 0, term = 0, invalid = 0, shared = 0;
38 friend Str &
operator << (Str &
s,
const size_struct & sst)
40 s << sst.total <<
" " << sst.seed <<
" " << sst.grow <<
" " << sst.term <<
" " << sst.invalid <<
" " << sst.shared;
45 struct cluster_info_struct
48 float seed_snr = -9e99;
49 float seed_energy = -9e99;
52 friend Str &
operator << (Str &
s,
const cluster_info_struct & cis)
54 s << cis.seed_index <<
" " << cis.size <<
" (" << cis.seed_snr <<
" " << cis.seed_energy <<
")";
65 if ( !cell_collection.
isValid() )
67 ATH_MSG_ERROR(
" Cannot retrieve CaloCellContainer: " << cell_collection.
name() );
68 return StatusCode::FAILURE;
73 const CaloNoise * noise_tool = *noise_handle;
75 unsigned int gain_counts[GainConversion::num_gain_values()] = {0};
77 size_struct global_counts, global_cluster_counts;
87 const unsigned int gain = GainConversion::from_standard_gain(
cell->gain());
89 ++gain_counts[
gain - GainConversion::min_gain_value()];
103 ++global_counts.term;
107 ++global_counts.invalid;
111 struct cluster_cell_info
114 double w_1 = -1, w_2 = -1,
energy = -9e99, SNR = -9e99;
122 else if (cl_2 ==
nullptr)
129 std::cout <<
"WARNING! Multiple shared cell: " << cell_id <<
" " << cl_1 <<
" " << cl_2 <<
" " <<
cl << std::endl;
133 bool is_shared()
const
135 return cl_1 !=
nullptr && cl_2 !=
nullptr;
140 std::map<int, cluster_cell_info> cluster_cells;
149 ATH_MSG_ERROR(
"Can't get valid links to CaloCells (CaloClusterCellLink)!");
150 return StatusCode::FAILURE;
153 for (
auto it = cell_links->
begin();
it != cell_links->
end(); ++
it)
158 const float this_energy = std::abs(
cell->energy());
160 const float this_snr = std::abs(this_energy / noise_tool->
getNoise(
m_calo_id->calo_cell_hash(
cell->ID()),
cell->gain()));
162 const IdentifierHash this_hash =
m_calo_id->calo_cell_hash(
cell->ID());
164 auto &
info = cluster_cells[this_hash];
166 info.energy = this_energy;
174 std::unordered_map<const xAOD::CaloCluster *, cluster_info_struct> cluster_sizes;
176 auto update_clusters = [&](
const cluster_cell_info & cci,
const int cell)
182 auto & c_info = cluster_sizes[
cl];
198 ++c_info.size.invalid;
203 ++c_info.size.shared;
207 if (cci.SNR > c_info.seed_snr || (cci.SNR == c_info.seed_snr &&
cell > c_info.seed_index))
209 c_info.seed_index =
cell;
210 c_info.seed_snr = cci.SNR;
211 c_info.seed_energy = cci.energy;
217 if (cci.cl_1 !=
nullptr || cci.cl_2 !=
nullptr)
219 ++global_cluster_counts.total;
222 ++global_cluster_counts.seed;
226 ++global_cluster_counts.grow;
230 ++global_cluster_counts.term;
234 ++global_cluster_counts.invalid;
238 ++global_cluster_counts.shared;
242 update_one(cci.cl_1);
243 update_one(cci.cl_2);
246 for (
auto &
it : cluster_cells)
248 update_clusters(
it.second,
it.first);
251 std::vector<cluster_info_struct> sorted_info;
253 sorted_info.reserve(cluster_sizes.size());
255 for (
auto &
v : cluster_sizes)
257 sorted_info.push_back(
v.second);
260 std::sort(sorted_info.begin(), sorted_info.end(),
261 [](
const auto &
a,
const auto &
b)
263 return a.seed_index < b.seed_index;
270 return StatusCode::FAILURE;
280 return StatusCode::FAILURE;
283 out_file <<
"Cell counts: " << global_counts <<
"\n\n";
285 out_file <<
"Cells in clusters count: " << global_cluster_counts <<
"\n\n";
288 for (
const auto &
info : sorted_info)
297 return StatusCode::FAILURE;
302 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
static std::string build_filename(const std::string &prefix, const std::string &text, const std::string &suffix, const std::string &ext)
Gaudi::Property< std::string > m_fileSuffix
The suffix of the saved files.
Const iterator class for DataVector/DataList.
path
python interpreter configuration --------------------------------------—
const std::string & name() const
Return the StoreGate ID for the referenced object.
Gaudi::Property< float > m_cellThreshold
Value to consider for the seed threshold.
const_iterator begin() const
const begin method
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
vector of names of the cell containers to use as input.
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Gaudi::Property< float > m_seedThreshold
Value to consider for the seed threshold.
virtual StatusCode initialize() override
Bookkeeping of cells that make up a cluster Simplified replacement for CaloCellLink,...
Description of a calorimeter cluster.
::StatusCode StatusCode
StatusCode definition for legacy code.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static ErrorState prepare_folder_for_output(const std::filesystem::path &folder, const bool output_errors=true)
Gaudi::Property< std::string > m_savePath
The path specifying the folder to which the files should be saved.
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
StatusCode initialize(bool used=true)
const_iterator end() const
const end method
const CaloCell_ID * m_calo_id
Pointer to Calo ID Helper.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Data object for each calorimeter readout cell.
Gaudi::Property< unsigned int > m_numWidth
The number of digits to reserve for the events.
CaloCellsCounterCPU(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Key of the CaloNoise Conditions data object.
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *cluster_collection) const override
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Gaudi::Property< std::string > m_filePrefix
The prefix of the saved files.
Gaudi::Property< float > m_growThreshold
Value to consider for the seed threshold.