ATLAS Offline Software
Loading...
Searching...
No Matches
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
12LArShape2Ntuple::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
26 ATH_CHECK(m_contKey.initialize());
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;
89 igain<CaloGain::LARNGAIN ; ++igain )
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);
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.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
INTupleSvc * ntupleSvc()
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
LArVectorProxy ShapeRef_t
This class defines the interface for accessing Shape (Nsample variable, Dt = 25 ns fixed) @stereotype...
Definition ILArShape.h:26
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) 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)
virtual StatusCode stop()
SG::ReadCondHandleKey< ILArShape > m_contKey
StatusCode initialize()
LArShape2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
std::string m_ntName
std::string m_ntFile
This class implements the ILArShape interface.
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const
virtual float timeOffset(const HWIdentifier &CellID, int gain) const
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18