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