ATLAS Offline Software
Loading...
Searching...
No Matches
BadLArRetriever.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 "BadLArRetriever.h"
6
8
11
12#include "CaloDetDescr/CaloDetDescrElement.h"
19
20using Athena::Units::GeV;
21
22namespace JiveXML {
23
30 BadLArRetriever::BadLArRetriever(const std::string& type,const std::string& name,const IInterface* parent):
31 AthAlgTool(type,name,parent),
32 m_calocell_id(nullptr)
33 {
34 //Only declare the interface
35 declareInterface<IDataRetriever>(this);
36
37 declareInterface<IDataRetriever>(this);
38 declareProperty("LArlCellThreshold", m_cellThreshold = 50.);
39 declareProperty("RetrieveLAr" , m_lar = true);
40 declareProperty("DoBadLAr", m_doBadLAr = false);
41 declareProperty("CellConditionCut", m_cellConditionCut = false);
42
43 declareProperty("CellEnergyPrec", m_cellEnergyPrec = 3);
44 }
45
49
51
52 ATH_MSG_DEBUG( "Initialising Tool" );
53 ATH_CHECK( detStore()->retrieve (m_calocell_id, "CaloCell_ID") );
54
55 ATH_CHECK(m_sgKey.initialize());
56 ATH_CHECK( m_cablingKey.initialize() );
57
58 return StatusCode::SUCCESS;
59 }
60
64 StatusCode BadLArRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
65
66 ATH_MSG_DEBUG( "in retrieve()" );
67
69 if (!cellContainer.isValid()){
70 ATH_MSG_WARNING( "Could not retrieve Calorimeter Cells " );
71 }
72 else{
73 if(m_lar){
74 DataMap data = getBadLArData(&(*cellContainer));
75 ATH_CHECK( FormatTool->AddToEvent(dataTypeName(), m_sgKey.key(), &data) );
76 ATH_MSG_DEBUG( "Bad LAr retrieved" );
77 }
78 }
79
80 //LAr cells retrieved okay
81 return StatusCode::SUCCESS;
82 }
83
84
90
91 ATH_MSG_DEBUG( "getBadLArData()" );
92
94 const auto nCells = cellContainer->size();
95 DataVect phi; phi.reserve(nCells);
96 DataVect eta; eta.reserve(nCells);
97 DataVect energy; energy.reserve(nCells);
98 DataVect idVec; idVec.reserve(nCells);
99 DataVect channel; channel.reserve(nCells);
100 DataVect feedThrough; feedThrough.reserve(nCells);
101 DataVect slot; slot.reserve(nCells);
102
103
104 char rndStr[30]; // for rounding (3 digit precision)
108 const LArOnOffIdMapping* cabling{*cablingHdl};
109 const LArOnlineID* onlineId = nullptr;
110 if ( detStore()->retrieve(onlineId, "LArOnlineID").isFailure()) {
111 ATH_MSG_ERROR( "in getBadLArData(),Could not get LArOnlineID!" );
112 }
113
114 if (m_doBadLAr && cabling) {
115 double energyGeV;
116 ATH_MSG_DEBUG( "Start iterator loop over cells" );
117 for(;it1!=it2;++it1){
118 if( !(*it1)->badcell() ) continue;
119 if ((((*it1)->provenance()&0xFF)!=0xA5)&&m_cellConditionCut) continue; // check full conditions for LAr
120 HWIdentifier LArhwid = cabling->createSignalChannelIDFromHash((*it1)->caloDDE()->calo_hash());
121 energyGeV = (*it1)->energy()*(1./GeV);
122 if (energyGeV == 0) energyGeV = 0.001; // 1 MeV due to LegoCut > 0.0 (couldn't be >= 0.0)
123
124 energy.emplace_back( gcvt( energyGeV, m_cellEnergyPrec, rndStr) );
125 idVec.emplace_back((Identifier::value_type)(*it1)->ID().get_compact() );
126 phi.emplace_back((*it1)->phi());
127 eta.emplace_back((*it1)->eta());
128 channel.emplace_back(onlineId->channel(LArhwid));
129 feedThrough.emplace_back(onlineId->feedthrough(LArhwid));
130 slot.emplace_back(onlineId->slot(LArhwid));
131 } // end cell iterator
132 } // doBadLAr
133 // write values into DataMap
134 const auto nEntries = phi.size();
135 DataMap["phi"] = std::move(phi);
136 DataMap["eta"] = std::move(eta);
137 DataMap["energy"] = std::move(energy);
138 DataMap["id"] = std::move(idVec);
139 DataMap["channel"] = std::move(channel);
140 DataMap["feedThrough"] = std::move(feedThrough);
141 DataMap["slot"] = std::move(slot);
142 //Be verbose
143 ATH_MSG_DEBUG( dataTypeName() << " , collection: " << dataTypeName()
144 << " retrieved with " << nEntries << " entries" );
145
146 //All collections retrieved okay
147 return DataMap;
148
149 } // getBadLArData
150
151 //--------------------------------------------------------------------------
152
153} // 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_ERROR(x)
#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.
virtual std::string dataTypeName() const
Return the name of the data type.
BadLArRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
SG::ReadHandleKey< CaloCellContainer > m_sgKey
for properties
const CaloCell_ID * m_calocell_id
StatusCode initialize()
Default AthAlgTool methods.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
const DataMap getBadLArData(const CaloCellContainer *cellContainer)
Retrieve LAr bad cell location and details.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
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