SetOwner added
[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"
afa8b37b 30#include "AliVAODParticle.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 fReader;
b26900d0 49 delete fEventCut;
50}
51/*********************************************************/
52
53Int_t AliRunAnalysis::Run()
54{
55 //makes analysis
b26900d0 56
a5556ea5 57 if (fReader == 0x0)
58 {
59 Error("Run","Reader is not set");
60 return 1;
61 }
b26900d0 62 /******************************/
63 /* Init Event */
64 /******************************/
a5556ea5 65 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 66 {
a5556ea5 67 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
b26900d0 68 analysis->Init();
69 }
a5556ea5 70
71 while (fReader->Next() == kFALSE)
b26900d0 72 {
a5556ea5 73 AliAOD* eventsim = fReader->GetEventSim();
74 AliAOD* eventrec = fReader->GetEventRec();
b26900d0 75
b26900d0 76 /******************************/
77 /* Event Cut */
78 /******************************/
a5556ea5 79 if ( Pass(eventrec,eventsim) )
b26900d0 80 {
afa8b37b 81 if (AliVAODParticle::GetDebug()) Info("Run","Event rejected by Event Cut");
a5556ea5 82 continue; //Did not pass the
b26900d0 83 }
84 /******************************/
85 /* Process Event */
86 /******************************/
a5556ea5 87 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 88 {
a5556ea5 89 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
afa8b37b 90 analysis->ProcessEvent(eventrec,eventsim);
b26900d0 91 }
b26900d0 92
a5556ea5 93 }//end of loop over events
b26900d0 94
95 /******************************/
96 /* Finish Event */
97 /******************************/
a5556ea5 98 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 99 {
a5556ea5 100 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
101 analysis->Finish();
b26900d0 102 }
103
104 return 0;
105}
106/*********************************************************/
107
a5556ea5 108void AliRunAnalysis::Add(AliAnalysis* a)
b26900d0 109{
a5556ea5 110 //adds a to the list of analysis
111 fAnalysies.Add(a);
b26900d0 112}
113/*********************************************************/
114
36715d31 115void AliRunAnalysis::SetEventCut(AliEventCut* evcut)
116{
117//Sets event - makes a private copy
118 delete fEventCut;
119 if (evcut) fEventCut = (AliEventCut*)evcut->Clone();
120 else fEventCut = 0x0;
121}
122
123/*********************************************************/
124
a5556ea5 125Bool_t AliRunAnalysis::Pass(AliAOD* recevent, AliAOD* simevent)
b26900d0 126{
a5556ea5 127 //checks the event cut
128 if (fEventCut == 0x0) return kFALSE;
129
130 if (fCutOnRec)
131 if (fEventCut->Pass(recevent)) return kTRUE;
132
133 if (fCutOnSim)
134 if (fEventCut->Pass(simevent)) return kTRUE;
135
136 return kFALSE;
b26900d0 137}