Skip to content

Commit

Permalink
stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
fjnicolas committed Jan 16, 2024
1 parent a19f444 commit 8e11f17
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 18 deletions.
9 changes: 6 additions & 3 deletions src/Analysis/CutDefinitions.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ std::vector<PlotDef> cutDefs2 = {
,{"FRANSScorePANDORA", "FRANSScorePANDORA", CutType::kNone, fCutFRANSPANDORA, {-.5,.5,40}, false, "FRANS score PANDORA", "FRANS \\ score \\ PANDORA"}
,{"RecoIsFiducial", "RecoIsFiducial", CutType::kCenter, 1, {0,2,2}, true, "Reco in FV", "Reco \\ in \\ FV"}

,{"FRANSScorePANDORA", "FRANSScorePANDORA", CutType::kRight, fCutFRANSPANDORA, {-.5,.5,40}, true, "FRANS score PANDORA", "FRANS \\ score \\ PANDORA"}

,{"NOriginsPairOneTwo>0", "NOriginsPairOneTwo>0", CutType::kCenter, 1, {0,2,2}, true, "# origins mult 1>0, # origins mult2>0", "\\#\\ origins\\ mult \\ 1>0, \\# \\ origins \\ mult \\ 2>0"}
,{"NAngles", "NAngles", CutType::kRight, fCutMinNAngles , {0,5,5}, true, "# V", "\\# \\ V" }

Expand Down Expand Up @@ -90,11 +92,11 @@ std::vector<PlotDef> cutDefs2 = {
,{"AngleBandCrossHits", "AngleBandCrossHits", CutType::kNone, 1, {0, 2, 50}, false, "AngleBandCrossHits", "AngleBandCrossHits"}


,{"AngleFRANSScore", "AngleFRANSScore", CutType::kRight, fCutFRANS, {-.5,.5,40}, true, "V FRANS score", "V \\ FRANS \\ score"}

//,{"AngleFRANSScore", "AngleFRANSScore", CutType::kRight, fCutFRANS, {-.5,.5,40}, true, "V FRANS score", "V \\ FRANS \\ score"}

,{"AnglePassFit", "AnglePassFit", CutType::kRight, 1, {0, 2, 2}, true, "AnglePassFit", "AnglePassFit"}
,{"AnglePassChargeFit", "AnglePassChargeFit", CutType::kRight, 1, {0, 2, 2}, true, "AnglePassChargeFit", "AnglePassChargeFit"}
,{"AngleNVertexHits", "AngleNVertexHits", CutType::kRight, 1, {0, 100, 20}, true, "AngleNVertexHits", "AngleNVertexHits"}

,{"NUnOriginsMultGT3", "NUnOriginsMultGT3", CutType::kLeft, 0, {0, 5, 5}, false, "# origins mult 3", "\\# \\ origins \\ mult \\ 3"}
,{"NUnOrigins", "NUnOrigins", CutType::kLeft, 0, {0, 15, 15}, true, "# origins", "\\# \\ origins"}
Expand All @@ -115,6 +117,7 @@ std::vector<PlotDef> cutDefs2 = {
,{"AngleResidualRangeMinRMS", "AngleResidualRangeMinRMS", CutType::kLeft, 0.1, {0, 2, 40}, true, "AngleResidualRangeMinRMS", "AngleResidualRangeMinRMS"}
,{"AngleChargeRatioFit", "AngleChargeRatioFit", CutType::kRight, 1.25, {0, 3, 20}, true, "AngleChargeRatioFit", "AngleChargeRatioFit"}
,{"AngleChargeRatioIntegral", "AngleChargeRatioIntegral", CutType::kRight, 1.25, {0, 3, 20}, true, "AngleChargeRatioIntegral", "AngleChargeRatioIntegral"}
,{"AngleNVertexHits", "AngleNVertexHits", CutType::kRight, 0, {0, 100, 20}, true, "AngleNVertexHits", "AngleNVertexHits"}
,{"AngleBandCrossHits", "AngleBandCrossHits", CutType::kLeft, 0.5, {0, 2, 50}, true, "AngleBandCrossHits", "AngleBandCrossHits"}


Expand All @@ -126,7 +129,7 @@ std::vector<PlotDef> cutDefs2 = {
,{"AngleNHits", "AngleNHits", CutType::kRight, 10, {0, 200, 40}, false, "Angle # hits", "Angle \\ \\# \\ hits"}
,{"NFreeHits", "NFreeHits", CutType::kLeft, 30, {0, 200, 40}, false, "# free hits", "\\# \\ free \\ hits"}*/

,{"FRANSScorePANDORA", "FRANSScorePANDORA", CutType::kRight, fCutFRANSPANDORA, {-.5,.5,40}, true, "FRANS score PANDORA", "FRANS \\ score \\ PANDORA"}




Expand Down
15 changes: 8 additions & 7 deletions src/Analysis/LambdaBDTAnalysis.C
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ void LambdaBDTAnalysis(std::string fInputFileName="", double nTrainFrac = -1, bo
TCut fTruthInAV("TruthIsAV==1");

// ---- Minimal cut
TCut fMinimalCut("RecoIsFiducial && NAngles>=1 && AnglePassFit==1 && AnglePassChargeFit==1"); //&& AngleChargeRatioAverage>=0 && AngleChargeRatioAverage<=15");
TCut fMinimalCut("RecoIsFiducial && NAngles>=1 && AnglePassFit && AnglePassChargeFit");
//TCut fSelCuts("FRANSScorePANDORA>=0.2 && AngleDecayContainedDiff<1 && NUnOrigins<1");

// Batch mode
useBatchMode? gROOT->SetBatch(kTRUE): gROOT->SetBatch(kFALSE);
Expand Down Expand Up @@ -106,8 +107,8 @@ void LambdaBDTAnalysis(std::string fInputFileName="", double nTrainFrac = -1, bo


dataloader->AddVariable( "AngleFRANSScore", "AngleFRANSScore", "", 'D' );
dataloader->AddVariable( "NUnOriginsMultGT3", "N^{2}", "", 'I' );
dataloader->AddVariable( "NUnOrigins", "N", "", 'I' );
//dataloader->AddVariable( "NUnOriginsMultGT3", "N^{2}", "", 'I' );
//dataloader->AddVariable( "NUnOrigins", "N", "", 'I' );
//dataloader->AddVariable( "CRUMBSScore", "CRUMBS", "", 'D' );
dataloader->AddVariable( "AngleDecayContainedDiff", "#alpha", "", 'D' );
dataloader->AddVariable( "AngleLengthMainTrack", "Main track Length [cm]", "", 'I' );
Expand All @@ -119,7 +120,7 @@ void LambdaBDTAnalysis(std::string fInputFileName="", double nTrainFrac = -1, bo
//dataloader->AddVariable( "AngleMinNHits", "# hits min", "", 'I' );
//dataloader->AddVariable( "NUnassociatedHits", "# unassociated hits", "", 'I' );
//dataloader->AddVariable( "FRANSScorePANDORA", "FRANS PANDORA", "", 'D' );
dataloader->AddVariable( "AngleDirtHits", "Dirt Hits", "", 'I' );
//dataloader->AddVariable( "AngleDirtHits", "Dirt Hits", "", 'I' );
dataloader->AddVariable( "NShowers", "# showers", "", 'I' );
//dataloader->AddVariable( "NShowerHits", "# shower hits", "", 'I' );
//dataloader->AddVariable( "AngleLongestIsMain", "LongestIsMain", "", 'I' );
Expand All @@ -132,14 +133,14 @@ void LambdaBDTAnalysis(std::string fInputFileName="", double nTrainFrac = -1, bo
//dataloader->AddVariable( "AngleTwoLinesChi2", "Two Lines Chi2", "", 'D' );
//dataloader->AddVariable( "AnglePassFit", "PassFit", "", 'I' );
//dataloader->AddVariable( "AnglePassChargeFit", "Pass Charge Fit", "", 'I' );
//dataloader->AddVariable( "AngleBandOverlap", "Band Overlap", "", 'D' );
//dataloader->AddVariable( "AngleBandOverlap", "B and Overlap", "", 'D' );

dataloader->AddVariable( "AngleBandCrossHits", "Band Overlap", "", 'D' );

//dataloader->AddVariable( "AngleChargeRatioFit", "Charge Ratio Fit", "", 'D' );
//dataloader->AddVariable( "AngleChargeDifferenceFit", "Charge Difference", "", 'D' );
//dataloader->AddVariable( "AngleChargeDifferenceFit", "Charge Difference Fit", "", 'D' );

dataloader->AddVariable( "AngleChargeRatioIntegral", "Charge Ratio Integral", "", 'D' );
//dataloader->AddVariable( "AngleChargeRatioIntegral", "Charge Ratio Integral", "", 'D' );

//dataloader->AddVariable( "AngleChargeDifferenceIntegral", "Charge Difference", "", 'D' );
//dataloader->AddVariable( "AngleChargeRatioAverage", "Charge Ratio Average", "", 'D' );
Expand Down
17 changes: 11 additions & 6 deletions src/Analysis/LambdaEvaluateBDTAnalysis.C
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ void EvaluateBDTAnalysis(TTree *fTree, TTree *fTreeHeader, std::string fWeightFi
if(fVarLabels["AngleNHitsTrack2"]==true) fTMVAReader->AddVariable( "AngleNHitsTrack2", &AngleNHitsTrack2 );
if(fVarLabels["AngleMinNHits"]==true) fTMVAReader->AddVariable( "AngleMinNHits", &AngleMinNHits );
if(fVarLabels["NUnassociatedHits"]==true) fTMVAReader->AddVariable( "NUnassociatedHits", &NUnassociatedHits );
if(fVarLabels["ShowerEnergy"]==true) fTMVAReader->AddVariable( "ShowerEnergy", &ShowerEnergy );
if(fVarLabels["FRANSScorePANDORA"]==true) fTMVAReader->AddVariable( "FRANSScorePANDORA", &FRANSScorePANDORA );
if(fVarLabels["AngleCoveredArea"]==true) fTMVAReader->AddVariable( "AngleCoveredArea", &AngleCoveredArea );
if(fVarLabels["AngleDirtHits"]==true) fTMVAReader->AddVariable( "AngleDirtHits", &AngleDirtHits );
if(fVarLabels["NShowers"]==true) fTMVAReader->AddVariable( "NShowers", &NShowers );
if(fVarLabels["NShowerHits"]==true) fTMVAReader->AddVariable( "NShowerHits", &NShowerHits );
if(fVarLabels["ShowerEnergy"]==true) fTMVAReader->AddVariable( "ShowerEnergy", &ShowerEnergy );
if(fVarLabels["AngleOpeningAngle"]==true) fTMVAReader->AddVariable( "AngleOpeningAngle", &AngleOpeningAngle );
if(fVarLabels["AngleLongestIsMain"]==true) fTMVAReader->AddVariable( "AngleLongestIsMain", &AngleLongestIsMain );
// Calo
Expand Down Expand Up @@ -151,7 +151,7 @@ void EvaluateBDTAnalysis(TTree *fTree, TTree *fTreeHeader, std::string fWeightFi
TH1F *hScoreCosmic = new TH1F("hScoreCosmic", "; Classifier score; # entries", 100, -1, 1);

// Store highest BG score events
int nHighestScoreEvents = 5;
int nHighestScoreEvents = 25;
std::vector<int> highestScoreEventID;
std::vector<std::string> highestScoreEventLabels;
std::vector<double> highestScoreEventScores;
Expand Down Expand Up @@ -211,11 +211,17 @@ void EvaluateBDTAnalysis(TTree *fTree, TTree *fTreeHeader, std::string fWeightFi


// check minimal cut
bool passCut = fAnaTreeHandle.fRecoIsFiducial && fAnaTreeHandle.fNAngles>=1 && fAnaTreeHandle.fAnglePassFit==1 && fAnaTreeHandle.fAnglePassChargeFit==1;
bool minimalCut = fAnaTreeHandle.fRecoIsFiducial && fAnaTreeHandle.fNAngles>=1;
bool passFitCuts = fAnaTreeHandle.fAnglePassFit==1 && fAnaTreeHandle.fAnglePassChargeFit==1;
bool selCuts = fAnaTreeHandle.fFRANSScorePANDORA>0.2 && fAnaTreeHandle.fAngleDecayContainedDiff<1 && fAnaTreeHandle.fNUnOrigins<=0;
bool passCut;

passCut = minimalCut && passFitCuts;
if(!passCut) score = -0.95;

bool isSignal = fAnaTreeHandle.fIntOrigin==1 && fAnaTreeHandle.fIntDirt==0 && (fAnaTreeHandle.fIntNLambda>0 && fAnaTreeHandle.fIntMode==0 && std::abs(fAnaTreeHandle.fIntNuPDG)!=12);
bool isNuBG = fAnaTreeHandle.fIntOrigin==1 && fAnaTreeHandle.fIntDirt==0 && !(fAnaTreeHandle.fIntNLambda>0 && fAnaTreeHandle.fIntMode==0 && std::abs(fAnaTreeHandle.fIntNuPDG)!=12);

// Fill histogram for signals
if(fTruthIsActive){
if(isSignal)
Expand All @@ -228,7 +234,8 @@ void EvaluateBDTAnalysis(TTree *fTree, TTree *fTreeHeader, std::string fWeightFi
}

// Fill highest score events
if(passCut && !isSignal && score>0.2){
if(passCut && !isSignal){
fAnaTreeHandle.PrintEventInfo();
if(highestScoreEventID.size()<nHighestScoreEvents){
highestScoreEventID.push_back(fAnaTreeHandle.fEventID);
std::string label = std::to_string(fAnaTreeHandle.fRunID)+":"+std::to_string(fAnaTreeHandle.fSubrunID);
Expand Down Expand Up @@ -435,8 +442,6 @@ void EvaluateBDTAnalysis(TTree *fTree, TTree *fTreeHeader, std::string fWeightFi
}
}



}

void MacroEvaluateBDT(std::string fInputFileName="", bool batchMode=1, std::string fTreeDirName = "originsAna/", std::string fTreeName = "LambdaAnaTree")
Expand Down
14 changes: 13 additions & 1 deletion src/EventHandle/LambdaAnaTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,16 @@ void LambdaAnaTree::ResetVars(){

void LambdaAnaTree::GetEntry(int i){
fTree->GetEntry(i);
}
}


// --- Print function ---
void LambdaAnaTree::PrintEventInfo() {
// Event information
std::cout << "\n Run: " << fRunID << " Subrun: " << fSubrunID << " Event: " << fEventID << "\n";
std::cout << "Input File Name: " << *fInputFileNameRead << "\n";
std::cout << " NuE: "<<fNuvE<<" NuT: "<<fNuvT<<" NuX: "<<fNuvX<<" NuY: "<<fNuvY<<" NuZ: "<<fNuvZ<<std::endl;
std::cout << " Lambda gap: " << fGap << " LambdaKE: "<<fLambdaKE<<std::endl;
// Track lengths
std::cout << " Track lengths: " << fAngleLengthTrack1 << " " << fAngleLengthTrack2 << " " << fAngleLengthMainTrack << std::endl;
}
4 changes: 4 additions & 0 deletions src/EventHandle/LambdaAnaTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ class LambdaAnaTree {
int GetEntries() { return fTree->GetEntries(); }
void GetEntry(int i);

// Reset all variables
void ResetVars();

// Print event information
void PrintEventInfo();

};


Expand Down
7 changes: 6 additions & 1 deletion src/RunAlgoTPCLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void RunAlgoTPCLines(const CommandLineParser& parser)

nEvents++;
std::cout << "\n\n ************** Analyzing: " << ev;
std::cout << " Interaction mode: "<<treeReader.intMode<<" NLambda: "<<treeReader.intNLambda<<std::endl;
std::cout << " Interaction mode: "<<treeReader.intMode<<" NLambda: "<<treeReader.intNLambda<<" E = "<<treeReader.nuvE<<" GeV" << " T = " <<treeReader.nuvT<<" ns"<<std::endl;

// True vertex
std::vector<double> VertexXYZ = {treeReader.nuvX, treeReader.nuvY, treeReader.nuvZ};
Expand Down Expand Up @@ -425,6 +425,9 @@ void RunAlgoTPCLines(const CommandLineParser& parser)
fAnaTreeHandle.fRecoIsFiducial = true;

//fAnaTreeHandle.FillTree();
// Cout FRANS Score PANDORA
std::cout<<" - FRANS Score PANDORA: "<<FRANSScorePANDORA<<std::endl;
std::cout<<" - FRANS Score: "<<bestFRANSScore<<std::endl;

TCanvas *cCalo = new TCanvas(("canvasCalo"+ev.Label()).c_str(),"Calorimetry", 600,1200);
TCanvas *cTPCDisplay = new TCanvas( ("FinalReco"+ev.Label()).c_str(), ("FinalReco"+ev.Label()).c_str(), 0, 0, 1000, 800);
Expand Down Expand Up @@ -462,6 +465,8 @@ void RunAlgoTPCLines(const CommandLineParser& parser)
delete cDisplay;
}



}
}

Expand Down

0 comments on commit 8e11f17

Please sign in to comment.