]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
AliMCEvent::GetPrimaryVertex() implemented
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 25 Nov 2009 09:13:40 +0000 (09:13 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 25 Nov 2009 09:13:40 +0000 (09:13 +0000)
 Fix for #59375  AliMCEvent::GetPrimaryVertex always returns 0

STEER/AliMCEvent.cxx
STEER/AliMCEvent.h
STEER/AliMCVertex.cxx [new file with mode: 0644]
STEER/AliMCVertex.h [new file with mode: 0644]
STEER/STEERBaseLinkDef.h
STEER/libSTEERBase.pkg

index 526340e03fb964a5df15a210635e92eb16dd53ac..cb81de01e5376e738293d0d8b6aebb73972d4b3c 100644 (file)
 #include <TClonesArray.h>
 #include <TRefArray.h>
 #include <TList.h>
+#include <TArrayF.h>
 
 #include "AliLog.h"
 #include "AliMCEvent.h"
+#include "AliMCVertex.h"
 #include "AliStack.h"
 #include "AliTrackReference.h"
 #include "AliHeader.h"
@@ -56,7 +58,8 @@ AliMCEvent::AliMCEvent():
     fSubsidiaryEvents(0),
     fPrimaryOffset(0),
     fSecondaryOffset(0),
-    fExternal(0)
+    fExternal(0),
+    fVertex(0)
 {
     // Default constructor
 }
@@ -77,7 +80,8 @@ AliMCEvent::AliMCEvent(const AliMCEvent& mcEvnt) :
     fSubsidiaryEvents(0),
     fPrimaryOffset(0),
     fSecondaryOffset(0),
-    fExternal(0)
+    fExternal(0),
+    fVertex(mcEvnt.fVertex)
 { 
 // Copy constructor
 }
@@ -169,11 +173,6 @@ Int_t AliMCEvent::GetParticleAndTR(Int_t i, TParticle*& particle, TClonesArray*&
 void AliMCEvent::Clean()
 {
     // Clean-up before new trees are connected
-//    if (fHeader) {
-//     delete fHeader;
-//     fHeader = 0;
-//    }
-
     delete fStack; fStack = 0;
 
     // Clear TR
@@ -182,6 +181,11 @@ void AliMCEvent::Clean()
        delete fTRBuffer;
        fTRBuffer = 0;
     }
+    if (fVertex) {
+       delete fVertex;
+       fVertex = 0;
+    }
+    
 }
 
 void AliMCEvent::FinishEvent()
@@ -570,7 +574,7 @@ AliVParticle* AliMCEvent::GetTrack(Int_t i) const
     return mcParticle;
 }
 
-    AliGenEventHeader* AliMCEvent::GenEventHeader() {return (fHeader->GenEventHeader());}
+AliGenEventHeader* AliMCEvent::GenEventHeader() const {return (fHeader->GenEventHeader());}
 
 
 void AliMCEvent::AddSubsidiaryEvent(AliMCEvent* event) 
@@ -680,4 +684,17 @@ void AliMCEvent::PreReadAll()
 }
 
 
+const AliVVertex * AliMCEvent::GetPrimaryVertex() const 
+{
+    // Create a MCVertex object from the MCHeader information
+    if (!fVertex) {
+       TArrayF v;
+       GenEventHeader()->PrimaryVertex(v) ;
+       fVertex = new AliMCVertex(v[0], v[1], v[2]);
+    }
+    
+    return fVertex;
+}
+
+
 ClassImp(AliMCEvent)
index c846ee63abb401d8b58943217f881eec453bb320..ddf77a117ad03154df8836482e3b87ded56c551c 100644 (file)
@@ -21,6 +21,7 @@
 #include <AliVEvent.h>
 #include "AliVHeader.h"
 #include "AliVParticle.h"
+#include "AliVVertex.h"
 #include "AliMCParticle.h"
 
 class AliStack;
@@ -94,14 +95,16 @@ public:
     virtual Int_t     GetNumberOfTracks()    const {return fNparticles;}
     virtual Int_t     GetNumberOfV0s()       const {return -1;}
     virtual Int_t     GetNumberOfCascades()  const {return -1;}
-
+    // Vertex
+    virtual const AliVVertex *GetPrimaryVertex() const;
+    
     //
     // MC Specific methods
     //
     // Getters
     AliStack*    Stack()   {return fStack;}
     AliHeader*   Header()  {return fHeader;}
-    AliGenEventHeader* GenEventHeader();
+    AliGenEventHeader* GenEventHeader() const;
     // Services
     virtual void      ConnectTreeE (TTree* tree);
     virtual void      ConnectTreeK (TTree* tree);
@@ -145,7 +148,8 @@ private:
     Int_t             fPrimaryOffset;    // Offset for primaries
     Int_t             fSecondaryOffset;  // Offset for secondaries
     Bool_t            fExternal;         // True if external particle array
-    static Int_t      fgkBgLabelOffset;  // Standard branch name    
+    static   Int_t        fgkBgLabelOffset;  // Standard branch name    
+    mutable  AliVVertex*  fVertex;           // MC Vertex
     ClassDef(AliMCEvent, 1)  // AliVEvent realisation for MC data
 };
 
diff --git a/STEER/AliMCVertex.cxx b/STEER/AliMCVertex.cxx
new file mode 100644 (file)
index 0000000..81c9aec
--- /dev/null
@@ -0,0 +1,26 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//     MC Vertex class
+//     Class to be used for Kinematics MC Data
+//     andreas.morsch@cern.ch
+//-------------------------------------------------------------------------
+
+#include "AliMCVertex.h"
+
+ClassImp(AliMCVertex)
diff --git a/STEER/AliMCVertex.h b/STEER/AliMCVertex.h
new file mode 100644 (file)
index 0000000..312f14a
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef AliMCVertex_H
+#define AliMCVertex_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//     Simple MC vertex class
+//     To be used with Kinematics MC data
+//     Inherits from AliVVertex
+//-------------------------------------------------------------------------
+
+#include "AliVVertex.h"
+
+class AliMCVertex : public AliVVertex {
+    public:
+    AliMCVertex() {;}
+    AliMCVertex(Double_t xv, Double_t yv, Double_t zv)
+       {fPosition[0] = xv; fPosition[1] = yv; fPosition[2] = zv;}
+    virtual ~AliMCVertex() {;}
+    virtual void     GetXYZ(Double_t position[3]) const
+       {for(Int_t i = 0; i < 3; i++) position[i] = fPosition[i];}
+    virtual Double_t GetX() const {return fPosition[0];}
+    virtual Double_t GetY() const {return fPosition[1];}
+    virtual Double_t GetZ() const {return fPosition[2];}
+    virtual void     GetCovarianceMatrix(Double_t covmatrix[6]) const
+       {for(Int_t i = 0; i < 6; i++) covmatrix[i] = 0.;}
+    virtual Double_t GetChi2perNDF() const {return -1.;}
+    virtual Double_t GetChi2()       const {return -1.;}
+    virtual Int_t    GetNDF()        const {return -1 ;}
+    
+    virtual Int_t    GetNContributors() const {return -1;}
+    virtual void     PrintIndices() const {;}
+    virtual void     Print(Option_t* option = "") const {;}
+    virtual void     Clear(Option_t* option) {TNamed::Clear(option);}
+ private:
+    Double32_t      fPosition[3]; // vertex position
+    ClassDef(AliMCVertex, 1);
+};
+
+#endif
index b52dd91a2c31c379bf531104547a4ff73b96b03a..f2a9a7ab4f53a54e9b29619c6b0068ef7e4ef95a 100644 (file)
@@ -55,6 +55,7 @@
 
 #pragma link C++ class AliMCEvent+;
 #pragma link C++ class AliMCParticle+;
+#pragma link C++ class AliMCVertex+;
 
 #pragma link C++ class  AliMagF+;
 #pragma link C++ class  AliMagWrapCheb+;
index 0a595dfa03ae2fa65f55529997e588751f643f58..427ef069ae8878144bfd18cc105f8149281d6be7 100644 (file)
@@ -21,7 +21,7 @@ SRCS = AliVParticle.cxx \
        AliGenEposEventHeader.cxx \
        AliStack.cxx AliMCEventHandler.cxx AliInputEventHandler.cxx \
        AliTrackReference.cxx AliSysInfo.cxx \
-       AliMCEvent.cxx AliMCParticle.cxx \
+       AliMCEvent.cxx AliMCParticle.cxx AliMCVertex.cxx \
        AliMagF.cxx AliMagWrapCheb.cxx AliCheb3D.cxx AliCheb3DCalc.cxx \
        AliCodeTimer.cxx \
        AliPDG.cxx \