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$ |
6f1e466d |
18 | Revision 1.1.4.1 2000/05/08 15:08:03 cblume |
19 | Remove the class AliTRDcluster |
20 | |
21 | Revision 1.1 2000/02/28 18:57:58 cblume |
22 | Add new TRD classes |
23 | |
f7336fa3 |
24 | */ |
25 | |
26 | /////////////////////////////////////////////////////////////////////////////// |
27 | // // |
28 | // TRD cluster finder base class // |
29 | // // |
30 | /////////////////////////////////////////////////////////////////////////////// |
31 | |
32 | #include "AliRun.h" |
33 | |
34 | #include "AliTRD.h" |
35 | #include "AliTRDclusterizer.h" |
36 | |
37 | ClassImp(AliTRDclusterizer) |
38 | |
39 | //_____________________________________________________________________________ |
40 | AliTRDclusterizer::AliTRDclusterizer():TNamed() |
41 | { |
42 | // |
43 | // AliTRDclusterizer default constructor |
44 | // |
45 | |
46 | fInputFile = NULL; |
47 | fEvent = 0; |
48 | |
49 | } |
50 | |
51 | //_____________________________________________________________________________ |
52 | AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title) |
53 | :TNamed(name, title) |
54 | { |
55 | // |
56 | // AliTRDclusterizer default constructor |
57 | // |
58 | |
59 | fInputFile = NULL; |
60 | fEvent = 0; |
61 | |
62 | Init(); |
63 | |
64 | } |
65 | |
66 | //_____________________________________________________________________________ |
67 | AliTRDclusterizer::~AliTRDclusterizer() |
68 | { |
69 | |
70 | if (fInputFile) { |
71 | fInputFile->Close(); |
72 | delete fInputFile; |
73 | } |
74 | |
75 | } |
76 | |
77 | //_____________________________________________________________________________ |
78 | void AliTRDclusterizer::Init() |
79 | { |
80 | // |
81 | // Initializes the cluster finder |
82 | // |
83 | |
84 | } |
85 | |
86 | //_____________________________________________________________________________ |
87 | Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent) |
88 | { |
89 | // |
90 | // Opens a ROOT-file with TRD-hits and reads in the digits-tree |
91 | // |
92 | |
93 | // Connect the AliRoot file containing Geometry, Kine, and Hits |
94 | fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); |
95 | if (!fInputFile) { |
96 | printf("AliTRDclusterizer::Open -- "); |
97 | printf("Open the ALIROOT-file %s.\n",name); |
98 | fInputFile = new TFile(name,"UPDATE"); |
99 | } |
100 | else { |
101 | printf("AliTRDclusterizer::Open -- "); |
102 | printf("%s is already open.\n",name); |
103 | } |
104 | |
105 | // Get AliRun object from file or create it if not on file |
106 | //if (!gAlice) { |
107 | gAlice = (AliRun*) fInputFile->Get("gAlice"); |
108 | if (gAlice) { |
109 | printf("AliTRDclusterizer::Open -- "); |
110 | printf("AliRun object found on file.\n"); |
111 | } |
112 | else { |
113 | printf("AliTRDclusterizer::Open -- "); |
114 | printf("Could not find AliRun object.\n"); |
115 | return kFALSE; |
116 | } |
117 | //} |
118 | |
119 | fEvent = nEvent; |
120 | |
121 | // Import the Trees for the event nEvent in the file |
122 | Int_t nparticles = gAlice->GetEvent(fEvent); |
123 | if (nparticles <= 0) { |
124 | printf("AliTRDclusterizer::Open -- "); |
125 | printf("No entries in the trees for event %d.\n",fEvent); |
126 | return kFALSE; |
127 | } |
128 | |
129 | return kTRUE; |
130 | |
131 | } |
132 | |
133 | //_____________________________________________________________________________ |
134 | Bool_t AliTRDclusterizer::WriteCluster() |
135 | { |
136 | // |
137 | // Writes out the TRD-cluster |
138 | // |
139 | |
140 | // Write the new tree into the input file (use overwrite option) |
141 | Char_t treeName[7]; |
142 | sprintf(treeName,"TreeR%d",fEvent); |
143 | printf("AliTRDclusterizer::WriteCluster -- "); |
144 | printf("Write the cluster tree %s for event %d.\n" |
145 | ,treeName,fEvent); |
146 | gAlice->TreeR()->Write(treeName,2); |
147 | |
148 | return kTRUE; |
149 | |
150 | } |