14 #include "CbmRichUtil.h"
17 #include "FairRootManager.h"
29 , fRichRingMatches(NULL)
32 , fStsTrackMatches(NULL)
35 , fHistoList_richrings()
37 , fRichRings_nofRings(NULL)
38 , fRichRings_motherpdg(NULL)
39 , fRichRings_richpdg(NULL)
40 , fRichRings_electronspE(NULL)
41 , fRichRings_sourcePI0(NULL)
42 , fRichRings_test(NULL)
43 , fRichRings_detectedParticles(NULL)
44 , fRichRings_detParticlesMother(NULL)
45 , fRichRings_Aaxis(NULL)
46 , fRichRings_Aaxis_part1(NULL)
47 , fRichRings_Aaxis_part2(NULL)
48 , fRichRings_Aaxis_part3(NULL)
49 , fRichRings_Aaxis_electrons(NULL)
50 , fRichRings_Baxis(NULL)
51 , fRichRings_Baxis_part1(NULL)
52 , fRichRings_Baxis_part2(NULL)
53 , fRichRings_Baxis_part3(NULL)
54 , fRichRings_Baxis_electrons(NULL)
55 , fRichRings_radius(NULL)
56 , fRichRings_radius_electrons(NULL)
57 , fRichRings_radius_vs_momentum(NULL)
58 , fRichRings_radius_vs_pt(NULL)
59 , fRichRings_distance(NULL)
60 , fRichRings_distance_electrons(NULL)
62 , fhRichRings_AaxisVSmom(NULL)
63 , fhRichRings_BaxisVSmom(NULL)
64 , fhRichRings_test1(NULL)
65 , fhRichRings_test2(NULL)
66 , fhRichRings_test3(NULL)
67 , fhRichRings_test4(NULL)
68 , fhRichRings_test5(NULL)
69 , fhRichRings_test6(NULL)
70 , fhRichRings_pos(NULL)
71 , fhRichRings_protons(NULL)
72 , fhRichRings_protons2(NULL)
73 , fhRichRings_start(NULL)
81 FairRootManager* ioman = FairRootManager::Instance();
83 Fatal(
"CbmAnaConversion::Init",
"RootManager not instantised!");
86 fRichPoints = (TClonesArray*) ioman->GetObject(
"RichPoint");
88 Fatal(
"CbmAnaConversion::Init",
"No RichPoint array!");
91 fMcTracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
93 Fatal(
"CbmAnaConversion::Init",
"No MCTrack array!");
96 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
98 Fatal(
"CbmAnaConversion::Init",
"No StsTrack array!");
103 Fatal(
"CbmAnaConversion::Init",
"No StsTrackMatch array!");
106 fGlobalTracks = (TClonesArray*) ioman->GetObject(
"GlobalTrack");
108 Fatal(
"CbmAnaConversion::Init",
"No GlobalTrack array!");
118 if (
nullptr ==
fPrimVertex) { LOG(fatal) <<
"No PrimaryVertex array!"; }
120 fRichRings = (TClonesArray*) ioman->GetObject(
"RichRing");
122 Fatal(
"CbmAnaConversion::Init",
"No RichRing array!");
127 Fatal(
"CbmAnaConversion::Init",
"No RichRingMatch array!");
137 fTest =
new TH2D(
"fTest",
"fTest; X; Y", 200, -100, 100, 400, -200, 200);
144 "fRichRings_nofRings;nof rings per Event;#",
149 "fRichRings_motherpdg;pdg code;#",
154 "fRichRings_richpdg",
"fRichRings_richpdg;pdg code;#", 5001, -0.5, 5000.5);
156 new TH1D(
"fRichRings_electronspE",
157 "fRichRings_electronspE;nof electrons per event;#",
162 new TH1D(
"fRichRings_sourcePI0",
163 "fRichRings_sourcePI0;nof electrons from pi0;#",
168 "fRichRings_test;nof electrons from pi0;#",
180 "fRichRings_detectedParticles;;#",
189 2,
"\\mu^{+}/\\mu^{-}");
191 3,
"\\pi^{+}/\\pi^{-}");
206 "fRichRings_detParticlesMother;;#",
215 2,
"\\mu^{+}/\\mu^{-}");
223 6,
"\\pi^{+}/\\pi^{-}");
264 new TH1D(
"fRichRings_Aaxis",
"fRichRings_Aaxis;A-axis;#", 300, 0., 30.);
266 "fRichRings_Aaxis_part1",
"fRichRings_Aaxis_part1;A-axis;#", 300, 0., 30.);
268 "fRichRings_Aaxis_part2",
"fRichRings_Aaxis_part2;A-axis;#", 300, 0., 30.);
270 "fRichRings_Aaxis_part3",
"fRichRings_Aaxis_part3;A-axis;#", 300, 0., 30.);
272 "fRichRings_Aaxis_electrons;A-axis;#",
277 new TH1D(
"fRichRings_Baxis",
"fRichRings_Baxis;B-axis;#", 300, 0., 30.);
279 "fRichRings_Baxis_part1",
"fRichRings_Baxis_part1;B-axis;#", 300, 0., 30.);
281 "fRichRings_Baxis_part2",
"fRichRings_Baxis_part2;B-axis;#", 300, 0., 30.);
283 "fRichRings_Baxis_part3",
"fRichRings_Baxis_part3;B-axis;#", 300, 0., 30.);
285 "fRichRings_Baxis_electrons;B-axis;#",
290 new TH1D(
"fRichRings_radius",
"fRichRings_radius;radius;#", 300, 0., 30.);
292 "fRichRings_radius_electrons;radius;#",
297 new TH2D(
"fRichRings_radius_vs_momentum",
298 "fRichRings_radius_vs_momentum;momentum;radius",
306 "fRichRings_radius_vs_pt;pt;radius",
314 "fRichRings_distance",
"fRichRings_distance;distance;#", 500, 0., 5.);
316 new TH1D(
"fRichRings_distance_electrons",
317 "fRichRings_distance_electrons;distance;#",
322 "fhRingtest;momentum [GeV/c];radius [cm]",
330 new TH2D(
"fhRichRings_AaxisVSmom",
331 "fhRichRings_AaxisVSmom;momentum [GeV/c];a-axis [cm]",
339 new TH2D(
"fhRichRings_BaxisVSmom",
340 "fhRichRings_BaxisVSmom;momentum [GeV/c];b-axis [cm]",
368 new TH1D(
"fRichRings_test1",
"fRichRings_test1;A-axis;#", 300, 0., 30.);
370 new TH1D(
"fRichRings_test2",
"fRichRings_test2;A-axis;#", 300, 0., 30.);
372 new TH1D(
"fRichRings_test3",
"fRichRings_test3;A-axis;#", 300, 0., 5.);
374 new TH1D(
"fRichRings_test4",
"fRichRings_test4;A-axis;#", 300, 0., 30.);
376 new TH1D(
"fRichRings_test5",
"fRichRings_test5;A-axis;#", 300, 0., 30.);
378 new TH1D(
"fRichRings_test6",
"fRichRings_test6;A-axis;#", 300, 0., 30.);
380 "fRichRings_pos",
"fRichRings_pos;x;y", 400, -200., 200., 400, -200., 200.);
392 "fhRichRings_protons;px;py",
401 "fhRichRings_protons2",
"fhRichRings_protons2;nof hits;#", 40, -0.5, 39.5);
406 new TH1D(
"fhRichRings_start",
"fhRichRings_start;z;#", 1000, 0, 100);
413 gDirectory->mkdir(
"RichRings");
414 gDirectory->cd(
"RichRings");
418 gDirectory->cd(
"..");
420 cout <<
"CbmAnaConversionRich: Realtime - " <<
fTime << endl;
428 Int_t nofMC =
fMcTracks->GetEntriesFast();
429 cout <<
"CbmAnaConversionRich: nof mc tracks " << nofMC << endl;
433 for (
int i = 0;
i < nofPoints;
i++) {
435 if (point == NULL)
continue;
437 fTest->Fill(point->GetX(), point->GetY());
443 Int_t nofElectrons = 0;
453 Int_t nofRings =
fRichRings->GetEntriesFast();
455 for (
int i = 0;
i < nofRings;
i++) {
457 if (richRing == NULL)
continue;
467 cout <<
"CbmAnaConversionRich: nof global tracks " << nofGlobalTracks
469 for (
int iG = 0; iG < nofGlobalTracks; iG++) {
471 if (NULL == gTrack)
continue;
474 if (richInd < 0)
continue;
479 if (stsInd < 0)
continue;
481 if (stsTrack == NULL)
continue;
485 if (stsMatch == NULL)
continue;
487 if (stsMcTrackId < 0)
continue;
489 if (mcTrack1 == NULL)
continue;
493 if (richMatch == NULL)
continue;
495 if (richMcTrackId < 0)
continue;
497 if (mcTrack2 == NULL)
continue;
501 if (stsMcTrackId != richMcTrackId)
continue;
510 int pdg = TMath::Abs(
544 if (motherId != -1) {
546 motherpdg = TMath::Abs(mothermcTrack1->
GetPdgCode());
548 if (motherId == -1) {
550 if (pdg == 11) primEl++;
551 if (pdg == 13) primMu++;
552 if (pdg == 211) primPi++;
553 if (pdg == 321) primK++;
566 int grandmotherpdg = 0;
567 int grandmotherId = 0;
568 if (motherpdg == 22) {
570 if (grandmotherId != -1) {
573 grandmotherpdg = TMath::Abs(grandmothermcTrack1->
GetPdgCode());
575 if (grandmotherId == -1) { grandmotherpdg = -1; }
577 if (motherpdg == 111 || grandmotherpdg == 111) {
579 if (motherpdg == 111) {
580 pi0ids.push_back(motherId);
581 }
else if (grandmotherpdg == 111) {
582 pi0ids.push_back(grandmotherId);
592 TH1I* zwischenhisto =
593 new TH1I(
"zwischenhisto",
"zwischenhisto", 1000000, 0, 1000000);
594 for (
unsigned int i = 0;
i < pi0ids.size();
i++) {
595 zwischenhisto->Fill(pi0ids[
i]);
598 if (zwischenhisto->GetMaximum() >= 4) {
602 cout <<
"CbmAnaConversionRich: MAXIMUM BIN: "
603 << zwischenhisto->GetMaximum() <<
"\t"
604 <<
"bin id: " << zwischenhisto->GetMaximumBin() - 1 << endl;
605 cout <<
"CbmAnaConversionRich: pdg code: " << pdg << endl;
606 cout <<
"CbmAnaConversionRich: \t";
608 std::sort(pi0ids.begin(), pi0ids.end());
609 for (
unsigned int i = 0;
i < pi0ids.size();
i++) {
610 cout << pi0ids[
i] <<
"\t";
614 cout <<
"CbmAnaConversionRich: number of electrons: " << nofElectrons
615 <<
"\t e from pi0: " << sourcePI0
616 <<
"\t pi0ids size: " << pi0ids.size() << endl;
618 zwischenhisto->Delete();
621 int photoncounter = 0;
622 std::multimap<int, int> electronMap;
623 for (
unsigned int i = 0;
i < pi0ids.size();
i++) {
624 electronMap.insert(std::pair<int, int>(pi0ids[
i],
i));
628 for (std::map<int, int>::iterator it = electronMap.begin();
629 it != electronMap.end();
631 if (it == electronMap.begin()) check = 1;
632 if (it != electronMap.begin()) {
633 std::map<int, int>::iterator zwischen = it;
636 int id_old = zwischen->first;
640 cout <<
"CbmAnaConversionRich: richmap - photon found " <<
id
654 for (Int_t iGTrack = 0; iGTrack < nGTracks; iGTrack++) {
656 if (NULL == gTrack)
continue;
659 if (richInd < 0)
continue;
660 if (stsInd < 0)
continue;
665 if (richMatch == NULL)
continue;
669 if (mctrack == NULL)
continue;
673 Double_t momentum = mctrack->
GetP();
675 Double_t axisA = richRing->
GetAaxis();
676 Double_t axisB = richRing->
GetBaxis();
695 if (
sqrt(ringX * ringX + (abs(ringY) - 105) * (abs(ringY) - 105)) <= 50) {
701 if (abs(ringX) <= 30 && abs(ringY) <= 130) {
705 if (abs(ringX) > 30 && abs(ringY) > 130 && abs(ringX) <= 70
706 && abs(ringY) <= 155) {
710 if (abs(ringX) > 70 && abs(ringY) > 155) {
732 if (pdg != 11 && pdg != 13 && pdg != 211 && pdg != 321 && pdg != 2212
733 && pdg != 3112 && pdg != 3222 && pdg != 3312)
752 if (motherpdg == -1) {
759 if (pdg != 11 && pdg != 13 && pdg != 211 && pdg != 321)
772 vector<int> electronids;
777 for (
int iG = 0; iG < nofGlobalTracks; iG++) {
779 if (NULL == gTrack)
continue;
783 if (stsInd < 0)
continue;
786 if (stsTrack == NULL)
continue;
789 if (stsMatch == NULL)
continue;
792 if (stsMcTrackId < 0)
continue;
794 if (mcTrack1 == NULL)
continue;
806 int pdg = TMath::Abs(
823 int grandmotherpdg = 0;
826 int grandmotherId = 0;
828 if (motherId != -1) {
830 motherpdg = TMath::Abs(mothermcTrack1->
GetPdgCode());
831 }
else if (motherId == -1) {
836 if (motherpdg == 22) {
838 if (grandmotherId != -1) {
840 grandmotherpdg = TMath::Abs(grandmothermcTrack1->
GetPdgCode());
842 if (grandmotherId == -1) { grandmotherpdg = -1; }
845 if (motherpdg == 111) {
846 ids.push_back(motherId);
847 electronids.push_back(stsMcTrackId);
849 if (motherpdg == 22 && grandmotherpdg == 111) {
850 ids.push_back(grandmotherId);
851 electronids.push_back(stsMcTrackId);
856 cout <<
"CbmAnaConversionRich: vector ids contains " << ids.size()
857 <<
" entries." << endl;
858 cout <<
"CbmAnaConversionRich: ids entries: ";
859 for (
unsigned int i = 0;
i < ids.size();
i++) {
860 cout << ids[
i] <<
" / ";
863 cout <<
"CbmAnaConversionRich: electronids entries: ";
864 for (
unsigned int i = 0;
i < electronids.size();
i++) {
865 cout << electronids[
i] <<
" / ";
869 int photoncounter = 0;
870 std::multimap<int, int> electronMap;
871 for (
unsigned int i = 0;
i < ids.size();
i++) {
872 electronMap.insert(std::pair<int, int>(ids[
i],
i));
876 for (std::map<int, int>::iterator it = electronMap.begin();
877 it != electronMap.end();
879 if (it == electronMap.begin()) check = 1;
880 if (it != electronMap.begin()) {
881 std::map<int, int>::iterator zwischen = it;
884 int id_old = zwischen->first;
888 cout <<
"CbmAnaConversionRich: richmap - photon found " <<
id << endl;