]>
Commit | Line | Data |
---|---|---|
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 | ||
32 | class AnaTrack; | |
33 | class 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 | //______________________________________________________________________________ | |
41 | class TaskGenerate : public AliAnalysisTask { | |
42 | ||
43 | public: | |
44 | TaskGenerate(const char *name) : AliAnalysisTask(name,"") {} | |
45 | virtual ~TaskGenerate() {} | |
46 | ||
47 | virtual void Exec(Option_t *option); | |
c52c2132 | 48 | ClassDef(TaskGenerate,1) // Simple generator |
16a89872 | 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 | //______________________________________________________________________________ | |
55 | class TaskFilter : public AliAnalysisTask { | |
56 | private: | |
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 | |
62 | public: | |
c52c2132 | 63 | TaskFilter() : AliAnalysisTask(), fEvent(0), fOutput(0), fList(0), fHist1(0), fHist2(0) {} |
16a89872 | 64 | TaskFilter(const char *name); |
65 | virtual ~TaskFilter() {} | |
66 | ||
c52c2132 | 67 | virtual void ConnectInputData(Option_t *); |
68 | virtual void CreateOutputObjects(); | |
16a89872 | 69 | virtual void Exec(Option_t *option); |
70 | virtual void Terminate(Option_t *); | |
c52c2132 | 71 | ClassDef(TaskFilter,1) // Event filter |
16a89872 | 72 | }; |
73 | ||
74 | // This task reconstructs pi0's for gammas coming from the same vertex | |
75 | //______________________________________________________________________________ | |
76 | class TaskRecoPi0 : public AliAnalysisTask { | |
77 | private: | |
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 | |
82 | public: | |
c52c2132 | 83 | TaskRecoPi0() : AliAnalysisTask(), fEvent(0), fGammas(0), fPions(0), fHist(0) {} |
16a89872 | 84 | TaskRecoPi0(const char *name); |
85 | virtual ~TaskRecoPi0(); | |
86 | ||
c52c2132 | 87 | virtual void ConnectInputData(Option_t *); |
88 | virtual void CreateOutputObjects(); | |
16a89872 | 89 | virtual void Exec(Option_t *option); |
90 | virtual void Terminate(Option_t *); | |
c52c2132 | 91 | ClassDef(TaskRecoPi0,1) // Pi0 reconstructor |
16a89872 | 92 | }; |
93 | ||
94 | //______________________________________________________________________________ | |
95 | class AnaTrack : public TObject { | |
96 | ||
97 | private: | |
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 | |
104 | ||
105 | public: | |
106 | AnaTrack() {} | |
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() {} | |
112 | ||
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.;} | |
126 | ||
127 | ClassDef(AnaTrack,1) // A simple track | |
128 | }; | |
129 | ||
130 | //______________________________________________________________________________ | |
131 | class AnaEvent : public TObject { | |
132 | ||
133 | private: | |
134 | Int_t fEventNumber; // Event number | |
135 | Int_t fNtracks; // Number of tracks | |
136 | TClonesArray *fTracks; //-> Array of all tracks | |
137 | ||
138 | static TClonesArray *fgTracks; | |
139 | ||
140 | public: | |
141 | AnaEvent(); | |
142 | virtual ~AnaEvent() {Clear();} | |
143 | ||
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=""); | |
148 | ||
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);} | |
152 | ||
153 | ClassDef(AnaEvent,1) // An event with tracks | |
154 | }; | |
155 | ||
156 | #endif |