ATLAS Offline Software
Loading...
Searching...
No Matches
BadTileRetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "BadTileRetriever.h"
6
8
10
12#include "CaloDetDescr/CaloDetDescrElement.h"
13#include "TileEvent/TileCell.h"
26
27using Athena::Units::GeV;
28
29namespace JiveXML {
30
37 BadTileRetriever::BadTileRetriever(const std::string& type,const std::string& name,const IInterface* parent):
38 AthAlgTool(type,name,parent),
39 m_calocell_id(nullptr)
40 {
41 //Only declare the interface
42 declareInterface<IDataRetriever>(this);
43
44 declareProperty("CellThreshold", m_cellThreshold = 50.);
45 declareProperty("RetrieveTILE" , m_tile = true);
46 declareProperty("DoBadTile", m_doBadTile = false);
47
48 declareProperty("CellEnergyPrec", m_cellEnergyPrec = 3);
49 }
50
54
56 ATH_MSG_DEBUG( "Initialising Tool" );
57 ATH_CHECK( detStore()->retrieve (m_calocell_id, "CaloCell_ID") );
58 ATH_CHECK(m_sgKey.initialize());
59 return StatusCode::SUCCESS;
60 }
61
65 StatusCode BadTileRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
66 ATH_MSG_DEBUG( "in retrieve()" );
68 if (!cellContainer.isValid()){
69 ATH_MSG_WARNING( "Could not retrieve Calorimeter Cells " );
70 } else {
71 if(m_tile){
72 DataMap data = getBadTileData(&(*cellContainer));
73 ATH_CHECK( FormatTool->AddToEvent(dataTypeName(), m_sgKey.key(), &data) );
74 ATH_MSG_DEBUG( "Bad Tile retrieved" );
75 }
76 }
77 //Tile cells retrieved okay
78 return StatusCode::SUCCESS;
79 }
80
81
87 ATH_MSG_DEBUG( "getBadTileData()" );
88 char rndStr[30];
90 DataVect phi; phi.reserve(cellContainer->size());
91 DataVect eta; eta.reserve(cellContainer->size());
92 DataVect idVec; idVec.reserve(cellContainer->size());
93 DataVect energyVec; energyVec.reserve(cellContainer->size());
94 m_sub.clear();
95 //Loop Over CaloCellContainer to retrieve TileCell information
98 if (m_doBadTile==true) {
99 double energyGeV;
100 //int cellInd;
101 ATH_MSG_DEBUG( "Start iterator loop over cells" );
102 for(;it1!=it2;++it1){
103 if( !(*it1)->badcell() ) continue;
104 Identifier cellid = (*it1)->ID();
105 calcTILELayerSub(cellid);
106 energyGeV = (*it1)->energy()*(1./GeV);
107 energyVec.emplace_back( gcvt( energyGeV, m_cellEnergyPrec, rndStr) );
108 idVec.emplace_back( (Identifier::value_type)(*it1)->ID().get_compact() );
109 phi.emplace_back((*it1)->phi());
110 eta.emplace_back((*it1)->eta());
111 } // end cell iterator
112 } // doBadTile
113
114 // write values into DataMap
115 const auto nEntries = phi.size();
116 DataMap["phi"] = std::move(phi);
117 DataMap["eta"] = std::move(eta);
118 DataMap["sub"] = std::move(m_sub);
119 DataMap["id"] = std::move(idVec);
120 DataMap["energy"] = std::move(energyVec);
121 //Be verbose
122 ATH_MSG_DEBUG( dataTypeName() << " retrieved with " << nEntries << " entries" );
123 //All collections retrieved okay
124 return DataMap;
125 } // getTileData
126
127 //-----------------------------------------------------------------------------------------------------
128
130 {
131 if(m_calocell_id->is_tile_barrel(cellid))
132 {
133 if(m_calocell_id->is_tile_negative(cellid))
134 m_sub.emplace_back(2);
135 else
136 m_sub.emplace_back(3);
137 }
138 else if(m_calocell_id->is_tile_extbarrel(cellid))
139 {
140 if(m_calocell_id->is_tile_negative(cellid))
141 m_sub.emplace_back(0);
142 else
143 m_sub.emplace_back(5);
144 }
145 //else in ITC or scint
146 else
147 {
148 if(m_calocell_id->is_tile_negative(cellid))
149 m_sub.emplace_back(1);
150 else
151 m_sub.emplace_back(4);
152 }
153 }
154
155 //--------------------------------------------------------------------------
156
157} // JiveXML namespace
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Wrapper to avoid constant divisions when using units.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
Container class for CaloCell.
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ReadHandleKey< CaloCellContainer > m_sgKey
virtual std::string dataTypeName() const
Return the name of the data type.
const CaloCell_ID * m_calocell_id
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
void calcTILELayerSub(Identifier &)
BadTileRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
StatusCode initialize()
Default AthAlgTool methods.
const DataMap getBadTileData(const CaloCellContainer *cellContainer)
Retrieve Tile bad cell location and details.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58