]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STARLIGHT/AliGenStarLight.cxx
Adding TOF calib task for calibration of problematic channels
[u/mrichter/AliRoot.git] / STARLIGHT / AliGenStarLight.cxx
CommitLineData
da32329d
AM
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id: $ */
17#include <Riostream.h>
18#include "AliLog.h"
19#include "TStarLight.h"
20#include "starlight.h"
21#include "upcevent.h"
a2de4243 22#include "AliRunLoader.h"
23#include "AliGenEventHeader.h"
da32329d
AM
24#include "AliGenStarLight.h"
25
a2de4243 26ClassImp(AliGenStarLight);
27
da32329d
AM
28AliGenStarLight::AliGenStarLight()
29 : AliGenMC()
30 , fTrials(0)
da32329d
AM
31 , fSLgenerator(NULL) {
32}
33//----------------------------------------------------------------------
34AliGenStarLight::AliGenStarLight(Int_t npart)
35 : AliGenMC(npart)
36 , fTrials(0)
a2de4243 37 , fSLgenerator(new TStarLight("TStarLight",
da32329d 38 "StarLight UPC Event Generator",
a2de4243 39 "")) // no config file name
40{
41 //
da32329d
AM
42}
43//----------------------------------------------------------------------
44AliGenStarLight::~AliGenStarLight() {
a2de4243 45 if (NULL != fSLgenerator) delete fSLgenerator;
da32329d
AM
46 fSLgenerator = NULL;
47}
48void AliGenStarLight::ImportConfigurationFromFile(const char* filename) {
49 if (NULL == fSLgenerator) {
50 AliFatal("AliGenStarLight class not constructed properly. ");
51 return;
52 }
53 fSLgenerator->ImportConfigurationFromFile(filename);
54}
55void AliGenStarLight::SetParameter(const char* line) {
56 if (NULL == fSLgenerator) {
57 AliFatal("AliGenStarLight class not constructed properly. ");
58 return;
59 }
60 fSLgenerator->SetParameter(line);
61}
62//----------------------------------------------------------------------
63void AliGenStarLight::Init() {
64 if (NULL == fSLgenerator) {
65 AliFatal("AliGenStarLight class not constructed properly. ");
66 return;
67 }
68 fSLgenerator->InitStarLight();
69}
70//----------------------------------------------------------------------
71void AliGenStarLight::Generate() {
a2de4243 72 Float_t vpos[4] = { 0, 0, 0, 0 };
da32329d
AM
73 if (fVertexSmear == kPerEvent) {
74 Vertex(); // get vertex
75 for (Int_t i=0; i<3; ++i)
a2de4243 76 vpos[i] = fVertex[i];
77 vpos[3] = fTime;
da32329d
AM
78 }
79
a2de4243 80 Int_t nt(0); // number of tracks
81 Float_t weight(1);
82 Bool_t genOK(kFALSE);
83 // generate events until all constraints are fulfilled
84 for (fTrials=0; !genOK && fTrials < 100*1000; ++fTrials) {
da32329d
AM
85 fSLgenerator->GenerateEvent();
86 fSLgenerator->BoostEvent();
87 fSLgenerator->ImportParticles(&fParticles, "ALL");
88
a2de4243 89 genOK = kTRUE;
90 for (Long64_t i(0), n(fParticles.GetEntries()); i<n && genOK; ++i) {
da32329d 91 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
a2de4243 92 if (NULL == part) {
93 AliFatal("NULL == part");
94 return;
95 }
96 genOK =
97 (part->Theta() >= fThetaMin) && (part->Theta() < fThetaMax) &&
98 (part->Phi() >= fPhiMin) && (part->Phi() < fPhiMax) &&
99 (part->Y() >= fYMin) && (part->Y() < fYMax) &&
100 (part->P() >= fPMin) && (part->P() < fPMax) &&
101 (part->Pt() >= fPtMin) && (part->Pt() < fPtMax);
102 }
103 if (kFALSE == genOK) continue;
104
105 fNprimaries = 0;
106 for (Long64_t i(0), n(fParticles.GetEntries()); i<n; ++i) {
107 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
108 if (NULL == part) {
109 AliFatal("NULL == part");
110 return;
111 }
112 Int_t iparent(-1);
113 Float_t polar[3] = { 0, 0, 0 };
114 PushTrack(fTrackIt, iparent, part->GetPdgCode(),
da32329d 115 part->Px(), part->Py(), part->Pz(), part->Energy(),
a2de4243 116 vpos[0], vpos[1], vpos[2], vpos[3],
117 polar[0], polar[1], polar[2],
118 kPPrimary, nt, weight, part->GetStatusCode());
119 AliInfo(Form("fTrials=%d nt=%d fTrackIt=%d statusCode=%d",
120 fTrials, nt, fTrackIt, part->GetStatusCode()));
121 part->Print();
da32329d 122 KeepTrack(nt);
a2de4243 123 ++fNprimaries;
da32329d 124 }
a2de4243 125 }
126 if (kFALSE == genOK)
127 AliFatal("Maximum number of trials reached");
da32329d 128
a2de4243 129 AliGenEventHeader* header = new AliGenEventHeader("SL");
130 const TArrayF vertexPosition(3, vpos);
131 header->SetPrimaryVertex(vertexPosition);
132 header->SetInteractionTime(vpos[3]);
133 header->SetNProduced(nt);
134 AddHeader(header);
135 SetHighWaterMark(nt);
136 AliRunLoader::Instance()->CdGAFile();
da32329d 137}