ATLAS Offline Software
TileCellIDCToNtuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //*****************************************************************************
6 // Filename : TileCellIDCToNtuple.cxx
7 // Author : Zhifang
8 // Created : Jan, 2003
9 //
10 // DESCRIPTION:
11 // Implement the algorithm
12 //
13 // HISTORY:
14 //
15 // BUGS:
16 //
17 //*****************************************************************************
18 
19 //Gaudi Includes
20 #include "GaudiKernel/INTupleSvc.h"
21 #include "GaudiKernel/IDataProviderSvc.h"
22 #include "GaudiKernel/SmartDataPtr.h"
23 
24 //Atlas include
27 
28 // Calo include
29 #include "CaloIdentifier/TileID.h"
30 
31 //TileCalo include
32 #include "TileEvent/TileCellIDC.h"
34 
35 const int max_chan=5216;
36 
37 // Constructor & deconstructor
38 TileCellIDCToNtuple::TileCellIDCToNtuple(const std::string& name, ISvcLocator* pSvcLocator)
39  : AthAlgorithm(name, pSvcLocator)
40  , m_ntuplePtr(0)
41  , m_ntupleID("h90")
42  , m_ntupleLoc("/FILE1/TileRec")
43  , m_cellContainer("TileCellIDC")
44  , m_tileID(0)
45 {
46  declareProperty("TileCellIDC", m_cellContainer);
47  declareProperty("NTupleLoc", m_ntupleLoc);
48  declareProperty("NTupleID", m_ntupleID);
49 }
50 
52 {
53 }
54 
55 // Alg standard interface function
57 {
58  ATH_MSG_INFO( "Initialization started" );
59 
60  // retrieve TileID helper from det store
61 
63 
64  m_ntupleLoc="/NTUPLES" + m_ntupleLoc;
65 
66  SmartDataPtr<NTuple::Directory> DirPtr(ntupleSvc(), m_ntupleLoc);
67  if(!DirPtr) DirPtr=ntupleSvc()->createDirectory(m_ntupleLoc);
68  if(!DirPtr) {
69  ATH_MSG_ERROR( "Invalid Ntuple Directory: " );
70  return StatusCode::FAILURE;
71  }
72  m_ntuplePtr=ntupleSvc()->book(DirPtr.ptr(), m_ntupleID,
73  CLID_ColumnWiseTuple, "TileCellIDC-Ntuple");
74  if(!m_ntuplePtr) {
75  ATH_MSG_ERROR( "Failed to book ntuple: TileCellIDCNtuple" );
76  return StatusCode::FAILURE;
77  }
78 
79  CHECK( m_ntuplePtr->addItem("TileCell/ncell",m_nchan,0,max_chan) );
80  CHECK( m_ntuplePtr->addItem("TileCell/totalE",m_tolE) );
81 
82  CHECK( m_ntuplePtr->addItem("TileCell/energy",m_nchan,m_energy) );
83  CHECK( m_ntuplePtr->addItem("TileCell/enediff",m_nchan,m_enediff) );
84  CHECK( m_ntuplePtr->addItem("TileCell/time",m_nchan,m_time) );
85  CHECK( m_ntuplePtr->addItem("TileCell/quality",m_nchan,m_quality) );
86 
87  CHECK( m_ntuplePtr->addItem("TileCell/detector",m_nchan,m_detector,0,3) );
88  CHECK( m_ntuplePtr->addItem("TileCell/side",m_nchan,m_side,-1,1) );
89  CHECK( m_ntuplePtr->addItem("TileCell/sample",m_nchan,m_sample,0,3) );
90  CHECK( m_ntuplePtr->addItem("TileCell/eta",m_nchan,m_eta,0,15) );
91  CHECK( m_ntuplePtr->addItem("TileCell/phi",m_nchan,m_phi,0,63) );
92 
93  ATH_MSG_INFO( "Initialization completed" );
94  return StatusCode::SUCCESS;
95 }
96 
98 {
99  // step1: read Cells from TDS
100  const TileCellIDC* CellCnt;
101  CHECK( evtStore()->retrieve(CellCnt, m_cellContainer) );
102 
103  // step2: to fill items in ntuple
104  SelectAllObject<TileCellIDC> selCells(CellCnt);
107  m_nchan=0;
108  m_tolE=0.0;
109  for(; it != end; ++it) {
110  const TileCell *cell = (*it);
111  m_tolE+=cell->energy();
112  m_energy[m_nchan]=cell->energy();
113  m_enediff[m_nchan]=cell->eneDiff();
114  m_time[m_nchan]=cell->time();
115  m_quality[m_nchan]=cell->quality();
116 
117  Identifier id=m_tileID->cell_id(cell->subcalo_hash());
119  m_side[m_nchan]=m_tileID->side(id);
121  m_eta[m_nchan]=m_tileID->tower(id);
123 
124  m_nchan++;
125 
126  if (m_nchan >= max_chan) break;
127  }
128 
129  // step3: coomit ntuple
130  CHECK( ntupleSvc()->writeRecord(m_ntuplePtr) );
131 
132  // Execution completed.
133  ATH_MSG_DEBUG( "execute() completed successfully" );
134  return StatusCode::SUCCESS;
135 }
136 
138 {
139  ATH_MSG_INFO( "finalize() successfully" );
140  return StatusCode::SUCCESS;
141 }
142 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileCell
Definition: TileCell.h:57
TileCellIDCToNtuple::m_tolE
NTuple::Item< double > m_tolE
Definition: TileCellIDCToNtuple.h:55
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
TileCellIDCToNtuple::m_cellContainer
std::string m_cellContainer
Definition: TileCellIDCToNtuple.h:68
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SelectAllObjectMT::end
const_iterator end()
Definition: SelectAllObjectMT.h:131
TileCellIDCToNtuple::m_ntupleLoc
std::string m_ntupleLoc
Definition: TileCellIDCToNtuple.h:52
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Tile_Base_ID::side
int side(const Identifier &id) const
Definition: Tile_Base_ID.cxx:153
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Tile_Base_ID::sample
int sample(const Identifier &id) const
Definition: Tile_Base_ID.cxx:171
TileCellIDCToNtuple::m_energy
NTuple::Array< float > m_energy
Definition: TileCellIDCToNtuple.h:57
TileCellIDCToNtuple::finalize
StatusCode finalize()
Definition: TileCellIDCToNtuple.cxx:137
Tile_Base_ID::tower
int tower(const Identifier &id) const
Definition: Tile_Base_ID.cxx:165
TileCellIDCToNtuple::m_nchan
NTuple::Item< int > m_nchan
Definition: TileCellIDCToNtuple.h:54
TileCellIDCToNtuple::initialize
StatusCode initialize()
Definition: TileCellIDCToNtuple.cxx:56
TileID.h
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
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
TileCellIDCToNtuple::m_side
NTuple::Array< int > m_side
Definition: TileCellIDCToNtuple.h:63
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
SelectAllObjectMT::begin
const_iterator begin()
Definition: SelectAllObjectMT.h:115
SelectAllObjectMT
Definition: SelectAllObjectMT.h:11
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Tile_Base_ID::module
int module(const Identifier &id) const
Definition: Tile_Base_ID.cxx:159
TileCellIDCToNtuple::m_phi
NTuple::Array< int > m_phi
Definition: TileCellIDCToNtuple.h:66
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
TileCellIDCToNtuple::m_enediff
NTuple::Array< float > m_enediff
Definition: TileCellIDCToNtuple.h:58
TileCellIDC.h
TileCellIDCToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition: TileCellIDCToNtuple.h:50
TileCellIDCToNtuple::~TileCellIDCToNtuple
virtual ~TileCellIDCToNtuple()
Definition: TileCellIDCToNtuple.cxx:51
TileCellIDCToNtuple::m_sample
NTuple::Array< int > m_sample
Definition: TileCellIDCToNtuple.h:64
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SelectAllObjectMT::const_iterator
Definition: SelectAllObjectMT.h:22
AthAlgorithm
Definition: AthAlgorithm.h:47
TileCellIDCToNtuple::TileCellIDCToNtuple
TileCellIDCToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TileCellIDCToNtuple.cxx:38
TileCellIDCToNtuple::m_ntupleID
std::string m_ntupleID
Definition: TileCellIDCToNtuple.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TileCellIDCToNtuple::m_detector
NTuple::Array< int > m_detector
Definition: TileCellIDCToNtuple.h:62
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileCellIDCToNtuple::m_eta
NTuple::Array< int > m_eta
Definition: TileCellIDCToNtuple.h:65
TileCellIDCToNtuple.h
TileCellIDCToNtuple::m_time
NTuple::Array< float > m_time
Definition: TileCellIDCToNtuple.h:59
max_chan
const int max_chan
Definition: TileCellIDCToNtuple.cxx:35
TileCellIDCToNtuple::execute
StatusCode execute()
Definition: TileCellIDCToNtuple.cxx:97
TileCellIDCToNtuple::m_tileID
const TileID * m_tileID
Definition: TileCellIDCToNtuple.h:69
SelectAllObject.h
Tile_Base_ID::section
int section(const Identifier &id) const
Definition: Tile_Base_ID.cxx:147
Tile_Base_ID::cell_id
Identifier cell_id(const Identifier &any_id) const
Definition: Tile_Base_ID.cxx:581
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
TileCellIDC
Definition: TileCellIDC.h:13
TileCellIDCToNtuple::m_quality
NTuple::Array< float > m_quality
Definition: TileCellIDCToNtuple.h:60