EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ValContext.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ValContext.h
1 #ifndef VALCONTEXT_H
2 #define VALCONTEXT_H
3 
4 #include "TObject.h"
5 #include "Experiment.h"
6 #include "Detector.h"
7 #include "SimFlag.h"
8 #include "ValTimeStamp.h"
9 
10 #include <iostream>
11 using namespace std;
12 
13 class ValContext;
14 
15 std::ostream& operator<<(std::ostream& os, const ValContext& vldc);
16 
17 class ValContext : public TObject
18 {
19 
20  public:
21 
22  ValContext(); // necessary for streamer io
23  ValContext(const Detector::Detector_t& detector,
24  const SimFlag::SimFlag_t mcflag,
25  const ValTimeStamp& time);
26  virtual ~ValContext();
27 
31  const char* AsString(Option_t* option = "") const;
32 
33  Detector::Detector_t GetDetector() const { return fDetector;}
34  SimFlag::SimFlag_t GetSimFlag() const { return fSimFlag;}
35  ValTimeStamp GetTimeStamp() const { return fTimeStamp;}
36 
39  Bool_t IsNull() const;
41  Bool_t IsValid() const { return !IsNull(); }
42 
43  void Print(Option_t* option = "") const;
44 
45  friend Bool_t operator< (const ValContext& lhs, const ValContext& rhs);
46  friend Bool_t operator==(const ValContext& lhs, const ValContext& rhs);
47  friend Bool_t operator!=(const ValContext& lhs, const ValContext& rhs);
48  friend Bool_t operator<=(const ValContext& lhs, const ValContext& rhs);
49  friend Bool_t operator> (const ValContext& lhs, const ValContext& rhs);
50  friend Bool_t operator>=(const ValContext& lhs, const ValContext& rhs);
51 
52  protected:
53 
57 
58  private:
59 
60  ClassDef(ValContext,1) // ValTimeStamp+Detector+SimFlag
61 
62 };
63 
64 #ifndef __CINT__
65 
66 inline Bool_t operator< (const ValContext& lhs, const ValContext& rhs)
67 {
68  // sorting is a little tricky with three fields
69  // this sorts first by time then experiment then simflag
70  // *WARNING* be very careful if you change this
71  if ( lhs.fTimeStamp < rhs.fTimeStamp ) { return true; }
72  if ( lhs.fTimeStamp == rhs.fTimeStamp ) {
73  if ( lhs.fDetector < rhs.fDetector ) { return true; }
74  if ( lhs.fDetector == rhs.fDetector ) {
75  if (lhs.fSimFlag < rhs.fSimFlag ) { return true; }
76  }
77  }
78  return false;
79 }
80 
81 inline Bool_t operator==(const ValContext& lhs, const ValContext& rhs)
82 {
83  // equal if all components match
84  return
85  lhs.fDetector == rhs.fDetector &&
86  lhs.fSimFlag == rhs.fSimFlag &&
87  lhs.fTimeStamp == rhs.fTimeStamp;
88 }
89 
90 inline Bool_t operator!=(const ValContext& lhs, const ValContext& rhs)
91 {
92  // not equal if any component doesn't match
93  return
94  lhs.fDetector != rhs.fDetector ||
95  lhs.fSimFlag != rhs.fSimFlag ||
96  lhs.fTimeStamp != rhs.fTimeStamp;
97 }
98 
99 inline Bool_t operator<=(const ValContext& lhs, const ValContext& rhs)
100 {
101  return (lhs<rhs) || (lhs==rhs);
102 }
103 
104 inline Bool_t operator>(const ValContext& lhs, const ValContext& rhs)
105 {
106  return !(lhs<rhs) && !(lhs==rhs);
107 }
108 
109 inline Bool_t operator>=(const ValContext& lhs, const ValContext& rhs)
110 {
111  return !(lhs<rhs);
112 }
113 
114 
115 #endif /* __CINT__ */
116 #endif // VALCONTEXT_H