New classes to handle the vertex in simulation (T.Kuhr)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Dec 2003 10:04:36 +0000 (10:04 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Dec 2003 10:04:36 +0000 (10:04 +0000)
EVGEN/AliVertexGenFile.cxx [new file with mode: 0644]
EVGEN/AliVertexGenFile.h [new file with mode: 0644]
EVGEN/EVGENLinkDef.h
EVGEN/libEVGEN.pkg
STEER/AliGenerator.cxx
STEER/AliGenerator.h
STEER/AliVertexGenerator.cxx [new file with mode: 0644]
STEER/AliVertexGenerator.h [new file with mode: 0644]
STEER/STEERLinkDef.h
STEER/libSTEER.pkg

diff --git a/EVGEN/AliVertexGenFile.cxx b/EVGEN/AliVertexGenFile.cxx
new file mode 100644 (file)
index 0000000..b2020b4
--- /dev/null
@@ -0,0 +1,116 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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$ */
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// Generator for vertices taken from a file                                  //
+//                                                                           //
+// The file name of the galice file is passed as argument to the             //
+// constructor. If a second argument is given, this determines the number    //
+// of events for which the same vertex is used.                              //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+
+#include "AliVertexGenFile.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+#include <TFile.h>
+#include <TTree.h>
+#include <TArrayF.h>
+
+
+ClassImp(AliVertexGenFile)
+
+
+//_____________________________________________________________________________
+AliVertexGenFile::AliVertexGenFile() :
+  fFile(NULL),
+  fTree(NULL),
+  fHeader(NULL),
+  fEventsPerEntry(0),
+  fEvent(0)
+{
+// default constructor: initialize data members
+
+}
+
+//_____________________________________________________________________________
+AliVertexGenFile::AliVertexGenFile(const char* fileName, 
+                                  Int_t eventsPerEntry) :
+  fFile(NULL),
+  fTree(NULL),
+  fHeader(NULL),
+  fEventsPerEntry(eventsPerEntry),
+  fEvent(0)
+{
+// main constructor:
+// fileName is the name of the galice file containing the vertices
+// eventsPerEntry is the number of events for which the same vertex is used
+
+  TDirectory* dir = gDirectory;
+
+  fFile = TFile::Open(fileName);
+  if (!fFile) {
+    Error("AliVertexGenFile", "could not open file %s", fileName);
+    return;
+  }
+  fTree = (TTree*) fFile->Get("TE");
+  if (!fTree) {
+    Error("AliVertexGenFile", "not header tree found in file %s", fileName);
+    dir->cd();
+    return;
+  }
+  fHeader = new AliHeader;
+  fTree->SetBranchAddress("Header", &fHeader);
+
+  dir->cd();
+}
+
+//_____________________________________________________________________________
+AliVertexGenFile::~AliVertexGenFile()
+{
+// clean up
+
+  fFile->Close();
+  delete fFile;
+  delete fHeader;
+}
+
+
+//_____________________________________________________________________________
+TVector3 AliVertexGenFile::GetVertex()
+{
+// get the vertex from the event header tree
+
+  Int_t entry = fEvent++ / fEventsPerEntry;
+  if (fTree->GetEntry(entry) <= 0) {
+    Error("GetVertex", "error loading entry %d", entry);
+    return TVector3(0,0,0);
+  }
+
+  if (!fHeader->GenEventHeader()) {
+    Error("GetVertex", "no generator event header");
+    return TVector3(0,0,0);
+  }
+
+  TArrayF vertex(3);
+  fHeader->GenEventHeader()->PrimaryVertex(vertex);
+  return TVector3(vertex[0], vertex[1], vertex[2]);
+}
+
+
diff --git a/EVGEN/AliVertexGenFile.h b/EVGEN/AliVertexGenFile.h
new file mode 100644 (file)
index 0000000..85b46ee
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef ALIVERTEXGENFILE_H
+#define ALIVERTEXGENFILE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#include "AliVertexGenerator.h"
+
+class TFile;
+class TTree;
+class AliHeader;
+
+
+class AliVertexGenFile: public AliVertexGenerator {
+ public:
+  AliVertexGenFile();
+  AliVertexGenFile(const char* fileName, Int_t eventsPerEntry = 1);
+  virtual ~AliVertexGenFile();
+
+  virtual TVector3 GetVertex();
+
+ private:
+  TFile*           fFile;           //! galice file with vertices
+  TTree*           fTree;           //! tree with headers
+  AliHeader*       fHeader;         //! event header
+  Int_t            fEventsPerEntry; // number of events with same vertex
+  Int_t            fEvent;          //! current event number
+
+  ClassDef(AliVertexGenFile, 1)     // generator for vertices taken from a file
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
index e031e985258721dfc520db740e4997985ee7558b..bf8239f81a6cdc6ce977d425c6a31c627276020d 100644 (file)
@@ -51,6 +51,7 @@
 #pragma link C++ class  AliGenSlowNucleons+;
 #pragma link C++ class  AliSlowNucleonModel+;
 #pragma link C++ class  AliSlowNucleonModelExp+;
+#pragma link C++ class  AliVertexGenFile+;
 #endif
 
 
index 1588c317673a8662afdf2908c07fbb0f728ab05c..d7fc700a758cc5bb014f9becced36698345541cd 100644 (file)
@@ -17,7 +17,8 @@ SRCS          = AliGenHIJINGpara.cxx AliGenBox.cxx AliGenFixed.cxx \
                AliPartonicEnergyLoss.cxx\
                AliStructFuncType.cxx AliGenSlowNucleons.cxx \
                AliGenGeVSimEventHeader.cxx\
-               AliSlowNucleonModel.cxx AliSlowNucleonModelExp.cxx
+               AliSlowNucleonModel.cxx AliSlowNucleonModelExp.cxx \
+               AliVertexGenFile.cxx
 
 # Headerfiles for this particular package (Path respect to own directory)
 HDRS= $(SRCS:.cxx=.h) 
index 507a2849cd4166fc0142123067734563c66aba91..cb28af264ce9d583c369c91e15c70fe8570a5647 100644 (file)
@@ -42,6 +42,7 @@
 #include "AliRun.h"
 #include "AliStack.h"
 #include "AliMC.h"
+#include "AliVertexGenerator.h"
 
 ClassImp(AliGenerator)
 
@@ -357,12 +358,13 @@ void AliGenerator::Vertex()
 //_______________________________________________________________________
 void AliGenerator::VertexExternal()
 {
-    // Dummy !!!!!!
-    // Obtain vertex from external source 
     //
-    // Should be something like fVertex = gAlice->GetVertex()
-    
-    fVertex[0]=fVertex[1]=fVertex[2]=0;  
+    // Obtain vertex from external source (vertex generator)
+    //
+    TVector3 vertex = fVertexGenerator->GetVertex();
+    fVertex[0] = vertex.X();
+    fVertex[1] = vertex.Y();
+    fVertex[2] = vertex.Z();
 }
 
 //_______________________________________________________________________
index 54638baefb954b825c8a8ce994e8e12e3594cda3..699dbe6952c01553e95fef296f308f0b859a0acf 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "AliRndm.h"
 
+class AliVertexGenerator;
 class AliCollisionGeometry;
 class AliStack;
 
@@ -61,6 +62,8 @@ class AliGenerator : public TNamed, public AliRndm
     virtual void SetVertexSource(VertexSource_t source = kInternal) {fVertexSource = source;}
     virtual void SetVertex(Float_t vx, Float_t vy, Float_t vz)
        {fVertex[0] = vx; fVertex[1] = vy; fVertex[2] = vz;}
+    void SetVertexGenerator(AliVertexGenerator* vertexGenerator)
+      {fVertexGenerator = vertexGenerator; fVertexSource = kExternal; fVertexSmear = kPerEvent;}
     virtual void SetTrackingFlag(Int_t flag=1) {fTrackIt=flag;}
     void Vertex();
     void VertexExternal();
@@ -119,6 +122,7 @@ class AliGenerator : public TNamed, public AliRndm
     VertexSource_t    fVertexSource; //Vertex source (internal/external)
     Float_t     fCutVertexZ;    // Vertex cut in units of sigma_z
     Int_t       fTrackIt;    // if 1, Track final state particles 
+    AliVertexGenerator* fVertexGenerator;  //! Generator for the vertex
     TArrayF     fOrigin;     // Origin of event
     TArrayF     fOsigma;     // Sigma of the Origin of event
     TArrayF     fVertex;     //! Vertex of current event
diff --git a/STEER/AliVertexGenerator.cxx b/STEER/AliVertexGenerator.cxx
new file mode 100644 (file)
index 0000000..70ff8a8
--- /dev/null
@@ -0,0 +1,34 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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$ */
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// Base class for vertex generators                                          //
+//                                                                           //
+// Derived classes have to implement the virtual method GetVertex().         //
+// This method should return the position of the primary event vertex. A new //
+// vertex is generated for each call to GetVertex().                         //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+
+#include "AliVertexGenerator.h"
+
+
+ClassImp(AliVertexGenerator)
+
+
diff --git a/STEER/AliVertexGenerator.h b/STEER/AliVertexGenerator.h
new file mode 100644 (file)
index 0000000..1f1efce
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef ALIVERTEXGENERATOR_H
+#define ALIVERTEXGENERATOR_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#include <TObject.h>
+#include <TVector3.h>
+
+
+class AliVertexGenerator: public TObject {
+ public:
+  virtual TVector3 GetVertex() = 0;
+
+  ClassDef(AliVertexGenerator, 1)    // Base class for vertex generators
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
index f8abd0bb7fcc82c7ed86bddb8d389c3a2049ef03..f93bf4a5fb72665745a68fb28be3f8fef359efed 100644 (file)
@@ -17,6 +17,7 @@
 #pragma link C++ class  AliPDG+;
 
 #pragma link C++ class  AliGenerator+;
+#pragma link C++ class  AliVertexGenerator+;
 #pragma link C++ class  AliRun-;
 #pragma link C++ class  AliModule+;
 #pragma link C++ class  AliDetector+;
index 7c933bb839d3f75b799e46ea9e124773aa445299..d9c94fa84834afcc9e872986845f66fd6683daab 100644 (file)
@@ -1,7 +1,7 @@
 SRCS          = AliRunLoader.cxx AliLoader.cxx AliDataLoader.cxx  \
 AliDetector.cxx        AliHeader.cxx   AliMagF.cxx \
 AliDigit.cxx   AliHit.cxx      AliPoints.cxx \
-AliDisplay.cxx AliRun.cxx AliGenerator.cxx \
+AliDisplay.cxx AliRun.cxx AliGenerator.cxx AliVertexGenerator.cxx \
 AliLego.cxx    AliModule.cxx   AliDigitNew.cxx \
 AliGeometry.cxx        AliRecPoint.cxx AliSegmentation.cxx \
 AliHitMap.cxx  AliMagFC.cxx    AliMagFCM.cxx \