]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliMillePedeRecord.cxx
Coding conventions fixed
[u/mrichter/AliRoot.git] / STEER / STEER / AliMillePedeRecord.cxx
1 #include "AliMillePedeRecord.h"
2 #include <TMath.h>
3 #include "AliLog.h"
4
5 /**********************************************************************************************/
6 /* AliMillePedeRecords: class to store the data of single track processing                    */
7 /* Format: for each measured point the data is stored consequtively                           */
8 /* INDEX                                                      VALUE                           */
9 /* -1                                                         residual                        */
10 /* Local_param_id                                             dResidual/dLocal_param          */
11 /* ...                                                        ...                             */
12 /* -2                                                         weight of the measurement       */
13 /* Global_param_od                                            dResidual/dGlobal_param         */
14 /* ...                                                        ...                             */
15 /*                                                                                            */
16 /* The records for all processed tracks are stored in the temporary tree in orgder to be      */
17 /* reused for multiple iterations of MillePede                                                */
18 /*                                                                                            */ 
19 /* Author: ruben.shahoyan@cern.ch                                                             */
20 /*                                                                                            */ 
21 /**********************************************************************************************/
22
23 ClassImp(AliMillePedeRecord)
24
25 //_____________________________________________________________________________________________
26 AliMillePedeRecord::AliMillePedeRecord() : 
27 fSize(0),fNGroups(0),fRunID(0),fGroupID(0),fIndex(0),fValue(0),fWeight(1) {SetUniqueID(0);}
28
29 //_____________________________________________________________________________________________
30 AliMillePedeRecord::AliMillePedeRecord(const AliMillePedeRecord& src) : 
31   TObject(src),fSize(src.fSize),fNGroups(src.fNGroups),fRunID(src.fRunID),fGroupID(0),fIndex(0),fValue(0),fWeight(src.fWeight)
32 {
33   // copy ct-r
34   fIndex = new Int_t[GetDtBufferSize()];
35   memcpy(fIndex,src.fIndex,fSize*sizeof(Int_t));
36   fValue = new Double_t[GetDtBufferSize()];
37   memcpy(fValue,src.fValue,fSize*sizeof(Double_t));
38   fGroupID = new UShort_t[GetGrBufferSize()];
39   memcpy(fGroupID,src.fGroupID,GetGrBufferSize()*sizeof(UShort_t));
40 }
41
42 //_____________________________________________________________________________________________
43 AliMillePedeRecord& AliMillePedeRecord::operator=(const AliMillePedeRecord& rhs)
44
45   // assignment op-r
46   if (this!=&rhs) {
47     Reset();
48     for (int i=0;i<rhs.GetSize();i++) {
49       Double_t val;
50       Int_t    ind;
51       rhs.GetIndexValue(i,ind,val);
52       AddIndexValue(ind,val);
53     }
54     fWeight = rhs.fWeight;
55     fRunID = rhs.fRunID;
56     for (int i=0;i<rhs.GetNGroups();i++) MarkGroup(rhs.GetGroupID(i));
57   }
58   return *this;
59 }
60
61 //_____________________________________________________________________________________________
62 AliMillePedeRecord::~AliMillePedeRecord() {delete[] fIndex; delete[] fValue; delete[] fGroupID;}
63
64 //_____________________________________________________________________________________________
65 void AliMillePedeRecord::Reset()
66 {
67   // reset all
68   fSize = 0;
69   for (int i=fNGroups;i--;) fGroupID[i] = 0;
70   fNGroups = 0;
71   fRunID = 0;
72   fWeight = 1.;
73 }
74
75 //_____________________________________________________________________________________________
76 void AliMillePedeRecord::Print(const Option_t *) const
77 {
78   // print itself
79   if (!fSize) {AliInfo("No data"); return;}
80   int cnt=0,point=0;
81   //  
82   if (fNGroups) printf("Groups: ");
83   for (int i=0;i<fNGroups;i++) printf("%4d |",GetGroupID(i)); 
84   printf("Run: %9d Weight: %+.2e\n",fRunID,fWeight);
85   while(cnt<fSize) {
86     //
87     Double_t resid = fValue[cnt++];
88     Double_t *derLoc = GetValue()+cnt;
89     int    *indLoc = GetIndex()+cnt;
90     int     nLoc = 0;
91     while(!IsWeight(cnt)) {nLoc++;cnt++;}
92     Double_t weight = GetValue(cnt++);
93     Double_t *derGlo = GetValue()+cnt;
94     int    *indGlo = GetIndex()+cnt;
95     int     nGlo = 0;
96     while(!IsResidual(cnt) && cnt<fSize) {nGlo++; cnt++;} 
97     //
98     printf("\n*** Point#%2d | Residual = %+.4e | Weight = %+.4e\n",point++,resid,weight);
99     printf("Locals : "); 
100     for (int i=0;i<nLoc;i++) printf("[%5d] %+.4e|",indLoc[i],derLoc[i]); printf("\n");
101     printf("Globals: "); 
102     for (int i=0;i<nGlo;i++) printf("[%5d] %+.4e|",indGlo[i],derGlo[i]); printf("\n");
103     //
104   }
105   //
106 }
107
108 //_____________________________________________________________________________________________
109 void AliMillePedeRecord::ExpandDtBuffer(Int_t bfsize)
110 {
111   // add extra space for derivatives data
112   bfsize = TMath::Max(bfsize,GetDtBufferSize());
113   Int_t *tmpI = new Int_t[bfsize];
114   memcpy(tmpI,fIndex, fSize*sizeof(Int_t));
115   delete [] fIndex;
116   fIndex = tmpI;
117   //
118   Double_t *tmpD = new Double_t[bfsize];
119   memcpy(tmpD,fValue, fSize*sizeof(Double_t));
120   delete [] fValue;
121   fValue = tmpD;
122   //
123   SetDtBufferSize(bfsize);
124 }
125
126 //_____________________________________________________________________________________________
127 void AliMillePedeRecord::ExpandGrBuffer(Int_t bfsize)
128 {
129   // add extra space for groupID data 
130   bfsize = TMath::Max(bfsize,GetGrBufferSize());
131   UShort_t *tmpI = new UShort_t[bfsize];
132   memcpy(tmpI,fGroupID, fNGroups*sizeof(UShort_t));
133   delete [] fGroupID;
134   fGroupID = tmpI;
135   for (int i=fNGroups;i<bfsize;i++) fGroupID[i] = 0;
136   //
137   SetGrBufferSize(bfsize);
138 }
139
140 //_____________________________________________________________________________________________
141 void AliMillePedeRecord::MarkGroup(Int_t id)
142 {
143   // mark the presence of the detector group
144   id++; // groupID is stored as realID+1
145   if (fNGroups>0 && fGroupID[fNGroups-1]==id) return; // already there
146   if (fNGroups>=GetGrBufferSize()) ExpandGrBuffer(2*(fNGroups+1));
147   fGroupID[fNGroups++] = id;  
148 }
149