Method to calculate mean vertex position added. (Romita, Rossella" <R.Romita@gsi...
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Jun 2009 10:11:40 +0000 (10:11 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Jun 2009 10:11:40 +0000 (10:11 +0000)
STEER/AliMixedEvent.cxx
STEER/AliMixedEvent.h

index 6c8ddb2..01dd541 100644 (file)
 
 
 #include "AliMixedEvent.h"
+#include "AliESDVertex.h"
+#include "AliExternalTrackParam.h"
+#include "AliESDtrack.h"
+#include "TVector3.h"
+#include "AliAODVertex.h"
 #include <TMath.h>
+#include <TMatrix.h>
+#include <TMatrixD.h>
 
 ClassImp(AliMixedEvent)
 
 
 AliMixedEvent::AliMixedEvent() :
     AliVEvent(),
-    fEventList(), 
+    fEventList(),
     fNEvents(0),       
     fNumberOfTracks(0),
     fNTracksCumul(0)
@@ -40,11 +47,10 @@ AliMixedEvent::AliMixedEvent() :
     // Default constructor
 }
 
-
 AliMixedEvent::AliMixedEvent(const AliMixedEvent& Evnt) :
     AliVEvent(Evnt),
-    fEventList(), 
-    fNEvents(0),       
+    fEventList(),
+    fNEvents(0),
     fNumberOfTracks(0),
     fNTracksCumul(0)
 { } // Copy constructor
@@ -61,7 +67,7 @@ AliMixedEvent& AliMixedEvent::operator=(const AliMixedEvent& vEvnt)
 void AliMixedEvent::AddEvent(AliVEvent* evt)
 {
     // Add a new event to the list
-    fEventList.Add(evt);
+    fEventList.AddLast(evt);
 }
 
 
@@ -87,12 +93,20 @@ AliVParticle* AliMixedEvent::GetTrack(Int_t i) const
     // Return track # i
     Int_t iEv  = TMath::BinarySearch(fNEvents, fNTracksCumul, i);
     while((iEv < (fNEvents - 1)) && (fNTracksCumul[iEv] == fNTracksCumul[iEv+1])) {iEv++;}
-    
+
     Int_t irel = i - fNTracksCumul[iEv];
     AliVEvent* evt = (AliVEvent*) (fEventList.At(iEv));
     return (evt->GetTrack(irel));
 }
 
+const AliVVertex* AliMixedEvent::GetEventVertex(Int_t i) const
+{
+    // Return track # i
+    Int_t iEv  = TMath::BinarySearch(fNEvents, fNTracksCumul, i);
+    while((iEv < (fNEvents - 1)) && (fNTracksCumul[iEv] == fNTracksCumul[iEv+1])) {iEv++;}
+    AliVEvent* evt = (AliVEvent*) (fEventList.At(iEv));
+    return (evt->GetPrimaryVertex());
+}
 
 void AliMixedEvent::Reset()
 {
@@ -111,3 +125,48 @@ Int_t AliMixedEvent::EventIndex(Int_t itrack)
   // Return the event index for track #itrack
   return  TMath::BinarySearch(fNEvents, fNTracksCumul, itrack);
 }
+
+void AliMixedEvent::ComputeVtx(TObjArray *vertices, Double_t *pos,Double_t *sig){
+//
+// Calculate the mean vertex psoitions from events in the buffer
+    Int_t nentries = vertices->GetEntriesFast();
+    Double_t sum[3]={0.,0.,0.};
+    Double_t sumsigma[6]={0.,0.,0.,0.,0.,0.};
+    
+    for(Int_t ivtx = 0; ivtx < nentries; ivtx++){
+       AliAODVertex *vtx=(AliAODVertex*)vertices->UncheckedAt(ivtx);
+       if(!vtx) return;
+       Double_t covariance[6];
+       vtx->GetCovMatrix(covariance);
+
+       Double_t vtxPos[3];
+       vtx->GetXYZ(vtxPos);
+       if(covariance[0]==0) continue;
+       sum[0]+=vtxPos[0]*(1./covariance[0]);
+       sumsigma[0]+=(1./covariance[0]);
+       if(covariance[2]==0) continue;
+       sum[1]+=vtxPos[1]*(1./covariance[2]);
+       sumsigma[2]+=(1./covariance[2]);
+       if(covariance[5]==0) continue;
+       sum[2]+=vtxPos[2]*(1./covariance[5]);
+       sumsigma[5]+=(1./covariance[5]);
+       if(covariance[1]==0) continue;
+       sumsigma[1]+=(1./covariance[1]);
+       if(covariance[3]==0) continue;
+       sumsigma[3]+=(1./covariance[3]);
+       if(covariance[4]==0) continue;
+       sumsigma[4]+=(1./covariance[4]);
+    }
+    
+    for(Int_t i=0;i<3;i++){
+       if(sumsigma[i]==0) continue;
+       pos[i]=sum[i]/sumsigma[i];
+    }
+    for(Int_t i2=0;i2<6;i2++){
+       if(sumsigma[i2]==0) {sig[i2]=0.; continue;}
+       sig[i2]=1./sumsigma[i2];
+    }
+    return;
+}
+
index 9e933f4..d9ec755 100644 (file)
@@ -15,7 +15,9 @@
 //-------------------------------------------------------------------------
 
 #include "AliVEvent.h"
+#include "AliVVertex.h"
 #include <TList.h>
+#include <TObjArray.h>
 
 class AliMixedEvent : public AliVEvent {
 
@@ -38,8 +40,11 @@ public:
     virtual void Print(Option_t * /*option*/) const  {;} 
     // Specific Services
     virtual void AddEvent(AliVEvent* evt);
+    virtual void SetPrimaryVertex(AliVVertex* newVertex) {fMeanVertex = newVertex;}
+    AliVVertex* GetPrimaryVtx(){return fMeanVertex;}
     virtual void Reset();
     virtual void Init();
+    const AliVVertex* GetEventVertex(Int_t i) const;
     
     // Header
     virtual AliVHeader* GetHeader() const {return 0;}
@@ -86,11 +91,13 @@ public:
 
   // Primary vertex
     virtual const AliVVertex   *GetPrimaryVertex() const {return 0;}
+    virtual void ComputeVtx(TObjArray *vertices,Double_t *pos,Double_t *sig); 
 private:
     TList   fEventList;         //! List of Events
     Int_t   fNEvents;           //! Number of Events 
     Int_t   fNumberOfTracks;    //! Total number of tracks
     Int_t*  fNTracksCumul;      //! Cumulant
+    AliVVertex* fMeanVertex;    //! Mean vertex
     
     ClassDef(AliMixedEvent, 0)  // Container for mixed events
 };