ATLAS Offline Software
Loading...
Searching...
No Matches
FCAL_HV_Energy_Rescale.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// FCAL_HV_Energy_Rescale.cxx
8// Implementation file for class FCAL_HV_Energy_Rescale
9// Author: S.Binet<binet@cern.ch>
11
12// CaloCondPhysAlgs includes
17
21
22#include "CoolKernel/types.h"
23#include "CoolKernel/Record.h"
24#include "CoralBase/AttributeListSpecification.h"
25
27 ISvcLocator* pSvcLocator ) :
28 AthAlgorithm( name, pSvcLocator )
29{
30}
31
33= default;
34
36{
37 ATH_CHECK( m_cablingKey.initialize());
38 ATH_CHECK( m_scaleCorrKey.initialize());
39 return StatusCode::SUCCESS;
40}
41
43{
44 return StatusCode::SUCCESS;
45}
46
47StatusCode FCAL_HV_Energy_Rescale::stop()
48{
49 const EventContext& ctx = Gaudi::Hive::currentContext();
51
52 const CaloCell_ID* calocell_id;
53 CHECK(detStore()->retrieve(calocell_id,"CaloCell_ID"));
54
55 IdentifierHash hashMin,hashMax;
56 calocell_id->calo_cell_hash_range(CaloCell_ID::LARFCAL, hashMin,hashMax);
57
59 const LArOnOffIdMapping* cabling{*cablingHdl};
60 if(!cabling) {
61 ATH_MSG_ERROR("Do not have cabling mapping from key " << m_cablingKey.key() );
62 return StatusCode::FAILURE;
63 }
64
65 ATH_MSG_INFO( "Working on hash range 0 to " << hashMax );
66
67 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
68 spec->extend("CaloCondBlob16M","blob");// , cool::StorageType::Blob16M);
69 AthenaAttributeList* attrList=new AthenaAttributeList(*spec);
70 coral::Blob& blob=(*attrList)["CaloCondBlob16M"].data<coral::Blob>();
71 CaloCondBlobFlt* flt= CaloCondBlobFlt::getInstance(blob);
72 spec->release(); // deletes spec
73 // cppcheck-suppress memleak
74 spec = nullptr;
75
76 //Blob Definition Vector
77 std::vector<std::vector<float> > defVec;
78 defVec.emplace_back(1,1);
79 flt->init(defVec,hashMax,1);
80
81 CHECK(detStore()->record(attrList,m_folder));
82
83 std::vector<float> setVec(1,1);
84 unsigned nFCAL=0, nSmall=0, nSet=0;
85 for(unsigned h=0;h<hashMax;++h) {
86 float value=1.0;
87 if (calocell_id->is_fcal(h)) {
88 ++nFCAL;
89 Identifier id=calocell_id->cell_id(h);
90 HWIdentifier hwid=cabling->createSignalChannelID(id);
91 const float corr=scaleCorr->HVScaleCorr(hwid);
92
93 if (std::fabs(1.0-corr)>0.01) {
94 value=corr;
95 ++nSet;
96 }
97 else
98 ++nSmall;
99 ATH_MSG_INFO( "FCAL module " << calocell_id->sampling(id) << " corr=" << corr << " =>" << value );
100 }
101 //std::cout << h << " " << value << std::endl;
102 setVec[0]=value;
103 flt->setData(h,0,setVec);
104 }//end loop over hash
105
106 ATH_MSG_INFO( "Found " << nFCAL << " FCAL channels of which " << nSet << " have a correction. (" << nSmall << " below threshold)" );
107
108 return StatusCode::SUCCESS;
109}
110
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
bool is_fcal(const Identifier id) const
test if the id belongs to the FCAL - true also for MiniFCAL
int sampling(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
virtual StatusCode initialize() override
virtual StatusCode execute() override
SG::ReadCondHandleKey< ILArHVScaleCorr > m_scaleCorrKey
Gaudi::Property< std::string > m_folder
virtual ~FCAL_HV_Energy_Rescale()
Destructor:
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
FCAL_HV_Energy_Rescale(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
This is a "hash" representation of an Identifier.