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