Printf commented out
[u/mrichter/AliRoot.git] / LHC / AliLhcBeam.cxx
CommitLineData
11141716 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
803d1ab0 16/* $Id$ */
11141716 17
18#include "AliLhcBeam.h"
19#include "AliLHC.h"
20#include <TMath.h>
21#include <TCanvas.h>
22#include <TGraph.h>
23#include <TMultiGraph.h>
24
25ClassImp(AliLhcBeam)
26
27AliLhcBeam::AliLhcBeam(AliLHC* lhc)
28{
29// Constructor
30 fAccelerator = lhc;
31}
32
33AliLhcBeam::AliLhcBeam(const AliLhcBeam& beam)
e76f229f 34 : TNamed(beam), AliLhcMonitor(beam)
11141716 35{
36// copy constructor
37}
38
39AliLhcBeam::~AliLhcBeam()
40{
41// Destructor
42
43}
44
45void AliLhcBeam::Init()
46{
47 // Initialization
48 printf("\n Initializing Beam");
49 printf("\n ^^^^^^^^^^^^^^^^^");
50 // Scale energy with regidity
51 fEnergy *= fZ/fA;
52 fGamma = fEnergy/0.938272;
53 fEmittance = fNEmittance/fGamma;
54 fEmittance0 = fEmittance;
55 fEmittanceL *= fZ;
56 fEmittanceL0 = fEmittanceL;
57 fN0=fN;
58
59 printf("\n Beam Energy :%10.3e GeV", fEnergy);
60 printf("\n Beam Normalized Emittance :%10.3e cm ", fNEmittance);
61 printf("\n Beam Particles per Bunch :%10.3e ", fN);
62}
63
64void AliLhcBeam::RemoveParticles(Float_t loss)
65{
66 fN-=loss;
67}
68
69void AliLhcBeam::IncreaseEmittance(Float_t de, Float_t del)
70{
71 fEmittance *= (1.+de);
72 fEmittanceL *= (1.+del);
73 fEnergySpread *= (1.+del);
74}
75
e76f229f 76AliLhcBeam& AliLhcBeam::operator=(const AliLhcBeam & /*rhs*/)
11141716 77{
78// Assignment operator
79 return *this;
80}
81void AliLhcBeam::SetMonitor(Int_t n)
82{
83 fNmax = n;
84 if (fEmittanceArray) delete fEmittanceArray;
85 if (fEmittanceLArray) delete fEmittanceLArray;
86
87
88 fEmittanceArray = new Float_t[n];
89 fEmittanceLArray = new Float_t[n];
90}
91
92void AliLhcBeam::Record()
93{
94 fEmittanceArray [fAccelerator->Nt()] = fEmittance/fEmittance0;
95 fEmittanceLArray[fAccelerator->Nt()] = fEmittanceL/fEmittanceL0;
96}
97
98
99void AliLhcBeam::DrawPlots()
100{
101 // Draw monitor plots
102 Float_t* t = fAccelerator->TimeA();
103
104 TH1 *e1 = new TH1F("e1","Hor. Emittance",fNmax,0,t[fNmax]);
105 e1->SetMinimum(1);
106 e1->SetMaximum(fEmittanceArray[fNmax]*1.1);
107 e1->SetStats(0);
108 e1->GetXaxis()->SetTitle("t (h)");
109 e1->GetYaxis()->SetTitle("rel. Emittance (t)");
110
111 TH1 *e2 = new TH1F("e2","Long. Emittance",fNmax,0,t[fNmax]);
112 e2->SetMinimum(1);
113 e2->SetMaximum(fEmittanceLArray[fNmax]*1.1);
114 e2->SetStats(0);
115 e2->GetXaxis()->SetTitle("t (h)");
116 e2->GetYaxis()->SetTitle("rel. Emittance (t)");
117
118
119 TGraph* grE = new TGraph(fNmax, t, fEmittanceArray);
120 grE->SetHistogram(e1);
121 TGraph* grEl = new TGraph(fNmax, t, fEmittanceLArray);
122 grEl->SetHistogram(e2);
123 grEl->SetLineStyle(2);
124
125 TMultiGraph* mg = new TMultiGraph();
126 mg->Add(grE);
127 mg->Add(grEl);
128
129 TCanvas *c2 = new TCanvas("c2","Emittance Increase", 200, 10, 700, 500);
130 c2->SetGrid();
131 mg->Draw("AC");
132 mg->GetXaxis()->SetTitle("t (h)");
133 mg->GetYaxis()->SetTitle("rel. Emittance(t)");
134 mg->Draw("AC");
135}
136
137
138
139