]>
Commit | Line | Data |
---|---|---|
8bb5c9a6 | 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 | ||
803d1ab0 | 16 | /* $Id$ */ |
a42548b0 | 17 | // |
18 | // Base class for fast simulation of a detctor | |
19 | // or a system of subdetectors. | |
20 | // The detector response is described by resolution and efficiency. | |
21 | // Author: | |
22 | // Andreas Morsch | |
23 | // andreas.morsch@cern.ch | |
8bb5c9a6 | 24 | |
25 | #include "AliFastDetector.h" | |
26 | #include "AliFastResponse.h" | |
27 | #include "AliGeometry.h" | |
28 | ||
29 | #include <TList.h> | |
30 | #include <TIterator.h> | |
31 | #include <TString.h> | |
32 | ||
33 | ClassImp(AliFastDetector) | |
34 | AliFastDetector::AliFastDetector() | |
35 | { | |
36 | // Default Constructor | |
37 | fName = "FastDetector"; | |
38 | fTitle = "Fast Detector Base Class"; | |
39 | fLnkD = 0; | |
40 | fLnkR = 0; | |
41 | ||
42 | fResponses = 0; | |
43 | fSubdetectors = 0; | |
44 | } | |
45 | ||
46 | AliFastDetector::AliFastDetector(char* Name, char* Title): | |
47 | TNamed(Name, Title) | |
48 | { | |
49 | // Constructor | |
50 | fSubdetectors = new TList(); | |
51 | fResponses = new TList(); | |
52 | } | |
53 | ||
a42548b0 | 54 | AliFastDetector::AliFastDetector(const AliFastDetector & det) |
55 | :TNamed(det) | |
56 | { | |
57 | // Copy constructor | |
58 | det.Copy(*this); | |
59 | } | |
60 | ||
8bb5c9a6 | 61 | AliFastDetector::~AliFastDetector() |
62 | { | |
63 | // Destructor | |
64 | delete fSubdetectors; | |
65 | delete fResponses; | |
66 | } | |
67 | ||
68 | ||
69 | void AliFastDetector::Init() | |
70 | { | |
71 | // | |
72 | // Initialisation | |
73 | // | |
74 | TIter nextRes(fResponses); | |
75 | AliFastResponse *res; | |
76 | // | |
77 | // Loop over responses and initialize | |
78 | while((res = (AliFastResponse*)nextRes())) { | |
79 | res->Init(); | |
80 | } | |
81 | ||
82 | TIter nextDet(fSubdetectors); | |
83 | AliFastDetector *det; | |
84 | // | |
85 | // Loop over subdetectors and initialize | |
86 | while((det = (AliFastDetector*)nextDet())) { | |
87 | det->Init(); | |
88 | } | |
89 | // | |
90 | TObject* obj; | |
91 | ||
92 | if ((obj = fResponses->FindObject("Efficiency"))) | |
93 | { | |
94 | ||
95 | fEfficiency = (AliFastResponse*) obj; | |
96 | printf("Detector %s provides Efficiency: %s\n", | |
97 | fName.Data(), fEfficiency->GetTitle()); | |
98 | } | |
99 | ||
100 | if ((obj = fResponses->FindObject("Resolution"))) | |
101 | { | |
102 | fResolution = (AliFastResponse*) obj; | |
103 | printf("Detector %s provides Resolution: %s\n", | |
104 | fName.Data(), fResolution->GetTitle()); | |
105 | } | |
106 | } | |
107 | ||
108 | Float_t AliFastDetector::EvaluateEfficiency(AliFastParticle* part) | |
109 | { | |
a42548b0 | 110 | // |
111 | // Evaluate the efficiency for detecting particle part | |
112 | // | |
8bb5c9a6 | 113 | TIter nextDet(fSubdetectors); |
114 | AliFastDetector *det; | |
115 | // | |
116 | // Loop over subdetectors | |
117 | Float_t eff = 1; | |
118 | while((det = (AliFastDetector*)nextDet())) { | |
119 | eff *= det->EvaluateEfficiency(part); | |
120 | } | |
121 | return eff; | |
122 | } | |
123 | ||
124 | Bool_t AliFastDetector::EvaluateAcceptance(AliFastParticle* part) | |
125 | { | |
126 | // | |
127 | // Loop over subdetectors | |
128 | Bool_t acc = kFALSE; | |
129 | ||
130 | if (fSubdetectors) { | |
131 | TIter nextDet(fSubdetectors); | |
132 | AliFastDetector *det; | |
133 | while((det = (AliFastDetector*)nextDet()) && !acc) { | |
134 | acc = (acc || det->EvaluateAcceptance(part)); | |
135 | } | |
136 | } else { | |
137 | if (fGeometry) | |
138 | acc = fGeometry->Impact((TParticle*) part); | |
139 | } | |
140 | ||
141 | return acc; | |
142 | } | |
143 | ||
f86dad79 | 144 | void AliFastDetector::EvaluateResponse(AliFastParticle* /*part*/) |
8bb5c9a6 | 145 | { |
146 | ; | |
147 | } | |
148 | ||
149 | void AliFastDetector:: | |
f86dad79 | 150 | AddSubdetector(AliFastDetector *Detector, char* /*Name*/) |
8bb5c9a6 | 151 | { |
152 | // | |
153 | // Add detector to list | |
154 | fSubdetectors->Add(Detector); | |
155 | } | |
156 | ||
157 | ||
158 | ||
159 | void AliFastDetector:: | |
160 | AddResponse(AliFastResponse *Response) | |
161 | { | |
162 | // | |
163 | // Add detector to list | |
164 | fResponses->Add(Response); | |
165 | } | |
166 | ||
167 | ||
168 | AliFastDetector* AliFastDetector::FirstSubdetector() | |
169 | { | |
170 | // Iterator over generators: Initialisation | |
171 | fLnkD = fSubdetectors->FirstLink(); | |
172 | if (fLnkD) { | |
173 | return (AliFastDetector*) (fLnkD->GetObject()); | |
174 | } else { | |
175 | return 0; | |
176 | } | |
177 | } | |
178 | ||
179 | AliFastDetector* AliFastDetector::NextSubdetector() | |
180 | { | |
181 | // Iterator over generators: Increment | |
182 | fLnkD = fLnkD->Next(); | |
183 | if (fLnkD) { | |
184 | return (AliFastDetector*) (fLnkD->GetObject()); | |
185 | } else { | |
186 | return 0; | |
187 | } | |
188 | } | |
189 | ||
190 | ||
191 | AliFastResponse* AliFastDetector::FirstResponse() | |
192 | { | |
193 | // Iterator over generators: Initialisation | |
194 | fLnkR = fResponses->FirstLink(); | |
195 | if (fLnkR) { | |
196 | return (AliFastResponse*) (fLnkR->GetObject()); | |
197 | } else { | |
198 | return 0; | |
199 | } | |
200 | } | |
201 | ||
202 | AliFastResponse* AliFastDetector::NextResponse() | |
203 | { | |
204 | // Iterator over generators: Increment | |
205 | fLnkR = fLnkR->Next(); | |
206 | if (fLnkR) { | |
207 | return (AliFastResponse*) (fLnkR->GetObject()); | |
208 | } else { | |
209 | return 0; | |
210 | } | |
211 | } | |
212 | ||
213 | ||
a42548b0 | 214 | AliFastDetector& AliFastDetector::operator=(const AliFastDetector& rhs) |
215 | { | |
216 | // Assignment operator | |
217 | rhs.Copy(*this); | |
218 | return *this; | |
219 | } | |
220 | ||
221 | void AliFastDetector::Copy(TObject&) const | |
222 | { | |
223 | // | |
224 | // Copy | |
225 | // | |
226 | Fatal("Copy","Not implemented!\n"); | |
227 | } | |
228 |