ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::IPCMat Class Reference

#include <IPCMat.h>

Collaboration diagram for Trk::IPCMat:

Classes

struct  MsgBuf
 

Public Member Functions

 IPCMat (IMessageSvc *msgSvc)
 
 ~IPCMat ()
 
 IPCMat (const IPCMat &)=delete
 
IPCMatoperator= (const IPCMat &)=delete
 
StatusCode init (void)
 
StatusCode allocate (int)
 
StatusCode write (const std::string &, bool)
 
StatusCode end ()
 
StatusCode incMat (uint32_t, uint32_t, double)
 
StatusCode incVec (uint32_t, double)
 
StatusCode scaleMat (int)
 
StatusCode scaleVec (int)
 
StatusCode setScale (int)
 
StatusCode setVersion (float, bool)
 
StatusCode reSize (int)
 
StatusCode removeModule (int)
 
StatusCode removeAlignPar (int)
 
void summary ()
 

Private Member Functions

 IPCMat ()
 
const std::string & name () const
 

Private Attributes

IMessageSvc * m_msgSvc {}
 
int m_ncalls {}
 
int m_msgid {}
 
std::string m_name
 
MsgStream * m_log {}
 
pid_t m_ipcmat_pid {}
 
struct Trk::IPCMat::MsgBuf m_ipcmat_msgp
 

Detailed Description

Definition at line 37 of file IPCMat.h.

Constructor & Destructor Documentation

◆ IPCMat() [1/3]

Trk::IPCMat::IPCMat ( IMessageSvc *  msgSvc)

Definition at line 22 of file IPCMat.cxx.

23  : m_msgSvc(msgSvc),
24  m_ncalls(0),
25  m_msgid(0),
26  m_name("GlobAlign::IPCMat"),
27  m_log(new MsgStream(msgSvc,name()))
28 {
29 }

◆ ~IPCMat()

Trk::IPCMat::~IPCMat ( )
inline

Definition at line 42 of file IPCMat.h.

42 {}

◆ IPCMat() [2/3]

Trk::IPCMat::IPCMat ( const IPCMat )
delete

◆ IPCMat() [3/3]

Trk::IPCMat::IPCMat ( )
private

Member Function Documentation

◆ allocate()

StatusCode Trk::IPCMat::allocate ( int  size)

Definition at line 238 of file IPCMat.cxx.

238  {
239  //MsgStream log(m_msgSvc,name());
240  if (m_log->level()>=MSG::INFO) {
241  *m_log << MSG::INFO; m_log->setColor(MSG::BLUE);
242  *m_log << "in IPCMat::ipcmat_allocate" << endmsg;
243  }
244 
247 
248  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
249  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
250  << " Error number is " << errno << endmsg;
251  return StatusCode::FAILURE;
252  }
253 
254  return StatusCode::SUCCESS;
255 }

◆ end()

StatusCode Trk::IPCMat::end ( )

Definition at line 324 of file IPCMat.cxx.

324  {
325  //MsgStream log(m_msgSvc,name());
326 
328  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
329  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
330  << " Error number is " << errno << endmsg;
331  return StatusCode::FAILURE;
332  }
333 
334  // let chid finish its jobs
335  wait4(m_ipcmat_pid, nullptr, 0, nullptr);
336  return StatusCode::SUCCESS;
337 }

◆ incMat()

StatusCode Trk::IPCMat::incMat ( uint32_t  a,
uint32_t  b,
double  c 
)

Definition at line 39 of file IPCMat.cxx.

39  {
40  //MsgStream log(m_msgSvc,name());
41 
46 
47  if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+2*sizeof(uint32_t)+sizeof(double),0)<0) {
48  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " Error number is " << errno << endmsg;
49  return StatusCode::FAILURE;
50  }
51 
52  return StatusCode::SUCCESS;
53 }

◆ incVec()

StatusCode Trk::IPCMat::incVec ( uint32_t  a,
double  c 
)

Definition at line 58 of file IPCMat.cxx.

58  {
59  //MsgStream log(m_msgSvc,name());
60 
65 
66  if (m_log->level()>=MSG::DEBUG)
67  *m_log << MSG::DEBUG << "call number " << std::setw(8) << m_ncalls
68  << endmsg;
69 
70  if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+2*sizeof(uint32_t)+sizeof(double),0)<0) {
71  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
72  << " Error number is " << errno << endmsg;
73  return StatusCode::FAILURE;
74  }
75 
76  m_ncalls++;
77  return StatusCode::SUCCESS;
78 }

◆ init()

StatusCode Trk::IPCMat::init ( void  )

Definition at line 177 of file IPCMat.cxx.

177  {
178  //MsgStream log(m_msgSvc,name());
179  if (m_log->level()>=MSG::INFO) {
180  *m_log << MSG::INFO; m_log->setColor(MSG::BLUE);
181  *m_log << "in IPCMat::ipcmat_init" << endmsg;
182  }
183 
184  key_t key;
185 
186  if ((key = ftok("/dev/null", 69)) == -1) {
187  *m_log << MSG::ERROR << "Unable to get key" << endmsg;
188  return StatusCode::FAILURE;
189  }
190  else{
191  if (m_log->level()>=MSG::INFO)
192  *m_log << MSG::INFO << "Got key " << key << endmsg;
193  }
194 
195  // destroy message queue if existed
196  msgctl(m_msgid, IPC_RMID, nullptr);
197 
198  m_msgid = msgget(key, IPC_CREAT | 0666);
199  if(m_msgid < 0) {
200  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " key: " << key
201  << " Error number is " << errno << endmsg;
202  return StatusCode::FAILURE;
203  }else{
204  if (m_log->level()>=MSG::INFO)
205  *m_log << MSG::INFO << "m_msgid = " << m_msgid << endmsg;
206  }
207 
208  // fork receiver
209  if ((m_ipcmat_pid = fork()) < 0) {
210  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " key: " << key
211  << " Error number is " << errno << endmsg;
212  return StatusCode::FAILURE;
213  }
214  if (m_log->level()>=MSG::INFO)
215  *m_log << MSG::INFO << "ipcmat_pid = " << m_ipcmat_pid << endmsg;
216 
217  if (m_ipcmat_pid == 0)
218  {
219  // ipcmatr compiled in 64 bits using same struct for message queue
220  // as declared in IPCMat.h. Must be in PATH
221  if (execlp("ipcmatr", "", NULL) < 0)
222  {
223  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " key: " << key
224  << " Error number is " << errno << endmsg;
225  return StatusCode::FAILURE;
226  }
227  }
228 
229  // let the children start
230  sleep(1);
231 
232  return StatusCode::SUCCESS;
233 }

◆ name()

const std::string & Trk::IPCMat::name ( ) const
private

Definition at line 32 of file IPCMat.cxx.

32  {
33  return m_name;
34 }

◆ operator=()

IPCMat& Trk::IPCMat::operator= ( const IPCMat )
delete

◆ removeAlignPar()

StatusCode Trk::IPCMat::removeAlignPar ( int  alpar)

Definition at line 159 of file IPCMat.cxx.

159  {
160  //MsgStream log(m_msgSvc,name());
161 
163  m_ipcmat_msgp.data.n = alpar;
164 
165  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
166  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
167  << " Error number is " << errno << endmsg;
168  return StatusCode::FAILURE;
169  }
170 
171  return StatusCode::SUCCESS;
172 }

◆ removeModule()

StatusCode Trk::IPCMat::removeModule ( int  mod)

Definition at line 141 of file IPCMat.cxx.

141  {
142  //MsgStream log(m_msgSvc,name());
143 
146 
147  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
148  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
149  << " Error number is " << errno << endmsg;
150  return StatusCode::FAILURE;
151  }
152 
153  return StatusCode::SUCCESS;
154 }

◆ reSize()

StatusCode Trk::IPCMat::reSize ( int  newsize)

Definition at line 122 of file IPCMat.cxx.

122  {
123  //MsgStream log(m_msgSvc,name());
124  if (m_log->level()>=MSG::INFO)
125  *m_log << MSG::INFO << "in ipcmat_resize" << endmsg;
126 
128  m_ipcmat_msgp.data.n = newsize;
129 
130  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
131  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " Error number is " << errno << endmsg;
132  return StatusCode::FAILURE;
133  }
134 
135  return StatusCode::SUCCESS;
136 }

◆ scaleMat()

StatusCode Trk::IPCMat::scaleMat ( int  scale)

Definition at line 83 of file IPCMat.cxx.

83  {
84  //MsgStream log(m_msgSvc,name());
85  if (m_log->level()>=MSG::INFO)
86  *m_log << MSG::INFO << "in ipcmat_scaleMat with scale=" << scale << endmsg;
87 
90 
91  if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+sizeof(double),0)<0) {
92  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
93  << " Error number is " << errno << endmsg;
94  return StatusCode::FAILURE;
95  }
96 
97  return StatusCode::SUCCESS;
98 }

◆ scaleVec()

StatusCode Trk::IPCMat::scaleVec ( int  scale)

Definition at line 103 of file IPCMat.cxx.

103  {
104  //MsgStream log(m_msgSvc,name());
105  if (m_log->level()>=MSG::INFO)
106  *m_log << MSG::INFO << "in ipcmat_scaleVec with scale=" << scale << endmsg;
107 
110 
111  if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+sizeof(double),0)<0) {
112  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " Error number is " << errno << endmsg;
113  return StatusCode::FAILURE;
114  }
115 
116  return StatusCode::SUCCESS;
117 }

◆ setScale()

StatusCode Trk::IPCMat::setScale ( int  scale)

Definition at line 260 of file IPCMat.cxx.

260  {
261  //MsgStream log(m_msgSvc,name());
262  if (m_log->level()>=MSG::INFO)
263  *m_log << MSG::INFO << "setting m_scale to : " << scale << endmsg;
264 
267 
268  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
269  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
270  << " Error number is " << errno << endmsg;
271  return StatusCode::FAILURE;
272  }
273 
274  return StatusCode::SUCCESS;
275 }

◆ setVersion()

StatusCode Trk::IPCMat::setVersion ( float  version,
bool  isMatrix 
)

Definition at line 280 of file IPCMat.cxx.

280  {
281  //MsgStream log(m_msgSvc,name());
282 
285 
286  std::string mType = isMatrix ? "MatVersion" : "VecVersion";
287  if (m_log->level()>=MSG::INFO)
288  *m_log << MSG::INFO << "setting " << mType << " to = " << version << endmsg;
289 
290 
291  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
292  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
293  << " Error number is " << errno << endmsg;
294  return StatusCode::FAILURE;
295  }
296 
297  return StatusCode::SUCCESS;
298 }

◆ summary()

void Trk::IPCMat::summary ( )

Definition at line 342 of file IPCMat.cxx.

342  {
343  //MsgStream log(m_msgSvc,name());
344 
345  if (m_log->level()>=MSG::INFO) {
346  *m_log << MSG::INFO << "++++++++++++++++++++++++++++++++++++++++" << endmsg;
347  *m_log << MSG::INFO << " Total calls = " << m_ncalls << endmsg;
348  *m_log << MSG::INFO << "++++++++++++++++++++++++++++++++++++++++" << endmsg;
349  }
350 }

◆ write()

StatusCode Trk::IPCMat::write ( const std::string &  ipcname,
bool  isMatrix 
)

Definition at line 303 of file IPCMat.cxx.

303  {
304  //MsgStream log(m_msgSvc,name());
305  if (m_log->level()>=MSG::INFO)
306  *m_log << MSG::INFO << "Writting ipcmat. Selected name is : " << ipcname
307  << endmsg;
308 
309  m_ipcmat_msgp.mtype = isMatrix ? M_WRITE_M : M_WRITE_V;
310  strncpy(m_ipcmat_msgp.data.fname, ipcname.c_str(), sizeof(m_ipcmat_msgp.data.fname)-1);
311  m_ipcmat_msgp.data.fname[sizeof(m_ipcmat_msgp.data.fname) - 1] = '\0';
312 
313  if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(m_ipcmat_msgp)-sizeof(long), IPC_NOWAIT) < 0) {
314  *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
315  << " Error number is " << errno << endmsg;
316  return StatusCode::FAILURE;
317  }
318  return StatusCode::SUCCESS;
319 }

Member Data Documentation

◆ m_ipcmat_msgp

struct Trk::IPCMat::MsgBuf Trk::IPCMat::m_ipcmat_msgp
private

◆ m_ipcmat_pid

pid_t Trk::IPCMat::m_ipcmat_pid {}
private

Definition at line 74 of file IPCMat.h.

◆ m_log

MsgStream* Trk::IPCMat::m_log {}
private

Definition at line 73 of file IPCMat.h.

◆ m_msgid

int Trk::IPCMat::m_msgid {}
private

Definition at line 71 of file IPCMat.h.

◆ m_msgSvc

IMessageSvc* Trk::IPCMat::m_msgSvc {}
private

Definition at line 69 of file IPCMat.h.

◆ m_name

std::string Trk::IPCMat::m_name
private

Definition at line 72 of file IPCMat.h.

◆ m_ncalls

int Trk::IPCMat::m_ncalls {}
private

Definition at line 70 of file IPCMat.h.


The documentation for this class was generated from the following files:
M_SCALE_M
#define M_SCALE_M
Definition: IPCMat.h:20
Trk::IPCMat::m_msgSvc
IMessageSvc * m_msgSvc
Definition: IPCMat.h:69
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
M_REMOVE_PAR
#define M_REMOVE_PAR
Definition: IPCMat.h:26
Trk::IPCMat::MsgBuf::fname
char fname[100]
Definition: IPCMat.h:81
M_INCR_M
#define M_INCR_M
Definition: IPCMat.h:18
Trk::IPCMat::MsgBuf::scale
double scale
Definition: IPCMat.h:83
M_WRITE_V
#define M_WRITE_V
Definition: IPCMat.h:23
Trk::IPCMat::m_log
MsgStream * m_log
Definition: IPCMat.h:73
M_SETVERSION
#define M_SETVERSION
Definition: IPCMat.h:28
M_REMOVE_MOD
#define M_REMOVE_MOD
Definition: IPCMat.h:25
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Trk::IPCMat::m_ipcmat_msgp
struct Trk::IPCMat::MsgBuf m_ipcmat_msgp
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trk::IPCMat::MsgBuf::n
uint32_t n
Definition: IPCMat.h:82
Trk::IPCMat::m_ncalls
int m_ncalls
Definition: IPCMat.h:70
M_INCR_V
#define M_INCR_V
Definition: IPCMat.h:19
Trk::IPCMat::MsgBuf::matrix
struct Trk::IPCMat::MsgBuf::@229::@230 matrix
Trk::IPCMat::MsgBuf::data
union Trk::IPCMat::MsgBuf::@229 data
Trk::IPCMat::m_ipcmat_pid
pid_t m_ipcmat_pid
Definition: IPCMat.h:74
M_SCALE_V
#define M_SCALE_V
Definition: IPCMat.h:21
Trk::IPCMat::m_name
std::string m_name
Definition: IPCMat.h:72
Trk::IPCMat::MsgBuf::mtype
long mtype
Definition: IPCMat.h:77
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
M_RESIZE
#define M_RESIZE
Definition: IPCMat.h:24
M_WRITE_M
#define M_WRITE_M
Definition: IPCMat.h:22
get_generator_info.version
version
Definition: get_generator_info.py:33
a
TList * a
Definition: liststreamerinfos.cxx:10
M_ALLOCATE
#define M_ALLOCATE
Definition: IPCMat.h:17
DEBUG
#define DEBUG
Definition: page_access.h:11
M_SETSCALE
#define M_SETSCALE
Definition: IPCMat.h:27
Trk::IPCMat::name
const std::string & name() const
Definition: IPCMat.cxx:32
M_END
#define M_END
Definition: IPCMat.h:29
python.compressB64.c
def c
Definition: compressB64.py:93
Trk::IPCMat::m_msgid
int m_msgid
Definition: IPCMat.h:71
Trk::IPCMat::MsgBuf::version
float version
Definition: IPCMat.h:84
python.logger.BLUE
BLUE
Definition: DataQuality/DQUtils/python/logger.py:15
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37