Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaAnalysisObject.h
Go to the documentation of this file.
1#ifndef Podd_THaAnalysisObject_h_
2#define Podd_THaAnalysisObject_h_
3
5//
6// THaAnalysisObject
7//
9
10#include "TNamed.h"
11#include "THaGlobals.h"
12#include "TDatime.h"
13#include "Database.h"
14#include "DataType.h"
15#include "OptionalType.h"
16
17#include <vector>
18#include <string>
19#include <cstdio>
20#include <map>
21#include <cstdarg>
22#include <utility>
23
24class THaEvData; //needed by derived classes
25class TList;
26class TVector3;
27class THaRunBase;
28class THaOutput;
29class TObjArray;
30
31class THaAnalysisObject : public TNamed {
32
33public:
34 enum EStatus { kOK = 0, kInitError = -8, kFileError = -9, kNotinit = -10 };
37
38 THaAnalysisObject(); // only for ROOT I/O
43
44 virtual ~THaAnalysisObject();
45
46 virtual Int_t Begin( THaRunBase* r=nullptr );
47 virtual void Clear( Option_t* ="" ) {} // override TNamed::Clear()
48 virtual Int_t End( THaRunBase* r=nullptr );
49 virtual const char* GetDBFileName() const;
50 const char* GetClassName() const;
51 const char* GetConfig() const { return fConfig.Data(); }
52 Int_t GetDebug() const { return fDebug; }
53 const char* GetPrefix() const { return fPrefix; }
54 TString GetPrefixName() const;
55 EStatus Init();
56 virtual EStatus Init( const TDatime& run_time );
57 Bool_t IsInit() const { return IsOK(); }
58 Bool_t IsOK() const { return (fStatus == kOK); }
59
60 TDatime GetInitDate() const { return fInitDate; }
61
62 void SetConfig( const char* label );
63 virtual void SetDebug( Int_t level );
64 virtual void SetName( const char* name );
65 virtual void SetNameTitle( const char* name, const char* title );
66 EStatus Status() const { return fStatus; }
67
68 virtual Int_t InitOutput( THaOutput * );
69 Bool_t IsOKOut() const { return fOKOut; }
70 virtual FILE* OpenFile( const TDatime& date );
71 virtual FILE* OpenRunDBFile( const TDatime& date );
72 virtual void Print( Option_t* opt="" ) const;
73
74 // For backwards compatibility
75 static Int_t LoadDB( FILE* file, const TDatime& date,
76 const DBRequest* request, const char* prefix,
77 Int_t search = 0,
78 const char* here = "THaAnalysisObject::LoadDB" )
79 {
80 return Podd::LoadDatabase(file, date, request, prefix, search, here);
81 }
82
83 // Geometry utility functions
84 static void GeoToSph( Double_t th_geo, Double_t ph_geo,
85 Double_t& th_sph, Double_t& ph_sph );
86 static void SphToGeo( Double_t th_sph, Double_t ph_sph,
87 Double_t& th_geo, Double_t& ph_geo );
88
89 static Bool_t IntersectPlaneWithRay( const TVector3& xax,
90 const TVector3& yax,
91 const TVector3& org,
92 const TVector3& ray_start,
93 const TVector3& ray_vect,
94 Double_t& length,
95 TVector3& intersect );
96
97 static Int_t DefineVarsFromList( const void* list,
98 EType type, EMode mode,
99 const char* def_prefix,
100 const TObject* obj,
101 const char* prefix,
102 const char* here,
103 const char* comment_subst = "" );
104
105 static void PrintObjects( Option_t* opt="" );
106
107protected:
108
110
111 // General status variables
112 char* fPrefix; // Name prefix for global variables
113 EStatus fStatus; // Initialization status flag
114 Int_t fDebug; // Debug level
115 Bool_t fIsInit; // Flag indicating that ReadDatabase done
116 Bool_t fIsSetup; // Flag indicating that DefineVariables done.
117 TString fConfig; // Configuration to use from database
118 UInt_t fProperties;// Properties of this object (see EProperties)
119 Bool_t fOKOut; // Flag indicating object-output prepared
120 TDatime fInitDate; // Date passed to Init
121
122 std::map<std::string,UInt_t> fMessages; // Warning messages & count
123 UInt_t fNEventsWithWarnings; // Events with warnings
124
125 TObject* fExtra; // Additional member data (for binary compat.)
126
127 virtual Int_t DefineVariables( EMode mode = kDefine );
128 Int_t DefineVarsFromList( const VarDef* list,
129 EMode mode = kDefine,
130 const char* def_prefix = "",
131 const char* comment_subst = "" ) const;
132 Int_t DefineVarsFromList( const RVarDef* list, EMode mode,
133 const char* def_prefix = "",
134 const char* comment_subst = "" ) const;
135 Int_t DefineVarsFromList( const void* list, EType type,
136 EMode mode, const char* def_prefix = "",
137 const char* comment_subst = "" ) const;
138
139 virtual void DoError( int level, const char* location,
140 const char* fmt, va_list va) const;
141
142 THaAnalysisObject* FindModule( const char* name, const char* classname,
143 bool do_error = true );
144
145 virtual const char* Here( const char* ) const;
146 virtual const char* ClassNameHere( const char* ) const;
147 Int_t LoadDB( FILE* f, const TDatime& date,
148 const DBRequest* req, Int_t search = 0 ) const;
149 void MakePrefix( const char* basename );
150 virtual void MakePrefix();
151 virtual Int_t ReadDatabase( const TDatime& date );
152 virtual Int_t ReadRunDatabase( const TDatime& date );
154
155#ifdef WITH_DEBUG
156 void DebugPrint( const DBRequest* list ) const;
157
158 template <typename T> // available for Double_t, Float_t, UInt_t and Int_t
159 static void WriteValue( T val, int p=0, int w=5 );
160#endif
161
162 // Only derived classes may construct
163 THaAnalysisObject( const char* name, const char* description );
164
165private:
167
168 static TList* fgModules; // List of all currently existing Analysis Modules
169
170 ClassDef(THaAnalysisObject,2) //ABC for a data analysis object
171};
172
173//____________ inline functions _______________________________________________
174
175#endif
int Int_t
unsigned int UInt_t
bool Bool_t
double Double_t
const char Option_t
#define ClassDef(name, id)
#define BIT(n)
static const char *const here
Definition THaVar.cxx:64
virtual void SetDebug(Int_t level)
static void GeoToSph(Double_t th_geo, Double_t ph_geo, Double_t &th_sph, Double_t &ph_sph)
virtual Int_t ReadRunDatabase(const TDatime &date)
virtual void SetNameTitle(const char *name, const char *title)
virtual Int_t Begin(THaRunBase *r=nullptr)
static void SphToGeo(Double_t th_sph, Double_t ph_sph, Double_t &th_geo, Double_t &ph_geo)
THaAnalysisObject(const THaAnalysisObject &)=delete
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
const char * GetConfig() const
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual Int_t InitOutput(THaOutput *)
Bool_t IsOKOut() const
virtual const char * Here(const char *) const
THaAnalysisObject & operator=(const THaAnalysisObject &)=delete
const char * GetPrefix() const
THaAnalysisObject * FindModule(const char *name, const char *classname, bool do_error=true)
virtual Int_t ReadDatabase(const TDatime &date)
std::map< std::string, UInt_t > fMessages
virtual const char * ClassNameHere(const char *) const
virtual void MakePrefix()
TString GetPrefixName() const
TDatime GetInitDate() const
static Bool_t IntersectPlaneWithRay(const TVector3 &xax, const TVector3 &yax, const TVector3 &org, const TVector3 &ray_start, const TVector3 &ray_vect, Double_t &length, TVector3 &intersect)
void SetConfig(const char *label)
virtual FILE * OpenRunDBFile(const TDatime &date)
const char * GetClassName() const
virtual Int_t DefineVariables(EMode mode=kDefine)
EStatus Status() const
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Bool_t IsOK() const
Int_t GetDebug() const
static TList * fgModules
THaAnalysisObject(const THaAnalysisObject &&)=delete
virtual FILE * OpenFile(const TDatime &date)
static void PrintObjects(Option_t *opt="")
virtual void Clear(Option_t *="")
virtual const char * GetDBFileName() const
Int_t DefineVariablesWrapper(EMode mode=kDefine)
THaAnalysisObject & operator=(const THaAnalysisObject &&)=delete
virtual void SetName(const char *name)
virtual void Print(Option_t *opt="") const
Bool_t IsInit() const
const char * Data() const