]>
Commit | Line | Data |
---|---|---|
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 | ||
b26900d0 | 24 | #include "AliRunAnalysis.h" |
c7ffd78f | 25 | #include "AliLog.h" |
0206ddfb | 26 | #include "AliAnalysis.h" |
b26900d0 | 27 | #include "AliEventCut.h" |
a5556ea5 | 28 | #include "AliReader.h" |
b26900d0 | 29 | |
b26900d0 | 30 | |
31 | ClassImp(AliRunAnalysis) | |
32 | AliRunAnalysis::AliRunAnalysis(): | |
2c95548d | 33 | TTask("RunAnalysis","Alice Analysis Manager"), |
34 | fAnalysies(10), | |
a5556ea5 | 35 | fReader(0x0), |
b26900d0 | 36 | fEventCut(0x0), |
a5556ea5 | 37 | fCutOnSim(kFALSE), |
38 | fCutOnRec(kTRUE) | |
b26900d0 | 39 | { |
40 | //ctor | |
41 | } | |
42 | /*********************************************************/ | |
43 | ||
44 | AliRunAnalysis::~AliRunAnalysis() | |
45 | { | |
46 | //dtor | |
a5556ea5 | 47 | delete fReader; |
b26900d0 | 48 | delete fEventCut; |
49 | } | |
50 | /*********************************************************/ | |
51 | ||
52 | Int_t AliRunAnalysis::Run() | |
53 | { | |
54 | //makes analysis | |
b26900d0 | 55 | |
2c95548d | 56 | if (fReader == 0x0) |
57 | { | |
c7ffd78f | 58 | AliError("Reader is not set"); |
2c95548d | 59 | return 1; |
60 | } | |
61 | TDirectory* cwd = gDirectory; | |
62 | Int_t nanal = fAnalysies.GetEntries(); | |
c7ffd78f | 63 | AliDebug(1,Form("There are %d analyses",nanal)); |
b26900d0 | 64 | /******************************/ |
65 | /* Init Event */ | |
66 | /******************************/ | |
c7ffd78f | 67 | AliDebug(1,"Intializing analyses..."); |
2c95548d | 68 | for (Int_t an = 0; an < nanal; an++) |
69 | { | |
a5556ea5 | 70 | AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an); |
c7ffd78f | 71 | AliDebug(1,Form("Intializing analysis %d,address=%#x, name=%s", |
72 | an, analysis, analysis->GetName())); | |
b26900d0 | 73 | analysis->Init(); |
c7ffd78f | 74 | AliDebug(1,Form("Init done for analysis %d",an)); |
b26900d0 | 75 | } |
c7ffd78f | 76 | AliDebug(1,"Intializing analyses... Done."); |
2c95548d | 77 | |
a5556ea5 | 78 | while (fReader->Next() == kFALSE) |
b26900d0 | 79 | { |
6e967bfd | 80 | AliAOD* eventrec = fReader->GetEventRec(); |
81 | AliAOD* eventsim = fReader->GetEventSim(); | |
82 | ||
83 | /******************************/ | |
84 | /* Event Cut */ | |
85 | /******************************/ | |
86 | if ( Rejected(eventrec,eventsim) ) | |
87 | { | |
c7ffd78f | 88 | AliDebug(1,"Event rejected by Event Cut"); |
6e967bfd | 89 | continue; //Did not pass the |
90 | } | |
2c95548d | 91 | |
6e967bfd | 92 | /******************************/ |
93 | /* Process Event */ | |
94 | /******************************/ | |
c7ffd78f | 95 | AliDebug(1,Form("There is %d analyses",fAnalysies.GetEntries())); |
2c95548d | 96 | |
6e967bfd | 97 | for (Int_t an = 0; an < fAnalysies.GetEntries(); an++) |
98 | { | |
99 | AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an); | |
100 | analysis->ProcessEvent(eventrec,eventsim); | |
101 | } | |
b26900d0 | 102 | |
a5556ea5 | 103 | }//end of loop over events |
b26900d0 | 104 | |
105 | /******************************/ | |
106 | /* Finish Event */ | |
107 | /******************************/ | |
c7ffd78f | 108 | AliDebug(1,Form("Finishing analyses...\n There are %d anlyses",fAnalysies.GetEntries())); |
9e5e23b5 | 109 | if (cwd) cwd->cd(); |
a5556ea5 | 110 | for (Int_t an = 0; an < fAnalysies.GetEntries(); an++) |
b26900d0 | 111 | { |
a5556ea5 | 112 | AliAnalysis* analysis = (AliAnalysis*)fAnalysies.At(an); |
c7ffd78f | 113 | AliDebug(1,Form("Calling Finish for analysis %d address %#x name=%s", |
114 | an, analysis,analysis->GetName())); | |
a5556ea5 | 115 | analysis->Finish(); |
c7ffd78f | 116 | AliDebug(1,Form("Called Finish for analysis %d",an)); |
b26900d0 | 117 | } |
c7ffd78f | 118 | AliDebug(1,"Finishing done"); |
b26900d0 | 119 | |
120 | return 0; | |
121 | } | |
122 | /*********************************************************/ | |
123 | ||
a5556ea5 | 124 | void AliRunAnalysis::Add(AliAnalysis* a) |
b26900d0 | 125 | { |
a5556ea5 | 126 | //adds a to the list of analysis |
127 | fAnalysies.Add(a); | |
b26900d0 | 128 | } |
129 | /*********************************************************/ | |
130 | ||
36715d31 | 131 | void AliRunAnalysis::SetEventCut(AliEventCut* evcut) |
132 | { | |
133 | //Sets event - makes a private copy | |
134 | delete fEventCut; | |
135 | if (evcut) fEventCut = (AliEventCut*)evcut->Clone(); | |
136 | else fEventCut = 0x0; | |
137 | } | |
138 | ||
139 | /*********************************************************/ | |
140 | ||
cea0a066 | 141 | Bool_t AliRunAnalysis::Rejected(AliAOD* recevent, AliAOD* simevent) |
b26900d0 | 142 | { |
a5556ea5 | 143 | //checks the event cut |
144 | if (fEventCut == 0x0) return kFALSE; | |
145 | ||
146 | if (fCutOnRec) | |
cea0a066 | 147 | if (fEventCut->Rejected(recevent)) return kTRUE; |
a5556ea5 | 148 | |
149 | if (fCutOnSim) | |
cea0a066 | 150 | if (fEventCut->Rejected(simevent)) return kTRUE; |
a5556ea5 | 151 | |
152 | return kFALSE; | |
b26900d0 | 153 | } |