ATLAS Offline Software
Loading...
Searching...
No Matches
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
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 , 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
54
55// Alg standard interface function
57{
58 ATH_MSG_INFO( "Initialization started" );
59
60 // retrieve TileID helper from det store
61
62 CHECK( detStore()->retrieve(m_tileID) );
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);
105 SelectAllObject<TileCellIDC>::const_iterator it=selCells.begin();
106 SelectAllObject<TileCellIDC>::const_iterator end=selCells.end();
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());
118 m_detector[m_nchan]=m_tileID->section(id);
119 m_side[m_nchan]=m_tileID->side(id);
120 m_sample[m_nchan]=m_tileID->sample(id);
121 m_eta[m_nchan]=m_tileID->tower(id);
122 m_phi[m_nchan]=m_tileID->module(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
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(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 with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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
NTuple::Array< float > m_time
NTuple::Array< int > m_phi
NTuple::Item< int > m_nchan
NTuple::Tuple * m_ntuplePtr
NTuple::Array< int > m_eta
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)