GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMSelection.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMSelection.hpp - COMPTEL selection set class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-2022 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GCOMSelection.hpp
23  * @brief COMPTEL selection set class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCOMSELECTION_HPP
28 #define GCOMSELECTION_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GPhases.hpp"
34 #include "GPulsar.hpp"
36 
37 /* __ Forward declarations _______________________________________________ */
38 class GFitsHDU;
39 class GCOMEventAtom;
40 
41 /* __ Constants __________________________________________________________ */
42 
43 
44 /***********************************************************************//**
45  * @class GCOMSelection
46  *
47  * @brief COMPTEL selection set class
48  *
49  * This class implements a COMPTEL selection set.
50  ***************************************************************************/
51 class GCOMSelection : public GBase {
52 
53 public:
54  // Constructors and destructors
55  GCOMSelection(void);
56  GCOMSelection(const GCOMSelection& select);
57  virtual ~GCOMSelection(void);
58 
59  // Operators
60  GCOMSelection& operator=(const GCOMSelection& select);
61 
62  // Implemented pure virtual base class methods
63  virtual void clear(void);
64  virtual GCOMSelection* clone(void) const;
65  virtual std::string classname(void) const;
66  virtual std::string print(const GChatter& chatter = NORMAL) const;
67 
68  // Other methods
69  void init_statistics(void) const;
70  bool use_event(const GCOMEventAtom& event) const;
71  const double& e1_min(void) const;
72  void e1_min(const double& e1_min);
73  const double& e1_max(void) const;
74  void e1_max(const double& e1_max);
75  const double& e2_min(void) const;
76  void e2_min(const double& e2_min);
77  const double& e2_max(void) const;
78  void e2_max(const double& e2_max);
79  const int& tof_min(void) const;
80  void tof_min(const int& tof_min);
81  const int& tof_max(void) const;
82  void tof_max(const int& tof_max);
83  const int& psd_min(void) const;
84  void psd_min(const int& psd_min);
85  const int& psd_max(void) const;
86  void psd_max(const int& psd_max);
87  const int& reflag_min(void) const;
88  void reflag_min(const int& reflag_min);
89  const int& reflag_max(void) const;
90  void reflag_max(const int& reflag_max);
91  const int& vetoflag_min(void) const;
92  void vetoflag_min(const int& vetoflag_min);
93  const int& vetoflag_max(void) const;
94  void vetoflag_max(const int& vetoflag_max);
95  const int& fpmtflag(void) const;
96  void fpmtflag(const int& fpmtflag);
97  const bool& use_d1(const int& id1) const;
98  void use_d1(const int& id1, const bool& use);
99  const bool& use_d2(const int& id2) const;
100  void use_d2(const int& id2, const bool& use);
101  const GPhases& orbital_phases(void) const;
102  void orbital_phases(const GPhases& phases);
103  void orbital_period(const double& period, const GTime& time);
104  double orbital_phase(const GTime& time) const;
105  const GPhases& pulsar_phases(void) const;
106  void pulsar_phases(const GPhases& phases);
107  const GPulsar& pulsar(void) const;
108  void pulsar(const GPulsar& pulsar);
109  bool has_pulsar(void) const;
110  void read(const GFitsHDU& hdu);
111  void write(GFitsHDU& hdu) const;
112 
113 protected:
114  // Protected methods
115  void init_members(void);
116  void copy_members(const GCOMSelection& select);
117  void free_members(void);
118 
119  // Protected members
120  double m_e1_min; //!< Minimum D1 energy deposit (MeV)
121  double m_e1_max; //!< Maximum D1 energy deposit (MeV)
122  double m_e2_min; //!< Minimum D2 energy deposit (MeV)
123  double m_e2_max; //!< Maximum D2 energy deposit (MeV)
124  int m_tof_min; //!< Minimum TOF window
125  int m_tof_max; //!< Maximum TOF window
126  int m_psd_min; //!< Minimum PSD window
127  int m_psd_max; //!< Maximum PSD window
128  int m_reflag_min; //!< Minimum rejection flag
129  int m_reflag_max; //!< Maximum rejection flag
130  int m_vetoflag_min; //!< Minimum veto flag
131  int m_vetoflag_max; //!< Maximum veto flag
132  int m_fpmtflag; //!< D2 PMT failures
133  //!< (0: exclude modules, 1: include modules,
134  //!< 2: use FPM information)
135  bool m_use_d1[7]; //!< D1 module usage
136  bool m_use_d2[14]; //!< D2 module usage
137  GPhases m_orbital_phases; //!< Phases for orbital phase selection
139  GPhases m_pulsar_phases; //!< Phases for pulse phase selection
140  GPulsar m_pulsar; //!< Pulsar information
141 
142  // Selection statistics
143  mutable int m_num_events_checked; //!< Number of checked events
144  mutable int m_num_events_used; //!< Number of used events
145  mutable int m_num_events_rejected; //!< Number of rejected events
146  mutable int m_num_e1_min; //!< Number of events below E1 threshold
147  mutable int m_num_e1_max; //!< Number of events above E1 threshold
148  mutable int m_num_e2_min; //!< Number of events below E2 threshold
149  mutable int m_num_e2_max; //!< Number of events above E2 threshold
150  mutable int m_num_tof_min; //!< Number of events below TOF threshold
151  mutable int m_num_tof_max; //!< Number of events above TOF threshold
152  mutable int m_num_psd_min; //!< Number of events below PSD threshold
153  mutable int m_num_psd_max; //!< Number of events above PSD threshold
154  mutable int m_num_reflag_min; //!< Number of events below rejection flag threshold
155  mutable int m_num_reflag_max; //!< Number of events above rejection flag threshold
156  mutable int m_num_vetoflag_min; //!< Number of events below veto flag threshold
157  mutable int m_num_vetoflag_max; //!< Number of events above veto flag threshold
158  mutable int m_num_no_scatter; //!< Number of events without scatter angle
159  mutable int m_num_invalid_modcom; //!< Number of events with invalid minitelescopes
160  mutable int m_num_d1module_off; //!< Number of events excluded since D1 module off
161  mutable int m_num_d2module_off; //!< Number of events excluded since D2 module off
162  mutable int m_num_fpmt; //!< Number of events excluded due to failed PMT
163  mutable int m_num_d1[7]; //!< Number of events per D1 module
164  mutable int m_num_d2[14]; //!< Number of events per D2 module
165 };
166 
167 
168 /***********************************************************************//**
169  * @brief Return class name
170  *
171  * @return String containing the class name ("GCOMSelection").
172  ***************************************************************************/
173 inline
174 std::string GCOMSelection::classname(void) const
175 {
176  return ("GCOMSelection");
177 }
178 
179 
180 /***********************************************************************//**
181  * @brief Return minimum of D1 energy selection window
182  *
183  * @return Minimum of D1 energy selection window.
184  ***************************************************************************/
185 inline
186 const double& GCOMSelection::e1_min(void) const
187 {
188  return (m_e1_min);
189 }
190 
191 
192 /***********************************************************************//**
193  * @brief Set minimum of D1 energy selection window
194  *
195  * @param[in] e1_min Minimum of D1 energy selection window.
196  ***************************************************************************/
197 inline
198 void GCOMSelection::e1_min(const double& e1_min)
199 {
200  m_e1_min = e1_min;
201  return;
202 }
203 
204 
205 /***********************************************************************//**
206  * @brief Return maximum of D1 energy selection window
207  *
208  * @return Maximum of D1 energy selection window.
209  ***************************************************************************/
210 inline
211 const double& GCOMSelection::e1_max(void) const
212 {
213  return (m_e1_max);
214 }
215 
216 
217 /***********************************************************************//**
218  * @brief Set maximum of D1 energy selection window
219  *
220  * @param[in] e1_max Maximum of D1 energy selection window.
221  ***************************************************************************/
222 inline
223 void GCOMSelection::e1_max(const double& e1_max)
224 {
225  m_e1_max = e1_max;
226  return;
227 }
228 
229 
230 /***********************************************************************//**
231  * @brief Return minimum of D2 energy selection window
232  *
233  * @return Minimum of D2 energy selection window.
234  ***************************************************************************/
235 inline
236 const double& GCOMSelection::e2_min(void) const
237 {
238  return (m_e2_min);
239 }
240 
241 
242 /***********************************************************************//**
243  * @brief Set minimum of D2 energy selection window
244  *
245  * @param[in] e2_min Minimum of D2 energy selection window.
246  ***************************************************************************/
247 inline
248 void GCOMSelection::e2_min(const double& e2_min)
249 {
250  m_e2_min = e2_min;
251  return;
252 }
253 
254 
255 /***********************************************************************//**
256  * @brief Return maximum of D2 energy selection window
257  *
258  * @return Maximum of D2 energy selection window.
259  ***************************************************************************/
260 inline
261 const double& GCOMSelection::e2_max(void) const
262 {
263  return (m_e2_max);
264 }
265 
266 
267 /***********************************************************************//**
268  * @brief Set maximum of D2 energy selection window
269  *
270  * @param[in] e2_max Maximum of D2 energy selection window.
271  ***************************************************************************/
272 inline
273 void GCOMSelection::e2_max(const double& e2_max)
274 {
275  m_e2_max = e2_max;
276  return;
277 }
278 
279 
280 /***********************************************************************//**
281  * @brief Return minimum of ToF selection window
282  *
283  * @return Minimum of ToF selection window.
284  ***************************************************************************/
285 inline
286 const int& GCOMSelection::tof_min(void) const
287 {
288  return (m_tof_min);
289 }
290 
291 
292 /***********************************************************************//**
293  * @brief Set minimum of ToF selection window
294  *
295  * @param[in] tof_min Minimum of ToF selection window.
296  ***************************************************************************/
297 inline
298 void GCOMSelection::tof_min(const int& tof_min)
299 {
300  m_tof_min = tof_min;
301  return;
302 }
303 
304 
305 /***********************************************************************//**
306  * @brief Return maximum of ToF selection window
307  *
308  * @return Maximum of ToF selection window.
309  ***************************************************************************/
310 inline
311 const int& GCOMSelection::tof_max(void) const
312 {
313  return (m_tof_max);
314 }
315 
316 
317 /***********************************************************************//**
318  * @brief Set maximum of ToF selection window
319  *
320  * @param[in] tof_max Maximum of ToF selection window.
321  ***************************************************************************/
322 inline
323 void GCOMSelection::tof_max(const int& tof_max)
324 {
325  m_tof_max = tof_max;
326  return;
327 }
328 
329 
330 /***********************************************************************//**
331  * @brief Return minimum of PSD selection window
332  *
333  * @return Minimum of PSD selection window.
334  ***************************************************************************/
335 inline
336 const int& GCOMSelection::psd_min(void) const
337 {
338  return (m_psd_min);
339 }
340 
341 
342 /***********************************************************************//**
343  * @brief Set minimum of PSD selection window
344  *
345  * @param[in] psd_min Minimum of PSD selection window.
346  ***************************************************************************/
347 inline
348 void GCOMSelection::psd_min(const int& psd_min)
349 {
350  m_psd_min = psd_min;
351  return;
352 }
353 
354 
355 /***********************************************************************//**
356  * @brief Return maximum of PSD selection window
357  *
358  * @return Maximum of PSD selection window.
359  ***************************************************************************/
360 inline
361 const int& GCOMSelection::psd_max(void) const
362 {
363  return (m_psd_max);
364 }
365 
366 
367 /***********************************************************************//**
368  * @brief Set maximum of PSD selection window
369  *
370  * @param[in] psd_max Maximum of PSD selection window.
371  ***************************************************************************/
372 inline
373 void GCOMSelection::psd_max(const int& psd_max)
374 {
375  m_psd_max = psd_max;
376  return;
377 }
378 
379 
380 /***********************************************************************//**
381  * @brief Return minimum of Rejection Flag selection window
382  *
383  * @return Minimum of Rejection Flag selection window.
384  ***************************************************************************/
385 inline
386 const int& GCOMSelection::reflag_min(void) const
387 {
388  return (m_reflag_min);
389 }
390 
391 
392 /***********************************************************************//**
393  * @brief Set minimum of Rejection Flag selection window
394  *
395  * @param[in] reflag_min Minimum of Rejection Flag selection window.
396  ***************************************************************************/
397 inline
398 void GCOMSelection::reflag_min(const int& reflag_min)
399 {
401  return;
402 }
403 
404 
405 /***********************************************************************//**
406  * @brief Return maximum of Rejection Flag selection window
407  *
408  * @return Maximum of Rejection Flag selection window.
409  ***************************************************************************/
410 inline
411 const int& GCOMSelection::reflag_max(void) const
412 {
413  return (m_reflag_max);
414 }
415 
416 
417 /***********************************************************************//**
418  * @brief Set maximum of Rejection Flag selection window
419  *
420  * @param[in] reflag_max Maximum of Rejection Flag selection window.
421  ***************************************************************************/
422 inline
423 void GCOMSelection::reflag_max(const int& reflag_max)
424 {
426  return;
427 }
428 
429 
430 /***********************************************************************//**
431  * @brief Return minimum of Veto Flag selection window
432  *
433  * @return Minimum of Veto Flag selection window.
434  ***************************************************************************/
435 inline
436 const int& GCOMSelection::vetoflag_min(void) const
437 {
438  return (m_vetoflag_min);
439 }
440 
441 
442 /***********************************************************************//**
443  * @brief Set minimum of Veto Flag selection window
444  *
445  * @param[in] vetoflag_min Minimum of Veto Flag selection window.
446  ***************************************************************************/
447 inline
448 void GCOMSelection::vetoflag_min(const int& vetoflag_min)
449 {
451  return;
452 }
453 
454 
455 /***********************************************************************//**
456  * @brief Return maximum of Veto Flag selection window
457  *
458  * @return Maximum of Veto Flag selection window.
459  ***************************************************************************/
460 inline
461 const int& GCOMSelection::vetoflag_max(void) const
462 {
463  return (m_vetoflag_max);
464 }
465 
466 
467 /***********************************************************************//**
468  * @brief Set maximum of Veto Flag selection window
469  *
470  * @param[in] vetoflag_max Maximum of Veto Flag selection window.
471  ***************************************************************************/
472 inline
473 void GCOMSelection::vetoflag_max(const int& vetoflag_max)
474 {
476  return;
477 }
478 
479 
480 /***********************************************************************//**
481  * @brief Return failed PMT flag for D2 modules
482  *
483  * @return Failed PMT flag for D2 modules.
484  *
485  * Returns the failed PMT flag for D2 modules. The following values can be
486  * returned:
487  * - 0: excluded D2 modules with failed PMTs
488  * - 1: include D2 modules with failed PMTs
489  * - 2: include D2 modules with failed PMTs by excluding zone around failed
490  * PMTs
491  ***************************************************************************/
492 inline
493 const int& GCOMSelection::fpmtflag(void) const
494 {
495  return (m_fpmtflag);
496 }
497 
498 
499 /***********************************************************************//**
500  * @brief Return orbital phases
501  *
502  * @return Orbital phases
503  ***************************************************************************/
504 inline
506 {
507  return (m_orbital_phases);
508 }
509 
510 
511 /***********************************************************************//**
512  * @brief Set orbital phases
513  *
514  * @param[in] phases Orbital phases.
515  ***************************************************************************/
516 inline
518 {
519  m_orbital_phases = phases;
520  return;
521 }
522 
523 
524 /***********************************************************************//**
525  * @brief Return orbital phase for a given time
526  *
527  * @param[in] time Time.
528  * @return Orbital phase.
529  ***************************************************************************/
530 inline
531 double GCOMSelection::orbital_phase(const GTime& time) const
532 {
533  // Compute phase
534  double phase = m_orbital_phase_curve.phase(time);
535 
536  // Return phase
537  return phase;
538 }
539 
540 
541 /***********************************************************************//**
542  * @brief Return pulsar phases
543  *
544  * @return Pulsar phases
545  ***************************************************************************/
546 inline
548 {
549  return (m_pulsar_phases);
550 }
551 
552 
553 /***********************************************************************//**
554  * @brief Set pulsar phases
555  *
556  * @param[in] phases Pulsar phases.
557  ***************************************************************************/
558 inline
560 {
561  m_pulsar_phases = phases;
562  return;
563 }
564 
565 
566 /***********************************************************************//**
567  * @brief Return pulsar
568  *
569  * @return Pulsar
570  ***************************************************************************/
571 inline
572 const GPulsar& GCOMSelection::pulsar(void) const
573 {
574  return (m_pulsar);
575 }
576 
577 
578 /***********************************************************************//**
579  * @brief Set pulsar
580  *
581  * @param[in] pulsar Pulsar.
582  ***************************************************************************/
583 inline
584 void GCOMSelection::pulsar(const GPulsar& pulsar)
585 {
586  m_pulsar = pulsar;
587  return;
588 }
589 
590 
591 /***********************************************************************//**
592  * @brief Signals that pulsar selection should be performed
593  *
594  * @return True if pulsar selection should be performed, false otherwise
595  *
596  * This method returns true if the pulsar and the pulsar phase selection are
597  * not empty.
598  ***************************************************************************/
599 inline
601 {
602  return (!pulsar().is_empty() && !pulsar_phases().is_empty());
603 }
604 
605 #endif /* GCOMSELECTION_HPP */
const double & e1_min(void) const
Return minimum of D1 energy selection window.
const bool & use_d2(const int &id2) const
Return D2 module usage flag.
const GPhases & pulsar_phases(void) const
Return pulsar phases.
void copy_members(const GCOMSelection &select)
Copy class members.
int m_num_d2[14]
Number of events per D2 module.
int m_vetoflag_max
Maximum veto flag.
int m_num_d1module_off
Number of events excluded since D1 module off.
int m_num_tof_max
Number of events above TOF threshold.
virtual std::string classname(void) const
Return class name.
const int & psd_min(void) const
Return minimum of PSD selection window.
int m_reflag_min
Minimum rejection flag.
bool m_use_d1[7]
D1 module usage.
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
Definition of interface for all GammaLib classes.
int m_tof_max
Maximum TOF window.
double m_e2_max
Maximum D2 energy deposit (MeV)
Time class.
Definition: GTime.hpp:55
double m_e2_min
Minimum D2 energy deposit (MeV)
COMPTEL selection set class.
const int & tof_min(void) const
Return minimum of ToF selection window.
double orbital_phase(const GTime &time) const
Return orbital phase for a given time.
int m_reflag_max
Maximum rejection flag.
int m_vetoflag_min
Minimum veto flag.
const int & fpmtflag(void) const
Return failed PMT flag for D2 modules.
GModelTemporalPhaseCurve m_orbital_phase_curve
Orbital phase curve.
void free_members(void)
Delete class members.
const double & e2_max(void) const
Return maximum of D2 energy selection window.
const int & vetoflag_min(void) const
Return minimum of Veto Flag selection window.
Phase intervals class interface definition.
void write(GFitsHDU &hdu) const
Write selection set keywords into FITS HDU.
int m_psd_max
Maximum PSD window.
bool has_pulsar(void) const
Signals that pulsar selection should be performed.
const int & vetoflag_max(void) const
Return maximum of Veto Flag selection window.
Temporal phase curve model class interface definition.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
int m_num_reflag_max
Number of events above rejection flag threshold.
void orbital_period(const double &period, const GTime &time)
Set orbital period.
GCOMSelection(void)
Void constructor.
int m_num_e1_min
Number of events below E1 threshold.
void init_members(void)
Initialise class members.
int m_psd_min
Minimum PSD window.
void init_statistics(void) const
Initialise selection statistics.
int m_num_d2module_off
Number of events excluded since D2 module off.
GCOMSelection & operator=(const GCOMSelection &select)
Assignment operator.
virtual ~GCOMSelection(void)
Destructor.
GChatter
Definition: GTypemaps.hpp:33
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL selection set.
double m_e1_max
Maximum D1 energy deposit (MeV)
int m_num_e2_max
Number of events above E2 threshold.
GPulsar m_pulsar
Pulsar information.
const bool & use_d1(const int &id1) const
Return D1 module usage flag.
int m_num_events_rejected
Number of rejected events.
bool m_use_d2[14]
D2 module usage.
const GPulsar & pulsar(void) const
Return pulsar.
virtual GCOMSelection * clone(void) const
Clone COMPTEL selection set.
int m_num_vetoflag_min
Number of events below veto flag threshold.
double phase(void) const
Return phase at reference Modified Julian Day.
int m_num_reflag_min
Number of events below rejection flag threshold.
const double & e1_max(void) const
Return maximum of D1 energy selection window.
const int & psd_max(void) const
Return maximum of PSD selection window.
bool use_event(const GCOMEventAtom &event) const
Check if event should be used.
Pulsar class.
Definition: GPulsar.hpp:53
int m_num_invalid_modcom
Number of events with invalid minitelescopes.
int m_num_events_checked
Number of checked events.
GPhases m_pulsar_phases
Phases for pulse phase selection.
int m_num_fpmt
Number of events excluded due to failed PMT.
const int & reflag_min(void) const
Return minimum of Rejection Flag selection window.
int m_num_tof_min
Number of events below TOF threshold.
virtual void clear(void)
Clear COMPTEL selection set.
int m_num_psd_max
Number of events above PSD threshold.
const int & reflag_max(void) const
Return maximum of Rejection Flag selection window.
const int & tof_max(void) const
Return maximum of ToF selection window.
Pulsar class definition.
const GPhases & orbital_phases(void) const
Return orbital phases.
int m_num_no_scatter
Number of events without scatter angle.
Phase Intervals class.
Definition: GPhases.hpp:42
int m_num_psd_min
Number of events below PSD threshold.
double m_e1_min
Minimum D1 energy deposit (MeV)
void read(const GFitsHDU &hdu)
Read selection set from FITS HDU keywords.
const double & e2_min(void) const
Return minimum of D2 energy selection window.
int m_num_e2_min
Number of events below E2 threshold.
GPhases m_orbital_phases
Phases for orbital phase selection.
int m_num_events_used
Number of used events.
int m_num_vetoflag_max
Number of events above veto flag threshold.
Temporal phase curve model class.
int m_tof_min
Minimum TOF window.
int m_num_e1_max
Number of events above E1 threshold.
int m_num_d1[7]
Number of events per D1 module.
COMPTEL event atom class.