Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHAna.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHAna.h
1 #ifndef __PHANA_H__
2 #define __PHANA_H__
3 
4 #include <fun4all/SubsysReco.h>
5 #include <string>
6 
7 //Forward declerations
8 class PHCompositeNode;
9 class PHG4HitContainer;
11 class TFile;
12 class TNtuple;
13 
14 
15 //Brief: basic ntuple and histogram creation for sim evaluation
16 class PHAna: public SubsysReco
17 {
18  public:
19  //Default constructor
20  PHAna(const std::string &name="PHAna");
21 
22  //Initialization, called for initialization
23  int Init(PHCompositeNode *);
24 
25  //Process Event, called for each event
27 
28  //End, write and close files
29  int End(PHCompositeNode *);
30 
31  //Change output filename
32  void set_filename(const char* file)
33  { if(file) _outfile = file; }
34 
35  float Square(float x){ return x*x; }
36 
37  //Flags of different kinds of outputs
38  enum Flag
39  {
40  //all disabled
41  NONE = 0,
42 
43  //truth
44  TRUTH = (1<<0),
45 
46  //histograms
47  HIST = (1<<1),
48 
49  //Sampling fractions
50  SF = (1<<2),
51 
52  //Inner HCal Towers
53  HCALIN_TOWER = (1<<3),
54 
55  //All flags ON
56  ALL = (1<<4)-1
57  };
58 
59  //Set the flag
60  //Flags should be set like set_flag(PHAna::TRUTH, true) from macro
61  void set_flag(const Flag& flag, const bool& value)
62  {
63  if(value) _flags |= flag;
64  else _flags &= (~flag);
65  }
66 
67  //User modules
70  void create_histos();
72 
73  private:
74  //output filename
76 
77  //Event counter
78  int _event;
79 
80  //Get all the nodes
81  void GetNodes(PHCompositeNode *);
82 
83  //flags
84  unsigned int _flags;
85 
86  //TNtuples
87  TNtuple* _truth;
88  TNtuple* _sf;
89  TNtuple* _hcalin_towers;
90 
91  //Node pointers
101 
102 
103 };
104 
105 #endif //* __PHANA_H__ *//