Class Reference for E1039 Core & Analysis Software
KJob.cc
Go to the documentation of this file.
1
#include <iostream>
2
#include <algorithm>
3
#include <cmath>
4
#include <ktracker/SRawEvent.h>
5
#include <ktracker/SRecEvent.h>
6
#include "
KScheduler.h
"
7
#include "
KJob.h
"
8
9
int
KJob::verb = 0;
10
11
// primary instantiator...
12
// evPtr is pointer to copy of event that doesn't get clobbered on get entry
13
KJob::KJob
(
int
jobId,
SRawEvent
* evPtr,
KScheduler
* universe,
bool
copy)
14
: jobId(jobId)
15
, universe(universe)
16
{
17
if
(
Verbose
() > 0)
18
TThread::Printf(
"starting KJOB: %i\n"
,
jobId
);
19
20
jobMutex
=
new
TMutex();
21
// make some big memory allocations...
22
// check them... somehow....
23
// need DEEP copy because event is clobbered by GetEntries
24
// src - dest
25
if
(copy){
26
evData
=
new
SRawEvent
(*evPtr);
27
}
28
// 1039 i produce new upstream
29
else
{
30
evData
= evPtr;
31
}
32
recEvData
=
new
SRecEvent
();
33
assert(
evData
);
34
if
(!
evData
){
35
std::cout <<
"failed to allocate memory for SRawEvent... smaller INPUT_PIPE_DEPTH?\n"
;
36
}
37
p_JobStatus
=
STARTED
;
38
jobTimer
=
new
TStopwatch();
39
isPoison
=
false
;
40
41
// get an available, clean TClonesArr
42
universe
->
ktrkqFSem
->Wait();
43
universe
->
ktrkQueueMutex
->Lock();
44
tracklets
=
universe
->
kTrackArrQueue
.front();
45
universe
->
kTrackArrQueue
.pop();
46
universe
->
ktrkQueueMutex
->UnLock();
47
universe
->
ktrkqESem
->Post();
48
nTracklets
= 0;
49
50
return
;
51
};
52
53
54
// poisoned jobs to kill downstream threads
55
KJob::KJob
(
bool
poisoned)
56
{
57
assert(poisoned &&
"shouldn't call this if not poisoned..."
);
58
isPoison
= poisoned;
59
return
;
60
}
61
62
// failing to initialize everything in poison pill was causing crashouts
63
KJob::~KJob
()
64
{
65
if
(
isPoison
)
66
return
;
67
68
delete
jobMutex
;
69
delete
evData
;
70
delete
recEvData
;
71
//p_jobStatus
72
if
(
Verbose
() > 0){
73
TThread::Printf(
"Kjob: %i completed in time:\n"
,
jobId
);
74
jobTimer
->Print(
"u"
);
75
}
76
delete
jobTimer
;
77
// clear and yield tracklet array
78
// TODO check if "C" needed in arg for tracklets
79
tracklets
->Clear();
80
universe
->
ktrkqESem
->Wait();
81
universe
->
ktrkQueueMutex
->Lock();
82
universe
->
kTrackArrQueue
.push(
tracklets
);
83
universe
->
ktrkQueueMutex
->UnLock();
84
universe
->
ktrkqFSem
->Post();
85
return
;
86
};
KJob.h
STARTED
@ STARTED
Definition:
KJob.h:18
KScheduler.h
KJob::p_JobStatus
KJobStatus p_JobStatus
Definition:
KJob.h:47
KJob::jobId
int jobId
Definition:
KJob.h:34
KJob::tracklets
TClonesArray * tracklets
Definition:
KJob.h:44
KJob::KJob
KJob(int jobId, SRawEvent *evPtr, KScheduler *universe, bool copy)
Definition:
KJob.cc:13
KJob::nTracklets
int nTracklets
Definition:
KJob.h:36
KJob::isPoison
bool isPoison
Definition:
KJob.h:37
KJob::jobTimer
TStopwatch * jobTimer
Definition:
KJob.h:40
KJob::Verbose
static int Verbose()
Definition:
KJob.h:30
KJob::evData
SRawEvent * evData
Definition:
KJob.h:41
KJob::recEvData
SRecEvent * recEvData
Definition:
KJob.h:46
KJob::universe
KScheduler * universe
Definition:
KJob.h:35
KJob::~KJob
~KJob()
Definition:
KJob.cc:63
KJob::jobMutex
TMutex * jobMutex
Definition:
KJob.h:39
KScheduler
Definition:
KScheduler.h:39
KScheduler::ktrkqESem
TSemaphore * ktrkqESem
Definition:
KScheduler.h:95
KScheduler::ktrkQueueMutex
TMutex * ktrkQueueMutex
Definition:
KScheduler.h:91
KScheduler::kTrackArrQueue
std::queue< TClonesArray * > kTrackArrQueue
Definition:
KScheduler.h:98
KScheduler::ktrkqFSem
TSemaphore * ktrkqFSem
Definition:
KScheduler.h:94
SRawEvent
Definition:
SRawEvent.h:97
SRecEvent
Definition:
SRecEvent.h:413
e1039-analysis
MultiThreadReco
src
KJob.cc
Built by
Haiwang Yu
. updated:
Thu Jan 30 2025 10:15:15
using
1.9.1 with
SeaQuest GitHub integration