LCOV - code coverage report
Current view: top level - STEER/STEERBase - AliTRDPIDResponseObject.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 21 106 19.8 %
Date: 2016-06-14 17:26:59 Functions: 6 18 33.3 %

          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             : // Container class for the reference distributions for TRD PID
      17             : // The class contains the reference distributions and the momentum steps
      18             : // the references are taken at. Mapping is done inside. To derive references,
      19             : // the functions GetUpperReference and GetLowerReference return the next
      20             : // reference distribution object and the momentum step above respectively below
      21             : // the tracklet momentum.
      22             : //
      23             : // Authors:
      24             : //    Markus Fasel <M.Fasel@gsi.de>
      25             : //    Daniel Lohner <Daniel.Lohner@cern.ch>
      26             : 
      27             : #include "AliLog.h"
      28             : 
      29             : #include "AliTRDPIDResponseObject.h"
      30             : 
      31             : #ifndef AliTRDPIDREFERENCE_H
      32             : #include "AliTRDPIDReference.h"
      33             : #endif
      34             : 
      35             : #ifndef AliTRDPIDPARAMS_H
      36             : #include "AliTRDPIDParams.h"
      37             : #endif
      38             : 
      39             : 
      40         176 : ClassImp(AliTRDPIDResponseObject)
      41             : 
      42             : //____________________________________________________________
      43             : AliTRDPIDResponseObject::AliTRDPIDResponseObject():
      44           2 :     TNamed(),
      45           2 :     fNSlicesQ0(4)
      46          10 : {
      47             :     //
      48             :     // Dummy constructor
      49             :     //
      50           2 :     SetBit(kIsOwner, kTRUE);
      51             : 
      52          24 :     for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
      53          10 :         fPIDParams[method]=NULL;
      54          10 :         fPIDReference[method]=NULL;
      55             :     }
      56           4 : }
      57             : 
      58             : //____________________________________________________________
      59             : AliTRDPIDResponseObject::AliTRDPIDResponseObject(const Char_t *name):
      60           0 : TNamed(name, "TRD PID Response Object"),
      61           0 : fNSlicesQ0(4)
      62           0 : {
      63             :         //
      64             :         // Default constructor
      65             :         //
      66           0 :         SetBit(kIsOwner, kTRUE);
      67             : 
      68           0 :         for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
      69           0 :             fPIDParams[method]=NULL;
      70           0 :             fPIDReference[method]=NULL;
      71             :         }
      72           0 : }
      73             : 
      74             : //____________________________________________________________
      75             : AliTRDPIDResponseObject::AliTRDPIDResponseObject(const AliTRDPIDResponseObject &ref):
      76           0 : TNamed(ref),
      77           0 : fNSlicesQ0(ref.fNSlicesQ0)
      78           0 : {
      79             :     //
      80             :     // Copy constructor
      81             :     // Only copies pointers, object is not the owner of the references
      82             :     //
      83           0 :     SetBit(kIsOwner, kFALSE);
      84             : 
      85           0 :     for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
      86           0 :         fPIDParams[method]=ref.fPIDParams[method];       // new Object is not owner, copy only pointer
      87           0 :         fPIDReference[method]=ref.fPIDReference[method];    // new Object is not owner, copy only pointer
      88             :     }
      89           0 : }
      90             : //____________________________________________________________
      91             : AliTRDPIDResponseObject &AliTRDPIDResponseObject::operator=(const AliTRDPIDResponseObject &ref){
      92             :         //
      93             :         // Assginment operator
      94             :         // Only copies poiters, object is not the owner of the references
      95             :         //
      96           0 :         if(this != &ref){
      97           0 :             TNamed::operator=(ref);
      98           0 :             fNSlicesQ0=ref.fNSlicesQ0;
      99           0 :             for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
     100           0 :               if(TestBit(kIsOwner) && fPIDParams[method]){
     101           0 :                 delete fPIDParams[method];
     102           0 :                 fPIDParams[method]= 0;
     103           0 :               }
     104           0 :               if(TestBit(kIsOwner) && fPIDReference[method]){
     105           0 :                 delete fPIDReference[method];
     106           0 :                 fPIDReference[method] = 0;
     107           0 :               }
     108           0 :               printf("Assignment");
     109           0 :               fPIDParams[method]=ref.fPIDParams[method];       // new Object is not owner, copy only pointer
     110           0 :               fPIDReference[method]=ref.fPIDReference[method];    // new Object is not owner, copy only pointer
     111             :             }
     112           0 :             SetBit(kIsOwner, kFALSE);
     113           0 :         }
     114           0 :         return *this;
     115             : }
     116             : 
     117             : //____________________________________________________________
     118           0 : AliTRDPIDResponseObject::~AliTRDPIDResponseObject(){
     119             :         //
     120             :         // Destructor
     121             :         // references are deleted if the object is the owner
     122             :         //
     123           0 :     for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
     124           0 :         if(fPIDParams[method] && TestBit(kIsOwner)){
     125           0 :         delete fPIDParams[method];fPIDParams[method] = 0;
     126           0 :       }
     127           0 :       if(fPIDReference[method] && TestBit(kIsOwner)){
     128           0 :         delete fPIDReference[method];
     129           0 :         fPIDReference[method] = 0;
     130           0 :       }
     131             :     }
     132           0 : }
     133             : 
     134             : //____________________________________________________________
     135             : void AliTRDPIDResponseObject::SetPIDParams(AliTRDPIDParams *params,AliTRDPIDResponse::ETRDPIDMethod method){
     136             : 
     137           0 :     printf("in trd pid response %i \n",method);
     138             : 
     139           0 :     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
     140           0 :         AliError("Method does not exist");
     141           0 :         return;
     142             :     }
     143           0 :     if(fPIDParams[method]){
     144           0 :         delete fPIDParams[method];
     145           0 :         fPIDParams[method]=NULL;
     146           0 :     }
     147             : 
     148           0 :     fPIDParams[method]=new AliTRDPIDParams(*params);
     149           0 : }
     150             : 
     151             : //____________________________________________________________
     152             : void AliTRDPIDResponseObject::SetPIDReference(AliTRDPIDReference *reference,AliTRDPIDResponse::ETRDPIDMethod method){
     153             : 
     154           4 :     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
     155           0 :         AliError("Method does not exist");
     156           0 :         return;
     157             :     }
     158           2 :     if(fPIDReference[method]){
     159           0 :         delete fPIDReference[method];
     160           0 :         fPIDReference[method]=NULL;
     161           0 :     }
     162           4 :     fPIDReference[method]=new AliTRDPIDReference(*reference);
     163           4 : }
     164             : 
     165             : //____________________________________________________________
     166             : TObject *AliTRDPIDResponseObject::GetUpperReference(AliPID::EParticleType spec, Float_t p, Float_t &pUpper,AliTRDPIDResponse::ETRDPIDMethod method) const{
     167             : 
     168         412 :     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
     169           0 :         AliError("Method does not exist");
     170           0 :         return NULL;
     171             :     }
     172             :    
     173         206 :     if(fPIDReference[method]){
     174         206 :         return fPIDReference[method]->GetUpperReference(spec,p,pUpper);
     175             :     }
     176           0 :     return NULL;
     177         206 : }
     178             : 
     179             : 
     180             : //____________________________________________________________
     181             : TObject *AliTRDPIDResponseObject::GetLowerReference(AliPID::EParticleType spec, Float_t p, Float_t &pLower,AliTRDPIDResponse::ETRDPIDMethod method) const{
     182             : 
     183         412 :     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
     184           0 :         AliError("Method does not exist");
     185           0 :         return NULL;
     186             :     }
     187             : 
     188         206 :     if(fPIDReference[method]){
     189         206 :          return fPIDReference[method]->GetLowerReference(spec,p,pLower);
     190             :      }
     191           0 :     return NULL;
     192         206 : }
     193             : 
     194             : //____________________________________________________________
     195             : Bool_t AliTRDPIDResponseObject::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params,Double_t centrality,AliTRDPIDResponse::ETRDPIDMethod method) const{
     196             : 
     197           0 :     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
     198           0 :         AliError("Method does not exist");
     199           0 :         return kFALSE;
     200             :     }
     201             : 
     202           0 :     if(fPIDParams[method]){
     203           0 :         return fPIDParams[method]->GetThresholdParameters(ntracklets,efficiency,params,centrality);
     204             :     }
     205           0 :     AliError("TRD Threshold Container does not exist");
     206           0 :     return kFALSE;
     207           0 : }
     208             : 
     209             : //____________________________________________________________
     210             : Int_t AliTRDPIDResponseObject::GetNumberOfMomentumBins(AliTRDPIDResponse::ETRDPIDMethod method) const{
     211             : 
     212           0 :     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
     213           0 :         AliError("Method does not exist");
     214           0 :         return 0;
     215             :     }
     216             : 
     217           0 :     if(fPIDReference[method]){
     218           0 :         return fPIDReference[method]->GetNumberOfMomentumBins();
     219             :     }
     220           0 :     return 0;
     221           0 : }
     222             : 
     223             : //____________________________________________________________
     224             : void AliTRDPIDResponseObject::Print(const Option_t* opt) const{
     225             :         //
     226             :         // Print content of the PID object
     227             :         //
     228           0 :     printf("Content of AliTRDPIDResponseObject \n\n");
     229             :    
     230           0 :     for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
     231           0 :         if(fPIDReference[method])fPIDReference[method]->Print(opt);
     232           0 :         if(fPIDParams[method])fPIDParams[method]->Print(opt);
     233             :     }
     234           0 : }

Generated by: LCOV version 1.11