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
9935e416
Commit
9935e416
authored
Aug 25, 2016
by
Daniel Hynds
Browse files
Added new class for clicpix event loading with Timepix3 telescope
Former-commit-id: f3697851612dba0d551d48e068b1a42e32bcc0bd
parent
454d0031
Changes
2
Hide whitespace changes
Inline
Side-by-side
branches/trunk/algorithms/CLICpixEventLoader.C
0 → 100644
View file @
9935e416
#include "CLICpixEventLoader.h"
CLICpixEventLoader
::
CLICpixEventLoader
(
bool
debugging
)
:
Algorithm
(
"CLICpixEventLoader"
){
debug
=
debugging
;
m_filename
=
""
;
}
void
CLICpixEventLoader
::
initialise
(
Parameters
*
par
){
parameters
=
par
;
// File structure is RunX/CLICpix/RunX.dat
// Take input directory from global parameters
string
inputDirectory
=
parameters
->
inputDirectory
+
"/CLICpix"
;
// Open the root directory
DIR
*
directory
=
opendir
(
inputDirectory
.
c_str
());
if
(
directory
==
NULL
){
tcout
<<
"Directory "
<<
inputDirectory
<<
" does not exist"
<<
endl
;
return
;}
dirent
*
entry
;
dirent
*
file
;
// Read the entries in the folder
while
(
entry
=
readdir
(
directory
)){
// Check for the data file
string
filename
=
inputDirectory
+
"/"
+
entry
->
d_name
;
if
(
filename
.
find
(
".dat"
)
!=
string
::
npos
){
m_filename
=
filename
;
}
}
// If no data was loaded, give a warning
if
(
m_filename
.
length
()
==
0
)
tcout
<<
"Warning: no data file was found for CLICpix in "
<<
inputDirectory
<<
endl
;
// Open the data file for later
m_file
.
open
(
m_filename
.
c_str
());
}
StatusCode
CLICpixEventLoader
::
run
(
Clipboard
*
clipboard
){
// Assume that the CLICpix is the DUT (if running this algorithm
string
detectorID
=
parameters
->
DUT
;
// If have reached the end of file, close it and exit program running
if
(
m_file
.
eof
()){
m_file
.
close
();
return
Failure
;
}
// Otherwise load a new frame
// Pixel container, shutter information
Pixels
*
pixels
;
long
double
shutterStartTime
,
shutterStopTime
;
string
data
;
// Read file and load data
while
(
getline
(
m_file
,
data
)){
// If line is empty then we have finished this event, stop looping
if
(
data
.
length
()
==
0
)
break
;
// Check if this is a header/shutter/power info
if
(
data
.
find
(
"PWR_RISE"
)
!=
string
::
npos
||
data
.
find
(
"PWR_FALL"
)
!=
string
::
npos
)
continue
;
if
(
data
.
find
(
"SHT_RISE"
)
!=
string
::
npos
){
// Read the shutter start time
long
int
timeInt
;
string
name
;
istringstream
header
(
data
);
header
>>
name
>>
timeInt
;
shutterStartTime
=
(
double
)
timeInt
/
(
4096
.
*
40000000
.);
continue
;
}
if
(
data
.
find
(
"SHT_FALL"
)
!=
string
::
npos
){
// Read the shutter stop time
long
int
timeInt
;
string
name
;
istringstream
header
(
data
);
header
>>
name
>>
timeInt
;
shutterStopTime
=
(
double
)
timeInt
/
(
4096
.
*
40000000
.);
continue
;
}
// Otherwise load data
int
row
,
col
,
tot
;
long
int
time
;
istringstream
pixelData
(
data
);
pixelData
>>
col
>>
row
>>
tot
;
Pixel
*
pixel
=
new
Pixel
(
detectorID
,
row
,
col
,
tot
);
pixels
->
push_back
(
pixel
);
}
// Now set the event time so that the Timepix3 data is loaded correctly
parameters
->
currentTime
=
shutterStartTime
;
parameters
->
eventLength
=
(
shutterStopTime
-
shutterStartTime
);
// Put the data on the clipboard
clipboard
->
put
(
detectorID
,
"pixels"
,(
TestBeamObjects
*
)
pixels
);
// Return value telling analysis to keep running
return
Success
;
}
void
CLICpixEventLoader
::
finalise
(){
if
(
debug
)
tcout
<<
"Analysed "
<<
m_eventNumber
<<
" events"
<<
endl
;
}
branches/trunk/algorithms/CLICpixEventLoader.h
0 → 100644
View file @
9935e416
#ifndef CLICpixEventLoader_H
#define CLICpixEventLoader_H 1
#include "Algorithm.h"
#include <iostream>
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "Pixel.h"
#include "Cluster.h"
#include "Track.h"
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <dirent.h>
class
CLICpixEventLoader
:
public
Algorithm
{
public:
// Constructors and destructors
CLICpixEventLoader
(
bool
);
~
CLICpixEventLoader
(){}
// Functions
void
initialise
(
Parameters
*
);
StatusCode
run
(
Clipboard
*
);
void
finalise
();
// Member variables
int
m_eventNumber
;
string
m_filename
;
ifstream
m_file
;
};
#endif // CLICpixEventLoader_H
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