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