ROOT logo
#ifndef ALIMILLEPEDERECORD_H
#define ALIMILLEPEDERECORD_H

/**********************************************************************************************/
/* AliMillePedeRecords: class to store the data of single track processing                    */
/* Format: for each measured point the data is stored consequtively                           */
/* INDEX                                                      VALUE                           */
/* -1                                                         residual                        */
/* Local_param_id                                             dResidual/dLocal_param          */
/* ...                                                        ...                             */
/* -2                                                         weight of the measurement       */
/* Global_param_od                                            dResidual/dGlobal_param         */
/* ...                                                        ...                             */
/*                                                                                            */
/* The records for all processed tracks are stored in the temporary tree in orgder to be      */
/* reused for multiple iterations of MillePede                                                */
/*                                                                                            */
/* Author: ruben.shahoyan@cern.ch                                                             */
/*                                                                                            */
/**********************************************************************************************/
#include <TObject.h>

class AliMillePedeRecord : public TObject
{
 public:
  AliMillePedeRecord();
  AliMillePedeRecord(const AliMillePedeRecord& src);
  AliMillePedeRecord& operator=(const AliMillePedeRecord& rhs);
  //
  virtual    ~AliMillePedeRecord();
  void       Reset();
  void       Print(const Option_t *opt="")                   const;
  //
  Int_t      GetSize()                                       const {return fSize;}
  Int_t     *GetIndex()                                      const {return fIndex;}
  Int_t      GetIndex(int i)                                 const {return fIndex[i];}
  //
  void       GetIndexValue(Int_t i,Int_t &ind,Double_t &val) const {ind=fIndex[i]; val=fValue[i];}
  void       AddIndexValue(Int_t ind, Double_t val);
  void       AddResidual(Double_t val)                             {AddIndexValue(-1,val);}
  void       AddWeight(Double_t val)                               {AddIndexValue(-2,val);}
  void       SetWeight(Double_t w=1)                               {fWeight = w;}
  Bool_t     IsResidual(Int_t i)                             const {return fIndex[i]==-1;}
  Bool_t     IsWeight(Int_t i)                               const {return fIndex[i]==-2;}
  //
  Double_t  *GetValue()                                      const {return fValue;}
  Double_t   GetValue(Int_t i)                               const {return fValue[i];}
  Double_t   GetWeight()                                     const {return fWeight;}
  //
  void       MarkGroup(Int_t id);
  Int_t      GetNGroups()                                    const {return fNGroups;}
  Int_t      GetGroupID(Int_t i)                             const {return fGroupID[i]-1;}
  Bool_t     IsGroupPresent(Int_t id)                        const;
  UInt_t     GetRunID()                                      const {return fRunID;}
  void       SetRunID(UInt_t run)                                  {fRunID = run;}  
  //
  // Aux methods
  Double_t   GetGlobalDeriv(Int_t pnt, Int_t indx)           const;
  Double_t   GetLocalDeriv(Int_t pnt, Int_t indx)            const;
  Double_t   GetResidual(Int_t pnt)                          const;
  Double_t   GetGloResWProd(Int_t indx)                      const;
  Double_t   GetWeight(Int_t indx)                           const;
  //
 protected:
  Int_t      GetDtBufferSize()                               const {return GetUniqueID()&0x0000ffff;}
  Int_t      GetGrBufferSize()                               const {return GetUniqueID()>>16;}
  void       SetDtBufferSize(Int_t sz)                             {SetUniqueID((GetGrBufferSize()<<16)+sz);}
  void       SetGrBufferSize(Int_t sz)                             {SetUniqueID(GetDtBufferSize()+(sz<<16));}
  void       ExpandDtBuffer(Int_t bfsize);
  void       ExpandGrBuffer(Int_t bfsize);
  //
 protected:
  Int_t      fSize;                             // size of the record
  Int_t      fNGroups;                          // number of groups (e.g. detectors) contributing
  UInt_t     fRunID;                            // run ID  
  UShort_t*  fGroupID;                          //[fNGroups] groups id's+1 (in increasing order)
  Int_t   *  fIndex;                            //[fSize] index of variables
  Double32_t* fValue;                           //[fSize] array of values: derivs,residuals
  Double32_t  fWeight;                          //global weight for the record
  //
  ClassDef(AliMillePedeRecord,3)                // Record of track residuals and local/global deriavtives
};

//_____________________________________________________________________________________________
inline void  AliMillePedeRecord::AddIndexValue(Int_t ind, Double_t val) 
{
  // add new pair of index/value
  if (fSize>=GetDtBufferSize()) ExpandDtBuffer(2*(fSize+1));
  fIndex[fSize]=ind; 
  fValue[fSize++]=val;
}

//_____________________________________________________________________________________________
inline Bool_t AliMillePedeRecord::IsGroupPresent(Int_t id) const
{
  // check if group is defined
  id++;
  for (int i=fNGroups;i--;) if (fGroupID[i]==id) return kTRUE;
  return kFALSE;
}

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