1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * DISCLAIMER * |
---|
4 | // * * |
---|
5 | // * The following disclaimer summarizes all the specific disclaimers * |
---|
6 | // * of contributors to this software. The specific disclaimers,which * |
---|
7 | // * govern, are listed with their locations in: * |
---|
8 | // * http://cern.ch/geant4/license * |
---|
9 | // * * |
---|
10 | // * Neither the authors of this software system, nor their employing * |
---|
11 | // * institutes,nor the agencies providing financial support for this * |
---|
12 | // * work make any representation or warranty, express or implied, * |
---|
13 | // * regarding this software system or assume any liability for its * |
---|
14 | // * use. * |
---|
15 | // * * |
---|
16 | // * This code implementation is the intellectual property of the * |
---|
17 | // * GEANT4 collaboration. * |
---|
18 | // * By copying, distributing or modifying the Program (or any work * |
---|
19 | // * based on the Program) you indicate your acceptance of this * |
---|
20 | // * statement, and all its terms. * |
---|
21 | // ******************************************************************** |
---|
22 | // |
---|
23 | // $Id: G4CrossSectionTest.cc,v 1.3 2009/06/15 10:35:12 gunter Exp $ |
---|
24 | // ------------------------------------------------------------------- |
---|
25 | // |
---|
26 | // ------------------------------------------------------------------- |
---|
27 | // GEANT 4 class file --- Copyright CERN 1998 |
---|
28 | // CERN Geneva Switzerland |
---|
29 | // |
---|
30 | // |
---|
31 | // File name: G4CrossSectionTest.cc |
---|
32 | // |
---|
33 | // Author: Maria Grazia Pia (pia@genova.infn.it), |
---|
34 | // |
---|
35 | // Creation date: 15 April 1999 |
---|
36 | // |
---|
37 | // Modifications: |
---|
38 | // |
---|
39 | // Dec- 2008 GF : migrate to root |
---|
40 | // |
---|
41 | // ------------------------------------------------------------------- |
---|
42 | |
---|
43 | #include "globals.hh" |
---|
44 | |
---|
45 | #include "G4ios.hh" |
---|
46 | #include <fstream> |
---|
47 | #include <iomanip> |
---|
48 | #include <iostream> |
---|
49 | #include <assert.h> |
---|
50 | |
---|
51 | #include "Randomize.hh" |
---|
52 | |
---|
53 | #include "G4ThreeVector.hh" |
---|
54 | #include "G4LorentzVector.hh" |
---|
55 | #include "G4LorentzRotation.hh" |
---|
56 | |
---|
57 | #include "G4AntiProton.hh" |
---|
58 | #include "G4Proton.hh" |
---|
59 | #include "G4AntiNeutron.hh" |
---|
60 | #include "G4Neutron.hh" |
---|
61 | #include "G4PionPlus.hh" |
---|
62 | #include "G4PionMinus.hh" |
---|
63 | #include "G4PionZero.hh" |
---|
64 | #include "G4KaonMinus.hh" |
---|
65 | #include "G4KaonPlus.hh" |
---|
66 | #include "G4Gamma.hh" |
---|
67 | #include "G4MuonMinus.hh" |
---|
68 | #include "G4MuonPlus.hh" |
---|
69 | #include "G4NeutrinoMu.hh" |
---|
70 | #include "G4AntiNeutrinoMu.hh" |
---|
71 | #include "G4Lambda.hh" |
---|
72 | |
---|
73 | #include "G4ParticleDefinition.hh" |
---|
74 | |
---|
75 | #include "G4VDecayChannel.hh" |
---|
76 | #include "G4DecayTable.hh" |
---|
77 | |
---|
78 | #include "G4KineticTrack.hh" |
---|
79 | #include "G4KineticTrackVector.hh" |
---|
80 | |
---|
81 | #include "G4VShortLivedParticle.hh" |
---|
82 | #include "G4ShortLivedConstructor.hh" |
---|
83 | #include "G4ParticleTable.hh" |
---|
84 | #include "G4ShortLivedTable.hh" |
---|
85 | #include "G4LeptonConstructor.hh" |
---|
86 | #include "G4BaryonConstructor.hh" |
---|
87 | #include "G4VCrossSectionSource.hh" |
---|
88 | #include "G4XAqmTotal.hh" |
---|
89 | #include "G4XAqmElastic.hh" |
---|
90 | #include "G4XNNTotalLowE.hh" |
---|
91 | #include "G4XPDGTotal.hh" |
---|
92 | #include "G4XNNTotal.hh" |
---|
93 | #include "G4XNNElastic.hh" |
---|
94 | #include "G4XPDGElastic.hh" |
---|
95 | #include "G4XNNElasticLowE.hh" |
---|
96 | #include "G4XnpElastic.hh" |
---|
97 | #include "G4XResonance.hh" |
---|
98 | |
---|
99 | #include "TFile.h" |
---|
100 | #include "TH1F.h" |
---|
101 | #include "TH1D.h" |
---|
102 | #include "TTree.h" |
---|
103 | |
---|
104 | #define G4FPE_DEBUG=1 |
---|
105 | |
---|
106 | #ifdef G4FPE_DEBUG |
---|
107 | #include "G4FPEDetection.hh" |
---|
108 | #endif |
---|
109 | |
---|
110 | G4ParticleDefinition* SelectTrackDef(int i); |
---|
111 | |
---|
112 | int main() |
---|
113 | { |
---|
114 | |
---|
115 | #ifdef G4FPE_DEBUG |
---|
116 | InvalidOperationDetection(); |
---|
117 | #endif |
---|
118 | std::string hFile="xsec.root"; |
---|
119 | TFile * rootFile = new TFile(hFile.c_str(),"CREATE"); |
---|
120 | if ( ! rootFile ) |
---|
121 | { |
---|
122 | std::cout << " Fail to create root file " << std::endl; |
---|
123 | exit(1); |
---|
124 | } |
---|
125 | |
---|
126 | TTree * Txs = new TTree("SEC","Secondary info"); |
---|
127 | |
---|
128 | struct xs_info { |
---|
129 | float cmsE; |
---|
130 | float sigma; |
---|
131 | }; |
---|
132 | xs_info xsec; |
---|
133 | Txs->Branch("secondaries",&xsec.cmsE,"cmsE/F:sigma/F"); |
---|
134 | |
---|
135 | |
---|
136 | TH1 * hSigma = new TH1F("1","CrossSection", 100,0.,10.); |
---|
137 | |
---|
138 | |
---|
139 | /* G4ParticleDefinition* gamma = G4Gamma::GammaDefinition(); |
---|
140 | |
---|
141 | G4ParticleDefinition* proton = G4Proton::ProtonDefinition(); |
---|
142 | G4ParticleDefinition* antiProton = G4AntiProton::AntiProtonDefinition(); |
---|
143 | G4ParticleDefinition* neutron = G4Neutron::NeutronDefinition(); |
---|
144 | G4ParticleDefinition* antiNeutron = G4AntiNeutron::AntiNeutronDefinition(); |
---|
145 | |
---|
146 | G4ParticleDefinition* pionPlus = G4PionPlus::PionPlusDefinition(); |
---|
147 | G4ParticleDefinition* pionMinus = G4PionMinus::PionMinusDefinition(); |
---|
148 | G4ParticleDefinition* pionZero = G4PionZero::PionZeroDefinition(); |
---|
149 | |
---|
150 | G4ParticleDefinition* kaonPlus = G4KaonPlus::KaonPlusDefinition(); |
---|
151 | G4ParticleDefinition* kaonMinus = G4KaonMinus::KaonMinusDefinition(); |
---|
152 | |
---|
153 | G4ParticleDefinition* lambda = G4Lambda::LambdaDefinition(); |
---|
154 | |
---|
155 | G4ParticleDefinition* theMuonPlus = G4MuonPlus::MuonPlusDefinition(); |
---|
156 | G4ParticleDefinition* theMuonMinus = G4MuonMinus::MuonMinusDefinition(); |
---|
157 | |
---|
158 | G4ParticleDefinition* theNeutrinoMu = G4NeutrinoMu::NeutrinoMuDefinition(); |
---|
159 | G4ParticleDefinition* theAntiNeutrinoMu = G4AntiNeutrinoMu::AntiNeutrinoMuDefinition(); |
---|
160 | */ |
---|
161 | G4BaryonConstructor Baryons; |
---|
162 | Baryons.ConstructParticle(); |
---|
163 | G4LeptonConstructor Leptons; |
---|
164 | Leptons.ConstructParticle(); |
---|
165 | G4ShortLivedConstructor ShortLived; |
---|
166 | ShortLived.ConstructParticle(); |
---|
167 | |
---|
168 | G4ParticleDefinition* definition1= SelectTrackDef(1); |
---|
169 | G4double mass1 = definition1->GetPDGMass(); |
---|
170 | |
---|
171 | // Formation time |
---|
172 | G4double time1 = 0.; |
---|
173 | // G4cout << "Formation time (ns)" << G4endl; |
---|
174 | // G4cin >> time1; |
---|
175 | // if (time1 < 0.) time1 = 0.; |
---|
176 | // time1 = time1 * ns; |
---|
177 | |
---|
178 | |
---|
179 | // Initial position |
---|
180 | G4double x1 = 0.; |
---|
181 | G4double y1 = 0.; |
---|
182 | G4double z1 = 0.; |
---|
183 | // G4cout <<"Initial position (cm) " << G4endl; |
---|
184 | // G4cin >> x1 >> y1 >> z1; |
---|
185 | G4ThreeVector position1(x1*cm, y1*cm, z1*cm); |
---|
186 | |
---|
187 | // Momentum |
---|
188 | G4double pzMin1, pzMax1; |
---|
189 | G4cout << "Pz min and max (GeV)" << G4endl; |
---|
190 | G4cin >> pzMin1 >> pzMax1; |
---|
191 | pzMin1 = pzMin1 * GeV; |
---|
192 | pzMax1 = pzMax1 * GeV; |
---|
193 | |
---|
194 | // Select track 2 |
---|
195 | |
---|
196 | G4cout << "---- Set KineticTrack 2 ----" << G4endl; |
---|
197 | G4int id2 = 0; |
---|
198 | G4cout << "1 p 2 ap 3 n 4 an 5 pi+ 6 pi- 7 K+ 8 K- " << G4endl; |
---|
199 | G4cin >> id2; |
---|
200 | |
---|
201 | G4ParticleDefinition* definition2= SelectTrackDef(2); |
---|
202 | G4double mass2 = definition2->GetPDGMass(); |
---|
203 | |
---|
204 | // Formation time |
---|
205 | G4double time2 = 0.; |
---|
206 | // G4cout << "Formation time (ns)" << G4endl; |
---|
207 | // G4cin >> time2; |
---|
208 | // if (time2 < 0.) time2 = 0.; |
---|
209 | // time2 = time2 * ns; |
---|
210 | |
---|
211 | // Initial position |
---|
212 | G4double x2 = 0.; |
---|
213 | G4double y2 = 0.; |
---|
214 | G4double z2 = 0.; |
---|
215 | // G4cout <<"Initial position (cm) " << G4endl; |
---|
216 | // G4cin >> x2 >> y2 >> z2; |
---|
217 | G4ThreeVector position2(x2*cm, y2*cm, z2*cm); |
---|
218 | |
---|
219 | // Momentum |
---|
220 | G4double pzMin2; |
---|
221 | G4double pzMax2; |
---|
222 | G4cout << "Pz min and max (GeV)" << G4endl; |
---|
223 | G4cin >> pzMin2 >> pzMax2; |
---|
224 | pzMin2 = pzMin2 * GeV; |
---|
225 | pzMax2 = pzMax2 * GeV; |
---|
226 | |
---|
227 | // Select CrossSectionSource |
---|
228 | |
---|
229 | G4cout << "CrossSectionSource: " << G4endl |
---|
230 | << "1) AqmElastic " |
---|
231 | << "2) AqmTotal " |
---|
232 | << "3) NNElastic " |
---|
233 | << "4) NNElasticLowE " |
---|
234 | << "5) NNTotal " << G4endl |
---|
235 | << "6) NNTotalLowE " |
---|
236 | << "7) PDGElastic " |
---|
237 | << "8) PDGTotal " |
---|
238 | << "9) Resonance " |
---|
239 | << "10) XnpElastic " |
---|
240 | << G4endl; |
---|
241 | |
---|
242 | G4int ids; |
---|
243 | G4cin >> ids; |
---|
244 | |
---|
245 | G4VCrossSectionSource* source; |
---|
246 | |
---|
247 | switch (ids) |
---|
248 | { |
---|
249 | case 1: |
---|
250 | source = new G4XAqmElastic; |
---|
251 | break; |
---|
252 | case 2: |
---|
253 | source = new G4XAqmTotal; |
---|
254 | break; |
---|
255 | case 3: |
---|
256 | source = new G4XNNElastic; |
---|
257 | break; |
---|
258 | case 4: |
---|
259 | source = new G4XNNElasticLowE; |
---|
260 | break; |
---|
261 | case 5: |
---|
262 | source = new G4XNNTotal; |
---|
263 | break; |
---|
264 | case 6: |
---|
265 | source = new G4XNNTotalLowE; |
---|
266 | break; |
---|
267 | case 7: |
---|
268 | source = new G4XPDGElastic(); |
---|
269 | break; |
---|
270 | case 8: |
---|
271 | source = new G4XPDGTotal(); |
---|
272 | break; |
---|
273 | case 9: |
---|
274 | // source = new G4XResonance; |
---|
275 | break; |
---|
276 | case 10: |
---|
277 | source = new G4XnpElastic; |
---|
278 | break; |
---|
279 | default: |
---|
280 | source = new G4XAqmTotal; |
---|
281 | break; |
---|
282 | } |
---|
283 | |
---|
284 | G4cout << "***** " << source->Name() << "***** created " << G4endl; |
---|
285 | source->Print(); |
---|
286 | |
---|
287 | // Number of iterations |
---|
288 | G4int n = 0; |
---|
289 | G4cout << "---- Number of iterations ----" << G4endl; |
---|
290 | G4cin >> n; |
---|
291 | if (n < 1) n = 1; |
---|
292 | |
---|
293 | G4double step1 = (pzMax1 - pzMin1) / n; |
---|
294 | G4double step2 = (pzMax2 - pzMin2) / n; |
---|
295 | |
---|
296 | G4cout << "pz min max step " |
---|
297 | << pzMin1 / GeV << ", " |
---|
298 | << pzMax1 / GeV << ", " |
---|
299 | << step1 / GeV << ", " << G4endl |
---|
300 | << "pz min max step " |
---|
301 | << pzMin2 / GeV << ", " |
---|
302 | << pzMax2 / GeV << ", " |
---|
303 | << step2 / GeV << G4endl; |
---|
304 | |
---|
305 | G4int i; |
---|
306 | for (i=0; i<n; i++) |
---|
307 | { |
---|
308 | G4double pStep1 = pzMin1 + step1 * i; |
---|
309 | G4ThreeVector p1(0.,0.,pStep1); |
---|
310 | G4double e1 = sqrt(mass1*mass1 + p1.mag()*p1.mag()); |
---|
311 | G4LorentzVector p41(p1,e1); |
---|
312 | G4KineticTrack trk1(definition1,time1,position1,p41); |
---|
313 | |
---|
314 | G4double pStep2 = -(pzMin2 + step2 * i); |
---|
315 | G4ThreeVector p2(0.,0.,pStep2); |
---|
316 | G4double e2 = sqrt(mass2*mass2 + p2.mag()*p2.mag()); |
---|
317 | G4LorentzVector p42(p2,e2); |
---|
318 | G4KineticTrack trk2(definition2,time2,position2,p42); |
---|
319 | |
---|
320 | G4double sqrts = (trk1.Get4Momentum() + trk2.Get4Momentum()).mag(); |
---|
321 | |
---|
322 | // G4cout << "*-*-*-*-* Step " << i |
---|
323 | // << " - pz1, pz2 = " << pStep1 << ", " << pStep2 |
---|
324 | // << " - e1, e2 = " << e1 << ", " << e2 |
---|
325 | // << " - p41.m(), p42.m() = " << trk1.Get4Momentum().m() << ", " << trk2.Get4Momentum().m() |
---|
326 | // << " ----- sqrtS = " << sqrts << G4endl; |
---|
327 | |
---|
328 | |
---|
329 | source->PrintAll(trk1,trk2); |
---|
330 | |
---|
331 | G4double sigma = source->CrossSection(trk1,trk2); |
---|
332 | |
---|
333 | // G4cout << "Energy: " << sqrts / GeV |
---|
334 | // << " ---- CrossSection = " << sigma / millibarn |
---|
335 | // << G4endl; |
---|
336 | |
---|
337 | xsec.cmsE=sqrts/GeV; |
---|
338 | xsec.sigma=sigma/millibarn; |
---|
339 | Txs->Fill(); |
---|
340 | } |
---|
341 | |
---|
342 | std::cout << "Committing..." << std::endl; |
---|
343 | rootFile->Write(); |
---|
344 | |
---|
345 | |
---|
346 | delete source; |
---|
347 | |
---|
348 | return EXIT_SUCCESS; |
---|
349 | } |
---|
350 | |
---|
351 | G4ParticleDefinition* SelectTrackDef(int i) |
---|
352 | { |
---|
353 | G4cout << "---- Set KineticTrack " << i << " ----" << G4endl; |
---|
354 | G4int id = 0; |
---|
355 | G4cout << "1 p 2 ap 3 n 4 an 5 pi+ 6 pi- 7 K+ 8 K- " << G4endl; |
---|
356 | G4cin >> id; |
---|
357 | |
---|
358 | G4ParticleDefinition* pDef; |
---|
359 | switch (id) |
---|
360 | { |
---|
361 | case 1: |
---|
362 | pDef = G4Proton::Proton(); |
---|
363 | break; |
---|
364 | case 2: |
---|
365 | pDef = G4AntiProton::AntiProton(); |
---|
366 | break; |
---|
367 | case 3: |
---|
368 | pDef = G4Neutron::Neutron(); |
---|
369 | break; |
---|
370 | case 4: |
---|
371 | pDef = G4AntiNeutron::AntiNeutron(); |
---|
372 | break; |
---|
373 | case 5: |
---|
374 | pDef = G4PionPlus::PionPlus(); |
---|
375 | break; |
---|
376 | case 6: |
---|
377 | pDef = G4PionMinus::PionMinus(); |
---|
378 | break; |
---|
379 | case 7: |
---|
380 | pDef = G4KaonPlus::KaonPlus(); |
---|
381 | break; |
---|
382 | case 8: |
---|
383 | pDef = G4KaonMinus::KaonMinus(); |
---|
384 | break; |
---|
385 | default: |
---|
386 | pDef = G4Proton::Proton(); |
---|
387 | break; |
---|
388 | } |
---|
389 | return pDef; |
---|
390 | } |
---|