]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDclusterizer.cxx
Macro to plot pathlengths of back-to-back jets. (A. Dainese)
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizer.cxx
CommitLineData
f7336fa3 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
88cb7938 16/* $Id$ */
f7336fa3 17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// TRD cluster finder base class //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
94de3818 24#include <TROOT.h>
25#include <TTree.h>
793ff80c 26#include <TFile.h>
f7336fa3 27
94de3818 28#include "AliRun.h"
88cb7938 29#include "AliRunLoader.h"
30#include "AliLoader.h"
31
f7336fa3 32#include "AliTRD.h"
33#include "AliTRDclusterizer.h"
3e1a3ad8 34#include "AliTRDcluster.h"
793ff80c 35#include "AliTRDrecPoint.h"
36#include "AliTRDgeometry.h"
5443e65e 37#include "AliTRDparameter.h"
f7336fa3 38
39ClassImp(AliTRDclusterizer)
40
41//_____________________________________________________________________________
42AliTRDclusterizer::AliTRDclusterizer():TNamed()
43{
44 //
45 // AliTRDclusterizer default constructor
46 //
47
3e1a3ad8 48 fClusterTree = NULL;
2685bf00 49 fTRD = 0;
3e1a3ad8 50 fEvent = 0;
51 fVerbose = 0;
5443e65e 52 fPar = 0;
f7336fa3 53
54}
55
56//_____________________________________________________________________________
57AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
58 :TNamed(name, title)
59{
60 //
61 // AliTRDclusterizer default constructor
62 //
63
3e1a3ad8 64 fClusterTree = NULL;
65 fEvent = 0;
66 fVerbose = 0;
5443e65e 67 fPar = 0;
f7336fa3 68
69}
70
8230f242 71//_____________________________________________________________________________
73ae7b59 72AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c):TNamed(c)
8230f242 73{
74 //
75 // AliTRDclusterizer copy constructor
76 //
77
dd9a6ee3 78 ((AliTRDclusterizer &) c).Copy(*this);
8230f242 79
80}
81
f7336fa3 82//_____________________________________________________________________________
83AliTRDclusterizer::~AliTRDclusterizer()
84{
8230f242 85 //
86 // AliTRDclusterizer destructor
87 //
f7336fa3 88
f7336fa3 89}
90
8230f242 91//_____________________________________________________________________________
dd9a6ee3 92AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
93{
94 //
95 // Assignment operator
96 //
97
98 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
99 return *this;
100
101}
102
103//_____________________________________________________________________________
104void AliTRDclusterizer::Copy(TObject &c)
8230f242 105{
106 //
107 // Copy function
108 //
109
3e1a3ad8 110 ((AliTRDclusterizer &) c).fClusterTree = NULL;
111 ((AliTRDclusterizer &) c).fEvent = 0;
112 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
5443e65e 113 ((AliTRDclusterizer &) c).fPar = 0;
8230f242 114
115}
116
f7336fa3 117//_____________________________________________________________________________
3e1a3ad8 118Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
f7336fa3 119{
120 //
3e1a3ad8 121 // Opens the AliROOT file. Output and input are in the same file
f7336fa3 122 //
19dd5b2f 123 TString evfoldname = AliConfig::fgkDefaultEventFolderName;
124 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
125 if (!fRunLoader)
126 fRunLoader = AliRunLoader::Open(name);
88cb7938 127 if (!fRunLoader)
128 {
129 Error("Open","Can not open session for file %s.",name);
130 return kFALSE;
131 }
132
133 OpenInput(nEvent);
134 OpenOutput();
3e1a3ad8 135 return kTRUE;
f7336fa3 136}
137
3e1a3ad8 138
139//_____________________________________________________________________________
88cb7938 140Bool_t AliTRDclusterizer::OpenOutput()
3e1a3ad8 141{
142 //
143 // Open the output file
144 //
145
3e1a3ad8 146 TObjArray *ioArray = 0;
88cb7938 147
148 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
149 loader->MakeTree("R");
150 fClusterTree = loader->TreeR();
365d0374 151 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
3e1a3ad8 152
3e1a3ad8 153
154 return kTRUE;
155
156}
157
158//_____________________________________________________________________________
88cb7938 159Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent)
f7336fa3 160{
161 //
162 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
163 //
164
165 // Connect the AliRoot file containing Geometry, Kine, and Hits
19dd5b2f 166 if (fRunLoader->GetAliRun() == 0x0) fRunLoader->LoadgAlice();
88cb7938 167 gAlice = fRunLoader->GetAliRun();
f7336fa3 168
a3c76cdc 169 if (!(gAlice)) {
88cb7938 170 fRunLoader->LoadgAlice();
171 gAlice = fRunLoader->GetAliRun();
172 if (!(gAlice)) {
173 printf("AliTRDclusterizer::OpenInput -- ");
174 printf("Could not find AliRun object.\n");
175 return kFALSE;
176 }
a3c76cdc 177 }
f7336fa3 178
179 fEvent = nEvent;
180
181 // Import the Trees for the event nEvent in the file
88cb7938 182 fRunLoader->GetEvent(fEvent);
183
3e1a3ad8 184 // Get the TRD object
185 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
186 if (!fTRD) {
187 printf("AliTRDclusterizer::OpenInput -- ");
188 printf("No TRD detector object found\n");
189 return kFALSE;
190 }
a3c76cdc 191
f7336fa3 192 return kTRUE;
193
194}
195
196//_____________________________________________________________________________
793ff80c 197Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
f7336fa3 198{
199 //
3e1a3ad8 200 // Fills TRDcluster branch in the tree with the clusters
793ff80c 201 // found in detector = det. For det=-1 writes the tree.
a3c76cdc 202 //
793ff80c 203
3e1a3ad8 204 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
205 printf("AliTRDclusterizer::WriteClusters -- ");
206 printf("Unexpected detector index %d.\n",det);
207 return kFALSE;
793ff80c 208 }
3e1a3ad8 209
f7336fa3 210
3e1a3ad8 211 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
212 if (!branch) {
793ff80c 213 TObjArray *ioArray = 0;
3e1a3ad8 214 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
793ff80c 215 }
216
217 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
218
3e1a3ad8 219 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
220 TObjArray *detRecPoints = new TObjArray(400);
221
222 for (Int_t i = 0; i < nRecPoints; i++) {
223 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
224 if (det == c->GetDetector()) {
225 detRecPoints->AddLast(c);
226 }
227 else {
228 printf("AliTRDclusterizer::WriteClusters --");
229 printf("Attempt to write a cluster with unexpected detector index\n");
230 }
793ff80c 231 }
232
3e1a3ad8 233 branch->SetAddress(&detRecPoints);
234 fClusterTree->Fill();
235
d9b8978b 236 delete detRecPoints;
237
793ff80c 238 return kTRUE;
3e1a3ad8 239
793ff80c 240 }
241
242 if (det == -1) {
243
19dd5b2f 244 Info("WriteClusters","Writing the cluster tree %s for event %d."
245 ,fClusterTree->GetName(),fEvent);
c630aafd 246 /*
3e1a3ad8 247 fClusterTree->Write();
ba2e024c 248 AliTRDgeometry *geo = fTRD->GetGeometry();
88cb7938 249 geo->SetName("TRDgeometry");
250 geo->Write();
c630aafd 251 fPar->Write();
252 */
253 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
254 loader->WriteRecPoints("OVERWRITE");
255
793ff80c 256 return kTRUE;
3e1a3ad8 257
793ff80c 258 }
c630aafd 259 /*
88cb7938 260 AliLoader* loader = fRunLoader->GetLoader("TRDLoader");
261 loader->WriteDigits("OVERWRITE");
c630aafd 262 */
3e1a3ad8 263 printf("AliTRDclusterizer::WriteClusters -- ");
264 printf("Unexpected detector index %d.\n",det);
265
793ff80c 266 return kFALSE;
88cb7938 267
f7336fa3 268}
793ff80c 269
270
271