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