]>
Commit | Line | Data |
---|---|---|
99e5fe42 | 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 | **************************************************************************/ | |
83a444b1 | 15 | |
52ff852a | 16 | /* $Id$ */ |
17 | ||
99e5fe42 | 18 | //--------------------------------------------------------------------- |
19 | // Jet finder base class | |
20 | // manages the search for jets | |
7d0f353c | 21 | // Authors: jgcn@mda.cinvestav.mx |
22 | // andreas.morsch@cern.ch | |
99e5fe42 | 23 | //--------------------------------------------------------------------- |
24 | ||
25 | #include <Riostream.h> | |
26 | #include <TFile.h> | |
1d27ecd2 | 27 | #include <TClonesArray.h> |
28 | ||
99e5fe42 | 29 | #include "AliJetFinder.h" |
30 | #include "AliJet.h" | |
1d27ecd2 | 31 | #include "AliAODJet.h" |
99e5fe42 | 32 | #include "AliJetReader.h" |
33 | #include "AliJetReaderHeader.h" | |
34 | #include "AliJetControlPlots.h" | |
35 | #include "AliLeading.h" | |
1d27ecd2 | 36 | #include "AliAODEvent.h" |
99e5fe42 | 37 | |
99e5fe42 | 38 | ClassImp(AliJetFinder) |
39 | ||
1b7d5d7e | 40 | AliJetFinder::AliJetFinder(): |
eaabc21f | 41 | fTreeJ(0), |
7d0f353c | 42 | fPlotMode(kFALSE), |
43 | fJets(0), | |
44 | fGenJets(0), | |
45 | fLeading(0), | |
46 | fReader(0x0), | |
19e6695b | 47 | fHeader(0x0), |
1d27ecd2 | 48 | fAODjets(0x0), |
49 | fNAODjets(0), | |
7d0f353c | 50 | fPlots(0x0), |
51 | fOut(0x0) | |
52 | ||
99e5fe42 | 53 | { |
99e5fe42 | 54 | // Constructor |
655dbb2b | 55 | fJets = new AliJet(); |
99e5fe42 | 56 | fGenJets = new AliJet(); |
57 | fLeading = new AliLeading(); | |
1d27ecd2 | 58 | fAODjets = 0; |
99e5fe42 | 59 | } |
60 | ||
99e5fe42 | 61 | //////////////////////////////////////////////////////////////////////// |
62 | ||
63 | AliJetFinder::~AliJetFinder() | |
64 | { | |
99e5fe42 | 65 | // destructor |
99e5fe42 | 66 | // here reset and delete jets |
67 | fJets->ClearJets(); | |
68 | delete fJets; | |
69 | fGenJets->ClearJets(); | |
70 | delete fGenJets; | |
71 | // close file | |
72 | if (fOut) { | |
73 | fOut->Close(); | |
74 | fOut->Delete(); | |
75 | } | |
76 | delete fOut; | |
77 | // reset and delete control plots | |
78 | if (fPlots) delete fPlots; | |
99e5fe42 | 79 | } |
80 | ||
99e5fe42 | 81 | //////////////////////////////////////////////////////////////////////// |
82 | ||
1d27ecd2 | 83 | void AliJetFinder::SetOutputFile(const char */*name*/) |
99e5fe42 | 84 | { |
eaabc21f | 85 | // opens output file |
1d27ecd2 | 86 | // fOut = new TFile(name,"recreate"); |
99e5fe42 | 87 | } |
88 | ||
99e5fe42 | 89 | //////////////////////////////////////////////////////////////////////// |
90 | ||
91 | void AliJetFinder::PrintJets() | |
92 | { | |
83a444b1 | 93 | // Print jet information |
99e5fe42 | 94 | cout << " Jets found with jet algorithm:" << endl; |
95 | fJets->PrintJets(); | |
96 | cout << " Jets found by pythia:" << endl; | |
97 | fGenJets->PrintJets(); | |
98 | } | |
99 | ||
99e5fe42 | 100 | //////////////////////////////////////////////////////////////////////// |
101 | ||
102 | void AliJetFinder::SetPlotMode(Bool_t b) | |
103 | { | |
83a444b1 | 104 | // Sets the plotting mode |
99e5fe42 | 105 | fPlotMode=b; |
106 | if (b && !fPlots) fPlots = new AliJetControlPlots(); | |
107 | } | |
108 | ||
109 | //////////////////////////////////////////////////////////////////////// | |
eaabc21f | 110 | TTree* AliJetFinder::MakeTreeJ(char* name) |
99e5fe42 | 111 | { |
eaabc21f | 112 | // Create the tree for reconstructed jets |
eaabc21f | 113 | fTreeJ = new TTree(name, "AliJet"); |
114 | fTreeJ->Branch("FoundJet", &fJets, 1000); | |
115 | fTreeJ->Branch("GenJet", &fGenJets,1000); | |
116 | fTreeJ->Branch("LeadingPart",&fLeading,1000); | |
117 | return fTreeJ; | |
99e5fe42 | 118 | } |
119 | ||
120 | //////////////////////////////////////////////////////////////////////// | |
121 | ||
122 | void AliJetFinder::WriteRHeaderToFile() | |
123 | { | |
124 | // write reader header | |
76c48857 | 125 | AliJetReaderHeader *rh = fReader->GetReaderHeader(); |
126 | rh->Write(); | |
99e5fe42 | 127 | } |
128 | ||
99e5fe42 | 129 | //////////////////////////////////////////////////////////////////////// |
130 | ||
99e5fe42 | 131 | |
132 | void AliJetFinder::Run() | |
133 | { | |
7d0f353c | 134 | // Do some initialization |
99e5fe42 | 135 | Init(); |
99e5fe42 | 136 | // connect files |
137 | fReader->OpenInputFiles(); | |
138 | ||
139 | // write headers | |
7d0f353c | 140 | WriteHeaders(); |
99e5fe42 | 141 | // loop over events |
b45b0c92 | 142 | Int_t nFirst, nLast, option, debug, arrayInitialised; |
99e5fe42 | 143 | nFirst = fReader->GetReaderHeader()->GetFirstEvent(); |
b45b0c92 | 144 | nLast = fReader->GetReaderHeader()->GetLastEvent(); |
145 | ||
146 | option = fReader->GetReaderHeader()->GetDetector(); | |
147 | debug = fReader->GetReaderHeader()->GetDebug(); | |
148 | arrayInitialised = fReader->GetArrayInitialised(); | |
149 | ||
99e5fe42 | 150 | // loop over events |
151 | for (Int_t i=nFirst;i<nLast;i++) { | |
152 | fReader->FillMomentumArray(i); | |
153 | fLeading->FindLeading(fReader); | |
7d0f353c | 154 | fReader->GetGenJets(fGenJets); |
b45b0c92 | 155 | |
156 | if (option == 0) { // TPC with fMomentumArray | |
157 | if(debug > 1) | |
158 | printf("In FindJetsTPC() routine: find jets with fMomentumArray !!!\n"); | |
159 | FindJetsTPC(); | |
160 | } else { | |
1d27ecd2 | 161 | if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n"); |
162 | FindJets(); | |
b45b0c92 | 163 | } |
eaabc21f | 164 | if (fOut) { |
165 | fOut->cd(); | |
eaabc21f | 166 | } |
167 | ||
83a444b1 | 168 | if (fPlots) fPlots->FillHistos(fJets); |
99e5fe42 | 169 | fLeading->Reset(); |
170 | fGenJets->ClearJets(); | |
171 | Reset(); | |
172 | } | |
b45b0c92 | 173 | |
99e5fe42 | 174 | // write out |
175 | if (fPlots) { | |
176 | fPlots->Normalize(); | |
177 | fPlots->PlotHistos(); | |
178 | } | |
179 | if (fOut) { | |
180 | fOut->cd(); | |
181 | fPlots->Write(); | |
182 | fOut->Close(); | |
183 | } | |
184 | } | |
7d0f353c | 185 | |
186 | ||
187 | // | |
188 | // The following methods have been added to allow for event steering from the outside | |
189 | // | |
190 | ||
f3f3617d | 191 | void AliJetFinder::ConnectTree(TTree* tree, TObject* data) |
7d0f353c | 192 | { |
193 | // Connect the input file | |
f3f3617d | 194 | fReader->ConnectTree(tree, data); |
7d0f353c | 195 | } |
196 | ||
197 | void AliJetFinder::WriteHeaders() | |
198 | { | |
199 | // Write the Headers | |
76c48857 | 200 | TFile* f = new TFile("jets_local.root", "recreate"); |
201 | WriteRHeaderToFile(); | |
202 | WriteJHeaderToFile(); | |
203 | f->Close(); | |
7d0f353c | 204 | } |
205 | ||
206 | ||
207 | Bool_t AliJetFinder::ProcessEvent(Long64_t entry) | |
208 | { | |
209 | // | |
210 | // Process one event | |
211 | // | |
eaabc21f | 212 | Int_t debug = fReader->GetReaderHeader()->GetDebug(); |
213 | if (debug > 0) printf("<<<<< Processing Event %5d >>>>> \n", (Int_t) entry); | |
76c48857 | 214 | |
7d0f353c | 215 | Bool_t ok = fReader->FillMomentumArray(entry); |
216 | if (!ok) return kFALSE; | |
76c48857 | 217 | |
218 | // Leading particles | |
7d0f353c | 219 | fLeading->FindLeading(fReader); |
76c48857 | 220 | // Jets |
7d0f353c | 221 | FindJets(); |
76c48857 | 222 | |
7d0f353c | 223 | if (fPlots) fPlots->FillHistos(fJets); |
224 | fLeading->Reset(); | |
225 | fGenJets->ClearJets(); | |
226 | Reset(); | |
227 | return kTRUE; | |
228 | } | |
229 | ||
230 | void AliJetFinder::FinishRun() | |
231 | { | |
232 | // Finish a run | |
eaabc21f | 233 | if (fPlots) { |
234 | fPlots->Normalize(); | |
235 | fPlots->PlotHistos(); | |
236 | } | |
237 | ||
238 | if (fOut) { | |
239 | fOut->cd(); | |
eaabc21f | 240 | if (fPlots) { |
241 | fPlots->Write(); | |
242 | } | |
243 | fOut->Close(); | |
244 | } | |
7d0f353c | 245 | } |
246 | ||
1d27ecd2 | 247 | void AliJetFinder::AddJet(AliAODJet p) |
248 | { | |
249 | // Add new jet to the list | |
250 | new ((*fAODjets)[fNAODjets++]) AliAODJet(p); | |
251 | } | |
252 | ||
253 | void AliJetFinder::ConnectAOD(AliAODEvent* aod) | |
254 | { | |
255 | // Connect to the AOD | |
256 | printf("Connect AOD \n"); | |
257 | fAODjets = aod->GetJets(); | |
258 | printf("Connect AOD %p \n", fAODjets); | |
259 | } |