]>
Commit | Line | Data |
---|---|---|
e5b96aa0 | 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 | **************************************************************************/ | |
f1a3e20a | 15 | |
16 | /* $Id$ */ | |
8838ab7a | 17 | #include <Riostream.h> |
e5b96aa0 | 18 | #include <TROOT.h> |
19 | #include <TSystem.h> | |
20 | #include <TInterpreter.h> | |
21 | #include <TChain.h> | |
76c48857 | 22 | #include <TFile.h> |
22003a60 | 23 | #include <TList.h> |
e5b96aa0 | 24 | |
25 | #include "AliAnalysisTaskJets.h" | |
1d27ecd2 | 26 | #include "AliAnalysisManager.h" |
e5b96aa0 | 27 | #include "AliJetFinder.h" |
99c8d2ad | 28 | #include "AliJetHeader.h" |
8838ab7a | 29 | #include "AliJetReader.h" |
30 | #include "AliJetReaderHeader.h" | |
22003a60 | 31 | #include "AliJetHistos.h" |
1b307662 | 32 | #include "AliESDEvent.h" |
7f7091b8 | 33 | #include "AliESD.h" |
1d27ecd2 | 34 | #include "AliAODEvent.h" |
35 | #include "AliAODHandler.h" | |
691685d6 | 36 | #include "AliMCEventHandler.h" |
9ff7671d | 37 | #include "AliESDInputHandler.h" |
7f7091b8 | 38 | #include "AliMCEvent.h" |
691685d6 | 39 | #include "AliStack.h" |
1d27ecd2 | 40 | |
e5b96aa0 | 41 | |
42 | ClassImp(AliAnalysisTaskJets) | |
43 | ||
44 | //////////////////////////////////////////////////////////////////////// | |
45 | ||
19e6695b | 46 | AliAnalysisTaskJets::AliAnalysisTaskJets(): |
8838ab7a | 47 | AliAnalysisTaskSE(), |
48 | fConfigFile("ConfigJetAnalysis.C"), | |
49 | fNonStdBranch(""), | |
4aa71b6f | 50 | fJetFinder(0x0), |
51 | fHistos(0x0), | |
8838ab7a | 52 | fListOfHistos(0x0), |
53 | fChain(0x0), | |
54 | fOpt(0) | |
19e6695b | 55 | { |
56 | // Default constructor | |
57 | } | |
58 | ||
e5b96aa0 | 59 | AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name): |
8838ab7a | 60 | AliAnalysisTaskSE(name), |
61 | fConfigFile("ConfigJetAnalysis.C"), | |
62 | fNonStdBranch(""), | |
63 | fJetFinder(0x0), | |
64 | fHistos(0x0), | |
65 | fListOfHistos(0x0), | |
66 | fChain(0x0), | |
67 | fOpt(0) | |
e5b96aa0 | 68 | { |
69 | // Default constructor | |
8838ab7a | 70 | DefineOutput(1, TList::Class()); |
eaabc21f | 71 | } |
72 | ||
8838ab7a | 73 | AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name, TChain* chain): |
74 | AliAnalysisTaskSE(name), | |
75 | fConfigFile("ConfigJetAnalysis.C"), | |
76 | fNonStdBranch(""), | |
77 | fJetFinder(0x0), | |
78 | fHistos(0x0), | |
79 | fListOfHistos(0x0), | |
80 | fChain(chain), | |
81 | fOpt(0) | |
eaabc21f | 82 | { |
8838ab7a | 83 | // Default constructor |
84 | DefineOutput(1, TList::Class()); | |
85 | } | |
4aa71b6f | 86 | |
8838ab7a | 87 | //---------------------------------------------------------------- |
88 | void AliAnalysisTaskJets::UserCreateOutputObjects() | |
89 | { | |
90 | // Create the output container | |
91 | // | |
92 | if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n"); | |
93 | ||
94 | if(fNonStdBranch.Length()==0) | |
95 | { | |
4aa71b6f | 96 | // Connec default AOD to jet finder |
97 | fJetFinder->ConnectAOD(AODEvent()); | |
98 | } | |
8838ab7a | 99 | else |
100 | { | |
4aa71b6f | 101 | // Create a new branch for jets... |
8838ab7a | 102 | // how is this reset? -> cleared in the UserExec.... |
4aa71b6f | 103 | // Can this be handled by the framework? |
104 | TClonesArray *tca = new TClonesArray("AliAODJet", 0); | |
105 | tca->SetName(fNonStdBranch); | |
106 | AddAODBranch("TClonesArray",&tca); | |
8838ab7a | 107 | fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data()); |
108 | } | |
952b368c | 109 | AliAODPWG4JetEventBackground* evBkg = fJetFinder->GetEventBackground(); |
110 | AddAODBranch("AliAODPWG4JetEventBackground",&evBkg); | |
111 | ||
8838ab7a | 112 | // Histograms |
113 | OpenFile(1); | |
114 | fListOfHistos = new TList(); | |
115 | fHistos = new AliJetHistos(); | |
116 | fHistos->AddHistosToList(fListOfHistos); | |
117 | ||
118 | // Add the JetFinderInformation to the Outputlist | |
119 | AliJetHeader *fH = fJetFinder->GetHeader(); | |
120 | ||
121 | // Compose a characteristic output name | |
122 | // with the name of the output branch | |
123 | if(fH) { | |
124 | if(fNonStdBranch.Length()==0) { | |
125 | fH->SetName("AliJetHeader_jets"); | |
4aa71b6f | 126 | } |
8838ab7a | 127 | else { |
128 | fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data())); | |
99c8d2ad | 129 | } |
8838ab7a | 130 | } |
131 | OutputTree()->GetUserInfo()->Add(fH); | |
e5b96aa0 | 132 | } |
133 | ||
8838ab7a | 134 | //---------------------------------------------------------------- |
19e6695b | 135 | void AliAnalysisTaskJets::Init() |
e5b96aa0 | 136 | { |
8838ab7a | 137 | // Initialization |
138 | if (fDebug > 1) printf("AnalysisTaskJets::Init() \n"); | |
139 | ||
140 | // Call configuration file | |
141 | if (fConfigFile.Length()) { | |
142 | gROOT->LoadMacro(fConfigFile); | |
143 | fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()"); | |
144 | } | |
145 | AliJetReaderHeader *header = (AliJetReaderHeader*)fJetFinder->GetReader()->GetReaderHeader(); | |
146 | fOpt = header->GetDetector(); | |
147 | ||
148 | // Initialise Jet Analysis | |
149 | if(fOpt == 0) fJetFinder->Init(); | |
150 | else fJetFinder->InitTask(fChain); // V2 | |
151 | ||
152 | // Write header information to local file | |
153 | fJetFinder->WriteHeaders(); | |
19e6695b | 154 | } |
155 | ||
8838ab7a | 156 | //---------------------------------------------------------------- |
ae24a5a1 | 157 | void AliAnalysisTaskJets::UserExec(Option_t */*option*/) |
e5b96aa0 | 158 | { |
4aa71b6f | 159 | // Execute analysis for current event |
160 | // | |
4aa71b6f | 161 | // Fill control histos |
162 | TClonesArray* jarray = 0; | |
8838ab7a | 163 | |
164 | if(fNonStdBranch.Length()==0) { | |
4aa71b6f | 165 | jarray = AODEvent()->GetJets(); |
166 | } | |
8838ab7a | 167 | else { |
168 | jarray = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data())); | |
4aa71b6f | 169 | jarray->Delete(); // this is our responsibility, clear before filling again |
170 | } | |
171 | ||
172 | fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent()); | |
8838ab7a | 173 | if(fOpt==0) fJetFinder->ProcessEvent(); |
174 | else fJetFinder->ProcessEvent2(); // V2 | |
175 | ||
176 | // Fill control histos | |
4aa71b6f | 177 | fHistos->FillHistos(jarray); |
8838ab7a | 178 | |
4aa71b6f | 179 | // Post the data |
180 | PostData(1, fListOfHistos); | |
e5b96aa0 | 181 | } |
182 | ||
8838ab7a | 183 | |
184 | //************************************************************* | |
185 | ||
e5b96aa0 | 186 | void AliAnalysisTaskJets::Terminate(Option_t */*option*/) |
187 | { | |
188 | // Terminate analysis | |
189 | // | |
19e6695b | 190 | if (fDebug > 1) printf("AnalysisJets: Terminate() \n"); |
9ff7671d | 191 | // if (fJetFinder) fJetFinder->FinishRun(); |
e5b96aa0 | 192 | } |
193 |