New test macros for the analysis framework
[u/mrichter/AliRoot.git] / ANALYSIS / testEvent.h
CommitLineData
16a89872 1#ifndef Ana_Event
2#define Ana_Event
3
4//////////////////////////////////////////////////////////////////////////
5// //
6// Simple event used for a simple analysis. The event has just a //
7// TClonesArray of tracks that can be either pi+/-, protons or //
8// gammas. Some ratio of all particles are pi0's that decay in //
9// 2 gammas. //
10// //
11// The analysis classes after the definition of AnaEvent/AnaTrack are //
12// just some simple tasks: //
13// //
14// TaskGenerate - task to generate 10k events in a tree "T" split in //
15// 5 files: input_n.root //
16// TaskFilter - task to filter just gammas from the inputs and //
17// write them to a single output file //
18// TaskReco - task to reconstruct pi0's from the mixed background //
19// +signal of gammas //
20// //
21//////////////////////////////////////////////////////////////////////////
22
23#include "TTree.h"
24#include "TFile.h"
25#include "TRandom.h"
26#include "TGeoMatrix.h"
27
28#include "AliAnalysisTask.h"
29#include "AliAnalysisManager.h"
30#include "AliAnalysisDataContainer.h"
31
32class AnaTrack;
33class AnaEvent;
34
35//
36// This task will work without using TSelector functionality
37// No Init() or Terminate() need to be defined. No input/output
38// slots are defined; th task will simply create several output files
39//
40//______________________________________________________________________________
41class TaskGenerate : public AliAnalysisTask {
42
43public:
44 TaskGenerate(const char *name) : AliAnalysisTask(name,"") {}
45 virtual ~TaskGenerate() {}
46
47 virtual void Exec(Option_t *option);
48 ClassDef(TaskGenerate,0) // Simple generator
49};
50
51// The next task is filtering the input events coming from a chain and having
52// more than 100 gammas. In Terminate() some histogram will be drawn
53
54//______________________________________________________________________________
55class TaskFilter : public AliAnalysisTask {
56private:
57 AnaEvent *fEvent; // Current event
58 TTree *fOutput; // Output tree
59 TList *fList; // List containing the output data
60 TH1I *fHist1; // Number of gammas per event
61 TH1I *fHist2; // Number of gammas per event
62public:
63 TaskFilter(const char *name);
64 virtual ~TaskFilter() {}
65
66 virtual void Init(Option_t *);
67 virtual void Exec(Option_t *option);
68 virtual void Terminate(Option_t *);
69 ClassDef(TaskFilter,0) // Event filter
70};
71
72// This task reconstructs pi0's for gammas coming from the same vertex
73//______________________________________________________________________________
74class TaskRecoPi0 : public AliAnalysisTask {
75private:
76 AnaEvent *fEvent; // Current event
77 TObjArray *fGammas; // Array of gammas
78 TObjArray *fPions; // Array of pi0's
79 TH1F *fHist; // Pt distrib. of reconstructed pions
80public:
81 TaskRecoPi0(const char *name);
82 virtual ~TaskRecoPi0();
83
84 virtual void Init(Option_t *);
85 virtual void Exec(Option_t *option);
86 virtual void Terminate(Option_t *);
87 ClassDef(TaskRecoPi0,0) // Pi0 reconstructor
88};
89
90//______________________________________________________________________________
91class AnaTrack : public TObject {
92
93private:
94 Double_t fPx; // X component of the momentum
95 Double_t fPy; // Y component of the momentum
96 Double_t fPz; // Z component of the momentum
97 Float_t fMass; // The mass of this particle
98 Int_t fCharge; // Charge
99 Double_t fVertex[3]; // Track vertex position
100
101public:
102 AnaTrack() {}
103 AnaTrack(Double_t random, Double_t *vertex=0);
104 AnaTrack(Double_t px, Double_t py, Double_t pz, Float_t mass, Int_t charge,
105 Double_t vx, Double_t vy, Double_t vz) : TObject(), fPx(px), fPy(py), fPz(pz), fMass(mass), fCharge(charge)
106 {fVertex[0]=vx; fVertex[1]=vy; fVertex[2]=vz;}
107 virtual ~AnaTrack() {}
108
109 Bool_t Decay(Double_t &px1, Double_t &py1, Double_t &pz1,
110 Double_t &px2, Double_t &py2, Double_t &pz2);
111 Double_t GetPx() const {return fPx;}
112 Double_t GetPy() const {return fPy;}
113 Double_t GetPz() const {return fPz;}
114 void SetPx(Double_t px) {fPx = px;}
115 void SetPy(Double_t py) {fPy = py;}
116 void SetPz(Double_t pz) {fPz = pz;}
117 Double_t GetPt() const {return TMath::Sqrt(fPx*fPx + fPy*fPy);}
118 Double_t GetP() const {return TMath::Sqrt(fPx*fPx + fPy*fPy + fPz*fPz);}
119 Double_t GetMass() const {return fMass;}
120 Double_t GetCharge() const {return fCharge;}
121 Double_t GetVertex(Int_t i) const {return (i<3)?fVertex[i]:0.;}
122
123 ClassDef(AnaTrack,1) // A simple track
124};
125
126//______________________________________________________________________________
127class AnaEvent : public TObject {
128
129private:
130 Int_t fEventNumber; // Event number
131 Int_t fNtracks; // Number of tracks
132 TClonesArray *fTracks; //-> Array of all tracks
133
134 static TClonesArray *fgTracks;
135
136public:
137 AnaEvent();
138 virtual ~AnaEvent() {Clear();}
139
140 AnaTrack *AddTrack(Double_t rnd, Double_t *vert=0);
141 Int_t Build(Int_t ev);
142 static void CreateEvents(Int_t nevents, const char *filename);
143 void Clear(Option_t *option="");
144
145 Int_t GetEvtNumber() const {return fEventNumber;}
146 Int_t GetNtracks() const {return fNtracks;}
147 AnaTrack *GetTrack(Int_t i) {return (AnaTrack*)fTracks->At(i);}
148
149ClassDef(AnaEvent,1) // An event with tracks
150};
151
152#endif