ATLAS Offline Software
LArOFC2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include "GaudiKernel/ThreadLocalContext.h"
10 
11 LArOFC2Ntuple::LArOFC2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
12  LArCond2NtupleBase(name, pSvcLocator)
13 {
14  declareProperty("Nsamples", m_nSamples = 5);
15  declareProperty("NtupleName", m_ntName = "OFC");
16  declareProperty("NtupleFile", m_ntFile = "FILE1");
17 }
18 
20 = default;
21 
23  m_ntTitle="Optimal Filtering Coefficients";
24  m_ntpath=std::string("/NTUPLES/")+m_ntFile+std::string("/")+m_ntName;
25 
27 
29  return StatusCode::SUCCESS;
30 }
31 
33  const EventContext& ctx = Gaudi::Hive::currentContext();
34 
35  // Ntuple booking: Specific
36  NTuple::Item<long> gain, phase, nSamples;
37  NTuple::Item<float> timeOffset, phasetime;
38  NTuple::Array<float> OFCa, OFCb;
39 
40  ATH_CHECK( m_nt->addItem("Gain",gain,-1,2) );
41  ATH_CHECK( m_nt->addItem("TimeOffset",timeOffset,0,100) );
42  ATH_CHECK( m_nt->addItem("Phase",phase,0,49) );
43  ATH_CHECK( m_nt->addItem("PhaseTime",phasetime,0,800) );
44  ATH_CHECK( m_nt->addItem("nSamples",nSamples,0,100) );
45  ATH_CHECK( m_nt->addItem("OFCa",m_nSamples,OFCa) );
46  ATH_CHECK( m_nt->addItem("OFCb",m_nSamples,OFCb) );
47 
48  // retrieve OFC object
49  const ILArOFC* larOFC=nullptr;
50 
51  //Try Det-Store (real data, elec-calib case)
52  if (detStore()->contains<ILArOFC>(m_ofcKey.key())) {
53  ATH_CHECK(detStore()->retrieve(larOFC,m_ofcKey.key()));
54  }
55  else {//Via ReadCondHandle from CondStore (MC case)
56  SG::ReadCondHandle<ILArOFC> larOFCHdl (m_ofcKey, ctx);
57  larOFC=larOFCHdl.cptr();
58  }
59 
60  const LArOnOffIdMapping *cabling=nullptr;
61  if(m_isSC) {
62  ATH_MSG_DEBUG( "LArOFC2Ntuple: using SC cabling" );
64  cabling=*cablingHdl;
65  }else{
67  cabling=*cablingHdl;
68  }
69 
70 
71  if(!cabling) {
72  ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
73  return StatusCode::FAILURE;
74  }
75 
76  unsigned cellCounter=0;
77  auto maxgain = CaloGain::LARNGAIN;
78  if(m_isSC) maxgain=CaloGain::LARMEDIUMGAIN;
79 
80  for ( int igain=CaloGain::LARHIGHGAIN;
81  igain<maxgain ; ++igain )
82  {
83  for (HWIdentifier chid : m_onlineId->channel_range()) {
84  if ( !cabling->isOnlineConnected(chid)) continue;
85  ATH_MSG_VERBOSE( "Dumping OFC for channel 0x" << MSG::hex
86  << chid.get_compact() << MSG::dec );
87  for (unsigned iphase=0;iphase<larOFC->nTimeBins(chid,igain);iphase++) {
88  ILArOFC::OFCRef_t ofc_a=larOFC->OFC_a(chid,igain,iphase);
89  //Check if we have OFC for this channel and gain
90  if (!ofc_a.size()) break;//No more phases
91  ILArOFC::OFCRef_t ofc_b=larOFC->OFC_b(chid,igain,iphase);
92  fillFromIdentifier(chid);
93  gain = (long)igain ;
94  phase = (long)iphase ;
95  nSamples=ofc_a.size();
96  for (int k=0;k<nSamples;k++ ) {
97  OFCa[k] = ofc_a[k] ;
98  OFCb[k] = ofc_b[k] ;
99  }
100 
101  timeOffset = larOFC->timeOffset(chid,igain);
102  phasetime = phase*larOFC->timeBinWidth(chid,igain);
103 
104 
105  ATH_CHECK( ntupleSvc()->writeRecord(m_nt) );
106  cellCounter++;
107  }//loop over phases
108  }//loop over channels
109  }//loop over gains
110  ATH_MSG_INFO( "Total number of cells = " << cellCounter );
111  ATH_MSG_INFO( "LArOFC2Ntuple has finished." );
112  return StatusCode::SUCCESS;
113 } // end finalize-method.
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
LArOFC2Ntuple::m_nSamples
unsigned m_nSamples
Definition: LArOFC2Ntuple.h:38
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArOFC2Ntuple::m_ofcKey
SG::ReadCondHandleKey< ILArOFC > m_ofcKey
Definition: LArOFC2Ntuple.h:44
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ILArOFC::OFC_b
virtual OFCRef_t OFC_b(const HWIdentifier &id, int gain, int tbin=0) const =0
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArOFC2Ntuple::initialize
virtual StatusCode initialize() override
Definition: LArOFC2Ntuple.cxx:22
LArOFC2Ntuple::stop
virtual StatusCode stop() override
Definition: LArOFC2Ntuple.cxx:32
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
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
ReadCondHandle.h
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
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
ILArOFC::timeOffset
virtual float timeOffset(const HWIdentifier &CellID, int gain) const =0
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1936
LArCond2NtupleBase::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCond2NtupleBase.h:89
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
ILArOFC::timeBinWidth
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const =0
LArOFC2Ntuple::m_ntFile
std::string m_ntFile
Definition: LArOFC2Ntuple.h:40
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArOFC2Ntuple::~LArOFC2Ntuple
virtual ~LArOFC2Ntuple()
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArOFC2Ntuple.h
ILArOFC
Definition: ILArOFC.h:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBase.h:55
LArOFC2Ntuple::LArOFC2Ntuple
LArOFC2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArOFC2Ntuple.cxx:11
ILArOFC::OFC_a
virtual OFCRef_t OFC_a(const HWIdentifier &id, int gain, int tbin=0) const =0
access to OFCs by online ID, gain, and tbin (!=0 for testbeam)
ILArOFC::nTimeBins
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const =0
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
LArOFC2Ntuple::m_ntName
std::string m_ntName
Definition: LArOFC2Ntuple.h:39
fitman.k
k
Definition: fitman.py:528
LArOnlineID.h
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67