ATLAS Offline Software
Loading...
Searching...
No Matches
TauShotVariableHelpers Namespace Reference

implementation of photon shot variable calculation More...

Functions

const CaloCellgetNeighbour (const CaloCell *cell, const CaloClusterCellLink &links, const CaloCell_ID *calo_id, const LArNeighbours::neighbourOption &option)
 Obtain the required neighbour cell.
std::vector< std::vector< const CaloCell * > > getCellBlock (const xAOD::PFO &shot, const CaloCell_ID *calo_id)
 Get cell block with (currently) 2 x 5 cells in correct order for variable calculations.
float ptWindow (const std::vector< std::vector< const CaloCell * > > &shotCells, int windowSize, const ToolHandle< IHadronicCalibrationTool > &caloWeightTool)
 pt in a window of (currently) 2 x windowSize cells

Detailed Description

Function Documentation

◆ getCellBlock()

std::vector< std::vector< const CaloCell * > > TauShotVariableHelpers::getCellBlock ( const xAOD::PFO & shot,
const CaloCell_ID * calo_id )

Get cell block with (currently) 2 x 5 cells in correct order for variable calculations.

Definition at line 48 of file TauShotVariableHelpers.cxx.

48 {
49 using namespace TauShotVariableHelpers::msgTauShotVariableHelpers;
50
51 std::vector<std::vector<const CaloCell*>> cellBlock;
52
53 int etaSize = 0;
54 if (shot.attribute(xAOD::PFODetails::PFOAttributes::tauShots_nCellsInEta, etaSize) == false) {
55 ANA_MSG_WARNING("Couldn't find nCellsInEta. Return empty cell block.");
56 return cellBlock;
57 }
58
59 int seedHash = 0;
60 if (shot.attribute(xAOD::PFODetails::PFOAttributes::tauShots_seedHash, seedHash) == false) {
61 ANA_MSG_WARNING("Couldn't find seed hash. Return empty cell block.");
62 return cellBlock;
63 }
64
65 // Initialize the cell block
66 std::vector<const CaloCell*> etaLayer;
67 for (int etaIndex = 0; etaIndex < etaSize; ++ etaIndex) {
68 etaLayer.push_back(nullptr);
69 }
70 int phiSize = 2;
71 for (int phiIndex = 0; phiIndex < phiSize; ++phiIndex) {
72 cellBlock.push_back(etaLayer);
73 }
74
75 // Get seed cell from shot cluster
76 const xAOD::CaloCluster* cluster = shot.cluster(0);
77 const CaloClusterCellLink* cellLinks = cluster->getCellLinks();
78
79 const CaloCell* seedCell = nullptr;
80 for (const auto cell : *cellLinks) {
81 if (cell->caloDDE()->calo_hash() != (unsigned) seedHash) continue;
82 seedCell = cell;
83 break;
84 }
85 if (seedCell==nullptr) {
86 ANA_MSG_WARNING("Couldn't find seed cell in shot cluster. Return empty cell block.");
87 return cellBlock;
88 }
89 int mediumEtaIndex = etaSize/2;
90 cellBlock.at(0).at(mediumEtaIndex) = seedCell;
91
92 // Obtain the neighbour cells in the eta direction
93 // -- Next in eta
94 const CaloCell* lastCell = seedCell;
95 int maxDepth = etaSize - mediumEtaIndex - 1;
96 for (int depth = 1; depth < maxDepth + 1; ++depth) {
97 lastCell = getNeighbour(lastCell, *cellLinks, calo_id, LArNeighbours::nextInEta);
98 if (lastCell != nullptr) {
99 cellBlock.at(0).at(mediumEtaIndex + depth) = lastCell;
100 }
101 else {
102 break;
103 }
104 }
105
106 // -- Previous in eta
107 lastCell = seedCell;
108 for (int depth = 1; depth < maxDepth + 1; ++depth) {
109 lastCell = getNeighbour(lastCell, *cellLinks, calo_id, LArNeighbours::prevInEta);
110 if (lastCell != nullptr) {
111 cellBlock.at(0).at(mediumEtaIndex - depth) = lastCell;
112 }
113 else {
114 break;
115 }
116 }
117
118 // Merged cell
119 const CaloCell* mergedCell = getNeighbour(seedCell, *cellLinks, calo_id, LArNeighbours::nextInPhi);
120 if (mergedCell == nullptr) {
121 mergedCell = getNeighbour(seedCell, *cellLinks, calo_id, LArNeighbours::prevInPhi);
122 }
123
124 if (mergedCell != nullptr) {
125 cellBlock.at(1).at(mediumEtaIndex) = mergedCell;
126
127 // Obtain the neighbour cells in the eta direction
128 // -- Next in eta
129 lastCell = mergedCell;
130 for (int depth = 1; depth < maxDepth + 1; ++depth) {
131 lastCell = getNeighbour(lastCell, *cellLinks, calo_id, LArNeighbours::nextInEta);
132 if (lastCell != nullptr) {
133 cellBlock.at(1).at(mediumEtaIndex + depth) = lastCell;
134 }
135 else {
136 break;
137 }
138 }
139
140 // -- Previous in eta
141 lastCell = mergedCell;
142 for (int depth = 1; depth < maxDepth + 1; ++depth) {
143 lastCell = getNeighbour(lastCell, *cellLinks, calo_id, LArNeighbours::prevInEta);
144 if (lastCell != nullptr) {
145 cellBlock.at(1).at(mediumEtaIndex - depth) = lastCell;
146 }
147 else {
148 break;
149 }
150 }
151 } // End of mergedCell != nullptr
152
153 return cellBlock;
154}
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
const CaloCluster * cluster(unsigned int index) const
Retrieve a const pointer to a CaloCluster.
Definition PFO_v1.cxx:669
std::string depth
tag string for intendation
Definition fastadd.cxx:46
const CaloCell * getNeighbour(const CaloCell *cell, const CaloClusterCellLink &links, const CaloCell_ID *calo_id, const LArNeighbours::neighbourOption &option)
Obtain the required neighbour cell.
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition EtaPhiLUT.cxx:23
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ getNeighbour()

const CaloCell * TauShotVariableHelpers::getNeighbour ( const CaloCell * cell,
const CaloClusterCellLink & links,
const CaloCell_ID * calo_id,
const LArNeighbours::neighbourOption & option )

Obtain the required neighbour cell.

Definition at line 22 of file TauShotVariableHelpers.cxx.

25 {
26 const CaloCell* neigCell = nullptr;
27
28 std::vector<IdentifierHash> neighHashes;
29 calo_id->get_neighbours(cell->caloDDE()->calo_hash(), option, neighHashes);
30
31 // Loop all the cells, and find the required neighbour cell
32 for (const auto cell : links) {
33 const IdentifierHash& cellHash = cell->caloDDE()->calo_hash();
34
35 // Check whether the cell is a neighbour cell
36 for (const IdentifierHash& neighHash : neighHashes) {
37 if (cellHash == neighHash) {
38 neigCell = cell;
39 return neigCell;
40 }
41 }
42 }
43
44 return neigCell;
45}
int get_neighbours(const IdentifierHash caloHash, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This is a "hash" representation of an Identifier.

◆ ptWindow()

float TauShotVariableHelpers::ptWindow ( const std::vector< std::vector< const CaloCell * > > & shotCells,
int windowSize,
const ToolHandle< IHadronicCalibrationTool > & caloWeightTool )

pt in a window of (currently) 2 x windowSize cells

Definition at line 158 of file TauShotVariableHelpers.cxx.

160 {
161 // window size should be odd and smaller than eta window of shotCells
162 if (windowSize%2 != 1) return 0.;
163
164 int etaSize = shotCells.at(0).size();
165 if (windowSize > etaSize) return 0.;
166
167 int seedIndex = etaSize/2;
168 int phiSize = shotCells.size();
169
170 float ptWindow = 0.;
171 for (int etaIndex = 0; etaIndex != etaSize; ++etaIndex) {
172 if (std::abs(etaIndex-seedIndex) > windowSize/2) continue;
173
174 for (int phiIndex = 0; phiIndex != phiSize; ++phiIndex) {
175 const CaloCell* cell = shotCells.at(phiIndex).at(etaIndex);
176 if (cell != nullptr) {
177 ptWindow += cell->pt() * caloWeightTool->wtCell(cell);
178 }
179 }
180 }
181
182 return ptWindow;
183}
float ptWindow(const std::vector< std::vector< const CaloCell * > > &shotCells, int windowSize, const ToolHandle< IHadronicCalibrationTool > &caloWeightTool)
pt in a window of (currently) 2 x windowSize cells