LCOV - code coverage report
Current view: top level - EMCAL/EMCALbase - AliEMCALDigit.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 259 383 67.6 %
Date: 2016-06-14 17:26:59 Functions: 20 32 62.5 %

          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             : // --- ROOT system ---
      17             : #include <Riostream.h>
      18             : #include <TMath.h>
      19             : 
      20             : // --- Standard library ---
      21             : 
      22             : // --- AliRoot header files ---
      23             : 
      24             : #include "AliEMCALDigit.h"
      25             : #include "AliEMCALGeometry.h"
      26             : #include "AliLog.h" 
      27             : 
      28             : using std::cout;
      29             : using std::endl;
      30          42 : ClassImp(AliEMCALDigit)
      31             : 
      32             : //____________________________________________________________________________
      33             : AliEMCALDigit::AliEMCALDigit() :  
      34         760 : AliDigitNew(), 
      35         760 :   fAmpFloat(0.),
      36         760 :   fNSamples(0),
      37         760 :   fSamples(0x0),
      38         760 :   fNSamplesHG(0),
      39         760 :   fSamplesHG(0x0),
      40         760 :   fNprimary(0),
      41         760 :   fNMaxPrimary(5),
      42         760 :   fPrimary(0x0),
      43         760 :   fDEPrimary(0x0),
      44         760 :   fNiparent(0),
      45         760 :   fNMaxiparent(5), 
      46         760 :   fIparent(0x0),
      47         760 :   fDEParent(0x0),
      48         760 :   fMaxIter(0),
      49         760 :   fTime(0.), 
      50         760 :   fTimeR(0.),
      51         760 :   fChi2(0.),
      52         760 :   fNDF(0),
      53         760 :   fDigitType(kUnknown),
      54         760 :   fAmpCalib(-1)
      55        3800 : {
      56             :   // default ctor 
      57             : 
      58             :   // Need to initialise for reading old files
      59        1520 :   fPrimary   = new Int_t[fNMaxPrimary] ;
      60        1520 :   fDEPrimary = new Float_t[fNMaxPrimary] ;
      61        1520 :   fIparent   = new Int_t[fNMaxiparent] ; 
      62        1520 :   fDEParent  = new Float_t[fNMaxiparent] ; 
      63        9120 :   for ( Int_t i = 0; i < fNMaxPrimary ; i++) {
      64        3800 :     fPrimary[i]    = -1 ;
      65        3800 :     fDEPrimary[i]  = 0 ;
      66             :   } 
      67             : 
      68        9120 :   for ( Int_t i = 0; i < fNMaxiparent ; i++) {
      69        3800 :     fIparent[i]  = -1 ;
      70        3800 :     fDEParent[i] = 0 ;
      71             :   }
      72        1520 : }
      73             : 
      74             : //____________________________________________________________________________
      75             : AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Float_t digEnergy, Float_t time, Int_t type, Int_t index, Float_t chi2, Int_t ndf, Float_t dE) 
      76       71005 :   : AliDigitNew(),
      77       71005 :     fAmpFloat(digEnergy),
      78       71005 :     fNSamples(0),
      79       71005 :     fSamples(0x0),
      80       71005 :     fNSamplesHG(0),
      81       71005 :     fSamplesHG(0x0),
      82       71005 :     fNprimary(0),
      83       71005 :     fNMaxPrimary(25),
      84       71005 :     fPrimary(0x0),
      85       71005 :     fDEPrimary(0x0),
      86       71005 :     fNiparent(0),
      87       71005 :     fNMaxiparent(150),
      88       71005 :     fIparent(0x0),
      89       71005 :     fDEParent(0x0),
      90       71005 :     fMaxIter(5),
      91       71005 :     fTime(time),
      92       71005 :     fTimeR(time),
      93       71005 :     fChi2(chi2),
      94       71005 :     fNDF(ndf),
      95       71005 :     fDigitType(type),
      96       71005 :     fAmpCalib(-1)
      97      355025 : {  
      98             :   // ctor with all data 
      99             : 
     100             :   // data memebrs of the base class (AliNewDigit)
     101       71005 :   fAmp         = 0;
     102       71005 :   fId          = id ;
     103       71005 :   fIndexInList = index ; 
     104             : 
     105             :   // data member  
     106      142010 :   fPrimary   = new Int_t[fNMaxPrimary] ;
     107      142010 :   fDEPrimary = new Float_t[fNMaxPrimary] ;
     108      142010 :   fIparent   = new Int_t[fNMaxiparent] ; 
     109      142010 :   fDEParent  = new Float_t[fNMaxiparent] ; 
     110       71005 :   if( primary != -1){
     111          56 :     fNprimary    = 1 ; 
     112          56 :     fPrimary[0]  = primary ;  
     113          56 :     fDEPrimary[0] = dE ;  
     114          56 :     fNiparent   = 1 ;
     115          56 :     fIparent[0] = iparent ;    
     116          56 :     fDEParent[0] = dE ;  
     117          56 :   }
     118             :   else{  //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
     119       70949 :     fNprimary    = 0 ; 
     120       70949 :     fPrimary[0]  = -1 ;
     121       70949 :     fDEPrimary[0]  = 0 ;
     122       70949 :     fNiparent   = 0 ;
     123       70949 :     fIparent[0] = -1 ;  
     124       70949 :     fDEParent[0]  = 0 ;  
     125             :   }
     126             :   Int_t i ;
     127     3550250 :   for ( i = 1; i < fNMaxPrimary ; i++) {
     128     1704120 :     fPrimary[i]  = -1 ; 
     129     1704120 :     fDEPrimary[i]  = 0 ;
     130             :   } 
     131             : 
     132    21301500 :   for ( i = 1; i< fNMaxiparent ; i++) {
     133    10579745 :     fIparent[i] = -1 ;  
     134    10579745 :     fDEParent[i] = 0 ;
     135             :   }  
     136      142010 : }
     137             : 
     138             : //____________________________________________________________________________
     139             : AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) 
     140        1096 :   : AliDigitNew(digit),
     141        1096 :     fAmpFloat(digit.fAmpFloat), 
     142        1096 :     fNSamples(digit.fNSamples),
     143        1096 :     fSamples(),
     144        1096 :     fNSamplesHG(digit.fNSamplesHG),
     145        1096 :     fSamplesHG(),
     146        1096 :     fNprimary(digit.fNprimary),
     147        1096 :     fNMaxPrimary(digit.fNMaxPrimary),
     148        1096 :     fPrimary(),
     149        1096 :     fDEPrimary(),
     150        1096 :     fNiparent(digit.fNiparent),
     151        1096 :     fNMaxiparent(digit.fNMaxiparent),
     152        1096 :     fIparent(),
     153        1096 :     fDEParent(),
     154        1096 :     fMaxIter(digit.fMaxIter),
     155        1096 :     fTime(digit.fTime),
     156        1096 :     fTimeR(digit.fTimeR), 
     157        1096 :     fChi2(digit.fChi2), 
     158        1096 :     fNDF(digit.fNDF),
     159        1096 :     fDigitType(digit.fDigitType),
     160        1096 :     fAmpCalib(digit.fAmpCalib)
     161        5480 : {
     162             :   // copy ctor
     163             :   // data memebrs of the base class (AliNewDigit)
     164        1096 :   fAmp         = digit.fAmp ;
     165        1096 :   fId          = digit.fId;
     166        1096 :   fIndexInList = digit.fIndexInList ; 
     167             : 
     168             :   // data members  
     169        2192 :   if (fSamples )   delete [] fSamples ;   fSamples   = NULL ;
     170        2192 :   if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ;
     171        2192 :   if (fPrimary  )  delete [] fPrimary ;   fPrimary   = NULL ;
     172        2192 :   if (fDEPrimary)  delete [] fDEPrimary ; fDEPrimary = NULL ;
     173        2192 :   if (fIparent )   delete [] fIparent ;   fIparent   = NULL ;
     174        2192 :   if (fDEParent)   delete [] fDEParent ;  fDEParent  = NULL ;
     175             : 
     176        1096 :   if (fNSamples){
     177           0 :     fSamples     = new Int_t[fNSamples]; 
     178           0 :     for (Int_t i=0; i < digit.fNSamples; i++) fSamples[i] = digit.fSamples[i];
     179           0 :   }
     180             :   
     181        1096 :   if (fNSamplesHG){
     182           0 :     fSamplesHG   = new Int_t[fNSamplesHG]; 
     183           0 :     for (Int_t i=0; i < digit.fNSamplesHG; i++) fSamplesHG[i] = digit.fSamplesHG[i];
     184           0 :   }
     185             :   
     186             :  
     187        1096 :   if (fNMaxPrimary){
     188        2192 :     fPrimary   = new Int_t  [fNMaxPrimary] ;  
     189        2192 :     fDEPrimary = new Float_t[fNMaxPrimary] ;
     190       56992 :     for ( Int_t i = 0; i < fNMaxPrimary ; i++) {
     191       27400 :       fPrimary[i]   = digit.fPrimary[i] ;
     192       27400 :       fDEPrimary[i] = digit.fDEPrimary[i] ;
     193             :     }
     194        1096 :   }
     195             :   
     196        1096 :   if (fNMaxiparent){
     197        2192 :     fIparent  = new Int_t  [fNMaxiparent] ;
     198        2192 :     fDEParent = new Float_t[fNMaxiparent] ;
     199      330992 :     for (Int_t j = 0; j< fNMaxiparent ; j++) {
     200      164400 :     fIparent[j]  = digit.fIparent[j] ;
     201      164400 :     fDEParent[j] = digit.fDEParent[j] ;
     202             :     }
     203        1096 :   }  
     204             :  
     205        2192 : }
     206             : 
     207             : //____________________________________________________________________________
     208             : AliEMCALDigit::~AliEMCALDigit() 
     209      434698 : {
     210             :   // Delete array of primaries if any
     211             : 
     212      145346 :   if (fSamples )   delete [] fSamples ;   fSamples   = NULL ;
     213      145346 :   if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ;
     214      290484 :   if (fPrimary  )  delete [] fPrimary ;   fPrimary   = NULL ;
     215      290484 :   if (fDEPrimary)  delete [] fDEPrimary ; fDEPrimary = NULL ;
     216      290484 :   if (fIparent )   delete [] fIparent ;   fIparent   = NULL ;
     217      290484 :   if (fDEParent)   delete [] fDEParent ;  fDEParent  = NULL ;
     218             : 
     219      217349 : }
     220             : 
     221             : 
     222             : //____________________________________________________________________________
     223             : void AliEMCALDigit::Clear(const Option_t*) 
     224             : {
     225             :   // Delete array of primaries if any
     226        5904 :   if (fSamples )   delete [] fSamples ;   fSamples   = NULL ;
     227        3936 :   if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ;
     228        7872 :   if (fPrimary  )  delete [] fPrimary ;   fPrimary   = NULL ;
     229        7872 :   if (fDEPrimary)  delete [] fDEPrimary ; fDEPrimary = NULL ;
     230        7872 :   if (fIparent )   delete [] fIparent ;   fIparent   = NULL ;
     231        7872 :   if (fDEParent)   delete [] fDEParent ;  fDEParent  = NULL ;
     232             : 
     233        1968 : }
     234             : 
     235             : //____________________________________________________________________________
     236             : Int_t AliEMCALDigit::Compare(const TObject * obj) const
     237             : {
     238             :   // Compares two digits with respect to its Id
     239             :   // to sort according increasing Id
     240             : 
     241             :   Int_t rv = 2 ;
     242             : 
     243       24864 :   AliEMCALDigit * digit = (AliEMCALDigit *)obj ; 
     244             : 
     245       12432 :   Int_t iddiff = fId - digit->GetId() ; 
     246             : 
     247       12432 :   if ( iddiff > 0 ) 
     248       11565 :     rv = 1 ;
     249         867 :   else if ( iddiff < 0 )
     250         867 :     rv = -1 ; 
     251             :   else
     252             :     rv = 0 ;
     253             :   
     254       12432 :   return rv ; 
     255             : 
     256             : }
     257             : 
     258             : //____________________________________________________________________________
     259             : Float_t AliEMCALDigit::GetEta() const
     260             : { 
     261             :   //return pseudorapidity for this digit
     262             :   // should be change in EMCALGeometry - 19-nov-04
     263           0 :   Float_t eta=-10., phi=-10.;
     264           0 :   Int_t id = GetId();
     265           0 :   const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
     266           0 :   g->EtaPhiFromIndex(id,eta,phi);
     267           0 :   return eta ;
     268           0 : }
     269             : 
     270             : //____________________________________________________________________________
     271             : Float_t AliEMCALDigit::GetPhi() const
     272             : { 
     273             :   //return phi coordinate of digit
     274             :   // should be change in EMCALGeometry - 19-nov-04
     275           0 :   Float_t eta=-10., phi=-10.;
     276           0 :   Int_t id = GetId();
     277           0 :   const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
     278           0 :   g->EtaPhiFromIndex(id,eta,phi);
     279           0 :   return phi ;
     280           0 : }
     281             : 
     282             : //____________________________________________________________________________
     283             : Bool_t AliEMCALDigit::GetFALTROSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
     284             : {
     285             :         //Get FALTRO sample in time bin iSample
     286           0 :         if (iSample >= fNSamples || iSample < 0 || fDigitType==kTrigger) return kFALSE;
     287             :         
     288           0 :         amp     =  fSamples[iSample] & 0xFFF;
     289           0 :         timeBin = (fSamples[iSample] >> 12) & 0xFF;
     290             :         
     291           0 :         return kTRUE;
     292           0 : }
     293             : //____________________________________________________________________________
     294             : Bool_t AliEMCALDigit::GetALTROSampleLG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
     295             : {
     296             :         //Get Low Gain ALTRO sample in time bin iSample
     297           0 :         if (iSample >= fNSamples || iSample < 0 || fDigitType==kLG) return kFALSE;
     298             :         
     299           0 :         amp     =  fSamples[iSample] & 0xFFF;
     300           0 :         timeBin = (fSamples[iSample] >> 12) & 0xFF;
     301             :         
     302           0 :         return kTRUE;
     303           0 : }
     304             : 
     305             : //____________________________________________________________________________
     306             : void AliEMCALDigit::SetALTROSamplesLG(const Int_t nSamples, Int_t *samples)
     307             : {
     308             :     //Set array of ALTRO samples, Low Gain or FALTRO 
     309           0 :         fNSamples = nSamples;
     310           0 :         fSamples  = new Int_t[fNSamples]; 
     311           0 :         for (Int_t i=0; i < fNSamples; i++) fSamples[i] = samples[i];
     312           0 : }
     313             : 
     314             : //____________________________________________________________________________
     315             : void AliEMCALDigit::SetALTROSamplesHG(const Int_t nSamples, Int_t *samples)
     316             : {
     317             :         //Set array of ALTRO samples, High Gain.
     318           0 :         fNSamplesHG = nSamples;
     319           0 :         fSamplesHG  = new Int_t[fNSamplesHG]; 
     320           0 :         for (Int_t i=0; i < fNSamplesHG; i++) fSamplesHG[i] = samples[i];
     321           0 : }
     322             : 
     323             : 
     324             : //____________________________________________________________________________
     325             : Bool_t AliEMCALDigit::GetALTROSampleHG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
     326             : {
     327             :         //Get High Gain ALTRO sample in time bin iSample
     328           0 :         if (iSample >= fNSamplesHG || iSample < 0 || fDigitType==kHG) return kFALSE;
     329             :         
     330           0 :         amp     =  fSamplesHG[iSample] & 0xFFF;
     331           0 :         timeBin = (fSamplesHG[iSample] >> 12) & 0xFF;
     332             :         
     333           0 :         return kTRUE;
     334           0 : }
     335             : 
     336             : 
     337             : //____________________________________________________________________________
     338             : Int_t AliEMCALDigit::GetPrimary(Int_t index) const
     339             : {
     340             :   // retrieves the primary particle number given its index in the list 
     341          88 :   if ( (index <= fNprimary) && (index > 0)){
     342          44 :     return fPrimary[index-1] ;
     343             :   } 
     344             : 
     345           0 :   return -1 ; 
     346          44 : }
     347             : 
     348             : //____________________________________________________________________________
     349             : Float_t AliEMCALDigit::GetDEPrimary(Int_t index) const
     350             : {
     351             :   // retrieves the primary particle energy contribution 
     352             :   // given its index in the list 
     353         156 :   if ( (index <= fNprimary) && (index > 0)){
     354          78 :     return fDEPrimary[index-1] ;
     355             :   } 
     356             : 
     357           0 :   return 0 ; 
     358             :   
     359          78 : }
     360             : 
     361             : //____________________________________________________________________________
     362             : Int_t AliEMCALDigit::GetIparent(Int_t index) const
     363             : {
     364             :   // retrieves the primary particle number given its index in the list 
     365         280 :   if ( index <= fNiparent && index > 0){
     366         140 :     return fIparent[index-1] ;
     367             :   } 
     368             : 
     369           0 :   return -1 ; 
     370             :   
     371         140 : }
     372             : 
     373             : //____________________________________________________________________________
     374             : Float_t AliEMCALDigit::GetDEParent(Int_t index) const
     375             : {
     376             :   // retrieves the parent particle energy contribution 
     377             :   // given its index in the list 
     378         382 :   if ( (index <= fNiparent) && (index > 0)){
     379         191 :     return fDEParent[index-1] ;
     380             :   } 
     381             : 
     382           0 :   return 0; 
     383         191 : }
     384             : 
     385             : //____________________________________________________________________________
     386             : void AliEMCALDigit::ShiftPrimary(Int_t shift){
     387             :   //shifts primary number to BIG offset, to separate primary in different TreeK
     388             :   Int_t index  ;
     389         914 :   for(index = 0; index <fNprimary; index++ ){
     390          55 :     fPrimary[index] = fPrimary[index]+ shift * 10000000   ;}
     391         648 :   for(index =0; index <fNiparent; index++){
     392          56 :     fIparent[index] = fIparent[index] + shift * 10000000 ;}
     393         268 : }
     394             : 
     395             : 
     396             : //____________________________________________________________________________
     397             : AliEMCALDigit& AliEMCALDigit::operator= (const AliEMCALDigit &digit)
     398             : {
     399             :   // assignment operator
     400             :   
     401        1340 :   if(&digit == this) return *this;
     402             :   
     403         670 :   fAmpFloat    = digit.fAmpFloat;       
     404         670 :   fNSamples    = digit.fNSamples;
     405         670 :   fNSamplesHG  = digit.fNSamplesHG;
     406         670 :   fNprimary    = digit.fNprimary;
     407         670 :   fNMaxPrimary = digit.fNMaxPrimary;
     408         670 :   fNiparent    = digit.fNiparent;
     409         670 :   fNMaxiparent = digit.fNMaxiparent;
     410         670 :   fMaxIter     = digit.fMaxIter;
     411         670 :   fTime        = digit.fTime;
     412         670 :   fTimeR       = digit.fTimeR; 
     413         670 :   fChi2        = digit.fChi2; 
     414         670 :   fNDF         = digit.fNDF;
     415         670 :   fDigitType   = digit.fDigitType;
     416         670 :   fAmpCalib    = digit.fAmpCalib;
     417         670 :   fAmp         = digit.fAmp ;
     418         670 :   fId          = digit.fId;
     419         670 :   fIndexInList = digit.fIndexInList ; 
     420             :   
     421             :   // data members  
     422        1340 :   if (fSamples )   delete [] fSamples ;   fSamples   = NULL ;
     423        1340 :   if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ;
     424        2680 :   if (fPrimary  )  delete [] fPrimary ;   fPrimary   = NULL ;
     425        2680 :   if (fDEPrimary)  delete [] fDEPrimary ; fDEPrimary = NULL ;
     426        2680 :   if (fIparent )   delete [] fIparent ;   fIparent   = NULL ;
     427        2680 :   if (fDEParent)   delete [] fDEParent ;  fDEParent  = NULL ;
     428             :   
     429         670 :   if (fNSamples){
     430           0 :     fSamples     = new Int_t[fNSamples]; 
     431           0 :     for (Int_t i=0; i < digit.fNSamples; i++) fSamples[i] = digit.fSamples[i];
     432           0 :   }
     433             :   
     434         670 :   if (fNSamplesHG){
     435           0 :     fSamplesHG   = new Int_t[fNSamplesHG]; 
     436           0 :     for (Int_t i=0; i < digit.fNSamplesHG; i++) fSamplesHG[i] = digit.fSamplesHG[i];
     437           0 :   }
     438             :   
     439             :   
     440         670 :   if (fNMaxPrimary){
     441         670 :     fPrimary   = new Int_t  [fNMaxPrimary] ;  
     442         670 :     fDEPrimary = new Float_t[fNMaxPrimary] ;
     443       34840 :     for ( Int_t i = 0; i < fNMaxPrimary ; i++) {
     444       16750 :       fPrimary[i]   = digit.fPrimary[i] ;
     445       16750 :       fDEPrimary[i] = digit.fDEPrimary[i] ;
     446             :     }
     447         670 :   }
     448             :   
     449         670 :   if (fNMaxiparent){
     450         670 :     fIparent  = new Int_t  [fNMaxiparent] ;
     451         670 :     fDEParent = new Float_t[fNMaxiparent] ;
     452      202340 :     for (Int_t j = 0; j< fNMaxiparent ; j++) {
     453      100500 :       fIparent[j]  = digit.fIparent[j] ;
     454      100500 :       fDEParent[j] = digit.fDEParent[j] ;
     455             :     }
     456         670 :   }  
     457             :   
     458         670 :   return *this;
     459             :   
     460         670 : }  
     461             : 
     462             : //____________________________________________________________________________
     463             : Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const 
     464             : {
     465             :   // Two digits are equal if they have the same Id
     466             :   
     467           0 :   if ( fId == digit.fId ) 
     468           0 :     return kTRUE ;
     469             :   else 
     470           0 :     return kFALSE ;
     471           0 : }
     472             :  
     473             : //____________________________________________________________________________
     474             : AliEMCALDigit AliEMCALDigit::operator+(const AliEMCALDigit &digit) 
     475             : {
     476             :   // Adds the amplitude of digits and completes the list of primary particles
     477             :   // if amplitude is larger than 
     478             :   
     479         804 :   fAmpFloat += digit.fAmpFloat ;
     480         804 :   for (Int_t i=0; i < fNSamples  ; i++) fSamples[i]   += digit.fSamples[i];
     481         804 :   for (Int_t i=0; i < fNSamplesHG; i++) fSamplesHG[i] += digit.fSamplesHG[i];
     482             :   
     483         402 :   fAmp    += digit.fAmp ;
     484         402 :   if(fTime > digit.fTime)
     485         316 :     fTime = digit.fTime ;
     486         402 :   if (digit.fTimeR < fTimeR)
     487         316 :     fTimeR = digit.fTimeR ; 
     488             :   
     489         402 :   Int_t max1 = fNprimary ; 
     490         402 :   Int_t max2 = fNiparent ;  
     491             :   Int_t index ; 
     492         976 :   for (index = 0 ; index < digit.fNprimary  ; index++){
     493             :     Bool_t newPrim = kTRUE ;
     494             :     Int_t old ;
     495         216 :     for ( old = 0 ; (old < max1) && newPrim; old++) { //already have this primary?
     496          22 :       if(fPrimary[old] == digit.fPrimary[index]) {
     497             :         newPrim = kFALSE;
     498          22 :         fDEPrimary[old] += digit.fDEPrimary[index];
     499          22 :       }
     500             :     }
     501          86 :     if (newPrim) {
     502          64 :       if(max1<fNMaxPrimary){ 
     503          64 :         fPrimary[max1] = digit.fPrimary[index] ; 
     504          64 :         fDEPrimary[max1] = digit.fDEPrimary[index] ; 
     505          64 :         fNprimary++ ;
     506          64 :         max1++;
     507          64 :       }
     508          64 :       if(fNprimary==fNMaxPrimary) {
     509             :         
     510           0 :         TString mess = " NMaxPrimary  =  " ; 
     511           0 :         mess += fNMaxPrimary ; 
     512           0 :         mess += " is too small" ; 
     513           0 :         AliFatal(mess.Data()) ; 
     514             :         
     515           0 :       }
     516             :     }
     517             :   }
     518             :   
     519         980 :   for (index = 0 ; index < digit.fNiparent ; index++){
     520             :     Bool_t newParent = kTRUE ;
     521             :     Int_t old ;
     522         224 :     for ( old = 0 ; (old < max2) && newParent; old++) { //already have this primary?
     523          24 :       if(fIparent[old] == digit.fIparent[index]) {
     524             :         newParent = kFALSE;
     525          21 :         fDEParent[old] += digit.fDEParent[index];
     526          21 :       }
     527             :     }
     528          88 :     if(newParent){
     529          67 :       if(max2<fNMaxiparent) { 
     530          67 :         fIparent[max2] = digit.fIparent[index] ; 
     531          67 :         fDEParent[max2] = digit.fDEParent[index] ; 
     532          67 :         fNiparent++ ;
     533          67 :         max2++;
     534          67 :       }
     535          67 :       if(fNiparent==fNMaxiparent) {
     536             :         
     537           0 :         TString mess = " NMaxiparent  =  " ; 
     538           0 :         mess += fNMaxiparent ; 
     539           0 :         mess += " is too small" ; 
     540           0 :         AliFatal(mess.Data()) ; 
     541             :         
     542           0 :       }
     543             :     }
     544             :   }
     545             :   
     546         402 :   return *this ;
     547         402 : }
     548             : 
     549             : //____________________________________________________________________________
     550             : AliEMCALDigit AliEMCALDigit::operator*(Float_t factor) 
     551             : {
     552             :   // Multiplies the amplitude by a factor
     553             :   
     554             :   //Float_t tempo = static_cast<Float_t>(fAmp) ; 
     555             :   //tempo *= factor ; 
     556             :   //fAmp = static_cast<Int_t>(TMath::Floor(tempo)) ; 
     557             :         
     558         536 :   fAmpFloat *= factor;
     559         536 :   for (Int_t i=0; i < fNSamples  ; i++) fSamples[i]   = Int_t(factor*fSamples[i]);
     560         536 :   for (Int_t i=0; i < fNSamplesHG; i++) fSamplesHG[i] = Int_t(factor*fSamplesHG[i]);
     561             : 
     562         646 :   for(Int_t i=0; i < fNprimary; i++) 
     563          55 :     fDEPrimary[i] *= factor;
     564         648 :   for(Int_t i=0; i < fNiparent; i++) 
     565          56 :     fDEParent[i] *= factor;
     566             : 
     567         268 :   return *this ;
     568             : }
     569             : 
     570             : //____________________________________________________________________________
     571             : ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
     572             : {
     573             :   // Prints the data of the digit
     574             :   
     575           0 :   out << "ID " << digit.fId << " Energy = " << digit.fAmp <<  " Time = " << digit.fTime << endl ; 
     576           0 :   for(Int_t i=0;i<digit.fNprimary;i++) 
     577           0 :     out << "Primary " << i+1 << " = " << digit.fPrimary[i] 
     578           0 :         << " : DE " << digit.fDEPrimary[i] << endl ;
     579             :    
     580           0 :   for(Int_t j=0;j<digit.fNiparent;j++)
     581           0 :     out << "Iparent " << j+1 << " = " << digit.fIparent[j] 
     582           0 :         << " : DE " << digit.fDEParent[j] << endl ;
     583           0 :   out << "Position in list = " << digit.fIndexInList << endl ; 
     584           0 :   return out ;
     585             : }
     586             : 
     587             : //____________________________________________________________________________
     588             : void AliEMCALDigit::Print(const Option_t* /*opt*/) const
     589             : {
     590             :     //Print
     591           0 :         printf("===\nDigit id: %4d / Energy %2.3f ; Time %e ; Time samples %d ; Chi2 %2.3f, NDF %d, Type? %d \n",
     592           0 :                    fId, fAmpFloat,fTime, fNSamples, fChi2, fNDF, fDigitType);
     593           0 :         if(fDigitType==kTrigger){
     594           0 :                 printf("FALTRO: ");
     595           0 :                 for (Int_t i=0; i < GetNFALTROSamples(); i++) 
     596             :                 {
     597           0 :                         Int_t timeBin, amp;
     598           0 :                         GetFALTROSample(i, timeBin, amp);
     599           0 :                         printf(" (%d,%d) ",timeBin,amp);
     600           0 :                 }
     601           0 :                 printf("\n");
     602           0 :         }//trigger
     603             :         else{
     604           0 :                 printf("ALTRO, Low Gain: ");
     605           0 :                 for (Int_t i=0; i < GetNALTROSamplesLG(); i++) 
     606             :                 {
     607           0 :                         Int_t timeBin, amp;
     608           0 :                         GetALTROSampleLG(i, timeBin, amp);
     609           0 :                         printf(" (%d,%d) ",timeBin,amp);
     610           0 :                 }
     611           0 :                 printf("\n");
     612           0 :                 printf("ALTRO, High Gain: ");
     613           0 :                 for (Int_t i=0; i < GetNALTROSamplesHG(); i++) 
     614             :                 {
     615           0 :                         Int_t timeBin, amp;
     616           0 :                         GetALTROSampleHG(i, timeBin, amp);
     617           0 :                         printf(" (%d,%d) ",timeBin,amp);
     618           0 :                 }
     619           0 :                 printf("\n");
     620             :         }//trigger
     621             :         
     622           0 : }
     623             : 
     624             : ///
     625             : /// Set the list of primary particles and energy deposition
     626             : /// Not used in reconstruction/simulation, add here just in case used in analysis
     627             : ///
     628             : //______________________________________________________________________________
     629             : void AliEMCALDigit::SetListOfPrimaries(Int_t npri, Int_t * prilist, Float_t * edepList) 
     630             : {
     631           0 :   if ( npri <= 0 || !prilist || !edepList )
     632             :   {
     633           0 :     AliError(Form("Null number of entries (%d) or null lists (%p,%p), do not set!",npri,prilist,edepList));
     634           0 :     return;
     635             :   }
     636             :   
     637           0 :   fNprimary = npri;
     638             :   
     639           0 :   if ( fPrimary   ) delete [] fPrimary  ; fPrimary   = NULL;
     640           0 :   if ( fDEPrimary ) delete [] fDEPrimary; fDEPrimary = NULL;
     641             :   
     642           0 :   fPrimary   = new Int_t  [fNprimary];
     643           0 :   fDEPrimary = new Float_t[fNprimary];
     644             :   
     645           0 :   for(Int_t ipri = 0; ipri < npri; ipri++)
     646             :   {
     647           0 :     fPrimary  [ipri] = prilist [ipri];
     648           0 :     fDEPrimary[ipri] = edepList[ipri];
     649             :   }
     650           0 : }
     651             : 
     652             : ///
     653             : /// Set the list of primary particles and energy deposition
     654             : /// Not used in reconstruction/simulation, but in analysis for reclusterization.
     655             : ///
     656             : //______________________________________________________________________________
     657             : void AliEMCALDigit::SetListOfParents(Int_t npar, Int_t * parlist, Float_t * edepList) 
     658             : {
     659           0 :   if ( npar <= 0 || !parlist  || !edepList )  
     660             :   {
     661           0 :     AliError(Form("Null number of entries (%d) or null lists (%p,%p), do not set!",npar,parlist,edepList));
     662           0 :     return;
     663             :   }
     664             :   
     665           0 :   fNiparent = npar;
     666             :     
     667           0 :   if ( fIparent  ) delete [] fIparent ; fIparent  = NULL;
     668           0 :   if ( fDEParent ) delete [] fDEParent; fDEParent = NULL;
     669             :   
     670           0 :   fIparent  = new Int_t  [fNiparent];
     671           0 :   fDEParent = new Float_t[fNiparent];
     672             : 
     673           0 :   for(Int_t ipar = 0; ipar < npar; ipar++)
     674             :   {
     675           0 :     fIparent [ipar] = parlist [ipar];
     676           0 :     fDEParent[ipar] = edepList[ipar];
     677             :   }
     678           0 : }
     679             : 
     680             : 

Generated by: LCOV version 1.11