LCOV - code coverage report
Current view: top level - TOF/TOFbase - AliTOFResponseParams.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 44 13.6 %
Date: 2016-06-14 17:26:59 Functions: 3 13 23.1 %

          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             : // *
      19             : // * this class defines the TOF object to be stored
      20             : // * in OCDB in order to have TOF response correction
      21             : // * and actual resolution
      22             : // * 
      23             : // *
      24             : // *
      25             : // *
      26             : 
      27             : #include "AliTOFResponseParams.h"
      28             : #include "TGraph.h"
      29             : 
      30          26 : ClassImp(AliTOFResponseParams)
      31             : 
      32             : //_________________________________________________________
      33             : 
      34             : AliTOFResponseParams::AliTOFResponseParams() :
      35           4 :   TObject()
      36          20 : {
      37             :   /*
      38             :    * default constructor
      39             :    */
      40             : 
      41          48 :   for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
      42          20 :     fNPoints[ipart] = 0;
      43           8 : }
      44             : 
      45             : //_________________________________________________________
      46             : 
      47             : AliTOFResponseParams::AliTOFResponseParams(Int_t *nPoints) :
      48           0 :   TObject()
      49           0 : {
      50             :   /*
      51             :    * default constructor
      52             :    */
      53             : 
      54           0 :   for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
      55           0 :     fNPoints[ipart] = nPoints[ipart] < fgkMaxPoints ? nPoints[ipart] : fgkMaxPoints;
      56           0 : }
      57             : 
      58             : //_________________________________________________________
      59             : 
      60             : AliTOFResponseParams::~AliTOFResponseParams()
      61           0 : {
      62             :   /*
      63             :    * default destructor
      64             :    */
      65             : 
      66           0 : }
      67             : 
      68             : //_________________________________________________________
      69             : 
      70             : AliTOFResponseParams::AliTOFResponseParams(const AliTOFResponseParams &source) :
      71           0 :   TObject(source)
      72           0 : {
      73             :   /*
      74             :    * copy constructor
      75             :    */
      76             : 
      77           0 :   for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++) {
      78           0 :     fNPoints[ipart] = source.fNPoints[ipart];
      79           0 :     for (Int_t ipoint = 0; ipoint < fNPoints[ipart]; ipoint++) {
      80           0 :       fP[ipart][ipoint] = source.fP[ipart][ipoint];
      81           0 :       fTExpCorr[ipart][ipoint] = source.fTExpCorr[ipart][ipoint];
      82             :     }
      83             :   }
      84             :     
      85           0 : }
      86             : 
      87             : //_________________________________________________________
      88             : 
      89             : AliTOFResponseParams &
      90             : AliTOFResponseParams::operator=(const AliTOFResponseParams &source)
      91             : {
      92             :   /*
      93             :    * operator=
      94             :    */
      95             : 
      96           0 :   if (this == &source) return *this;
      97           0 :   TObject::operator=(source);
      98             :   
      99           0 :   for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++) {
     100           0 :     fNPoints[ipart] = source.fNPoints[ipart];
     101           0 :     for (Int_t ipoint = 0; ipoint < fNPoints[ipart]; ipoint++) {
     102           0 :       fP[ipart][ipoint] = source.fP[ipart][ipoint];
     103           0 :       fTExpCorr[ipart][ipoint] = source.fTExpCorr[ipart][ipoint];
     104             :     }
     105             :   }
     106             :     
     107           0 :   return *this;
     108           0 : }
     109             : 
     110             : //_________________________________________________________
     111             : 
     112             : TGraph *
     113             : AliTOFResponseParams::DrawGraph(Int_t ipart, Option_t* option)
     114             : {
     115             :   /*
     116             :    * draw
     117             :    */
     118             : 
     119           0 :   if (ipart >= AliPID::kSPECIES) return NULL;
     120           0 :   if (fNPoints[ipart] == 0) return NULL;
     121             : 
     122           0 :   TGraph *graph = new TGraph(fNPoints[ipart], fP[ipart], fTExpCorr[ipart]);
     123           0 :   graph->Draw(option);
     124             :   return graph;
     125           0 : }
     126             : 
     127             : //_________________________________________________________
     128             : 
     129             : Double_t
     130             : AliTOFResponseParams::EvalTExpCorr(Int_t ipart, Double_t p)
     131             : {
     132             :   /*
     133             :    * eval corr
     134             :    */
     135             : 
     136           0 :   if (ipart >= AliPID::kSPECIES) return 0.;
     137           0 :   if (fNPoints[ipart] == 0) return 0.;
     138           0 :   if (p < fP[ipart][0]) return fTExpCorr[ipart][0];
     139           0 :   if (p >= fP[ipart][fNPoints[ipart] - 1]) return fTExpCorr[ipart][fNPoints[ipart] - 1];
     140             :   
     141             :   Int_t ipoint;
     142           0 :   for (ipoint = 0; ipoint < fNPoints[ipart] - 1; ipoint++)
     143           0 :     if (p >= fP[ipart][ipoint] && p < fP[ipart][ipoint + 1]) break;
     144           0 :   Double_t coeff = (fTExpCorr[ipart][ipoint + 1] - fTExpCorr[ipart][ipoint]) / (fP[ipart][ipoint + 1] - fP[ipart][ipoint]);
     145           0 :   Double_t corr = fTExpCorr[ipart][ipoint] + coeff * (p - fP[ipart][ipoint]);
     146             :   return corr;
     147           0 : }

Generated by: LCOV version 1.11