]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FASTSIM/AliFastDetector.cxx
Preprocessor with new DA
[u/mrichter/AliRoot.git] / FASTSIM / AliFastDetector.cxx
CommitLineData
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
33ClassImp(AliFastDetector)
e6e76983 34
35
36AliFastDetector::AliFastDetector():
37 fSubdetectors(0),
38 fResponses(0),
39 fLnkD(0),
40 fLnkR(0),
41 fEfficiency(0),
42 fResolution(0),
43 fGeometry(0)
8bb5c9a6 44{
45// Default Constructor
46 fName = "FastDetector";
47 fTitle = "Fast Detector Base Class";
8bb5c9a6 48}
49
50AliFastDetector::AliFastDetector(char* Name, char* Title):
e6e76983 51 TNamed(Name, Title),
52 fSubdetectors(0),
53 fResponses(0),
54 fLnkD(0),
55 fLnkR(0),
56 fEfficiency(0),
57 fResolution(0),
58 fGeometry(0)
8bb5c9a6 59{
60// Constructor
e6e76983 61 }
8bb5c9a6 62
a42548b0 63AliFastDetector::AliFastDetector(const AliFastDetector & det)
e6e76983 64 :TNamed(det),
65 fSubdetectors(0),
66 fResponses(0),
67 fLnkD(0),
68 fLnkR(0),
69 fEfficiency(0),
70 fResolution(0),
71 fGeometry(0)
a42548b0 72{
73// Copy constructor
74 det.Copy(*this);
75}
76
8bb5c9a6 77AliFastDetector::~AliFastDetector()
78{
79// Destructor
80 delete fSubdetectors;
81 delete fResponses;
82}
83
84
85void AliFastDetector::Init()
86{
87//
88// Initialisation
89//
90 TIter nextRes(fResponses);
91 AliFastResponse *res;
92 //
93 // Loop over responses and initialize
94 while((res = (AliFastResponse*)nextRes())) {
95 res->Init();
96 }
97
98 TIter nextDet(fSubdetectors);
99 AliFastDetector *det;
100 //
101 // Loop over subdetectors and initialize
102 while((det = (AliFastDetector*)nextDet())) {
103 det->Init();
104 }
105 //
106 TObject* obj;
107
108 if ((obj = fResponses->FindObject("Efficiency")))
109 {
110
111 fEfficiency = (AliFastResponse*) obj;
112 printf("Detector %s provides Efficiency: %s\n",
113 fName.Data(), fEfficiency->GetTitle());
114 }
115
116 if ((obj = fResponses->FindObject("Resolution")))
117 {
118 fResolution = (AliFastResponse*) obj;
119 printf("Detector %s provides Resolution: %s\n",
120 fName.Data(), fResolution->GetTitle());
121 }
122}
123
124Float_t AliFastDetector::EvaluateEfficiency(AliFastParticle* part)
125{
a42548b0 126//
127// Evaluate the efficiency for detecting particle part
128//
8bb5c9a6 129 TIter nextDet(fSubdetectors);
130 AliFastDetector *det;
131 //
132 // Loop over subdetectors
133 Float_t eff = 1;
134 while((det = (AliFastDetector*)nextDet())) {
135 eff *= det->EvaluateEfficiency(part);
136 }
137 return eff;
138}
139
140Bool_t AliFastDetector::EvaluateAcceptance(AliFastParticle* part)
141{
142 //
143 // Loop over subdetectors
144 Bool_t acc = kFALSE;
145
146 if (fSubdetectors) {
147 TIter nextDet(fSubdetectors);
148 AliFastDetector *det;
149 while((det = (AliFastDetector*)nextDet()) && !acc) {
150 acc = (acc || det->EvaluateAcceptance(part));
151 }
152 } else {
153 if (fGeometry)
154 acc = fGeometry->Impact((TParticle*) part);
155 }
156
157 return acc;
158}
159
f86dad79 160void AliFastDetector::EvaluateResponse(AliFastParticle* /*part*/)
8bb5c9a6 161{
162 ;
163}
164
165void AliFastDetector::
f86dad79 166AddSubdetector(AliFastDetector *Detector, char* /*Name*/)
8bb5c9a6 167{
168//
169// Add detector to list
170 fSubdetectors->Add(Detector);
171}
172
173
174
175void AliFastDetector::
176AddResponse(AliFastResponse *Response)
177{
178//
179// Add detector to list
180 fResponses->Add(Response);
181}
182
183
184AliFastDetector* AliFastDetector::FirstSubdetector()
185{
186// Iterator over generators: Initialisation
187 fLnkD = fSubdetectors->FirstLink();
188 if (fLnkD) {
189 return (AliFastDetector*) (fLnkD->GetObject());
190 } else {
191 return 0;
192 }
193}
194
195AliFastDetector* AliFastDetector::NextSubdetector()
196{
197// Iterator over generators: Increment
198 fLnkD = fLnkD->Next();
199 if (fLnkD) {
200 return (AliFastDetector*) (fLnkD->GetObject());
201 } else {
202 return 0;
203 }
204}
205
206
207AliFastResponse* AliFastDetector::FirstResponse()
208{
209// Iterator over generators: Initialisation
210 fLnkR = fResponses->FirstLink();
211 if (fLnkR) {
212 return (AliFastResponse*) (fLnkR->GetObject());
213 } else {
214 return 0;
215 }
216}
217
218AliFastResponse* AliFastDetector::NextResponse()
219{
220// Iterator over generators: Increment
221 fLnkR = fLnkR->Next();
222 if (fLnkR) {
223 return (AliFastResponse*) (fLnkR->GetObject());
224 } else {
225 return 0;
226 }
227}
228
229
a42548b0 230AliFastDetector& AliFastDetector::operator=(const AliFastDetector& rhs)
231{
232// Assignment operator
233 rhs.Copy(*this);
234 return *this;
235}
236
237void AliFastDetector::Copy(TObject&) const
238{
239 //
240 // Copy
241 //
242 Fatal("Copy","Not implemented!\n");
243}
244