ATLAS Offline Software
LArShape2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 
12 LArShape2Ntuple::LArShape2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
13  LArCond2NtupleBase(name, pSvcLocator)
14 {
15  declareProperty("NtupleName", m_ntName = "SHAPE");
16  declareProperty("NtupleFile", m_ntFile = "FILE1");
17  declareProperty("isComplete", m_isComplete=false);
18 
19 }
20 
22 = default;
23 
24 
27  m_ntTitle="Pulse Shape";
28  m_ntpath=std::string("/NTUPLES/")+m_ntFile+std::string("/")+m_ntName;
30 }
31 
32 
34  const EventContext& ctx = Gaudi::Hive::currentContext();
35  // Ntuple booking: Specific
36  NTuple::Item<long> gain, phase, nSamples;
37  NTuple::Item<float> timeOffset, phasetime;
38  NTuple::Array<float> Shape, ShapeDer;
39 
40 
41  ATH_CHECK(m_nt->addItem("Gain",gain,-1,2));
42 
43  //Specific:
44  if (m_isComplete) {
45  ATH_CHECK(m_nt->addItem("TimeOffset",timeOffset,0,100));
46  ATH_CHECK(m_nt->addItem("Phase",phase,0,49));
47  ATH_CHECK(m_nt->addItem("PhaseTime",phasetime,0,800));
48  }
49  ATH_CHECK(m_nt->addItem("nSamples",nSamples,0,100));
50  ATH_CHECK(m_nt->addItem("Shape",nSamples,Shape));
51  ATH_CHECK(m_nt->addItem("ShapeDer",nSamples,ShapeDer));
52 
53  const ILArShape* larShape = nullptr ;
54  const LArShapeComplete* larShapeComplete = nullptr ;
55 
56  if (m_isComplete) {
57  ATH_CHECK(detStore()->retrieve(larShapeComplete,m_contKey.key()));
58  larShape=larShapeComplete; //Cast to base-class
59  }
60  else { //Use just the abstract interface (works also for LArShapeFlat and LArShapeMC)
61  // For compatibility with existing configurations, look in the detector
62  // store first, then in conditions.
63  larShape=detStore()->tryConstRetrieve<ILArShape> (m_contKey.key());
64  if (!larShape) {
66  larShape=*shapeHandle;
67  }
68  }
69 
70  const LArOnOffIdMapping *cabling=nullptr;
71  if(m_isSC) {
72  ATH_MSG_DEBUG( "LArOFC2Ntuple: using SC cabling" );
74  cabling=*cablingHdl;
75  }else{
77  cabling=*cablingHdl;
78  }
79 
80 
81  if(!cabling) {
82  ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
83  return StatusCode::FAILURE;
84  }
85 
86 
87  unsigned cellCounter=0;
88  for ( unsigned igain=CaloGain::LARHIGHGAIN;
90  {
91  for (HWIdentifier chid : m_onlineId->channel_range()) {
92  if (!cabling->isOnlineConnected(chid)) continue;
93  unsigned nPhase=1;
94  if (larShapeComplete) nPhase=larShapeComplete->nTimeBins(chid,gain);
95  for (unsigned iphase=0;iphase<nPhase;iphase++) {
96  ATH_MSG_VERBOSE("Dumping Shape for channel " << m_onlineId->channel_name(chid) << ", gain " << gain << ", phase " << iphase);
97  ILArShape::ShapeRef_t shape=larShape->Shape(chid,igain);
98  ILArShape::ShapeRef_t shapeder =larShape->ShapeDer(chid,igain);
99  fillFromIdentifier(chid);
100  gain = (long)igain ;
101  nSamples=shape.size();
102  for (int k=0;k<nSamples;k++ ) {
103  Shape[k] = shape[k] ;
104  ShapeDer[k] = shapeder[k] ;
105  }
106  if (larShapeComplete) {
107  timeOffset = larShapeComplete->timeOffset(chid,igain);
108  phasetime = phase*larShapeComplete->timeBinWidth(chid,igain);
109  phase = (long)iphase ;
110  }
111 
112  ATH_CHECK(ntupleSvc()->writeRecord(m_nt));
113  cellCounter++;
114  }//loop over phases
115  }//loop over channels
116  }//loop over gains
117 
118  ATH_MSG_INFO( "Total number of cells = " << cellCounter );
119  ATH_MSG_INFO( "LArShape2Ntuple has finished." );
120  return StatusCode::SUCCESS;
121 } // end finalize-method.
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
LArShapeComplete::timeBinWidth
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const
Definition: LArShapeComplete.cxx:83
LArShape2Ntuple::LArShape2Ntuple
LArShape2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArShape2Ntuple.cxx:12
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArShape2Ntuple::stop
virtual StatusCode stop()
Definition: LArShape2Ntuple.cxx:33
LArShape2Ntuple::m_isComplete
bool m_isComplete
Definition: LArShape2Ntuple.h:40
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
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
ILArShape::ShapeDer
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
LArShapeComplete
This class implements the ILArShape interface.
Definition: LArShapeComplete.h:26
LArShapeComplete.h
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
LArShape2Ntuple.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
LArShape2Ntuple::m_ntName
std::string m_ntName
Definition: LArShape2Ntuple.h:38
LArShape2Ntuple::m_ntFile
std::string m_ntFile
Definition: LArShape2Ntuple.h:39
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1936
LArShapeComplete::timeOffset
virtual float timeOffset(const HWIdentifier &CellID, int gain) const
Definition: LArShapeComplete.cxx:59
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
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArShape2Ntuple::m_contKey
SG::ReadCondHandleKey< ILArShape > m_contKey
Definition: LArShape2Ntuple.h:37
LArShapeComplete::nTimeBins
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const
Definition: LArShapeComplete.cxx:72
LArShapeSC.h
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
LArShapeFlat.h
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
LArShape2Ntuple::initialize
StatusCode initialize()
Definition: LArShape2Ntuple.cxx:25
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArShape32MC.h
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBase.h:55
LArShape2Ntuple::~LArShape2Ntuple
~LArShape2Ntuple()
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
LArOnlineID_Base::channel_name
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Definition: LArOnlineID_Base.cxx:218
CaloGain.h
ILArShape
Definition: ILArShape.h:13
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
fitman.k
k
Definition: fitman.py:528
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
ILArShape::Shape
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0