Splitting the variables used to accumulate the sums from the ones used to fill the...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Sep 2008 15:57:01 +0000 (15:57 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Sep 2008 15:57:01 +0000 (15:57 +0000)
ITS/AliITSMeanVertexer.cxx
ITS/AliITSMeanVertexer.h

index a7fe298..4cae9a6 100644 (file)
@@ -45,16 +45,21 @@ fVertexZ(NULL),
 fNoEventsContr(0),
 fTotTracklets(0.),
 fAverTracklets(0.),
 fNoEventsContr(0),
 fTotTracklets(0.),
 fAverTracklets(0.),
+fTotTrackletsSq(0.),
 fSigmaOnAverTracks(0.), 
 fFilterOnContributors(0),
 fFilterOnTracklets(0)
 {
   // Default Constructor
   for(Int_t i=0;i<3;i++){
 fSigmaOnAverTracks(0.), 
 fFilterOnContributors(0),
 fFilterOnTracklets(0)
 {
   // Default Constructor
   for(Int_t i=0;i<3;i++){
+    fWeighPosSum[i] = 0.;
+    fWeighSigSum[i] = 0.;
+    fAverPosSum[i] = 0.;
     fWeighPos[i] = 0.;
     fWeighSig[i] = 0.;
     fAverPos[i] = 0.;
     for(Int_t j=0; j<3;j++)fAverPosSq[i][j] = 0.;
     fWeighPos[i] = 0.;
     fWeighSig[i] = 0.;
     fAverPos[i] = 0.;
     for(Int_t j=0; j<3;j++)fAverPosSq[i][j] = 0.;
+    for(Int_t j=0; j<3;j++)fAverPosSqSum[i][j] = 0.;
   }
 
   // Histograms initialization
   }
 
   // Histograms initialization
@@ -82,6 +87,7 @@ Bool_t AliITSMeanVertexer::Init() {
   printf("Geometry name: %s \n",(initgeom.GetGeometryName()).Data());
 
   fDetTypeRec = new AliITSDetTypeRec();
   printf("Geometry name: %s \n",(initgeom.GetGeometryName()).Data());
 
   fDetTypeRec = new AliITSDetTypeRec();
+  fDetTypeRec->SetLoadOnlySPDCalib(kTRUE);
   fDetTypeRec->SetITSgeom(geom);
   fDetTypeRec->SetDefaults();
   fDetTypeRec->SetDefaultClusterFindersV2(kTRUE);
   fDetTypeRec->SetITSgeom(geom);
   fDetTypeRec->SetDefaults();
   fDetTypeRec->SetDefaultClusterFindersV2(kTRUE);
@@ -157,7 +163,7 @@ void AliITSMeanVertexer::WriteVertices(const char *filename){
     AliDebug(1,Form("Contrib av. trk = %10.2f ",mv.GetAverageNumbOfTracklets()));
     AliDebug(1,Form("Sigma %10.4f ",mv.GetSigmaOnAvNumbOfTracks()));
     // we have to add chi2 here
     AliDebug(1,Form("Contrib av. trk = %10.2f ",mv.GetAverageNumbOfTracklets()));
     AliDebug(1,Form("Sigma %10.4f ",mv.GetSigmaOnAvNumbOfTracks()));
     // we have to add chi2 here
-    AliESDVertex vtx(fWeighPos,cov,0,fAverTracklets,"MeanVertexPos");
+    AliESDVertex vtx(fWeighPos,cov,0,TMath::Nint(fAverTracklets),"MeanVertexPos");
 
     mv.Write(mv.GetName(),TObject::kOverwrite);
     vtx.Write(vtx.GetName(),TObject::kOverwrite);
 
     mv.Write(mv.GetName(),TObject::kOverwrite);
     vtx.Write(vtx.GetName(),TObject::kOverwrite);
@@ -181,8 +187,8 @@ Bool_t AliITSMeanVertexer::Filter(AliESDVertex *vert,AliMultiplicity *mult){
   AliDebug(1,Form("Number of contributors = %d",ncontr));
   AliDebug(1,Form("Number of tracklets = %d",ntracklets));
   if(ncontr>fFilterOnContributors && ntracklets > fFilterOnTracklets) status = kTRUE;
   AliDebug(1,Form("Number of contributors = %d",ncontr));
   AliDebug(1,Form("Number of tracklets = %d",ntracklets));
   if(ncontr>fFilterOnContributors && ntracklets > fFilterOnTracklets) status = kTRUE;
-  fAverTracklets += ntracklets;
-  fSigmaOnAverTracks += ntracklets*ntracklets;
+  fTotTracklets += ntracklets;
+  fTotTrackletsSq += ntracklets*ntracklets;
   return status;
 }
 
   return status;
 }
 
@@ -196,13 +202,13 @@ void AliITSMeanVertexer::AddToMean(AliESDVertex *vert){
   for(Int_t i=0;i<3;i++)if(currentSigma[i] == 0.)goon = kFALSE;
   if(!goon)return;
   for(Int_t i=0;i<3;i++){
   for(Int_t i=0;i<3;i++)if(currentSigma[i] == 0.)goon = kFALSE;
   if(!goon)return;
   for(Int_t i=0;i<3;i++){
-    fWeighPos[i]+=currentPos[i]/currentSigma[i]/currentSigma[i];
-    fWeighSig[i]+=1./currentSigma[i]/currentSigma[i];
-    fAverPos[i]+=currentPos[i];
+    fWeighPosSum[i]+=currentPos[i]/currentSigma[i]/currentSigma[i];
+    fWeighSigSum[i]+=1./currentSigma[i]/currentSigma[i];
+    fAverPosSum[i]+=currentPos[i];
   }
   for(Int_t i=0;i<3;i++){
     for(Int_t j=i;j<3;j++){
   }
   for(Int_t i=0;i<3;i++){
     for(Int_t j=i;j<3;j++){
-      fAverPosSq[i][j] += currentPos[i] * currentPos[j];
+      fAverPosSqSum[i][j] += currentPos[i] * currentPos[j];
     }
   }
 
     }
   }
 
@@ -218,21 +224,20 @@ Bool_t AliITSMeanVertexer::ComputeMean(){
   if(fNoEventsContr < 2) return kFALSE;
   Double_t nevents = fNoEventsContr;
   for(Int_t i=0;i<3;i++){
   if(fNoEventsContr < 2) return kFALSE;
   Double_t nevents = fNoEventsContr;
   for(Int_t i=0;i<3;i++){
-    fWeighPos[i] /= fWeighSig[i]; 
-    fWeighSig[i] = 1./TMath::Sqrt(fWeighSig[i]);
-    fAverPos[i] /= nevents;
+    fWeighPos[i] = fWeighPosSum[i]/fWeighSigSum[i]; 
+    fWeighSig[i] = 1./TMath::Sqrt(fWeighSigSum[i]);
+    fAverPos[i] = fAverPosSum[i]/nevents;
   } 
   for(Int_t i=0;i<3;i++){
     for(Int_t j=i;j<3;j++){
   } 
   for(Int_t i=0;i<3;i++){
     for(Int_t j=i;j<3;j++){
-      fAverPosSq[i][j] /= (nevents -1.);
+      fAverPosSq[i][j] = fAverPosSqSum[i][j]/(nevents -1.);
       fAverPosSq[i][j] -= nevents/(nevents -1.)*fAverPos[i]*fAverPos[j];
     }
   } 
       fAverPosSq[i][j] -= nevents/(nevents -1.)*fAverPos[i]*fAverPos[j];
     }
   } 
-  fTotTracklets = fAverTracklets;  //  total number of tracklets used 
-  fAverTracklets /= nevents;
-  fSigmaOnAverTracks /= (nevents - 1);
-  Double_t tmp = nevents/(nevents -1.)*fAverTracklets*fAverTracklets;
-  fSigmaOnAverTracks -= tmp;
+
+  fAverTracklets = fTotTracklets/nevents;
+  fSigmaOnAverTracks = fTotTrackletsSq/(nevents - 1);
+  fSigmaOnAverTracks -= nevents/(nevents -1.)*fAverTracklets*fAverTracklets;
   fSigmaOnAverTracks = TMath::Sqrt(fSigmaOnAverTracks);
   return kTRUE;
 }
   fSigmaOnAverTracks = TMath::Sqrt(fSigmaOnAverTracks);
   return kTRUE;
 }
index bef3df8..da2e67e 100644 (file)
@@ -50,16 +50,21 @@ class AliITSMeanVertexer : public TObject {
     TH2F    *fVertexXY;        //! histogram with transverse vertex distribution (vertex diamond)
     TH1F    *fVertexZ;         //! histogram with longitudinal vertex distribution
 
     TH2F    *fVertexXY;        //! histogram with transverse vertex distribution (vertex diamond)
     TH1F    *fVertexZ;         //! histogram with longitudinal vertex distribution
 
-    Double_t fWeighPos[3];     //! weighted average position
-    Double_t fWeighSig[3];     //! errors on weighted average position
-    Double_t fAverPos[3];      //! average position
-    Double_t fAverPosSq[3][3];  //! average square position for covariance
-    Int_t fNoEventsContr;      //! number of events used for mean vertex
+    Double_t fWeighPosSum[3];    //! weighted average position sum (transient)
+    Double_t fWeighSigSum[3];    //! weighted average position sum (transient)
+    Double_t fAverPosSum[3];     //! average position sum (transient)
+    Double_t fAverPosSqSum[3][3];//! average square position sum for covariance (transient)
+    Double_t fWeighPos[3];       //! weighted average position
+    Double_t fWeighSig[3];       //! errors on weighted average position
+    Double_t fAverPos[3];        //! average position
+    Double_t fAverPosSq[3][3];   //! average square position for covariance
+    Int_t fNoEventsContr;        //! number of events used for mean vertex
     Float_t fTotTracklets;       //! total number of tracklets used (integrated)
     Float_t fTotTracklets;       //! total number of tracklets used (integrated)
-    Float_t fAverTracklets;    //! average number of tracklets per event
-    Float_t fSigmaOnAverTracks; //! RMS of fAverTracklets
+    Float_t fAverTracklets;      //! average number of tracklets per event
+    Float_t fTotTrackletsSq;     //! total squared number of tracklets (transient)
+    Float_t fSigmaOnAverTracks;  //! RMS of fAverTracklets
     Int_t fFilterOnContributors; //! Numb. of contrib must be > fFilter...
     Int_t fFilterOnContributors; //! Numb. of contrib must be > fFilter...
-    Int_t fFilterOnTracklets; //! Numb. of tracklets must be > fFilterOnTr...
+    Int_t fFilterOnTracklets;    //! Numb. of tracklets must be > fFilterOnTr...
 
     ClassDef(AliITSMeanVertexer,0)
 };
 
     ClassDef(AliITSMeanVertexer,0)
 };