1 #include "numuCCMultiTargetAnalysis.hxx" 2 #include "numuCCMultiTargetUtils.hxx" 3 #include "Parameters.hxx" 4 #include "CategoriesUtils.hxx" 6 bool _doMultiPi =
false;
7 bool _IsAntinu =
false;
22 _doMultiPi = ND::params().
GetParameterI(
"numuCCMultiTargetAnalysis.DoMultiPi");
25 _IsAntinu = ND::params().
GetParameterI(
"numuCCMultiTargetAnalysis.DoAntiNu");
28 numuccmultitarget_utils::AddCategories();
31 if (ND::params().GetParameterI(
"numuCCMultiTargetAnalysis.UseReducedFV")) {
33 double FVXmin = TMath::Max(FVDef::FVdefminFGD1[0], FVDef::FVdefminFGD2[0]);
34 double FVXmax = TMath::Max(FVDef::FVdefmaxFGD1[0], FVDef::FVdefmaxFGD2[0]);
35 double FVYmin = TMath::Max(FVDef::FVdefminFGD1[1], FVDef::FVdefminFGD2[1]);
36 double FVYmax = TMath::Max(FVDef::FVdefmaxFGD1[1], FVDef::FVdefmaxFGD2[1]);
37 double FVZmin = TMath::Max(FVDef::FVdefminFGD1[2], FVDef::FVdefminFGD2[2]);
38 double FVZmax = TMath::Max(FVDef::FVdefmaxFGD1[2], FVDef::FVdefmaxFGD2[2]);
39 FVDef::FVdefminFGD1[0] = FVXmin; FVDef::FVdefminFGD1[1] = FVYmin; FVDef::FVdefminFGD1[2] = FVZmin;
40 FVDef::FVdefmaxFGD1[0] = FVXmax; FVDef::FVdefmaxFGD1[1] = FVYmax; FVDef::FVdefmaxFGD1[2] = FVZmax;
41 FVDef::FVdefminFGD2[0] = FVXmin; FVDef::FVdefminFGD2[1] = FVYmin; FVDef::FVdefminFGD2[2] = FVZmin;
42 FVDef::FVdefmaxFGD2[0] = FVXmax; FVDef::FVdefmaxFGD2[1] = FVYmax; FVDef::FVdefmaxFGD2[2] = FVZmax;
45 std::cout <<
"Using a reduced Fiducial Volume: " << std::endl;
46 std::cout <<
" DetDef::fgd1min = " << DetDef::fgd1min[0] <<
" " << DetDef::fgd1min[1] <<
" " << DetDef::fgd1min[2] << std::endl;
47 std::cout <<
" DetDef::fgd1max = " << DetDef::fgd1max[0] <<
" " << DetDef::fgd1max[1] <<
" " << DetDef::fgd1max[2] << std::endl;
48 std::cout <<
" DetDef::fgd2min = " << DetDef::fgd2min[0] <<
" " << DetDef::fgd2min[1] <<
" " << DetDef::fgd2min[2] << std::endl;
49 std::cout <<
" DetDef::fgd2max = " << DetDef::fgd2max[0] <<
" " << DetDef::fgd2max[1] <<
" " << DetDef::fgd2max[2] << std::endl;
50 std::cout <<
" FVDef::FVdefminFGD1 = " << FVDef::FVdefminFGD1[0] <<
" " << FVDef::FVdefminFGD1[1] <<
" " << FVDef::FVdefminFGD1[2] << std::endl;
51 std::cout <<
" FVDef::FVdefmaxFGD1 = " << FVDef::FVdefmaxFGD1[0] <<
" " << FVDef::FVdefmaxFGD1[1] <<
" " << FVDef::FVdefmaxFGD1[2] << std::endl;
52 std::cout <<
" FVDef::FVdefminFGD2 = " << FVDef::FVdefminFGD2[0] <<
" " << FVDef::FVdefminFGD2[1] <<
" " << FVDef::FVdefminFGD2[2] << std::endl;
53 std::cout <<
" FVDef::FVdefmaxFGD2 = " << FVDef::FVdefmaxFGD2[0] <<
" " << FVDef::FVdefmaxFGD2[1] <<
" " << FVDef::FVdefmaxFGD2[2] << std::endl;
61 std::cout <<
"Processing antiNumuCC selection with numuCCMultiTargetAnalysis package" << std::endl;
64 if (!_antiNumuCCAnalysis->Initialize())
return false;
68 else if (_doMultiPi) {
69 std::cout <<
"Processing numuCCMultiPi selection with numuCCMultiTargetAnalysis package" << std::endl;
72 if (!_numuCCMultiPiAnalysis->Initialize())
return false;
77 std::cout <<
"Processing numuCC selection with numuCCMultiTargetAnalysis package" << std::endl;
80 if (!_numuCCAnalysis->
Initialize())
return false;
83 std::cout <<
"----------------------------------------------------" << std::endl;
84 std::cout <<
"WARNING: only for events with accum_level > 5 the vars in the output microtree will surely refer to the muon candidate in that FGD" << std::endl;
85 std::cout <<
"----------------------------------------------------" << std::endl;
94 void numuCCMultiTargetAnalysis::DefineSelections(){
105 void numuCCMultiTargetAnalysis::DefineCorrections(){
108 if (_IsAntinu) _antiNumuCCAnalysis->DefineCorrections();
109 else if (_doMultiPi) _numuCCMultiPiAnalysis->DefineCorrections();
110 else _numuCCAnalysis->DefineCorrections();
114 void numuCCMultiTargetAnalysis::DefineMicroTrees(
bool addBase){
120 if (_IsAntinu) _antiNumuCCAnalysis->DefineMicroTrees(addBase);
121 else if (_doMultiPi) _numuCCMultiPiAnalysis->DefineMicroTrees(addBase);
122 else _numuCCAnalysis->DefineMicroTrees(addBase);
126 AddVarI(output(), ntracks,
"");
129 AddVarI(output(), selmu_fgdmoduletype,
"");
130 AddVarI(output(), selmu_fgdlayer,
"");
131 AddVar3VF(output(), selmu_hit1_pos,
"");
132 AddVar3VF(output(), selmu_hit2_pos,
"");
133 AddVarF(output(), selmu_hit1_charge,
"");
134 AddVarF(output(), selmu_hit2_charge,
"");
137 AddVarI(output(), truelepton_fgdmoduletype ,
"");
138 AddVarI(output(), truelepton_fgdlayer,
"");
139 AddVarI(output(), truelepton_targetZ,
"");
140 AddVarI(output(), truelepton_targetPDG,
"");
143 AddVarF(output(), distance_track_hit1,
"");
144 AddVarF(output(), distance_track_hit2,
"");
145 AddVar3VF(output(), selmu_fittrack_hit1_pos,
"");
146 AddVar3VF(output(), selmu_fittrack_hit2_pos,
"");
147 AddVarF(output(), selmu_deltachi2_hit1,
"");
148 AddVarF(output(), selmu_deltachi2_hit2,
"");
151 AddVarF(output(), selmu_nuErecQEoxygen,
"neutrino reconstructed energy with muon candidate's reconstructed kinematics in ccqe formula with Eb for oxygen");
152 AddVarF(output(), truelepton_nuErecQEoxygen,
"neutrino reconstructed energy with true lepton kinematics in ccqe formula with Eb for oxygen");
153 AddVarF(output(), selmu_chi2,
"");
158 void numuCCMultiTargetAnalysis::DefineTruthTree(){
162 if (_IsAntinu) _antiNumuCCAnalysis->DefineTruthTree();
163 else if (_doMultiPi) _numuCCMultiPiAnalysis->DefineTruthTree();
164 else _numuCCAnalysis->DefineTruthTree();
166 AddVarI(output(), truevtx_fgdmoduletype ,
"");
167 AddVarI(output(), truevtx_fgdlayer,
"");
168 AddVarI(output(), truevtx_targetZ,
"");
169 AddVarI(output(), truevtx_targetPDG,
"");
173 void numuCCMultiTargetAnalysis::FillMicroTrees(
bool addBase){
177 if (_IsAntinu) _antiNumuCCAnalysis->FillMicroTrees(addBase);
178 else if (_doMultiPi) _numuCCMultiPiAnalysis->FillMicroTrees(addBase);
179 else _numuCCAnalysis->FillMicroTrees(addBase);
195 output().
FillVar(truelepton_fgdlayer, numuccmultitarget_utils::GetFgdLayer(
GetEvent().GetIsMC(), truevtx->
Position));
199 Float_t Erec =
anaUtils::ComputeRecNuEnergyCCQE(output().GetVarValueF(numuCCAnalysis::truelepton_mom), units::mass_muon, output().GetVarValueF(numuCCAnalysis::truelepton_costheta), 27.);
200 output().
FillVar(truelepton_nuErecQEoxygen, Erec);
206 if ( ! input().InputIsFlatTree()) {
214 output().
FillVar(selmu_hit1_charge, selmu->UpstreamHits_Charge[0]);
215 output().
FillVar(selmu_hit2_charge, selmu->UpstreamHits_Charge[1]);
218 for (
int i=0; i<3; i++) hit1_pos[i] = selmu->DownstreamHits_Position[0][i];
219 for (
int i=0; i<3; i++) hit2_pos[i] = selmu->DownstreamHits_Position[1][i];
220 output().
FillVar(selmu_hit1_charge, selmu->DownstreamHits_Charge[0]);
221 output().
FillVar(selmu_hit2_charge, selmu->DownstreamHits_Charge[1]);
229 TVector3 fittedPos1 = numuccmultitarget_utils::GetFittedPos(anaUtils::ArrayToTVector3(selmu->
PositionStart),
232 TVector3 fittedPos2 = numuccmultitarget_utils::GetFittedPos(anaUtils::ArrayToTVector3(selmu->
PositionStart),
235 Float_t ft1pos[3]; anaUtils::VectorToArray(fittedPos1,ft1pos);
236 Float_t ft2pos[3]; anaUtils::VectorToArray(fittedPos2,ft2pos);
239 output().
FillVar(selmu_deltachi2_hit1, numuccmultitarget_utils::GetDeltaChi2(hit1_pos,fittedPos1));
240 output().
FillVar(selmu_deltachi2_hit2, numuccmultitarget_utils::GetDeltaChi2(hit2_pos,fittedPos2));
242 TVector3 track_start_pos = anaUtils::ArrayToTVector3(selmu->
PositionStart);
243 TVector3 track_end_pos = anaUtils::ArrayToTVector3(selmu->
PositionEnd);
244 output().
FillVar(distance_track_hit1, numuccmultitarget_utils::CalculateLineLineDistance(track_start_pos, track_end_pos, hit1_pos));
245 output().
FillVar(distance_track_hit2, numuccmultitarget_utils::CalculateLineLineDistance(track_start_pos, track_end_pos, hit2_pos));
248 if (selmu_hit1_charge == -999) std::cout <<
"ERROR: selmu_hit1_charge is -999" << std::endl;
253 Float_t Erec =
anaUtils::ComputeRecNuEnergyCCQE(output().GetVarValueF(numuCCAnalysis::selmu_mom), units::mass_muon, output().GetVarValueF(numuCCAnalysis::selmu_costheta), 27.);
254 output().
FillVar(selmu_nuErecQEoxygen, Erec);
260 void numuCCMultiTargetAnalysis::FillToyVarsInMicroTrees(
bool addBase){
264 if (_IsAntinu) _antiNumuCCAnalysis->FillToyVarsInMicroTrees(addBase);
265 else if (_doMultiPi) _numuCCMultiPiAnalysis->FillToyVarsInMicroTrees(addBase);
266 else _numuCCAnalysis->FillToyVarsInMicroTrees(addBase);
272 bool numuCCMultiTargetAnalysis::CheckFillTruthTree(
const AnaTrueVertex& vtx){
276 bool numuCCinFV = anaUtils::GetReactionCC(vtx, SubDetId::kFGD, _IsAntinu)==1;
282 bool topoCCinFV = (topo == 0 || topo == 1 || topo == 2);
284 if ( ! numuCCinFV && topoCCinFV) std::cout <<
"WOW here you have a topoCC non-numuCC! TruthVertex ID: " << vtx.
ID << std::endl;
286 return (numuCCinFV || topoCCinFV);
290 void numuCCMultiTargetAnalysis::FillTruthTree(
const AnaTrueVertex& vtx){
294 if (_IsAntinu) _antiNumuCCAnalysis->FillTruthTree(vtx);
295 else if (_doMultiPi) _numuCCMultiPiAnalysis->FillTruthTree(vtx);
296 else _numuCCAnalysis->FillTruthTree(vtx);
306 cat().
SetCode(
"fgd2moduletype", CATSAND);
307 cat().
SetCode(
"fgd2moduletypeCC", CATSAND);
308 cat().
SetCode(
"fgd2targetCCQE", CATSAND);
309 cat().
SetCode(
"fgd2targetCC", CATSAND);
314 cat().
SetCode(
"fgd2moduletypeCC", numuccmultitarget_utils::GetFgdModuleTypeCC(
GetSpill().GetIsMC(), &vtx, SubDetId::kFGD2), _IsAntinu);
315 cat().
SetCode(
"fgd2targetCCQE", numuccmultitarget_utils::GetTargetCCQE(&vtx, SubDetId::kFGD2));
316 cat().
SetCode(
"fgd2targetCC", numuccmultitarget_utils::GetTargetCC(&vtx, SubDetId::kFGD2));
320 void numuCCMultiTargetAnalysis::FillCategories(){
324 if (_IsAntinu) _antiNumuCCAnalysis->FillCategories();
325 else if (_doMultiPi) _numuCCMultiPiAnalysis->FillCategories();
326 else _numuCCAnalysis->FillCategories();
331 cat().
SetCode(
"fgd2moduletype", CATSAND);
332 cat().
SetCode(
"fgd2moduletypeCC", CATSAND);
333 cat().
SetCode(
"fgd2targetCCQE", CATSAND);
334 cat().
SetCode(
"fgd2targetCC", CATSAND);
338 cat().
SetCode(
"fgd2moduletype", CATNOTRUTH);
339 cat().
SetCode(
"fgd2moduletypeCC", CATNOTRUTH);
340 cat().
SetCode(
"fgd2targetCCQE", CATNOTRUTH);
341 cat().
SetCode(
"fgd2targetCC", CATNOTRUTH);
347 cat().
SetCode(
"fgd2moduletypeCC", numuccmultitarget_utils::GetFgdModuleTypeCC(
GetEvent().GetIsMC(), truevtx, SubDetId::kFGD2), _IsAntinu);
348 cat().
SetCode(
"fgd2targetCCQE", numuccmultitarget_utils::GetTargetCCQE(truevtx, SubDetId::kFGD2));
349 cat().
SetCode(
"fgd2targetCC", numuccmultitarget_utils::GetTargetCC(truevtx, SubDetId::kFGD2));
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
Representation of a global track.
void SetMinAccumCutLevelToSave(Int_t level)
Set the minimum accumulated cut level to save an event into the micro-tree.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
void SetCode(const std::string &categ, int code, int defaultcode=0)
void AddPackage(const std::string &name, const std::string &version)
Add a package.
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
Float_t ComputeRecNuEnergyCCQE(Float_t mom_lepton, Float_t mass_lepton, Float_t costheta_lepton, Float_t bindingEnergy=25.)
bool Initialize()
[AnalysisAlgorithm_mandatory]
AnaBunch & GetBunch()
Get a casted AnaBunchBB to AnaBunch from the InputManager (TODO the protection)
Int_t TargetPDG
The PDG code of the target nucleus.
Int_t GetTopology(const AnaTrueVertex &trueVertex, const SubDetId::SubDetEnum det=SubDetId::kFGD1, bool IsAntinu=false)
Classify reaction topologies.
Int_t GetFgdModuleType(bool IsMC, const Float_t *pos, SubDetId::SubDetEnum det, bool includeGlueSkin=true)
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
Float_t Chi2
The chi2 value when the track was fitted using a Kalman filter.
std::string GetSoftwareVersionFromPath(const std::string &path)
Get The software version from the path of the package.
Representation of a true Monte Carlo vertex.
virtual const ToyBoxTracker & box(Int_t isel=-1) const
Returns the ToyBoxTracker.
TVector3 UpstreamHits_Position[2]
Float_t Position[4]
The position the true interaction happened at.
AnaEvent & GetEvent()
Get a casted AnaEventC to AnaEvent.
bool Initialize()
[AnalysisAlgorithm_mandatory]
void FillVar(Int_t index, Float_t var)
Fill a single variable.
void AddSelection(const std::string &name, const std::string &title, SelectionBase *sel, Int_t presel=-1)
Add a user selection to the selection manager.
AnaSpill & GetSpill()
Get a casted AnaSpillC to AnaSpill from the InputManager.
void UseAnalysis(AnalysisAlgorithm *ana)
Used a given analysis.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
void FillVectorVarFromArray(Int_t index, const Double_t var[], UInt_t size)
Fill a vector variable from array.
Int_t GetTargetCode(const AnaTrueVertex *trueVertex)
Get the code for filling the target PDG category.
Float_t PositionEnd[4]
The reconstructed end position of the particle.