StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.beampipe.C
1 /*
2  * Example macro for generating events distriuted along a simplified (i.e. all Al)
3  * beam pipe. We sample the vertex distribution w/in the macro and set it event-by-
4  * event.
5  *
6  * TODO: Provide a class which enables users to pass in arbitrary compiled functors,
7  * TF1, histograms, etc... to simulate vertex distributions...
8  *
9  */
10 
11 class St_geant_Maker;
12 St_geant_Maker *geant_maker = 0;
13 
14 class StarGenEvent;
15 StarGenEvent *event = 0;
16 
17 class StarPrimaryMaker;
18 StarPrimaryMaker *_primary = 0;
19 
20 class StarHijing;
21 StarHijing *hijing = 0;
22 
23 TString material = "Al"; // Section of beam pipe
24 
25 const Double_t inch = 2.54;
26 
27 Double_t bp_oradius = 1.125; // 1cm radius beam pipe
28 Double_t bp_iradius = 0.975; // 0.25 cm thickness beam pipe
29 Double_t bp_startz = -55.21 * inch; //
30 Double_t bp_endz = +55.21 * inch; //
31 
32 TH2F *hXY = 0; // XY vertex
33 TH1F *hZ = 0; // Z vertex
34 TH1F *hPT = 0; // PT distribution
35 TH1F *hPz = 0; // Pz distribution
36 
37 /*
38  PIPI, <!--Mother volume of the middle section Placed in IDSM-->
39  PIHI, <!--Hole inside the beam pipe of middle section-->
40  PALS, <!--East aluminium part-->
41  PBES, <!--Berillium part-->
42  PALI, <!--West aluminium part-->
43  SSCF, <!-- Stainless Steel conflat flanges (ID 2 cm -->
44  SSCG, <!-- Stainless Steel conflat flanges (ID 3 inches -->
45 
46 PALS section
47  <Shape type = "Pcon"
48  nz = "6" phi1="0" dphi="360"
49  zi = "{-55.46*inch, -55.21*inch,
50  -55.21*inch, -43.71*inch,
51  -43.71*inch, -15.75*inch}"
52 
53  rmn = "{0.7875*inch, 0.7875*inch,
54  0.7875*inch, 0.7875*inch,
55  0.7875*inch, 0.7875*inch}"
56  rmx = "{0.7875*inch+0.5875*inch, 0.7875*inch+0.5875*inch,
57  0.7875*inch+0.065*inch, 0.7875*inch+0.065*inch,
58  0.7875*inch+0.055*inch, 0.7875*inch+0.055*inch}" />
59 */
60 
61 /*
62 PBES
63  <Shape type="TUBE" rmin="0.7875*inch" rmax="0.7875*inch + 0.030*inch" dz="47.25*INCH/2" />
64  zoffset = + 7.875 inches
65 */
66 
67 
68 
69 
70 /*
71 
72 PALI
73  <Shape type = "Pcon"
74  nz = "6" phi1="0" dphi="360"
75  zi = "{ 31.5 *inch, 43.72*inch,
76  43.72*inch, 55.21*inch,
77  55.21*inch, 55.46*inch }"
78 
79  rmn = "{0.7875*inch, 0.7875*inch,
80  0.7875*inch, 0.7875*inch,
81  0.7875*inch, 0.7875*inch}"
82  rmx = "{0.7875*inch+0.055*inch, 0.7875*inch+0.055*inch,
83  0.7875*inch+0.065*inch, 0.7875*inch+0.065*inch,
84  0.7875*inch+0.5875*inch, 0.7875*inch+0.5875*inch}" />
85 
86 
87  */
88 
89 // ----------------------------------------------------------------------------
90 void geometry( TString tag, Bool_t agml=true )
91 {
92  TString cmd = "DETP GEOM "; cmd += tag;
93  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
94  geant_maker -> LoadGeometry(cmd);
95  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
96 }
97 // ----------------------------------------------------------------------------
98 void command( TString cmd )
99 {
100  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
101  geant_maker -> Do( cmd );
102 }
103 // ----------------------------------------------------------------------------
104 
105 void vertex()
106 {
107 
108  bp_iradius = 0.7875;
109 
110  // Sample z
111  REDO:
112  Double_t z = StarRandom::Instance().flat(bp_startz, bp_endz );
113 
114  // Carve out Be section of the beam pipe
115 
116 
117  // Inner radius is pretty much constant
118  bp_iradius = 0.7875 * inch;
119 
120  if ( TMath::Abs(z) < 55.21 * inch ) /* Al */ bp_oradius = bp_iradius + 0.065 * inch;
121  if ( TMath::Abs(z) < 43.71 * inch ) /* Al */ bp_oradius = bp_iradius + 0.055 * inch;
122  if (z>-15.75 *inch && z<31.5*inch ) /* Be */ bp_oradius = bp_iradius + 0.030 * inch;
123 
124 
125 
126  // Sample radius (hack)
127  Double_t r = StarRandom::Instance().flat( bp_iradius, bp_oradius);
128 
129  // Sample circle
130  Double_t phi = StarRandom::Instance().flat( 0., TMath::TwoPi() );
131  TVector2 circle;
132  circle.SetMagPhi( r, phi );
133  circle.Print();
134  Double_t x = circle.X();
135  Double_t y = circle.Y();
136 
137  _primary->SetSigma ( 0, 0, 0, 0);
138  _primary->SetVertex( x, y, z );
139 
140 
141 };
142 // ----------------------------------------------------------------------------
143 void trig( Int_t n=0 )
144 {
145  for ( Int_t i=0; i<n+1; i++ ) {
146  chain->Clear();
147  // Set vertex
148  vertex();
149  chain->Make();
150 
151  DoHist();
152 
153  }
154 }
155 // ----------------------------------------------------------------------------
156 void DoHist()
157 {
158  TDataSet *geant = chain->DataSet("geant"); // Get geant dataset
159  TDataSetIter Iter(geant);
160  St_g2t_track *trackTable = Iter.Find("g2t_track");
161  St_g2t_vertex *vertexTable = Iter.Find("g2t_vertex");
162  if (!trackTable) return;
163  if (!vertexTable) return; // but should probably puke here...
164  Int_t nt = trackTable->GetNRows();
165  Int_t nv = vertexTable->GetNRows();
166 
167  g2t_track_st *track = trackTable->GetTable();
168  g2t_vertex_st *vertex = vertexTable->GetTable();
169 
170  for ( Int_t i=0;i<nt; i++, track++ )
171  {
172  Float_t px = track->p[0];
173  Float_t py = track->p[1];
174  Float_t pz = track->p[2];
175  hPz -> Fill( pz );
176  hPT -> Fill( TMath::Sqrt( px*px + py*py ) );
177  }
178 
179  nv=1; /* only first */ for ( Int_t i=0;i<nv; i++, vertex++ )
180  {
181  Float_t x = vertex->ge_x[0];
182  Float_t y = vertex->ge_x[1];
183  Float_t z = vertex->ge_x[2];
184  hXY -> Fill( x, y );
185  hZ -> Fill( z );
186  }
187 
188 }
189 // ----------------------------------------------------------------------------
190 void Hijing()
191 {
192  hijing = new StarHijing("hijing");
193  hijing->SetTitle("Hijing 1.383");
194 
195  Bool_t blue = true;
196  Bool_t yell = !blue;
197 
198 }
199 // ----------------------------------------------------------------------------
200 // ----------------------------------------------------------------------------
201 // ----------------------------------------------------------------------------
202 void starsim( const Char_t *basename="rcf14000",
203  Int_t setnum=1000,
204  Int_t nevents=10)
205 {
206 
207  TString name = basename;
208  Float_t energy = 0.0;
209  if ( setnum<3000 ) energy = -7.25;
210  if ( setnum<2000 ) energy = +7.25;
211 
212  name += Form("_%i_%ievts",setnum,nevents);
213 
214 
215  Int_t rngSeed = setnum;
216 
217  hXY = new TH2F("hXY","Y_{vertex} vs X_{vertex}",101,-2.525,2.525,100,-2.5,2.5);
218  hZ = new TH1F("hZ", "Z_{vertex}",101,-101.,+101.);
219  hPT = new TH1F("hPT","p_{T} [GeV]",100,0.,10.);
220  hPz = new TH1F("hPz","p_{z} [GeV]",101,-50.5,50.5);
221 
222  gROOT->ProcessLine(".L bfc.C");
223  {
224  TString simple = "y2014 geant gstar usexgeom agml ";
225  bfc(0, simple );
226  }
227 
228  gSystem->Load( "libVMC.so");
229 
230  gSystem->Load( "StarGeneratorUtil.so" );
231  gSystem->Load( "StarGeneratorEvent.so" );
232  gSystem->Load( "StarGeneratorBase.so" );
233  gSystem->Load( "libMathMore.so" );
234  gSystem->Load( "libHijing1_383.so");
235  gSystem->Load( "xgeometry.so" );
236 
237  // Setup RNG seed and map all ROOT TRandom here
238  StarRandom::seed( rngSeed );
240 
241  //
242  // Create the primary event generator and insert it
243  // before the geant maker
244  //
245  _primary = new StarPrimaryMaker();
246  {
247  _primary -> SetFileName( Form("%s.genevents.root",name.Data()) );
248  chain -> AddBefore( "geant", _primary );
249  }
250 
251 
252  //
253  // Setup an event generator
254  //
255  Hijing();
256 
257  // Setup collision frame, energy and beam species
258  hijing->SetFrame("FIXT", energy); // 7.25 GeV incident beam on beam pipe
259  hijing->SetBlue("Au"); // The BEAM
260  hijing->SetYell("Al"); // The TARGET
261 
262  // For more configuration options, see the HIJING manual
263  // http://ntc0.lbl.gov/~xnwang/hijing/doc.html
264 
265  _primary -> AddGenerator(hijing);
266  _primary -> SetCuts( 1.0E-6 , -1., -2.5, +2.5 );
267 
268 
269 
270 
271  //
272  // Initialize primary event generator and all sub makers
273  //
274  _primary -> Init();
275 
276  hijing->SetImpact(0.0, 30.0); // Impact parameter min/max (fm) 0. 30.
277  hijing->hiparnt().ihpr2(4) = 0; // Jet quenching (1=yes/0=no) 0
278  hijing->hiparnt().ihpr2(3) = 0; // Hard scattering (1=yes/0=no)
279  hijing->hiparnt().hipr1(10) = 2.0; // pT jet
280  hijing->hiparnt().ihpr2(8) = 10; // Max number of jets / nucleon
281  hijing->hiparnt().ihpr2(11) = 1; // Set baryon production
282  hijing->hiparnt().ihpr2(12) = 1; // Turn on/off decay of particles [1=recommended]
283  hijing->hiparnt().ihpr2(18) = 1; // Turn on/off B production
284  hijing->hiparnt().hipr1(7) = 5.35; // Set B production ???? Not really used... Really ????
285  hijing->hiparnt().ihpr2(10) = 0; // show error msgs (1=show, 0=no)
286 
287  //
288  // Setup geometry and set starsim to use agusread for input
289  //
290  command("gkine -4 0");
291  // command("gfile o hijing.starsim.fzd");
292  command( Form("gfile o %s.fzd",name.Data()) );
293 
294  //
295  // Trigger on nevents
296  //
297  trig( nevents );
298  command("gprint kine");
299 
300  // command("call agexit"); // Make sure that STARSIM exits properly
301 
302 }
303 // ----------------------------------------------------------------------------
304 
static StarRandom & Instance()
Obtain the single instance of the random number generator.
Definition: StarRandom.cxx:87
void SetSigma(Double_t sx, Double_t sy, Double_t sz, Double_t rho=0)
void SetFrame(const Char_t *frame, const Double_t val)
void SetImpact(Double_t bmin, Double_t bmax)
Set the minimum and maximum impact parameters for the collision (HI generators)
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void SetBlue(const Char_t *b)
Sets the particle species for the blue beam.
int & ihpr2(int i)
Definition: Hijing.h:94
Double_t flat() const
Return a random number uniformly distributed between 0 and 1.
Definition: StarRandom.cxx:68
HiParnt_t & hiparnt()
Returns a reference to the hijing parameters.
Definition: StarHijing.h:58
float & hipr1(int i)
Definition: Hijing.h:90
Interface to the HIJING event generator.
Definition: StarHijing.h:48
virtual Int_t Make()
Definition: StChain.cxx:110
static void seed(UInt_t s)
Definition: StarRandom.cxx:119
Base class for event records.
Definition: StarGenEvent.h:81
Main steering class for event generation.
void SetYell(const Char_t *y)
Sets the particle species for the yellow beam.
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57
Int_t Init()
Definition: StarHijing.cxx:98
void SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.