50{
52
53
54 TTree * tree = 0;
56
58
59 tree = dynamic_cast <TTree *> ( file.Get("gtree") );
61
62 if(!tree) return 1;
63
64
65 std::string filename = std::string(file.GetName());
66 std::string histofilename = filename.substr(0,filename.size()-5) +
67 ".histo.root";
68 TFile *histofile = new TFile(histofilename.c_str(),"RECREATE");
69
70
71 TH1D* dnPdgHisto = new TH1D("DecayedNucleonPdg", "DecayedNucleonPdg", 5000, -2500, 2500);
72
73 TH1D* dnPHisto = new TH1D("DecayedNucleonMomentum", "DecayedNucleonMomentum [GeV/c]", 100, 0., 0.5);
74
75 TH1D* dnRemovalEnergyHisto = new TH1D("DecayedNucleonRemovalEnergy", "DecayedNucleonRemovalEnergy [GeV]", 100, 0., 0.05);
76
77
78 TH1D* dndaughtersNHisto = new TH1D("DecayedNucleonNDaughters", "DecayedNucleonNDaughters", 6, 0, 6);
79
80 TH1D* dndaughter0PdgHisto = new TH1D("DecayedNucleonDaughter0Pdg", "DecayedNucleonDaughter0Pdg", 1000, -500, 500);
81 TH1D* dndaughter1PdgHisto = new TH1D("DecayedNucleonDaughter1Pdg", "DecayedNucleonDaughter1Pdg", 1000, -500, 500);
82 TH1D* dndaughter2PdgHisto = new TH1D("DecayedNucleonDaughter2Pdg", "DecayedNucleonDaughter2Pdg", 1000, -500, 500);
83
84 TH1D* dndaughter0PHisto = new TH1D("DecayedNucleonDaughter0Momentum", "DecayedNucleonDaughter0Momentum [GeV/c]", 100, 0., 1.);
85 TH1D* dndaughter1PHisto = new TH1D("DecayedNucleonDaughter1Momentum", "DecayedNucleonDaughter1Momentum [GeV/c]", 100, 0., 1.);
86 TH1D* dndaughter2PHisto = new TH1D("DecayedNucleonDaughter2Momentum", "DecayedNucleonDaughter2Momentum [GeV/c]", 100, 0., 1.);
87
88
89 TH1D* finalparticlesNHisto = new TH1D("NFinalParticles", "NFinalParticles", 20, 0, 20);
90 TH1D* finalparticlesPdgHisto = new TH1D("FinalParticlesPdg", "FinalParticlesPdg", 5000, -2500, 2500);
91 TH1D* finalparticlesPHisto = new TH1D("FinalParticlesMomentum", "FinalParticlesMomentum [GeV/c]", 100, 0., 1.);
92
93
94
96 tree->SetBranchAddress("gmcrec", &mcrec);
97
99 TMath::Min(
gOptNEvt, (
int)tree->GetEntries()) :
100 (int) tree->GetEntries();
101
102
103
104
105
106 bool first = true;
107 TText decayName = TText();
108 decayName.SetName("DecayName");
109 TText targetName = TText();
110 targetName.SetName("TargetName");
111
112
113 int dnIndex = 1;
114
115 int ndaughters;
116 int nfinalparticles;
117
118 for(int i = 0; i < nev; i++) {
119
120
121 tree->GetEntry(i);
122
123
125
127
128 if (first) {
129 first = !first;
130
132 int npdg = event.Summary()->InitStatePtr()->TgtPtr()->HitNucPdg();
134 decayName.SetTitle(decayNameString.c_str());
135 string targetNameString = event.Summary()->InitStatePtr()->TgtPtr()->AsString();
136 targetName.SetTitle(targetNameString.c_str());
137 }
138
140 TIter event_iter(&event);
141
142
144
145 if (dnpart->
Status() != 3) {
146 LOG(
"testNucleonDecay",
pFATAL) <<
"Unexpected status code for candidate decayed nucleon: " << dnpart->
Status() <<
", exiting.";
147 exit(1);
148 }
149
151 LOG(
"testNucleonDecay",
pFATAL) <<
"Unexpected first mother index for candidate decayed nucleon: " << dnpart->
FirstMother() <<
", exiting.";
152 exit(1);
153 }
154
155 dnPdgHisto->Fill(dnpart->
Pdg());
156 dnPHisto->Fill(dnpart->
P4()->Vect().Mag());
158
159
160 ndaughters = 0;
161
162 while((p=
dynamic_cast<GHepParticle *
>(event_iter.Next())))
163 {
165 if (ndaughters == 0) {
166 dndaughter0PdgHisto->Fill(p->
Pdg());
167 dndaughter0PHisto->Fill(p->
P4()->Vect().Mag());
168 } else if (ndaughters == 1) {
169 dndaughter1PdgHisto->Fill(p->
Pdg());
170 dndaughter1PHisto->Fill(p->
P4()->Vect().Mag());
171 } else if (ndaughters == 2) {
172 dndaughter2PdgHisto->Fill(p->
Pdg());
173 dndaughter2PHisto->Fill(p->
P4()->Vect().Mag());
174 }
175 ndaughters++;
176 }
177 }
178 dndaughtersNHisto->Fill(ndaughters);
179
180
181 nfinalparticles = 0;
182
184 while((p=
dynamic_cast<GHepParticle *
>(event_iter.Next())))
185 {
187 finalparticlesPdgHisto->Fill(p->
Pdg());
188 finalparticlesPHisto->Fill(p->
P4()->Vect().Mag());
189 nfinalparticles++;
190 }
191 }
192 finalparticlesNHisto->Fill(nfinalparticles);
193
194
195
197
198 }
199
200
201 file.Close();
202
203
204 decayName.Write();
205 targetName.Write();
206
207 histofile->Write();
208 histofile->Close();
209
211
212 return 0;
213}
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
STDHEP-like event record entry that can fit a particle or a nucleus.
int FirstMother(void) const
const TLorentzVector * P4(void) const
double RemovalEnergy(void) const
Get removal energy.
GHepStatus_t Status(void) const
MINOS-style ntuple record. Each such ntuple record holds a generated EventRecord object....
void Clear(Option_t *opt="")
void GetCommandLineArgs(int argc, char **argv)
string AsString(NucleonDecayMode_t ndm, int npdg=0)
enum genie::ENucleonDecayMode NucleonDecayMode_t