ATLAS Offline Software
Loading...
Searching...
No Matches
TileCellIDCToNtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
30
31//TileCalo include
34
35const int max_chan=5216;
36
37// Constructor & deconstructor
38TileCellIDCToNtuple::TileCellIDCToNtuple(const std::string& name, ISvcLocator* pSvcLocator)
39 : AthAlgorithm(name, pSvcLocator)
40{
41}
42
46
47// Alg standard interface function
49{
50 ATH_MSG_INFO( "Initialization started" );
51
52 // retrieve TileID helper from det store
53
54 CHECK( detStore()->retrieve(m_tileID) );
55
56 m_ntupleLoc="/NTUPLES" + m_ntupleLoc.value();
57
58 SmartDataPtr<NTuple::Directory> DirPtr(ntupleSvc(), m_ntupleLoc);
59 if(!DirPtr) DirPtr=ntupleSvc()->createDirectory(m_ntupleLoc);
60 if(!DirPtr) {
61 ATH_MSG_ERROR( "Invalid Ntuple Directory: " );
62 return StatusCode::FAILURE;
63 }
64 m_ntuplePtr=ntupleSvc()->book(DirPtr.ptr(), m_ntupleID,
65 CLID_ColumnWiseTuple, "TileCellIDC-Ntuple");
66 if(!m_ntuplePtr) {
67 ATH_MSG_ERROR( "Failed to book ntuple: TileCellIDCNtuple" );
68 return StatusCode::FAILURE;
69 }
70
71 CHECK( m_ntuplePtr->addItem("TileCell/ncell",m_nchan,0,max_chan) );
72 CHECK( m_ntuplePtr->addItem("TileCell/totalE",m_tolE) );
73
74 CHECK( m_ntuplePtr->addItem("TileCell/energy",m_nchan,m_energy) );
75 CHECK( m_ntuplePtr->addItem("TileCell/enediff",m_nchan,m_enediff) );
76 CHECK( m_ntuplePtr->addItem("TileCell/time",m_nchan,m_time) );
77 CHECK( m_ntuplePtr->addItem("TileCell/quality",m_nchan,m_quality) );
78
79 CHECK( m_ntuplePtr->addItem("TileCell/detector",m_nchan,m_detector,0,3) );
80 CHECK( m_ntuplePtr->addItem("TileCell/side",m_nchan,m_side,-1,1) );
81 CHECK( m_ntuplePtr->addItem("TileCell/sample",m_nchan,m_sample,0,3) );
82 CHECK( m_ntuplePtr->addItem("TileCell/eta",m_nchan,m_eta,0,15) );
83 CHECK( m_ntuplePtr->addItem("TileCell/phi",m_nchan,m_phi,0,63) );
84
85 ATH_MSG_INFO( "Initialization completed" );
86 return StatusCode::SUCCESS;
87}
88
89StatusCode TileCellIDCToNtuple::execute(const EventContext& /*ctx*/)
90{
91 // step1: read Cells from TDS
92 const TileCellIDC* CellCnt;
93 CHECK( evtStore()->retrieve(CellCnt, m_cellContainer.value()) );
94
95 // step2: to fill items in ntuple
96 SelectAllObject<TileCellIDC> selCells(CellCnt);
97 SelectAllObject<TileCellIDC>::const_iterator it=selCells.begin();
98 SelectAllObject<TileCellIDC>::const_iterator end=selCells.end();
99 m_nchan=0;
100 m_tolE=0.0;
101 for(; it != end; ++it) {
102 const TileCell *cell = (*it);
103 m_tolE+=cell->energy();
104 m_energy[m_nchan]=cell->energy();
105 m_enediff[m_nchan]=cell->eneDiff();
106 m_time[m_nchan]=cell->time();
107 m_quality[m_nchan]=cell->quality();
108
109 Identifier id=m_tileID->cell_id(cell->subcalo_hash());
110 m_detector[m_nchan]=m_tileID->section(id);
111 m_side[m_nchan]=m_tileID->side(id);
112 m_sample[m_nchan]=m_tileID->sample(id);
113 m_eta[m_nchan]=m_tileID->tower(id);
114 m_phi[m_nchan]=m_tileID->module(id);
115
116 m_nchan++;
117
118 if (m_nchan >= max_chan) break;
119 }
120
121 // step3: coomit ntuple
122 CHECK( ntupleSvc()->writeRecord(m_ntuplePtr) );
123
124 // Execution completed.
125 ATH_MSG_DEBUG( "execute() completed successfully" );
126 return StatusCode::SUCCESS;
127}
128
130{
131 ATH_MSG_INFO( "finalize() successfully" );
132 return StatusCode::SUCCESS;
133}
134
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
INTupleSvc * ntupleSvc()
const int max_chan
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
const_iterator end()
const_iterator begin()
NTuple::Item< double > m_tolE
NTuple::Array< float > m_energy
NTuple::Array< int > m_sample
StatusCode execute(const EventContext &ctx)
Execute method.
NTuple::Array< float > m_time
Gaudi::Property< std::string > m_cellContainer
NTuple::Array< int > m_phi
NTuple::Item< int > m_nchan
NTuple::Tuple * m_ntuplePtr
NTuple::Array< int > m_eta
Gaudi::Property< std::string > m_ntupleLoc
NTuple::Array< int > m_detector
NTuple::Array< float > m_quality
NTuple::Array< float > m_enediff
NTuple::Array< int > m_side
TileCellIDCToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::string > m_ntupleID