New version including TOF
[u/mrichter/AliRoot.git] / ANALYSIS / AliRunAnalysis.cxx
CommitLineData
b26900d0 1#include "AliRunAnalysis.h"
2//________________________________
3///////////////////////////////////////////////////////////
4//
5// class AliRunAnalysis
6//
7//
8//
9// Piotr.Skowronski@cern.ch
10//
11///////////////////////////////////////////////////////////
12
13#include <stdlib.h>
14
15#include <TString.h>
16#include <TObjString.h>
17#include <TClass.h>
18#include <TFile.h>
19#include <TKey.h>
20#include <TObjArray.h>
21
22#include <AliRun.h>
23#include <AliRunLoader.h>
24#include <AliStack.h>
25#include <AliESDtrack.h>
26#include <AliESD.h>
27
28#include "AliEventCut.h"
a5556ea5 29#include "AliReader.h"
30#include "AliAODParticle.h"
b26900d0 31
b26900d0 32
33ClassImp(AliRunAnalysis)
34AliRunAnalysis::AliRunAnalysis():
91757255 35 TTask("RunAnalysis","Alice Analysis Manager") ,
a5556ea5 36 fReader(0x0),
b26900d0 37 fEventCut(0x0),
a5556ea5 38 fCutOnSim(kFALSE),
39 fCutOnRec(kTRUE)
b26900d0 40{
41 //ctor
42}
43/*********************************************************/
44
45AliRunAnalysis::~AliRunAnalysis()
46{
47 //dtor
a5556ea5 48 delete fEventCut;
49 delete fReader;
b26900d0 50 delete fEventCut;
51}
52/*********************************************************/
53
54Int_t AliRunAnalysis::Run()
55{
56 //makes analysis
b26900d0 57
a5556ea5 58 if (fReader == 0x0)
59 {
60 Error("Run","Reader is not set");
61 return 1;
62 }
b26900d0 63 /******************************/
64 /* Init Event */
65 /******************************/
a5556ea5 66 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 67 {
a5556ea5 68 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
b26900d0 69 analysis->Init();
70 }
a5556ea5 71
72 while (fReader->Next() == kFALSE)
b26900d0 73 {
a5556ea5 74 AliAOD* eventsim = fReader->GetEventSim();
75 AliAOD* eventrec = fReader->GetEventRec();
b26900d0 76
b26900d0 77 /******************************/
78 /* Event Cut */
79 /******************************/
a5556ea5 80 if ( Pass(eventrec,eventsim) )
b26900d0 81 {
a5556ea5 82 if (AliAODParticle::GetDebug()) Info("Run","Event rejected by Event Cut");
83 continue; //Did not pass the
b26900d0 84 }
85 /******************************/
86 /* Process Event */
87 /******************************/
a5556ea5 88 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 89 {
a5556ea5 90 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
91 analysis->ProcessEvent(eventsim,eventrec);
b26900d0 92 }
b26900d0 93
a5556ea5 94 }//end of loop over events
b26900d0 95
96 /******************************/
97 /* Finish Event */
98 /******************************/
a5556ea5 99 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 100 {
a5556ea5 101 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
102 analysis->Finish();
b26900d0 103 }
104
105 return 0;
106}
107/*********************************************************/
108
a5556ea5 109void AliRunAnalysis::Add(AliAnalysis* a)
b26900d0 110{
a5556ea5 111 //adds a to the list of analysis
112 fAnalysies.Add(a);
b26900d0 113}
114/*********************************************************/
115
a5556ea5 116Bool_t AliRunAnalysis::Pass(AliAOD* recevent, AliAOD* simevent)
b26900d0 117{
a5556ea5 118 //checks the event cut
119 if (fEventCut == 0x0) return kFALSE;
120
121 if (fCutOnRec)
122 if (fEventCut->Pass(recevent)) return kTRUE;
123
124 if (fCutOnSim)
125 if (fEventCut->Pass(simevent)) return kTRUE;
126
127 return kFALSE;
b26900d0 128}