-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNeutrinoSelectionFilter.C
More file actions
176 lines (101 loc) · 5.48 KB
/
NeutrinoSelectionFilter.C
File metadata and controls
176 lines (101 loc) · 5.48 KB
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
#define NeutrinoSelectionFilter_cxx
#include "NeutrinoSelectionFilter.h"
#include <TH1D.h>
#include <TH2D.h>
#include <TString.h>
#include <TVector3.h>
#include "Constants.h"
using namespace std;
using namespace Constants;
void NeutrinoSelectionFilter::Loop() {
//--------------------------------------------------//
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
TH1D::SetDefaultSumw2();
TH2D::SetDefaultSumw2();
//--------------------------------------------------//
// Output file
TString FileName = "MicroBooNE_Truth.root";
TFile* OutputFile = new TFile(FileName,"recreate");
std::cout << std::endl << "File " << FileName << " to be created"<< std::endl << std::endl;
//--------------------------------------------------//
// Plot declaration
TH1D* TrueVertexXPlot[NInte];
TH1D* TrueVertexYPlot[NInte];
TH1D* TrueVertexZPlot[NInte];
TH1D* TrueMuonCosThetaPlot[NInte];
//--------------------------------------------------//
// Loop over the interaction processes
for (int inte = 0; inte < NInte; inte++) {
//--------------------------------------------------//
// 1D analysis
TrueVertexXPlot[inte] = new TH1D(InteractionLabels[inte]+"TrueVertexXPlot",RecoLabelXAxisVertexX,NBinsVertexX,MinVertexX,MaxVertexX);
TrueVertexYPlot[inte] = new TH1D(InteractionLabels[inte]+"TrueVertexYPlot",RecoLabelXAxisVertexY,NBinsVertexY,MinVertexY,MaxVertexY);
TrueVertexZPlot[inte] = new TH1D(InteractionLabels[inte]+"TrueVertexZPlot",RecoLabelXAxisVertexZ,NBinsVertexZ,MinVertexZ,MaxVertexZ);
TrueMuonCosThetaPlot[inte] = new TH1D(InteractionLabels[inte]+"TrueMuonCosThetaPlot",LabelXAxisMuonCosTheta,NBinsMuonCosTheta,ArrayNBinsMuonCosTheta);
//--------------------------------------------------//
} // End of the loop over the interaction processes
//--------------------------------------------------//
// Loop over the events
for (Long64_t jentry=0; jentry<nentries;jentry++) {
//--------------------------------------------------//
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
if (jentry%1000 == 0) std::cout << jentry/1000 << " k " << std::setprecision(2) << double(jentry)/nentries*100. << " %"<< std::endl;
//--------------------------------------------------//
// MC weight to scale events to data pot
double event_weight = (data_pot / mc_pot) * weightSplineTimesTune;
//--------------------------------------------------//
int TrueMuonCounter = 0, TrueProtonCounter = 0, TrueChargedPionCounter = 0, TruePi0Counter = 0;
int TrueNeutronCounter = 0, TrueHeavierMesonCounter = 0;
std::vector<int> VectorTrueMuonIndex; VectorTrueMuonIndex.clear();
std::vector<int> VectorTrueProtonIndex; VectorTrueProtonIndex.clear();
std::vector<int> VectorTrueNeutronIndex; VectorTrueNeutronIndex.clear();
int NMCParticles = mc_pdg->size();
for (int WhichMCParticle = 0; WhichMCParticle < NMCParticles; WhichMCParticle++) {
// MC truth information for the final-state primary particles
// CC numu events
if ( ccnc == 0 && nu_pdg == 14) {
TVector3 MCParticle(mc_px->at(WhichMCParticle),mc_py->at(WhichMCParticle),mc_pz->at(WhichMCParticle));
double MCParticleMomentum = MCParticle.Mag();
int MCParticlePdg = mc_pdg->at(WhichMCParticle);
if ( MCParticlePdg == MuonPdg && MCParticleMomentum >= ArrayNBinsMuonMomentum[0] )
{ TrueMuonCounter++; VectorTrueMuonIndex.push_back(WhichMCParticle); }
if ( MCParticlePdg == ProtonPdg && MCParticleMomentum >= ArrayNBinsProtonMomentum[0] )
{ TrueProtonCounter++; VectorTrueProtonIndex.push_back(WhichMCParticle); }
if ( fabs(MCParticlePdg) == AbsChargedPionPdg && MCParticleMomentum >= ChargedPionMomentumThres )
{ TrueChargedPionCounter++; }
if (MCParticlePdg == NeutralPionPdg) { TruePi0Counter++; }
} // End of the demand stable final state particles and primary interactions
} // end of the loop over the MCParticles
//--------------------------------------------------//
// CC1p0pi signal events
bool CC1p0pi = false;
if (TrueMuonCounter == 1 && TrueProtonCounter == 1 && TrueChargedPionCounter == 0 && TruePi0Counter == 0 && TrueHeavierMesonCounter == 0) {
CC1p0pi = true;
}
if (!CC1p0pi) { continue; }
//--------------------------------------------------//
// Define muon / proton vectors & deltapt
//--------------------------------------------------//
// Use only true CC1p0pi events inside fiducial volume of interest
//--------------------------------------------------//
// Classify events based on interaction
int genie_mode = -1;
if (interaction == 0) { genie_mode = 1; } // QE
else if (interaction == 10) { genie_mode = 2; } // MEC
else if (interaction == 1) { genie_mode = 3; } // RES
else if (interaction == 2) { genie_mode = 4; } // DIS
else { genie_mode = 5; } // COH / other
//--------------------------------------------------//
// Fill in plots
// All events
// For a specific interaction
//--------------------------------------------------//
} // End of the loop over the events
//--------------------------------------------------//
// Divide by bin width with Reweight function
//--------------------------------------------------//
} // End of the program