--- /dev/null
+/**************************************************************************
+ * 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]);
+}
+
+
--- /dev/null
+#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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#pragma link C++ class AliGenSlowNucleons+;
#pragma link C++ class AliSlowNucleonModel+;
#pragma link C++ class AliSlowNucleonModelExp+;
+#pragma link C++ class AliVertexGenFile+;
#endif
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)
#include "AliRun.h"
#include "AliStack.h"
#include "AliMC.h"
+#include "AliVertexGenerator.h"
ClassImp(AliGenerator)
//_______________________________________________________________________
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();
}
//_______________________________________________________________________
#include "AliRndm.h"
+class AliVertexGenerator;
class AliCollisionGeometry;
class AliStack;
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();
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
--- /dev/null
+/**************************************************************************
+ * 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)
+
+
--- /dev/null
+#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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#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+;
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 \