]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMillePedeRecord.cxx
OADB classes and root files for the physics selection
[u/mrichter/AliRoot.git] / STEER / AliMillePedeRecord.cxx
index 4cba214c5ff3e1c45da0b61ebdb7f2051220b77a..7a8d586c6e70cb594941a714e97f4ec6e9b7d0df 100644 (file)
@@ -24,18 +24,18 @@ ClassImp(AliMillePedeRecord)
 
 //_____________________________________________________________________________________________
 AliMillePedeRecord::AliMillePedeRecord() : 
-fSize(0),fNGroups(0),fGroupID(0),fIndex(0),fValue(0) {SetUniqueID(0);}
+fSize(0),fNGroups(0),fRunID(0),fGroupID(0),fIndex(0),fValue(0),fWeight(1) {SetUniqueID(0);}
 
 //_____________________________________________________________________________________________
 AliMillePedeRecord::AliMillePedeRecord(const AliMillePedeRecord& src) : 
-  TObject(src),fSize(src.fSize),fNGroups(src.fNGroups),fGroupID(0),fIndex(0),fValue(0)
+  TObject(src),fSize(src.fSize),fNGroups(src.fNGroups),fRunID(src.fRunID),fGroupID(0),fIndex(0),fValue(0),fWeight(src.fWeight)
 {
   fIndex = new Int_t[GetDtBufferSize()];
   memcpy(fIndex,src.fIndex,fSize*sizeof(Int_t));
   fValue = new Double_t[GetDtBufferSize()];
   memcpy(fValue,src.fValue,fSize*sizeof(Double_t));
-  fGroupID = new Int_t[GetGrBufferSize()];
-  memcpy(fGroupID,src.fGroupID,GetGrBufferSize()*sizeof(Int_t));
+  fGroupID = new UShort_t[GetGrBufferSize()];
+  memcpy(fGroupID,src.fGroupID,GetGrBufferSize()*sizeof(UShort_t));
 }
 
 //_____________________________________________________________________________________________
@@ -49,6 +49,8 @@ AliMillePedeRecord& AliMillePedeRecord::operator=(const AliMillePedeRecord& rhs)
       rhs.GetIndexValue(i,ind,val);
       AddIndexValue(ind,val);
     }
+    fWeight = rhs.fWeight;
+    fRunID = rhs.fRunID;
     for (int i=0;i<rhs.GetNGroups();i++) MarkGroup(rhs.GetGroupID(i));
   }
   return *this;
@@ -61,8 +63,10 @@ AliMillePedeRecord::~AliMillePedeRecord() {delete[] fIndex; delete[] fValue; del
 void AliMillePedeRecord::Reset()
 {
   fSize = 0;
-  for (int i=fNGroups;i--;) fGroupID[i] = -1;
+  for (int i=fNGroups;i--;) fGroupID[i] = 0;
   fNGroups = 0;
+  fRunID = 0;
+  fWeight = 1.;
 }
 
 //_____________________________________________________________________________________________
@@ -72,7 +76,8 @@ void AliMillePedeRecord::Print(const Option_t *) const
   int cnt=0,point=0;
   //  
   if (fNGroups) printf("Groups: ");
-  for (int i=0;i<fNGroups;i++) printf("%4d |",GetGroupID(i)); printf("\n");
+  for (int i=0;i<fNGroups;i++) printf("%4d |",GetGroupID(i)); 
+  printf("Run: %9d Weight: %+.2e\n",fRunID,fWeight);
   while(cnt<fSize) {
     //
     Double_t resid = fValue[cnt++];
@@ -103,12 +108,12 @@ void AliMillePedeRecord::ExpandDtBuffer(Int_t bfsize)
   bfsize = TMath::Max(bfsize,GetDtBufferSize());
   Int_t *tmpI = new Int_t[bfsize];
   memcpy(tmpI,fIndex, fSize*sizeof(Int_t));
-  delete fIndex;
+  delete [] fIndex;
   fIndex = tmpI;
   //
   Double_t *tmpD = new Double_t[bfsize];
   memcpy(tmpD,fValue, fSize*sizeof(Double_t));
-  delete fValue;
+  delete [] fValue;
   fValue = tmpD;
   //
   SetDtBufferSize(bfsize);
@@ -119,11 +124,11 @@ void AliMillePedeRecord::ExpandGrBuffer(Int_t bfsize)
 {
   // add extra space for groupID data 
   bfsize = TMath::Max(bfsize,GetGrBufferSize());
-  Int_t *tmpI = new Int_t[bfsize];
-  memcpy(tmpI,fGroupID, fNGroups*sizeof(Int_t));
-  delete fGroupID;
+  UShort_t *tmpI = new UShort_t[bfsize];
+  memcpy(tmpI,fGroupID, fNGroups*sizeof(UShort_t));
+  delete [] fGroupID;
   fGroupID = tmpI;
-  for (int i=fNGroups;i<bfsize;i++) fGroupID[i] = -1;
+  for (int i=fNGroups;i<bfsize;i++) fGroupID[i] = 0;
   //
   SetGrBufferSize(bfsize);
 }
@@ -132,14 +137,9 @@ void AliMillePedeRecord::ExpandGrBuffer(Int_t bfsize)
 void AliMillePedeRecord::MarkGroup(Int_t id)
 {
   // mark the presence of the detector group
+  id++; // groupID is stored as realID+1
   if (fNGroups>0 && fGroupID[fNGroups-1]==id) return; // already there
   if (fNGroups>=GetGrBufferSize()) ExpandGrBuffer(2*(fNGroups+1));
   fGroupID[fNGroups++] = id;  
 }
 
-//_____________________________________________________________________________________________
-Bool_t AliMillePedeRecord::IsGroupPresent(Int_t id) const
-{
-  for (int i=fNGroups;i--;) if (GetGroupID(i)==id) return kTRUE;
-  return kFALSE;
-}