]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliJetFinder.cxx
Obsolete code removed.
[u/mrichter/AliRoot.git] / JETAN / AliJetFinder.cxx
CommitLineData
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
8838ab7a 23// magali.estienne@subatech.in2p3.fr
99e5fe42 24//---------------------------------------------------------------------
25
26#include <Riostream.h>
27#include <TFile.h>
1d27ecd2 28
99e5fe42 29#include "AliJetFinder.h"
30#include "AliJet.h"
1d27ecd2 31#include "AliAODJet.h"
99e5fe42 32#include "AliJetControlPlots.h"
33#include "AliLeading.h"
1d27ecd2 34#include "AliAODEvent.h"
8838ab7a 35#include "AliJetUnitArray.h"
99e5fe42 36
be6e5811 37class TProcessID;
38class TClonesArray;
39
99e5fe42 40ClassImp(AliJetFinder)
41
1b7d5d7e 42AliJetFinder::AliJetFinder():
eaabc21f 43 fTreeJ(0),
7d0f353c 44 fPlotMode(kFALSE),
45 fJets(0),
46 fGenJets(0),
47 fLeading(0),
48 fReader(0x0),
19e6695b 49 fHeader(0x0),
1d27ecd2 50 fAODjets(0x0),
51 fNAODjets(0),
7d0f353c 52 fPlots(0x0),
53 fOut(0x0)
54
99e5fe42 55{
8838ab7a 56 //
99e5fe42 57 // Constructor
8838ab7a 58 //
59
655dbb2b 60 fJets = new AliJet();
99e5fe42 61 fGenJets = new AliJet();
62 fLeading = new AliLeading();
1d27ecd2 63 fAODjets = 0;
99e5fe42 64}
65
99e5fe42 66////////////////////////////////////////////////////////////////////////
99e5fe42 67AliJetFinder::~AliJetFinder()
68{
8838ab7a 69 //
70 // Destructor
71 //
72
73 // Reset and delete jets
99e5fe42 74 fJets->ClearJets();
75 delete fJets;
76 fGenJets->ClearJets();
77 delete fGenJets;
78 // close file
79 if (fOut) {
80 fOut->Close();
81 fOut->Delete();
82 }
83 delete fOut;
84 // reset and delete control plots
85 if (fPlots) delete fPlots;
99e5fe42 86}
87
99e5fe42 88////////////////////////////////////////////////////////////////////////
1d27ecd2 89void AliJetFinder::SetOutputFile(const char */*name*/)
99e5fe42 90{
eaabc21f 91 // opens output file
1d27ecd2 92 // fOut = new TFile(name,"recreate");
99e5fe42 93}
94
99e5fe42 95////////////////////////////////////////////////////////////////////////
99e5fe42 96void AliJetFinder::PrintJets()
97{
83a444b1 98 // Print jet information
99e5fe42 99 cout << " Jets found with jet algorithm:" << endl;
100 fJets->PrintJets();
101 cout << " Jets found by pythia:" << endl;
102 fGenJets->PrintJets();
103}
104
99e5fe42 105////////////////////////////////////////////////////////////////////////
99e5fe42 106void AliJetFinder::SetPlotMode(Bool_t b)
107{
83a444b1 108 // Sets the plotting mode
99e5fe42 109 fPlotMode=b;
110 if (b && !fPlots) fPlots = new AliJetControlPlots();
111}
112
113////////////////////////////////////////////////////////////////////////
eaabc21f 114TTree* AliJetFinder::MakeTreeJ(char* name)
99e5fe42 115{
eaabc21f 116 // Create the tree for reconstructed jets
eaabc21f 117 fTreeJ = new TTree(name, "AliJet");
118 fTreeJ->Branch("FoundJet", &fJets, 1000);
119 fTreeJ->Branch("GenJet", &fGenJets,1000);
120 fTreeJ->Branch("LeadingPart",&fLeading,1000);
121 return fTreeJ;
99e5fe42 122}
123
124////////////////////////////////////////////////////////////////////////
99e5fe42 125void AliJetFinder::WriteRHeaderToFile()
126{
127 // write reader header
76c48857 128 AliJetReaderHeader *rh = fReader->GetReaderHeader();
129 rh->Write();
99e5fe42 130}
131
99e5fe42 132////////////////////////////////////////////////////////////////////////
99e5fe42 133void AliJetFinder::Run()
134{
7d0f353c 135 // Do some initialization
99e5fe42 136 Init();
99e5fe42 137 // connect files
138 fReader->OpenInputFiles();
139
140 // write headers
7d0f353c 141 WriteHeaders();
99e5fe42 142 // loop over events
b45b0c92 143 Int_t nFirst, nLast, option, debug, arrayInitialised;
99e5fe42 144 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
b45b0c92 145 nLast = fReader->GetReaderHeader()->GetLastEvent();
146
147 option = fReader->GetReaderHeader()->GetDetector();
148 debug = fReader->GetReaderHeader()->GetDebug();
149 arrayInitialised = fReader->GetArrayInitialised();
150
99e5fe42 151 // loop over events
152 for (Int_t i=nFirst;i<nLast;i++) {
ae24a5a1 153 fReader->FillMomentumArray();
99e5fe42 154 fLeading->FindLeading(fReader);
7d0f353c 155 fReader->GetGenJets(fGenJets);
b45b0c92 156
157 if (option == 0) { // TPC with fMomentumArray
158 if(debug > 1)
8838ab7a 159 printf("In FindJetsC() routine: find jets with fMomentumArray !!!\n");
160 FindJetsC();
b45b0c92 161 } else {
8838ab7a 162 if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n");
163 FindJets();
b45b0c92 164 }
eaabc21f 165 if (fOut) {
166 fOut->cd();
eaabc21f 167 }
168
83a444b1 169 if (fPlots) fPlots->FillHistos(fJets);
99e5fe42 170 fLeading->Reset();
171 fGenJets->ClearJets();
172 Reset();
173 }
b45b0c92 174
99e5fe42 175 // write out
176 if (fPlots) {
177 fPlots->Normalize();
178 fPlots->PlotHistos();
179 }
180 if (fOut) {
181 fOut->cd();
182 fPlots->Write();
183 fOut->Close();
184 }
185}
7d0f353c 186
187
188//
189// The following methods have been added to allow for event steering from the outside
190//
191
8838ab7a 192////////////////////////////////////////////////////////////////////////
f3f3617d 193void AliJetFinder::ConnectTree(TTree* tree, TObject* data)
7d0f353c 194{
195 // Connect the input file
f3f3617d 196 fReader->ConnectTree(tree, data);
7d0f353c 197}
198
8838ab7a 199////////////////////////////////////////////////////////////////////////
7d0f353c 200void AliJetFinder::WriteHeaders()
201{
202 // Write the Headers
76c48857 203 TFile* f = new TFile("jets_local.root", "recreate");
204 WriteRHeaderToFile();
205 WriteJHeaderToFile();
206 f->Close();
7d0f353c 207}
208
8838ab7a 209////////////////////////////////////////////////////////////////////////
ae24a5a1 210Bool_t AliJetFinder::ProcessEvent()
7d0f353c 211{
8838ab7a 212 //
213 // Process one event
214 // Charged only jets
215 //
216
217 Bool_t ok = fReader->FillMomentumArray();
218 if (!ok) return kFALSE;
219
220 // Leading particles
221 fLeading->FindLeading(fReader);
222 // Jets
223 FindJets(); // V1
224 // FindJetsC(); // V2
225
226 if (fPlots) fPlots->FillHistos(fJets);
227 fLeading->Reset();
228 fGenJets->ClearJets();
229 Reset();
230 return kTRUE;
7d0f353c 231}
232
8838ab7a 233////////////////////////////////////////////////////////////////////////
234Bool_t AliJetFinder::ProcessEvent2()
235{
236 //
237 // Process one event
238 // Charged only or charged+neutral jets
239 //
240
241 TRefArray* ref = new TRefArray();
242 Bool_t procid = kFALSE;
243 Bool_t ok = fReader->ExecTasks(procid,ref);
244
245 // Delete reference pointer
246 if (!ok) {delete ref; return kFALSE;}
247
248 // Leading particles
249 fLeading->FindLeading(fReader);
250 // Jets
251 FindJets();
252
253 Int_t nEntRef = ref->GetEntries();
8838ab7a 254
255 for(Int_t i=0; i<nEntRef; i++)
256 {
257 // Reset the UnitArray content which were referenced
258 ((AliJetUnitArray*)ref->At(i))->SetUnitTrackID(0);
259 ((AliJetUnitArray*)ref->At(i))->SetUnitEnergy(0.);
260 ((AliJetUnitArray*)ref->At(i))->SetUnitCutFlag(kPtSmaller);
261 ((AliJetUnitArray*)ref->At(i))->SetUnitCutFlag2(kPtSmaller);
8838ab7a 262 ((AliJetUnitArray*)ref->At(i))->SetUnitSignalFlag(kBad);
be6e5811 263 ((AliJetUnitArray*)ref->At(i))->SetUnitSignalFlagC(kTRUE,kBad);
8838ab7a 264 ((AliJetUnitArray*)ref->At(i))->SetUnitDetectorFlag(kTpc);
265 ((AliJetUnitArray*)ref->At(i))->SetUnitFlag(kOutJet);
be6e5811 266 ((AliJetUnitArray*)ref->At(i))->ClearUnitTrackRef();
8838ab7a 267
268 // Reset process ID
269 AliJetUnitArray* uA = (AliJetUnitArray*)ref->At(i);
270 uA->ResetBit(kIsReferenced);
271 uA->SetUniqueID(0);
272 }
273
274 // Delete the reference pointer
275 ref->Delete();
276 delete ref;
277
278 if (fPlots) fPlots->FillHistos(fJets);
279 fLeading->Reset();
280 fGenJets->ClearJets();
281 Reset();
282
283 return kTRUE;
284}
285
286////////////////////////////////////////////////////////////////////////
7d0f353c 287void AliJetFinder::FinishRun()
288{
289 // Finish a run
eaabc21f 290 if (fPlots) {
291 fPlots->Normalize();
292 fPlots->PlotHistos();
293 }
294
295 if (fOut) {
296 fOut->cd();
eaabc21f 297 if (fPlots) {
298 fPlots->Write();
299 }
300 fOut->Close();
301 }
7d0f353c 302}
303
8838ab7a 304////////////////////////////////////////////////////////////////////////
1d27ecd2 305void AliJetFinder::AddJet(AliAODJet p)
306{
8838ab7a 307// Add new jet to the list
1d27ecd2 308 new ((*fAODjets)[fNAODjets++]) AliAODJet(p);
309}
310
8838ab7a 311////////////////////////////////////////////////////////////////////////
1d27ecd2 312void AliJetFinder::ConnectAOD(AliAODEvent* aod)
313{
314// Connect to the AOD
1d27ecd2 315 fAODjets = aod->GetJets();
1d27ecd2 316}
4aa71b6f 317
8838ab7a 318////////////////////////////////////////////////////////////////////////
4aa71b6f 319void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname)
320{
321
322 fAODjets = dynamic_cast<TClonesArray*>(aod->FindListObject(bname));
323 // how is this is reset? Cleared?
324}
8838ab7a 325