]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliRunAnalysis.cxx
Excluding AliAnalisysGoodies from the compilation if Root is compiled without XML...
[u/mrichter/AliRoot.git] / ANALYSIS / AliRunAnalysis.cxx
CommitLineData
c7ffd78f 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
0206ddfb 18//********************************************************
19// class AliRunAnalysis *
20// Analysis manager *
21// Author: Piotr.Skowronski@cern.ch *
22//********************************************************
23
9edefa04 24#include <TDirectory.h>
25
b26900d0 26#include "AliRunAnalysis.h"
c7ffd78f 27#include "AliLog.h"
0206ddfb 28#include "AliAnalysis.h"
b26900d0 29#include "AliEventCut.h"
a5556ea5 30#include "AliReader.h"
b26900d0 31
b26900d0 32
33ClassImp(AliRunAnalysis)
34AliRunAnalysis::AliRunAnalysis():
2c95548d 35 TTask("RunAnalysis","Alice Analysis Manager"),
36 fAnalysies(10),
a5556ea5 37 fReader(0x0),
b26900d0 38 fEventCut(0x0),
a5556ea5 39 fCutOnSim(kFALSE),
40 fCutOnRec(kTRUE)
b26900d0 41{
42 //ctor
43}
44/*********************************************************/
45
46AliRunAnalysis::~AliRunAnalysis()
47{
48 //dtor
a5556ea5 49 delete fReader;
b26900d0 50 delete fEventCut;
51}
52/*********************************************************/
53
54Int_t AliRunAnalysis::Run()
55{
56 //makes analysis
b26900d0 57
2c95548d 58 if (fReader == 0x0)
59 {
c7ffd78f 60 AliError("Reader is not set");
2c95548d 61 return 1;
62 }
63 TDirectory* cwd = gDirectory;
64 Int_t nanal = fAnalysies.GetEntries();
c7ffd78f 65 AliDebug(1,Form("There are %d analyses",nanal));
b26900d0 66 /******************************/
67 /* Init Event */
68 /******************************/
c7ffd78f 69 AliDebug(1,"Intializing analyses...");
2c95548d 70 for (Int_t an = 0; an < nanal; an++)
71 {
a5556ea5 72 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
c7ffd78f 73 AliDebug(1,Form("Intializing analysis %d,address=%#x, name=%s",
74 an, analysis, analysis->GetName()));
b26900d0 75 analysis->Init();
c7ffd78f 76 AliDebug(1,Form("Init done for analysis %d",an));
b26900d0 77 }
c7ffd78f 78 AliDebug(1,"Intializing analyses... Done.");
2c95548d 79
a5556ea5 80 while (fReader->Next() == kFALSE)
b26900d0 81 {
6e967bfd 82 AliAOD* eventrec = fReader->GetEventRec();
83 AliAOD* eventsim = fReader->GetEventSim();
84
85 /******************************/
86 /* Event Cut */
87 /******************************/
88 if ( Rejected(eventrec,eventsim) )
89 {
c7ffd78f 90 AliDebug(1,"Event rejected by Event Cut");
6e967bfd 91 continue; //Did not pass the
92 }
2c95548d 93
6e967bfd 94 /******************************/
95 /* Process Event */
96 /******************************/
c7ffd78f 97 AliDebug(1,Form("There is %d analyses",fAnalysies.GetEntries()));
2c95548d 98
6e967bfd 99 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
100 {
101 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
102 analysis->ProcessEvent(eventrec,eventsim);
103 }
b26900d0 104
a5556ea5 105 }//end of loop over events
b26900d0 106
107 /******************************/
108 /* Finish Event */
109 /******************************/
c7ffd78f 110 AliDebug(1,Form("Finishing analyses...\n There are %d anlyses",fAnalysies.GetEntries()));
9e5e23b5 111 if (cwd) cwd->cd();
a5556ea5 112 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 113 {
a5556ea5 114 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
c7ffd78f 115 AliDebug(1,Form("Calling Finish for analysis %d address %#x name=%s",
116 an, analysis,analysis->GetName()));
a5556ea5 117 analysis->Finish();
c7ffd78f 118 AliDebug(1,Form("Called Finish for analysis %d",an));
b26900d0 119 }
c7ffd78f 120 AliDebug(1,"Finishing done");
b26900d0 121
122 return 0;
123}
124/*********************************************************/
125
a5556ea5 126void AliRunAnalysis::Add(AliAnalysis* a)
b26900d0 127{
a5556ea5 128 //adds a to the list of analysis
129 fAnalysies.Add(a);
b26900d0 130}
131/*********************************************************/
132
36715d31 133void AliRunAnalysis::SetEventCut(AliEventCut* evcut)
134{
135//Sets event - makes a private copy
136 delete fEventCut;
137 if (evcut) fEventCut = (AliEventCut*)evcut->Clone();
138 else fEventCut = 0x0;
139}
140
141/*********************************************************/
142
cea0a066 143Bool_t AliRunAnalysis::Rejected(AliAOD* recevent, AliAOD* simevent)
b26900d0 144{
a5556ea5 145 //checks the event cut
146 if (fEventCut == 0x0) return kFALSE;
147
148 if (fCutOnRec)
cea0a066 149 if (fEventCut->Rejected(recevent)) return kTRUE;
a5556ea5 150
151 if (fCutOnSim)
cea0a066 152 if (fEventCut->Rejected(simevent)) return kTRUE;
a5556ea5 153
154 return kFALSE;
b26900d0 155}