LCOV - code coverage report
Current view: top level - STEER/STEERBase - AliDetectorPID.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 77 1.3 %
Date: 2016-06-14 17:26:59 Functions: 1 18 5.6 %

          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             : 
      17             : ///////////////////////////////////////////////////////////////////////////
      18             : //                       Detector PID                                    //
      19             : //                                                                       //
      20             : //                                                                       //
      21             : /*
      22             : 
      23             : This class is supposed to store the detector pid values for all detectors
      24             :   and all particle species.
      25             : It is meant to be used to buffer the PID values as a transient object in
      26             :   AliESDtrack and AliAODTrack, respectively.
      27             : The calculation filling and association to the track is done in
      28             :   AliAnalysisTaskPID response.
      29             : The idea of this object is to save computing time in an analysis train with
      30             :   many analyses where access to pid is done often
      31             : 
      32             : 
      33             : 
      34             : */
      35             : //                                                                       //
      36             : ///////////////////////////////////////////////////////////////////////////
      37             : 
      38             : #include "AliPIDValues.h"
      39             : 
      40             : #include "AliDetectorPID.h"
      41             : 
      42         176 : ClassImp(AliDetectorPID)
      43             : 
      44             : 
      45             : AliDetectorPID::AliDetectorPID() :
      46           0 :   TObject(),
      47           0 :   fArrNsigmas("AliPIDValues",AliPIDResponse::kNdetectors),
      48           0 :   fArrRawProbabilities("AliPIDValues",AliPIDResponse::kNdetectors)
      49           0 : {
      50             :   //
      51             :   // default constructor
      52             :   //
      53             :   
      54           0 : }
      55             : 
      56             : //_______________________________________________________________________
      57             : AliDetectorPID::AliDetectorPID(const AliDetectorPID &pid) :
      58           0 :   TObject(pid),
      59           0 :   fArrNsigmas(pid.fArrNsigmas),
      60           0 :   fArrRawProbabilities(pid.fArrRawProbabilities)
      61           0 : {
      62             :   //
      63             :   // copy constructor
      64             :   //
      65             :   
      66           0 : }
      67             : 
      68             : //_______________________________________________________________________
      69             : AliDetectorPID::~AliDetectorPID()
      70           0 : {
      71             :   //
      72             :   // destructor
      73             :   //
      74           0 :   fArrNsigmas.Delete();
      75           0 :   fArrRawProbabilities.Delete();
      76           0 : }
      77             : 
      78             : //_______________________________________________________________________
      79             : AliDetectorPID& AliDetectorPID::operator= (const AliDetectorPID &pid)
      80             : {
      81             :   //
      82             :   // assignment operator
      83             :   //
      84             :   
      85           0 :   if (this==&pid) return *this;
      86             : 
      87           0 :   TObject::operator=(pid);
      88             :   
      89           0 :   fArrNsigmas.Clear();
      90           0 :   fArrRawProbabilities.Clear();
      91             :   
      92             :   AliPIDValues *val=0x0;
      93           0 :   for (Int_t idet=0; idet<(Int_t)AliPIDResponse::kNdetectors; ++idet){
      94           0 :     val=static_cast<AliPIDValues*>(pid.fArrNsigmas.UncheckedAt(idet));
      95           0 :     if (val) new (fArrNsigmas[idet]) AliPIDValues(*val);
      96             : 
      97           0 :     val=static_cast<AliPIDValues*>(pid.fArrRawProbabilities.UncheckedAt(idet));
      98           0 :     if (val) new (fArrRawProbabilities[idet]) AliPIDValues(*val);
      99             :   }
     100             : 
     101             :   return *this;
     102           0 : }
     103             : 
     104             : //_______________________________________________________________________
     105             : void AliDetectorPID::SetRawProbability(AliPIDResponse::EDetector det, const Double_t prob[],
     106             :                                        Int_t nspecies, AliPIDResponse::EDetPidStatus status)
     107             : {
     108             :   //
     109             :   // set raw probabilities for nspecies for 'det'ector
     110             :   //
     111             :   
     112           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt(det));
     113           0 :   if (!val)
     114           0 :     val=new (fArrRawProbabilities[(Int_t)det]) AliPIDValues;
     115             : 
     116           0 :   val->SetValues(prob,nspecies,status);
     117           0 : }
     118             : 
     119             : //_______________________________________________________________________
     120             : void AliDetectorPID::SetNumberOfSigmas(AliPIDResponse::EDetector det, const Double_t nsig[], Int_t nspecies,
     121             :                                        AliPIDResponse::EDetPidStatus status)
     122             : {
     123             :   //
     124             :   // set number of sigmas for nspecies for 'det'ector
     125             :   //
     126             :   
     127           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt(det));
     128           0 :   if (!val)
     129           0 :     val=new (fArrNsigmas[(Int_t)det]) AliPIDValues;
     130             : 
     131           0 :   val->SetValues(nsig,nspecies);
     132           0 :   val->SetPIDStatus(status);
     133           0 : }
     134             : 
     135             : //_______________________________________________________________________
     136             : AliPIDResponse::EDetPidStatus AliDetectorPID::GetRawProbability(AliPIDResponse::EDetector det, Double_t prob[], Int_t nspecies) const
     137             : {
     138             :   //
     139             :   // get raw probabilities for nspecies for 'det'ector
     140             :   //
     141             :   
     142           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
     143           0 :   if (!val) {
     144           0 :     for (Int_t i=0; i<nspecies; ++i) prob[i]=1.; //TODO: Is '1' the correct values or better 1/nspecies
     145           0 :     return AliPIDResponse::kDetNoSignal;
     146             :   }
     147             : 
     148           0 :   return val->GetValues(prob,nspecies);
     149           0 : }
     150             : 
     151             : //_______________________________________________________________________
     152             : AliPIDResponse::EDetPidStatus AliDetectorPID::GetNumberOfSigmas(AliPIDResponse::EDetector det, Double_t nsig[], Int_t nspecies) const
     153             : {
     154           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
     155           0 :   if (!val) {
     156           0 :     for (Int_t i=0; i<nspecies; ++i) nsig[i]=-999.;
     157           0 :     return AliPIDResponse::kDetNoSignal;
     158             :   }
     159             :   
     160           0 :   return val->GetValues(nsig,nspecies);
     161           0 : }
     162             : 
     163             : //_______________________________________________________________________
     164             : Double_t AliDetectorPID::GetRawProbability(AliPIDResponse::EDetector det, AliPID::EParticleType type) const
     165             : {
     166             :   //
     167             :   // get 'det'ector raw probability for particle 'type'
     168             :   //
     169             :   
     170           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
     171           0 :   if (!val) {
     172           0 :     return 0.; //TODO: Is '0' the correct value?
     173             :   }
     174             :   
     175           0 :   return val->GetValue(type);
     176           0 : }
     177             : 
     178             : //_______________________________________________________________________
     179             : Double_t AliDetectorPID::GetNumberOfSigmas(AliPIDResponse::EDetector det, AliPID::EParticleType type) const
     180             : {
     181             :   //
     182             :   // get 'det'ector number of sigmas for particle 'type'
     183             :   //
     184           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
     185           0 :   if (!val) {
     186           0 :     return -999.; //TODO: Is '-999.' the correct value?
     187             :   }
     188             :   
     189           0 :   return val->GetValue(type);
     190           0 : }
     191             : 
     192             : //_______________________________________________________________________
     193             : AliPIDResponse::EDetPidStatus AliDetectorPID::GetRawProbability(AliPIDResponse::EDetector det, AliPID::EParticleType type, Double_t &prob) const
     194             : {
     195             :   //
     196             :   // get 'det'ector raw probability for particle 'type'
     197             :   //
     198             :   
     199           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
     200           0 :   if (!val) {
     201           0 :     prob=0.;
     202           0 :     return AliPIDResponse::kDetNoSignal; 
     203             :   }
     204             :   
     205           0 :   prob=val->GetValue(type);
     206           0 :   return val->GetPIDStatus();
     207           0 : }
     208             : 
     209             : //_______________________________________________________________________
     210             : AliPIDResponse::EDetPidStatus AliDetectorPID::GetNumberOfSigmas(AliPIDResponse::EDetector det, AliPID::EParticleType type, Double_t &nsig) const
     211             : {
     212             :   //
     213             :   // get 'det'ector number of sigmas for particle 'type'
     214             :   //
     215           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
     216           0 :   if (!val) {
     217           0 :     nsig=-999.;
     218           0 :     return AliPIDResponse::kDetNoSignal; 
     219             :   }
     220             :   
     221           0 :   nsig=val->GetValue(type);
     222           0 :   return val->GetPIDStatus();
     223           0 : }
     224             : 
     225             : 
     226             : //_______________________________________________________________________
     227             : AliPIDResponse::EDetPidStatus AliDetectorPID::GetPIDStatus(AliPIDResponse::EDetector det) const
     228             : {
     229             :   //
     230             :   // return the detector PID status
     231             :   //
     232             :   
     233           0 :   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
     234           0 :   if (!val) val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
     235           0 :   if (val) return val->GetPIDStatus();
     236             : 
     237           0 :   return AliPIDResponse::kDetNoSignal;
     238           0 : }
     239             : 

Generated by: LCOV version 1.11