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