]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FASTSIM/AliFastDetector.cxx
Base classes for fast simulation. First commit.
[u/mrichter/AliRoot.git] / FASTSIM / AliFastDetector.cxx
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 #include "AliFastDetector.h"
22 #include "AliFastResponse.h"
23 #include "AliGeometry.h"
24
25 #include <TList.h>
26 #include <TIterator.h>
27 #include <TString.h>
28
29 ClassImp(AliFastDetector)
30 AliFastDetector::AliFastDetector()
31 {
32 // Default Constructor
33     fName  = "FastDetector";
34     fTitle = "Fast Detector Base Class";
35     fLnkD  = 0;
36     fLnkR  = 0;
37     
38     fResponses    = 0;
39     fSubdetectors = 0;
40 }
41
42 AliFastDetector::AliFastDetector(char* Name, char* Title):
43     TNamed(Name, Title)
44 {
45 // Constructor
46     fSubdetectors = new TList();
47     fResponses    = new TList();
48 }
49
50 AliFastDetector::~AliFastDetector()
51 {
52 // Destructor
53     delete fSubdetectors;
54     delete fResponses;
55 }
56
57
58 void AliFastDetector::Init()
59 {
60 //
61 // Initialisation
62 //
63     TIter nextRes(fResponses);
64     AliFastResponse *res;
65     //
66     // Loop over responses  and initialize
67     while((res = (AliFastResponse*)nextRes())) {
68         res->Init();
69     }  
70
71     TIter nextDet(fSubdetectors);
72     AliFastDetector *det;
73     //
74     // Loop over subdetectors  and initialize
75     while((det = (AliFastDetector*)nextDet())) {
76         det->Init();
77     }  
78     //
79     TObject* obj;
80     
81     if ((obj = fResponses->FindObject("Efficiency")))
82     {
83
84         fEfficiency = (AliFastResponse*) obj;
85         printf("Detector %s provides Efficiency: %s\n",
86                fName.Data(), fEfficiency->GetTitle());
87     }
88     
89     if ((obj = fResponses->FindObject("Resolution"))) 
90     {
91         fResolution = (AliFastResponse*) obj;
92         printf("Detector %s provides Resolution: %s\n",
93                fName.Data(), fResolution->GetTitle());
94     }
95 }
96
97 Float_t AliFastDetector::EvaluateEfficiency(AliFastParticle* part)
98 {
99     TIter nextDet(fSubdetectors);
100     AliFastDetector *det;
101     //
102     // Loop over subdetectors  
103     Float_t eff = 1;
104     while((det = (AliFastDetector*)nextDet())) {
105         eff *= det->EvaluateEfficiency(part);
106     }  
107     return eff;
108 }
109
110 Bool_t  AliFastDetector::EvaluateAcceptance(AliFastParticle* part)
111 {
112     //
113     // Loop over subdetectors 
114     Bool_t acc = kFALSE;
115
116     if (fSubdetectors) {
117         TIter nextDet(fSubdetectors);
118         AliFastDetector *det;
119         while((det = (AliFastDetector*)nextDet()) && !acc) {
120             acc = (acc ||  det->EvaluateAcceptance(part));
121         }  
122     } else {
123         if (fGeometry)
124         acc = fGeometry->Impact((TParticle*) part);
125     }
126     
127     return acc;
128 }
129
130 void    AliFastDetector::EvaluateResponse(AliFastParticle* part)
131 {
132     ;
133 }
134
135 void AliFastDetector::
136 AddSubdetector(AliFastDetector *Detector, char* Name)
137 {
138 //
139 //  Add detector to list   
140      fSubdetectors->Add(Detector);
141 }
142
143
144
145 void AliFastDetector::
146 AddResponse(AliFastResponse *Response)
147 {
148 //
149 //  Add detector to list   
150      fResponses->Add(Response);
151 }
152
153
154 AliFastDetector*  AliFastDetector::FirstSubdetector()
155 {
156 // Iterator over generators: Initialisation
157     fLnkD = fSubdetectors->FirstLink();
158     if (fLnkD) {
159         return (AliFastDetector*) (fLnkD->GetObject());
160     } else {
161         return 0;
162     }
163 }
164
165 AliFastDetector*  AliFastDetector::NextSubdetector()
166 {
167 // Iterator over generators: Increment
168     fLnkD = fLnkD->Next();
169     if (fLnkD) {
170         return (AliFastDetector*) (fLnkD->GetObject());
171     } else {
172         return 0;
173     }
174 }
175
176
177 AliFastResponse*  AliFastDetector::FirstResponse()
178 {
179 // Iterator over generators: Initialisation
180     fLnkR = fResponses->FirstLink();
181     if (fLnkR) {
182         return (AliFastResponse*) (fLnkR->GetObject());
183     } else {
184         return 0;
185     }
186 }
187
188 AliFastResponse*  AliFastDetector::NextResponse()
189 {
190 // Iterator over generators: Increment
191     fLnkR = fLnkR->Next();
192     if (fLnkR) {
193         return (AliFastResponse*) (fLnkR->GetObject());
194     } else {
195         return 0;
196     }
197 }
198
199