]>
Commit | Line | Data |
---|---|---|
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 | |
39 | ClassImp(AliTRDclusterizer) | |
40 | ||
41 | //_____________________________________________________________________________ | |
42 | AliTRDclusterizer::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 | //_____________________________________________________________________________ | |
57 | AliTRDclusterizer::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 | //_____________________________________________________________________________ |
dd9a6ee3 | 72 | AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c) |
8230f242 | 73 | { |
74 | // | |
75 | // AliTRDclusterizer copy constructor | |
76 | // | |
77 | ||
dd9a6ee3 | 78 | ((AliTRDclusterizer &) c).Copy(*this); |
8230f242 | 79 | |
80 | } | |
81 | ||
f7336fa3 | 82 | //_____________________________________________________________________________ |
83 | AliTRDclusterizer::~AliTRDclusterizer() | |
84 | { | |
8230f242 | 85 | // |
86 | // AliTRDclusterizer destructor | |
87 | // | |
f7336fa3 | 88 | |
f7336fa3 | 89 | } |
90 | ||
8230f242 | 91 | //_____________________________________________________________________________ |
dd9a6ee3 | 92 | AliTRDclusterizer &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 | //_____________________________________________________________________________ | |
104 | void 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 | 118 | Bool_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 | // |
88cb7938 | 123 | fRunLoader = AliRunLoader::Open(name); |
124 | if (!fRunLoader) | |
125 | { | |
126 | Error("Open","Can not open session for file %s.",name); | |
127 | return kFALSE; | |
128 | } | |
129 | ||
130 | OpenInput(nEvent); | |
131 | OpenOutput(); | |
3e1a3ad8 | 132 | return kTRUE; |
f7336fa3 | 133 | } |
134 | ||
3e1a3ad8 | 135 | |
136 | //_____________________________________________________________________________ | |
88cb7938 | 137 | Bool_t AliTRDclusterizer::OpenOutput() |
3e1a3ad8 | 138 | { |
139 | // | |
140 | // Open the output file | |
141 | // | |
142 | ||
3e1a3ad8 | 143 | TObjArray *ioArray = 0; |
88cb7938 | 144 | |
145 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); | |
146 | loader->MakeTree("R"); | |
147 | fClusterTree = loader->TreeR(); | |
365d0374 | 148 | fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); |
3e1a3ad8 | 149 | |
3e1a3ad8 | 150 | |
151 | return kTRUE; | |
152 | ||
153 | } | |
154 | ||
155 | //_____________________________________________________________________________ | |
88cb7938 | 156 | Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent) |
f7336fa3 | 157 | { |
158 | // | |
159 | // Opens a ROOT-file with TRD-hits and reads in the digits-tree | |
160 | // | |
161 | ||
162 | // Connect the AliRoot file containing Geometry, Kine, and Hits | |
88cb7938 | 163 | fRunLoader->LoadgAlice(); |
164 | gAlice = fRunLoader->GetAliRun(); | |
f7336fa3 | 165 | |
a3c76cdc | 166 | if (!(gAlice)) { |
88cb7938 | 167 | fRunLoader->LoadgAlice(); |
168 | gAlice = fRunLoader->GetAliRun(); | |
169 | if (!(gAlice)) { | |
170 | printf("AliTRDclusterizer::OpenInput -- "); | |
171 | printf("Could not find AliRun object.\n"); | |
172 | return kFALSE; | |
173 | } | |
a3c76cdc | 174 | } |
f7336fa3 | 175 | |
176 | fEvent = nEvent; | |
177 | ||
178 | // Import the Trees for the event nEvent in the file | |
88cb7938 | 179 | fRunLoader->GetEvent(fEvent); |
180 | ||
3e1a3ad8 | 181 | // Get the TRD object |
182 | fTRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
183 | if (!fTRD) { | |
184 | printf("AliTRDclusterizer::OpenInput -- "); | |
185 | printf("No TRD detector object found\n"); | |
186 | return kFALSE; | |
187 | } | |
a3c76cdc | 188 | |
f7336fa3 | 189 | return kTRUE; |
190 | ||
191 | } | |
192 | ||
193 | //_____________________________________________________________________________ | |
793ff80c | 194 | Bool_t AliTRDclusterizer::WriteClusters(Int_t det) |
f7336fa3 | 195 | { |
196 | // | |
3e1a3ad8 | 197 | // Fills TRDcluster branch in the tree with the clusters |
793ff80c | 198 | // found in detector = det. For det=-1 writes the tree. |
a3c76cdc | 199 | // |
793ff80c | 200 | |
3e1a3ad8 | 201 | if ((det < -1) || (det >= AliTRDgeometry::Ndet())) { |
202 | printf("AliTRDclusterizer::WriteClusters -- "); | |
203 | printf("Unexpected detector index %d.\n",det); | |
204 | return kFALSE; | |
793ff80c | 205 | } |
3e1a3ad8 | 206 | |
f7336fa3 | 207 | |
3e1a3ad8 | 208 | TBranch *branch = fClusterTree->GetBranch("TRDcluster"); |
209 | if (!branch) { | |
793ff80c | 210 | TObjArray *ioArray = 0; |
3e1a3ad8 | 211 | branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); |
793ff80c | 212 | } |
213 | ||
214 | if ((det >= 0) && (det < AliTRDgeometry::Ndet())) { | |
215 | ||
3e1a3ad8 | 216 | Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast(); |
217 | TObjArray *detRecPoints = new TObjArray(400); | |
218 | ||
219 | for (Int_t i = 0; i < nRecPoints; i++) { | |
220 | AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i); | |
221 | if (det == c->GetDetector()) { | |
222 | detRecPoints->AddLast(c); | |
223 | } | |
224 | else { | |
225 | printf("AliTRDclusterizer::WriteClusters --"); | |
226 | printf("Attempt to write a cluster with unexpected detector index\n"); | |
227 | } | |
793ff80c | 228 | } |
229 | ||
3e1a3ad8 | 230 | branch->SetAddress(&detRecPoints); |
231 | fClusterTree->Fill(); | |
232 | ||
793ff80c | 233 | return kTRUE; |
3e1a3ad8 | 234 | |
793ff80c | 235 | } |
236 | ||
237 | if (det == -1) { | |
238 | ||
3e1a3ad8 | 239 | printf("AliTRDclusterizer::WriteClusters -- "); |
793ff80c | 240 | printf("Writing the cluster tree %-18s for event %d.\n" |
3e1a3ad8 | 241 | ,fClusterTree->GetName(),fEvent); |
793ff80c | 242 | |
3e1a3ad8 | 243 | fClusterTree->Write(); |
ba2e024c | 244 | |
245 | AliTRDgeometry *geo = fTRD->GetGeometry(); | |
88cb7938 | 246 | geo->SetName("TRDgeometry"); |
247 | geo->Write(); | |
248 | fPar->Write(); | |
249 | ||
793ff80c | 250 | return kTRUE; |
3e1a3ad8 | 251 | |
793ff80c | 252 | } |
253 | ||
88cb7938 | 254 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); |
255 | loader->WriteDigits("OVERWRITE"); | |
256 | ||
3e1a3ad8 | 257 | printf("AliTRDclusterizer::WriteClusters -- "); |
258 | printf("Unexpected detector index %d.\n",det); | |
259 | ||
793ff80c | 260 | return kFALSE; |
88cb7938 | 261 | |
f7336fa3 | 262 | } |
793ff80c | 263 | |
264 | ||
265 |