Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Corryvreckan
Corryvreckan
Commits
11bb4103
Commit
11bb4103
authored
Oct 11, 2017
by
Simon Spannagel
Browse files
Timepix3EventLoader: use the provided detector list
parent
ef41e12d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/algorithms/Timepix3EventLoader.cpp
View file @
11bb4103
...
...
@@ -58,20 +58,25 @@ void Timepix3EventLoader::initialise(Parameters* par) {
DIR
*
dataDir
=
opendir
(
dataDirName
.
c_str
());
string
trimdacfile
;
// Check if this device is to be masked
if
(
parameters
->
masked
.
count
(
detectorID
)
!=
0
)
{
LOG
(
DEBUG
)
<<
"Device with detector ID "
<<
entry
->
d_name
<<
" is masked."
;
// Check if this device has conditions loaded and is a Timepix3
auto
it
=
find_if
(
m_detectors
.
begin
(),
m_detectors
.
end
(),
[
&
detectorID
](
Detector
*
obj
)
{
return
obj
->
name
()
==
detectorID
;
});
if
(
it
==
m_detectors
.
end
())
{
LOG
(
DEBUG
)
<<
"Device with detector ID "
<<
entry
->
d_name
<<
" is not registered."
;
continue
;
}
// Check if this device has conditions loaded and is a Timepix3
if
(
parameters
->
detector
.
count
(
detectorID
)
==
0
)
{
LOG
(
DEBUG
)
<<
"Device with detector ID "
<<
entry
->
d_name
<<
" does not have conditions loaded."
;
Detector
*
detector
=
*
it
;
// Check if this device is to be masked
if
(
parameters
->
masked
.
count
(
detectorID
)
!=
0
)
{
LOG
(
DEBUG
)
<<
"Device with detector ID "
<<
entry
->
d_name
<<
" is masked."
;
continue
;
}
if
(
parameters
->
detector
[
detectorID
]
->
m_detectorT
ype
!=
"Timepix3"
)
{
LOG
(
DEBU
G
)
<<
"Device with detector ID "
<<
entry
->
d_name
<<
" is not of type Timepix3."
;
if
(
detector
->
t
ype
()
!=
"Timepix3"
)
{
LOG
(
WARNIN
G
)
<<
"Device with detector ID "
<<
entry
->
d_name
<<
" is not of type Timepix3."
;
continue
;
}
...
...
@@ -107,20 +112,14 @@ void Timepix3EventLoader::initialise(Parameters* par) {
if
(
m_nFiles
.
count
(
detectorID
)
>
0
)
{
LOG
(
INFO
)
<<
"Registering detector "
<<
detectorID
;
if
(
parameters
->
detector
.
count
(
detectorID
)
==
0
)
{
LOG
(
ERROR
)
<<
"Detector "
<<
detectorID
<<
" has no alignment/conditions loaded. Please check "
"that it is in the alignment file"
;
return
;
}
// parameters->registerDetector(detectorID);
// Now that we have all of the data files and mask files for this
// detector, pass the mask file to parameters
LOG
(
INFO
)
<<
"Set mask file "
<<
trimdacfile
;
parameters
->
detector
[
detectorID
]
->
setMaskFile
(
trimdacfile
);
detector
->
setMaskFile
(
trimdacfile
);
// Apply the pixel masking
maskPixels
(
detector
ID
,
trimdacfile
);
maskPixels
(
detector
,
trimdacfile
);
}
}
}
...
...
@@ -143,11 +142,11 @@ StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
int
loadedData
=
0
;
// Loop through all registered detectors
for
(
int
det
=
0
;
det
<
parameters
->
nD
etectors
;
det
++
)
{
for
(
auto
&
detector
:
m_d
etectors
)
{
// Check if they are a Timepix3
string
detectorID
=
parameters
->
detectors
[
det
]
;
if
(
parameters
->
detector
[
detectorID
]
->
type
()
!=
"Timepix3"
)
string
detectorID
=
detector
->
name
()
;
if
(
detector
->
type
()
!=
"Timepix3"
)
continue
;
if
(
parameters
->
masked
.
count
(
detectorID
))
continue
;
...
...
@@ -157,7 +156,7 @@ StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
SpidrSignals
*
spidrData
=
new
SpidrSignals
();
// Load the next chunk of data
bool
data
=
loadData
(
detector
ID
,
deviceData
,
spidrData
);
bool
data
=
loadData
(
detector
,
deviceData
,
spidrData
);
// If data was loaded then put it on the clipboard
if
(
data
)
{
...
...
@@ -169,7 +168,7 @@ StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
// Check if all devices have reached the end of file
devices
++
;
if
(
feof
(
m_currentFile
[
detectorID
]))
if
(
m_currentFile
[
detectorID
]
!=
NULL
&&
feof
(
m_currentFile
[
detectorID
]))
endOfFiles
++
;
}
...
...
@@ -191,7 +190,7 @@ StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
}
// Function to load the pixel mask file
void
Timepix3EventLoader
::
maskPixels
(
string
detector
ID
,
string
trimdacfile
)
{
void
Timepix3EventLoader
::
maskPixels
(
Detector
*
detector
,
string
trimdacfile
)
{
// Open the mask file
ifstream
trimdacs
;
...
...
@@ -207,7 +206,7 @@ void Timepix3EventLoader::maskPixels(string detectorID, string trimdacfile) {
for
(
int
row
=
0
;
row
<
256
;
row
++
)
{
trimdacs
>>
t_col
>>
t_row
>>
t_trim
>>
t_mask
>>
t_tpen
;
if
(
t_mask
)
parameters
->
detector
[
detectorID
]
->
maskChannel
(
t_col
,
t_row
);
detector
->
maskChannel
(
t_col
,
t_row
);
}
}
...
...
@@ -216,7 +215,9 @@ void Timepix3EventLoader::maskPixels(string detectorID, string trimdacfile) {
}
// Function to load data for a given device, into the relevant container
bool
Timepix3EventLoader
::
loadData
(
string
detectorID
,
Pixels
*
devicedata
,
SpidrSignals
*
spidrData
)
{
bool
Timepix3EventLoader
::
loadData
(
Detector
*
detector
,
Pixels
*
devicedata
,
SpidrSignals
*
spidrData
)
{
string
detectorID
=
detector
->
name
();
// if(detectorID == "W0019_F07") debug = true;
// if(detectorID != "W0019_F07") debug = false;
...
...
@@ -440,7 +441,7 @@ bool Timepix3EventLoader::loadData(string detectorID, Pixels* devicedata, SpidrS
const
UShort_t
row
=
(
spix
+
(
pix
&
0x3
));
// Check if this pixel is masked
if
(
parameters
->
detector
[
detectorID
]
->
masked
(
col
,
row
))
if
(
detector
->
masked
(
col
,
row
))
continue
;
// Get the rest of the data from the pixel
...
...
@@ -459,7 +460,7 @@ bool Timepix3EventLoader::loadData(string detectorID, Pixels* devicedata, SpidrS
// 40000000.);
// Add the timing offset from the coniditions file (if any)
time
+=
(
long
long
int
)(
parameters
->
detector
[
detectorID
]
->
timingOffset
()
*
4096.
*
40000000.
);
time
+=
(
long
long
int
)(
detector
->
timingOffset
()
*
4096.
*
40000000.
);
// The time from the pixels has a maximum value of ~26 seconds. We compare
// the pixel time
...
...
src/algorithms/Timepix3EventLoader.h
View file @
11bb4103
...
...
@@ -19,11 +19,10 @@ namespace corryvreckan {
StatusCode
run
(
Clipboard
*
clipboard
);
void
finalise
();
// Extra functions
bool
loadData
(
std
::
string
,
Pixels
*
,
SpidrSignals
*
);
void
maskPixels
(
std
::
string
,
std
::
string
);
private:
bool
loadData
(
Detector
*
detector
,
Pixels
*
,
SpidrSignals
*
);
void
maskPixels
(
Detector
*
,
std
::
string
);
// cofngiuration paramaters:
bool
applyTimingCut
;
double
m_timingCut
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment