source: trunk/source/processes/electromagnetic/xrays/test/testG4SynchrotronRadiation.cc @ 1340

Last change on this file since 1340 was 1199, checked in by garnier, 15 years ago

nvx fichiers dans CVS

File size: 15.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27//
28//
29// 
30//
31//  Test routine for G4SynchrotronRadiation class
32//
33// History:
34//
35// 12.03.06, V. Grichine
36
37#include "G4ios.hh"
38#include <fstream>
39#include <cmath>
40#include "globals.hh"
41#include "Randomize.hh"
42#include "G4UnitsTable.hh"
43
44
45#include <iomanip>
46
47#include "G4Isotope.hh"
48#include "G4Element.hh"
49#include "G4Material.hh"
50#include "G4MaterialCutsCouple.hh"
51#include "G4Region.hh"
52#include "G4ProductionCuts.hh"
53#include "G4RegionStore.hh"
54#include "G4MaterialTable.hh"
55
56#include "G4Box.hh"
57#include "G4LogicalVolume.hh"
58
59
60#include "G4SynchrotronRadiation.hh"
61
62#include "G4ParticleDefinition.hh"
63#include "G4Proton.hh"
64
65
66
67int main()
68{
69
70  /*
71  std::ofstream outdEdx("XTRdEdx.out", std::ios::out ) ;
72  outdEdx.setf( std::ios::scientific, std::ios::floatfield );
73
74  std::ofstream outdNdx("XTRdNdx.out", std::ios::out ) ;
75  outdNdx.setf( std::ios::scientific, std::ios::floatfield );
76
77  std::ofstream outXsc("InitXsc.out", std::ios::out ) ;
78  outXsc.setf( std::ios::scientific, std::ios::floatfield );
79
80  //  std::ifstream fileRead("exp.dat", std::ios::out ) ;
81  //  fileRead.setf( std::ios::scientific, std::ios::floatfield );
82
83  std::ofstream fileWrite1("mpXTR.dat", std::ios::out ) ;
84  fileWrite1.setf( std::ios::scientific, std::ios::floatfield );
85  */
86 
87
88  /////////////////////////////////////////////////////////////////
89  //
90  // Create materials 
91
92 
93  G4String name, symbol ;                            //a =mass of a mole;
94  G4double a, z ;   //z =mean number of protons; 
95  G4double density, foilDensity, gasDensity, totDensity ;
96  G4double fractionFoil, fractionGas ;
97  G4int nel ; 
98 
99  //G4int ncomponents, natoms;
100  G4int  ncomponents;
101  //G4double abundance, fractionmass;
102  G4double fractionmass;
103  //G4double temperature, pressure;
104 
105  /////////////////////////////////////
106  //
107  // define Elements
108 
109   
110  a = 1.01*g/mole;
111  G4Element* elH  = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
112 
113  a = 6.94*g/mole;
114  G4Element* elLi = new G4Element(name="Lithium",symbol="Li" , z= 3., a);
115 
116  a = 9.01*g/mole;
117  G4Element* elBe = new G4Element(name="Berillium",symbol="Be" , z= 4., a);
118 
119  a = 12.01*g/mole;
120  G4Element* elC  = new G4Element(name="Carbon", symbol="C", z=6., a);
121 
122  a = 14.01*g/mole;
123  G4Element* elN  = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
124 
125  a = 16.00*g/mole;
126  G4Element* elO  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);
127 
128  a = 39.948*g/mole;
129  G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a);
130 
131  a = 131.29*g/mole;
132  G4Element* elXe = new G4Element(name="Xenon", symbol="Xe", z=54., a);
133 
134  a = 19.00*g/mole;
135  G4Element* elF  = new G4Element(name="Fluorine", symbol="F", z=9., a);
136
137  /////////////////////////////////////////////////////////////////
138  //
139  // Detector windows, electrodes
140  // Al for electrodes
141 
142  density = 2.700*g/cm3;
143  a = 26.98*g/mole;
144  G4Material* Al = new G4Material(name="Aluminium", z=13., a, density);
145 
146 
147  ////////////////////////////////////////////////////////////////////////////
148  //
149  // Materials for popular X-ray TR radiators
150  //
151 
152  // TRT_CH2
153 
154  density = 0.935*g/cm3;
155  G4Material* TRT_CH2 = new G4Material(name="TRT_CH2",density, nel=2);
156  TRT_CH2->AddElement(elC,1);
157  TRT_CH2->AddElement(elH,2);
158 
159  // Radiator
160 
161  density = 0.059*g/cm3;
162  G4Material* Radiator = new G4Material(name="Radiator",density, nel=2);
163  Radiator->AddElement(elC,1);
164  Radiator->AddElement(elH,2);
165 // Carbon Fiber
166 
167  density = 0.145*g/cm3;
168  G4Material* CarbonFiber = new G4Material(name="CarbonFiber",density, nel=1);
169  CarbonFiber->AddElement(elC,1);
170 
171  // Lithium
172 
173  density = 0.534*g/cm3;
174  G4Material* Li = new G4Material(name="Li",density, nel=1);
175  Li->AddElement(elLi,1);
176 
177  // Beryllium
178 
179  density = 1.848*g/cm3;
180  G4Material* Be = new G4Material(name="Be",density, nel=1);
181  Be->AddElement(elBe,1);
182 
183  // Mylar
184 
185  density = 1.39*g/cm3;
186  G4Material* Mylar = new G4Material(name="Mylar", density, nel=3);
187  Mylar->AddElement(elO,2);
188  Mylar->AddElement(elC,5);
189  Mylar->AddElement(elH,4);
190 
191  // Kapton (polyimide) ??? since = Mylar C5H4O2
192 
193  density = 1.39*g/cm3;
194  G4Material* Kapton = new G4Material(name="Kapton", density, nel=3);
195  Kapton->AddElement(elO,2);
196  Kapton->AddElement(elC,5);
197  Kapton->AddElement(elH,4);
198 
199 // Polypropelene
200
201  G4Material* CH2 = new G4Material ("CH2" , 0.91*g/cm3, 2);
202  CH2->AddElement(elH,2);
203  CH2->AddElement(elC,1);
204 
205  //////////////////////////////////////////////////////////////////////////
206  //
207  // Noble gases , STP conditions
208 
209  // Helium as detector gas, STP
210 
211  density = 0.178*mg/cm3 ;
212  a = 4.0026*g/mole ;
213  G4Material* He  = new G4Material(name="He",z=2., a, density );
214 
215  // Neon as detector gas, STP
216
217  density = 0.900*mg/cm3 ;
218  a = 20.179*g/mole ;
219  G4Material* Ne  = new G4Material(name="Ne",z=10., a, density );
220
221  // Argon as detector gas, STP
222
223  density = 1.7836*mg/cm3 ;       // STP
224  G4Material* Argon = new G4Material(name="Argon"  , density, ncomponents=1);
225  Argon->AddElement(elAr, 1);
226
227  // Krypton as detector gas, STP
228
229  density = 3.700*mg/cm3 ;
230  a = 83.80*g/mole ;
231  G4Material* Kr  = new G4Material(name="Kr",z=36., a, density );
232
233  // Xenon as detector gas, STP
234
235  density = 5.858*mg/cm3 ;
236  a = 131.29*g/mole ;
237  G4Material* Xe  = new G4Material(name="Xenon",z=54., a, density );
238
239/////////////////////////////////////////////////////////////////////////////
240//
241// Hydrocarbones, metane and others
242
243  // Metane, STP
244 
245  density = 0.7174*mg/cm3 ;
246  G4Material* metane = new G4Material(name="CH4",density,nel=2) ;
247  metane->AddElement(elC,1) ;
248  metane->AddElement(elH,4) ;
249 
250  // Propane, STP
251 
252  density = 2.005*mg/cm3 ;
253  G4Material* propane = new G4Material(name="C3H8",density,nel=2) ;
254  propane->AddElement(elC,3) ;
255  propane->AddElement(elH,8) ;
256 
257  // iso-Butane (methylpropane), STP
258 
259  density = 2.67*mg/cm3 ;
260  G4Material* isobutane = new G4Material(name="isoC4H10",density,nel=2) ;
261  isobutane->AddElement(elC,4) ;
262  isobutane->AddElement(elH,10) ;
263
264  ///////////////////////////////////////////////////////////////////////////
265  //
266  // Molecular gases
267
268  // Carbon dioxide, STP
269
270  density = 1.977*mg/cm3;
271  G4Material* CO2 = new G4Material(name="CO2", density, nel=2,
272                                       kStateGas,273.15*kelvin,1.*atmosphere);
273  CO2->AddElement(elC,1);
274  CO2->AddElement(elO,2);
275
276  // Carbon dioxide, STP
277
278  density = 1.977*mg/cm3;
279  G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2);
280  CarbonDioxide->AddElement(elC,1);
281  CarbonDioxide->AddElement(elO,2);
282
283
284  // Nitrogen, STP
285
286  density = 1.25053*mg/cm3 ;       // STP
287  G4Material* Nitrogen = new G4Material(name="N2"  , density, ncomponents=1);
288  Nitrogen->AddElement(elN, 2);
289
290  // Oxygen, STP
291
292  density = 1.4289*mg/cm3 ;       // STP
293  G4Material* Oxygen = new G4Material(name="O2"  , density, ncomponents=1);
294  Oxygen->AddElement(elO, 2);
295
296  /* *****************************
297
298  density = 1.25053*mg/cm3 ;       // STP
299  a = 14.01*g/mole ;       // get atomic weight !!!
300  //  a = 28.016*g/mole;
301  G4Material* N2  = new G4Material(name="Nitrogen", z= 7.,a,density) ;
302
303  density = 1.25053*mg/cm3 ;       // STP
304  G4Material* anotherN2 = new G4Material(name="anotherN2", density,ncomponents=2);
305  anotherN2->AddElement(elN, 1);
306  anotherN2->AddElement(elN, 1);
307
308  // air made from oxigen and nitrogen only
309
310  density = 1.290*mg/cm3;  // old air from elements
311  G4Material* air = new G4Material(name="air"  , density, ncomponents=2);
312  air->AddElement(elN, fractionmass=0.7);
313  air->AddElement(elO, fractionmass=0.3);
314
315  ******************************************** */
316
317  // Dry Air (average composition), STP
318
319  density = 1.2928*mg/cm3 ;       // STP
320  G4Material* Air = new G4Material(name="Air"  , density, ncomponents=3);
321  Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ;
322  Air->AddMaterial( Oxygen,   fractionmass = 0.2315 ) ;
323  Air->AddMaterial( Argon,    fractionmass = 0.0128 ) ;
324
325   ////////////////////////////////////////////////////////////////////////////
326  //
327  // MWPC mixtures
328 
329  // 80% Xe + 20% CO2, STP
330 
331  density = 5.0818*mg/cm3 ;     
332  G4Material* Xe20CO2 = new G4Material(name="Xe20CO2"  , density, ncomponents=2);
333  Xe20CO2->AddMaterial( Xe,              fractionmass = 0.922 ) ;
334  Xe20CO2->AddMaterial( CarbonDioxide,   fractionmass = 0.078 ) ;
335 
336  // 80% Kr + 20% CO2, STP
337 
338  density = 3.601*mg/cm3 ;     
339  G4Material* Kr20CO2 = new G4Material(name="Kr20CO2", density, 
340                                       ncomponents=2);
341  Kr20CO2->AddMaterial( Kr,              fractionmass = 0.89 ) ;
342  Kr20CO2->AddMaterial( CarbonDioxide,   fractionmass = 0.11 ) ;
343 
344  // Xe + 55% He + 15% CH4 ; NIM A294 (1990) 465-472; STP
345 
346  density = 1.963*mg/cm3;
347  G4Material* Xe55He15CH4 = new G4Material(name="Xe55He15CH4",density,
348                                           ncomponents=3);
349  Xe55He15CH4->AddMaterial(Xe, 0.895);
350  Xe55He15CH4->AddMaterial(He, 0.050);
351  Xe55He15CH4->AddMaterial(metane,0.055);
352
353  // 90% Xe + 10% CH4, STP ; NIM A248 (1986) 379-388
354 
355  density = 5.344*mg/cm3 ;     
356  G4Material* Xe10CH4 = new G4Material(name="Xe10CH4"  , density, 
357                                       ncomponents=2);
358  Xe10CH4->AddMaterial( Xe,       fractionmass = 0.987 ) ;
359  Xe10CH4->AddMaterial( metane,   fractionmass = 0.013 ) ;
360 
361  // 95% Xe + 5% CH4, STP ; NIM A214 (1983) 261-268
362 
363  density = 5.601*mg/cm3 ;     
364  G4Material* Xe5CH4 = new G4Material(name="Xe5CH4"  , density, 
365                                      ncomponents=2);
366  Xe5CH4->AddMaterial( Xe,       fractionmass = 0.994 ) ;
367  Xe5CH4->AddMaterial( metane,   fractionmass = 0.006 ) ;
368 
369  // 80% Xe + 20% CH4, STP ; NIM A253 (1987) 235-244
370 
371  density = 4.83*mg/cm3 ;     
372  G4Material* Xe20CH4 = new G4Material(name="Xe20CH4"  , density, 
373                                       ncomponents=2);
374  Xe20CH4->AddMaterial( Xe,       fractionmass = 0.97 ) ;
375  Xe20CH4->AddMaterial( metane,   fractionmass = 0.03 ) ;
376
377  // 93% Ar + 7% CH4, STP ; NIM 107 (1973) 413-422
378
379  density = 1.709*mg/cm3 ;     
380  G4Material* Ar7CH4 = new G4Material(name="Ar7CH4"  , density, 
381                                                  ncomponents=2);
382  Ar7CH4->AddMaterial( Argon,       fractionmass = 0.971 ) ;
383  Ar7CH4->AddMaterial( metane,   fractionmass = 0.029 ) ;
384
385  // 93% Kr + 7% CH4, STP ; NIM 107 (1973) 413-422
386
387  density = 3.491*mg/cm3 ;     
388  G4Material* Kr7CH4 = new G4Material(name="Kr7CH4"  , density, 
389                                                  ncomponents=2);
390  Kr7CH4->AddMaterial( Kr,       fractionmass = 0.986 ) ;
391  Kr7CH4->AddMaterial( metane,   fractionmass = 0.014 ) ;
392
393  // 0.5*(95% Xe + 5% CH4)+0.5*(93% Ar + 7% CH4), STP ; NIM A214 (1983) 261-268
394
395  density = 3.655*mg/cm3 ;     
396  G4Material* XeArCH4 = new G4Material(name="XeArCH4"  , density, 
397                                                  ncomponents=2);
398  XeArCH4->AddMaterial( Xe5CH4,       fractionmass = 0.766 ) ;
399  XeArCH4->AddMaterial( Ar7CH4,   fractionmass = 0.234 ) ;
400
401
402  ////////////////////////////////////////////////////////////
403  //
404  // Geometry
405
406
407  ///////////////////////
408
409  G4int i, j, k, nBin, numOfMaterials, iSan, nbOfElements, sanIndex, row ;
410
411  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable() ;
412
413  numOfMaterials = theMaterialTable->size();
414
415  G4String testName;
416
417  for( k = 0; k < numOfMaterials; k++ )
418  {
419    //    if((*theMaterialTable)[k]->GetName() != testName) continue ;
420
421    // outFile << "Material : " <<(*theMaterialTable)[k]->GetName() << G4endl ;
422    // G4cout <<k<<"\t"<< "Material : " <<(*theMaterialTable)[k]->GetName() << G4endl ;
423  }
424
425  //  G4cout<<"Enter material name for test : "<<std::flush ;
426  //  G4cin>>testName ;
427
428   
429  // G4Region* regGasDet = new G4Region("VertexDetector");
430  // regGasDet->AddRootLogicalVolume(logicAbsorber);
431   
432  G4ProductionCuts* cuts = new G4ProductionCuts();
433  cuts->SetProductionCut(10.*mm,"gamma");
434  cuts->SetProductionCut(1.*mm,"e-");
435  cuts->SetProductionCut(1.*mm,"e+");
436
437   // regGasDet->SetProductionCuts(cuts);
438   
439  G4cout.precision(4);
440
441  //  G4MaterialCutsCouple* matCC = new G4MaterialCutsCouple(
442  //                                  (*theMaterialTable)[k], cuts);
443 // const G4RegionStore* theRegionStore = G4RegionStore::GetInstance();
444  // G4Region* gas = theRegionStore->GetRegion("XTRdEdxDetector");
445
446  const G4ParticleDefinition proton(
447                 name,   0.9382723*GeV,       0.0*MeV,       eplus,
448                    1,              +1,             0,
449                    1,              +1,             0,
450             "baryon",               0,            +1,        2212,
451                 true,            -1.0,          NULL,
452             false,           "neucleon"
453              );
454
455  G4ParticleDefinition* theProton = G4Proton::ProtonDefinition();
456  // *proton = theProton; 
457
458  // test of XTR table step do-it
459
460
461  G4double energyTR = 10*keV, cofAngle = 5.1,  angle2, dNdA, xCompton, lambdaC;
462  G4double charge = 1.0;
463  G4double chargeSq  = charge*charge ;
464  G4double gamma     = 4.e4; 
465  G4cout<<"gamma = "<<gamma<<G4endl;
466  G4cout<<"energyTR = "<<energyTR/keV<<" keV"<<G4endl;
467 
468
469  G4int iTkin;
470  G4cout<<"gamma = "<<gamma<<G4endl;
471
472  G4double TkinScaled = (gamma - 1.)*proton_mass_c2;
473
474  // output to file
475
476    std::ofstream fileWrite("normF.dat", std::ios::out ) ;
477    fileWrite.setf( std::ios::scientific, std::ios::floatfield );
478
479
480
481  G4cout.precision(12);
482  G4double ksi, gpsi, prob;
483
484  G4SynchrotronRadiation* sr = new G4SynchrotronRadiation();
485
486  /*
487  // sr->SetRootNumber(100);
488  // ksi = 1.e-8;
489  ksi = 0.;
490  prob = sr->GetIntProbSR( ksi);
491  G4cout<<"ksi = "<<ksi<<"; SR probability = "<<prob<<G4endl<<G4endl;
492
493  for( i = 0; i < 30; i++ )
494  {
495    ksi = std::pow(10.,-2. + i/10.);
496    prob = sr->GetEnergyProbSR( ksi);
497    G4cout<<"x = "<<ksi<<"; SR F(x) = "<<prob<<G4endl;
498    fileWrite<<ksi<<"\t"<<prob<<G4endl;
499  }
500  */
501
502  ksi = 5.;
503  sr->SetKsi(ksi);
504
505  for( i = 0; i < 30; i++ )
506  {
507    gpsi = std::pow(10.,-2. + i/10.);
508    prob = sr->GetAngleNumberAtGammaKsi( gpsi);
509    G4cout<<"x = "<<gpsi<<"; AngleDistr(x) = "<<prob<<G4endl;
510    fileWrite<<gpsi<<"\t"<<prob<<G4endl;
511  }
512
513
514  return 1 ;
515}
516
Note: See TracBrowser for help on using the repository browser.