BmnRoot
Loading...
Searching...
No Matches
MpdLAQGSMGenerator.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- MpdLAQGSMGenerator source file -----
3// -------------------------------------------------------------------------
4
13#include "MpdLAQGSMGenerator.h"
14
15#include "CbmStack.h" //AZ-310822
16#include "FairIon.h"
17#include "FairMCEventHeader.h"
18#include "FairParticle.h"
19#include "FairPrimaryGenerator.h"
20#include "FairRunSim.h"
21#include "MpdHypYPtGenerator.h" //AZ
22#include "TDatabasePDG.h"
23#include "TParticle.h"
24#include "TParticlePDG.h"
25#include "TSystem.h"
26
27#include <TVirtualMC.h> //AZ-310822
28#include <iostream>
29
30using std::cout;
31using std::endl;
32using std::map;
33
34const Double_t kProtonMass = 0.938272013;
35const Double_t kNeutronMass = 0.93957;
36
37// ----- Default constructor ------------------------------------------
38
40// ------------------------------------------------------------------------
41
42// ----- Standard constructor -----------------------------------------
43
45 const Bool_t use_collider_system,
46 Int_t QGSM_format_ID,
47 Int_t Max_Event_Number)
48 : FairGenerator()
49 , fX(0.)
50 , fY(0.)
51 , fZ(0.)
52 , fIonMap()
53{
54 // AZ memset(la_tab,0,sizeof(la_tab));
55
56 fPDG = TDatabasePDG::Instance();
57
58 fFileName = fileName;
59 cout << "-I- MpdLAQGSMGenerator: Opening input file " << fileName << endl;
60
61 fInputFile = NULL;
62 fGZInputFile = NULL;
63
64 TString sFileName = fileName;
65 if (sFileName.Contains(".gz"))
66 fGZ_input = 1;
67 else
68 fGZ_input = 0;
69
70 if (fGZ_input)
71 fGZInputFile = gzopen(fFileName, "rb");
72 else
73 fInputFile = fopen(fFileName, "r");
74
75 if ((!fInputFile) && (!fGZInputFile))
76 Fatal("MpdLAQGSMGenerator", "Cannot open input file.");
77
78 fUseColliderSystem = use_collider_system;
79 fQGSM_format_ID = QGSM_format_ID;
80
81 Init(); // AZ
82 cout << "-I- MpdLAQGSMGenerator: Looking for ions..." << endl;
83 // AZ Int_t nIons = RegisterIons();
84 // Int_t nIons = RegisterIons1();
85 // Int_t nIons = RegisterIons(); // MG
86 Int_t nIons = RegisterIons(Max_Event_Number); // EL
87 cout << "-I- MpdLAQGSMGenerator: " << nIons << " ions registered." << endl;
88
89 CloseInput();
90 cout << "-I- MpdLAQGSMGenerator: Reopening input file " << fileName << endl;
91 if (fGZ_input)
92 fGZInputFile = gzopen(fFileName, "rb");
93 else
94 fInputFile = fopen(fFileName, "r");
95}
96// ------------------------------------------------------------------------
97
98// ----- Destructor ---------------------------------------------------
99
101{
102
103 CloseInput();
104 Int_t nPart = fLa_tab.size();
105 for (Int_t i = 0; i < nPart; ++i)
106 delete fLa_tab[i];
107 fLa_tab.clear();
108}
109// ------------------------------------------------------------------------
110
111// --------------Public method Init (fill list of known light particles)---
112
113void MpdLAQGSMGenerator::InitGenerator(const char* light_particles_filename)
114{
115 TString fname, dd;
116 if (!light_particles_filename) {
117 dd = getenv("VMCWORKDIR");
118 if (gSystem->OpenDirectory(dd + "/parameters"))
119 dd += "/parameters";
120 else {
121 if (gSystem->OpenDirectory(dd + "/generators"))
122 dd += "/generators";
123 else
124 dd = gSystem->WorkingDirectory();
125 }
126
127 fname = dd + "/MpdLAQGSM_light_particles.dat";
128 } else
129 fname = light_particles_filename;
130
131 Int_t /*i = 0,*/ i_val /*, i_max = 84*/;
132 Float_t a_val;
133
134 char ss[300];
135
136 FILE* fInputFile_light = fopen(fname.Data(), "r");
137 // AZ while (!(feof(fInputFile_light))&&(i<i_max)) {
138 while (!(feof(fInputFile_light))) {
139 la_tab_t* lt = new la_tab_t;
140 /*AZ
141 fscanf(fInputFile_light, "%d", &i_val); la_tab[i].pdg=i_val;
142 fscanf(fInputFile_light, "%d", &i_val); la_tab[i].Z=i_val;
143 fscanf(fInputFile_light, "%d", &i_val); la_tab[i].lepton=i_val;
144 fscanf(fInputFile_light, "%d", &i_val); la_tab[i].strange=i_val;
145 fscanf(fInputFile_light, "%d", &i_val); la_tab[i].A=i_val;
146 fscanf(fInputFile_light, "%f", &a_val); la_tab[i].mass=a_val;
147 fscanf(fInputFile_light, "%s", ss); strncpy(la_tab[i].name,ss,10);
148 i++;
149 */
150 fscanf(fInputFile_light, "%d", &i_val);
151 lt->pdg = i_val;
152 fscanf(fInputFile_light, "%d", &i_val);
153 lt->Z = i_val;
154 fscanf(fInputFile_light, "%d", &i_val);
155 lt->lepton = i_val;
156 fscanf(fInputFile_light, "%d", &i_val);
157 lt->strange = i_val;
158 fscanf(fInputFile_light, "%d", &i_val);
159 lt->A = i_val;
160 fscanf(fInputFile_light, "%f", &a_val);
161 lt->mass = a_val;
162 fscanf(fInputFile_light, "%s", ss);
163 strncpy(lt->name, ss, 10);
164 fLa_tab.push_back(lt);
165 }
166 fclose(fInputFile_light);
167}
168// ------------------------------------------------------------------------
169
170Bool_t MpdLAQGSMGenerator::general_fgets(char* ss, Int_t nn, FILE* p)
171{
172 Bool_t finished = 0;
173
174 if (fGZ_input) {
175 gzgets(fGZInputFile, ss, nn);
176 finished = (gzeof(fGZInputFile));
177 } else {
178 fgets(ss, nn, fInputFile);
179 finished = (feof(fInputFile));
180 }
181 return finished;
182}
183
185{
186 Bool_t finished = 0;
187
188 // if (fGZ_input) {
189 // gzgets(fGZInputFile,ss,250);
190 // finished = (gzeof(fGZInputFile));
191 // }
192 // else {
193 // fgets(ss,250,fInputFile);
194 // finished = ( feof(fInputFile) );
195 // }
196 finished = general_fgets(ss, 250, fInputFile);
197
198 // If end of input file is reached : close it and abort run
199 if (finished) {
200 cout << "-I- MpdLAQGSMGenerator: End of input file reached " << endl;
201 CloseInput();
202 return kFALSE;
203 }
204
205 Bool_t wrong_file = kFALSE;
206
207 TString tss(ss);
208 if (tss.Contains("QGSM")) { // 0
209
210 general_fgets(ss, 250, fInputFile);
211 tss = ss;
212 Int_t lines = 0;
213 while (!(tss.Contains("particles, b,bx,by"))) {
214 if (tss.Contains("QGSM format ID")) {
215 sscanf(ss, "QGSM format ID=%d", &fQGSM_format_ID);
216 cout << "QGSM format ID " << fQGSM_format_ID << endl;
217
218 if (fQGSM_format_ID == 2) { // correction of incorrect format_ID in some data files
219 fpos_t file_loc;
220 z_off_t gz_file_loc;
221 if (fGZ_input)
222 gz_file_loc = gztell(fGZInputFile);
223 else
224 fgetpos(fInputFile, &file_loc);
225 for (int k = 0; k < 5; k++)
226 general_fgets(ss, 250, fInputFile);
227 if (strlen(ss) > 90)
228 fQGSM_format_ID = 3;
229 cout << "QGSM format ID now " << fQGSM_format_ID << endl;
230 if (fGZ_input)
231 gzseek(fGZInputFile, gz_file_loc, SEEK_SET);
232 else
233 fsetpos(fInputFile, &file_loc);
234 }
235 }
236 general_fgets(ss, 250, fInputFile);
237 tss = ss;
238 lines++;
239 if ((fQGSM_format_ID >= 2) && (lines >= 4))
240 return kTRUE;
241 if (lines > 25) {
242 wrong_file = kTRUE;
243 break;
244 }
245 }
246 } else {
247 if (fQGSM_format_ID >= 2)
248 return kTRUE;
249 if (!tss.Contains("particles, b,bx,by")) {
250 general_fgets(ss, 250, fInputFile);
251 tss = ss;
252 }
253 }
254
255 if (wrong_file) {
256 cout << "-E- MpdLAQGSMGenerator: Wrong file header! " << endl;
257 CloseInput();
258 return kFALSE;
259 }
260
261 if (!tss.Contains("event")) { // 3
262 if (fQGSM_format_ID >= 2)
263 return kTRUE;
264 else {
265 cout << "-E- MpdLAQGSMGenerator: Wrong event header!" << endl;
266 CloseInput();
267 return kFALSE;
268 }
269 }
270
271 char tmp[250];
272
273 switch (fQGSM_format_ID) {
274 case 0:
275 case 1:
276 general_fgets(tmp, 250, fInputFile);
277 break;
278 case 2:
279 case 3:
280 general_fgets(ss, 250, fInputFile);
281 general_fgets(ss, 250, fInputFile);
282 break;
283 case 4: // AZ
284 general_fgets(ss, 250, fInputFile);
285 general_fgets(ss, 250, fInputFile);
286 break;
287 default:
288 break;
289 }
290
291 return kTRUE;
292}
293
294// ------------------------------------------------------------------------
295
296// AZ ----- Public method SkipEvents --------------------------------------
297
299{
300
301 if (count <= 0)
302 return kTRUE;
303
304 // Check for input file
305 if (fGZ_input) {
306 if (!fGZInputFile) {
307 cout << "-E- MpdLAQGSMGenerator: Input file not open!" << endl;
308 return kFALSE;
309 }
310 } else {
311 if (!fInputFile) {
312 cout << "-E- MpdLAQGSMGenerator: Input file not open!" << endl;
313 return kFALSE;
314 }
315 }
316
317 Int_t eventId = 0, nTracks = 0;
318
319 for (Int_t ii = 0; ii < count; ii++) {
320 char ss[252];
321
322 if (!GetEventHeader(ss))
323 return kFALSE;
324
325 sscanf(ss, " %d %d", &eventId, &nTracks);
326 // cout << ii << " " << eventId << endl;
327
328 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
329 general_fgets(ss, 250, fInputFile);
330 }
331 }
332 return kTRUE;
333}
334// ------------------------------------------------------------------------
335
336// ----- Public method ReadEvent --------------------------------------
337
338Bool_t MpdLAQGSMGenerator::ReadEvent(FairPrimaryGenerator* primGen)
339{
340
341 // Check for input file
342 if (fGZ_input) {
343 if (!fGZInputFile) {
344 cout << "-E- MpdLAQGSMGenerator: Input file not open!" << endl;
345 return kFALSE;
346 }
347 } else {
348 if (!fInputFile) {
349 cout << "-E- MpdLAQGSMGenerator: Input file not open!" << endl;
350 return kFALSE;
351 }
352 }
353
354 // ---> Check for primary generator
355 if (!primGen) {
356 cout << "-E- MpdLAQGSMGenerator::ReadEvent: "
357 << "No PrimaryGenerator!" << endl;
358 return kFALSE;
359 }
360
361 // AZ if (la_tab[0].pdg<=0)
362 if (fLa_tab[0]->pdg <= 0)
363 Init();
364
365 // Define event variable to be read from file
366 Int_t eventId = 0;
367 Int_t nTracks = 0;
368 Float_t b = 0., bx = 0, by = 0;
369
370 // Define track variables to be read from file
371 Int_t iCharge = 0, iLeptonic = 0, iStrange = 0, iBarionic = 0, iCode = 0, io1 = 0, io2 = 0, io3 = 0 //,
372 // A=0,
373 // Z=0
374 ;
375 Float_t px = 0., py = 0., pz = 0., pz1 = 0, pza1 = 0,
376 // Ekin = 0,
377 // Ekin1 = 0,
378 mass = 0;
379
380 Int_t PDG = 0;
381 char ss[252];
382
383 char ionName[30];
384
385 if (!GetEventHeader(ss))
386 return kFALSE;
387
388 // Double_t projA,projZ,projEex, targA, targZ, targEex;
389 Float_t projA, projZ, projEex, targA, targZ, targEex;
390
391 int bpos;
392 sscanf(ss, " %d %d %n", &eventId, &nTracks, &bpos);
393
394 if (!fQGSM_format_ID)
395 sscanf(&(ss[bpos]), "%g %g %g %g %g %g %g %g %g", &b, &bx, &by, &projA, &projZ, &projEex, &targA, &targZ,
396 &targEex);
397 else
398 sscanf(&(ss[bpos]), "%g %g %g", &b, &bx, &by);
399
400 cout << "-I- MpdLAQGSMGenerator::ReadEvent: Event " << eventId << ", b = " << b << " fm, multiplicity " << nTracks
401 << endl;
402
403 TVector2 bb; // MG
404 bb.Set(bx, by); // MG
405
406 // Set event id and impact parameter in MCEvent if not yet done
407 FairMCEventHeader* event = primGen->GetEvent();
408 if (event && (!event->IsSet())) {
409 event->SetEventID(eventId - 1);
410 event->SetB(b);
411 event->SetRotZ(bb.Phi()); // MG
412 event->MarkSet(kTRUE);
413 }
414
415 /*
416 //AZ - Loop over tracks to find hypernuclei
417 fpos_t position;
418 fgetpos (fInputFile, &position); // save position
419 Int_t iHyperOk = 0;
420
421 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
422
423 fgets(ss,250,fInputFile);
424 sscanf(ss," %d %d %d %d %d", &iCharge,&iLeptonic,&iStrange,&iBarionic, &iCode);
425
426 if (iStrange == -1 && iCharge == 1 && iBarionic == 3) {
427 // select only H3L
428 iHyperOk = 1;
429 break;
430 }
431 // Select H4LL
432 //if (iStrange == -2 && iCharge == 1 && iBarionic == 4) {
433 //iHyperOk = 1;
434 //break;
435 //}
436 }
437 if (iHyperOk) fsetpos (fInputFile, &position);
438 //else nTracks = 0; // do not store any track
439 else {
440 // Add particle manually
441 TParticlePDG* part = fPDG->GetParticle("H3L");
442 Int_t pdgType = part->PdgCode();
443 static MpdHypYPtGenerator *hypGen = 0x0;
444 if (hypGen == 0x0) {
445 hypGen = new MpdHypYPtGenerator(pdgType,1);
446 hypGen->SetDistributionPt(0.163); // temperature - H3L: NICA @ 5 GeV
447 hypGen->SetDistributionY(0.0, 0.373); // y0, Sigma_y - H3L: NICA @ 5 GeV
448 hypGen->Init();
449 }
450 hypGen->ReadEvent(primGen);
451 fsetpos (fInputFile, &position);
452 }
453 // AZ
454 */
455
456 // Loop over tracks in the current event
457 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
458
459 general_fgets(ss, 250, fInputFile);
460
461 // AZ if (fQGSM_format_ID < 3)
462 if (fQGSM_format_ID < 3 || fQGSM_format_ID == 4)
463 sscanf(ss, " %d %d %d %d %d", &iCharge, &iLeptonic, &iStrange, &iBarionic, &iCode);
464 else
465 sscanf(ss, " %d %d %d %d %d %d %d", &iCharge, &iLeptonic, &iStrange, &iBarionic, &io1, &io2, &io3);
466
467 Int_t p_num = 21;
468 if (fQGSM_format_ID == 3)
469 p_num = 36;
470 else if (fQGSM_format_ID == 4)
471 p_num = 30;
472
473 if (!fQGSM_format_ID)
474 sscanf(&(ss[p_num]), "%g%g%g%g%g", &px, &py, &pz, &pz1, &mass);
475 else
476 sscanf(&(ss[p_num]), "%g%g%g%g%g%g", &px, &py, &pz, &pz1, &pza1, &mass);
477
478 if (FindParticle(iCharge, iStrange, iLeptonic, iBarionic, mass, PDG, ionName)) {
479
480 if (!fPDG->GetParticle(PDG)) {
481 cout << "-W- MpdLAQGSMGenerator::ReadEvent: Cannot find " << PDG << " " << ionName << " in database!"
482 << endl;
483 continue;
484 }
485
486 // Give track to PrimaryGenerator
488 primGen->AddTrack(PDG, px, py, pz, 0., 0., 0.);
489 else
490 primGen->AddTrack(PDG, px, py, pz1, fX, fY, fZ);
491 // AZ-310822
492 if (fQGSM_format_ID == 3 && TMath::Abs(PDG) == 3122) {
493 // Store lambda polarization
494 Int_t nTr = gMC->GetStack()->GetNtrack();
495 TParticle* part = ((CbmStack*)gMC->GetStack())->GetParticle(nTr - 1);
496 Double_t polx = pza1; // pza1 - polarization after rescattering
497 if (polx > 0)
498 polx = 0;
499 // polx = -0.5; // pza1 - polarization after rescattering
500 Double_t poly = TMath::Sqrt(1.0 - polx * polx);
501 Double_t polz = pz1; // pz1 - initial polarization
502 part->SetPolarisation(polx, poly, polz);
503 }
504 }
505 }
506
507 return kTRUE;
508}
509// ------------------------------------------------------------------------
510
511// ----- Private method CloseInput ------------------------------------
512
514{
515 if (fInputFile) {
516 if (!fGZ_input)
517 fclose(fInputFile);
518 fInputFile = NULL;
519 }
520 if (fGZInputFile) {
521 if (fGZ_input)
522 gzclose(fGZInputFile);
523 fGZInputFile = NULL;
524 }
525}
526// ------------------------------------------------------------------------
527
528Int_t MpdLAQGSMGenerator::CreatePdgCode(Int_t Z, Int_t A, Int_t Strange, Int_t user)
529{
530 // 10LZZZAAAI
531
532 const Int_t kion = 1000000000;
533 const Int_t kion_strange = kion + 10000000;
534 const Int_t kspecial = 50000000;
535
536 if (Strange) {
537 Int_t ss = abs(Strange);
538 if (Z) {
539 if (ss == 1)
540 return (kion_strange + Z * 10000 + A * 10);
541 else
542 return (kion + 10000000 * ss + Z * 10000 + A * 10);
543 } else
544 return (kspecial + A * 10);
545 } else {
546 return (kion + Z * 10000 + A * 10 + user);
547 }
548}
549
551{
552 Bool_t finished = 0;
553 if (fGZ_input)
554 finished = (gzeof(fGZInputFile));
555 else
556 finished = (feof(fInputFile));
557 return finished;
558}
559
560// ----- Private method RegisterIons ----------------------------------
561
562Int_t MpdLAQGSMGenerator::RegisterIons(Int_t Max_Event_Number)
563{
564
565 Int_t nIons = 0;
566 // Int_t eventId, nTracks, iPid, iMass, iCharge;
567 // Double_t pBeam, b, px, py, pz;
568 Int_t eventId = 0;
569 Int_t nTracks = 0;
570 // Float_t b = 0., bx=0, by=0;
571
572 // Define track variables to be read from file
573 Int_t iCharge = 0, iLeptonic = 0, iStrange = 0, iBarionic = 0, iCode = 0;
574 Float_t px = 0., py = 0., pz = 0., pz1 = 0, pza1 = 0,
575 // Ekin = 0,
576 // Ekin1 = 0,
577 mass = 0, excEnergy = 0;
578 char ss[252], buf_ionName[30];
579
580 Int_t A = 0, Z = 0, Q = 0;
581
582 fIonMap.clear();
583
584 if (!GetEventHeader(ss))
585 return 0;
586
587 Bool_t geant4_bug_case = 1;
588
589 Int_t PDG;
590 TString ionName;
591
592 while ((!general_feof(fInputFile)) && ((!Max_Event_Number) || (eventId < Max_Event_Number))) {
593
594 sscanf(ss, " %d %d", &eventId, &nTracks);
595
597 continue;
598
599 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
600
601 general_fgets(ss, 250, fInputFile);
602
603 sscanf(ss, " %d %d %d %d %d", &iCharge, &iLeptonic, &iStrange, &iBarionic, &iCode);
604
605 // if (!fQGSM_format_ID)
606 // sscanf(&(ss[21]),"%g%g%g%g%g",&px,&py,&pz,&pz1,&mass);
607 // else
608 // sscanf(&(ss[21]),"%g%g%g%g%g%g",&px,&py,&pz,&pz1,&pza1,&mass);
609
610 Int_t p_num = 21;
611 if (fQGSM_format_ID == 3)
612 p_num = 36;
613 else if (fQGSM_format_ID == 4)
614 p_num = 30;
615
616 if (!fQGSM_format_ID)
617 sscanf(&(ss[p_num]), "%g%g%g%g%g", &px, &py, &pz, &pz1, &mass);
618 else
619 sscanf(&(ss[p_num]), "%g%g%g%g%g%g", &px, &py, &pz, &pz1, &pza1, &mass);
620
621 if (iBarionic > 1) { // ion
622
623 A = iBarionic;
624 Z = iCharge;
625 Q = iCharge;
626
627 if (A > 9)
628 geant4_bug_case = 0;
629
630 if (FindParticle(iCharge, iStrange, iLeptonic, iBarionic, mass, PDG, buf_ionName)) {
631
632 if (fPDG->GetParticle(PDG))
633 continue;
634
635 ionName = buf_ionName;
636
637 if (!iStrange) { // normal ion
638 if (Z > 2 || (Z == 2 && A > 4)) { // MG
639
640 if (fIonMap.find(ionName) == fIonMap.end()) { // new ion
641 // excEnergy = fabs(mass - kProtonMass*Z -kNeutronMass*(iBarionic-Z));
642 FairIon* ion = new FairIon(ionName, Z, A, Q); // , excEnergy,mass); // from MG
643 fIonMap[ionName] = ion;
644 nIons++;
645 }
646 }
647 }
648
649 else
650 { // hyper
651 // AZ if(false)
652 if (CreateNucleus(Z, mass, PDG, buf_ionName)) {
653 // FairParticle *pa=new FairParticle(buf_ionName,Z, iBarionic, abs(iStrange),
654 // mass,Z,0,2.6e-10);
655 /*
656 TParticle *tpa= new TParticle();
657 if (tpa) {
658 tpa->SetPdgCode(PDG);
659 FairParticle *pa=new FairParticle(PDG,tpa);
660 if (pa)
661 (FairRunSim::Instance())->AddNewParticle(pa);
662 }
663 */
664 if (Z) { // AZ
665 FairParticle* pa =
666 new FairParticle(PDG, buf_ionName, kPTHadron, mass, Z, 2.6e-10, "hadron");
667 if (pa)
668 FairRunSim::Instance()->AddNewParticle(pa);
669 } else {
670 FairParticle* pa =
671 new FairParticle(PDG, buf_ionName, kPTNeutron, mass, Z, 2.6e-10, "special");
672 if (pa)
673 FairRunSim::Instance()->AddNewParticle(pa);
674 } // AZ
675 }
676 }
677 }
678
679 } // ion
680
681 } // track loop
682
683 if (!GetEventHeader(ss))
684 break;
685
686 } // event loop
687
688 if (geant4_bug_case) { // artificial heavy ion
689 mass = 9.98;
690 excEnergy = fabs(mass - (kProtonMass + kNeutronMass) * 5);
691 TString ionName_dummy = "Ion_10_5";
692 if (fIonMap.find(ionName_dummy) == fIonMap.end()) {
693 FairIon* ion = new FairIon(ionName_dummy, 5, 10, 5, excEnergy, mass);
694 fIonMap[ionName_dummy] = ion;
695 nIons++;
696 }
697 }
698
699 FairRunSim* run = FairRunSim::Instance();
700 map<TString, FairIon*>::iterator mapIt;
701 for (mapIt = fIonMap.begin(); mapIt != fIonMap.end(); ++mapIt) {
702 FairIon* ion = (*mapIt).second;
703 run->AddNewIon(ion);
704 }
705
706 return nIons;
707}
708
709// ----- Private method RegisterIons1 ----------------------------------
710
712{
713 // Read file with particle data
714
715 Int_t nIons = 0, nPart = fLa_tab.size();
716
717 fIonMap.clear();
718 Bool_t geant4_bug_case = 1;
719 Int_t PDG;
720 TString ionName;
721 Float_t mass = 0.0, excEnergy = 0.0;
722 char buf_ionName[30];
723
724 for (Int_t i = 0; i < nPart; ++i) {
725 Int_t Z = fLa_tab[i]->Z, iCharge = Z, Q = Z;
726 Int_t iLeptonic = fLa_tab[i]->lepton;
727 Int_t iStrange = fLa_tab[i]->strange;
728 Int_t A = fLa_tab[i]->A, iBarionic = A;
729 mass = fLa_tab[i]->mass;
730
731 if (iBarionic > 1) {
732 // ion
733
734 // if (A > 9) geant4_bug_case = 0;
735
736 if (FindParticle(iCharge, iStrange, iLeptonic, iBarionic, mass, PDG, buf_ionName)) {
737
738 if (fPDG->GetParticle(PDG))
739 continue;
740
741 ionName = buf_ionName;
742
743 if (!iStrange) {
744 // normal ion
745
746 if (fIonMap.find(ionName) == fIonMap.end()) { // new ion
747 excEnergy = fabs(mass - kProtonMass * Z - kNeutronMass * (iBarionic - Z));
748 FairIon* ion = new FairIon(ionName, Z, A, Q, excEnergy, mass);
749 fIonMap[ionName] = ion;
750 nIons++;
751 }
752 } else {
753 // hyper
754 if (false)
755 if (CreateNucleus(Z, mass, PDG, buf_ionName)) {
756 // FairParticle *pa=new FairParticle(buf_ionName,Z, iBarionic, abs(iStrange),
757 // mass,Z,0,2.6e-10);
758 if (Z) {
759 FairParticle* pa =
760 new FairParticle(PDG, buf_ionName, kPTHadron, mass, Z, 2.6e-10, "hadron");
761 if (pa)
762 FairRunSim::Instance()->AddNewParticle(pa);
763 } else {
764 FairParticle* pa =
765 new FairParticle(PDG, buf_ionName, kPTNeutron, mass, Z, 2.6e-10, "special");
766 if (pa)
767 FairRunSim::Instance()->AddNewParticle(pa);
768 }
769 }
770 }
771 }
772
773 } // if (iBarionic > 1)
774
775 } // for (Int_t i = 0; i < nPart;
776
777 if (geant4_bug_case) { // artificial heavy ion
778 mass = 9.98;
779 excEnergy = fabs(mass - (kProtonMass + kNeutronMass) * 5);
780 TString ionName_dummy = "Ion_10_5";
781 if (fIonMap.find(ionName_dummy) == fIonMap.end()) {
782 FairIon* ion = new FairIon(ionName_dummy, 5, 10, 5, excEnergy, mass);
783 fIonMap[ionName_dummy] = ion;
784 nIons++;
785 }
786 }
787
788 FairRunSim* run = FairRunSim::Instance();
789 map<TString, FairIon*>::iterator mapIt;
790 for (mapIt = fIonMap.begin(); mapIt != fIonMap.end(); ++mapIt) {
791 FairIon* ion = (*mapIt).second;
792 run->AddNewIon(ion);
793 }
794
795 return nIons;
796}
797
798// ------------------------------------------------------------------------
799
801 Int_t strange,
802 Int_t lepton,
803 Int_t A,
804 Float_t mass,
805 Int_t& PDG,
806 char name[11])
807{
808 Int_t n_mass, result = 0;
809
810 // AZ if (mass < 6) { // use table
811 if (strange || Z <= 2) { // use table
812
813 Int_t l_min = -1, // line number first
814 l_max = -1; // line number last
815
816 n_mass = (Int_t)(mass / 0.1);
817
818 switch (n_mass) {
819 case 1:
820 l_min = 8;
821 l_max = 12; // MU+,MU-,PI0,PI+,PI-
822 break;
823 case 9:
824 l_min = 28;
825 l_max = 32; // P,AP,AN,N,ETAP
826 break;
827 case 4:
828 l_min = 13;
829 l_max = 18; // K+,K-,AK0,KL,KS,K0
830 break;
831 case 18:
832 l_min = 66;
833 l_max = 66; // d
834 break;
835 case 5:
836 l_min = 19;
837 l_max = 19; // ETA
838 break;
839 case 11:
840 l_min = 34;
841 l_max = 41; // AL,L,S+,AS+,AS0,S0,AS-,S-
842 break;
843 case 28:
844 l_min = 68;
845 l_max = 69; // He3,t
846 break;
847 case 37:
848 l_min = 71;
849 l_max = 71; // He4
850 break;
851 case 13:
852 l_min = 50;
853 l_max = 59; // AXI0,XI0,AXI-,XI-,AS*0,S*0,S*+,AS*+,S*-,AS*-
854 break;
855 case 29:
856 l_min = 70;
857 l_max = 70; // H3L
858 break;
859
860 case 22:
861 if (!Z) {
862 l_min = 67;
863 l_max = 67;
864 } // LL
865 else
866 {
867 l_min = 81;
868 l_max = 81;
869 } // KsiNP
870 break;
871
872 case 39:
873 l_min = 72;
874 l_max = 73; // He4L,H4L
875 break;
876 case 48:
877 l_min = 75;
878 l_max = 75; // He5L
879 break;
880 case 16:
881 l_min = 64;
882 l_max = 65; // AOM-,OM-
883 break;
884 case 41:
885 l_min = 74;
886 l_max = 74; // H4LL
887 break;
888 case 50:
889 l_min = 76;
890 l_max = 77; // He5LL,H5LL
891 break;
892 case 59:
893 l_min = 78;
894 l_max = 78; // He6LL
895 break;
896 case 0:
897 l_min = 1;
898 l_max = 7; // GM,ANUM,ANUE,NUE,NUM,E+,E-
899 break;
900 case 7:
901 l_min = 20;
902 l_max = 23; // RHO+,RHO-,RHO0,OMEG
903 break;
904 case 8:
905 l_min = 24;
906 l_max = 27; // K*+,K*-,AK*0,K*0
907 break;
908 case 10:
909 l_min = 33;
910 l_max = 33; // PHI
911 break;
912 case 12:
913 l_min = 42;
914 l_max = 49; // DL++,ADL++,DL+,DL-,ADL0,DL0,ADL-,ADL+
915 break;
916 case 15:
917 l_min = 60;
918 l_max = 63; // AXI*0,XI*0,AXI*-,XI*-
919 break;
920 case 20:
921 l_min = 79;
922 l_max = 80; // LN, LP
923 break;
924 case 24:
925 l_min = 82;
926 l_max = 83; // KsiL0, KsiL1
927 break;
928 case 26:
929 l_min = 84;
930 l_max = 84; // KsiKsi
931 break;
932 default: // unknown particle
933 break;
934 }
935
936 if (l_min > 0) {
937 for (int i = l_min - 1; i < l_max; i++) {
938 /*AZ
939 if (Z!=la_tab[i].Z) continue;
940 if (strange!=la_tab[i].strange) continue;
941 if (lepton!=la_tab[i].lepton) continue;
942 if (A!=la_tab[i].A) continue;
943 if (mass<(la_tab[i].mass*0.99)) continue;
944 if (mass>(la_tab[i].mass*1.01)) continue;
945 PDG=la_tab[i].pdg;
946 strncpy(name,la_tab[i].name,10);
947 */
948 if (Z != fLa_tab[i]->Z)
949 continue;
950 if (strange != fLa_tab[i]->strange)
951 continue;
952 if (lepton != fLa_tab[i]->lepton)
953 continue;
954 if (A != fLa_tab[i]->A)
955 continue;
956 if (mass < (fLa_tab[i]->mass * 0.99))
957 continue;
958 if (mass > (fLa_tab[i]->mass * 1.01))
959 continue;
960 PDG = fLa_tab[i]->pdg;
961 strncpy(name, fLa_tab[i]->name, 10);
962 result = 1;
963 break;
964 }
965 }
966
967 } else { // must be ion
968
969 if (A > 1) {
970 PDG = CreatePdgCode(Z, A, strange, 0); // 1); // MG
971 sprintf(name, "Ion_%d_%d", A, Z);
972 result = 1;
973 }
974 }
975 return (result);
976}
977
978// ------------------------------------------------------------------------
979
980Bool_t MpdLAQGSMGenerator::CreateNucleus(Int_t Z, Float_t mass, Int_t pdgCode, char pdgName[11])
981{
982
983 // const Double_t kAu2Gev=0.9314943228; // constants from TGeant3::AddParticlesToPdgDataBase code
984 const Double_t khSlash = 1.0545726663e-27; // constants from TGeant3::AddParticlesToPdgDataBase code
985 const Double_t kErg2Gev = 1 / 1.6021773349e-3;
986 const Double_t khShGev = khSlash * kErg2Gev;
987 const Double_t kYear2Sec = 3600 * 24 * 365.25;
988
989 Double_t width = khShGev / (12.33 * kYear2Sec); // ? EL
990
991 cout << "-I- MpdLAQGSMGenerator::CreateNucleus " << pdgName << " " << pdgCode << endl;
992
993 TParticlePDG* p = 0;
994
995 if (Z)
996 p = fPDG->AddParticle(pdgName, pdgName, mass, kFALSE, width, Z * 3, "nucleus", pdgCode, 0, kPTHadron);
997 else
998 p = fPDG->AddParticle(pdgName, pdgName, mass, kFALSE, 6.58211889e-25 / 2.6e-10, 0,
999 // "special",pdgCode,0,kPTHadron);
1000 "special", pdgCode, 0, kPTNeutron); // AZ!!!
1001
1002 if (p)
1003 p->Print();
1004
1005 return (p);
1006}
1007// ------------------------------------------------------------------------
const Double_t kNeutronMass
const Double_t kProtonMass
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
int i
Definition P4_F32vec4.h:22
Bool_t SkipEvents(Int_t nSkip)
Int_t CreatePdgCode(Int_t Z, Int_t A, Int_t Strange, Int_t user=0)
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Double_t fX
0: ascii input, 1: gzipped input
Bool_t CreateNucleus(Int_t Z, Float_t mass, Int_t pdgCode, char pdgName[11])
Int_t fQGSM_format_ID
PDG database.
Int_t RegisterIons(Int_t Max_Event_Number=0)
virtual Bool_t Init()
Bool_t FindParticle(Int_t Z, Int_t strange, Int_t lepton, Int_t A, Float_t mass, Int_t &PDG, char name[11])
void InitGenerator(const char *light_particles_filename)
Bool_t general_feof(void *p)
gzFile fGZInputFile
Input file.
const Char_t * fFileName
GZ Input file.
std::vector< la_tab_t * > fLa_tab
std::map< TString, FairIon * > fIonMap
Bool_t fGZ_input
list of light particles known for MpdLAQGSMGenerator
virtual Bool_t GetEventHeader(char *ss)
TDatabasePDG * fPDG
Input file Name.
Bool_t general_fgets(char *ss, Int_t nn=250, FILE *p=0)
-clang-format