ATLAS Offline Software
LArMphysOverMcal2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
10 
11 
12 LArMphysOverMcal2Ntuple::LArMphysOverMcal2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
13  LArCond2NtupleBase(name, pSvcLocator) {
14  m_ntTitle="MphysOverMcal";
15  m_ntpath="/NTUPLES/FILE1/MPMC";
16 
17 }
18 
20 = default;
21 
25 }
26 
27 
29 
30  // For compatibility with existing configurations, look in the detector
31  // store first, then in conditions.
32  const ILArMphysOverMcal* larMphysOverMcal= detStore()->tryConstRetrieve<ILArMphysOverMcal>(m_contKey.key());
33  if (!larMphysOverMcal) {
35  larMphysOverMcal=*mpmcHandle;
36  }
37 
38  if (!larMphysOverMcal) {
39  ATH_MSG_ERROR( "Unable to retrieve ILArMphysOverMcal with key "
40  << m_contKey.key() << " from DetectorStore nor from ConditionsStore");
41  return StatusCode::FAILURE;
42  }
43 
44 
45 
46  StatusCode sc;
47  NTuple::Item<long> cellIndex,gain;
48  NTuple::Item<float> mpmc;
49 
50  sc=m_nt->addItem("icell",cellIndex,0,2000);
51  if (sc!=StatusCode::SUCCESS)
52  {ATH_MSG_ERROR( "addItem 'Cell Index' failed" );
53  return StatusCode::FAILURE;
54  }
55 
56  sc=m_nt->addItem("gain",gain,0,3);
57  if (sc!=StatusCode::SUCCESS) {
58  ATH_MSG_ERROR( "addItem 'gain' failed" );
59  return StatusCode::FAILURE;
60  }
61 
62 
63  sc=m_nt->addItem("mphysovermcal",mpmc,-1000.,2.);
64  if (sc!=StatusCode::SUCCESS) {
65  ATH_MSG_ERROR( "addItem 'mphysovermcal' failed" );
66  return StatusCode::FAILURE;
67  }
68 
69 
70  const LArOnOffIdMapping *cabling=nullptr;
71  if(m_isSC) {
72  ATH_MSG_DEBUG( "LArMphysOverMcal2Ntuple: using SC cabling" );
74  cabling=*cablingHdl;
75  }else{
76  ATH_MSG_DEBUG( "LArMphysOverMcal2Ntuple: using LAr cell cabling" );
78  cabling=*cablingHdl;
79  }
80  if(!cabling) {
81  ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
82  return StatusCode::FAILURE;
83  }
84 
85  //=================
86 
87  if(m_isSC){
89  sc = detStore()->retrieve(ll, "LArOnline_SuperCellID");
90  if (sc.isFailure()) {
91  msg(MSG::ERROR) << "Could not get LArOnlineID helper !" << endmsg;
92  return StatusCode::FAILURE;
93  }
94  else {
95  m_onlineId = (const LArOnlineID_Base*)ll;
96  ATH_MSG_DEBUG("Found the SC LArOnlineID helper");
97  }
98  }else{
99  const LArOnlineID* ll;
100  sc = detStore()->retrieve(ll, "LArOnlineID");
101  if (sc.isFailure()) {
102  msg(MSG::ERROR) << "Could not get LArOnlineID helper !" << endmsg;
103  return StatusCode::FAILURE;
104  }
105  else {
106  m_onlineId = (const LArOnlineID_Base*)ll;
107  ATH_MSG_DEBUG(" Found the LAr cell LArOnlineID helper. ");
108  }
109 
110  }
111 
112  // ==============
113 
114  unsigned cellCounter=0;
115  unsigned filledCell=0;
116  unsigned nGain = m_isSC ? 1 : CaloGain::LARNGAIN;
117  for(unsigned igain=CaloGain::LARHIGHGAIN; igain<nGain; igain++) {
118  for (const HWIdentifier hwid: m_onlineId->channel_range()) {
119  if ( cabling->isOnlineConnected(hwid) && !m_onlineId->isFCALchannel(hwid)) {
120  fillFromIdentifier(hwid);
121  cellIndex = cellCounter;
122  gain=igain;
123  mpmc = larMphysOverMcal->MphysOverMcal(hwid,igain);
124  sc=ntupleSvc()->writeRecord(m_nt);
125  if (sc!=StatusCode::SUCCESS) {
126  ATH_MSG_ERROR( "writeRecord failed" );
127  return StatusCode::FAILURE;
128  }
129  filledCell++;
130  }//end if isConnected
131  cellCounter++;
132  }//end loop over online ID
133  } // ovr gains
134  ATH_MSG_INFO("LArMphysOverMcal2Ntuple: filled "<<filledCell<<" out of "<<cellCounter);
135  ATH_MSG_INFO( "LArMphysOverMcal2Ntuple has finished." );
136  return StatusCode::SUCCESS;
137 }// end finalize-method.
138 
LArMphysOverMcal2Ntuple::LArMphysOverMcal2Ntuple
LArMphysOverMcal2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArMphysOverMcal2Ntuple.cxx:12
detail::ll
long long ll
Definition: PrimitiveHelpers.h:46
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition: LArCond2NtupleBase.cxx:33
LArCond2NtupleBase::m_cablingSCKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
Definition: LArCond2NtupleBase.h:90
LArMphysOverMcal2Ntuple::stop
virtual StatusCode stop()
Definition: LArMphysOverMcal2Ntuple.cxx:28
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArOnlineID_Base::isFCALchannel
bool isFCALchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1653
LArMphysOverMcal2Ntuple.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1932
LArCond2NtupleBase::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCond2NtupleBase.h:89
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
LArMphysOverMcal2Ntuple::m_contKey
SG::ReadCondHandleKey< ILArMphysOverMcal > m_contKey
Definition: LArMphysOverMcal2Ntuple.h:37
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArMphysOverMcal2Ntuple::initialize
StatusCode initialize()
Definition: LArMphysOverMcal2Ntuple.cxx:22
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
ILArMphysOverMcal
Definition: ILArMphysOverMcal.h:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
ILArMphysOverMcal::MphysOverMcal
virtual const float & MphysOverMcal(const HWIdentifier &id, int gain) const =0
LArMphysOverMcal2Ntuple::~LArMphysOverMcal2Ntuple
~LArMphysOverMcal2Ntuple()
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBase.h:55
LArOnline_SuperCellID.h
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20