Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MySimpleTree.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MySimpleTree.h
1 #ifndef MYSIMPLETREE_h
2 #define MYSIMPLETREE_h
3 
4 // This class just stores an int and a float. While not needed it is
5 // better in the long run to get used to use methods to get to the
6 // data. It doesn't matter for the root TTree which is saved but if
7 // you save this class inside a TClonesArray (the other example) it
8 // makes it easier. It also allows greater flexibility, e.g. if you ever
9 // want to ("dammit I forgot to multiply myfloat with Pi") modify the
10 // values on the fly:
11 // exchange
12 // float MyFloat() const {return myfloat;}
13 // by
14 // float MyFloat() const {return myfloat*M_PI;}
15 // and you don't have to change your analysis code one bit
16 
17 
18 #include <phool/PHObject.h>
19 
20 #include <cmath> // for NAN
21 
22 class MySimpleTree: public PHObject
23 {
24 
25  public:
26 
27  MySimpleTree();
28  ~MySimpleTree() override {}
29 
30  void Reset() override;
31 
32  void MyFloat(const float f) {myfloat = f;}
33  float MyFloat() const {return myfloat;}
34  void MyInt(const int i) {myint = i;}
35  int MyInt() const {return myint;}
36 
37  private:
38  int myint = -9999;
39  float myfloat = NAN;
40 
41  ClassDefOverride(MySimpleTree,1)
42 
43 };
44 
45 #endif