]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliJetFinder.cxx
Coverity fixes.
[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"
1d27ecd2 30#include "AliAODJet.h"
1d27ecd2 31#include "AliAODEvent.h"
8838ab7a 32#include "AliJetUnitArray.h"
952b368c 33#include "AliJetReaderHeader.h"
34#include "AliJetHeader.h"
35#include "AliJetReader.h"
b8bf1e90 36#include "AliAODJetEventBackground.h"
be6e5811 37
99e5fe42 38ClassImp(AliJetFinder)
39
1b7d5d7e 40AliJetFinder::AliJetFinder():
7d0f353c 41 fReader(0x0),
19e6695b 42 fHeader(0x0),
1d27ecd2 43 fAODjets(0x0),
952b368c 44 fNAODjets(0),
dd677561 45 fAODEvBkg(0),
46 fDebug(0)
99e5fe42 47{
8838ab7a 48 //
99e5fe42 49 // Constructor
8838ab7a 50 //
1d27ecd2 51 fAODjets = 0;
99e5fe42 52}
53
99e5fe42 54////////////////////////////////////////////////////////////////////////
99e5fe42 55AliJetFinder::~AliJetFinder()
56{
8838ab7a 57 //
58 // Destructor
59 //
99e5fe42 60}
61
99e5fe42 62
99e5fe42 63
64////////////////////////////////////////////////////////////////////////
99e5fe42 65void AliJetFinder::WriteRHeaderToFile()
66{
67 // write reader header
76c48857 68 AliJetReaderHeader *rh = fReader->GetReaderHeader();
69 rh->Write();
99e5fe42 70}
71
7d0f353c 72
8838ab7a 73////////////////////////////////////////////////////////////////////////
f3f3617d 74void AliJetFinder::ConnectTree(TTree* tree, TObject* data)
7d0f353c 75{
76 // Connect the input file
f3f3617d 77 fReader->ConnectTree(tree, data);
7d0f353c 78}
79
8838ab7a 80////////////////////////////////////////////////////////////////////////
7d0f353c 81void AliJetFinder::WriteHeaders()
82{
83 // Write the Headers
76c48857 84 TFile* f = new TFile("jets_local.root", "recreate");
85 WriteRHeaderToFile();
86 WriteJHeaderToFile();
87 f->Close();
7d0f353c 88}
89
8838ab7a 90////////////////////////////////////////////////////////////////////////
ae24a5a1 91Bool_t AliJetFinder::ProcessEvent()
7d0f353c 92{
8838ab7a 93 //
94 // Process one event
95 // Charged only jets
96 //
97
98 Bool_t ok = fReader->FillMomentumArray();
99 if (!ok) return kFALSE;
8838ab7a 100 // Jets
101 FindJets(); // V1
8838ab7a 102 Reset();
103 return kTRUE;
7d0f353c 104}
105
8838ab7a 106////////////////////////////////////////////////////////////////////////
107Bool_t AliJetFinder::ProcessEvent2()
108{
109 //
110 // Process one event
111 // Charged only or charged+neutral jets
112 //
113
114 TRefArray* ref = new TRefArray();
115 Bool_t procid = kFALSE;
116 Bool_t ok = fReader->ExecTasks(procid,ref);
117
118 // Delete reference pointer
119 if (!ok) {delete ref; return kFALSE;}
8838ab7a 120 // Jets
121 FindJets();
122
42b0ac89 123 Int_t nEntRef = ref->GetEntries();
8838ab7a 124
125 for(Int_t i=0; i<nEntRef; i++)
126 {
127 // Reset the UnitArray content which were referenced
128 ((AliJetUnitArray*)ref->At(i))->SetUnitTrackID(0);
129 ((AliJetUnitArray*)ref->At(i))->SetUnitEnergy(0.);
130 ((AliJetUnitArray*)ref->At(i))->SetUnitCutFlag(kPtSmaller);
131 ((AliJetUnitArray*)ref->At(i))->SetUnitCutFlag2(kPtSmaller);
8838ab7a 132 ((AliJetUnitArray*)ref->At(i))->SetUnitSignalFlag(kBad);
be6e5811 133 ((AliJetUnitArray*)ref->At(i))->SetUnitSignalFlagC(kTRUE,kBad);
8838ab7a 134 ((AliJetUnitArray*)ref->At(i))->SetUnitDetectorFlag(kTpc);
135 ((AliJetUnitArray*)ref->At(i))->SetUnitFlag(kOutJet);
be6e5811 136 ((AliJetUnitArray*)ref->At(i))->ClearUnitTrackRef();
8838ab7a 137
138 // Reset process ID
139 AliJetUnitArray* uA = (AliJetUnitArray*)ref->At(i);
140 uA->ResetBit(kIsReferenced);
141 uA->SetUniqueID(0);
142 }
143
144 // Delete the reference pointer
145 ref->Delete();
146 delete ref;
147
8838ab7a 148 Reset();
149
150 return kTRUE;
151}
152
7d0f353c 153
1d27ecd2 154void AliJetFinder::AddJet(AliAODJet p)
155{
8838ab7a 156// Add new jet to the list
1d27ecd2 157 new ((*fAODjets)[fNAODjets++]) AliAODJet(p);
158}
159
160void AliJetFinder::ConnectAOD(AliAODEvent* aod)
161{
162// Connect to the AOD
1d27ecd2 163 fAODjets = aod->GetJets();
bcec7a80 164 fAODEvBkg = (AliAODJetEventBackground*)(aod->FindListObject(AliAODJetEventBackground::StdBranchName()));
1d27ecd2 165}
4aa71b6f 166
8838ab7a 167////////////////////////////////////////////////////////////////////////
4aa71b6f 168void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname)
169{
170
171 fAODjets = dynamic_cast<TClonesArray*>(aod->FindListObject(bname));
bcec7a80 172 fAODEvBkg = (AliAODJetEventBackground*)(aod->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),bname)));
173 // how is this is reset? Cleared? -> by the UserExec!!
4aa71b6f 174}
8838ab7a 175