ATLAS Offline Software
Loading...
Searching...
No Matches
LArCelldeadOTXTool Class Reference

#include <LArCelldeadOTXTool.h>

Inheritance diagram for LArCelldeadOTXTool:
Collaboration diagram for LArCelldeadOTXTool:

Public Member Functions

 ~LArCelldeadOTXTool ()=default
virtual StatusCode initialize () override final
virtual StatusCode finalize () override final
virtual StatusCode process (CaloCellContainer *cellCollection, const EventContext &ctx) const override final

Private Attributes

SG::ReadHandleKey< LArRawSCContainerm_SCKey {this, "keySC", "SC_ET","Key for SuperCells container"}
SG::ReadCondHandleKey< LArDeadOTXCorrFactorsm_factors {this,"SCFactors","LArDeadOTXCorrFactors"}
Gaudi::Property< int > m_scCut {this,"SCEneCut",70,"Do not use super-cells with values below this cut"}
Gaudi::Property< bool > m_testMode {this,"TestMode",false}
std::unordered_map< int, std::pair< float, int > > m_testMap ATLAS_THREAD_SAFE
std::mutex m_mtx
std::atomic< int > m_nWarnings {0}

Detailed Description

Definition at line 19 of file LArCelldeadOTXTool.h.

Constructor & Destructor Documentation

◆ ~LArCelldeadOTXTool()

LArCelldeadOTXTool::~LArCelldeadOTXTool ( )
default

Member Function Documentation

◆ finalize()

StatusCode LArCelldeadOTXTool::finalize ( )
finaloverridevirtual

Definition at line 114 of file LArCelldeadOTXTool.cxx.

114 {
115 if (m_testMode) {
116 ATH_MSG_INFO("Test mode for cell-patching:");
117 std::vector<std::pair<float, float> > avgList;
118 for (auto& [scEne, entry] : m_testMap) {
119 avgList.emplace_back(scEne, entry.first / entry.second);
120 }
121 auto ordering = [](const std::pair<float, float>& a, std::pair<float, float>& b) { return (a.first < b.first); };
122 std::sort(avgList.begin(), avgList.end(), ordering);
123 for (auto& p : avgList) {
124 ATH_MSG_INFO("SCEne=" << p.first << "Avg patching ratio=" << p.second);
125 }
126 }
127 return StatusCode::SUCCESS;
128}
#define ATH_MSG_INFO(x)
static Double_t a
Gaudi::Property< bool > m_testMode
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ initialize()

StatusCode LArCelldeadOTXTool::initialize ( )
finaloverridevirtual

Definition at line 11 of file LArCelldeadOTXTool.cxx.

11 {
12
13 ATH_CHECK(m_SCKey.initialize());
14 ATH_CHECK(m_factors.initialize());
15
16 if (m_testMode) {
18 "Test mode activated with additional debug output. Makes only sense if we try to patch a FEB that is actually there, so we have a reference");
19 }
20
21 return StatusCode::SUCCESS;
22}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
SG::ReadHandleKey< LArRawSCContainer > m_SCKey
SG::ReadCondHandleKey< LArDeadOTXCorrFactors > m_factors

◆ process()

StatusCode LArCelldeadOTXTool::process ( CaloCellContainer * cellCollection,
const EventContext & ctx ) const
finaloverridevirtual

Definition at line 24 of file LArCelldeadOTXTool.cxx.

24 {
25
26 ATH_MSG_VERBOSE(" in process...");
27 if (!cellCollection) {
28 ATH_MSG_ERROR("Cell Correction tool receives invalid cell Collection");
29 return StatusCode::FAILURE;
30 }
31
32 if (!(cellCollection->hasCalo(CaloCell_ID::LAREM) ||
33 cellCollection->hasCalo(CaloCell_ID::LARHEC) ||
34 cellCollection->hasCalo(CaloCell_ID::LARFCAL))) {
35 ATH_MSG_VERBOSE("No LAr cell in CellContainer. Do nothing");
36 return StatusCode::SUCCESS;
37 }
38
39 SG::ReadCondHandle<LArDeadOTXCorrFactors> scToDeadHdl{m_factors,ctx};
40 const LArDeadOTXCorrFactors::payload_t& scToDead=scToDeadHdl->get();
41 if (scToDead.empty()) {
42 return StatusCode::SUCCESS; // No dead FEBs, do nothing
43 }
44
45 // get SuperCellContainer
46 SG::ReadHandle<LArRawSCContainer> scHdl(m_SCKey, ctx);
47 if (!scHdl.isValid()) {
48 if (msgLvl(MSG::WARNING) && m_nWarnings < 5) {
49 ATH_MSG_WARNING("Do not have SuperCell container no patching !!!!");
51 }
52 return StatusCode::SUCCESS;
53 }
54
55 const unsigned int bcid = ctx.eventID().bunch_crossing_id();
56
57 // get the SC, container is unordered, so have to loop
58 const LArRawSCContainer* scells = scHdl.cptr();
59 for (const auto* sc : *scells) {
60 if (!sc)
61 continue;
62 const HWIdentifier scHwid = sc->hardwareID();
63 auto itr = scToDead.find(scHwid);
64 if (itr == scToDead.end())
65 continue; // This SC is not connected to any deadFEB cell
66
67 const std::vector<unsigned short>& bcids = sc->bcids();
68 const std::vector<int>& energies = sc->energies();
69 const std::vector<bool>& satur = sc->satur();
70
71 // Look for bcid:
72 float scEne = 0;
73 const size_t nBCIDs = bcids.size();
74 size_t i = 0;
75 for (i = 0; i < nBCIDs && bcids[i] != bcid; i++)
76 ;
77
78 if (ATH_LIKELY(!satur[i]))
79 scEne = energies[i];
80 if (scEne < m_scCut) {
81 ATH_MSG_VERBOSE("SuperCell value " << scEne << " below threshold, ignoring");
82 continue;
83 }
84 float cellESum = 0;
85 float patchEneSum = 0;
86 for (const auto& [h, convFactor] : itr->second) { // Loop over all deadFEB cells connected to this SC
87 CaloCell* cell = cellCollection->findCell(h);
88 if (cell) {
89 const float patchEne = scEne * convFactor; // Convert ET (coming from LATOMEs) into Energy
90 if (m_testMode) {
91 cellESum += cell->energy();
92 patchEneSum += patchEne;
93 }
94 ATH_MSG_DEBUG("Cell id 0x" << std::hex << cell->ID().get_identifier32().get_compact() << " Replacing energy " << cell->energy() << " " << patchEne
95 << ", SCene=" << scEne);
96 cell->setEnergy(patchEne);
97 cell->setProvenance(cell->provenance() | LArProv::PATCHED);
98 } // end if cell obj found
99 } // end loop over all deadFEB cells connected to this SC
100 if (m_testMode) {
101 const float ratio = patchEneSum != 0 ? cellESum / patchEneSum : 0;
102 ATH_MSG_DEBUG("ESums=" << cellESum << "/" << patchEneSum << "=" << ratio);
103 std::scoped_lock l(m_mtx);
104 auto& entry = m_testMap[scEne];
105 entry.first += ratio;
106 entry.second++;
107 } // end if testMode
108 } // End loop over SuperCell container
109
110 return StatusCode::SUCCESS;
111}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define ATH_LIKELY(x)
static Double_t sc
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
std::atomic< int > m_nWarnings
Gaudi::Property< int > m_scCut
std::map< HWIdentifier, std::vector< std::pair< IdentifierHash, float > > > payload_t
l
Printing final latex table to .tex output file.
setEventNumber setTimeStamp bcid

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::unordered_map<int,std::pair<float,int> > m_testMap LArCelldeadOTXTool::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 35 of file LArCelldeadOTXTool.h.

◆ m_factors

SG::ReadCondHandleKey<LArDeadOTXCorrFactors> LArCelldeadOTXTool::m_factors {this,"SCFactors","LArDeadOTXCorrFactors"}
private

Definition at line 31 of file LArCelldeadOTXTool.h.

31{this,"SCFactors","LArDeadOTXCorrFactors"};

◆ m_mtx

std::mutex LArCelldeadOTXTool::m_mtx
mutableprivate

Definition at line 36 of file LArCelldeadOTXTool.h.

◆ m_nWarnings

std::atomic<int> LArCelldeadOTXTool::m_nWarnings {0}
mutableprivate

Definition at line 38 of file LArCelldeadOTXTool.h.

38{0};

◆ m_scCut

Gaudi::Property<int> LArCelldeadOTXTool::m_scCut {this,"SCEneCut",70,"Do not use super-cells with values below this cut"}
private

Definition at line 32 of file LArCelldeadOTXTool.h.

32{this,"SCEneCut",70,"Do not use super-cells with values below this cut"};

◆ m_SCKey

SG::ReadHandleKey<LArRawSCContainer> LArCelldeadOTXTool::m_SCKey {this, "keySC", "SC_ET","Key for SuperCells container"}
private

Definition at line 30 of file LArCelldeadOTXTool.h.

30{this, "keySC", "SC_ET","Key for SuperCells container"};

◆ m_testMode

Gaudi::Property<bool> LArCelldeadOTXTool::m_testMode {this,"TestMode",false}
private

Definition at line 33 of file LArCelldeadOTXTool.h.

33{this,"TestMode",false};

The documentation for this class was generated from the following files: