LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSdigitSDD.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 21 78 26.9 %
Date: 2016-06-14 17:26:59 Functions: 6 15 40.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 2004-2006, 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 <AliITSdigitSDD.h>
      17             : #include <AliITSCalibrationSDD.h>
      18             : #include <TArrayI.h>
      19             : #include <TArrayF.h>
      20             : #include <iostream>
      21             : 
      22             : ///////////////////////////////////////////////////////////////////
      23             : //                                                               //
      24             : // Class defining the digit object
      25             : // for SDD
      26             : // Inherits from AliITSdigit
      27             : //                                                               //
      28             : ///////////////////////////////////////////////////////////////////
      29             : 
      30         118 : ClassImp(AliITSdigitSDD)
      31             : 
      32             : 
      33             : //______________________________________________________________________
      34         127 : AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(),
      35         127 : fPhysics(0),
      36         762 : fSignalExpanded(0){
      37             :     // default constructor, zero coordinates and set array
      38             :     // elements to clearly unphysical values. A value of 0 may
      39             :     // be a valide track of hit number.
      40             :     Int_t i;
      41             : 
      42        2794 :     for(i=0;i<fgkSize;i++) fTracks[i] = -3;
      43        2794 :     for(i=0;i<fgkSize;i++) fHits[i]   = -1;
      44        2794 :     for(i=0;i<fgkSize;i++) fTcharges[i] = 0;
      45         127 :     SetSignalExpanded(-1000);
      46         254 : }
      47             : //________________________________________________________________________
      48           0 : AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): AliITSdigit(digits),
      49           0 : fPhysics(phys),
      50           0 : fSignalExpanded(0){
      51             :  
      52             :    // Creates a simulated SDD digit object to be updated
      53           0 :   for(Int_t i=0;i<fgkSize;i++) fTracks[i] = -3;
      54           0 :   for(Int_t i=0;i<fgkSize;i++) fHits[i]   = -1;
      55           0 :   for(Int_t i=0;i<fgkSize;i++) fTcharges[i] = 0;
      56             :   
      57           0 :   SetSignalExpanded(-1000);
      58           0 : }
      59             : 
      60             : //________________________________________________________________________
      61             : void AliITSdigitSDD::InitObject(Float_t phys,const Int_t *tracks,
      62             :                            const Int_t *hits,const Float_t *charges){
      63             : 
      64             :   // Protected function used by standard constructors
      65        1286 :   fPhysics = phys;
      66       14146 :   for(Int_t i=0; i<fgkSize; i++) {
      67        6430 :     fTcharges[i] = charges[i];
      68        6430 :     fTracks[i]   = tracks[i];
      69        6430 :     fHits[i]     = hits[i];
      70             :   }
      71         643 : }
      72             :  
      73             : //_____________________________________________________________________________
      74             : AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
      75             :                                const Int_t *tracks,const Int_t *hits,
      76           0 :                                const Float_t *charges):AliITSdigit(digits),
      77           0 : fPhysics(0),
      78           0 : fSignalExpanded(0){
      79             : 
      80             : // standard constructor
      81           0 :   InitObject(phys,tracks,hits,charges);
      82           0 :   SetSignalExpanded(-1000);
      83           0 : }
      84             : //_____________________________________________________________________________
      85             : AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
      86         643 :     const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): AliITSdigit(digits),
      87         643 : fPhysics(0),
      88        3858 : fSignalExpanded(0){
      89             : 
      90             :   //constructor setting also fSignalExpanded
      91         643 :   InitObject(phys,tracks,hits,charges);
      92         643 :   SetSignalExpanded(sige);
      93        1286 : }
      94             : 
      95             : //_____________________________________________________________________________
      96             : Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){
      97             : 
      98             :     // Fills the TArrayI t with the tracks found in fTracks removing
      99             :     // duplicated tracks, summing up their charge, and ordering the tracks
     100             :     // by the charge contributed to this digit. It will return
     101             :     // the number of tracks and fill the remaining elements to the array
     102             :     // t with -1.
     103             :     // Inputs:
     104             :     //   TArrayI  &t Reference to a TArrayI to contain the list of
     105             :     //               nonduplicated track numbers.
     106             :     //   TArrayF  &c Reference to a TArrayF to contain the summed charge
     107             :     //               contributed by each track.
     108             :     // Output:
     109             :     //   TArrayI  &t The input array filled with the nonduplicated track
     110             :     //               numbers.
     111             :     //   TArrayF  &c The input array filled with the summed charge 
     112             :     //               contributed by the corresponding track in the array t.
     113             :     // Return:
     114             :     //   Int_t The number of none -1 entries in the TArrayI t.
     115           0 :     Int_t nt = t.GetSize();
     116           0 :     nt = TMath::Min(nt,c.GetSize());
     117           0 :     Int_t nth = this->GetNTracks();
     118             :     Int_t n = 0,i,j;
     119             :     Bool_t inlist = kFALSE;
     120             : 
     121           0 :     t.Reset(-1); // -1 array.
     122           0 :     c.Reset(0.0); // zero array.
     123           0 :     for(i=0;i<nth;i++) {
     124           0 :         if(this->GetTrack(i) == -1) continue;
     125             :         inlist = kFALSE;
     126           0 :         for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){
     127             :             inlist = kTRUE;
     128           0 :             c.AddAt(this->GetCharge(i)+c.At(j),j);
     129           0 :         } // end for j/end if
     130           0 :         if(!inlist){ // add to end of list
     131           0 :             t.AddAt(this->GetTrack(i),n);
     132           0 :             c.AddAt(this->GetCharge(i),n);
     133           0 :             if(n<nt) n++;
     134             :         } // end if
     135             :     } // end for i
     136             : 
     137             :     // Now lets sort the TArrays according to the charge. This algorithm
     138             :     // is based on the method from Chapter 8 section 1 Straight Insertion
     139             :     // sort. Wiliam H. Press, Saul A. Teukolsky, William T. Vetterling
     140             :     // and Brian P. Flannery, "Numerical Recipeis in C, The Art of Scientific
     141             :     // Computing", second Edition page 330 (1997).
     142             :     Int_t   tr;
     143             :     Float_t ch;
     144           0 :     for(i=0;i<n;i++){
     145           0 :         tr = t.At(i);
     146           0 :         ch = c.At(i);
     147           0 :         j = i-1;
     148           0 :         while(j>-1 && c.At(j)>ch){
     149           0 :             t.AddAt(t.At(j+1),j);
     150           0 :             c.AddAt(c.At(j+1),j);
     151           0 :             j--;
     152             :         } // end while
     153           0 :         t.AddAt(tr,j+1);
     154           0 :         c.AddAt(ch,j+1);
     155             :     } // end for i
     156             :     //
     157           0 :     return n;
     158             : }
     159             : 
     160             : 
     161             : //______________________________________________________________________
     162             : void AliITSdigitSDD::Print(ostream *os){
     163             : 
     164             : 
     165             :   //Standard output format for this class
     166             :     Int_t i;
     167             : 
     168           0 :     AliITSdigit::Print(os);
     169           0 :     *os <<","<< fPhysics;
     170           0 :     for(i=0; i<fgkSize; i++) *os <<","<< fTcharges[i];
     171           0 :     for(i=0; i<fgkSize; i++) *os <<","<< fTracks[i];
     172           0 :     for(i=0; i<fgkSize; i++) *os <<","<< fHits[i];
     173           0 :     *os <<","<< fSignalExpanded;
     174           0 : }
     175             : //______________________________________________________________________
     176             : void AliITSdigitSDD::Read(istream *os){
     177             : 
     178             :   //Standard input for this class
     179             :   Int_t i;
     180             : 
     181           0 :     AliITSdigit::Read(os);
     182           0 :     *os >>fPhysics;
     183           0 :     for(i=0; i<fgkSize; i++) *os >> fTcharges[i];
     184           0 :     for(i=0; i<fgkSize; i++) *os >> fTracks[i];
     185           0 :     for(i=0; i<fgkSize; i++) *os >> fHits[i];
     186           0 :     *os >>fSignalExpanded;
     187           0 : }
     188             : //______________________________________________________________________
     189             : ostream &operator<<(ostream &os,AliITSdigitSDD &source){
     190             : 
     191             :   // Standard output streaming function.
     192             : 
     193           0 :     source.Print(&os);
     194           0 :     return os;
     195             : }
     196             : //______________________________________________________________________
     197             : istream &operator>>(istream &os,AliITSdigitSDD &source){
     198             :   
     199             :   // Standard output streaming function.
     200             : 
     201           0 :     source.Read(&os);
     202           0 :     return os;
     203             : }

Generated by: LCOV version 1.11