ATLAS Offline Software
Loading...
Searching...
No Matches
LArMphysOverMcal2Ntuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
10
11
12LArMphysOverMcal2Ntuple::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
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){
88 const LArOnline_SuperCellID* ll;
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 = static_cast<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 = static_cast<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
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
INTupleSvc * ntupleSvc()
const ServiceHandle< StoreGateSvc > & detStore() const
virtual const float & MphysOverMcal(const HWIdentifier &id, int gain) const =0
Gaudi::Property< bool > m_isSC
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
const LArOnlineID_Base * m_onlineId
bool fillFromIdentifier(const HWIdentifier &id)
LArCond2NtupleBase(const std::string &name, ISvcLocator *pSvcLocator)
LArMphysOverMcal2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< ILArMphysOverMcal > m_contKey
Helper for the Liquid Argon Calorimeter cell identifiers.
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18
MsgStream & msg
Definition testRead.cxx:32