forked from Leo-Leonis/tesitriennale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main142.cpp
870 lines (780 loc) · 33 KB
/
main142.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
#include "Pythia8/Pythia.h"
// #include "Pythia8Plugins/ProgressLog.h"
#include "TCanvas.h"
#include "TDirectory.h"
#include "TFile.h"
#include "TH1D.h"
#include "TLatex.h" //
#include "TMarker.h" //
#include "TMath.h"
#include "TPave.h" //
#include "TRandom3.h"
#include "TStopwatch.h"
#include "TString.h"
#include "TStyle.h"
#include "TSystem.h"
#include <algorithm>
#include <cassert>
#include <iomanip>
// ritorna la stringa del tempo da secondi al formato h,m,s
std::string formatHMSTime(double seconds) {
int const h = static_cast<int>(seconds) / 3600; // ore rimaste
int const m = (static_cast<int>(seconds) % 3600) / 60; // min rimasti
int const s = static_cast<int>(seconds) % 60; // secondi rimasti
std::ostringstream timeStream; // elemento ostringstream da costruire
timeStream << std::setw(2) << std::setfill('0') << h << "h" << std::setw(2)
<< std::setfill('0') << m << "m" << std::setw(2)
<< std::setfill('0') << s << "s";
return timeStream.str();
}
// mostra una barra di progressione
void showProgressBar(int progress, int total, double elapsed_time) {
int const barWidth = 40; // Larghezza in pixel della barra di progresso
float const progressPercentage = (float)progress / total;
std::cout << "\033[33m[";
for (int i = 0; i < barWidth; ++i) {
if (i < barWidth * progressPercentage)
std::cout << "#";
else
std::cout << " ";
}
// tempo totale stimato
double const estimated_total_time = (elapsed_time / progress) * total;
std::cout
<< "] " << int(progressPercentage * 100.0) << "% (" << progress
<< " ev., required: " << formatHMSTime(estimated_total_time)
<< ", remaining: " << formatHMSTime(estimated_total_time - elapsed_time)
<< ")"
<< "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
"\033[0m";
std::cout.flush(); // Assicura che la barra venga aggiornata immediatamente
}
int main142(const int nevs = 1e4,
const bool Dprod = 1,
const int seed = 10,
const int runMode = 0) {
if (nevs == 0) {
return 0;
}
gSystem->Exec("date > started");
gStyle->SetOptStat(2200);
// gStyle->SetOptFit(1111);
Int_t n_bins_pp = 68; // il numero dei bin per istogrammi di protoni
Int_t n_bins_DD = 47; // il numero dei bin per deuteroni
// il numero dei bin deve essere calcolato contando il numero dei limiti dei
// bin sottraendo 1, quindi se ci sono 40 bin allora quello che si deve fare è
// mettere nbin = #valori - 1
// binnaggio pazzo del cern per istogrammi di protoni
Double_t bin_edges_pp[] = {
0.005, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.09, 0.11, 0.13, 0.15,
0.175, 0.20, 0.225, 0.25, 0.275, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6,
0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4,
1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.2,
3.4, 3.6, 3.8, 4, 4.5, 5, 5.5, 6, 6.5, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 18, 20};
// binnaggio pazzo del cern per istogrammi di deuteroni
Double_t bin_edges_DD[] = {
0.005, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.09, 0.11, 0.13, 0.15,
0.175, 0.20, 0.225, 0.25, 0.275, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6,
0.65, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.4, 1.6, 1.8, 2, 2.2,
2.6, 3, 3.4, 3.8, 4, 4.5, 5, 5.5, 6, 6.5, 7, 8};
TH1D *h_pt_proton = new TH1D(
"h_pt_proton",
"Proton #it{p}_{t} distribution;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_pp, bin_edges_pp);
TH1D *h_pt_antiproton = new TH1D(
"h_pt_antiproton",
"Antiproton #it{p}_{t} distribution;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_pp, bin_edges_pp);
TH1D *h_pt_tot_pp = new TH1D(
"h_pt_tot_pp",
"p+#bar{p} #it{p}_{t} distribution;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_pp, bin_edges_pp);
TH1D *h_pt_deuteron = new TH1D(
"h_pt_deuteron",
"Deuteron #it{p}_{t} distribution;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
TH1D *h_pt_antideuteron = new TH1D(
"h_pt_antideuteron",
"Antideuteron #it{p}_{t} distribution;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
TH1D *h_pt_tot_DD = new TH1D(
"h_pt_tot_DD",
"D+#bar{D} #it{p}_{t} distribution;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
std::vector<TH1D *> h_main_vector;
h_main_vector.push_back(h_pt_proton);
h_main_vector.push_back(h_pt_antiproton);
h_main_vector.push_back(h_pt_tot_pp);
h_main_vector.push_back(h_pt_deuteron);
h_main_vector.push_back(h_pt_antideuteron);
h_main_vector.push_back(h_pt_tot_DD);
/////////////////////////////////////////////////////////////////////////////
// distribuzione di D prodotti da p+n________________________________________
TH1D *h_pt_deuteron_in_p_n = new TH1D(
"h_pt_deuteron_in_p_n",
"Deuteron #it{p}_{t} distribution from p+n;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da p+n a g+D
TH1D *h_pt_deuteron_out_g_D = new TH1D(
"h_pt_deuteron_out_g_D",
"D #it{p}_{t} distribution from p+n to #gamma+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da p+n a pi0+D
TH1D *h_pt_deuteron_out_pi0_D = new TH1D(
"h_pt_deuteron_out_pi0_D",
"D #it{p}_{t} distribution from p+n to #pi^{0}+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da p+n a piP+piM+D
TH1D *h_pt_deuteron_out_piP_piM_D = new TH1D(
"h_pt_deuteron_out_piP_piM_D",
"D #it{p}_{t} distribution from p+n to #pi^{+}+#pi^{-}+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da p+n a pi0+pi0+D
TH1D *h_pt_deuteron_out_pi0_pi0_D = new TH1D(
"h_pt_deuteron_out_pi0_pi0_D",
"D #it{p}_{t} distribution from p+n to #pi^{0}+#pi^{0}+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
std::vector<TH1D *> h_vector_deuteron;
h_vector_deuteron.push_back(h_pt_deuteron_in_p_n);
h_vector_deuteron.push_back(h_pt_deuteron_out_g_D);
h_vector_deuteron.push_back(h_pt_deuteron_out_pi0_D);
h_vector_deuteron.push_back(h_pt_deuteron_out_piP_piM_D);
h_vector_deuteron.push_back(h_pt_deuteron_out_pi0_pi0_D);
// distribuzione di D prodotti da p+p________________________________________
TH1D *h_pt_deuteron_in_p_p = new TH1D(
"h_pt_deuteron_in_p_p",
"Deuteron #it{p}_{t} distribution from p+p;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da p+p a piP+D
TH1D *h_pt_deuteron_out_piP_D = new TH1D(
"h_pt_deuteron_out_piP_D",
"D #it{p}_{t} distribution from p+p to #pi^{+}+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da p+p a piP+pi0+D
TH1D *h_pt_deuteron_out_piP_pi0_D = new TH1D(
"h_pt_deuteron_out_piP_pi0_D",
"D #it{p}_{t} distribution from p+p to #pi^{+}+#pi^{0}+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
h_vector_deuteron.push_back(h_pt_deuteron_in_p_p);
h_vector_deuteron.push_back(h_pt_deuteron_out_piP_D);
h_vector_deuteron.push_back(h_pt_deuteron_out_piP_pi0_D);
// distribuzione di D prodotti da n+n________________________________________
TH1D *h_pt_deuteron_in_n_n = new TH1D(
"h_pt_deuteron_in_n_n",
"Deuteron #it{p}_{t} distribution from n+n;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da n+n a piM+D
TH1D *h_pt_deuteron_out_piM_D = new TH1D(
"h_pt_deuteron_out_piM_D",
"D #it{p}_{t} distribution from p+p to #pi^{-}+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D prodotti da n+n a piM+pi0+D
TH1D *h_pt_deuteron_out_piM_pi0_D = new TH1D(
"h_pt_deuteron_out_piM_pi0_D",
"D #it{p}_{t} distribution from p+p to #pi^{-}+#pi^{0}+D;Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
h_vector_deuteron.push_back(h_pt_deuteron_in_n_n);
h_vector_deuteron.push_back(h_pt_deuteron_out_piM_D);
h_vector_deuteron.push_back(h_pt_deuteron_out_piM_pi0_D);
///////////////////////////////////////////////////////////////////////////////
// distribuzione di D- prodotti da p+n________________________________________
TH1D *h_pt_antideuteron_in_p_n = new TH1D(
"h_pt_antideuteron_in_p_n",
"Antideuteron #it{p}_{t} distribution from #bar{p}+#bar{n};Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da p+n a g+D-
TH1D *h_pt_antideuteron_out_g_D = new TH1D(
"h_pt_antideuteron_out_g_D",
"#bar{D} #it{p}_{t} distribution from #bar{p}+#bar{n} to "
"#gamma+#bar{D};Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da p+n a pi0+D-
TH1D *h_pt_antideuteron_out_pi0_D = new TH1D(
"h_pt_antideuteron_out_pi0_D",
"#bar{D} #it{p}_{t} distribution from #bar{p}+#bar{n} to "
"#pi^{0}+#bar{D};Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da p+n a piP+piM+D-
TH1D *h_pt_antideuteron_out_piP_piM_D = new TH1D(
"h_pt_antideuteron_out_piP_piM_D",
"#bar{D} #it{p}_{t} distribution from #bar{p}+#bar{n} to "
"#pi^{+}+#pi^{-}+#bar{D};Transverse momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da p+n a pi0+pi0+D-
TH1D *h_pt_antideuteron_out_pi0_pi0_D = new TH1D(
"h_pt_antideuteron_out_pi0_pi0_D",
"#bar{D} #it{p}_{t} distribution from #bar{p}+#bar{n} to "
"#pi^{0}+#pi^{0}+#bar{D};Transverse momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
std::vector<TH1D *> h_vector_antideuteron;
h_vector_antideuteron.push_back(h_pt_antideuteron_in_p_n);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_g_D);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_pi0_D);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_piP_piM_D);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_pi0_pi0_D);
// distribuzione di D- prodotti da p+p________________________________________
TH1D *h_pt_antideuteron_in_p_p = new TH1D(
"h_pt_antideuteron_in_p_p",
"Antideuteron #it{p}_{t} distribution from #bar{p}+#bar{p};Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da p+p a piM+D-
TH1D *h_pt_antideuteron_out_piM_D =
new TH1D("h_pt_antideuteron_out_piM_D",
"#bar{D} #it{p}_{t} distribution from #bar{p}+#bar{p} to "
"#pi^{-}+#bar{D};#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#"
"it{p}_{t}d#it{y}} "
"[(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da p+p a piM+pi0+D-
TH1D *h_pt_antideuteron_out_pi0_piM_D =
new TH1D("h_pt_antideuteron_out_pi0_piM_D",
"#bar{D} #it{p}_{t} distribution from #bar{p}+#bar{p} to "
"#pi^{-}+#pi^{0}+#bar{D};Transverse momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#"
"it{p}_{t}d#it{y}} [(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
h_vector_antideuteron.push_back(h_pt_antideuteron_in_p_p);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_piM_D);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_pi0_piM_D);
// distribuzione di D- prodotti da n+n________________________________________
TH1D *h_pt_antideuteron_in_n_n = new TH1D(
"h_pt_antideuteron_in_n_n",
"Antideuteron #it{p}_{t} distribution from #bar{n}+#bar{n};Transverse "
"momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#"
"it{p}_{t}d#it{y}} [(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da n+n a piP+D-
TH1D *h_pt_antideuteron_out_piP_D =
new TH1D("h_pt_antideuteron_out_piP_D",
"#bar{D} #it{p}_{t} distribution from #bar{n}+#bar{n} to "
"#pi^{+}+#bar{D};Transverse momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#"
"it{p}_{t}d#it{y}} [(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
//// distribuzione di D- prodotti da n+n a piP+pi0+D-
TH1D *h_pt_antideuteron_out_piP_pi0_D =
new TH1D("h_pt_antideuteron_out_piP_pi0_D",
"#bar{D} #it{p}_{t} distribution from #bar{n}+#bar{n} to "
"#pi^{+}+#pi^{0}+#bar{D};Transverse momentum #it{p}_{t} "
"[GeV/c];#frac{1}{#it{N}_{events}}#frac{d^{2}#it{N}}{d#"
"it{p}_{t}d#it{y}} [(GeV/c)^{-1}];",
n_bins_DD, bin_edges_DD);
h_vector_antideuteron.push_back(h_pt_antideuteron_in_n_n);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_piP_D);
h_vector_antideuteron.push_back(h_pt_antideuteron_out_piP_pi0_D);
// cronometro per monitorare il tempo rimanente
TStopwatch stopwatch;
stopwatch.Start(); // fai partire il cronometro
// Inizializzazione impostazioni di pythia
Pythia8::Pythia pythia;
pythia.readString("Beams:eCM = 13000.");
pythia.readString("Beams:idA = 2212");
pythia.readString("Beams:idB = 2212");
pythia.readString("Beams:frameType = 1");
pythia.readString("Random:setSeed = on");
pythia.readString(Form("Random:seed = %i", seed));
pythia.readString("Next:numberCount = 0"); // numero dei conti disattivato
pythia.readString("PartonVertex:setVertex = on");
pythia.readString("Fragmentation:setVertices = on");
pythia.readString("Tune:pp = 4");
pythia.readString("HardQCD:all = off");
pythia.readString("LowEnergyQCD:all = off");
pythia.readString("SoftQCD:inelastic = on");
TString outTag = "";
if (Dprod == true) {
pythia.readString("HadronLevel:DeuteronProduction = on");
// norm = 1000 / (3.179165 * value_from_table)
switch (runMode)
{
case 0:
// norm default = 119.6 [A]
outTag = "_modeA";
pythia.readString("DeuteronProduction:norm = 119.6");
break;
case 1:
// norm deuterone = 183.5597586 [B]
pythia.readString("DeuteronProduction:norm = 183.5597586");
outTag = "_modeB";
break;
case 2:
// (norm antideut = 200.51252128 [C])
pythia.readString("DeuteronProduction:norm = 200.51252128");
outTag = "_modeC";
break;
case 3:
// norm fit di [A,B] = 137.26665 [D] <- migliore
pythia.readString("DeuteronProduction:norm = 137.26665");
outTag = "_modeD";
break;
case 4:
// norm coalescenza = 1 [E] mod coalescenza
// modello di coalescenza prevede solo capture radiattiva
// normalizzazione = 1 perché vogliamo essere certi che verrà prodotta il
// deuterone
outTag = "_modeE";
pythia.readString("DeuteronProduction:norm = 1");
pythia.readString(
"DeuteronProduction:channels = {2212 2112 > 22}"); // solo capture
// radiattiva
pythia.readString(
"DeuteronProduction:models = {0}"); // modifica del primo canale
// di produzione (a coal.)
pythia.readString(
"DeuteronProduction:parms = {0.195 1}"); // modifica del param del primo
// canale di produzione
outTag = "_modeE";
break;
case 5:
// norm fit 1/x = 133.581 [F]
pythia.readString("DeuteronProduction:norm = 133.581");
outTag = "_modeF";
break;
default:
pythia.readString("DeuteronProduction:norm = 137.26665");
outTag = "_modeStd";
break;
}
} else {
outTag = "_modeNoDeuteron";
pythia.readString("HadronLevel:DeuteronProduction = off");
}
// se Pythia si rompe, uccidi il programma.
if (!pythia.init())
return 1;
auto &event = pythia.event;
// array per contenere le pdg codes delle particelle prodotte da una rezione
// con D
std::array<int, 3> PDGarray;
double elapsed_time; // Tempo reale trascorso
double estimated_total_time; // Stima del tempo totale
double remaining_time; // Stima del tempo rimanente
elapsed_time = stopwatch.RealTime();
std::cout << "\033[1;31mLEO_INFO: Init time: " << formatHMSTime(elapsed_time)
<< "\033[0m";
stopwatch.Reset(); // riprendi il cronometro
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////PER OGNI EVENTO///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
for (int iEvent = 0; iEvent < nevs; ++iEvent) {
if (!pythia.next()) // se il evento generato va a male skippa al prossimo
// evento
continue;
//__________________________________________________________________________
//___________________per ogni particelle dell'evento________________________
//__________________________________________________________________________
for (int iParticle = 0; iParticle < event.size();
++iParticle) { // per ogni particella dell'evento
// la particella i-esima dell'evento del loop
auto &p = event[iParticle];
if (std::abs(p.y()) > 0.5) // se la rapidità di p è maggiore di 0.5 skippa
// questa particella
continue;
if (!p.isFinal()) // skippa se la particella non è finale
continue;
// momento trasverso della particella corrente
const float pt = std::sqrt(p.px() * p.px() + p.py() * p.py());
// Qui riempiamo i nostri istogrammi per protoni, antiprotoni e deutoni e
// antideutoni
switch (p.id()) {
case 2212: // p+
h_pt_proton->Fill(pt);
break;
case -2212: // p-
h_pt_antiproton->Fill(pt);
break;
case 1000010020: // deuterone
{
PDGarray = {300, 300,
300}; // reset dell'array (300 perché non lo faccio
// corrispondere a nessuna particella)
h_pt_deuteron->Fill(pt);
const auto &mother1 = event[p.mother1()];
const int mom1id = mother1.id(); // pdg della mother1
const auto &mother2 = event[p.mother2()];
const int mom2id = mother2.id(); // pdg della mother2
// vettore degli indici delle particelle figlie
const auto &daughterlist = mother1.daughterList();
const int size = daughterlist.size();
// fill in reactions
if (mom1id == 2212 && mom2id == 2212) {
h_pt_deuteron_in_p_p->Fill(pt);
} else if (mom1id == 2112 && mom2id == 2112) {
h_pt_deuteron_in_n_n->Fill(pt);
} else if ((mom1id == 2212 && mom2id == 2112) ||
(mom1id == 2112 && mom2id == 2212)) {
h_pt_deuteron_in_p_n->Fill(pt);
} else {
std::cout << "\033[1;31mLEO_WARNING\033[0m: couldn't identify the "
"mothers! (event: "
<< iEvent << ")" << '\n';
}
if (size == 2 || size == 3) {
for (int ip = 0; ip < size; ip++) {
PDGarray[ip] = (event[daughterlist[ip]]).id();
}
std::sort(PDGarray.begin(), PDGarray.end()); // riordina l'array
} else {
std::cout << "\033[1;31mLEO_WARNING\033[0m: Daughter list size was "
"neither 2 or 3 (event: "
<< iEvent << ", PDGarray: (" << PDGarray[0] << ','
<< PDGarray[1] << ',' << PDGarray[2] << "))\n";
return 0;
}
if (PDGarray[2] == 1000010020) {
// fill out reactions
switch (PDGarray[0]) {
// g + ... + D
case 22:
switch (PDGarray[1]) {
// g + D
case 300:
h_pt_deuteron_out_g_D->Fill(pt); // g + D
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
// piP + ... + D
case 211:
switch (PDGarray[1]) {
case 300:
h_pt_deuteron_out_piP_D->Fill(pt); // piP + D
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
// pi0 + ... + D
case 111:
switch (PDGarray[1]) {
// pi0 + D
case 300:
h_pt_deuteron_out_pi0_D->Fill(pt);
break;
// pi0 + pi0 + D
case 111:
h_pt_deuteron_out_pi0_pi0_D->Fill(pt);
break;
// pi0 + piP + D
case 211:
h_pt_deuteron_out_piP_pi0_D->Fill(pt);
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
// piM + ... + D
case -211:
switch (PDGarray[1]) {
// piM + D
case 300:
h_pt_deuteron_out_piM_D->Fill(pt);
break;
// piM + piP + D
case 211:
h_pt_deuteron_out_piP_piM_D->Fill(pt);
break;
// piM + pi0 + D
case 111:
h_pt_deuteron_out_piM_pi0_D->Fill(pt);
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 1 ("
<< PDGarray[0]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ',' << PDGarray[2]
<< "))\n";
break;
}
} else {
std::cout << "\033[1;31m\033[1;31mLEO_WARNING\033[0m\033[0m: "
"daughter n. 3 is not an expected result "
"(expected: 1000010020, result: ("
<< PDGarray[0] << ',' << PDGarray[1] << ',' << PDGarray[2]
<< "))\n";
return 0;
}
} break; // fine deuterone
case -1000010020: // antideuterone
{
h_pt_antideuteron->Fill(pt);
PDGarray = {-300, -300,
-300}; // reset dell'array (-300 perché non lo faccio
// corrispondere a nessuna particella)
const auto &mother1 = event[p.mother1()];
const int mom1id = mother1.id(); // pdg della mother1
const auto &mother2 = event[p.mother2()];
const int mom2id = mother2.id(); // pdg della mother2
// vettore degli indici delle particelle figlie
const auto &daughterlist = mother1.daughterList();
const int size = daughterlist.size();
// fill in reactions
if (mom1id == -2212 && mom2id == -2212) {
h_pt_antideuteron_in_p_p->Fill(pt);
} else if (mom1id == -2112 && mom2id == -2112) {
h_pt_antideuteron_in_n_n->Fill(pt);
} else if ((mom1id == -2212 && mom2id == -2112) ||
(mom1id == -2112 && mom2id == -2212)) {
h_pt_antideuteron_in_p_n->Fill(pt);
} else {
std::cout << "\033[1;31mLEO_WARNING\033[0m: couldn't identify the "
"mothers! (event: "
<< iEvent << ")" << '\n';
}
if (size == 2 || size == 3) {
for (int ip = 0; ip < size; ip++) {
PDGarray[ip] = (event[daughterlist[ip]]).id();
}
std::sort(PDGarray.begin(), PDGarray.end()); // riordina l'array
} else {
std::cout << "\033[1;31mLEO_WARNING\033[0m: Daughter list size was "
"neither 2 or 3 (event: "
<< iEvent << ", PDGarray: (" << PDGarray[0] << ','
<< PDGarray[1] << ',' << PDGarray[2] << "))\n";
return 0;
}
if (PDGarray[0] == -1000010020) {
// fill out reactions
switch (PDGarray[2]) {
// g + ... + D-
case 22:
switch (PDGarray[1]) {
// g + D-
case -300:
h_pt_antideuteron_out_g_D->Fill(pt); // g + D
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
// piM + ... + D-
case -211:
switch (PDGarray[1]) {
case -300: // piM + D-
h_pt_antideuteron_out_piM_D->Fill(pt);
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
// pi0 + ... + D-
case 111:
switch (PDGarray[1]) {
// pi0 + D-
case -300:
h_pt_antideuteron_out_pi0_D->Fill(pt);
break;
// pi0 + pi0 + D-
case 111:
h_pt_antideuteron_out_pi0_pi0_D->Fill(pt);
break;
// pi0 + piM + D-
case -211:
h_pt_antideuteron_out_pi0_piM_D->Fill(pt);
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
// piP + ... + D-
case 211:
switch (PDGarray[1]) {
// piP + D-
case -300:
h_pt_antideuteron_out_piP_D->Fill(pt);
break;
// piP + piM + D-
case -211:
h_pt_antideuteron_out_piP_piM_D->Fill(pt);
break;
// piP + pi0 + D-
case 111:
h_pt_antideuteron_out_piP_pi0_D->Fill(pt);
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 2 ("
<< PDGarray[1]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ','
<< PDGarray[2] << "))\n";
break;
}
break;
default:
std::cout << "\033[1;31mLEO_WARNING\033[0m: daughter n. 3 ("
<< PDGarray[2]
<< ") is not an expected result (PDGarray: ("
<< PDGarray[0] << ',' << PDGarray[1] << ',' << PDGarray[2]
<< "))\n";
break;
}
} else {
std::cout << "\033[1;31mLEO_WARNING\033[0m: "
"daughter n. 1 is not an expected result "
"(expected: -1000010020, result: ("
<< PDGarray[0] << ',' << PDGarray[1] << ',' << PDGarray[2]
<< "))\n";
return 0;
}
} // fine antideuterone
break;
}
}
if (iEvent % 100 == 0) {
elapsed_time = stopwatch.RealTime();
stopwatch.Continue(); // riprendi il cronometro
showProgressBar(iEvent, nevs,
elapsed_time); // mostra la barra di progressione
}
} // fine simulazione
// riempimento istogrammi totali dei protoni e dei deuteroni
h_pt_tot_pp->Add(h_pt_proton, h_pt_antiproton, 1, 1);
h_pt_tot_DD->Add(h_pt_deuteron, h_pt_antideuteron, 1, 1);
// lambda da applicare a tutti gli istogrammi
auto action_hist_lambda = [nevs](TH1D *hist) {
if (hist) {
// riscalaggio grafici
// hist->Scale(1. / nevs, "width");
// salvataggio grafici
hist->Write();
}
};
// file di output
TFile *resultfile = new TFile("main142"+outTag+".root", "RECREATE");
// sotto directory
TDirectory *p_D_dir = resultfile->mkdir("p_D_production");
TDirectory *deuteron_dir = resultfile->mkdir("deuteron");
TDirectory *antideuteron_dir = resultfile->mkdir("antideuteron");
TH1F *hevents = new TH1F("hevents", "hevents", 1, 0, 1);
hevents->SetBinContent(1, nevs);
hevents->Write();
gDirectory->cd("p_D_production");
// riscala e salva gli istogrammi
std::for_each(h_main_vector.begin(), h_main_vector.end(), action_hist_lambda);
gDirectory->cd("..");
// vai nella cartella deuteron
gDirectory->cd("deuteron");
std::for_each(h_vector_deuteron.begin(), h_vector_deuteron.end(),
action_hist_lambda);
gDirectory->cd("..");
// vai nella cartella antideuteron
gDirectory->cd("antideuteron");
std::for_each(h_vector_antideuteron.begin(), h_vector_antideuteron.end(),
action_hist_lambda);
gDirectory->cd("..");
resultfile->Close(); // chiusura file
return 0;
}