Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fdd1e3a
Fixed segmentation faults in SLDCorrection
nVentis Oct 29, 2024
8e551f3
Fixed segfault in case no track exists for linkedRecoLepton
nVentis Nov 3, 2024
79d3623
Fixed segfault when no primary vertex exists
nVentis Nov 5, 2024
9f5c951
Changes for outputting to AIDA
nVentis Feb 8, 2025
049682e
Corrected headers and made output compatible to AIDA
nVentis Feb 11, 2025
bda38a0
Removed VCS mark
nVentis Feb 11, 2025
9079aaa
Merge branch 'iLCSoft:master' into master
nVentis Mar 26, 2025
32d424d
Added fixes to SLDCorrection
nVentis Apr 23, 2025
52d5336
Fixed segmentation faults in SLDCorrection
nVentis Oct 29, 2024
2b0441c
Fixed segfault in case no track exists for linkedRecoLepton
nVentis Nov 3, 2024
17a8f87
Fixed segfault when no primary vertex exists
nVentis Nov 5, 2024
d1b03c6
Changes for outputting to AIDA
nVentis Feb 8, 2025
f816a92
Corrected headers and made output compatible to AIDA
nVentis Feb 11, 2025
d2a8d35
Removed VCS mark
nVentis Feb 11, 2025
6536263
Added fixes to SLDCorrection
nVentis Apr 23, 2025
c363f5a
Added MCP option by Uli
nVentis Jul 1, 2025
3a09c9d
Quick fix to TrueJet: Cause to be investigated
nVentis Jul 8, 2025
a8d1b85
Merge remote-tracking branch 'refs/remotes/origin/master'
nVentis Jul 8, 2025
b2885e4
Merge branch 'master' into sldcorrection-fixes
tmadlener Jan 10, 2026
099f192
Remove unnecessary formattting to reduce diff size
tmadlener Jan 10, 2026
12c205a
Added skipping of un-processable events
nVentis Apr 28, 2026
3417f3b
Added catch logic for un-processable events
nVentis Apr 28, 2026
7d66286
Merge branch 'master' into sldcorrection-fixes
tmadlener Apr 29, 2026
2987729
Fix formatting to make pre-commit happy
tmadlener Apr 29, 2026
edc2511
Revert changes to TrueJet, keep explicit Exceptions
nVentis Jul 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Analysis/PIDTools/include/ComprehensivePIDProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class ComprehensivePIDProcessor : public Processor {
bool _modeExtract = false;
bool _modeTrain = false;
bool _modeInfer = false;
bool _addMCPID = false;

std::string _TTreeFileName{};
std::vector<std::string> _inputAlgoSpecs{};
Expand Down
40 changes: 34 additions & 6 deletions Analysis/PIDTools/src/ComprehensivePIDProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ ComprehensivePIDProcessor::ComprehensivePIDProcessor() : Processor("Comprehensiv
"you need to provide the reference and weight files; default: false.",
_modeInfer, false);

registerProcessorParameter("addMCPID",
"Set true to add a PID output called 'MCPID' to the PFOs which is directly derived from "
"MC information (no inference), not compatible with training mode; default: false.",
_addMCPID, false);

registerProcessorParameter(
"TTreeFileName",
"Name of the root file in which the TTree with all observables is stored; in case of extraction it is an "
Expand Down Expand Up @@ -146,6 +151,10 @@ void ComprehensivePIDProcessor::init() {
sloE << "I cannot train and infer in the same process!" << std::endl;
throw std::runtime_error("mode error");
}
if (_modeTrain && _addMCPID) {
sloE << "I cannot train and add MCPID in the same process!" << std::endl;
throw std::runtime_error("mode error");
}

if (_TTreeFileName == "") {
sloM << "TTreeFileName is empty, no root file is created" << std::endl;
Expand Down Expand Up @@ -410,7 +419,7 @@ void ComprehensivePIDProcessor::processEvent(LCEvent* evt) {
if (_nAlgos == 0)
return;

if (_modeExtract || _modeInfer) {
if (_modeExtract || _modeInfer || _addMCPID) {
LCCollection *col_pfo{}, *col_pfo2mc{};

try {
Expand All @@ -427,7 +436,7 @@ void ComprehensivePIDProcessor::processEvent(LCEvent* evt) {
PIDHandler pidh(col_pfo);
std::vector<int> algoID{};
std::vector<int> allPDGs{};
if (_modeInfer) {
if (_modeInfer || _addMCPID) {
std::vector<std::string> PDGness{};
for (int pdg : _signalPDGs) {
std::stringstream pn;
Expand All @@ -441,8 +450,12 @@ void ComprehensivePIDProcessor::processEvent(LCEvent* evt) {
PDGness.push_back(pn.str());
allPDGs.push_back(pdg);
}
for (int m = 0; m < _nModels; ++m)
algoID.push_back(pidh.addAlgorithm(_trainModelNames[m], PDGness));
if (_modeInfer)
for (int m = 0; m < _nModels; ++m)
algoID.push_back(pidh.addAlgorithm(_trainModelNames[m], PDGness));

if (_addMCPID)
algoID.push_back(pidh.addAlgorithm("MCPID", PDGness));
}

for (int i = 0; i < n_pfo; ++i) {
Expand Down Expand Up @@ -567,6 +580,20 @@ void ComprehensivePIDProcessor::processEvent(LCEvent* evt) {
break;
}
}

if (_addMCPID) {
sloD << "start adding MCPID" << std::endl;
std::vector<float> mcPID{};

for (int ipdg = 0; ipdg < (int)allPDGs.size(); ++ipdg) {
if (allPDGs[ipdg] == abs(MCPDG))
mcPID.push_back(1);
else
mcPID.push_back(0);
}

pidh.setParticleID(pfo, 0, abs(MCPDG), 0, pidh.getAlgorithmID("MCPID"), mcPID);
}
} // for pfos
}

Expand Down Expand Up @@ -633,8 +660,9 @@ void ComprehensivePIDProcessor::end() {

for (int i = 0; i < _nAlgos; ++i)
delete _inputAlgorithms[i];
for (int i = 0; i < _nModels; ++i)
delete _trainingModels[i];
if (_modeTrain || _modeInfer)
for (int i = 0; i < _nModels; ++i)
delete _trainingModels[i];

sloM << "Numer of Events: " << _nEvt << " Numer of PFOs: " << _nPFO << std::endl;
sloM << "-------------------------------------------------" << std::endl;
Expand Down
16 changes: 15 additions & 1 deletion Analysis/SLDCorrection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,18 @@ Green histograms are used to estimate the overall uncertainty due to neutrino co

sigmaAlphaNu = 0.100 rad , sigmaENu = 4.0 GeV

In the end, neutrinos are assumed to be massless and sigmaAlphaNu and sigmaENu are transformed to a covariance matrix in (p,E) space.
In the end, neutrinos are assumed to be massless and sigmaAlphaNu and sigmaENu are transformed to a covariance matrix in (p,E) space.

### SLDStatus Reference
| SLDStatus | Interpretation |
|-----------|-------------------------------------------------|
| 0 | PrimaryVertex collection found, but empty |
| 1 | Reconstructed Lepton is not found |
| 2 | Reconstructed Lepton doesn't belong to any jet |
| 3 | Infer SLD from reconstructed lepton in primary vertex |
| 4 | Infer SLD from reconstructed lepton in a secondary (BuildUp) Vertex. |
| 5 | Infer SLD frmo BuildUp Vertex in a jet. Intersection point of Lepton and other BuildUp Vertices in jet is used as vertex of semi-leptonic decay. |
| 6 | Inferred from lepton track alone. |
| 7 | other |

In the h_SLDStatus histogram, these values are inserted with a shift of -0.5
35 changes: 17 additions & 18 deletions Analysis/SLDCorrection/include/SLDCorrection.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
#include <EVENT/Track.h>
#include <IMPL/ReconstructedParticleImpl.h>
#include <IMPL/VertexImpl.h>
#include <TF1.h>
#include <TFile.h>
#include <TH1F.h>
#include <TH1I.h>
#include <TH2F.h>
#include <TH2I.h>
#include <TTree.h>
#include <marlin/Global.h>
#include <marlin/Processor.h>
#include <math.h>
#include <set>
#include <string>
#include <vector>
class TFile;
class TDirectory;
class TH1F;
class TH1I;
class TH2I;
class TH2F;
class TTree;
class TF1;

using namespace lcio;
using namespace marlin;
Expand Down Expand Up @@ -59,24 +58,24 @@ class SLDCorrection : public Processor {
bool hasUpStreamSLDecay(const MCP& parentHadron);

// checkBHadronSLDecay checks the flavour of the Hadron decays semi-leptonicall, if B-Hadron: true, if not: false
bool checkBHadronSLDecay(const MCP& SLDLepton);
bool checkBHadronSLDecay(const MCP& parentHadron);

// checkCHadronSLDecay checks the flavour of the Hadron decays semi-leptonicall, if C-Hadron: true, if not: false
bool checkCHadronSLDecay(const MCP& SLDLepton);
bool checkCHadronSLDecay(const MCP& parentHadron);

// checkTauLeptonSLDecay checks the flavour of the Hadron decays semi-leptonicall, if tau-lepton: true, if not:
// false
bool checkTauLeptonSLDecay(const MCP& SLDLepton);
bool checkTauLeptonSLDecay(const MCP& parentHadron);

// doSLDCorrection prepares all inputs for nu-correction and makes output LCIO elements (SLDVertex, associated RP
// of SLDVertex, solutions for neutrino as Reconstructed Particle, etc)
virtual void doSLDCorrection(EVENT::LCEvent* pLCEvent, const MCP& SLDLepton, VertexVector& semiLeptonicVertices,
PFOVector& semiLeptonicVertexRecoParticles, PFOVector& jetsOfSemiLeptonicDecays,
PFOVectorVector& neutrinos, IntVector& sldStatus, IntVector& pvaStatus,
IntVector& solutionSigns, MCPVector& trueNeutrinos);
virtual void doSLDCorrection(EVENT::LCEvent* pLCEvent, const MCP& SLDLepton, size_t parentHadronIDx,
VertexVector& semiLeptonicVertices, PFOVector& semiLeptonicVertexRecoParticles,
PFOVector& jetsOfSemiLeptonicDecays, PFOVectorVector& neutrinos, IntVector& sldStatus,
IntVector& pvaStatus, IntVector& solutionSigns, MCPVector& trueNeutrinos);

// showTrueParameters prints true input for nu-correction
void showTrueParameters(const MCP& SLDLepton);
void showTrueParameters(const MCP& SLDLepton, size_t parentHadronIDx);

// getNeutrinoFourMomentum corrects neutrino energy using rapidity-based approach
TLorentzVector getNeutrinoFourMomentum(const TVector3& flightDirection, const TLorentzVector& visibleFourMomentum,
Expand All @@ -94,7 +93,7 @@ class SLDCorrection : public Processor {
const double& parentHadronMass, const float& solutionSign);

// getTrueNeutrinogets true four-momentum of neutrino
MCP getTrueNeutrino(const MCP& SLDLepton);
MCP getTrueNeutrino(const MCP& SLDLepton, size_t parent_idx);

// fillTrueRecoFourMomentummakes performance evaluation variables stored in root tree
void fillTrueRecoFourMomentum(
Expand Down Expand Up @@ -582,6 +581,6 @@ class SLDCorrection : public Processor {
TH1F* h_FlightDirectionError{};
TH1F* h_distRecoLeptonToDownStreamVertex{};
TFile* m_pTFile{};
TTree* m_pTTree1{};
TTree* m_pTTree1 = new TTree("SLDCorrection", "SLDCorrection");
};
#endif
8 changes: 6 additions & 2 deletions Analysis/SLDCorrection/src/FlightDirection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ int getRecoFlightDirection(const RecoParticle& linkedRecoLepton, TVector3& recoF
daughterHadronFlightDistance = 0.0;
daughterHadronFlightDirection = TVector3(0.0, 0.0, 0.0);
sldVertexPosition.clear();
if (linkedRecoLepton->getTracks().size() == 0) {
streamlog_out(DEBUG1) << " (" << SLDStatus << ") No track for linkedRecoLepton. SLDCorrection aborts."
<< std::endl;
return SLDStatus;
}

if (recoLeptonIsInVertex) {
SLDStatus = 4;
streamlog_out(DEBUG1) << " (" << SLDStatus
Expand Down Expand Up @@ -151,8 +157,6 @@ int getRecoFlightDirection(const RecoParticle& linkedRecoLepton, TVector3& recoF
// thirdVertex = testVertex;
// }
}
if (thirdVertex != NULL) {
}
} else {
streamlog_out(DEBUG1) << " There is NO BuildUp Vertex in jet" << std::endl;
streamlog_out(DEBUG1) << " Other scenarios are investigated, but Nu-correction will not be performed" << std::endl;
Expand Down
Loading
Loading