LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSMapA2.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 40 110 36.4 %
Date: 2016-06-14 17:26:59 Functions: 11 22 50.0 %

          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             : #include <TH1.h>
      17             : #include <TObjArray.h>
      18             : 
      19             : #include "AliITSMapA2.h"
      20             : #include "AliITSsegmentation.h"
      21             : #include "AliITSdigit.h"
      22             : 
      23             : ////////////////////////////////////////////////////////////////////////
      24             : //  Map Class for ITS. Implementation A2. In this implementation, the //
      25             : // 2 dimensional (iz,ix) map is filled with Double precision floating //
      26             : // point values. Since this class is derived for AliITSMapA1 it also  //
      27             : // has all of the functionality of that class as well. For each       //
      28             : // cell a corresponding TObject, a hit, can also be stored.           //
      29             : //  The detector geometry is accessed via the that detectors          //
      30             : // segmentation class and stored here for conveniance.                //
      31             : ////////////////////////////////////////////////////////////////////////
      32             : 
      33         118 : ClassImp(AliITSMapA2)
      34             : 
      35             : //______________________________________________________________________
      36           0 : AliITSMapA2::AliITSMapA2():
      37           0 : fHitMapD(0),
      38           0 : fMapThresholdD(0),
      39           0 : fScaleSizeX(0),
      40           0 : fScaleSizeZ(0){
      41             :     // default constructor
      42             : 
      43           0 :     fSegmentation  = 0;
      44           0 :     fNpz           = 0;
      45           0 :     fNpx           = 0;
      46           0 :     fMaxIndex      = 0;
      47           0 :     fObjects       = 0;
      48           0 :     fNobjects      = 0;
      49           0 : }
      50             : //______________________________________________________________________
      51           1 : AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg):
      52           1 : fHitMapD(0),
      53           1 : fMapThresholdD(0),
      54           1 : fScaleSizeX(1),
      55           6 : fScaleSizeZ(1){
      56             :     //constructor
      57             : 
      58           1 :     fSegmentation  = seg;
      59           2 :     fNpz           = fSegmentation->Npz();
      60           2 :     fNpx           = fSegmentation->Npx();
      61           1 :     fMaxIndex      = fNpz*fNpx+fNpx;       // 2 halves of detector
      62           2 :     fHitMapD       = new Double_t[fMaxIndex+1];
      63           1 :     fObjects       = 0;
      64           1 :     fNobjects      = 0;
      65           1 :     ClearMap();
      66           2 : }
      67             : //______________________________________________________________________
      68           2 : AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg,
      69             :                          Int_t scalesizeX, Int_t scalesizeZ):
      70           2 : fHitMapD(0),
      71           2 : fMapThresholdD(0),
      72           2 : fScaleSizeX(scalesizeX),
      73          12 : fScaleSizeZ(scalesizeZ){
      74             :     //constructor
      75             : 
      76           2 :     fSegmentation  = seg;
      77           4 :     fNpz           = fScaleSizeZ*fSegmentation->Npz();
      78           4 :     fNpx           = fScaleSizeX*fSegmentation->Npx();
      79           2 :     fMaxIndex      = fNpz*fNpx+fNpx;             // 2 halves of detector
      80           4 :     fHitMapD       = new Double_t[fMaxIndex+1];
      81           2 :     fObjects       = 0;
      82           2 :     fNobjects      = 0;
      83           2 :     ClearMap();
      84           4 : }
      85             : //______________________________________________________________________
      86           0 : AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, 
      87             :                          Double_t thresh):
      88           0 : fHitMapD(0),
      89           0 : fMapThresholdD(thresh),
      90           0 : fScaleSizeX(1),
      91           0 : fScaleSizeZ(1){
      92             :     //constructor
      93             : 
      94           0 :     fNobjects      = 0;
      95           0 :     fSegmentation  = seg;
      96           0 :     fNpz           = fSegmentation->Npz();
      97           0 :     fNpx           = fSegmentation->Npx();
      98           0 :     fMaxIndex      = fNpz*fNpx+fNpx;             // 2 halves of detector  
      99           0 :     fHitMapD       = new Double_t[fMaxIndex+1];
     100           0 :     fObjects       =  obj;
     101           0 :     if (fObjects) fNobjects = fObjects->GetEntriesFast();
     102           0 :     ClearMap();
     103           0 : }
     104             : //______________________________________________________________________
     105          18 : AliITSMapA2::~AliITSMapA2(){
     106             :     //destructor
     107             : 
     108           9 :     if (fHitMapD) delete[] fHitMapD;
     109           9 : }
     110             : 
     111             : 
     112             : //______________________________________________________________________
     113             : void AliITSMapA2::ClearMap(){
     114             :     //clear array
     115             : 
     116       18142 :     memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
     117        9071 : }
     118             : //______________________________________________________________________
     119             : void  AliITSMapA2::FillMap(){
     120             :     // fills signal map from digits - apply a threshold for signal
     121             :   
     122           0 :     if (!fObjects) return;
     123             : 
     124           0 :     Int_t ndigits = fObjects->GetEntriesFast();
     125           0 :     if (!ndigits) return;
     126             : 
     127             :     AliITSdigit *dig;
     128           0 :     for (Int_t ndig=0; ndig<ndigits; ndig++) {
     129           0 :         dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
     130           0 :         Double_t signal = (Double_t)(dig->GetSignal());
     131           0 :         if (signal > fMapThresholdD) SetHit(dig->GetCoord1(),dig->GetCoord2(),signal);
     132             :     } // end for ndig
     133           0 : }
     134             : //______________________________________________________________________
     135             : void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){
     136             :   //flag an entry
     137             : 
     138           0 :     fHitMapD[CheckedIndex(iz, ix)]=
     139           0 :                 -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
     140           0 : }
     141             : //______________________________________________________________________
     142             : TObject* AliITSMapA2::GetHit(Int_t i, Int_t /* dummy */) const {
     143             :   //return a pointer to the 1D histogram
     144             : 
     145           0 :     if (fObjects) {
     146           0 :         return fObjects->UncheckedAt(i);
     147           0 :     } else return NULL;
     148           0 : }
     149             : //______________________________________________________________________
     150             : Double_t AliITSMapA2::GetSignal(Int_t index) const {
     151             :     //get signal in a cell 
     152             : 
     153   314523695 :     if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
     154           0 :     else return 0.;
     155    62904739 : }
     156             : //______________________________________________________________________
     157             : FlagTypeITS AliITSMapA2::TestHit(Int_t iz, Int_t ix){
     158             :     // check if the entry has already been flagged
     159             : 
     160           0 :     if (CheckedIndex(iz, ix) < 0) return kEmptyITS;
     161           0 :     Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)];
     162             :     
     163           0 :     if (inf <= -1000) {
     164           0 :         return kUsedITS;
     165           0 :     } else if (inf == 0) {
     166           0 :         return kEmptyITS;
     167             :     } else {
     168           0 :         return kUnusedITS;
     169             :     } // end if inf...
     170           0 : }
     171             : //______________________________________________________________________
     172             : void  AliITSMapA2::FillMapFromHist(){
     173             :     // fills map from 1D histograms
     174             : 
     175           0 :     if (!fObjects) return;
     176             : 
     177             :     // an example
     178           0 :     for( Int_t i=0; i<fNobjects; i++) {
     179           0 :         TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
     180           0 :         Int_t nsamples = hist->GetNbinsX();
     181           0 :         for( Int_t j=0; j<nsamples; j++) {
     182           0 :             Double_t signal = (Double_t)(hist->GetBinContent(j+1));
     183           0 :             if (signal > fMapThresholdD) SetHit(i,j,signal);
     184             :         } // end for j
     185             :     } // end for i
     186           0 : }
     187             : //______________________________________________________________________
     188             : void  AliITSMapA2::FillHist(){
     189             :     // fill 1D histograms from map
     190             : 
     191           0 :     if (!fObjects || fScaleSizeX != 1) return;
     192             : 
     193             :     // an example
     194           0 :     for( Int_t i=0; i<fNobjects; i++) {
     195           0 :         TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
     196           0 :         for( Int_t j=0; j<fNpx; j++) {
     197           0 :             Double_t signal=GetSignal(i,j);
     198           0 :             if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal);
     199             :         } // end for j
     200             :     } // end for i
     201           0 : }
     202             : //______________________________________________________________________
     203             : void  AliITSMapA2::ResetHist(){
     204             :     // Reset histograms
     205             : 
     206           0 :     if (!fObjects) return;
     207             : 
     208           0 :     for( Int_t i=0; i<fNobjects; i++) {
     209           0 :         if ((*fObjects)[i])    ((TH1F*)(*fObjects)[i])->Reset();
     210             :     } // end for i
     211           0 : }
     212             : //______________________________________________________________________
     213             : void AliITSMapA2::AddSignal(Int_t iz,Int_t ix,Double_t sig){
     214             :     // Addes sig to cell iz. equivalent to the very common
     215             :     // sig = fMapA2->GetSignal(iz,ix) + sig; fMapA2->SetHit(iz,ix,sig);
     216             : 
     217             : 
     218    20882404 :     Int_t index=GetHitIndex(iz,ix);
     219    10441202 :     if(index<0) return;
     220    10441202 :     fHitMapD[CheckedIndex(iz, ix)] += sig;    
     221    20882404 : }

Generated by: LCOV version 1.11