1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //---------------------------------------------------------------------
19 // Jet finder base class
20 // manages the search for jets
21 // Authors: jgcn@mda.cinvestav.mx
22 // andreas.morsch@cern.ch
23 // magali.estienne@subatech.in2p3.fr
24 //---------------------------------------------------------------------
26 #include <Riostream.h>
29 #include "AliJetFinder.h"
31 #include "AliAODJet.h"
32 #include "AliJetControlPlots.h"
33 #include "AliLeading.h"
34 #include "AliAODEvent.h"
35 #include "AliJetUnitArray.h"
40 ClassImp(AliJetFinder)
42 AliJetFinder::AliJetFinder():
61 fGenJets = new AliJet();
62 fLeading = new AliLeading();
66 ////////////////////////////////////////////////////////////////////////
67 AliJetFinder::~AliJetFinder()
73 // Reset and delete jets
76 fGenJets->ClearJets();
84 // reset and delete control plots
85 if (fPlots) delete fPlots;
88 ////////////////////////////////////////////////////////////////////////
89 void AliJetFinder::SetOutputFile(const char */*name*/)
92 // fOut = new TFile(name,"recreate");
95 ////////////////////////////////////////////////////////////////////////
96 void AliJetFinder::PrintJets()
98 // Print jet information
99 cout << " Jets found with jet algorithm:" << endl;
101 cout << " Jets found by pythia:" << endl;
102 fGenJets->PrintJets();
105 ////////////////////////////////////////////////////////////////////////
106 void AliJetFinder::SetPlotMode(Bool_t b)
108 // Sets the plotting mode
110 if (b && !fPlots) fPlots = new AliJetControlPlots();
113 ////////////////////////////////////////////////////////////////////////
114 TTree* AliJetFinder::MakeTreeJ(char* name)
116 // Create the tree for reconstructed jets
117 fTreeJ = new TTree(name, "AliJet");
118 fTreeJ->Branch("FoundJet", &fJets, 1000);
119 fTreeJ->Branch("GenJet", &fGenJets,1000);
120 fTreeJ->Branch("LeadingPart",&fLeading,1000);
124 ////////////////////////////////////////////////////////////////////////
125 void AliJetFinder::WriteRHeaderToFile()
127 // write reader header
128 AliJetReaderHeader *rh = fReader->GetReaderHeader();
132 ////////////////////////////////////////////////////////////////////////
133 void AliJetFinder::Run()
135 // Do some initialization
138 fReader->OpenInputFiles();
143 Int_t nFirst, nLast, option, debug, arrayInitialised;
144 nFirst = fReader->GetReaderHeader()->GetFirstEvent();
145 nLast = fReader->GetReaderHeader()->GetLastEvent();
147 option = fReader->GetReaderHeader()->GetDetector();
148 debug = fReader->GetReaderHeader()->GetDebug();
149 arrayInitialised = fReader->GetArrayInitialised();
152 for (Int_t i=nFirst;i<nLast;i++) {
153 fReader->FillMomentumArray();
154 fLeading->FindLeading(fReader);
155 fReader->GetGenJets(fGenJets);
157 if (option == 0) { // TPC with fMomentumArray
159 printf("In FindJetsC() routine: find jets with fMomentumArray !!!\n");
162 if(debug > 1) printf("In FindJets() routine: find jets with fUnitArray !!!\n");
169 if (fPlots) fPlots->FillHistos(fJets);
171 fGenJets->ClearJets();
178 fPlots->PlotHistos();
189 // The following methods have been added to allow for event steering from the outside
192 ////////////////////////////////////////////////////////////////////////
193 void AliJetFinder::ConnectTree(TTree* tree, TObject* data)
195 // Connect the input file
196 fReader->ConnectTree(tree, data);
199 ////////////////////////////////////////////////////////////////////////
200 void AliJetFinder::WriteHeaders()
203 TFile* f = new TFile("jets_local.root", "recreate");
204 WriteRHeaderToFile();
205 WriteJHeaderToFile();
209 ////////////////////////////////////////////////////////////////////////
210 Bool_t AliJetFinder::ProcessEvent()
217 Bool_t ok = fReader->FillMomentumArray();
218 if (!ok) return kFALSE;
221 fLeading->FindLeading(fReader);
224 // FindJetsC(); // V2
226 if (fPlots) fPlots->FillHistos(fJets);
228 fGenJets->ClearJets();
233 ////////////////////////////////////////////////////////////////////////
234 Bool_t AliJetFinder::ProcessEvent2()
238 // Charged only or charged+neutral jets
241 TRefArray* ref = new TRefArray();
242 Bool_t procid = kFALSE;
243 Bool_t ok = fReader->ExecTasks(procid,ref);
245 // Delete reference pointer
246 if (!ok) {delete ref; return kFALSE;}
249 fLeading->FindLeading(fReader);
253 Int_t nEntRef = ref->GetEntries();
255 for(Int_t i=0; i<nEntRef; i++)
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);
262 ((AliJetUnitArray*)ref->At(i))->SetUnitSignalFlag(kBad);
263 ((AliJetUnitArray*)ref->At(i))->SetUnitSignalFlagC(kTRUE,kBad);
264 ((AliJetUnitArray*)ref->At(i))->SetUnitDetectorFlag(kTpc);
265 ((AliJetUnitArray*)ref->At(i))->SetUnitFlag(kOutJet);
266 ((AliJetUnitArray*)ref->At(i))->ClearUnitTrackRef();
269 AliJetUnitArray* uA = (AliJetUnitArray*)ref->At(i);
270 uA->ResetBit(kIsReferenced);
274 // Delete the reference pointer
278 if (fPlots) fPlots->FillHistos(fJets);
280 fGenJets->ClearJets();
286 ////////////////////////////////////////////////////////////////////////
287 void AliJetFinder::FinishRun()
292 fPlots->PlotHistos();
304 ////////////////////////////////////////////////////////////////////////
305 void AliJetFinder::AddJet(AliAODJet p)
307 // Add new jet to the list
308 new ((*fAODjets)[fNAODjets++]) AliAODJet(p);
311 ////////////////////////////////////////////////////////////////////////
312 void AliJetFinder::ConnectAOD(AliAODEvent* aod)
314 // Connect to the AOD
315 fAODjets = aod->GetJets();
318 ////////////////////////////////////////////////////////////////////////
319 void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname)
322 fAODjets = dynamic_cast<TClonesArray*>(aod->FindListObject(bname));
323 // how is this is reset? Cleared?