* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
+
+/* $Id$ */
#include <TROOT.h>
#include <TSystem.h>
#include <TInterpreter.h>
#include <TChain.h>
-#include <TH1.h>
+#include <TFile.h>
+#include <TList.h>
#include "AliAnalysisTaskJets.h"
+#include "AliAnalysisManager.h"
#include "AliJetFinder.h"
+#include "AliJetHeader.h"
+#include "AliJetHistos.h"
+#include "AliESDEvent.h"
#include "AliESD.h"
+#include "AliAODEvent.h"
+#include "AliAODHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliESDInputHandler.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
+
ClassImp(AliAnalysisTaskJets)
////////////////////////////////////////////////////////////////////////
AliAnalysisTaskJets::AliAnalysisTaskJets():
- fDebug(0),
- fJetFinder(0x0),
- fChain(0x0),
- fESD(0x0),
- fTreeJ(0x0)
+ AliAnalysisTaskSE(),
+ fConfigFile("ConfigJetAnalysis.C"),
+ fNonStdBranch(""),
+ fJetFinder(0x0),
+ fHistos(0x0),
+ fListOfHistos(0x0)
{
// Default constructor
}
AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
- AliAnalysisTask(name, "AnalysisTaskJets"),
- fDebug(0),
+ AliAnalysisTaskSE(name),
+ fConfigFile("ConfigJetAnalysis.C"),
+ fNonStdBranch(""),
fJetFinder(0x0),
- fChain(0x0),
- fESD(0x0),
- fTreeJ(0x0)
+ fHistos(0x0),
+ fListOfHistos(0x0)
{
// Default constructor
- DefineInput (0, TChain::Class());
- DefineOutput(0, TTree::Class());
+ DefineOutput(1, TList::Class());
}
-void AliAnalysisTaskJets::CreateOutputObjects()
+void AliAnalysisTaskJets::UserCreateOutputObjects()
{
// Create the output container
- fTreeJ = fJetFinder->MakeTreeJ("TreeJ");
+//
+ if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
+
+
+
+ if(fNonStdBranch.Length()==0){
+ // Connec default AOD to jet finder
+ fJetFinder->ConnectAOD(AODEvent());
+ }
+ else{
+ // Create a new branch for jets...
+ // how is this is reset cleared in the UserExec....
+ // Can this be handled by the framework?
+ TClonesArray *tca = new TClonesArray("AliAODJet", 0);
+ tca->SetName(fNonStdBranch);
+ AddAODBranch("TClonesArray",&tca);
+ fJetFinder->ConnectAODNonStd(AODEvent(),fNonStdBranch.Data());
+ }
+ // Histograms
+ OpenFile(1);
+ fListOfHistos = new TList();
+ fHistos = new AliJetHistos();
+ fHistos->AddHistosToList(fListOfHistos);
+
+ // Add the JetFinderInforamtion to the Outputlist
+ AliJetHeader *fH = fJetFinder->GetHeader();
+ // Compose a characteristic output name
+ // with the name of the output branch
+ if(fH){
+ if(fNonStdBranch.Length()==0){
+ fH->SetName("AliJetHeader_jets");
+ }
+ else{
+ fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data()));
+ }
+ }
+ OutputTree()->GetUserInfo()->Add(fH);
}
void AliAnalysisTaskJets::Init()
if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
// Call configuration file
- gROOT->LoadMacro("ConfigJetAnalysis.C");
+ gROOT->LoadMacro(fConfigFile);
fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
// Initialise Jet Analysis
fJetFinder->Init();
+ // Write header information to local file
+ fJetFinder->WriteHeaders();
}
-void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
-{
-// Connect the input data
-//
- if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
- char ** address = (char **)GetBranchAddress(0, "ESD");
+
+
- if (address) {
- fESD = (AliESD*)(*address);
- }
- else {
- fESD = new AliESD();
- SetBranchAddress(0, "ESD", &fESD); // first task taking the branch enables it
- }
- fChain = (TChain*)GetInputData(0);
- fJetFinder->ConnectTree(fChain, fESD);
- fJetFinder->WriteHeaders();
-}
-void AliAnalysisTaskJets::Exec(Option_t */*option*/)
+void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
{
-// Execute analysis for current event
-//
- Long64_t ientry = fChain->GetReadEntry();
- if (fDebug > 1) printf("Analysing event # %5d \n", (Int_t) ientry);
- fJetFinder->ProcessEvent(ientry);
- PostData(0, fTreeJ);
+ // Execute analysis for current event
+ //
+
+
+ // Fill control histos
+ TClonesArray* jarray = 0;
+ if(fNonStdBranch.Length()==0){
+ jarray = AODEvent()->GetJets();
+ }
+ else{
+ jarray = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
+ jarray->Delete(); // this is our responsibility, clear before filling again
+ }
+
+ fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
+ fJetFinder->ProcessEvent();
+
+ fHistos->FillHistos(jarray);
+ // Post the data
+ PostData(1, fListOfHistos);
}
void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
// Terminate analysis
//
if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
-
- if (fJetFinder) fJetFinder->FinishRun();
+// if (fJetFinder) fJetFinder->FinishRun();
}