CbmRoot
Loading...
Searching...
No Matches
CbmKresSelectGoodEvents.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Ievgenii Kres, Florian Uhlig [committer] */
4
19
20#include "CbmMCTrack.h"
21
22#include "FairRootManager.h"
23#include "FairRunSim.h"
24#include <Logger.h>
25
26#include <iostream>
27
28using namespace std;
29
30CbmKresSelectGoodEvents::CbmKresSelectGoodEvents() : FairTask(), fMcTracks(nullptr), fApp(nullptr) {}
31
33
35{
36
37 FairRunSim* sim = FairRunSim::Instance();
38 if (sim) { fApp = FairMCApplication::Instance(); }
39
40 FairRootManager* ioman = FairRootManager::Instance();
41 if (nullptr == ioman) { Fatal("CbmKresEta::Init", "RootManager not instantised!"); }
42
43 fMcTracks = (TClonesArray*) ioman->GetObject("MCTrack");
44 if (nullptr == fMcTracks) { Fatal("CbmKresSelectGoodEvents::Init", "No MCTrack array!"); }
45
46 return kSUCCESS;
47}
48
49
51{
52 Electrons.clear();
53 Int_t nofMcTracks = fMcTracks->GetEntriesFast();
54 for (int i = 0; i < nofMcTracks; i++) {
55 CbmMCTrack* mctrack = (CbmMCTrack*) fMcTracks->At(i);
56 if (mctrack == nullptr) continue;
57 if (mctrack->GetMotherId() == -1) continue;
58 CbmMCTrack* mcMotherTrack = (CbmMCTrack*) fMcTracks->At(mctrack->GetMotherId());
59 if (mcMotherTrack == nullptr) continue;
60
61 if (TMath::Abs(mctrack->GetPdgCode()) == 11 && mcMotherTrack->GetPdgCode() == 22) {
62 if (mcMotherTrack->GetMotherId() == -1) continue;
63 CbmMCTrack* mcGrTrack = (CbmMCTrack*) fMcTracks->At(mcMotherTrack->GetMotherId());
64 if (mcGrTrack == nullptr) continue;
65 if (mcGrTrack->GetPdgCode() == 221) { Electrons.push_back(mctrack); }
66 }
67 }
68
69 int EtaConversion = 0;
70 if (Electrons.size() >= 4) {
71 for (size_t i = 0; i < Electrons.size(); i++) {
72 for (size_t j = i + 1; j < Electrons.size(); j++) {
73 for (size_t k = j + 1; k < Electrons.size(); k++) {
74 for (size_t l = k + 1; l < Electrons.size(); l++) {
75
76 int pdg1 = Electrons.at(i)->GetPdgCode();
77 int pdg2 = Electrons.at(j)->GetPdgCode();
78 int pdg3 = Electrons.at(k)->GetPdgCode();
79 int pdg4 = Electrons.at(l)->GetPdgCode();
80
81 if (pdg1 + pdg2 + pdg3 + pdg4 != 0) continue;
82 if (TMath::Abs(pdg1) != 11 || TMath::Abs(pdg2) != 11 || TMath::Abs(pdg3) != 11 || TMath::Abs(pdg4) != 11)
83 continue;
84
85 int motherId1 = Electrons.at(i)->GetMotherId();
86 int motherId2 = Electrons.at(j)->GetMotherId();
87 int motherId3 = Electrons.at(k)->GetMotherId();
88 int motherId4 = Electrons.at(l)->GetMotherId();
89
90 if (motherId1 == -1 || motherId2 == -1 || motherId3 == -1 || motherId4 == -1) continue;
91
92 CbmMCTrack* mother1 = (CbmMCTrack*) fMcTracks->At(motherId1);
93 CbmMCTrack* mother2 = (CbmMCTrack*) fMcTracks->At(motherId2);
94 CbmMCTrack* mother3 = (CbmMCTrack*) fMcTracks->At(motherId3);
95 CbmMCTrack* mother4 = (CbmMCTrack*) fMcTracks->At(motherId4);
96
97 int mcMotherPdg1 = mother1->GetPdgCode();
98 int mcMotherPdg2 = mother2->GetPdgCode();
99 int mcMotherPdg3 = mother3->GetPdgCode();
100 int mcMotherPdg4 = mother4->GetPdgCode();
101
102 if (mcMotherPdg1 != 22 || mcMotherPdg2 != 22 || mcMotherPdg3 != 22 || mcMotherPdg4 != 22) continue;
103
104 int grandmotherId1 = mother1->GetMotherId();
105 int grandmotherId2 = mother2->GetMotherId();
106 int grandmotherId3 = mother3->GetMotherId();
107 int grandmotherId4 = mother4->GetMotherId();
108
109 if (grandmotherId1 == -1) continue;
110 CbmMCTrack* GrTrack = (CbmMCTrack*) fMcTracks->At(grandmotherId1);
111
112 if (grandmotherId1 == grandmotherId2 && grandmotherId1 == grandmotherId3 && grandmotherId1 == grandmotherId4
113 && GrTrack->GetPdgCode() == 221) {
114 EtaConversion++;
115 cout << "Decay eta -> gamma gamma -> e+e- e+e- detected!\t\t mc "
116 "mass: "
117 << GrTrack->GetMass() << endl;
118 cout << "motherids: " << motherId1 << "/" << motherId2 << "/" << motherId3 << "/" << motherId4 << endl;
119 cout << "grandmotherid: " << grandmotherId1 << "/" << grandmotherId2 << "/" << grandmotherId3 << "/"
120 << grandmotherId4 << endl;
121 }
122 }
123 }
124 }
125 }
126 }
127
128 cout << "CbmKresSelectGoodEvents, EtaConversion = " << EtaConversion << endl;
129
130 // if (fApp && EtaConversion == 0) {
131 // LOG(warning) << "No double converted Eta";
132 // fApp->SetSaveCurrentEvent(kFALSE);
133 // }
134}
135
136
virtual void Exec(Option_t *)
std::vector< CbmMCTrack * > Electrons
int32_t GetMotherId() const
Definition CbmMCTrack.h:69
double GetMass() const
Mass of the associated particle.
int32_t GetPdgCode() const
Definition CbmMCTrack.h:68
Hash for CbmL1LinkKey.