Omicron  4.2.0
An algorithm to detect and characterize transient events in gravitational-wave detectors
Oomicron.h
Go to the documentation of this file.
1 
6 #ifndef __Oomicron__
7 #define __Oomicron__
8 
9 #include <IO.h>
10 #include "Otile.h"
11 #include "Oinject.h"
12 #include <Date.h>
13 #include <InjEct.h>
14 #include <ffl.h>
15 
16 using namespace std;
17 
36 class Omicron: public GwollumOptions {
37 
38  public:
39 
57  Omicron(const string aOptionFile, const bool aOneChannel, const unsigned int aGpsRef=0, const bool aStrict=false);
58 
62  virtual ~Omicron(void);
72  inline void ResetSequence(void){ tile->ResetSequence(); };
73 
87  bool InitSegments(Segments *aInSeg, Segments *aOutSeg=NULL);
88 
102  bool MakeDirectories(const double aId = 0.0);
103 
113  bool NewChunk(void);
114 
128  bool DefineNewChunk(const unsigned int aTimeStart, const unsigned int aTimeEnd,
129  const bool aResetPsdBuffer=false);
130 
137  bool NewChannel(void);
138 
144  inline string GetChannelPrefix(const unsigned int aChannelIndex){
145  if(aChannelIndex<GetChannelsN()) return triggers[aChannelIndex]->Streams::GetNamePrefix();
146  return "";
147  };
148 
154  inline string GetChannelName(const unsigned int aChannelIndex){
155  if(aChannelIndex<GetChannelsN()) return triggers[aChannelIndex]->Streams::GetName();
156  return "";
157  };
158 
163  inline string GetChannelName(void){
164  if(chanindex>=0) return triggers[chanindex]->Streams::GetName();
165  return "";
166  };
167 
172  inline unsigned int GetChannelNativeFrequency(void){
173  if(chanindex>=0) return triggers[chanindex]->Streams::GetNativeFrequency();
174  return 0;
175  };
176 
191  bool LoadData(double **aDataVector, unsigned int &aSize);
192 
222  int Condition(const unsigned int aInVectSize, double *aInVect, bool &aIsFlat);
223 
229  long unsigned int Project(void);
230 
235  bool WriteOutput(void);
236 
245  bool ExtractTriggers(double &aTriggerRate);
246 
260  inline Segments* GetTileSegments(TH1D *aSnrThreshold, const double aPadding){
261  return tile->GetTileSegments(aSnrThreshold, aPadding);
262  };
263 
267  inline double GetTileFrequencyMin(void){
268  return tile->GetFrequencyMin();
269  };
270 
274  inline double GetTileFrequencyMax(void){
275  return tile->GetFrequencyMax();
276  };
277 
285  Long64_t FlushTriggers(void);
286 
298  string WriteTriggers(const bool aUseLVDir = false);
299 
303  inline unsigned int GetTriggerSegmentsN(void){
304  if(chanindex>=0) return triggers[chanindex]->Segments::GetN();
305  return 0;
306  }
307 
312  inline void SetPlotTimeOffset(const double aTimeOffset){ toffset=aTimeOffset; };
313 
317  inline unsigned int GetChannelsN(void){ return triggers.size(); };
318 
322  inline unsigned int GetChunkDuration(void){return tile->GetTimeRange();};
323 
327  inline unsigned int GetOverlapDuration(void){return tile->GetOverlapDuration();};
328 
332  inline unsigned int GetChunkTimeStart(void){return tile->GetChunkTimeStart();};
333 
337  inline unsigned int GetChunkTimeEnd(void){return tile->GetChunkTimeEnd();};
338 
342  inline unsigned int GetQN(void){return tile->GetQN();};
343 
349  inline double GetQ(const unsigned int aQindex){return tile->GetQ(aQindex);};
350 
355  inline unsigned int GetBandN(const unsigned int aQindex){return tile->GetBandN(aQindex);};
356 
363  inline double* GetBands(const unsigned int aQindex){ return tile->GetBands(aQindex); };
364 
370  inline double GetBandFrequency(const unsigned int aQindex, const unsigned int aBandIndex){
371  return tile->GetBandFrequency(aQindex, aBandIndex);
372  };
373 
380  inline unsigned int GetBandTileN(const unsigned int aQindex, const unsigned int aBandIndex){
381  return tile->GetBandTileN(aQindex, aBandIndex);
382  };
383 
389  inline double GetSnrSqMax(const unsigned int aQindex){ return tile->GetSnrSqMax(aQindex); };
390 
398  inline double GetTileSnrSq(const unsigned int aQindex, const unsigned int aBandIndex, const unsigned int aTimeTileIndex){
399  return tile->GetTileSnrSq(aQindex, aBandIndex, aTimeTileIndex);
400  };
401 
409  inline double GetTileAmplitudeSq(const unsigned int aQindex, const unsigned int aBandIndex, const unsigned int aTimeTileIndex){
410  return tile->GetTileAmplitudeSq(aQindex, aBandIndex, aTimeTileIndex);
411  };
412 
420  inline double GetTileAmplitude(const unsigned int aQindex, const unsigned int aBandIndex, const unsigned int aTimeTileIndex){
421  return tile->GetTileAmplitude(aQindex, aBandIndex, aTimeTileIndex);
422  };
423 
429  inline long unsigned int GetTileN(const double aPadding=0.0){return tile->GetTileN(aPadding);};
430 
434  inline unsigned int GetSampleFrequency(void){return triggers[0]->GetWorkingFrequency();};
435 
439  inline Long64_t GetTriggerN(void){
440  if(chanindex>=0) return triggers[chanindex]->GetTriggerN();
441  return 0;
442  };
443 
447  inline double GetSnrThreshold(void){ return tile->GetSnrTriggerThr(); };
448 
452  inline void ResetPsdBuffer(void) {
453  if(chanindex>=0) spectrum1[chanindex]->Reset();
454  return;
455  };
456 
460  inline void ResetTriggerBuffer(void) {
461  if(chanindex>=0) triggers[chanindex]->TriggerBuffer::Reset();
462  return;
463  };
464 
469  void PrintMessage(const string aMessage);
470 
474  void PrintStatusInfo(void);
475 
479  vector <string> GetChannels(void);
480 
484  inline bool GetStatus(void){ return status_OK; };
485 
489  inline unsigned int GetInjectionChannelN(void){ return GO_InjChan.size(); };
490 
494  inline bool GetSgInjectionFlag(void){ return GO_InjSg; };
495 
499  inline unsigned int GetInjGenN(void){
500  if(inject!=NULL) return inject[0]->GetN();
501  return 0;
502  };
503 
504 
505  private:
506 
507  // STATUS
508  bool status_OK;
509  time_t timer;
510  time_t timer_start;
511  struct tm * ptm;
512  int chanindex;
513 
514  // OPTIONS
515  unsigned int GO_Verbosity;
516  string GO_OutProducts;
517  string GO_OutFormat;
518  string GO_MainDir;
519  string MainDir;
520  vector<string> GO_InjChan;
521  vector<double> GO_InjFact;
522  bool GO_InjSg;
523  double GO_RateMax;
524  bool GO_thumb;
525 
526  // COMPONENTS
527  ffl *FFL;
528  vector<TriggerBuffer*> triggers;
530  unsigned int one_channel;
531  Spectrum **spectrum1;
532  Spectrum **spectrum2;
533  Spectrum *spectrumw;
534  ffl *FFL_inject;
535  InjEct **inject;
537  fft *offt;
538  double *ChunkVect;
539  double *TukeyWindow;
540 
541  // OUTPUT
542  vector <string> outdir;
543  ofstream osummaryfile;
544  ofstream oinjfile;
545  double toffset;
546 
547  // MONITORING
548  Segments *inSegments;
549  Segments **outSegments;
550  unsigned int chunk_ctr;
551  unsigned int *chan_data_ctr;
552  unsigned int *chan_cond_ctr;
553  unsigned int *chan_proj_ctr;
554  unsigned int *chan_write_ctr;
555  unsigned int *trig_ctr;
556  double *chan_mapsnrmax;
557  vector <unsigned int> chunkcenter;
558  vector <string> chunktfile;
559 
560 
566  void ReadOptions(const string aOptFile, const bool aStrict=false);
567 
572  void MakeOptions(void);
573 
579  void MakeFfl(const unsigned int aGpsRef=0);
580 
585  void MakeTriggers(void);
586 
590  void MakeTiling(void);
591 
596  void MakeSpectrum(const bool aOneChannel);
597 
602  void MakeInjections(const unsigned int aGpsRef=0);
603 
614  void Whiten(Spectrum *aSpec, const double aNorm=1.0);
615 
619  void MakeHtml(void);
620 
625  void MakeHtmlInit(void);
626 
633  bool IsFlat(const unsigned int aInVectSize, double *aInVect);
634 
639  string GetColorCode(const double aSnrRatio);
640 
644  void SaveSummary(void);
645 
649  void SaveOptions(void);
650 
654  void SaveSG(void);
655 
660  void SaveAPSD(const string aType);
661 
666  void SaveTS(const bool aWhite=false);
667 
671  void SaveWPSD(void);
672 
673  ClassDef(Omicron,0)
674 };
675 
676 #endif
677 
678 
Inject sinusoidal Gaussian waveforms.
Omicron tiling structure.
Inject sinusoidal Gaussian waveforms.
Definition: Oinject.h:20
Process data with the Omicron algorithm.
Definition: Oomicron.h:36
unsigned int GetBandTileN(const unsigned int aQindex, const unsigned int aBandIndex)
Returns the number of tiles in a frequency row of given Q-plane.
Definition: Oomicron.h:380
Otile * tile
Tiling structure.
Definition: Oomicron.h:529
Segments * inSegments
Requested segments.
Definition: Oomicron.h:548
unsigned int one_channel
Optimization flag to process one channel at a time.
Definition: Oomicron.h:530
ofstream oinjfile
Output file with omicron injection parameters.
Definition: Oomicron.h:544
struct tm * ptm
GMT time.
Definition: Oomicron.h:511
void SetPlotTimeOffset(const double aTimeOffset)
When time plots are requested in output, a time offset [s] can be added.
Definition: Oomicron.h:312
vector< double > GO_InjFact
List of injection factors.
Definition: Oomicron.h:521
vector< string > chunktfile
save chunk file (only for html)
Definition: Oomicron.h:558
int chanindex
Current channel index (-1 = no channel).
Definition: Oomicron.h:512
string GO_MainDir
Output main directory (original).
Definition: Oomicron.h:518
double GetQ(const unsigned int aQindex)
Returns the Q value of a given q planes.
Definition: Oomicron.h:349
Segments * GetTileSegments(TH1D *aSnrThreshold, const double aPadding)
Returns tile segments.
Definition: Oomicron.h:260
string GO_OutProducts
Output product string.
Definition: Oomicron.h:516
Spectrum ** spectrum2
2nd spectrum structure / channel.
Definition: Oomicron.h:532
string GetChannelName(const unsigned int aChannelIndex)
Returns the name of a given channel.
Definition: Oomicron.h:154
bool GetSgInjectionFlag(void)
Returns the SG injection flag.
Definition: Oomicron.h:494
unsigned int GetInjectionChannelN(void)
Returns the number of injection channels.
Definition: Oomicron.h:489
string GetChannelName(void)
Returns the name of the current channel.
Definition: Oomicron.h:163
unsigned int * chan_write_ctr
Number of WriteOutput() calls /channel.
Definition: Oomicron.h:554
unsigned int GetInjGenN(void)
Returns the total number of InjGen injections.
Definition: Oomicron.h:499
time_t timer_start
Timer start.
Definition: Oomicron.h:510
bool GO_thumb
Flag to produce thumbnails.
Definition: Oomicron.h:524
unsigned int * chan_proj_ctr
Number of Project() calls /channel.
Definition: Oomicron.h:553
fft * offt
FFT plan to FFT the input chunk.
Definition: Oomicron.h:537
unsigned int GetChannelNativeFrequency(void)
Returns the native sampling frequency of the current channel.
Definition: Oomicron.h:172
unsigned int * chan_cond_ctr
Number of Condition() calls /channel.
Definition: Oomicron.h:552
bool GO_InjSg
Flag to perform sine-Gaussian injections.
Definition: Oomicron.h:522
vector< string > GO_InjChan
List of injection channels.
Definition: Oomicron.h:520
bool status_OK
General status.
Definition: Oomicron.h:502
string GetChannelPrefix(const unsigned int aChannelIndex)
Returns the name prefix of a given channel.
Definition: Oomicron.h:144
Segments ** outSegments
Processed segments /channel.
Definition: Oomicron.h:549
unsigned int GetSampleFrequency(void)
Returns the working sampling frequency [Hz].
Definition: Oomicron.h:434
Spectrum ** spectrum1
1st spectrum structure / channel.
Definition: Oomicron.h:531
double GetTileFrequencyMax(void)
Returns the tiling maximum frequency [Hz].
Definition: Oomicron.h:274
double GetTileSnrSq(const unsigned int aQindex, const unsigned int aBandIndex, const unsigned int aTimeTileIndex)
Returns the SNR squared of a given tile.
Definition: Oomicron.h:398
Long64_t GetTriggerN(void)
Returns the current number of triggers in memory for the current channel.
Definition: Oomicron.h:439
vector< TriggerBuffer * > triggers
Output triggers / channel.
Definition: Oomicron.h:528
Omicron(const string aOptionFile, const bool aOneChannel, const unsigned int aGpsRef=0, const bool aStrict=false)
Constructor of the Omicron class.
double GetSnrSqMax(const unsigned int aQindex)
Returns the maximum SNR squared estimated in a given Q plane.
Definition: Oomicron.h:389
void ResetPsdBuffer(void)
Resets the PSD buffer of current channel.
Definition: Oomicron.h:452
double * TukeyWindow
Tukey window.
Definition: Oomicron.h:539
bool GetStatus(void)
Returns class status.
Definition: Oomicron.h:484
ofstream osummaryfile
Output summary file.
Definition: Oomicron.h:543
double GetTileAmplitudeSq(const unsigned int aQindex, const unsigned int aBandIndex, const unsigned int aTimeTileIndex)
Returns the amplitude squared of a given tile.
Definition: Oomicron.h:409
unsigned int GetChannelsN(void)
Returns the number of channels.
Definition: Oomicron.h:317
ffl * FFL
ffl object (NULL if none).
Definition: Oomicron.h:527
double GetTileFrequencyMin(void)
Returns the tiling minimum frequency [Hz].
Definition: Oomicron.h:267
unsigned int * trig_ctr
Number of tiles above snr thr /channel.
Definition: Oomicron.h:555
double * ChunkVect
Chunk raw data (time domain).
Definition: Oomicron.h:538
void ResetTriggerBuffer(void)
Resets the trigger buffer of current channel.
Definition: Oomicron.h:460
double GetSnrThreshold(void)
Returns the SNR threshold used to save triggers.
Definition: Oomicron.h:447
unsigned int GO_Verbosity
Verbosity level.
Definition: Oomicron.h:515
double GetTileAmplitude(const unsigned int aQindex, const unsigned int aBandIndex, const unsigned int aTimeTileIndex)
Returns the amplitude of a given tile.
Definition: Oomicron.h:420
ffl * FFL_inject
FFL for injections.
Definition: Oomicron.h:534
unsigned int GetChunkTimeEnd(void)
Returns the current chunk end time [s].
Definition: Oomicron.h:337
unsigned int GetTriggerSegmentsN(void)
Returns the number of processed segments.
Definition: Oomicron.h:303
unsigned int GetChunkTimeStart(void)
Returns the current chunk start time [s].
Definition: Oomicron.h:332
time_t timer
Timer.
Definition: Oomicron.h:509
InjEct ** inject
Software injections / channel.
Definition: Oomicron.h:535
unsigned int GetOverlapDuration(void)
Returns the overlap duration [s].
Definition: Oomicron.h:327
unsigned int * chan_data_ctr
Number of LoadData() calls /channel.
Definition: Oomicron.h:551
long unsigned int GetTileN(const double aPadding=0.0)
Returns the number of tiles.
Definition: Oomicron.h:429
string GO_OutFormat
Output format string.
Definition: Oomicron.h:517
double GO_RateMax
Maximum trigger rate.
Definition: Oomicron.h:523
Spectrum * spectrumw
Spectrum structure to test whitening.
Definition: Oomicron.h:533
vector< string > outdir
Output directories / channel.
Definition: Oomicron.h:542
Oinject * oinj
Software Oinject injections.
Definition: Oomicron.h:536
vector< unsigned int > chunkcenter
Chunk centers (only for html).
Definition: Oomicron.h:557
void ResetSequence(void)
Resets the time sequence of chunks.
Definition: Oomicron.h:72
unsigned int GetChunkDuration(void)
Returns the chunk duration [s].
Definition: Oomicron.h:322
double toffset
Time offset for plots [s].
Definition: Oomicron.h:545
unsigned int GetBandN(const unsigned int aQindex)
Returns the number of frequency rows of a given Q-plane.
Definition: Oomicron.h:355
double * chan_mapsnrmax
Channel SNR max in maps (only for html)
Definition: Oomicron.h:556
unsigned int GetQN(void)
Returns the number of q planes.
Definition: Oomicron.h:342
double * GetBands(const unsigned int aQindex)
Returns the list of frequency bands.
Definition: Oomicron.h:363
string MainDir
Output main directory.
Definition: Oomicron.h:519
double GetBandFrequency(const unsigned int aQindex, const unsigned int aBandIndex)
Returns the band central frequency [Hz] of a given Q-plane.
Definition: Oomicron.h:370
unsigned int chunk_ctr
Number of called chunks.
Definition: Oomicron.h:550
Construct a time-frequency-Q tiling structure.
Definition: Otile.h:39