LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSpListItem.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 113 193 58.5 %
Date: 2016-06-14 17:26:59 Functions: 13 26 50.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-2004, 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 <Riostream.h>
      16             : #include <TMath.h>
      17             : #include "AliLog.h"
      18             : #include "AliITSpListItem.h"
      19             : // ************************************************************************
      20             : // the data member "fa" of the AliITSpList class
      21             : // is a TObjectArray of AliITSpListItem objects
      22             : // each AliITSpListItem object contains information related to
      23             : // the digitization such signal, noise, module number,...
      24             : // plus some info related to the simulation (hits/track)
      25             : // in order to allow efficiency studies
      26             : //************************************************************************
      27         118 : ClassImp(AliITSpListItem)
      28             : //______________________________________________________________________
      29      566784 : AliITSpListItem::AliITSpListItem():
      30      566784 : fmodule(-1),
      31      566784 : findex(-1),
      32      566784 : fTsignal(0.0),
      33      566784 : fNoise(0.0),
      34      566784 : fSignalAfterElect(0.0),
      35     3400704 : fUsed(kFALSE){
      36             :     // Default constructor
      37             :     // Inputs:
      38             :     //    none.
      39             :     // Outputs:
      40             :     //    none.
      41             :     // Return:
      42             :     //    A zeroed/empty AliITSpListItem class.
      43             : 
      44    12469248 :     for(Int_t i=0;i<this->fgksize;i++){
      45     5667840 :         this->fTrack[i]  = -2;
      46     5667840 :         this->fHits[i]   = -1;
      47     5667840 :         this->fSignal[i] = 0.0;
      48     5667840 :         this->fInFastOrStrobe[i] = kFALSE;
      49             :     } // end if i
      50     1133568 : }
      51             : //______________________________________________________________________
      52     6422528 : AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise):
      53     6422528 : fmodule(module),
      54     6422528 : findex(index),
      55     6422528 : fTsignal(0.0),
      56     6422528 : fNoise(noise),
      57     6422528 : fSignalAfterElect(0.0),
      58    38535168 : fUsed(kTRUE){
      59             :     // Standard noise constructor
      60             :     // Inputs:
      61             :     //    Int_t module   The module where this noise occurred
      62             :     //    Int_t index    The cell index where this noise occurred
      63             :     //    Double_t noise The value of the noise.
      64             :     // Outputs:
      65             :     //    none.
      66             :     // Return:
      67             :     //    A setup and noise filled AliITSpListItem class.
      68             : 
      69   141295616 :     for(Int_t i=0;i<this->fgksize;i++){
      70    64225280 :         this->fTrack[i]  = -2;
      71    64225280 :         this->fSignal[i] = 0.0;
      72    64225280 :         this->fHits[i]   = -1;
      73    64225280 :         this->fInFastOrStrobe[i] = kFALSE;
      74             :     } // end if i
      75    12845056 : }
      76             : //______________________________________________________________________
      77           0 : AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
      78             :                                Int_t index,Double_t signal):
      79           0 : fmodule(module),
      80           0 : findex(index),
      81           0 : fTsignal(signal),
      82           0 : fNoise(0.0),
      83           0 : fSignalAfterElect(0.0),
      84           0 : fUsed(kTRUE){
      85             :     // Standard signal constructor
      86             :     // Inputs:
      87             :     //    Int_t track     The track number which produced this signal
      88             :     //    Int_t hit       The hit number which produced this signal
      89             :     //    Int_t module    The module where this signal occurred
      90             :     //    Int_t index     The cell index where this signal occurred
      91             :     //    Double_t signal The value of the signal (ionization)
      92             :     // Outputs:
      93             :     //    none.
      94             :     // Return:
      95             :     //    A setup and signal filled  AliITSpListItem class.
      96             : 
      97           0 :     this->fTrack[0]  = track;
      98           0 :     this->fHits[0]   = hit;
      99           0 :     this->fSignal[0] = signal;
     100           0 :     this->fInFastOrStrobe[0] = kFALSE;
     101           0 :     for(Int_t i=1;i<this->fgksize;i++){
     102           0 :         this->fTrack[i]  = -2;
     103           0 :         this->fSignal[i] = 0.0;
     104           0 :         this->fHits[i]   = -1;
     105           0 :         this->fInFastOrStrobe[i] = kFALSE;
     106             :     } // end if i
     107           0 : }
     108             : 
     109             : //______________________________________________________________________
     110             : void AliITSpListItem::Build(Int_t module,Int_t index,Double_t noise){
     111             :   // this method resets all the data members and initializes the
     112             :   // object as in the constructor which has the same arguments
     113    95165556 :   fmodule = module;
     114    47582778 :   findex = index;
     115    47582778 :   fTsignal = 0.;
     116    47582778 :   fNoise = noise;
     117    47582778 :   fSignalAfterElect = 0.;
     118    47582778 :   fUsed = kTRUE;
     119  1046821116 :   for(Int_t i=0;i<this->fgksize;i++){
     120   475827780 :     this->fTrack[i]  = -2;
     121   475827780 :     this->fSignal[i] = 0.0;
     122   475827780 :     this->fHits[i]   = -1;
     123   475827780 :         this->fInFastOrStrobe[i] = kFALSE;
     124             :   } 
     125    47582778 : }
     126             : 
     127             : //______________________________________________________________________
     128             : void AliITSpListItem::Build(Int_t track,Int_t hit,Int_t module,Int_t index,Double_t signal){
     129             :   // this method resets all the data members and initializes the
     130             :   // object as in the constructor which has the same arguments
     131    12874376 :   fmodule = module;
     132     6437188 :   findex = index;
     133     6437188 :   fTsignal = signal;
     134     6437188 :   fNoise = 0.;
     135     6437188 :   fSignalAfterElect = 0.;
     136     6437188 :   fUsed = kTRUE;
     137     6437188 :   this->fTrack[0]  = track;
     138     6437188 :   this->fHits[0]   = hit;
     139     6437188 :   this->fSignal[0] = signal;
     140     6437188 :         this->fInFastOrStrobe[0] = kFALSE;
     141   128743760 :   for(Int_t i=1;i<this->fgksize;i++){
     142    57934692 :     this->fTrack[i]  = -2;
     143    57934692 :     this->fSignal[i] = 0.0;
     144    57934692 :     this->fHits[i]   = -1;
     145    57934692 :         this->fInFastOrStrobe[i] = kFALSE;
     146             :   } 
     147     6437188 : }
     148             : 
     149             : //______________________________________________________________________
     150             : void AliITSpListItem::Build(const AliITSpListItem &source){
     151             :   // this method resets all the data members and initializes the
     152             :   // object as in the constructor which has the same arguments
     153           0 :   fmodule = source.fmodule;
     154           0 :   findex = source.findex;
     155           0 :   fTsignal = source.fTsignal;
     156           0 :   fNoise = source.fNoise;
     157           0 :   fSignalAfterElect = source.fSignalAfterElect;
     158           0 :   fUsed = source.fUsed;
     159           0 :   for(Int_t i=0;i<this->fgksize;i++){
     160           0 :     this->fTrack[i]  = source.fTrack[i];
     161           0 :     this->fSignal[i] = source.fSignal[i];
     162           0 :     this->fHits[i]   = source.fHits[i];
     163           0 :    this->fInFastOrStrobe[i] = source.fInFastOrStrobe[i];
     164             :   }
     165           0 : }
     166             : 
     167             : //______________________________________________________________________
     168    13978624 : AliITSpListItem::~AliITSpListItem(){
     169             :     // Destructor
     170             :     // Inputs:
     171             :     //    none.
     172             :     // Outputs:
     173             :     //    none.
     174             :     // Return:
     175             :     //    A properly destroyed AliITSpListItem class.
     176             : 
     177    20967936 : }
     178             : //______________________________________________________________________
     179             : AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
     180             :     // = operator
     181             :     // Inputs:
     182             :     //    AliITSpListItem &source   A AliITSpListItem Object
     183             :     // Outputs:
     184             :     //    none.
     185             :     // Return:
     186             :     //    A copied AliITSpListItem object
     187           0 :   this->~AliITSpListItem();
     188           0 :   new(this) AliITSpListItem(source);
     189           0 :   return *this;
     190             : 
     191           0 : }
     192             : //______________________________________________________________________
     193             : AliITSpListItem::AliITSpListItem(const AliITSpListItem &source) : 
     194           0 : TObject(source),
     195           0 : fmodule(source.fmodule),
     196           0 : findex(source.findex),
     197           0 : fTsignal(source.fTsignal),
     198           0 : fNoise(source.fNoise),
     199           0 : fSignalAfterElect(source.fSignalAfterElect),
     200           0 : fUsed(source.fUsed){
     201             :     // Copy operator
     202             :     // Inputs:
     203             :     //    AliITSpListItem &source   A AliITSpListItem Object
     204             :     // Outputs:
     205             :     //    none.
     206             :     // Return:
     207             :     //    A copied AliITSpListItem object
     208             :   
     209           0 :     for(Int_t i=0;i<this->fgksize;i++){
     210           0 :       this->fTrack[i]  = source.fTrack[i];
     211           0 :       this->fSignal[i] = source.fSignal[i];
     212           0 :       this->fHits[i]   = source.fHits[i];
     213           0 :       this->fInFastOrStrobe[i] = source.fInFastOrStrobe[i];
     214             :     } // end if i
     215             : 
     216           0 : }
     217             : //______________________________________________________________________
     218             : void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
     219             :                                Int_t index,Double_t signal){
     220             :     // Adds this track number and signal to the pList and orders them
     221             :     // Inputs:
     222             :     //    Int_t track     The track number which produced this signal
     223             :     //    Int_t hit       The hit number which produced this signal
     224             :     //    Int_t module    The module where this signal occurred
     225             :     //    Int_t index     The cell index where this signal occurred
     226             :     //    Double_t signal The value of the signal (ionization)
     227             :     // Outputs:
     228             :     //    none.
     229             :     // Return:
     230             :     //    none.
     231             :     Int_t    i,j,trk,hts;
     232             :     Double_t sig;
     233             :     Bool_t   flg=kFALSE;
     234             : 
     235     1111292 :     if (TMath::Abs(signal)>2147483647.0) {
     236             :       //PH 2147483647 is the max. integer
     237             :       //PH This apparently is a problem which needs investigation
     238           0 :       AliWarning(Form("Too big or too small signal value %f",signal));
     239           0 :       signal = TMath::Sign((Double_t)2147483647,signal);
     240           0 :     }
     241     1111292 :     if(findex!=index || fmodule!=module) 
     242           0 :         Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
     243           0 :                  index,findex,module,fmodule);
     244      555646 :     fTsignal += signal; // Keep track of sum signal.
     245             : 
     246             :     //    for(i=0;i<fgksize;i++) if( track==fTrack[i] && hit==fHits[i] ){
     247    17780672 :     for(i=0;i<fgksize;i++) if( track==fTrack[i]  ){
     248      534630 :         fSignal[i] += signal;
     249             :         flg = kTRUE;
     250      534630 :     } // end for i & if.
     251             :     //cout << "track="<<track<<endl;
     252      555646 :     if(flg){ // resort arrays.  
     253    10692600 :         for(i=1;i<fgksize;i++){
     254             :             j = i;
     255    14438571 :             while(j>0 && fSignal[j]>fSignal[j-1]){
     256        1653 :                 trk = fTrack[j-1];
     257        1653 :                 hts = fHits[j-1];
     258             :                 sig = fSignal[j-1];
     259        1653 :                 fTrack[j-1]  = fTrack[j];
     260        1653 :                 fHits[j-1]   = fHits[j];
     261        1653 :                 fSignal[j-1] = fSignal[j];                
     262        1653 :                 fTrack[j]  = trk;
     263        1653 :                 fHits[j]   = hts;
     264        1653 :                 fSignal[j] = sig;
     265             :                 //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<<
     266             :                 // j<<"]="<<fTrack[j]<<endl;
     267        1653 :                 j--;
     268             :             } // end while
     269             :         } // end if i
     270      534630 :         return;
     271             :     } // end if added to existing and resorted array
     272             : 
     273             :     // new entry add it in order.
     274             :     // if this signal is <= smallest then don't add it.
     275       34032 :     if(signal <= fSignal[fgksize-1]) return;
     276      149570 :     for(i=fgksize-2;i>=0;i--){
     277       71286 :         if(signal > fSignal[i]){
     278       66785 :             fSignal[i+1] = fSignal[i];
     279       66785 :             fTrack[i+1]  = fTrack[i];
     280       66785 :             fHits[i+1]   = fHits[i];
     281             :         }else{
     282        4501 :             fSignal[i+1] = signal;
     283        4501 :             fTrack[i+1]  = track;
     284        4501 :             fHits[i+1]   = hit;
     285        4501 :             return; // put it in the right place, now exit.
     286             :         } //  end if
     287             :         //cout << "$fTrack["<<i+1<<"]="<<fTrack[i+1]<< " fTrack["<<i<<"]="
     288             :         //<<fTrack[i]<< " fHits["<<i+1<<"]="<<fHits[i+1]<< " fHits["<<i<<"]="
     289             :         //<<fHits[i]<< " fSignal["<<i+1<<"]="<<fSignal[i+1]<< " fSignal["<<i
     290             :         //<<"]="<<fSignal[i]<<endl;
     291             :     } // end if; end for i
     292             :     // Still haven't found the right place. Must be at top of list.
     293        3499 :     fSignal[0] = signal;
     294        3499 :     fTrack[0]  = track;
     295        3499 :     fHits[0]   = hit;
     296             :     //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0]
     297             :     //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl;
     298        3499 :     return;
     299      555646 : }
     300             : //______________________________________________________________________
     301             : void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
     302             :     // Adds noise to this existing list.
     303             :     // Inputs:
     304             :     //    Int_t module   The module where this noise occurred
     305             :     //    Int_t index    The cell index where this noise occurred
     306             :     //    Double_t noise The value of the noise.
     307             :     // Outputs:
     308             :     //    none.
     309             :     // Return:
     310             :     //    none.
     311             : 
     312     5205504 :     if(findex!=index || fmodule!=module) 
     313           0 :         Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d",
     314           0 :             index,findex,module,fmodule);
     315     1735168 :     fNoise += noise; // Keep track of sum signal.
     316     1735168 : }
     317             : //______________________________________________________________________
     318             : void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
     319             :     // Adds signal after electronics to this existing list.
     320             :     // Inputs:
     321             :     //    Int_t module   The module where this noise occurred
     322             :     //    Int_t index    The cell index where this noise occurred
     323             :     //    Double_t signal The value of the signal.
     324             :     // Outputs:
     325             :     //    none.
     326             :     // Return:
     327             :     //    none.
     328             : 
     329           0 :     if(findex!=index || fmodule!=module) 
     330           0 :         Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d "
     331           0 :                 "!= fmodule=%d",index,findex,module,fmodule);
     332           0 :     fSignalAfterElect += signal; // Keep track of sum signal.
     333           0 : }
     334             : //______________________________________________________________________
     335             : void AliITSpListItem::Add(AliITSpListItem *pl){
     336             :     // Adds the contents of pl to this
     337             :     // pl could come from different module and index 
     338             :     // Inputs:
     339             :     //    AliITSpListItem *pl  an AliITSpListItem to be added to this class.
     340             :     // Outputs:
     341             :     //    none.
     342             :     // Return:
     343             :     //    none.
     344             :     Int_t i;
     345             :     Double_t sig  = 0.0;
     346             :     Double_t sigT = 0.0;
     347             : 
     348       57740 :     for(i=0;i<pl->GetNsignals();i++){
     349       23379 :         sig = pl->GetSignal(i); 
     350       23379 :         if( sig <= 0.0 ) break; // no more signals
     351       12397 :         AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig);
     352       12397 :         sigT += sig;
     353             :     } // end for i
     354       10982 :     fTsignal += (pl->fTsignal - sigT);
     355       10982 :     fNoise   += pl->fNoise;
     356             :     return;
     357       10982 : }
     358             : //______________________________________________________________________
     359             : void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
     360             :     // Adds the contents of pl to this with track number off set given by
     361             :     // fileIndex.
     362             :     // Inputs:
     363             :     //    Int_t fileIndex      track number offset value
     364             :     //    AliITSpListItem *pl  an AliITSpListItem to be added to this class.
     365             :     // Outputs:
     366             :     //    none.
     367             :     // Return:
     368             :     //    none.
     369             :     Int_t i,trk;
     370             :     Double_t sig  = 0.0;
     371             : 
     372    12845056 :     Int_t module = pl->GetModule();
     373     6422528 :     Int_t index  = pl->GetIndex();
     374    12849146 :     for(i=0;i<pl->GetNsignals();i++){
     375     6424573 :         sig = pl->GetSignal(i); 
     376     6424573 :         if( sig <= 0.0 ) break; // no more signals
     377        2045 :         trk = pl->GetTrack(i);
     378        2045 :         trk += fileIndex; 
     379        2045 :         AddSignal(trk,pl->GetHit(i),module,index,sig);
     380             :     } // end for i
     381     6422528 :     fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
     382     6422528 :     fNoise = pl->fNoise;
     383             :     return;
     384     6422528 : }
     385             : //______________________________________________________________________
     386             : Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk) const {
     387             :     // Shift an index number to occupy the upper four bits. No longer used.
     388             :     // Inputs:
     389             :     //    Int_t in   The file number
     390             :     //    Int_t trk  The track number
     391             :     // Outputs:
     392             :     //    none.
     393             :     // Return:
     394             :     //    Int_t The track number with the file number in the upper bits.
     395             :     Int_t si = sizeof(Int_t) * 8;
     396             :     UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative.
     397             : 
     398             :     uin = in;
     399             :     utrk = trk;
     400           0 :     for(Int_t i=0;i<si-4;i++) uin *= 2;
     401           0 :     uin += utrk;
     402             :     in = uin;
     403           0 :     return in;
     404             : }
     405             : //______________________________________________________________________
     406             : void AliITSpListItem::Print(ostream *os) const {
     407             :     //Standard output format for this class
     408             :     // Inputs:
     409             :     //    ostream *os  The output stream
     410             :     // Outputs:
     411             :     //    none.
     412             :     // Return:
     413             :     //    none.
     414             :     Int_t i;
     415             : 
     416           0 :     *os << fmodule <<","<<findex<<",";
     417           0 :     *os << fgksize <<",";
     418           0 :     for(i=0;i<fgksize;i++) *os << fTrack[i] <<",";
     419           0 :     for(i=0;i<fgksize;i++) *os << fHits[i] <<",";
     420           0 :     for(i=0;i<fgksize;i++) *os << fSignal[i] <<",";
     421           0 :     *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect;
     422           0 : }
     423             : //______________________________________________________________________
     424             : void AliITSpListItem::Read(istream *is){
     425             :     // Standard output streaming function.
     426             :     // Inputs:
     427             :     //    istream *is The input stream
     428             :     // Outputs:
     429             :     //    none.
     430             :     // Return:
     431             :     //    none.
     432           0 :     Int_t i,iss;
     433             : 
     434           0 :     *is >> fmodule >> findex;
     435           0 :     *is >> iss; // read in fgksize
     436           0 :     for(i=0;i<fgksize&&i<iss;i++) *is >> fTrack[i];
     437           0 :     for(i=0;i<fgksize&&i<iss;i++) *is >> fHits[i];
     438           0 :     for(i=0;i<fgksize&&i<iss;i++) *is >> fSignal[i];
     439           0 :     *is >> fTsignal >> fNoise >> fSignalAfterElect;
     440           0 : }
     441             : //______________________________________________________________________
     442             : ostream &operator<<(ostream &os,AliITSpListItem &source){
     443             :     // Standard output streaming function.
     444             :     // Inputs:
     445             :     //    ostream &os             The output stream
     446             :     //    AliITSpListItem &source The AliITSpListItem object to be written out.
     447             :     // Outputs:
     448             :     //    none.
     449             :     // Return:
     450             :     //    ostream  The output stream
     451             : 
     452           0 :     source.Print(&os);
     453           0 :     return os;
     454             : }
     455             : //______________________________________________________________________
     456             : istream &operator>>(istream &os,AliITSpListItem &source){
     457             :     // Standard output streaming function.
     458             :     // Inputs:
     459             :     //    istream os              The input stream
     460             :     //    AliITSpListItem &source The AliITSpListItem object to be inputted
     461             :     // Outputs:
     462             :     //    none.
     463             :     // Return:
     464             :     //    istream The input stream.
     465             : 
     466           0 :     source.Read(&os);
     467           0 :     return os;
     468             : }

Generated by: LCOV version 1.11