![]() |
GWOLLUM 4.2.0
Tools for gravitational-wave analyses
|
Manage time segment lists. More...
#include <Segments.h>
Public Member Functions | |
bool | AddSegment (const double aGpsStart, const double aGpsEnd, const int aTag=1) |
Adds a segment to the list. | |
bool | AddSegments (Segments *aSeg) |
Adds a segment list to the list. | |
bool | Append (const double aGpsStart, const double aGpsEnd, const int aTag=1) |
Appends a segment to the list. | |
bool | Append (Segments *aSeg) |
Appends segments to the list. | |
bool | Append (TTree *aSegmentTree) |
Appends segments to the list. | |
bool | Append (vector< double > aGpsStarts, vector< double > aGpsEnds, vector< double > aTags) |
Appends segments to the list. | |
bool | ApplyPadding (const double aPadStart, const double aPadEnd) |
Apply a padding to all segments. | |
void | Dump (unsigned int aNcols=2, const string aTxtFileName="") |
Dumps the current segment list in the standard output or in a file. | |
double | GetDuration (const unsigned int aSegmentIndex=0) |
Returns the duration of a given segment. | |
double | GetEnd (const unsigned int aSegmentIndex=0) |
Returns the ending time of a given segment. | |
vector< double > | GetEnds (void) |
Returns the list of segment ends. | |
double | GetFirst () |
Returns the starting time of the first segment. | |
TH1I * | GetHisto (const double aOffset=0.0) |
Returns an histogram representing the segments. | |
TH1I * | GetHistogram (const double aGpsStart, const double aGpsEnd, const double aOffset=0.0) |
Returns an histogram representing the segments. | |
double | GetLast () |
Returns the ending time of the last segment. | |
double | GetLiveTime (const double aGpsStart, const double aGpsEnd) |
Returns the livetime between two GPS times. | |
double | GetLiveTime (const unsigned int aSegmentIndex) |
Returns the livetime of one segment. | |
double | GetLiveTime (void) |
Returns the total livetime. | |
double | GetLiveTimeWithTag (const int aTag) |
Returns the livetime for segments with a given tag. | |
unsigned int | GetN (void) |
Returns the number of time segments in the list. | |
unsigned int | GetNWithTag (const int aTag) |
Returns the number of time segments in the list with a given tag. | |
int | GetSegmentStartBefore (const double aGps) |
Returns the segment starting just before a given GPS time. | |
double | GetStart (const unsigned int aSegmentIndex=0) |
Returns the starting time of a given segment. | |
vector< double > | GetStarts (void) |
Returns the list of segment starts. | |
bool | GetStatus (void) |
Returns the class status. | |
int | GetTag (const unsigned int aSegmentIndex=0) |
Returns the tag of a given segment. | |
vector< int > | GetTags (void) |
Returns the list of segment tags. | |
TTree * | GetTree (const double aGpsStart, const double aGpsEnd) |
Returns a formatted TTree representing the segments. | |
TTree * | GetTree (void) |
Returns a formatted TTree representing the segments. | |
bool | Intersect (const double aGpsStart, const double aGpsEnd, const int aTag=1) |
Intersects with a segment. | |
bool | Intersect (Segments *aSeg) |
Intersects with a segment list. | |
bool | IsInsideSegment (const double aGps) |
Checks whether a given GPS time is inside a segment of the list. | |
bool | IsInsideSegment (unsigned int &aSegmentIndex, const double aGps) |
Checks whether a given GPS time is inside a segment of the list. | |
bool | MakeSecond (void) |
Rounds segment boundaries to integer seconds. | |
void | Reset (void) |
Resets the segment list. | |
bool | Reverse (void) |
Reverses the segment list. | |
void | SetTag (const unsigned int aSegmentIndex, const int aTag) |
Tags a given segment. | |
void | SetTags (const int aTag) |
Tags all segments. | |
bool | TruncateAfter (const double aGps) |
Removes segments after a given time. | |
bool | TruncateBefore (const double aGps) |
Removes segments before a given time. | |
Constructors and destructors | |
Segments (void) | |
Default constructor of the Segments class. | |
Segments (const string aSegmentFile, const int aDefaultTag=1) | |
Constructor of the Segments class. | |
Segments (TTree *aSegmentTree) | |
Constructor of the Segments class. | |
Segments (const string aFilePattern, const string aDirectory, const string aTreeName) | |
Constructor of the Segments class. | |
Segments (const vector< double > aGpsStarts, const vector< double > aGpsEnds) | |
Constructor of the Segments class. | |
Segments (const double aGpsStart, const double aGpsEnd, const int aTag=1) | |
Constructor of the Segments class. | |
virtual | ~Segments (void) |
Destructor of the Segments class. | |
Private Member Functions | |
bool | CheckConsistency (const unsigned int aStartIndex) |
Checks the sanity of the segment list. | |
void | ComputeLiveTime (void) |
Computes the sgments livetime. | |
int | GetMark (const unsigned int aGps) |
Returns the time mark for a given GPS time. | |
int | GetTagProduct (const int aTag1, const int aTag2) |
Computes the product of 2 tags. | |
void | MergeOverlaps (const unsigned int aStartIndex) |
Merges segment overlaps. | |
void | SetMarks (void) |
Sets time marks for internal lookup. | |
Private Attributes | |
Monitor * | mon |
Class monitor. | |
vector< unsigned int > | n_mark |
Segment index marks. | |
vector< double > | seg_end |
List of segment ends. | |
double | seg_livetime |
Integrated livetime. | |
vector< double > | seg_start |
List of segment starts. | |
vector< int > | seg_tag |
List of segment tags. | |
vector< unsigned int > | time_mark |
Time marks. | |
Manage time segment lists.
Every gravitational-wave analysis has to deal with segment lists at some point. This class is designed to manage segment lists in an easy way.
A segment is a time interval limited by 2 GPS times: [GPS_START]
(included) and [GPS_END]
(excluded). A segment list must respect the rules documented in CheckConsistency()
Segments can be individually tagged by an signed integer [TAG]
.
This class offers methods to transform segment lists: new segments, intersection, padding, truncation...
Segments::Segments | ( | void | ) |
Default constructor of the Segments class.
An empty segment list is initialized.
Segments::Segments | ( | const string | aSegmentFile, |
const int | aDefaultTag = 1 |
||
) |
Constructor of the Segments class.
The original segment list is downloaded from a text file. Several formats are supported to extract the segments and the tags:
[GPS_START]
[GPS_END]
. In this case the segment tags are initialized to the default value.[GPS_START]
, (third column)=[GPS_END]
. In this case the segment tags are initialized to the default value.[GPS_START]
, (third column)=[GPS_END]
, (fifth column)=[TAG]
.[in] | aSegmentFile | Path to the segment text file. |
[in] | aDefaultTag | Default tag value aaplied to the segments when the number of columns is less than 5. |
Segments::Segments | ( | TTree * | aSegmentTree | ) |
Constructor of the Segments class.
The original segment list is downloaded from a TTree. 3 branches must be found: start/D
, end/D
, and tag/I
.
[in] | aSegmentTree | Pointer to the segment TTree structure. |
Segments::Segments | ( | const string | aFilePattern, |
const string | aDirectory, | ||
const string | aTreeName | ||
) |
Constructor of the Segments class.
The original segment list is downloaded from a TTree in a list of ROOT files. 3 branches must be found: start/D
, end/D
, and tag/I
.
[in] | aFilePattern | Input file pattern. |
[in] | aDirectory | ROOT sub-directory. Use "" if none. |
[in] | aTreeName | Segment tree name. |
Segments::Segments | ( | const vector< double > | aGpsStarts, |
const vector< double > | aGpsEnds | ||
) |
Constructor of the Segments class.
The original segment list is downloaded from vectors.
[in] | aGpsStarts | Vector of GPS starts. |
[in] | aGpsEnds | Vector of GPS ends. |
Segments::Segments | ( | const double | aGpsStart, |
const double | aGpsEnd, | ||
const int | aTag = 1 |
||
) |
Constructor of the Segments class.
The original segment list contains one single segment.
[in] | aGpsStart | Segment GPS start. |
[in] | aGpsEnd | Segment GPS end. |
[in] | aTag | Segment tag. |
|
virtual |
Destructor of the Segments class.
bool Segments::AddSegment | ( | const double | aGpsStart, |
const double | aGpsEnd, | ||
const int | aTag = 1 |
||
) |
Adds a segment to the list.
The Segments object is automatically re-organized to remove overlaps.
[in] | aGpsStart | Segment GPS start. |
[in] | aGpsEnd | Segment GPS end. |
[in] | aTag | Segment tag. |
bool Segments::AddSegments | ( | Segments * | aSeg | ) |
Adds a segment list to the list.
The Segments object is automatically re-organized to remove overlaps.
[in] | aSeg | Segment list to add. |
bool Segments::Append | ( | const double | aGpsStart, |
const double | aGpsEnd, | ||
const int | aTag = 1 |
||
) |
Appends a segment to the list.
This function appends a time segment at the end of the current Segments object. It only works if the new segment starts after the last segment start (an overlap is possible).
[in] | aGpsStart | Segment GPS start. |
[in] | aGpsEnd | Segment GPS end. |
[in] | aTag | Segment tag. |
bool Segments::Append | ( | Segments * | aSeg | ) |
Appends segments to the list.
This function appends a list of segments at the end of the current Segments object. It only works if the first segment starts after the last segment start (an overlap is possible).
[in] | aSeg | Segment list to append. |
bool Segments::Append | ( | TTree * | aSegmentTree | ) |
Appends segments to the list.
The Segments object is automatically re-organized to remove overlaps.
start/D
, end/D
, and tag/I
. [in] | aSegmentTree | Segment tree with 3 branches: "start", "end", and "tag". |
bool Segments::Append | ( | vector< double > | aGpsStarts, |
vector< double > | aGpsEnds, | ||
vector< double > | aTags | ||
) |
Appends segments to the list.
This function appends a list of segments at the end of the current Segments object. It only works if the first segment starts after the last segment start (an overlap is possible).
[in] | aGpsStarts | Segment GPS starts. |
[in] | aGpsEnds | Segment GPS ends. |
[in] | aTags | Segment tags. |
bool Segments::ApplyPadding | ( | const double | aPadStart, |
const double | aPadEnd | ||
) |
Apply a padding to all segments.
This function shifts the segment start and end by a given padding value. The Segments object is automatically re-organized to remove overlaps. Some segments are removed if the duration becomes null or negative.
[in] | aPadStart | Padding value added to the segment starts. |
[in] | aPadEnd | Padding value added to the segment ends. |
|
private |
Checks the sanity of the segment list.
List of checks:
[GPS_START]
.[in] | aStartIndex | Segment index where to start the checks. |
|
private |
Computes the sgments livetime.
void Segments::Dump | ( | unsigned int | aNcols = 2 , |
const string | aTxtFileName = "" |
||
) |
Dumps the current segment list in the standard output or in a file.
Several formats are possible:
[in] | aNcols | number of columns in the output. |
[in] | aTxtFileName | Text file name. Use "" for the standard output. |
|
inline |
Returns the duration of a given segment.
[in] | aSegmentIndex | Segment index. |
|
inline |
Returns the ending time of a given segment.
[in] | aSegmentIndex | Segment index. |
|
inline |
Returns the list of segment ends.
|
inline |
Returns the starting time of the first segment.
|
inline |
Returns an histogram representing the segments.
The GPS time is represented on the X axis:
[in] | aOffset | Time offset applied to GPS times. |
TH1I * Segments::GetHistogram | ( | const double | aGpsStart, |
const double | aGpsEnd, | ||
const double | aOffset = 0.0 |
||
) |
Returns an histogram representing the segments.
Only segments between 'aGpsStart' and 'aGpsEnd' are represented. The GPS time is represented on the X axis:
[in] | aGpsStart | Starting GPS time of the histogram. |
[in] | aGpsEnd | Ending GPS time of the histogram. |
[in] | aOffset | Time offset applied to GPS times. |
|
inline |
Returns the ending time of the last segment.
double Segments::GetLiveTime | ( | const double | aGpsStart, |
const double | aGpsEnd | ||
) |
Returns the livetime between two GPS times.
[in] | aGpsStart | Starting GPS time. |
[in] | aGpsEnd | Ending GPS time. |
|
inline |
Returns the livetime of one segment.
[in] | aSegmentIndex | Segment index. |
|
inline |
Returns the total livetime.
Every segments in the list are considered.
double Segments::GetLiveTimeWithTag | ( | const int | aTag | ) |
Returns the livetime for segments with a given tag.
[in] | aTag | Tag value of segments to consider. |
|
private |
Returns the time mark for a given GPS time.
[in] | aGps | GPS time of interest. |
|
inline |
Returns the number of time segments in the list.
unsigned int Segments::GetNWithTag | ( | const int | aTag | ) |
Returns the number of time segments in the list with a given tag.
[in] | aTag | Tag value of segments to consider. |
int Segments::GetSegmentStartBefore | ( | const double | aGps | ) |
Returns the segment starting just before a given GPS time.
[in] | aGps | GPS time of interest |
|
inline |
Returns the starting time of a given segment.
[in] | aSegmentIndex | Segment index. |
|
inline |
Returns the list of segment starts.
|
inline |
Returns the class status.
|
inline |
Returns the tag of a given segment.
[in] | aSegmentIndex | Segment index. |
|
inlineprivate |
Computes the product of 2 tags.
[in] | aTag1 | First tag. |
[in] | aTag2 | Second tag. |
|
inline |
Returns the list of segment tags.
TTree * Segments::GetTree | ( | const double | aGpsStart, |
const double | aGpsEnd | ||
) |
Returns a formatted TTree representing the segments.
This tree has 3 branches: "start", "end", and "tag". Only segments between 'aGpsStart' and 'aGpsEnd' are copied in the tree.
[in] | aGpsStart | Starting GPS time. |
[in] | aGpsEnd | Ending GPS time. |
|
inline |
Returns a formatted TTree representing the segments.
This tree has 3 branches: "start", "end", and "tag".
bool Segments::Intersect | ( | const double | aGpsStart, |
const double | aGpsEnd, | ||
const int | aTag = 1 |
||
) |
Intersects with a segment.
This function intersects the current segment list with a segment given in argument.
[in] | aGpsStart | Segment GPS start. |
[in] | aGpsEnd | Segment GPS end. |
[in] | aTag | Segment tag. |
bool Segments::Intersect | ( | Segments * | aSeg | ) |
Intersects with a segment list.
This function intersects the current segment list with a second segment list given in argument.
[in] | aSeg | External Segments objects (not modified) |
bool Segments::IsInsideSegment | ( | const double | aGps | ) |
Checks whether a given GPS time is inside a segment of the list.
[in] | aGps | GPS time of interest. |
bool Segments::IsInsideSegment | ( | unsigned int & | aSegmentIndex, |
const double | aGps | ||
) |
Checks whether a given GPS time is inside a segment of the list.
[out] | aSegmentIndex | Segment index of segment containing the GPS time. This is irrelevant if false is returned. |
[in] | aGps | GPS time of interest. |
bool Segments::MakeSecond | ( | void | ) |
|
private |
Merges segment overlaps.
When merging 2 segments, the tag with the highest value is kept.
[in] | aStartIndex | Segment index where to start the merge. |
void Segments::Reset | ( | void | ) |
Resets the segment list.
As a result, the segment list is empty and the status is back to OK.
bool Segments::Reverse | ( | void | ) |
Reverses the segment list.
It means that the gaps between segments are now considered as segments. The first segment starts at :: SEGMENTS_START. The last segment ends at :: SEGMENTS_END.
|
private |
Sets time marks for internal lookup.
|
inline |
Tags a given segment.
[in] | aSegmentIndex | Segment index. |
[in] | aTag | New tag value. |
void Segments::SetTags | ( | const int | aTag | ) |
Tags all segments.
[in] | aTag | New tag value. |
bool Segments::TruncateAfter | ( | const double | aGps | ) |
Removes segments after a given time.
[in] | aGps | GPS time after which to truncate. |
bool Segments::TruncateBefore | ( | const double | aGps | ) |
Removes segments before a given time.
[in] | aGps | GPS time before which to truncate. |
|
private |
Class monitor.
|
private |
Segment index marks.
|
private |
List of segment ends.
|
private |
Integrated livetime.
|
private |
List of segment starts.
|
private |
List of segment tags.
|
private |
Time marks.