]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/src/AliL3VertexArray.cxx
Setting more appropriate TOF resolution for TOF PID
[u/mrichter/AliRoot.git] / HLT / src / AliL3VertexArray.cxx
index b384d9ef99f1d971efcd0f31401ecb41fa1acb7c..2bebaf7505e08f6719e30b4580d8808621f325df 100644 (file)
@@ -1,12 +1,19 @@
-//Author:        Uli Frankenfeld
-//Last Modified: 07.11.2000
+// @(#) $Id$
+
+// Author: Uli Frankenfeld <mailto:franken@fi.uib.no>
+//*-- Copyright &copy ALICE HLT Group
+
+#include "AliL3StandardIncludes.h"
 
 #include "AliL3Logging.h"
-//#include <TMath.h>
-#include <iostream.h>
 #include "AliL3VertexArray.h"
 
+
+/** \class AliL3VertexArray
+<pre>
 //_____________________________________________________________
+// AliL3VertexArray
+//
 // The L3 Fast Vertex Finder Base Class
 //
 // usage:
 //  FindSectorVertex();
 //  Double_t z = GetZSector();
 //  Double_t zerr = GetZSectorErr();
-//// do somethink with z, zerr
+//  // do somethink with z, zerr
 //}
+</pre>
+*/
+
+#if __GNUC__ >= 3
+using namespace std;
+#endif
 
 ClassImp(AliL3VertexArray)
-void AliL3VertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len){
-//loop over all seeds and all vertex position
+
+void AliL3VertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len)
+{
+  //loop over all seeds and all vertex position
   LOG(AliL3Log::kInformational,"AliL3VertexArray::AnalyzeSector","Analyze")
   <<AliL3Log::kDec<<"Number of Seeds: "<<fNSeed<<ENDLOG;
   for(Int_t i =0;i<fNSeed;i++)
@@ -31,34 +46,36 @@ void AliL3VertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len){
       array[bin] += Trace(fZSeed[i],fRSeed[i],fSecSeed[i],vertex[bin]);
 }
 
-void AliL3VertexArray::FindSectorVertex(Double_t pos, Double_t range, Int_t nbin){
-//define position and range for search and
-//loop over all seeds
-//and find position of vertex and error 
-  const Int_t len = nbin;
-  const Double_t width = range; 
-  const Double_t  xmin = pos - width/2;
-  const Double_t step = width/len;
-  const Double_t start = xmin + step/2.;
-  Int_t * array = new Int_t[len];
-  Float_t * ver   = new Float_t[len];
-  for(Int_t i=0;i<len;i++){
-    ver[i] =  start + step * i;
+void AliL3VertexArray::FindSectorVertex(Double_t pos, Double_t range, Int_t nbin)
+{
+  //define position and range for search and
+  //loop over all seeds
+  //and find position of vertex and error 
+  const Int_t klen = nbin;
+  const Double_t kwidth = range; 
+  const Double_t kxmin = pos - kwidth/2;
+  const Double_t kstep = kwidth/klen;
+  const Double_t kstart = kxmin + kstep/2.;
+  Int_t * array = new Int_t[klen];
+  Float_t * ver   = new Float_t[klen];
+  for(Int_t i=0;i<klen;i++){
+    ver[i] =  kstart + kstep * i;
     array[i] = 0;
   }
-  AnalyzeSector(ver,array,len);
-  FindMean(ver,array,len);
+  AnalyzeSector(ver,array,klen);
+  FindMean(ver,array,klen);
   delete[] array;
   delete[] ver;
 }
 
-void AliL3VertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len){
-//find mean and error of array and store it in
-//fZSector and fZSectorErr
-  const Int_t nbin = len;
+void AliL3VertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len)
+{
+  //find mean and error of array and store it in
+  //fZSector and fZSectorErr
+  const Int_t knbin = len;
   Int_t xbin =0;
   Int_t max=0;
-  for(Int_t i = 0;i<nbin;i++){
+  for(Int_t i = 0;i<knbin;i++){
     if(array[i]>max){
       max = array[i];
       xbin =i;
@@ -76,13 +93,13 @@ void AliL3VertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len){
   }
   xmax = xbin;
   while(xmax++){
-    if(xmax>=nbin) {ops++;break;}
+    if(xmax>=knbin) {ops++;break;}
     if(array[xmax]<hmax){
       break;
     }
   }
   if(ops){
-    if(xbin >= nbin/2){xmin = 2 * xbin - nbin +1;xmax = nbin-1;}
+    if(xbin >= knbin/2){xmin = 2 * xbin - knbin +1;xmax = knbin-1;}
     else{xmin = 0;xmax = 2 * xbin;}
   }
   Double_t sumw=0;
@@ -102,5 +119,17 @@ void AliL3VertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len){
     fZSector = mean;
   }
   else{fZSectorErr = fZSector = 0;}
+  sumw=sumw2=sumwx=sumwx2=0;
+  for(Int_t bin = 0;bin<knbin;bin++){
+    sumw   += array[bin];
+    sumw2  += array[bin] * array[bin];
+    sumwx  += array[bin] * vertex[bin];
+    sumwx2 += array[bin] * vertex[bin] * vertex[bin];
+  }
+  if(sumw){
+    Double_t mean = fZSector;
+    Double_t rms2 = fabs(sumwx2/sumw - mean*mean);
+    fZSectorErr = sqrt(rms2/sumw);
+  }
 }