14#include "CoralBase/Blob.h"
22 ISvcLocator* pSvcLocator ) :
36 return StatusCode::SUCCESS;
44 const EventContext& ctx = Gaudi::Hive::currentContext();
48 return StatusCode::FAILURE;
59 return StatusCode::FAILURE;
66 return StatusCode::FAILURE;
77 std::ifstream fin(
file.c_str());
80 return StatusCode::FAILURE;
84 float em0,em1,em2,em3,em4;
85 float had0,had1,had2,had3;
86 std::map<int,std::vector<float> > wmap;
87 while (std::getline(fin, line)){
88 int nread = sscanf(line.c_str(),
"%d %f %f %f %f %f %f %f %f %f",
89 &ttbin,&em0,&em1,&em2,&em3,&em4,&had0,&had1,&had2,&had3);
90 if(nread != 10)
continue;
91 wmap[ttbin]=std::vector<float>{had0,had1,had2,had3};
98 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
99 spec->extend(
"HVScaleCorr",
"blob");
100 spec->extend<
unsigned>(
"version");
102 coral::AttributeList attrList(*spec);
103 attrList[
"version"].setValue(0U);
104 coral::Blob& hvBlob=attrList[
"HVScaleCorr"].data<coral::Blob>();
113 float *pHV=
static_cast<float*
>(hvBlob.startingAddress());
114 std::vector<float> vScale;
119 if(!
m_outKey.empty()) vScale.resize(hashMax,(
float)1.0);
121 unsigned nFilledIds=0;
122 unsigned nTotalIds=0;
123 for (
unsigned i=0; i < hashMax; ++i) {
127 const std::vector<Identifier> &cellIds=
m_scidTool->superCellToOfflineID(scId);
128 if (cellIds.empty()) {
129 ATH_MSG_ERROR(
"Got empty vector of cell ids for super cell id 0x"
131 return StatusCode::FAILURE;
140 hvcorr += weight * hvHdl->HVScaleCorr(cabling->createSignalChannelID(cellId));
143 if(wsum>0.) hvcorr /= wsum;
159 if(!
m_outKey.empty()) vScale[i]=hvcorr;
166 coll->
add(0,attrList);
168 ATH_MSG_INFO(
"Total number of SuperCells:" << nTotalIds <<
", filled:" << nFilledIds);
178 auto scHvCorr = std::make_unique<LArHVCorr>(std::move(vScale), cablingSC, calosccellID);
179 if (writeHandle.
record(std::move(scHvCorr)).isFailure()) {
181 <<
" with EventRange " << writeHandle.
getRange() <<
" into Conditions Store");
182 return StatusCode::FAILURE;
184 ATH_MSG_INFO(
"Recorded new " << writeHandle.
key() <<
" with range " << writeHandle.
getRange() <<
" into Conditions Store");
186 return StatusCode::SUCCESS;
191 int reg = hecID->
region(
id);
195 case -2:
if(reg==0) ttbin=-16-
eta;
else ttbin=-27-2*
eta;
if(ttbin==-33) ttbin=-32;
break;
196 case 2:
if(reg==0) ttbin=15+
eta;
else ttbin=25+2*
eta;
198 if(ttbin!=0 && wmap.find(ttbin) != wmap.end()){
200 return wmap[ttbin][hecID->
sampling(
id)];
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
Helper class for offline supercell identifiers.
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Defines a common ERRORCODE enum for LAr-Calibration objects.
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
bool is_lar_hec(Identifier id) const
std::string cell_name(const Identifier id) const
Returns the cell-location in a human readable form.
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
int sub_calo(const Identifier id) const
returns an int taken from SUBCALO enum and describing the subCalo to which the Id belongs.
size_type calo_cell_hash_max() const
cell 'global' hash table max size
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
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 supercell identifiers.
This class is a collection of AttributeLists where each one is associated with a channel number.
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
int region(const Identifier id) const
return region [0,1]
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
int pos_neg(const Identifier id) const
return pos_neg -2 (C side) or 2 (A side)
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
Helper class for LArHEC offline identifiers.
float getWeight(const LArHEC_ID *hecID, const Identifier &id, std::map< int, std::vector< float > > &wmap)
LArHVCorrToSCHVCorr(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
SG::ReadCondHandleKey< ILArHVScaleCorr > m_contKey
virtual StatusCode initialize() override
SG::WriteCondHandleKey< LArHVCorr > m_outKey
StringProperty m_folderName
ToolHandle< ICaloSuperCellIDTool > m_scidTool
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
StringProperty m_weightsName
virtual StatusCode stop() override
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
size_type channelHashMax() const
Define channel hash tables max size.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED