LCOV - code coverage report
Current view: top level - FASTSIM - AliFastDetector.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 95 1.1 %
Date: 2016-06-14 17:26:59 Functions: 1 22 4.5 %

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

Generated by: LCOV version 1.11