ATLAS Offline Software
Loading...
Searching...
No Matches
InDetUpdateCaches.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
10
11
12
13// for getmem
14#include <sys/types.h>
15#include <unistd.h>
16#include <string>
17#include <fstream>
18#include <sstream>
19
20
21
22InDetUpdateCaches::InDetUpdateCaches(const std::string& name, ISvcLocator* pSvcLocator) :
23 AthAlgorithm(name, pSvcLocator),
24 m_first(true){
25 // Get parameter values from jobOptions file
26 declareProperty("UpdateInInit", m_inInit = false);
27 declareProperty("UpdateInExec", m_inExec = true);
28}
29
30
31StatusCode
33 msg(MSG::INFO) << "initialize()" << endmsg;
34 StatusCode sc;
35 // Retrieve GeoModel managers
36 const InDetDD::SCT_DetectorManager * sctManager = nullptr;
37 sc=detStore()->retrieve(sctManager, "SCT");
38 if (sc.isFailure() || !sctManager) {
39 msg(MSG::WARNING) << "Could not find the SCT_DetectorManager" << endmsg;
40 } else {
41 msg(MSG::DEBUG) << "SCT_DetectorManager found" << endmsg;
42 m_detManagers.push_back(sctManager);
43 }
44 const InDetDD::PixelDetectorManager * pixelManager = nullptr;
45 sc=detStore()->retrieve(pixelManager, "Pixel");
46 if (sc.isFailure() || !pixelManager) {
47 msg(MSG::WARNING) << "Could not find the PixelDetectorManager" << endmsg;
48 } else {
49 msg(MSG::DEBUG) << "PixelDetectorManager found" << endmsg;
50 m_detManagers.push_back(pixelManager);
51 }
52 const InDetDD::TRT_DetectorManager * trtManager = nullptr;
53 sc=detStore()->retrieve(trtManager, "TRT");
54 if (sc.isFailure() || !trtManager) {
55 msg(MSG::WARNING) << "Could not find the TRT_DetectorManager" << endmsg;
56 } else {
57 msg(MSG::DEBUG) << "TRT_DetectorManager found" << endmsg;
58 m_detManagers.push_back(trtManager);
59 }
60 if (m_inInit) {
61 msg(MSG::DEBUG) << "Updating caches during initialize" << endmsg;
62 updateAll();
63 }
64 return StatusCode::SUCCESS;
65}
66
67
68StatusCode
70 if (m_first) {
71 if (m_inExec) {
72 msg(MSG::DEBUG) << "Updating caches during first execute" << endmsg;
73 updateAll();
74 }
75 m_first = false;
76 }
77 return StatusCode::SUCCESS;
78}
79
80
81StatusCode
83 return StatusCode::SUCCESS;
84}
85
86
87void
89 msg(MSG::DEBUG) << "Updating ..." << endmsg;
90 IChronoStatSvc* chrono = chronoSvc();
91 for (unsigned int i = 0; i < m_detManagers.size(); i++) {
93 msg(MSG::DEBUG) << "manager ..." << manager << endmsg;
94 if (manager) {
95 std::string chronoTag = manager->getName() + name();
96 float memStart = getMem();
97 chrono->chronoStart( chronoTag );
98 msg(MSG::DEBUG) << "Updating " << manager->getName() << " caches ..." << endmsg;
99 manager->updateAll();
100 msg(MSG::DEBUG) << "... done " << endmsg;
101 chrono->chronoStop(chronoTag);
102 float memUsed = getMem() - memStart;
103 float uTime = chrono->chronoDelta(chronoTag, IChronoStatSvc::USER)/1000.;
104 msg(MSG::DEBUG) << "Memory used by UpdatedCaches for " << manager->getName() << " = " << memUsed/1024.0 << " MB" << endmsg;
105 msg(MSG::DEBUG) << "Time used by UpdatedCaches for " << manager->getName() << " = " << uTime << " ms" << endmsg;
106 }
107 }
108}
109
110
111float
113 int pid=getpid();
114 std::ostringstream is;
115 is<<pid;
116 std::string spid=is.str();
117 std::string temp="cat /proc/"+spid+"/status | grep VmSize > mem.txt";
118 system(temp.c_str());
119 std::ifstream in("mem.txt");
120 std::string text,mem,text1;
121 in>>text>>mem>>text1;
122 system("rm -f mem.txt");
123 float memsize=atof(mem.c_str());
124 return memsize;
125}
#define endmsg
static Double_t sc
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
MsgStream & msg() const
Virtual base class for all ID detector managers.
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated SCT in...
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
std::vector< const InDetDD::InDetDetectorManager * > m_detManagers
InDetUpdateCaches(const std::string &name, ISvcLocator *pSvcLocator)