GWOLLUM 4.2.0
Tools for gravitational-wave analyses
Loading...
Searching...
No Matches
Segments.h
Go to the documentation of this file.
1
6#ifndef __Segments__
7#define __Segments__
8
9#include "ReadAscii.h"
10#include "Monitor.h"
11#include <TFile.h>
12#include <TChain.h>
13#include <TMath.h>
14#include <TH1.h>
15
16using namespace std;
17
31
32 public:
33
42 Segments(void);
43
58 Segments(const string aSegmentFile,
59 const int aDefaultTag=1);
60
68 Segments(TTree *aSegmentTree);
69
79 Segments(const string aFilePattern, const string aDirectory, const string aTreeName);
80
89 Segments(const vector<double> aGpsStarts, const vector<double> aGpsEnds);
90
98 Segments(const double aGpsStart, const double aGpsEnd, const int aTag=1);
99
103 virtual ~Segments(void);
111 inline bool GetStatus(void){ return mon->GetStatus(); };
112
117 void Reset(void);
118
124 int GetSegmentStartBefore(const double aGps);
125
129 inline unsigned int GetN(void){ return seg_start.size(); };
130
135 unsigned int GetNWithTag(const int aTag);
136
140 inline vector<double> GetStarts(void){ return seg_start; };
141
145 inline vector<double> GetEnds(void){ return seg_end; };
146
150 inline vector<int> GetTags(void){ return seg_tag; };
151
157 inline double GetStart(const unsigned int aSegmentIndex=0){ return seg_start[aSegmentIndex]; };
158
164 inline double GetEnd(const unsigned int aSegmentIndex=0){ return seg_end[aSegmentIndex]; };
165
170 inline double GetFirst(){ return GetStart(0); };
171
176 inline double GetLast(){ return GetEnd(GetN()-1); };
177
183 inline double GetDuration(const unsigned int aSegmentIndex=0){ return seg_end[aSegmentIndex]-seg_start[aSegmentIndex]; };
184
190 inline int GetTag(const unsigned int aSegmentIndex=0){ return seg_tag[aSegmentIndex]; };
191
196 inline double GetLiveTime(void){ return seg_livetime; };
197
203 double GetLiveTime(const double aGpsStart, const double aGpsEnd);
204
211 inline double GetLiveTime(const unsigned int aSegmentIndex){ return GetDuration(aSegmentIndex); };
212
217 double GetLiveTimeWithTag(const int aTag);
218
231 TH1I* GetHistogram(const double aGpsStart, const double aGpsEnd, const double aOffset=0.0);
232
242 inline TH1I* GetHisto(const double aOffset=0.0){
243 return GetHistogram(seg_start[0],seg_end[seg_start.size()-1],aOffset);
244 };
245
255 TTree* GetTree(const double aGpsStart, const double aGpsEnd);
256
263 TTree* GetTree(void){
264 if(GetN()) return GetTree(seg_start[0], seg_end[seg_start.size()-1]);
265 return GetTree(0.0, 0.0);
266 };
267
274 bool IsInsideSegment(unsigned int &aSegmentIndex, const double aGps);
275
281 bool IsInsideSegment(const double aGps);
282
289 inline void SetTag(const unsigned int aSegmentIndex, const int aTag){
290 seg_tag[aSegmentIndex] = aTag;
291 };
292
297 void SetTags(const int aTag);
298
308 bool Append(const double aGpsStart, const double aGpsEnd, const int aTag=1);
309
319 bool Append(vector <double> aGpsStarts, vector <double> aGpsEnds, vector <double> aTags);
320
328 bool Append(Segments *aSeg);
329
337 bool Append(TTree *aSegmentTree);
338
347 bool AddSegment(const double aGpsStart, const double aGpsEnd, const int aTag=1);
348
355 bool AddSegments(Segments *aSeg);
356
365 bool ApplyPadding(const double aPadStart, const double aPadEnd);
366
372 bool TruncateAfter(const double aGps);
373
379 bool TruncateBefore(const double aGps);
380
387 bool MakeSecond(void);
388
397 bool Reverse(void);
398
407 bool Intersect(Segments *aSeg);
408
419 bool Intersect(const double aGpsStart, const double aGpsEnd, const int aTag=1);
420
434 void Dump(unsigned int aNcols=2, const string aTxtFileName="");
435
436 private:
437
439 vector<double> seg_start;
440 vector<double> seg_end;
441 vector<int> seg_tag;
443 vector <unsigned int> time_mark;
444 vector <unsigned int> n_mark;
445
454 inline int GetTagProduct(const int aTag1, const int aTag2){
455 if(aTag1<0||aTag2<0) return TMath::Min(aTag1,aTag2);
456 return TMath::Max(aTag1,aTag2);
457 };
458
471 bool CheckConsistency(const unsigned int aStartIndex);
472
479 void MergeOverlaps(const unsigned int aStartIndex);
480
485 void SetMarks(void);
486
492 int GetMark(const unsigned int aGps);
493
498 void ComputeLiveTime(void);
499
500
501 ClassDef(Segments,0)
502};
503
504#endif
505
506
Process monitoring.
Parser for text files with columns.
Monitor a GWOLLUM processing.
Definition Monitor.h:39
bool GetStatus(void)
Returns the object status.
Definition Monitor.h:109
Manage time segment lists.
Definition Segments.h:30
bool TruncateBefore(const double aGps)
Removes segments before a given time.
Definition Segments.cc:826
bool Intersect(Segments *aSeg)
Intersects with a segment list.
Definition Segments.cc:939
vector< double > GetEnds(void)
Returns the list of segment ends.
Definition Segments.h:145
bool IsInsideSegment(unsigned int &aSegmentIndex, const double aGps)
Checks whether a given GPS time is inside a segment of the list.
Definition Segments.cc:466
unsigned int GetN(void)
Returns the number of time segments in the list.
Definition Segments.h:129
bool CheckConsistency(const unsigned int aStartIndex)
Checks the sanity of the segment list.
Definition Segments.cc:1124
bool MakeSecond(void)
Rounds segment boundaries to integer seconds.
Definition Segments.cc:867
unsigned int GetNWithTag(const int aTag)
Returns the number of time segments in the list with a given tag.
Definition Segments.cc:303
vector< double > seg_start
List of segment starts.
Definition Segments.h:439
bool GetStatus(void)
Returns the class status.
Definition Segments.h:111
vector< int > seg_tag
List of segment tags.
Definition Segments.h:441
bool Reverse(void)
Reverses the segment list.
Definition Segments.cc:890
TH1I * GetHisto(const double aOffset=0.0)
Returns an histogram representing the segments.
Definition Segments.h:242
TTree * GetTree(void)
Returns a formatted TTree representing the segments.
Definition Segments.h:263
void ComputeLiveTime(void)
Computes the sgments livetime.
Definition Segments.cc:1244
double GetEnd(const unsigned int aSegmentIndex=0)
Returns the ending time of a given segment.
Definition Segments.h:164
void SetTag(const unsigned int aSegmentIndex, const int aTag)
Tags a given segment.
Definition Segments.h:289
TH1I * GetHistogram(const double aGpsStart, const double aGpsEnd, const double aOffset=0.0)
Returns an histogram representing the segments.
Definition Segments.cc:373
void MergeOverlaps(const unsigned int aStartIndex)
Merges segment overlaps.
Definition Segments.cc:1175
bool AddSegments(Segments *aSeg)
Adds a segment list to the list.
Definition Segments.cc:722
double GetLast()
Returns the ending time of the last segment.
Definition Segments.h:176
void SetMarks(void)
Sets time marks for internal lookup.
Definition Segments.cc:1200
bool AddSegment(const double aGpsStart, const double aGpsEnd, const int aTag=1)
Adds a segment to the list.
Definition Segments.cc:681
double GetLiveTimeWithTag(const int aTag)
Returns the livetime for segments with a given tag.
Definition Segments.cc:358
vector< double > seg_end
List of segment ends.
Definition Segments.h:440
bool TruncateAfter(const double aGps)
Removes segments after a given time.
Definition Segments.cc:786
bool Append(const double aGpsStart, const double aGpsEnd, const int aTag=1)
Appends a segment to the list.
Definition Segments.cc:511
bool ApplyPadding(const double aPadStart, const double aPadEnd)
Apply a padding to all segments.
Definition Segments.cc:746
int GetSegmentStartBefore(const double aGps)
Returns the segment starting just before a given GPS time.
Definition Segments.cc:280
int GetMark(const unsigned int aGps)
Returns the time mark for a given GPS time.
Definition Segments.cc:1226
double GetFirst()
Returns the starting time of the first segment.
Definition Segments.h:170
double GetStart(const unsigned int aSegmentIndex=0)
Returns the starting time of a given segment.
Definition Segments.h:157
vector< unsigned int > n_mark
Segment index marks.
Definition Segments.h:444
double GetDuration(const unsigned int aSegmentIndex=0)
Returns the duration of a given segment.
Definition Segments.h:183
vector< double > GetStarts(void)
Returns the list of segment starts.
Definition Segments.h:140
double GetLiveTime(const unsigned int aSegmentIndex)
Returns the livetime of one segment.
Definition Segments.h:211
Segments(void)
Default constructor of the Segments class.
Definition Segments.cc:21
int GetTag(const unsigned int aSegmentIndex=0)
Returns the tag of a given segment.
Definition Segments.h:190
void Reset(void)
Resets the segment list.
Definition Segments.cc:267
void Dump(unsigned int aNcols=2, const string aTxtFileName="")
Dumps the current segment list in the standard output or in a file.
Definition Segments.cc:1041
vector< int > GetTags(void)
Returns the list of segment tags.
Definition Segments.h:150
double GetLiveTime(void)
Returns the total livetime.
Definition Segments.h:196
Monitor * mon
Class monitor.
Definition Segments.h:438
double seg_livetime
Integrated livetime.
Definition Segments.h:442
vector< unsigned int > time_mark
Time marks.
Definition Segments.h:443
int GetTagProduct(const int aTag1, const int aTag2)
Computes the product of 2 tags.
Definition Segments.h:454
virtual ~Segments(void)
Destructor of the Segments class.
Definition Segments.cc:260
void SetTags(const int aTag)
Tags all segments.
Definition Segments.cc:503