ATLAS Offline Software
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
25 #include "StoreGate/ReadHandle.h"
26 
27 // Gaudi includes
28 #include "GaudiKernel/INTupleSvc.h"
29 #include "GaudiKernel/IDataProviderSvc.h"
30 #include "GaudiKernel/SmartDataPtr.h"
31 
32 
33 TileMuRODToNtuple::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 
48 }
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 }
TileMuRODToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition: TileMuRODToNtuple.h:58
TileMuRODToNtuple::finalize
StatusCode finalize()
Definition: TileMuRODToNtuple.cxx:106
TileMuRODToNtuple::m_l2ContainerKey
SG::ReadHandleKey< TileL2Container > m_l2ContainerKey
TileL2Container in detector store.
Definition: TileMuRODToNtuple.h:75
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TileMuRODToNtuple::m_eta
NTuple::Array< float > m_eta
Definition: TileMuRODToNtuple.h:68
TileMuRODToNtuple::m_phi
NTuple::Array< float > m_phi
Definition: TileMuRODToNtuple.h:69
TileMuRODToNtuple::m_ntupleLoc
std::string m_ntupleLoc
Definition: TileMuRODToNtuple.h:62
skel.l2
l2
Definition: skel.GENtoEVGEN.py:426
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileMuRODToNtuple.h
TileMuRODToNtuple::initialize
StatusCode initialize()
Definition: TileMuRODToNtuple.cxx:50
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
TileMuRODToNtuple::~TileMuRODToNtuple
virtual ~TileMuRODToNtuple()
Destructor.
Definition: TileMuRODToNtuple.cxx:47
TileMuRODToNtuple::m_ntag
NTuple::Item< int > m_ntag
Definition: TileMuRODToNtuple.h:64
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileMuRODToNtuple::m_close
int m_close
Definition: TileMuRODToNtuple.h:61
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TileMuRODToNtuple::execute
StatusCode execute()
Definition: TileMuRODToNtuple.cxx:81
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileMuRODToNtuple::TileMuRODToNtuple
TileMuRODToNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: TileMuRODToNtuple.cxx:33
a
TList * a
Definition: liststreamerinfos.cxx:10
ReadHandle.h
Handle class for reading from StoreGate.
TileMuRODToNtuple::m_ntupleID
int m_ntupleID
Definition: TileMuRODToNtuple.h:59
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
TileMuRODToNtuple::m_maxNMuons
int m_maxNMuons
Definition: TileMuRODToNtuple.h:60
TileL2
Class to store TileMuId and Et quantities computed at the TileCal ROD DSPs.
Definition: TileL2.h:33