ATLAS Offline Software
Loading...
Searching...
No Matches
TileMuRODToNtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5//*****************************************************************************
6// Filename : TileMuRODToNtuple.cxx
7// Author : Aranzazu Ruiz
8// Created : March 2006
9//
10// DESCRIPTION:
11// Implementation comments only. Class level comments go in .h file.
12//
13// HISTORY:
14//
15// BUGS:
16//
17//
18//*****************************************************************************
19
20// Tile includes
22
23// Athena includes
26
27// Gaudi includes
28#include "GaudiKernel/INTupleSvc.h"
29#include "GaudiKernel/IDataProviderSvc.h"
30#include "GaudiKernel/SmartDataPtr.h"
31
32
33TileMuRODToNtuple::TileMuRODToNtuple(const std::string& name, ISvcLocator* pSvcLocator)
34 : AthAlgorithm(name, pSvcLocator)
35 , m_ntuplePtr(0)
36 , m_ntupleID(100)
37 , m_maxNMuons(50)
38 , m_close(1)
39 , m_ntupleLoc("/FILE1/TileMuRODTag")
40{
41 declareProperty("NTupleLoc", m_ntupleLoc);
42 declareProperty("NTupleID", m_ntupleID);
43 declareProperty("MaxNMuons", m_maxNMuons);
44 declareProperty("CloseNtuple", m_close);
45}
46
49
51
52 m_ntupleLoc = "/NTUPLES/FILE1/TileMuRODTag";
53
54 SmartDataPtr<NTuple::Directory> DirPtr(ntupleSvc(), m_ntupleLoc);
55 if (!DirPtr) DirPtr = ntupleSvc()->createDirectory(m_ntupleLoc);
56
57 if (!DirPtr) {
58 ATH_MSG_ERROR( "Invalid Ntuple Directory: " << m_ntupleLoc );
59 return StatusCode::FAILURE;
60 }
61
62 m_ntuplePtr = ntupleSvc()->book(DirPtr.ptr(), m_ntupleID, CLID_ColumnWiseTuple
63 , "TileMuRODTag-Ntuple");
64
65 if (!m_ntuplePtr) {
66 ATH_MSG_ERROR( "Failed to book ntuple: TileMuRODTagNtuple" );
67 return StatusCode::FAILURE;
68 }
69
70 CHECK(m_ntuplePtr->addItem("TileMuROD/NMuons", m_ntag, 0, m_maxNMuons));
71 CHECK(m_ntuplePtr->addItem("TileMuROD/EtaMuons", m_ntag, m_eta, -1.5, 1.5));
72 CHECK(m_ntuplePtr->addItem("TileMuROD/PhiMuons", m_ntag, m_phi, 0., 6.3));
73
74 ATH_CHECK( m_l2ContainerKey.initialize() );
75
76 ATH_MSG_INFO( "Initialization completed" );
77
78 return StatusCode::SUCCESS;
79}
80
82
83 // step1: read from TDS
85 ATH_CHECK( l2Container.isValid() );
86
87 m_ntag = 0;
88 for (const TileL2* l2 : *l2Container) {
89 for (unsigned int a = 0; a < l2->NMuons(); ++a) {
90 m_eta[m_ntag] = l2->eta(a);
91 m_phi[m_ntag] = l2->phi(a);
92 m_ntag++;
93 }
94 if (m_ntag >= m_maxNMuons) break;
95 }
96
97 if (m_close == 1) {
98 CHECK( ntupleSvc()->writeRecord(m_ntuplePtr) );
99 }
100
101 ATH_MSG_DEBUG( "execute() completed successfully" );
102
103 return StatusCode::SUCCESS;
104}
105
107
108 ATH_MSG_INFO( "finalize() successfully" );
109
110 return StatusCode::SUCCESS;
111}
#define ATH_CHECK
Evaluate an expression and check for errors.
#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.
static Double_t a
INTupleSvc * ntupleSvc()
Handle class for reading from StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Class to store TileMuId and Et quantities computed at the TileCal ROD DSPs.
Definition TileL2.h:33
NTuple::Tuple * m_ntuplePtr
NTuple::Array< float > m_phi
TileMuRODToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
NTuple::Array< float > m_eta
SG::ReadHandleKey< TileL2Container > m_l2ContainerKey
TileL2Container in detector store.
NTuple::Item< int > m_ntag
virtual ~TileMuRODToNtuple()
Destructor.