1 /**************************************************************************
2 * Copyright(c) 1998-2009, 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 **************************************************************************/
18 /////////////////////////////////////////////////////////////
20 // Test task to add an object to the new AliESDfriends file
22 // /////////////////////////////////////////////////////////////
30 #include "AliESDInputHandler.h"
31 #include "AliESDtrack.h"
32 #include "AliESDEvent.h"
33 #include "AliESDfriend.h"
34 #include "AliAnalysisTask.h"
35 #include "AliAnalysisManager.h"
36 #include "AliAnalysisTaskAddObject.h"
39 ClassImp(AliAnalysisTaskAddObject)
42 //________________________________________________________________________
43 AliAnalysisTaskAddObject::AliAnalysisTaskAddObject():
54 //________________________________________________________________________
55 AliAnalysisTaskAddObject::AliAnalysisTaskAddObject(const char* name):
56 AliAnalysisTask(name,"Adding an object"),
64 // Define input and output slots here
65 // Input slot #0 works with a TChain
66 DefineInput(0, TChain::Class());
67 // Output slot #0 writes into a TTree
68 // DefineOutput(0,TTree::Class());
69 // Output slot #1 writes into a TH1D
70 DefineOutput(0,TH1D::Class());
73 //________________________________________________________________________
74 AliAnalysisTaskAddObject::~AliAnalysisTaskAddObject()
84 //______________________________________________________________________________
85 void AliAnalysisTaskAddObject::ConnectInputData(Option_t* /*option*/)
88 // Connect the input data
91 printf("AliAnalysisTaskAddObject::ConnectInputData()\n");
92 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
93 if (!mgr) AliFatal("No analysis manager available");
94 fESDhandler = dynamic_cast<AliESDInputHandler *>(mgr->GetInputEventHandler());
97 fESDInput = fESDhandler->GetEvent();
99 AliFatal("No ESD input event handler connected") ;
102 //________________________________________________________________________
103 void AliAnalysisTaskAddObject::CreateOutputObjects()
106 // Create the output container
108 //OpenFile(0,"UPDATE");
109 fh = new TH1D("fh1","Integrated Length",100,0,1000);
113 //________________________________________________________________________
114 void AliAnalysisTaskAddObject::Exec(Option_t */*option*/)
118 Long64_t entry = fESDhandler->GetReadEntry();
119 AliDebug(2,Form("AliAnalysisTaskAddObject::Exec() %s ==> processing event %lld", fESDhandler->GetTree()->GetCurrentFile()->GetName(),entry));
121 fESDInput = fESDhandler->GetEvent();
123 printf("AliAnalysisTaskAddObject::Exec(): no ESD \n");
126 for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){
127 AliESDtrack* t = fESDInput->GetTrack(i);
128 Double_t l = t->GetIntegratedLength();
135 //________________________________________________________________________
136 void AliAnalysisTaskAddObject::Terminate(Option_t */*option*/)
138 // Terminate analysis
140 AliDebug(2,"AliAnalysisTaskAddObject: Terminate() \n");