ATLAS Offline Software
PerfMonServices.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 #include "GaudiKernel/MsgStream.h"
7 #include "GaudiKernel/StatusCode.h"
8 
9 // NULL the static pointers
10 ISvcLocator* PerfMonServices::s_pxSvcLocator = nullptr;
11 ITHistSvc* PerfMonServices::s_pxTHistSvc = nullptr;
12 IMessageSvc* PerfMonServices::s_pxMessageSvc = nullptr;
13 StoreGateSvc* PerfMonServices::s_pxStoreGateSvc = nullptr;
14 INTupleSvc* PerfMonServices::s_pxNtupleSvc = nullptr;
15 
16 // Names of the various containers.
17 const std::string PerfMonServices::s_sContainerNames[NUM_CONTAINERS] = { "MuidMuonCollection",
18  "StacoMuonCollection",
19  "Muons",
20  "Electrons",// "ElectronCllection"
21  "PhotonCollection",
22  "MET_Final",
23  "TrackParticleCandidate",
24  // "VxPrimaryCandidate"};
25  "PrimaryVertices"};
26 const std::string PerfMonServices::s_sAtlfastContainerNames[NUM_CONTAINERS] = { "AtlfastMuonCollection",
27  "AtlfastMuonCollection",
28  "AtlfastMuons",
29  "AtlfastElectronCollection",
30  "AtlfastPhotonCollection",
31  "AtlfastMissingEt",
32  "Placeholder" };
33 
34 //===========================================================================
35 // Constructors & destructors
36 //===========================================================================
37 
39 {
40 }
41 
43 {
44 }
45 
46 //===========================================================================
47 // Public Members
48 //===========================================================================
49 
50 StatusCode PerfMonServices::InitialiseServices( ISvcLocator* pxSvcLocator )
51 {
52  s_pxSvcLocator = pxSvcLocator;
53 
54  // Init. the Athena services that will be used in PhysAna.
55  // Init. Messaging first (the others use it for output).
56  bool bRegisterSuccess = true;
57  bRegisterSuccess &= InitialiseMessaging();
58  bRegisterSuccess &= InitialiseStoreGate();
59  bRegisterSuccess &= InitialiseRootTuple();
60  bRegisterSuccess &= InitialiseHistograms();
61 
62  //MsgStream log( s_pxMessageSvc, "Services" );
63  if ( !bRegisterSuccess )
64  {
65  //log << MSG::WARNING
66  //<< "Problem starting at least one of the Athena services : this may be cause problems downstream"
67  //<< endreq;
68  }
69 
70  return StatusCode::SUCCESS;
71 }
72 
73 //===========================================================================
74 // Private Members
75 //===========================================================================
76 
77 // Set of initialisation functions
79 {
80  StatusCode xStatus = s_pxSvcLocator->service( "MessageSvc", s_pxMessageSvc );
81  return CheckServiceInit( xStatus, !s_pxMessageSvc /* , "messaging" */ );
82 }
83 
85 {
86  StatusCode xStatus = s_pxSvcLocator->service( "StoreGateSvc", s_pxStoreGateSvc );
87  return CheckServiceInit( xStatus, !s_pxStoreGateSvc /* , "StoreGateSvc" */ );
88 }
89 
91 {
92  StatusCode xStatus = s_pxSvcLocator->service( "NTupleSvc", s_pxNtupleSvc );
93  return CheckServiceInit( xStatus, !s_pxNtupleSvc /* , "NTuple" */ );
94 }
95 
97 {
98  StatusCode xStatus = s_pxSvcLocator->service( "THistSvc", s_pxTHistSvc);
99  return CheckServiceInit( xStatus, !s_pxTHistSvc /* , "Histogram" */ );
100 }
101 
102 // Small status check utility function for the initialisers above
103 bool PerfMonServices::CheckServiceInit( const StatusCode& xSC, bool bNullPointer /*, const std::string& sType */ )
104 {
105  //MsgStream log( s_pxMessageSvc, "Services" );
106  if ( !xSC.isSuccess() )
107  {
108  //log << MSG::WARNING
109  //<< "Problem starting " << sType << " service : Error Code."
110  //<< endreq;
111  }
112  if ( bNullPointer )
113  {
114  //log << MSG::WARNING
115  //<< "Problem starting " << sType << " service : NULL pointer."
116  //<< endreq;
117  }
118  return ( xSC.isSuccess() && !bNullPointer ) ? true : false;
119 }
120 
121 //===========================================================================
122 
PerfMonServices::PerfMonServices
PerfMonServices()
Definition: PerfMonServices.cxx:38
PerfMonServices::InitialiseRootTuple
static bool InitialiseRootTuple()
Definition: PerfMonServices.cxx:90
PerfMonServices::InitialiseMessaging
static bool InitialiseMessaging()
Definition: PerfMonServices.cxx:78
PerfMonServices.h
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
PerfMonServices::~PerfMonServices
~PerfMonServices()
Definition: PerfMonServices.cxx:42
PerfMonServices::s_sAtlfastContainerNames
static const std::string s_sAtlfastContainerNames[NUM_CONTAINERS]
Definition: PerfMonServices.h:116
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PerfMonServices::CheckServiceInit
static bool CheckServiceInit(const StatusCode &xSC, bool bNullPointer)
Definition: PerfMonServices.cxx:103
PerfMonServices::InitialiseHistograms
static bool InitialiseHistograms()
Definition: PerfMonServices.cxx:96
PerfMonServices::s_sContainerNames
static const std::string s_sContainerNames[NUM_CONTAINERS]
Definition: PerfMonServices.h:115
PerfMonServices::InitialiseServices
static StatusCode InitialiseServices(ISvcLocator *pxSvcLocator)
Definition: PerfMonServices.cxx:50
PerfMonServices::InitialiseStoreGate
static bool InitialiseStoreGate()
Definition: PerfMonServices.cxx:84