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