-/**************************************************************************
- * 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$ */
-
-
-
//-------------------------------------------------------------
// Generate Beam-Gas-Events
// Default: underlying event: pO @ 7 TeV (fixed target)
//
// underlying event can be changed by adding generators
-// in the same way as to AliGenCocktail before calling
-// the Init()
-// Author: Jochen Klein
+// in the same as to AliGenCocktail before calling the Init()
//-------------------------------------------------------------
+/* $Id$ */
+
+#include <TList.h>
+#include <TObjArray.h>
+#include "TParticle.h"
+
#include "AliGenBeamGasNew.h"
#include "AliGenCocktail.h"
#include "AliGenCocktailEntry.h"
-#include "AliGenEventHeader.h"
#include "AliGenCocktailEventHeader.h"
-#include "AliGenHijing.h"
-#include <TList.h>
-#include <TObjArray.h>
+#include "../THijing/AliGenHijing.h"
#include "AliCollisionGeometry.h"
#include "AliRun.h"
#include "AliMC.h"
#include "AliStack.h"
-#include "AliHeader.h"
-#include "TParticle.h"
+#include "AliLog.h"
ClassImp(AliGenBeamGasNew)
AliGenBeamGasNew::AliGenBeamGasNew() :
AliGenCocktail(),
- fItime(0),
- fTwindow(88e-6),
- fZwindow(2000),
- fRate(1e3)
+ fTwindow(88.e-6)
{
- printf("AliGenBeamGasNew instatiated!\n");
+ // Default constructor
}
AliGenBeamGasNew::~AliGenBeamGasNew()
{
- delete fEntries;
- fEntries = 0;
- fHeader = 0;
+ // Destructor
}
-void AliGenBeamGasNew::SetTimeWindow(Float_t twindow) { fTwindow = twindow; }
-
-bool AliGenBeamGasNew::SetRate(Float_t rate) {
- if (rate >= 0) {
- fRate = rate;
- return true;
- } else
- return false;
+AliGenBeamGasNew::AliGenBeamGasNew(const AliGenBeamGasNew& /*rhs*/) : AliGenCocktail()
+{
+ AliFatal("Copy Constructor not yet implemented!");
}
-void AliGenBeamGasNew::SetZWindow(Float_t zwindow) { fZwindow = zwindow; }
void AliGenBeamGasNew::Init()
{
gen->SetDecaysOff(1);
gen->SetSpectators(1);
gen->SetSelectAll(1);
- gen->SetRandomPz(kFALSE);
+ gen->SetRandomPz(kTRUE);
gen->SetPileUpTimeWindow(0.);
AddGenerator(gen,"Hijing pO",1);
}
// Loop over generators and initialize
while((entry = (AliGenCocktailEntry*)next())) {
- if (fStack) entry->Generator()->SetStack(fStack);
- entry->Generator()->Init();
+ if (fStack) entry->Generator()->SetStack(fStack);
+ entry->Generator()->Init();
}
next.Reset();
{
// calculation of the interaction vertex for the beam gas event
// both spatial and time coordinate are adjusted.
-
- Float_t random[2];
- Float_t nbunch;
- Float_t bunch;
-
- gRandom->RndmArray(2,random);
- fVertex[0] = fVertex[1] = 0;
- fVertex[2] = random[0] * 4000 - 2000;
- nbunch = fTwindow/25e-9;
- bunch = floor(2*nbunch * random[1] - nbunch);
- fItime = fVertex[2] / 100 / 3e8 + bunch * 25e-9;
+
+ Float_t random[2];
+ Float_t nbunch;
+ Int_t bunch;
+
+ Rndm(random,2);
+ fVertex[0] = fVertex[1] = 0.;
+ fVertex[2] = random[1] * 4000. - 2000.;
+ AliInfo(Form("z-Koord.: %13.3f \n", fVertex[2]));
+ nbunch = 2 * fTwindow / 25.e-9;
+ bunch = (Int_t) (nbunch * (random[0] - 0.5));
+ fItime = fVertex[2] / 3.e8 + bunch * 25.e-9;
+ AliInfo(Form("fItime: %13.3e \n", fItime));
}
void AliGenBeamGasNew::Generate()
{
-//
-// Generate the collisions for one event
-//
- Int_t numbg = gRandom->Poisson(fRate*fZwindow/100*2*fTwindow);
- if (numbg == 0) return;
-
TIter next(fEntries);
AliGenCocktailEntry *entry = 0;
AliGenCocktailEntry *preventry = 0;
AliGenerator* gen = 0;
- TLorentzVector v;
- TArrayF eventVertex;
- Int_t lastpart=0;
- Float_t sign;
if (fHeader) delete fHeader;
fHeader = new AliGenCocktailEventHeader("Beamgas Header");
TObjArray *partArray = gAlice->GetMCApp()->Particles();
- AliStack *stack = gAlice->GetRunLoader()->Stack();
- for (Int_t l = 0; l < numbg; l++) {
+ TArrayF eventVertex;
+ int numbg = 0; // variable for counting how many bg interactions happened
+
+ do {
+ numbg++;
Vertex();
- sign = (gRandom->Rndm() < 0.5)? -1. : 1.;
eventVertex.Set(3);
for (Int_t j=0; j < 3; j++) eventVertex[j] = fVertex[j];
igen++;
if (igen ==1) {
- entry->SetFirst(lastpart);
+ entry->SetFirst(0);
} else {
entry->SetFirst((partArray->GetEntriesFast())+1);
}
}
entry = (AliGenCocktailEntry*) fEntries->At(i);
- entry->SetFirst(lastpart);
+ entry->SetFirst(0);
gen = entry->Generator();
entry->Generator()->SetVertex(fVertex.At(0), fVertex.At(1), fVertex.At(2));
entry->Generator()->Generate();
entry->SetLast(partArray->GetEntriesFast());
}
- for (int k = lastpart; k < stack->GetNprimary(); k++) {
+ AliStack *stack = gAlice->GetRunLoader()->Stack();
+ TLorentzVector v;
+ for (int k = 0; k < stack->GetNprimary(); k++) {
stack->Particle(k)->ProductionVertex(v);
- v[2] *= sign;
- v[3] = fItime; // ??? +=
+ v[3] += fItime;
stack->Particle(k)->SetProductionVertex(v);
- stack->Particle(k)->Momentum(v);
- v[2] *= sign;
- stack->Particle(k)->SetMomentum(v);
}
-
- lastpart = stack->GetNprimary();
+
next.Reset();
- }
+ } while (gRandom->Rndm() < 1. / 5.); // must be adjusted to the rate of bg interactions
// Event Vertex
fHeader->SetPrimaryVertex(eventVertex);
- // fHeader->SetNvertex(numbg);
- if (fContainer) {
- fContainer->AddHeader(fHeader);
- } else {
- gAlice->SetGenEventHeader(fHeader);
- }
+ // Total number of produced an stored particles
+ fHeader->CalcNProduced();
+
+ gAlice->SetGenEventHeader(fHeader);
}
#ifndef ALIGENBEAMGASNEW_H
#define ALIGENBEAMGASNEW_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice */
/* $Id$ */
#include "AliGenCocktail.h"
-//
-// Class for the simulation of beam gas events with correct timing.
-// By default HIJING is used as a generator for pO collisions.
-//
-// Author: Jochen Klein
-//
-
class AliGenBeamGasNew : public AliGenCocktail
{
public:
AliGenBeamGasNew();
+ AliGenBeamGasNew(const AliGenBeamGasNew& rhs);
+ // AliGenBeamGasNew& operator=(const AliGenBeamGasNew&);
virtual ~AliGenBeamGasNew();
-
+ void SetTimeWindow(Float_t twindow) {fTwindow = twindow;}
virtual void Generate();
void VertexInternal();
virtual void Init();
- void SetTimeWindow(Float_t twindow);
- bool SetRate(Float_t rate);
- void SetZWindow(Float_t zwindow);
-
protected:
Float_t fItime; // time of bg-interaction
Float_t fTwindow; // time-window in which tpc-gate is open
- Float_t fZwindow; // extension of simulation in z-direction in cm
- Float_t fRate; // rate for bg-interaction in Hz/m
- private:
- AliGenBeamGasNew& operator=(const AliGenBeamGasNew &rhs);
- AliGenBeamGasNew(const AliGenBeamGasNew& rhs);
ClassDef(AliGenBeamGasNew,1);
};