ATLAS Offline Software
GepPi0Alg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #ifndef TRIGL0GEPPERF_GEPPI0ALG_H
6 #define TRIGL0GEPPERF_GEPPI0ALG_H
7 
8 /*
9  This algorithm provides a framework in which to study alternative
10  pi0 detection algorithms or, more precisely, algorithms which take
11  a seed cell and a neighborhood of cells all lying in the EMB1 sampling
12  layer of the LArEM calorimeter.
13 
14  The AlgTool delivers cell collections to the Algorithm. There may
15  a single collection if all the cells are read in, or many such collections
16  as would happen when a cell collection is produced for each CaloCluster
17  in the event.
18 
19  A seed cell for a each input cell collection is identified.
20 
21  The algorithm also reads in all Calorimeter Cells.
22 
23  The algorithms are implemented in separate merthods. They receive
24  as inputs the seeds, and the EMB1 cells.
25 
26  Output is currently done in debug mode (m_debug = true) by outputing
27  text files.
28 
29 */
30 
31 #include "./ICaloCellsProducer.h"
32 
34 
38 
39 #include "Identifier/Identifier.h"
40 #include <vector>
41 
43  public:
44 
45  using CellVectors = std::vector<std::vector<const CaloCell*>>;
46  using PathsSignif = std::vector<std::vector<float>>;
47 
48 
49  GepPi0Alg(const std::string& name, ISvcLocator* pSvcLocator);
50 
51  virtual StatusCode initialize() override;
52  virtual StatusCode execute(const EventContext& ) const override;
53 
54  private:
55 
56  // label for debug output
57  mutable std::atomic<size_t> m_id{0l};
58 
59  // key to get all calo cells
61  this, "caloCells", "AllCalo", "key to read in a CaloCell constainer"};
62 
63  // tool to get vector of vector of cal cells, eg one vector per cluster
64  ToolHandle<ICaloCellsProducer> m_cellsProducer{this,
65  "caloCellsProducer",
66  "EMB1CellsFromCaloCells",
67  "AlgTool to provide vectors of CaloCells ot GepPi0Alg"};
68 
69  // Provide access to a noise tool. Allows calculation of S/N for a CaloCell
72  "totalNoiseKey",
73  "totalNoise",
74  "SG Key of CaloNoise data object"};
75 
76  // CaloCell_ID helps with with intercell navigation
77  const CaloCell_ID* m_calocell_id{nullptr};
78 
79  // CaloDetDescrMAnager provides descriptors with cell geometry information.
82  "caloDetDescrManager",
83  "CaloDetDescrManager",
84  "SG Key of the CaloDetDescrManager in the Consition Store"};
85 
86  // Neighborhood generation
87  // 0.25: about seed strip +- 1 strip in eta
88  Gaudi::Property<float> m_neigh_half_eta{
89  "neigh_half_eta",
90  {0.004},
91  "+- neighborhood extent in eta"};
92 
93  // 0.1: about seed strip +- 6 strips in phi
94  Gaudi::Property<float> m_neigh_half_phi{
95  this,
96  "neigh_half_phi",
97  {0.6},
98  "+- neighborhood extent in phi"};
99 
100  // Allow the user to set the desired algorithm(s)
101  Gaudi::Property<std::vector<std::string>> m_strategies{
102  this,
103  "pi0strategies",
104  {"TWINPEAKS", "CRAWL"},
105  "list of pi0 detection strategies to be run"};
106 
107  // paramaters for seed cell identification
108  Gaudi::Property<float> m_seed_signifcut{
109  this, "seed_signif_cut", {2.0}, "twin peak min peak e/noise"};
110 
111 
112  // parameters for crawl algorithm
113  Gaudi::Property<float> m_tp_signifcut{
114  this, "tp_signif_cut", {2.0}, "twin peak min peak e/noise"};
115 
116  Gaudi::Property<float> m_crawl_signifcut{
117  this, "crawl_signif_cut", {2.0}, "crawl min peak e/noise"};
118 
119  Gaudi::Property<int> m_er_neta{
120  this, "er_neta", {1}, "crawl number of steps eta"};
121 
122  Gaudi::Property<int> m_er_nphi{
123  this, "er_nphi", {10}, "crawl number of steps phi"};
124 
125 
126  Gaudi::Property<bool> m_dump{
127  this, "dump", false, "flag to trigger writing out debug information"};
128 
129 
130  // The different algorithms are encapsulated in private methods
131  // twin peaks exhaustively looks for local peaks in the neighborhood
132  // of a seed
134  const std::vector<const CaloCell*>& laremCells,
135  const std::vector<const CaloCell*>& emb1Cells,
136  std::size_t iseed,
137  const CaloNoise*,
138  const CaloDetDescrManager*
139  ) const;
140 
141  // sort will sort the cells in a neighborhood of a seed by e, and examine
142  // this for cells which are local maxima.
143 
144  StatusCode sort_strategy(const CaloCell* seed,
145  const std::vector<const CaloCell*>& laremCells,
146  const std::vector<const CaloCell*>& emb1Cells,
147  std::size_t iseed,
148  const CaloNoise*,
149  const CaloDetDescrManager*) const;
150 
151  // the crawl algorithm finds the binary string found by comparing the
152  // energy of at location along a path with the previous location.
153  // The strings are then tested against a regex to determine whether
154  // a particular pattern is present. The default regex identifies '010'
155  // within the string, or '01' at the end of the string.
156 
157  StatusCode crawl_strategy(const CaloCell* seed,
158  const std::vector<const CaloCell*>& laremCells,
159  const std::vector<const CaloCell*>& emb1Cells,
160  std::size_t iseed,
161  const CaloNoise*,
162  const CaloDetDescrManager*) const;
163 
164 
165 
166 
167  // Find a list of cell identifiers in the neighborhood of a seed cell.
168  // The neighborhood is rectangular in eta-phi.
170  const std::vector<const CaloCell*>& laremCells,
171  std::vector<const CaloCell*>& neighs,
172  const CaloDetDescrManager*) const;
173 
174  // methods to output details of the different algorithms
175  StatusCode dump_crawl(std::size_t iseed,
176  const CaloCell* seed,
177  float seed_signif,
178  const CellVectors&,
179  const PathsSignif&,
180  const std::vector<std::string>& paths_pat) const;
181 
182  StatusCode dump_twinpeaks(std::size_t iseed,
183  const CaloCell* seed,
184  double seed_signif,
185  const std::vector<const CaloCell*>& neighborhood,
186  const std::vector<const CaloCell*>& peaks,
187  const std::vector<double>& peak_signifs) const;
188 };
189 
190 #endif
191 
192 
193 
194 
GepPi0Alg::execute
virtual StatusCode execute(const EventContext &) const override
Definition: GepPi0Alg.cxx:40
GepPi0Alg::m_cellsProducer
ToolHandle< ICaloCellsProducer > m_cellsProducer
Definition: GepPi0Alg.h:64
GepPi0Alg::m_seed_signifcut
Gaudi::Property< float > m_seed_signifcut
Definition: GepPi0Alg.h:108
GepPi0Alg::neighborhood
StatusCode neighborhood(const CaloCell *, const std::vector< const CaloCell * > &laremCells, std::vector< const CaloCell * > &neighs, const CaloDetDescrManager *) const
Definition: GepPi0Alg.cxx:789
GepPi0Alg::twinpeaks_strategy
StatusCode twinpeaks_strategy(const CaloCell *seed, const std::vector< const CaloCell * > &laremCells, const std::vector< const CaloCell * > &emb1Cells, std::size_t iseed, const CaloNoise *, const CaloDetDescrManager *) const
Definition: GepPi0Alg.cxx:241
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
GepPi0Alg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: GepPi0Alg.h:81
SG::ReadHandleKey< CaloCellContainer >
GepPi0Alg::m_er_neta
Gaudi::Property< int > m_er_neta
Definition: GepPi0Alg.h:119
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
GepPi0Alg::PathsSignif
std::vector< std::vector< float > > PathsSignif
Definition: GepPi0Alg.h:46
GepPi0Alg::m_totalNoiseKey
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
Definition: GepPi0Alg.h:71
GepPi0Alg::dump_crawl
StatusCode dump_crawl(std::size_t iseed, const CaloCell *seed, float seed_signif, const CellVectors &, const PathsSignif &, const std::vector< std::string > &paths_pat) const
Definition: GepPi0Alg.cxx:668
GepPi0Alg::initialize
virtual StatusCode initialize() override
Definition: GepPi0Alg.cxx:25
ICaloCellsProducer.h
GepPi0Alg::m_dump
Gaudi::Property< bool > m_dump
Definition: GepPi0Alg.h:126
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GepPi0Alg::m_allCaloCellsKey
SG::ReadHandleKey< CaloCellContainer > m_allCaloCellsKey
Definition: GepPi0Alg.h:60
GepPi0Alg::m_tp_signifcut
Gaudi::Property< float > m_tp_signifcut
Definition: GepPi0Alg.h:113
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
GepPi0Alg::m_calocell_id
const CaloCell_ID * m_calocell_id
Definition: GepPi0Alg.h:77
GepPi0Alg::m_crawl_signifcut
Gaudi::Property< float > m_crawl_signifcut
Definition: GepPi0Alg.h:116
GepPi0Alg::GepPi0Alg
GepPi0Alg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GepPi0Alg.cxx:20
AthReentrantAlgorithm.h
CaloNoise
Definition: CaloNoise.h:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloNoise.h
CaloCellContainer.h
SG::ReadCondHandleKey< CaloNoise >
GepPi0Alg
Definition: GepPi0Alg.h:42
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
GepPi0Alg::sort_strategy
StatusCode sort_strategy(const CaloCell *seed, const std::vector< const CaloCell * > &laremCells, const std::vector< const CaloCell * > &emb1Cells, std::size_t iseed, const CaloNoise *, const CaloDetDescrManager *) const
Definition: GepPi0Alg.cxx:402
GepPi0Alg::CellVectors
std::vector< std::vector< const CaloCell * > > CellVectors
Definition: GepPi0Alg.h:45
GepPi0Alg::m_neigh_half_eta
Gaudi::Property< float > m_neigh_half_eta
Definition: GepPi0Alg.h:88
GepPi0Alg::m_strategies
Gaudi::Property< std::vector< std::string > > m_strategies
Definition: GepPi0Alg.h:101
GepPi0Alg::m_er_nphi
Gaudi::Property< int > m_er_nphi
Definition: GepPi0Alg.h:122
GepPi0Alg::crawl_strategy
StatusCode crawl_strategy(const CaloCell *seed, const std::vector< const CaloCell * > &laremCells, const std::vector< const CaloCell * > &emb1Cells, std::size_t iseed, const CaloNoise *, const CaloDetDescrManager *) const
Definition: GepPi0Alg.cxx:423
GepPi0Alg::m_neigh_half_phi
Gaudi::Property< float > m_neigh_half_phi
Definition: GepPi0Alg.h:94
GepPi0Alg::dump_twinpeaks
StatusCode dump_twinpeaks(std::size_t iseed, const CaloCell *seed, double seed_signif, const std::vector< const CaloCell * > &neighborhood, const std::vector< const CaloCell * > &peaks, const std::vector< double > &peak_signifs) const
Definition: GepPi0Alg.cxx:725
GepPi0Alg::m_id
std::atomic< size_t > m_id
Definition: GepPi0Alg.h:57