// @(#)root/tmva $Id$
// Author: S. Jadach, Tancredi Carli, Dominik Dannheim, Alexander Voigt

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Classes: PDEFoamCell                                                           *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Objects of this class are hyperrectangular cells organized in             *
 *      the binary tree. Special algoritm for encoding relalive                   *
 *      positioning of the cells saves total memory allocation needed             *
 *      for the system of cells.                                                  *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      S. Jadach        - Institute of Nuclear Physics, Cracow, Poland           *
 *      Tancredi Carli   - CERN, Switzerland                                      *
 *      Dominik Dannheim - CERN, Switzerland                                      *
 *      Alexander Voigt  - TU Dresden, Germany                                    *
 *                                                                                *
 * Copyright (c) 2008:                                                            *
 *      CERN, Switzerland                                                         *
 *      MPI-K Heidelberg, Germany                                                 *
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

#ifndef ROOT_TMVA_PDEFoamCell
#define ROOT_TMVA_PDEFoamCell

#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TRef
#include "TRef.h"
#endif

#ifndef ROOT_TMVA_PDEFoamVect
#include "TMVA/PDEFoamVect.h"
#endif

namespace TMVA {

   class PDEFoamCell : public TObject {

      //   static, the same for all cells!
   private:
      Short_t  fDim;                   // Dimension of the vector space
      //   MEMBERS

   private:
      //--- linked tree organization ---
      Int_t    fSerial;                // Serial number
      Int_t    fStatus;                // Status (active, inactive)
      TRef     fParent;                // Pointer to parent cell
      TRef     fDaught0;               // Pointer to daughter 1
      TRef     fDaught1;               // Pointer to daughter 2
      //--- M.C. sampling and choice of the best edge ---

   private:
      Double_t fXdiv;                  // Factor for division
      Int_t    fBest;                  // Best Edge for division
      //--- Integrals of all kinds ---
      Double_t fVolume;                // Cartesian Volume of cell
      Double_t fIntegral;              // Integral over cell (estimate from exploration)
      Double_t fDrive;                 // Driver  integral, only for cell build-up
      //----------  working space for the user --------------
      TObject *fElement;               // may set by the user to save some data in this cell

      //////////////////////////////////////////////////////////////////////////////////////
      //                           METHODS                                                //
      //////////////////////////////////////////////////////////////////////////////////////
   public:
      PDEFoamCell();                          // Default Constructor for ROOT streamers
      PDEFoamCell(Int_t);                     // User Constructor
      PDEFoamCell(const PDEFoamCell&);        // Copy constructor
      virtual ~PDEFoamCell();                 // Destructor
      void  Fill(Int_t, PDEFoamCell*, PDEFoamCell*, PDEFoamCell*);    // Assigns values of attributes
      //--------------- Geometry ----------------------------------
      Double_t  GetXdiv() const { return fXdiv;}          // Pointer to Xdiv
      Int_t     GetBest() const { return fBest;}          // Pointer to Best
      void      SetBest(Int_t    Best){ fBest =Best;}     // Set Best edge candidate
      void      SetXdiv(Double_t Xdiv){ fXdiv =Xdiv;}     // Set x-division for best edge cand.
      void      GetHcub(  PDEFoamVect&, PDEFoamVect&) const;  // Get position and size vectors (h-cubical subspace)
      void      GetHSize( PDEFoamVect& ) const;             // Get size only of cell vector  (h-cubical subspace)
      //--------------- Integrals/Volumes -------------------------
      void      CalcVolume();                             // Calculates volume of cell
      Double_t  GetVolume() const { return fVolume;}      // Volume of cell
      Double_t  GetIntg() const { return fIntegral;}      // Get Integral
      Double_t  GetDriv() const { return fDrive;}         // Get Drive
      void      SetIntg(Double_t Intg){ fIntegral=Intg;}  // Set true integral
      void      SetDriv(Double_t Driv){ fDrive   =Driv;}  // Set driver integral
      //--------------- linked tree organization ------------------
      Int_t     GetStat() const { return fStatus;}        // Get Status
      void      SetStat(Int_t Stat){ fStatus=Stat;}       // Set Status
      PDEFoamCell* GetPare() const { return (PDEFoamCell*) fParent.GetObject(); }  // Get Pointer to parent cell
      PDEFoamCell* GetDau0() const { return (PDEFoamCell*) fDaught0.GetObject(); } // Get Pointer to 1-st daughter vertex
      PDEFoamCell* GetDau1() const { return (PDEFoamCell*) fDaught1.GetObject(); } // Get Pointer to 2-nd daughter vertex
      void      SetDau0(PDEFoamCell* Daug){ fDaught0 = Daug;}  // Set pointer to 1-st daughter
      void      SetDau1(PDEFoamCell* Daug){ fDaught1 = Daug;}  // Set pointer to 2-nd daughter
      void      SetPare(PDEFoamCell* Pare){ fParent  = Pare;}  // Set pointer to parent
      void      SetSerial(Int_t Serial){ fSerial=Serial;}    // Set serial number
      Int_t     GetSerial() const { return fSerial;}         // Get serial number
      UInt_t    GetDepth();                                  // Get depth in binary tree
      UInt_t    GetTreeDepth(UInt_t depth=0);                // Get depth of binary tree
      //--- other ---
      void Print(Option_t *option) const ;                   // Prints cell content
      //--- getter and setter for user variable ---
      void SetElement(TObject* fobj){ fElement = fobj; }     // Set user variable
      TObject* GetElement() const { return fElement; }       // Get pointer to user varibale
      ////////////////////////////////////////////////////////////////////////////
      ClassDef(PDEFoamCell,2)  //Single cell of FOAM
   }; // end of PDEFoamCell
} // namespace TMVA

#endif
 PDEFoamCell.h:1
 PDEFoamCell.h:2
 PDEFoamCell.h:3
 PDEFoamCell.h:4
 PDEFoamCell.h:5
 PDEFoamCell.h:6
 PDEFoamCell.h:7
 PDEFoamCell.h:8
 PDEFoamCell.h:9
 PDEFoamCell.h:10
 PDEFoamCell.h:11
 PDEFoamCell.h:12
 PDEFoamCell.h:13
 PDEFoamCell.h:14
 PDEFoamCell.h:15
 PDEFoamCell.h:16
 PDEFoamCell.h:17
 PDEFoamCell.h:18
 PDEFoamCell.h:19
 PDEFoamCell.h:20
 PDEFoamCell.h:21
 PDEFoamCell.h:22
 PDEFoamCell.h:23
 PDEFoamCell.h:24
 PDEFoamCell.h:25
 PDEFoamCell.h:26
 PDEFoamCell.h:27
 PDEFoamCell.h:28
 PDEFoamCell.h:29
 PDEFoamCell.h:30
 PDEFoamCell.h:31
 PDEFoamCell.h:32
 PDEFoamCell.h:33
 PDEFoamCell.h:34
 PDEFoamCell.h:35
 PDEFoamCell.h:36
 PDEFoamCell.h:37
 PDEFoamCell.h:38
 PDEFoamCell.h:39
 PDEFoamCell.h:40
 PDEFoamCell.h:41
 PDEFoamCell.h:42
 PDEFoamCell.h:43
 PDEFoamCell.h:44
 PDEFoamCell.h:45
 PDEFoamCell.h:46
 PDEFoamCell.h:47
 PDEFoamCell.h:48
 PDEFoamCell.h:49
 PDEFoamCell.h:50
 PDEFoamCell.h:51
 PDEFoamCell.h:52
 PDEFoamCell.h:53
 PDEFoamCell.h:54
 PDEFoamCell.h:55
 PDEFoamCell.h:56
 PDEFoamCell.h:57
 PDEFoamCell.h:58
 PDEFoamCell.h:59
 PDEFoamCell.h:60
 PDEFoamCell.h:61
 PDEFoamCell.h:62
 PDEFoamCell.h:63
 PDEFoamCell.h:64
 PDEFoamCell.h:65
 PDEFoamCell.h:66
 PDEFoamCell.h:67
 PDEFoamCell.h:68
 PDEFoamCell.h:69
 PDEFoamCell.h:70
 PDEFoamCell.h:71
 PDEFoamCell.h:72
 PDEFoamCell.h:73
 PDEFoamCell.h:74
 PDEFoamCell.h:75
 PDEFoamCell.h:76
 PDEFoamCell.h:77
 PDEFoamCell.h:78
 PDEFoamCell.h:79
 PDEFoamCell.h:80
 PDEFoamCell.h:81
 PDEFoamCell.h:82
 PDEFoamCell.h:83
 PDEFoamCell.h:84
 PDEFoamCell.h:85
 PDEFoamCell.h:86
 PDEFoamCell.h:87
 PDEFoamCell.h:88
 PDEFoamCell.h:89
 PDEFoamCell.h:90
 PDEFoamCell.h:91
 PDEFoamCell.h:92
 PDEFoamCell.h:93
 PDEFoamCell.h:94
 PDEFoamCell.h:95
 PDEFoamCell.h:96
 PDEFoamCell.h:97
 PDEFoamCell.h:98
 PDEFoamCell.h:99
 PDEFoamCell.h:100
 PDEFoamCell.h:101
 PDEFoamCell.h:102
 PDEFoamCell.h:103
 PDEFoamCell.h:104
 PDEFoamCell.h:105
 PDEFoamCell.h:106
 PDEFoamCell.h:107
 PDEFoamCell.h:108
 PDEFoamCell.h:109
 PDEFoamCell.h:110
 PDEFoamCell.h:111
 PDEFoamCell.h:112
 PDEFoamCell.h:113
 PDEFoamCell.h:114
 PDEFoamCell.h:115
 PDEFoamCell.h:116
 PDEFoamCell.h:117
 PDEFoamCell.h:118
 PDEFoamCell.h:119