LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSMapA1.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 19 130 14.6 %
Date: 2016-06-14 17:26:59 Functions: 4 26 15.4 %

          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             : #include <TObjArray.h>
      16             : #include "AliITSMapA1.h"
      17             : #include "AliITSsegmentation.h"
      18             : #include "AliITSdigit.h"
      19             : 
      20             : ////////////////////////////////////////////////////////////////////////
      21             : //  Map Class for ITS. Implementation A1. In this implementation, the //
      22             : // 2 dimensional (iz,ix) map is filled with integers values. For each //
      23             : // cell a corresponding TObject, a hit, can also be stored.           //
      24             : //  The detector geometry is accessed via the that detectors          //
      25             : // segmentation class and stored here for conveniance.                //
      26             : ////////////////////////////////////////////////////////////////////////
      27             : 
      28         118 : ClassImp(AliITSMapA1)
      29             : //______________________________________________________________________
      30           3 : AliITSMapA1::AliITSMapA1():
      31           3 : fSegmentation(0),
      32           3 : fNpx(0),
      33           3 : fNpz(0),
      34           3 : fObjects(0),
      35           3 : fNobjects(0),
      36           3 : fMaxIndex(0),
      37           3 : fMapThresholdArr(0),
      38           3 : fHitMap(0),
      39          12 : fMapThreshold(0){
      40             :     // default constructor
      41             : 
      42           3 : }
      43             : //______________________________________________________________________
      44           0 : AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg):
      45           0 : fSegmentation(seg),
      46           0 : fNpx(0),
      47           0 : fNpz(0),
      48           0 : fObjects(0),
      49           0 : fNobjects(0),
      50           0 : fMaxIndex(0),
      51           0 : fMapThresholdArr(0),
      52           0 : fHitMap(0),
      53           0 : fMapThreshold(0){
      54             :     //constructor
      55             : 
      56           0 :     fNpz          = fSegmentation->Npz();
      57           0 :     fNpx          = fSegmentation->Npx();
      58           0 :     fMaxIndex     = fNpz*fNpx+fNpx;             // 2 halves of detector
      59           0 :     fHitMap       = new Int_t[fMaxIndex];
      60           0 :     ClearMap();
      61           0 : }
      62             : //______________________________________________________________________
      63           0 : AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj):
      64           0 : fSegmentation(seg),
      65           0 : fNpx(0),
      66           0 : fNpz(0),
      67           0 : fObjects(obj),
      68           0 : fNobjects(0),
      69           0 : fMaxIndex(0),
      70           0 : fMapThresholdArr(0),
      71           0 : fHitMap(0),
      72           0 : fMapThreshold(0){
      73             :     //constructor
      74             : 
      75           0 :   fNpz          = fSegmentation->Npz();
      76           0 :   fNpx          = fSegmentation->Npx();
      77           0 :   fMaxIndex     = fNpz*fNpx+fNpx;             // 2 halves of detector
      78           0 :   fHitMap       = new Int_t[fMaxIndex];
      79           0 :   if(fObjects) fNobjects = fObjects->GetEntriesFast();
      80           0 :   ClearMap();
      81           0 : }
      82             : //______________________________________________________________________
      83           0 : AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr):
      84           0 : fSegmentation(seg),
      85           0 : fNpx(0),
      86           0 : fNpz(0),
      87           0 : fObjects(obj),
      88           0 : fNobjects(0),
      89           0 : fMaxIndex(0),
      90           0 : fMapThresholdArr(0),
      91           0 : fHitMap(0),
      92           0 : fMapThreshold(thr){
      93             :     //constructor
      94             : 
      95           0 :   fNpz          = fSegmentation->Npz();
      96           0 :   fNpx          = fSegmentation->Npx();
      97           0 :   fMaxIndex     = fNpz*fNpx+fNpx;             // 2 halves of detector
      98           0 :   fHitMap       = new Int_t[fMaxIndex];
      99           0 :   if(fObjects) fNobjects = fObjects->GetEntriesFast();
     100           0 :   ClearMap();
     101           0 : }
     102             : //______________________________________________________________________
     103           0 : AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, TArrayI thr):
     104           0 : fSegmentation(seg),
     105           0 : fNpx(0),
     106           0 : fNpz(0),
     107           0 : fObjects(obj),
     108           0 : fNobjects(0),
     109           0 : fMaxIndex(0),
     110           0 : fMapThresholdArr(thr),
     111           0 : fHitMap(0),
     112           0 : fMapThreshold(0){
     113             :     //constructor
     114             : 
     115           0 :   fNpz          = fSegmentation->Npz();
     116           0 :   fNpx          = fSegmentation->Npx();
     117           0 :   fMaxIndex     = fNpz*fNpx+fNpx;             // 2 halves of detector
     118           0 :   fHitMap       = new Int_t[fMaxIndex];
     119           0 :   if(fObjects) fNobjects = fObjects->GetEntriesFast();
     120           0 :   ClearMap();
     121           0 : }
     122             : 
     123             : //______________________________________________________________________
     124           6 : AliITSMapA1::~AliITSMapA1(){
     125             :     //destructor
     126             : 
     127           3 :     if(fHitMap) delete[] fHitMap;
     128           3 : }
     129             : 
     130             : //______________________________________________________________________
     131             : void AliITSMapA1::ClearMap(){
     132             :     //clear array
     133             : 
     134           0 :     memset(fHitMap,0,sizeof(int)*fMaxIndex);
     135           0 : }
     136             : //______________________________________________________________________
     137             : void AliITSMapA1::SetArray(TObjArray *obj){
     138             :     // set array of objects
     139             : 
     140           0 :     fObjects =  obj;
     141           0 :     if (fObjects) fNobjects = fObjects->GetEntriesFast();
     142           0 : }
     143             : //______________________________________________________________________
     144             : Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix) const {
     145             :     //check boundaries and return an index in array
     146   189571878 :     Int_t index=fNpx*iz+ix;
     147             : 
     148             :     //if (index > fMaxIndex) {
     149    94785939 :     if (index > fMaxIndex || index < 0) {
     150           0 :         printf("\n \n \n Try to read/write outside array !!!!"
     151           0 :                " \n \n %d %d %d %d %d %d \n",iz,ix,fMaxIndex,index,fNpz,fNpx);
     152             :         // force crash
     153           0 :         return  -1;
     154             :     } else {
     155    94785939 :         return index;
     156             :     } // end if index>max or < 0
     157    94785939 : }
     158             : //______________________________________________________________________
     159             : void  AliITSMapA1::FillMap(){
     160             :     // fill array with digits indices
     161             : 
     162           0 :     Int_t ndigits = fObjects->GetEntriesFast();
     163           0 :     if (!ndigits) return;
     164             : 
     165             :     AliITSdigit *dig;
     166           0 :     for (Int_t ndig=0; ndig<ndigits; ndig++) {
     167           0 :         dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
     168           0 :         if(dig->GetSignal() > fMapThreshold) {
     169           0 :             SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
     170           0 :         } // end if fSignal > fMapthreshold
     171             :     } // end for ndig
     172           0 : }
     173             : //______________________________________________________________________
     174             : void  AliITSMapA1::FillMap2(){
     175             :     // fill array with digits indices
     176             : 
     177           0 :     Int_t ndigits = fObjects->GetEntriesFast();
     178           0 :     if (!ndigits) return;
     179             : 
     180             :     AliITSdigit *dig;
     181           0 :     for (Int_t ndig=0; ndig<ndigits; ndig++) {
     182           0 :         dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
     183           0 :         if(dig->GetSignal() > fMapThresholdArr[dig->GetCoord1()]) {
     184           0 :             SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
     185           0 :         } // end if fSignal > fMapthreshold
     186             :     } // end for ndig
     187           0 : }
     188             : 
     189             : //______________________________________________________________________
     190             : void  AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit){
     191             :     // set the digit index at a certain position in array
     192             : 
     193           0 :     fHitMap[CheckedIndex(iz, ix)]=idigit+1;
     194           0 : }
     195             : //______________________________________________________________________
     196             : void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){
     197             :     // delete an entry in array
     198             : 
     199           0 :     fHitMap[CheckedIndex(iz, ix)]=0;
     200           0 : }
     201             : //______________________________________________________________________
     202             : void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){
     203             :     // flag an entry in array
     204             : 
     205           0 :     fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
     206           0 : }
     207             : //______________________________________________________________________
     208             : Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix) const {
     209             :     // return the digit index from a specific entry in array
     210             : 
     211           0 :     return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
     212             : }
     213             : //______________________________________________________________________
     214             : TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix) const {
     215             :     // return the pointer to the digit 
     216             : 
     217           0 :     Int_t index=GetHitIndex(iz,ix);
     218             :     // Force crash if index does not exist ! 
     219           0 :     return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
     220             : }
     221             : //______________________________________________________________________
     222             : Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix) const{
     223             :     // get a pad signal
     224             :     Double_t signal;
     225             : 
     226           0 :     AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
     227           0 :     if(dig) signal=(Double_t)dig->GetSignal();
     228             :     else signal=0.;
     229           0 :     return signal;
     230             : }
     231             : //______________________________________________________________________
     232             : FlagTypeITS AliITSMapA1::TestHit(Int_t iz, Int_t ix)  {
     233             :     // check whether the digit has already been flagged
     234             : 
     235           0 :     if (CheckedIndex(iz, ix) < 0) return kEmptyITS;
     236           0 :     Int_t inf=fHitMap[CheckedIndex(iz, ix)]; 
     237           0 :     if (inf < 0) {
     238           0 :         return kUsedITS;
     239           0 :     } else if (inf == 0) {
     240           0 :         return kEmptyITS;
     241             :     } else {
     242           0 :         return kUnusedITS;
     243             :     } // end if inf
     244           0 : }
     245             : 

Generated by: LCOV version 1.11