ATLAS Offline Software
CaloCellPedestalCorr.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ****************************************************************************************
6 //
7 // To perform cell per cell pedestal shift correction
8 // taking the pedestal shift in MeV from the database /CALO/Pedestal/CellPedestal folder
9 //
10 // G.Unal 9 may 2008 .... first version
11 //
12 // ****************************************************************************************
13 
14 #include "CaloCellPedestalCorr.h"
15 
17 #include "CaloDetDescr/CaloDetDescrElement.h"
18 
19 //=== AttributeList
20 #include "CoralBase/Blob.h"
22 //=== CaloCondBlod
25 
27 
28 // ======================================================
29 // Constructor
30 
32  const std::string& type,
33  const std::string& name,
34  const IInterface* parent)
35  : AthAlgTool(type, name, parent) {
36  declareInterface<ICaloCellMakerTool>(this);
37 }
38 
39 //========================================================
40 // Initialize
41 
43 {
44  ATH_MSG_INFO( " in CaloCellPedestalCorr::initialize() " );
45 
46  ATH_CHECK(detStore()->retrieve(m_cellId, "CaloCell_ID"));
47 
50 
51  ATH_MSG_INFO( "CaloCellPedestalCorr initialize() end" );
52  return StatusCode::SUCCESS;
53 }
54 
55 
56 StatusCode CaloCellPedestalCorr::process( CaloCellContainer * theCellContainer, const EventContext& ctx) const {
57 
58  const CaloCellPedShift* pedShifts=nullptr;
59 
60  if (!m_isMC) {
62  pedShifts=*pedShiftHdl;
63  }
64 
65  const CaloBCIDAverage* bcidavgshift=nullptr;
66  if (!(m_caloBCIDAvg.key().empty())) {
68  bcidavgshift=&(*bcidavgshiftHdl);
69  }
70 
71 
72 
73  for (CaloCell* theCell : *theCellContainer) {
74  const IdentifierHash cellHash=theCell->caloDDE()->calo_hash();
75  float pedestal=0;
76  if (!m_isMC) {
77  const unsigned int dbGain = CaloCondUtils::getDbCaloGain(theCell->gain());
78  pedestal = pedShifts->pedShift(cellHash,dbGain);
79  }
80 
81  if (bcidavgshift) {
82  pedestal = pedestal + bcidavgshift->averageOflHash(cellHash);
83  }
84 
85  theCell->addEnergy(-pedestal);
86  }//end loop over cell-container
87 
88  return StatusCode::SUCCESS;
89 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellPedShift
Definition: CaloCellPedShift.h:16
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CaloCondUtils.h
CaloBCIDAverage::averageOflHash
float averageOflHash(const IdentifierHash h) const
Definition: CaloBCIDAverage.h:21
CaloCell_ID.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
CaloCellPedestalCorr::m_isMC
Gaudi::Property< bool > m_isMC
Definition: CaloCellPedestalCorr.h:42
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloCellPedestalCorr.h
CaloCellPedestalCorr::m_cellId
const CaloCell_ID * m_cellId
Definition: CaloCellPedestalCorr.h:43
CaloCellPedestalCorr::CaloCellPedestalCorr
CaloCellPedestalCorr(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CaloCellPedestalCorr.cxx:31
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloBCIDAverage
Definition: CaloBCIDAverage.h:16
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloCellPedestalCorr::process
StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
Definition: CaloCellPedestalCorr.cxx:56
WriteCellNoiseToCool.cellHash
cellHash
Definition: WriteCellNoiseToCool.py:433
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloCondUtils::getDbCaloGain
static unsigned int getDbCaloGain(int caloGain)
Returns the non-negative gainId to be used with the COOL DB.
Definition: CaloCondUtils.cxx:86
CaloCellPedestalCorr::initialize
virtual StatusCode initialize() override
Definition: CaloCellPedestalCorr.cxx:42
CaloCondBlobFlt.h
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloCellPedestalCorr::m_pedShiftKey
SG::ReadCondHandleKey< CaloCellPedShift > m_pedShiftKey
Definition: CaloCellPedestalCorr.h:39
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
Definition: IdentifierHash.h:38
CaloCellPedShift::pedShift
float pedShift(const IdentifierHash hash, const int gain) const
Definition: CaloCellPedShift.h:41
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CaloCellPedestalCorr::m_caloBCIDAvg
SG::ReadHandleKey< CaloBCIDAverage > m_caloBCIDAvg
Definition: CaloCellPedestalCorr.h:40