]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliRunAnalysis.cxx
Streamline the different messages output by the code using the AliLog, Remove warning...
[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
b26900d0 18#include "AliRunAnalysis.h"
c7ffd78f 19#include "AliLog.h"
20
b26900d0 21//________________________________
22///////////////////////////////////////////////////////////
23//
24// class AliRunAnalysis
25//
26//
27//
28// Piotr.Skowronski@cern.ch
29//
30///////////////////////////////////////////////////////////
31
32#include <stdlib.h>
33
34#include <TString.h>
35#include <TObjString.h>
36#include <TClass.h>
37#include <TFile.h>
38#include <TKey.h>
39#include <TObjArray.h>
40
41#include <AliRun.h>
42#include <AliRunLoader.h>
43#include <AliStack.h>
44#include <AliESDtrack.h>
45#include <AliESD.h>
46
9e5e23b5 47
b26900d0 48#include "AliEventCut.h"
a5556ea5 49#include "AliReader.h"
afa8b37b 50#include "AliVAODParticle.h"
b26900d0 51
b26900d0 52
53ClassImp(AliRunAnalysis)
54AliRunAnalysis::AliRunAnalysis():
2c95548d 55 TTask("RunAnalysis","Alice Analysis Manager"),
56 fAnalysies(10),
a5556ea5 57 fReader(0x0),
b26900d0 58 fEventCut(0x0),
a5556ea5 59 fCutOnSim(kFALSE),
60 fCutOnRec(kTRUE)
b26900d0 61{
62 //ctor
63}
64/*********************************************************/
65
66AliRunAnalysis::~AliRunAnalysis()
67{
68 //dtor
a5556ea5 69 delete fReader;
b26900d0 70 delete fEventCut;
71}
72/*********************************************************/
73
74Int_t AliRunAnalysis::Run()
75{
76 //makes analysis
b26900d0 77
2c95548d 78 if (fReader == 0x0)
79 {
c7ffd78f 80 AliError("Reader is not set");
2c95548d 81 return 1;
82 }
83 TDirectory* cwd = gDirectory;
84 Int_t nanal = fAnalysies.GetEntries();
c7ffd78f 85 AliDebug(1,Form("There are %d analyses",nanal));
b26900d0 86 /******************************/
87 /* Init Event */
88 /******************************/
c7ffd78f 89 AliDebug(1,"Intializing analyses...");
2c95548d 90 for (Int_t an = 0; an < nanal; an++)
91 {
a5556ea5 92 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
c7ffd78f 93 AliDebug(1,Form("Intializing analysis %d,address=%#x, name=%s",
94 an, analysis, analysis->GetName()));
b26900d0 95 analysis->Init();
c7ffd78f 96 AliDebug(1,Form("Init done for analysis %d",an));
b26900d0 97 }
c7ffd78f 98 AliDebug(1,"Intializing analyses... Done.");
2c95548d 99
a5556ea5 100 while (fReader->Next() == kFALSE)
b26900d0 101 {
6e967bfd 102 AliAOD* eventrec = fReader->GetEventRec();
103 AliAOD* eventsim = fReader->GetEventSim();
104
105 /******************************/
106 /* Event Cut */
107 /******************************/
108 if ( Rejected(eventrec,eventsim) )
109 {
c7ffd78f 110 AliDebug(1,"Event rejected by Event Cut");
6e967bfd 111 continue; //Did not pass the
112 }
2c95548d 113
6e967bfd 114 /******************************/
115 /* Process Event */
116 /******************************/
c7ffd78f 117 AliDebug(1,Form("There is %d analyses",fAnalysies.GetEntries()));
2c95548d 118
6e967bfd 119 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
120 {
121 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
122 analysis->ProcessEvent(eventrec,eventsim);
123 }
b26900d0 124
a5556ea5 125 }//end of loop over events
b26900d0 126
127 /******************************/
128 /* Finish Event */
129 /******************************/
c7ffd78f 130 AliDebug(1,Form("Finishing analyses...\n There are %d anlyses",fAnalysies.GetEntries()));
9e5e23b5 131 if (cwd) cwd->cd();
a5556ea5 132 for (Int_t an = 0; an < fAnalysies.GetEntries(); an++)
b26900d0 133 {
a5556ea5 134 AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an);
c7ffd78f 135 AliDebug(1,Form("Calling Finish for analysis %d address %#x name=%s",
136 an, analysis,analysis->GetName()));
a5556ea5 137 analysis->Finish();
c7ffd78f 138 AliDebug(1,Form("Called Finish for analysis %d",an));
b26900d0 139 }
c7ffd78f 140 AliDebug(1,"Finishing done");
b26900d0 141
142 return 0;
143}
144/*********************************************************/
145
a5556ea5 146void AliRunAnalysis::Add(AliAnalysis* a)
b26900d0 147{
a5556ea5 148 //adds a to the list of analysis
149 fAnalysies.Add(a);
b26900d0 150}
151/*********************************************************/
152
36715d31 153void AliRunAnalysis::SetEventCut(AliEventCut* evcut)
154{
155//Sets event - makes a private copy
156 delete fEventCut;
157 if (evcut) fEventCut = (AliEventCut*)evcut->Clone();
158 else fEventCut = 0x0;
159}
160
161/*********************************************************/
162
cea0a066 163Bool_t AliRunAnalysis::Rejected(AliAOD* recevent, AliAOD* simevent)
b26900d0 164{
a5556ea5 165 //checks the event cut
166 if (fEventCut == 0x0) return kFALSE;
167
168 if (fCutOnRec)
cea0a066 169 if (fEventCut->Rejected(recevent)) return kTRUE;
a5556ea5 170
171 if (fCutOnSim)
cea0a066 172 if (fEventCut->Rejected(simevent)) return kTRUE;
a5556ea5 173
174 return kFALSE;
b26900d0 175}