]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAnalysisTaskAddObject.cxx
added run dependent corrections on T for calibration, removed old method
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskAddObject.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2009, 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 //
20 //   Test task to add an object to the new AliESDfriends file
21 //
22 // /////////////////////////////////////////////////////////////
23
24 #include <TTree.h>
25 #include <TChain.h>
26 #include <TFile.h>
27 #include <TH1D.h>
28
29 #include "AliLog.h"
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"
37
38
39 ClassImp(AliAnalysisTaskAddObject)
40
41
42 //________________________________________________________________________
43 AliAnalysisTaskAddObject::AliAnalysisTaskAddObject():
44 AliAnalysisTask(),
45 fESDInput(0x0),
46 fESDfriendInput(0x0),
47 fESDhandler(0x0),
48 fh(0x0)
49 {
50         // Dummy Constructor
51         
52 }
53
54 //________________________________________________________________________
55 AliAnalysisTaskAddObject::AliAnalysisTaskAddObject(const char* name):
56 AliAnalysisTask(name,"Adding an object"),
57 fESDInput(0),
58 fESDfriendInput(0),
59 fESDhandler(0x0),
60 fh(0x0)
61 {
62         // Constructor
63         
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());  
71 }
72
73 //________________________________________________________________________
74 AliAnalysisTaskAddObject::~AliAnalysisTaskAddObject()
75 {
76
77         // dtor
78         if (fh){
79                 delete fh;
80                 fh = 0x0;
81         }
82 }  
83
84 //______________________________________________________________________________
85 void AliAnalysisTaskAddObject::ConnectInputData(Option_t* /*option*/)
86 {
87         //
88         // Connect the input data
89         //
90
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());
95     
96         if (fESDhandler) {
97                 fESDInput = fESDhandler->GetEvent();
98         } else {
99                 AliFatal("No ESD input event handler connected") ; 
100         }
101 }
102 //________________________________________________________________________
103 void AliAnalysisTaskAddObject::CreateOutputObjects()
104 {
105         //
106         // Create the output container
107         //
108         //OpenFile(0,"UPDATE");
109         fh = new TH1D("fh1","Integrated Length",100,0,1000);
110         return;
111 }
112
113 //________________________________________________________________________
114 void AliAnalysisTaskAddObject::Exec(Option_t */*option*/)
115 {
116
117         //      if (fDebug > 1) {
118         Long64_t entry = fESDhandler->GetReadEntry();
119         AliDebug(2,Form("AliAnalysisTaskAddObject::Exec() %s ==> processing event %lld", fESDhandler->GetTree()->GetCurrentFile()->GetName(),entry));
120         //}  
121         fESDInput = fESDhandler->GetEvent();
122         if(!fESDInput) {
123                 printf("AliAnalysisTaskAddObject::Exec(): no ESD \n");
124                 return;
125         } 
126         for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){
127                 AliESDtrack* t = fESDInput->GetTrack(i);
128                 Double_t l = t->GetIntegratedLength();
129                 fh->Fill(l);
130         }
131         PostData(0,fh);
132         return;
133 }
134
135 //________________________________________________________________________
136 void AliAnalysisTaskAddObject::Terminate(Option_t */*option*/)
137 {
138         // Terminate analysis
139         //
140         AliDebug(2,"AliAnalysisTaskAddObject: Terminate() \n");
141         
142         return;
143 }