1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //----------------------------------------------------------------------------------
17 // Class AliRsnAnalysisSimpleTask
18 // ------------------------
19 // Reader for conversion of ESD output into the internal format
20 // used for resonance study.
22 // original author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
24 // adapted for Analysis Framework
25 // by : R. Vernet (email: renaud.vernet@cern.ch)
26 //----------------------------------------------------------------------------------
31 #include "AliVEvent.h"
32 #include "AliMCEventHandler.h"
33 #include "AliInputEventHandler.h"
34 #include "AliAnalysisManager.h"
36 #include "AliMCEvent.h"
38 #include "AliRsnEvent.h"
39 #include "AliRsnReader.h"
40 #include "AliRsnPID.h"
41 #include "AliRsnPairSimple.h"
42 #include "AliRsnAnalyzerSimple.h"
43 #include "AliRsnAnalysisSimpleTask.h"
45 ClassImp(AliRsnAnalysisSimpleTask)
47 //_____________________________________________________________________________
48 AliRsnAnalysisSimpleTask::AliRsnAnalysisSimpleTask() :
59 // Default constructor (not recommended)
63 //_____________________________________________________________________________
64 AliRsnAnalysisSimpleTask::AliRsnAnalysisSimpleTask(const char *name) :
65 AliAnalysisTask(name, ""),
75 // Working constructor (recommended)
78 DefineInput (0, TChain::Class());
79 DefineOutput (0, TList::Class());
82 //_____________________________________________________________________________
83 AliRsnAnalysisSimpleTask::AliRsnAnalysisSimpleTask(const AliRsnAnalysisSimpleTask& obj) :
89 fAnalyzer(obj.fAnalyzer),
94 // Copy constructor (not recommended)
98 //_____________________________________________________________________________
99 AliRsnAnalysisSimpleTask& AliRsnAnalysisSimpleTask::operator=(const AliRsnAnalysisSimpleTask& /*obj*/)
102 // Assignment operator (not recommended)
105 AliInfo("Not implemented. Avoid using the assignment operator");
109 //_____________________________________________________________________________
110 void AliRsnAnalysisSimpleTask::CreateOutputObjects()
113 // Create the output container
116 // check for presence of NECESSARY data-members
118 AliFatal("Event reader not initialized. Impossible to continue. Aborting with fatal error.");
122 AliFatal("PID manager not initialized. Impossible to continue. Aborting with fatal error.");
126 AliFatal("Analysis manager not initialized. Impossible to continue. Aborting with fatal error.");
132 // output histogram list
133 fHistograms = new TList(0);
135 // initialize analyzer
138 // store all histograms in the pairs into the list
139 TObjArray *array = fAnalyzer->GetPairs();
140 AliRsnPairSimple *pair;
142 TObjArrayIter iter(array);
143 while ( (pair = (AliRsnPairSimple*)iter.Next()) ) {
144 fHistograms->AddLast((TObject*)pair->GetHistogram());
145 fHistograms->AddLast((TObject*)pair->GetHistogramMC());
148 array = fAnalyzer->GetMixPairs();
150 TObjArrayIter iter(array);
151 while ( (pair = (AliRsnPairSimple*)iter.Next()) ) {
152 fHistograms->AddLast((TObject*)pair->GetHistogram());
153 fHistograms->AddLast((TObject*)pair->GetHistogramMC());
158 //_____________________________________________________________________________
159 void AliRsnAnalysisSimpleTask::ConnectInputData(Option_t *)
162 // Connect the input data
166 AliInputEventHandler *inH = dynamic_cast<AliInputEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
168 AliError("Could not get InputHandler");
171 fEvent = inH->GetEvent();
175 AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
177 AliError("Could not get MCInputHandler");
180 fMC = mcH->MCEvent();
184 //_____________________________________________________________________________
185 void AliRsnAnalysisSimpleTask::Exec(Option_t */*option*/)
188 // Loops on input container to store data of all tracks.
189 // Uses the AliRsnReader methods to save them in the output.
192 // check ESD and MC events
194 AliWarning("Event not available here");
198 AliWarning("MC event not available here");
202 // clear previous event
204 fCurrEvent = new AliRsnEvent;
207 else fCurrEvent->Clear();
209 // read event, identify
210 if (!fReader->Fill(fCurrEvent, fEvent, fMC)) AliWarning("Failed reading");
211 if (!fPID->Identify(fCurrEvent)) AliWarning("Failed PID");
212 AliInfo(Form("Collected %d tracks", fCurrEvent->GetMultiplicity()));
214 // process event with analyzer
215 fPID->Identify(fCurrEvent);
216 fAnalyzer->Process(fCurrEvent);
218 // post collected data
219 PostData (0, fHistograms);
222 //_____________________________________________________________________________
223 void AliRsnAnalysisSimpleTask::Terminate(Option_t */*option*/)
226 // Terminate analysis
229 AliDebug(1, "Terminating");
230 AliAnalysisTask::Terminate();