LCOV - code coverage report
Current view: top level - STEER/ESD - AliESDCaloCells.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 37 122 30.3 %
Date: 2016-06-14 17:26:59 Functions: 13 26 50.0 %

          Line data    Source code
       1             : #ifndef ALIESDCALOCELLS_H
       2             : #define ALIESDCALOCELLS_H
       3             : /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
       4             :  * See cxx source for full Copyright notice                               */
       5             : 
       6             : //-------------------------------------------------------------------------
       7             : /// \class AliESDCaloCells
       8             : /// \brief Class for calorimeter cell ESD data handling
       9             : ///
      10             : /// ESD class to store calorimeter cell data
      11             : /// Clone of AliAODCaloCells made by Markus Oldenburg, CERN.
      12             : ///
      13             : /// Data is stored in different arrays, each entry of the array corresponding to a cell.
      14             : /// The data stored is the cell energy, time, high gain bool, absolute id number, 
      15             : /// MC label that deposited most energy, and a container for the MC embedded energy.
      16             : ///
      17             : ///  \author Gustavo Conesa Balbastre, <Gustavo.Conesa.Balbastre@cern.ch>, LPSC-Grenoble
      18             : ///
      19             : //-------------------------------------------------------------------------
      20             : 
      21             : #include <AliVCaloCells.h>
      22             : #include <TMath.h>
      23             : 
      24             : class AliESDCaloCells : public AliVCaloCells
      25             : {
      26             :  public:
      27             : 
      28             :   AliESDCaloCells();
      29             :   AliESDCaloCells(const char* name, const char* title, VCells_t ttype=kUndef);
      30             :   AliESDCaloCells(const AliESDCaloCells & cells);
      31             :   AliESDCaloCells & operator=(const AliESDCaloCells& source);
      32             :   virtual ~AliESDCaloCells();
      33             :   
      34             :   virtual AliVCaloCells * CopyCaloCells(Bool_t all) const;
      35             :   virtual void    Copy(TObject &obj) const;
      36             :   void            Clear(const Option_t*);
      37             :   void            CreateContainer(Short_t nCells);
      38             :   void            DeleteContainer();
      39             :   void            Sort();
      40             :   
      41           0 :   Bool_t          IsEMCAL()  const { return (fType == kEMCALCell); }
      42           0 :   Bool_t          IsPHOS()   const { return (fType == kPHOSCell) ; }
      43           0 :   Char_t          GetType()  const { return  fType               ; }
      44          32 :   void            SetType(Char_t t){ fType = t                   ; }
      45             :   
      46             :   inline Bool_t   GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time, Int_t &mclabel,      Double_t &efrac) const;
      47             :   Bool_t          SetCell(Short_t pos, Short_t  cellNumber, Double_t  amplitude, Double_t  time, Int_t  mclabel = -1, Double_t  efrac = 0., Bool_t isHG=kFALSE);
      48             :   
      49          32 :   Short_t         GetNumberOfCells() const  { return fNCells ; }
      50          32 :   void            SetNumberOfCells(Int_t n) { fNCells = n    ; }
      51             :   
      52             :   
      53             :   inline Double_t GetCellAmplitude(Short_t cellNumber);
      54             :   inline Bool_t   GetCellHighGain(Short_t cellNumber);  //is this cell High Gain
      55             :   inline Short_t  GetCellPosition(Short_t cellNumber);
      56             :   inline Double_t GetCellTime(Short_t cellNumber);
      57             :   
      58             :   inline Double_t GetAmplitude(Short_t pos) const;
      59             :   inline Bool_t   GetHighGain(Short_t pos) const;
      60             :   inline Double_t GetTime(Short_t pos) const;
      61             :   inline Short_t  GetCellNumber(Short_t pos) const;
      62             : 
      63             :   // MC & embedding
      64             :   inline Int_t    GetCellMCLabel(Short_t cellNumber) ;
      65             :   inline Int_t    GetMCLabel(Short_t pos) const ;
      66             :   
      67             :   inline Double_t GetCellEFraction(Short_t cellNumber) ;
      68             :   inline Double_t GetEFraction(Short_t pos) const ;
      69             :   
      70             :   inline void     SetEFraction    (Short_t pos,         Double32_t efrac) ;
      71             :   inline void     SetCellEFraction(Short_t cellNumber,  Double32_t efrac) ;
      72             :   
      73             :  protected:
      74             :   
      75             :   Int_t       fNCells;       ///< Number of cells
      76             :   
      77             :   /// If Cell is High Gain or Low Gain
      78             :   Bool_t     *fHGLG;         //[fNCells]
      79             :   
      80             :   /// Array of cell absolute Id. numbers.
      81             :   Short_t    *fCellNumber;   //[fNCells]
      82             :   
      83             :   /// Array with cell amplitudes (= energy!).
      84             :   Double32_t *fAmplitude;    //[fNCells][0.,0.,16]
      85             :   
      86             :   /// Array with cell times.
      87             :   Double32_t *fTime;         //[fNCells][0.,0.,16]
      88             :   
      89             :   /// Array with fraction of MC energy and data - for embedding.
      90             :   Double32_t *fEFraction;    //[fNCells][0.,0.,16] 
      91             :   
      92             :   ///  Array of MC labels, each label is the highest contributor to the cell signal.
      93             :   Int_t      *fMCLabel;      //[fNCells]
      94             :   
      95             :   Bool_t      fIsSorted;     //!<! True if cell arrays are sorted by index.
      96             :   
      97             :   Char_t      fType;         ///< Cell type.
      98             : 
      99             :   /// \cond CLASSIMP
     100         376 :   ClassDef(AliESDCaloCells, 5) ;
     101             :   /// \endcond
     102             : 
     103             : };
     104             : 
     105             : ///
     106             : /// Given the position index in the array, return the cell parameters.
     107             : ///
     108             : /// \param pos: Index of cell in array
     109             : /// \param cellNumber: Absolute cell Id. number
     110             : /// \param amplitude: Cell energy
     111             : /// \param time: Cell time
     112             : /// \param mclabel: MC particle index in kine tree
     113             : /// \param efrac: Fraction of energy (embedding)
     114             : ///
     115             : /// \return True if pos is correct not negative or larger than expected.
     116             : ///
     117             : Bool_t AliESDCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, 
     118             :                                 Double_t & time, Int_t & mclabel, Double_t & efrac) const 
     119             : { 
     120           0 :   if (pos>=0 && pos<fNCells) 
     121             :   {
     122           0 :     cellNumber = fCellNumber[pos];
     123           0 :     amplitude  = fAmplitude[pos];
     124           0 :     time       = fTime[pos];
     125             :     
     126           0 :     if(fMCLabel)   mclabel = fMCLabel[pos];
     127           0 :     else           mclabel =-1 ; 
     128           0 :     if(fEFraction) efrac   = fEFraction[pos];
     129           0 :     else           efrac   = 0 ;
     130             :     
     131           0 :     return kTRUE;
     132             :     
     133             :   } else 
     134             :   {
     135           0 :     return kFALSE;
     136             :   }
     137           0 : }
     138             : 
     139             : ///
     140             : /// \return Cell amplitude (GeV).
     141             : /// \param cellNumber: Cell absolute Id.
     142             : ///
     143             : Double_t AliESDCaloCells::GetCellAmplitude(Short_t cellNumber)
     144             : { 
     145         194 :   if (!fIsSorted) {
     146           0 :     Sort();
     147           0 :     fIsSorted=kTRUE;
     148           0 :   }
     149             : 
     150          97 :   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
     151         291 :   if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
     152          97 :     return fAmplitude[pos];
     153             :   } else {
     154           0 :     return 0.;
     155             :   }
     156          97 : }
     157             : 
     158             : ///
     159             : /// \return True for high gain, False for low gain.
     160             : /// \param cellNumber: Cell absolute Id.
     161             : ///
     162             : Bool_t AliESDCaloCells::GetCellHighGain(Short_t cellNumber)
     163             : { 
     164           0 :   if (!fIsSorted) {
     165           0 :     Sort();
     166           0 :     fIsSorted=kTRUE;
     167           0 :   }
     168             : 
     169           0 :   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
     170           0 :   if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
     171           0 :     if(fHGLG)
     172           0 :       return fHGLG[pos];
     173             :     else{
     174           0 :       if(fMCLabel)//old version of ESD, for data HG flag stored in MCLabel 
     175           0 :         return !(fMCLabel[pos]==-2) ;
     176             :       else
     177           0 :         return kTRUE ;
     178             :     }
     179             :   } else {
     180           0 :     return kFALSE;
     181             :   }
     182           0 : }
     183             : 
     184             : ///
     185             : /// \return Cell time (s).
     186             : /// \param cellNumber: Cell absolute Id.
     187             : ///
     188             : Double_t AliESDCaloCells::GetCellTime(Short_t cellNumber)
     189             : { 
     190           0 :   if (!fIsSorted) {
     191           0 :     Sort();
     192           0 :     fIsSorted=kTRUE;
     193           0 :   }
     194             : 
     195           0 :   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
     196           0 :   if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
     197           0 :     return fTime[pos];
     198             :   } else {
     199           0 :     return -1.;
     200             :   }
     201           0 : }
     202             : 
     203             : ///
     204             : /// \return Cell amplitude (GeV).
     205             : /// \param pos: Cell position in array.
     206             : ///
     207             : Double_t AliESDCaloCells::GetAmplitude(Short_t pos) const 
     208             : { 
     209         957 :   if (pos>=0 && pos<fNCells) {
     210         319 :     return fAmplitude[pos];
     211             :   } else {
     212           0 :     return 0.;
     213             :   }
     214         319 : }
     215             : 
     216             : ///
     217             : /// \return True for high gain, False for low gain.
     218             : /// \param pos: Cell position in array.
     219             : ///
     220             : Bool_t AliESDCaloCells::GetHighGain(Short_t pos) const 
     221             : { 
     222         957 :   if (pos>=0 && pos<fNCells) {
     223         319 :     if(fHGLG)
     224         319 :       return fHGLG[pos];
     225             :     else{
     226           0 :       if(fMCLabel)//old version of ESD, for data HG flag stored in MCLabel 
     227           0 :         return !(fMCLabel[pos]==-2) ;
     228             :       else
     229           0 :         return kTRUE ;
     230             :     }
     231             :   } else {
     232           0 :     return kFALSE;
     233             :   }
     234         319 : }
     235             : 
     236             : ///
     237             : /// \return Cell time (s).
     238             : /// \param pos: Cell position in array.
     239             : ///
     240             : Double_t AliESDCaloCells::GetTime(Short_t pos) const 
     241             : { 
     242         957 :   if (pos>=0 && pos<fNCells) {
     243         319 :     return fTime[pos];
     244             :   } else {
     245           0 :     return -1.;
     246             :   }
     247         319 : }
     248             : 
     249             : ///
     250             : /// \return Cell absolute Id. number.
     251             : /// \param pos: Cell position in array.
     252             : ///
     253             : Short_t AliESDCaloCells::GetCellNumber(Short_t pos) const 
     254             : { 
     255         957 :   if (pos>=0 && pos<fNCells) {
     256         319 :     return fCellNumber[pos];
     257             :   } else {
     258           0 :     return fNCells;
     259             :   }
     260         319 : }
     261             : 
     262             : ///
     263             : /// \param cellNumber: Cell absolute Id. number.
     264             : /// \return Cell position in array.
     265             : ///
     266             : Short_t AliESDCaloCells::GetCellPosition(Short_t cellNumber)
     267             : { 
     268          98 :   if (!fIsSorted) {
     269           0 :     Sort();
     270           0 :     fIsSorted=kTRUE;
     271           0 :   }
     272             :   
     273             :   Int_t nabove, nbelow, middle;
     274             :   Short_t pos = -1;
     275             :   
     276          49 :   nabove = fNCells + 1;
     277             :   nbelow = 0;
     278         212 :   while (nabove - nbelow > 1) {
     279         163 :     middle = (nabove + nbelow) / 2;
     280         163 :     if (cellNumber == fCellNumber[middle-1]) {
     281          49 :       pos =   middle - 1;
     282          49 :       break;
     283             :     }
     284         168 :     if (cellNumber  < fCellNumber[middle-1]) nabove = middle;
     285             :     else                                     nbelow = middle;
     286             :   }
     287             :   
     288          49 :   return pos;
     289             : }
     290             : 
     291             : ///
     292             : /// \return MC label of highest contributor particle depositing energy in cell.
     293             : /// \param pos: Cell position in array.
     294             : ///
     295             : Int_t AliESDCaloCells::GetMCLabel(Short_t pos) const 
     296             : { 
     297        1276 :   if (pos>=0 && pos<fNCells && fMCLabel) {
     298         319 :     return fMCLabel[pos];
     299             :   } else {
     300           0 :     return -1 ;
     301             :   }
     302         319 : }
     303             : 
     304             : ///
     305             : /// \return Fraction of energy in cell from embedding.
     306             : /// \param pos: Cell position in array.
     307             : ///
     308             : Double_t AliESDCaloCells::GetEFraction(Short_t pos) const 
     309             : { 
     310        1276 :   if (pos>=0 && pos<fNCells && fEFraction) {
     311         319 :     return fEFraction[pos];
     312             :   } else {
     313           0 :     return 0.;
     314             :   }
     315         319 : }
     316             : 
     317             : ///
     318             : /// \return MC label of highest contributor particle depositing energy in cell.
     319             : /// \param cellNumber: Cell position in array.
     320             : ///
     321             : Int_t AliESDCaloCells::GetCellMCLabel(Short_t cellNumber)
     322             : { 
     323           0 :   if (!fIsSorted) {
     324           0 :     Sort();
     325           0 :     fIsSorted=kTRUE;
     326           0 :   }
     327             :   
     328           0 :   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
     329           0 :   if (pos>=0 && fCellNumber[pos] == cellNumber && fMCLabel) {
     330           0 :     return fMCLabel[pos];
     331             :   } else {
     332           0 :     return -1;
     333             :   }
     334           0 : }
     335             : 
     336             : ///
     337             : /// \return Fraction of energy in cell from embedding.
     338             : /// \param cellNumber: Absolute Id number of cell.
     339             : ///
     340             : Double_t AliESDCaloCells::GetCellEFraction(Short_t cellNumber)
     341             : { 
     342           0 :   if (!fIsSorted) {
     343           0 :     Sort();
     344           0 :     fIsSorted=kTRUE;
     345           0 :   }
     346             :   
     347           0 :   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
     348           0 :   if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber && fEFraction) {
     349           0 :     return fEFraction[pos];
     350             :   } else {
     351           0 :     return 0.;
     352             :   }
     353           0 : }
     354             : 
     355             : ///
     356             : /// Set Fraction of energy in cell from embedding.
     357             : /// \param pos: Cell position in array.
     358             : /// \param efrac: fraction of energy.
     359             : ///
     360             : void AliESDCaloCells::SetEFraction(Short_t pos,  Double32_t efrac)
     361             : {  
     362           0 :   if (pos>=0 && pos < fNCells) 
     363             :   {
     364           0 :     if(!fEFraction) fEFraction = new Double32_t[fNCells];
     365           0 :     fEFraction[pos]  = efrac;
     366           0 :   } 
     367           0 : }
     368             : 
     369             : ///
     370             : /// Set fraction of energy in cell from embedding.
     371             : /// \param cellNumber: Absolute cell Id. number of cell.
     372             : /// \param efrac: fraction of energy.
     373             : ///
     374             : void AliESDCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac)
     375             : { 
     376           0 :   if (!fIsSorted) {
     377           0 :     Sort();
     378           0 :     fIsSorted=kTRUE;
     379           0 :   }
     380             :   
     381           0 :   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
     382           0 :   if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) 
     383             :   {
     384           0 :     if(!fEFraction) fEFraction = new Double32_t[fNCells];
     385           0 :     fEFraction[pos] = efrac;
     386           0 :   } 
     387           0 : }
     388             : 
     389             : 
     390             : #endif

Generated by: LCOV version 1.11