4 //////////////////////////////////////////////////////////////////////////
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 //
11 // The analysis classes after the definition of AnaEvent/AnaTrack are //
12 // just some simple tasks: //
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 //
21 //////////////////////////////////////////////////////////////////////////
26 #include "TGeoMatrix.h"
28 #include "AliAnalysisTask.h"
29 #include "AliAnalysisManager.h"
30 #include "AliAnalysisDataContainer.h"
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
40 //______________________________________________________________________________
41 class TaskGenerate : public AliAnalysisTask {
44 TaskGenerate(const char *name) : AliAnalysisTask(name,"") {}
45 virtual ~TaskGenerate() {}
47 virtual void Exec(Option_t *option);
48 ClassDef(TaskGenerate,1) // Simple generator
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
54 //______________________________________________________________________________
55 class TaskFilter : public AliAnalysisTask {
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
63 TaskFilter() : AliAnalysisTask(), fEvent(0), fOutput(0), fList(0), fHist1(0), fHist2(0) {}
64 TaskFilter(const char *name);
65 virtual ~TaskFilter() {}
67 virtual void ConnectInputData(Option_t *);
68 virtual void CreateOutputObjects();
69 virtual void Exec(Option_t *option);
70 virtual void Terminate(Option_t *);
71 ClassDef(TaskFilter,1) // Event filter
74 // This task reconstructs pi0's for gammas coming from the same vertex
75 //______________________________________________________________________________
76 class TaskRecoPi0 : public AliAnalysisTask {
78 AnaEvent *fEvent; // Current event
79 TObjArray *fGammas; // Array of gammas
80 TObjArray *fPions; // Array of pi0's
81 TH1F *fHist; // Pt distrib. of reconstructed pions
83 TaskRecoPi0() : AliAnalysisTask(), fEvent(0), fGammas(0), fPions(0), fHist(0) {}
84 TaskRecoPi0(const char *name);
85 virtual ~TaskRecoPi0();
87 virtual void ConnectInputData(Option_t *);
88 virtual void CreateOutputObjects();
89 virtual void Exec(Option_t *option);
90 virtual void Terminate(Option_t *);
91 ClassDef(TaskRecoPi0,1) // Pi0 reconstructor
94 //______________________________________________________________________________
95 class AnaTrack : public TObject {
98 Double_t fPx; // X component of the momentum
99 Double_t fPy; // Y component of the momentum
100 Double_t fPz; // Z component of the momentum
101 Float_t fMass; // The mass of this particle
102 Int_t fCharge; // Charge
103 Double_t fVertex[3]; // Track vertex position
107 AnaTrack(Double_t random, Double_t *vertex=0);
108 AnaTrack(Double_t px, Double_t py, Double_t pz, Float_t mass, Int_t charge,
109 Double_t vx, Double_t vy, Double_t vz) : TObject(), fPx(px), fPy(py), fPz(pz), fMass(mass), fCharge(charge)
110 {fVertex[0]=vx; fVertex[1]=vy; fVertex[2]=vz;}
111 virtual ~AnaTrack() {}
113 Bool_t Decay(Double_t &px1, Double_t &py1, Double_t &pz1,
114 Double_t &px2, Double_t &py2, Double_t &pz2);
115 Double_t GetPx() const {return fPx;}
116 Double_t GetPy() const {return fPy;}
117 Double_t GetPz() const {return fPz;}
118 void SetPx(Double_t px) {fPx = px;}
119 void SetPy(Double_t py) {fPy = py;}
120 void SetPz(Double_t pz) {fPz = pz;}
121 Double_t GetPt() const {return TMath::Sqrt(fPx*fPx + fPy*fPy);}
122 Double_t GetP() const {return TMath::Sqrt(fPx*fPx + fPy*fPy + fPz*fPz);}
123 Double_t GetMass() const {return fMass;}
124 Double_t GetCharge() const {return fCharge;}
125 Double_t GetVertex(Int_t i) const {return (i<3)?fVertex[i]:0.;}
127 ClassDef(AnaTrack,1) // A simple track
130 //______________________________________________________________________________
131 class AnaEvent : public TObject {
134 Int_t fEventNumber; // Event number
135 Int_t fNtracks; // Number of tracks
136 TClonesArray *fTracks; //-> Array of all tracks
138 static TClonesArray *fgTracks;
142 virtual ~AnaEvent() {Clear();}
144 AnaTrack *AddTrack(Double_t rnd, Double_t *vert=0);
145 Int_t Build(Int_t ev);
146 static void CreateEvents(Int_t nevents, const char *filename);
147 void Clear(Option_t *option="");
149 Int_t GetEvtNumber() const {return fEventNumber;}
150 Int_t GetNtracks() const {return fNtracks;}
151 AnaTrack *GetTrack(Int_t i) {return (AnaTrack*)fTracks->At(i);}
153 ClassDef(AnaEvent,1) // An event with tracks