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 | |
16 | /* |
17 | $Log$ |
94de3818 |
18 | Revision 1.4 2000/06/09 11:10:07 cblume |
19 | Compiler warnings and coding conventions, next round |
20 | |
dd9a6ee3 |
21 | Revision 1.3 2000/06/08 18:32:58 cblume |
22 | Make code compliant to coding conventions |
23 | |
8230f242 |
24 | Revision 1.2 2000/05/08 16:17:27 cblume |
25 | Merge TRD-develop |
26 | |
6f1e466d |
27 | Revision 1.1.4.1 2000/05/08 15:08:03 cblume |
28 | Remove the class AliTRDcluster |
29 | |
30 | Revision 1.1 2000/02/28 18:57:58 cblume |
31 | Add new TRD classes |
32 | |
f7336fa3 |
33 | */ |
34 | |
35 | /////////////////////////////////////////////////////////////////////////////// |
36 | // // |
37 | // TRD cluster finder base class // |
38 | // // |
39 | /////////////////////////////////////////////////////////////////////////////// |
40 | |
94de3818 |
41 | #include <TROOT.h> |
42 | #include <TTree.h> |
f7336fa3 |
43 | |
94de3818 |
44 | #include "AliRun.h" |
f7336fa3 |
45 | #include "AliTRD.h" |
46 | #include "AliTRDclusterizer.h" |
47 | |
48 | ClassImp(AliTRDclusterizer) |
49 | |
50 | //_____________________________________________________________________________ |
51 | AliTRDclusterizer::AliTRDclusterizer():TNamed() |
52 | { |
53 | // |
54 | // AliTRDclusterizer default constructor |
55 | // |
56 | |
57 | fInputFile = NULL; |
58 | fEvent = 0; |
59 | |
60 | } |
61 | |
62 | //_____________________________________________________________________________ |
63 | AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title) |
64 | :TNamed(name, title) |
65 | { |
66 | // |
67 | // AliTRDclusterizer default constructor |
68 | // |
69 | |
70 | fInputFile = NULL; |
71 | fEvent = 0; |
72 | |
73 | Init(); |
74 | |
75 | } |
76 | |
8230f242 |
77 | //_____________________________________________________________________________ |
dd9a6ee3 |
78 | AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c) |
8230f242 |
79 | { |
80 | // |
81 | // AliTRDclusterizer copy constructor |
82 | // |
83 | |
dd9a6ee3 |
84 | ((AliTRDclusterizer &) c).Copy(*this); |
8230f242 |
85 | |
86 | } |
87 | |
f7336fa3 |
88 | //_____________________________________________________________________________ |
89 | AliTRDclusterizer::~AliTRDclusterizer() |
90 | { |
8230f242 |
91 | // |
92 | // AliTRDclusterizer destructor |
93 | // |
f7336fa3 |
94 | |
95 | if (fInputFile) { |
96 | fInputFile->Close(); |
97 | delete fInputFile; |
98 | } |
99 | |
100 | } |
101 | |
8230f242 |
102 | //_____________________________________________________________________________ |
dd9a6ee3 |
103 | AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c) |
104 | { |
105 | // |
106 | // Assignment operator |
107 | // |
108 | |
109 | if (this != &c) ((AliTRDclusterizer &) c).Copy(*this); |
110 | return *this; |
111 | |
112 | } |
113 | |
114 | //_____________________________________________________________________________ |
115 | void AliTRDclusterizer::Copy(TObject &c) |
8230f242 |
116 | { |
117 | // |
118 | // Copy function |
119 | // |
120 | |
dd9a6ee3 |
121 | ((AliTRDclusterizer &) c).fInputFile = NULL; |
122 | ((AliTRDclusterizer &) c).fEvent = 0; |
8230f242 |
123 | |
124 | } |
125 | |
f7336fa3 |
126 | //_____________________________________________________________________________ |
127 | void AliTRDclusterizer::Init() |
128 | { |
129 | // |
130 | // Initializes the cluster finder |
131 | // |
132 | |
133 | } |
134 | |
135 | //_____________________________________________________________________________ |
136 | Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent) |
137 | { |
138 | // |
139 | // Opens a ROOT-file with TRD-hits and reads in the digits-tree |
140 | // |
141 | |
142 | // Connect the AliRoot file containing Geometry, Kine, and Hits |
143 | fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); |
144 | if (!fInputFile) { |
145 | printf("AliTRDclusterizer::Open -- "); |
146 | printf("Open the ALIROOT-file %s.\n",name); |
147 | fInputFile = new TFile(name,"UPDATE"); |
148 | } |
149 | else { |
150 | printf("AliTRDclusterizer::Open -- "); |
151 | printf("%s is already open.\n",name); |
152 | } |
153 | |
154 | // Get AliRun object from file or create it if not on file |
155 | //if (!gAlice) { |
156 | gAlice = (AliRun*) fInputFile->Get("gAlice"); |
157 | if (gAlice) { |
158 | printf("AliTRDclusterizer::Open -- "); |
159 | printf("AliRun object found on file.\n"); |
160 | } |
161 | else { |
162 | printf("AliTRDclusterizer::Open -- "); |
163 | printf("Could not find AliRun object.\n"); |
164 | return kFALSE; |
165 | } |
166 | //} |
167 | |
168 | fEvent = nEvent; |
169 | |
170 | // Import the Trees for the event nEvent in the file |
171 | Int_t nparticles = gAlice->GetEvent(fEvent); |
172 | if (nparticles <= 0) { |
173 | printf("AliTRDclusterizer::Open -- "); |
174 | printf("No entries in the trees for event %d.\n",fEvent); |
175 | return kFALSE; |
176 | } |
177 | |
178 | return kTRUE; |
179 | |
180 | } |
181 | |
182 | //_____________________________________________________________________________ |
183 | Bool_t AliTRDclusterizer::WriteCluster() |
184 | { |
185 | // |
186 | // Writes out the TRD-cluster |
187 | // |
188 | |
189 | // Write the new tree into the input file (use overwrite option) |
190 | Char_t treeName[7]; |
191 | sprintf(treeName,"TreeR%d",fEvent); |
192 | printf("AliTRDclusterizer::WriteCluster -- "); |
193 | printf("Write the cluster tree %s for event %d.\n" |
194 | ,treeName,fEvent); |
195 | gAlice->TreeR()->Write(treeName,2); |
196 | |
197 | return kTRUE; |
198 | |
199 | } |