ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */
//
// Base class for fast simulation of a detctor
// or a system of subdetectors.
// The detector response is described by resolution and efficiency.
// Author:
// Andreas Morsch
// andreas.morsch@cern.ch

#include "AliFastDetector.h"
#include "AliFastResponse.h"
#include "AliGeometry.h"

#include <TList.h>
#include <TIterator.h>
#include <TString.h>

ClassImp(AliFastDetector)


AliFastDetector::AliFastDetector():
    fSubdetectors(0),
    fResponses(0),
    fLnkD(0),
    fLnkR(0),
    fEfficiency(0),
    fResolution(0),
    fGeometry(0)
{
// Default Constructor
    fName  = "FastDetector";
    fTitle = "Fast Detector Base Class";
}

AliFastDetector::AliFastDetector(char* Name, char* Title):
    TNamed(Name, Title),
    fSubdetectors(new TList()),
    fResponses(new TList()),
    fLnkD(0),
    fLnkR(0),
    fEfficiency(0),
    fResolution(0),
    fGeometry(0)
{
// Constructor
 }

AliFastDetector::AliFastDetector(const AliFastDetector & det)
    :TNamed(det),
    fSubdetectors(0),
    fResponses(0),
    fLnkD(0),
    fLnkR(0),
    fEfficiency(0),
    fResolution(0),
    fGeometry(0)
{
// Copy constructor
    det.Copy(*this);
}

AliFastDetector::~AliFastDetector()
{
// Destructor
    delete fSubdetectors;
    delete fResponses;
}


void AliFastDetector::Init()
{
//
// Initialisation
//
    TIter nextRes(fResponses);
    AliFastResponse *res;
    //
    // Loop over responses  and initialize
    while((res = (AliFastResponse*)nextRes())) {
	res->Init();
    }  

    TIter nextDet(fSubdetectors);
    AliFastDetector *det;
    //
    // Loop over subdetectors  and initialize
    while((det = (AliFastDetector*)nextDet())) {
	det->Init();
    }  
    //
    TObject* obj;
    
    if ((obj = fResponses->FindObject("Efficiency")))
    {

	fEfficiency = (AliFastResponse*) obj;
	printf("Detector %s provides Efficiency: %s\n",
	       fName.Data(), fEfficiency->GetTitle());
    }
    
    if ((obj = fResponses->FindObject("Resolution"))) 
    {
	fResolution = (AliFastResponse*) obj;
	printf("Detector %s provides Resolution: %s\n",
	       fName.Data(), fResolution->GetTitle());
    }
}

Float_t AliFastDetector::EvaluateEfficiency(AliFastParticle* part)
{
//
//  Evaluate the efficiency for detecting particle part
//
    TIter nextDet(fSubdetectors);
    AliFastDetector *det;
    //
    // Loop over subdetectors  
    Float_t eff = 1;
    while((det = (AliFastDetector*)nextDet())) {
	eff *= det->EvaluateEfficiency(part);
    }  
    return eff;
}

Bool_t  AliFastDetector::EvaluateAcceptance(AliFastParticle* part)
{
    //
    // Loop over subdetectors 
    Bool_t acc = kFALSE;

    if (fSubdetectors) {
	TIter nextDet(fSubdetectors);
	AliFastDetector *det;
	while((det = (AliFastDetector*)nextDet()) && !acc) {
	    acc = (acc ||  det->EvaluateAcceptance(part));
	}  
    } else {
        if (fGeometry)
	acc = fGeometry->Impact((TParticle*) part);
    }
    
    return acc;
}

void    AliFastDetector::EvaluateResponse(AliFastParticle* /*part*/)
{
    ;
}

void AliFastDetector::
AddSubdetector(AliFastDetector *Detector, char* /*Name*/)
{
//
//  Add detector to list   
     fSubdetectors->Add(Detector);
}



void AliFastDetector::
AddResponse(AliFastResponse *Response)
{
//
//  Add detector to list   
     fResponses->Add(Response);
}


AliFastDetector*  AliFastDetector::FirstSubdetector()
{
// Iterator over generators: Initialisation
    fLnkD = fSubdetectors->FirstLink();
    if (fLnkD) {
	return (AliFastDetector*) (fLnkD->GetObject());
    } else {
	return 0;
    }
}

AliFastDetector*  AliFastDetector::NextSubdetector()
{
// Iterator over generators: Increment
    fLnkD = fLnkD->Next();
    if (fLnkD) {
	return (AliFastDetector*) (fLnkD->GetObject());
    } else {
	return 0;
    }
}


AliFastResponse*  AliFastDetector::FirstResponse()
{
// Iterator over generators: Initialisation
    fLnkR = fResponses->FirstLink();
    if (fLnkR) {
	return (AliFastResponse*) (fLnkR->GetObject());
    } else {
	return 0;
    }
}

AliFastResponse*  AliFastDetector::NextResponse()
{
// Iterator over generators: Increment
    fLnkR = fLnkR->Next();
    if (fLnkR) {
	return (AliFastResponse*) (fLnkR->GetObject());
    } else {
	return 0;
    }
}


AliFastDetector& AliFastDetector::operator=(const  AliFastDetector& rhs)
{
// Assignment operator
    rhs.Copy(*this);
    return *this;
}

void AliFastDetector::Copy(TObject&) const
{
    //
    // Copy 
    //
    Fatal("Copy","Not implemented!\n");
}

 AliFastDetector.cxx:1
 AliFastDetector.cxx:2
 AliFastDetector.cxx:3
 AliFastDetector.cxx:4
 AliFastDetector.cxx:5
 AliFastDetector.cxx:6
 AliFastDetector.cxx:7
 AliFastDetector.cxx:8
 AliFastDetector.cxx:9
 AliFastDetector.cxx:10
 AliFastDetector.cxx:11
 AliFastDetector.cxx:12
 AliFastDetector.cxx:13
 AliFastDetector.cxx:14
 AliFastDetector.cxx:15
 AliFastDetector.cxx:16
 AliFastDetector.cxx:17
 AliFastDetector.cxx:18
 AliFastDetector.cxx:19
 AliFastDetector.cxx:20
 AliFastDetector.cxx:21
 AliFastDetector.cxx:22
 AliFastDetector.cxx:23
 AliFastDetector.cxx:24
 AliFastDetector.cxx:25
 AliFastDetector.cxx:26
 AliFastDetector.cxx:27
 AliFastDetector.cxx:28
 AliFastDetector.cxx:29
 AliFastDetector.cxx:30
 AliFastDetector.cxx:31
 AliFastDetector.cxx:32
 AliFastDetector.cxx:33
 AliFastDetector.cxx:34
 AliFastDetector.cxx:35
 AliFastDetector.cxx:36
 AliFastDetector.cxx:37
 AliFastDetector.cxx:38
 AliFastDetector.cxx:39
 AliFastDetector.cxx:40
 AliFastDetector.cxx:41
 AliFastDetector.cxx:42
 AliFastDetector.cxx:43
 AliFastDetector.cxx:44
 AliFastDetector.cxx:45
 AliFastDetector.cxx:46
 AliFastDetector.cxx:47
 AliFastDetector.cxx:48
 AliFastDetector.cxx:49
 AliFastDetector.cxx:50
 AliFastDetector.cxx:51
 AliFastDetector.cxx:52
 AliFastDetector.cxx:53
 AliFastDetector.cxx:54
 AliFastDetector.cxx:55
 AliFastDetector.cxx:56
 AliFastDetector.cxx:57
 AliFastDetector.cxx:58
 AliFastDetector.cxx:59
 AliFastDetector.cxx:60
 AliFastDetector.cxx:61
 AliFastDetector.cxx:62
 AliFastDetector.cxx:63
 AliFastDetector.cxx:64
 AliFastDetector.cxx:65
 AliFastDetector.cxx:66
 AliFastDetector.cxx:67
 AliFastDetector.cxx:68
 AliFastDetector.cxx:69
 AliFastDetector.cxx:70
 AliFastDetector.cxx:71
 AliFastDetector.cxx:72
 AliFastDetector.cxx:73
 AliFastDetector.cxx:74
 AliFastDetector.cxx:75
 AliFastDetector.cxx:76
 AliFastDetector.cxx:77
 AliFastDetector.cxx:78
 AliFastDetector.cxx:79
 AliFastDetector.cxx:80
 AliFastDetector.cxx:81
 AliFastDetector.cxx:82
 AliFastDetector.cxx:83
 AliFastDetector.cxx:84
 AliFastDetector.cxx:85
 AliFastDetector.cxx:86
 AliFastDetector.cxx:87
 AliFastDetector.cxx:88
 AliFastDetector.cxx:89
 AliFastDetector.cxx:90
 AliFastDetector.cxx:91
 AliFastDetector.cxx:92
 AliFastDetector.cxx:93
 AliFastDetector.cxx:94
 AliFastDetector.cxx:95
 AliFastDetector.cxx:96
 AliFastDetector.cxx:97
 AliFastDetector.cxx:98
 AliFastDetector.cxx:99
 AliFastDetector.cxx:100
 AliFastDetector.cxx:101
 AliFastDetector.cxx:102
 AliFastDetector.cxx:103
 AliFastDetector.cxx:104
 AliFastDetector.cxx:105
 AliFastDetector.cxx:106
 AliFastDetector.cxx:107
 AliFastDetector.cxx:108
 AliFastDetector.cxx:109
 AliFastDetector.cxx:110
 AliFastDetector.cxx:111
 AliFastDetector.cxx:112
 AliFastDetector.cxx:113
 AliFastDetector.cxx:114
 AliFastDetector.cxx:115
 AliFastDetector.cxx:116
 AliFastDetector.cxx:117
 AliFastDetector.cxx:118
 AliFastDetector.cxx:119
 AliFastDetector.cxx:120
 AliFastDetector.cxx:121
 AliFastDetector.cxx:122
 AliFastDetector.cxx:123
 AliFastDetector.cxx:124
 AliFastDetector.cxx:125
 AliFastDetector.cxx:126
 AliFastDetector.cxx:127
 AliFastDetector.cxx:128
 AliFastDetector.cxx:129
 AliFastDetector.cxx:130
 AliFastDetector.cxx:131
 AliFastDetector.cxx:132
 AliFastDetector.cxx:133
 AliFastDetector.cxx:134
 AliFastDetector.cxx:135
 AliFastDetector.cxx:136
 AliFastDetector.cxx:137
 AliFastDetector.cxx:138
 AliFastDetector.cxx:139
 AliFastDetector.cxx:140
 AliFastDetector.cxx:141
 AliFastDetector.cxx:142
 AliFastDetector.cxx:143
 AliFastDetector.cxx:144
 AliFastDetector.cxx:145
 AliFastDetector.cxx:146
 AliFastDetector.cxx:147
 AliFastDetector.cxx:148
 AliFastDetector.cxx:149
 AliFastDetector.cxx:150
 AliFastDetector.cxx:151
 AliFastDetector.cxx:152
 AliFastDetector.cxx:153
 AliFastDetector.cxx:154
 AliFastDetector.cxx:155
 AliFastDetector.cxx:156
 AliFastDetector.cxx:157
 AliFastDetector.cxx:158
 AliFastDetector.cxx:159
 AliFastDetector.cxx:160
 AliFastDetector.cxx:161
 AliFastDetector.cxx:162
 AliFastDetector.cxx:163
 AliFastDetector.cxx:164
 AliFastDetector.cxx:165
 AliFastDetector.cxx:166
 AliFastDetector.cxx:167
 AliFastDetector.cxx:168
 AliFastDetector.cxx:169
 AliFastDetector.cxx:170
 AliFastDetector.cxx:171
 AliFastDetector.cxx:172
 AliFastDetector.cxx:173
 AliFastDetector.cxx:174
 AliFastDetector.cxx:175
 AliFastDetector.cxx:176
 AliFastDetector.cxx:177
 AliFastDetector.cxx:178
 AliFastDetector.cxx:179
 AliFastDetector.cxx:180
 AliFastDetector.cxx:181
 AliFastDetector.cxx:182
 AliFastDetector.cxx:183
 AliFastDetector.cxx:184
 AliFastDetector.cxx:185
 AliFastDetector.cxx:186
 AliFastDetector.cxx:187
 AliFastDetector.cxx:188
 AliFastDetector.cxx:189
 AliFastDetector.cxx:190
 AliFastDetector.cxx:191
 AliFastDetector.cxx:192
 AliFastDetector.cxx:193
 AliFastDetector.cxx:194
 AliFastDetector.cxx:195
 AliFastDetector.cxx:196
 AliFastDetector.cxx:197
 AliFastDetector.cxx:198
 AliFastDetector.cxx:199
 AliFastDetector.cxx:200
 AliFastDetector.cxx:201
 AliFastDetector.cxx:202
 AliFastDetector.cxx:203
 AliFastDetector.cxx:204
 AliFastDetector.cxx:205
 AliFastDetector.cxx:206
 AliFastDetector.cxx:207
 AliFastDetector.cxx:208
 AliFastDetector.cxx:209
 AliFastDetector.cxx:210
 AliFastDetector.cxx:211
 AliFastDetector.cxx:212
 AliFastDetector.cxx:213
 AliFastDetector.cxx:214
 AliFastDetector.cxx:215
 AliFastDetector.cxx:216
 AliFastDetector.cxx:217
 AliFastDetector.cxx:218
 AliFastDetector.cxx:219
 AliFastDetector.cxx:220
 AliFastDetector.cxx:221
 AliFastDetector.cxx:222
 AliFastDetector.cxx:223
 AliFastDetector.cxx:224
 AliFastDetector.cxx:225
 AliFastDetector.cxx:226
 AliFastDetector.cxx:227
 AliFastDetector.cxx:228
 AliFastDetector.cxx:229
 AliFastDetector.cxx:230
 AliFastDetector.cxx:231
 AliFastDetector.cxx:232
 AliFastDetector.cxx:233
 AliFastDetector.cxx:234
 AliFastDetector.cxx:235
 AliFastDetector.cxx:236
 AliFastDetector.cxx:237
 AliFastDetector.cxx:238
 AliFastDetector.cxx:239
 AliFastDetector.cxx:240
 AliFastDetector.cxx:241
 AliFastDetector.cxx:242
 AliFastDetector.cxx:243
 AliFastDetector.cxx:244