LCOV - code coverage report
Current view: top level - TOF/TOFbase - AliTOFSDigit.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 75 145 51.7 %
Date: 2016-06-14 17:26:59 Functions: 11 17 64.7 %

          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             : //_________________________________________________________________________//
      19             : //                                                                         //
      20             : //  TOF sdigit: member variables                                           //
      21             : //  fSector  : TOF sector                                                  //
      22             : //  fPlate   : TOF plate                                                   //
      23             : //  fStrip   : strips number                                               //
      24             : //  fPadx    : pad number along x                                          //
      25             : //  fPadz    : pad number along z                                          //
      26             : //  fTdc     : TArrayI of TDC values                                       //
      27             : //  fAdc     : TArrayI of ADC values                                       //
      28             : //                                                                         //
      29             : //  Getters, setters and member functions  defined here                    //
      30             : //                                                                         //
      31             : // -- Authors: F. Pierella, A. Seganti, D. Vicinanza                       //
      32             : //_________________________________________________________________________//
      33             : 
      34             : #include "AliLog.h"
      35             : 
      36             : #include "AliTOFGeometry.h"
      37             : #include "AliTOFSDigit.h"
      38             : 
      39          26 : ClassImp(AliTOFSDigit)
      40             : 
      41             : ////////////////////////////////////////////////////////////////////////
      42          65 : AliTOFSDigit::AliTOFSDigit():
      43          65 :   fSector(-1),
      44          65 :   fPlate(-1),
      45          65 :   fStrip(-1),
      46          65 :   fPadx(-1),
      47          65 :   fPadz(-1),
      48          65 :   fNDigits(0),
      49          65 :   fTdc(0x0),
      50          65 :   fAdc(0x0),
      51          65 :   fTracks(0x0)
      52         325 : {
      53             :   //
      54             :   // default ctor
      55             :   //
      56         130 : }
      57             : 
      58             : ////////////////////////////////////////////////////////////////////////
      59             : AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t * const vol,Int_t * const digit):
      60         100 :   TObject(),
      61         100 :   fSector(-1),
      62         100 :   fPlate(-1),
      63         100 :   fStrip(-1),
      64         100 :   fPadx(-1),
      65         100 :   fPadz(-1),
      66         100 :   fNDigits(0),
      67         100 :   fTdc(0x0),
      68         100 :   fAdc(0x0),
      69         100 :   fTracks(0x0)
      70         500 : {
      71             :   //
      72             :   // Constructor of digit object
      73             :   //
      74             : 
      75         100 :   fSector = vol[0];
      76         100 :   fPlate  = vol[1];
      77         100 :   fStrip  = vol[2];
      78         100 :   fPadx   = vol[3];
      79         100 :   fPadz   = vol[4];
      80         100 :   fNDigits = 1;
      81         300 :   fTdc = new TArrayI(fNDigits);
      82         200 :   (*fTdc)[0] = digit[0];
      83         300 :   fAdc = new TArrayI(fNDigits);
      84         200 :   (*fAdc)[0] = digit[1];
      85         300 :   fTracks = new TArrayI(kMAXDIGITS*fNDigits);
      86         200 :   (*fTracks)[0] = tracknum;
      87         600 :   for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) {
      88         400 :     (*fTracks)[i] = -1;
      89             :   }
      90         200 : }
      91             : 
      92             : ////////////////////////////////////////////////////////////////////////
      93             : AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit):
      94         100 :   TObject(digit),
      95         100 :   fSector(digit.fSector),
      96         100 :   fPlate(digit.fPlate),
      97         100 :   fStrip(digit.fStrip),
      98         100 :   fPadx(digit.fPadx),
      99         100 :   fPadz(digit.fPadz),
     100         100 :   fNDigits(digit.fNDigits),
     101         100 :   fTdc(0x0),
     102         100 :   fAdc(0x0),
     103         100 :   fTracks(0x0)
     104         500 : {
     105             :   // 
     106             :   // copy ctor for AliTOFSDigit object
     107             :   //
     108         300 :   fTdc = new TArrayI(*digit.fTdc);  
     109         300 :   fAdc = new TArrayI(*digit.fAdc);
     110         300 :   fTracks = new TArrayI(*digit.fTracks);
     111         200 : }
     112             : 
     113             : ////////////////////////////////////////////////////////////////////////
     114             : AliTOFSDigit& AliTOFSDigit::operator=(const AliTOFSDigit & digit)
     115             : {
     116             :   // 
     117             :   // copy ctor for AliTOFSDigit object
     118             :   //
     119             : 
     120           0 :   if (this == &digit)
     121           0 :     return *this;
     122             : 
     123           0 :   TObject::operator=(digit);
     124           0 :   fSector = digit.fSector;
     125           0 :   fPlate  = digit.fPlate;
     126           0 :   fStrip  = digit.fStrip;
     127           0 :   fPadx   = digit.fPadx;
     128           0 :   fPadz   = digit.fPadz;
     129           0 :   fNDigits = digit.fNDigits;
     130           0 :   fTdc = digit.fTdc;
     131           0 :   fAdc = digit.fAdc;
     132           0 :   fTracks = digit.fTracks;
     133           0 :   return *this;
     134             : 
     135           0 : }
     136             : 
     137             : ////////////////////////////////////////////////////////////////////////
     138           0 : AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
     139             :                            Int_t padz, Int_t tdc, Int_t adc):
     140           0 :   fSector(sector),
     141           0 :   fPlate(plate),
     142           0 :   fStrip(strip),
     143           0 :   fPadx(padx),
     144           0 :   fPadz(padz),
     145           0 :   fNDigits(1),
     146           0 :   fTdc(0x0),
     147           0 :   fAdc(0x0),
     148           0 :   fTracks(0x0)
     149           0 : {
     150             :   //
     151             :   // Constructor for sdigit
     152             :   //
     153           0 :   fTdc = new TArrayI(fNDigits);
     154           0 :   (*fTdc)[0] = tdc;   
     155           0 :   fAdc = new TArrayI(fNDigits);
     156           0 :   (*fAdc)[0] = adc;   
     157             :   // no tracks were specified, set them to -1
     158           0 :   fTracks = new TArrayI(kMAXDIGITS*fNDigits);
     159           0 :   for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) {
     160           0 :     (*fTracks)[i] = -1;
     161             :   }
     162           0 : }
     163             : 
     164             : ////////////////////////////////////////////////////////////////////////
     165             : void AliTOFSDigit::GetLocation(Int_t *Loc) const
     166             : {
     167             :   //
     168             :   // Get the coordinates of the digit
     169             :   // in terms of Sector - Plate - Strip - Pad
     170             :   //
     171             :   
     172           0 :   Loc[0]=fSector;
     173           0 :   Loc[1]=fPlate;
     174           0 :   Loc[2]=fStrip;
     175           0 :   Loc[3]=fPadx;
     176           0 :   Loc[4]=fPadz;
     177           0 : }
     178             : 
     179             : ////////////////////////////////////////////////////////////////////////
     180             : void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track)
     181             : {
     182             :   //
     183             :   // Add charge and track
     184             :   //
     185             :   
     186             :   Int_t sameTime = -1;
     187          20 :   Float_t tdcwindow = AliTOFGeometry::DeadTime()/tdcbin;
     188          20 :   for (Int_t i = 0; i < fNDigits; i++) {
     189          10 :     if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
     190             :       sameTime = i;
     191          10 :       break;
     192             :     }
     193             :   }
     194             :   
     195          10 :   if (sameTime >= 0) { // another time measurement happens during the
     196             :                        // dead time of the hit pad => it corresponds
     197             :                        // to the same time measurement
     198          10 :     (*fAdc)[sameTime] += adc;
     199             : 
     200             :     // update track index array in case the current digit track index
     201             :     // is different from -1
     202          10 :     if (track!=-1) {
     203             : 
     204             :       //Find the first -1 value of the track index array and replace
     205             :       //it by the current digit track index
     206          49 :       for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
     207          23 :         if (track==(*fTracks)[sameTime*kMAXDIGITS+iTrack]) break;
     208          23 :         if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
     209           9 :           (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
     210           9 :           break;
     211             :         }
     212             :         // write warning about many tracks going to this pad at same time
     213          14 :         if (iTrack == kMAXDIGITS-1) {
     214           3 :           AliDebug(1,Form("Update: Many different tracks in the same TOF pad"
     215             :                           " (%2d %1d %2d %1d %2d)\n",
     216             :                           fSector,fPlate,fStrip,fPadz,fPadx));
     217             :           //ToAliWarning(PrintPad());
     218             :         }
     219             :       }
     220          10 :     }
     221             : 
     222             :   } else { // they are two different time measurements
     223             : 
     224             :     // add new time slot
     225           0 :     fNDigits++;
     226           0 :     fTdc->Set(fNDigits);
     227           0 :     (*fTdc)[fNDigits-1] = tdc;
     228           0 :     fAdc->Set(fNDigits);
     229           0 :     (*fAdc)[fNDigits-1] = adc;
     230           0 :     fTracks->Set(fNDigits*kMAXDIGITS);
     231           0 :     (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
     232           0 :     for (Int_t i = 1; i <kMAXDIGITS; i++)
     233           0 :       (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
     234             : 
     235             :   }
     236             :   
     237          10 : }
     238             : 
     239             : ////////////////////////////////////////////////////////////////////////
     240             : void AliTOFSDigit::Update(AliTOFSDigit * const sdig)
     241             : {
     242             : 
     243             :   //
     244             :   // Perform the sum with sdig
     245             :   //
     246             : 
     247           0 :   Float_t tdcbin = AliTOFGeometry::TdcBinWidth();// [ps] hardwired for the time being
     248             : 
     249             :   Int_t track = -1;
     250             :   Int_t adc = -1;
     251             :   Int_t tdc = -1;
     252             : 
     253             :   // start loop on all sdig locations
     254           0 :   Int_t nlocations = sdig->GetNDigits();
     255           0 :   for (Int_t j = 0; j < nlocations; j++) {
     256           0 :     tdc = (Int_t)sdig->GetTdc(j);
     257           0 :     adc = (Int_t)sdig->GetAdc(j);
     258             : 
     259             :     // getting here only the first track number
     260             :     //Int_t track = GetTrack(j,0);
     261             : 
     262             :     // getting here all the track numbers
     263           0 :     for (Int_t iTrack = 0; iTrack<kMAXDIGITS; iTrack++) {
     264           0 :       track = sdig->GetTrack(j,iTrack);
     265           0 :       Update(tdcbin, tdc, adc, track);
     266             :     } // end loop on tracks
     267             : 
     268             :   } // end loop on sdig locations
     269             : 
     270             : 
     271           0 : }
     272             : 
     273             : ////////////////////////////////////////////////////////////////////////
     274             : AliTOFSDigit::~AliTOFSDigit()
     275         774 : {
     276             :   //
     277             :   // dtor
     278             :   //
     279         257 :   delete fTdc;
     280         257 :   delete fAdc;
     281         257 :   delete fTracks;
     282         387 : }
     283             : 
     284             : ////////////////////////////////////////////////////////////////////////
     285             : 
     286             : Int_t AliTOFSDigit::GetTotPad() const
     287             : {
     288             :   //
     289             :   // Get the "total" index of the pad inside a Sector
     290             :   // starting from the digits data.
     291             :   //
     292             :   
     293           0 :   Int_t pad = AliTOFGeometry::NpadZ()*fPadx + fPadz;
     294             :   Int_t before=0;
     295             :   
     296           0 :   switch(fPlate){ 
     297             :   case 0:
     298             :     //before = 0;
     299             :     break;
     300             :   case 1:
     301           0 :     before = AliTOFGeometry::NStripC();
     302           0 :     break;
     303             :   case 2:
     304           0 :     before = AliTOFGeometry::NStripB() +   AliTOFGeometry::NStripC();
     305           0 :     break;
     306             :   case 3:
     307           0 :     before = AliTOFGeometry::NStripA() +   AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC();
     308           0 :     break;
     309             :   case 4:
     310           0 :     before = AliTOFGeometry::NStripA() + 2*AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC();
     311           0 :     break;
     312             :   }
     313             :   
     314           0 :   Int_t strip = fStrip + before;
     315           0 :   Int_t padTot = AliTOFGeometry::NpadXStrip()*strip + pad;
     316           0 :   return padTot;
     317             : }

Generated by: LCOV version 1.11