Skip to content
Snippets Groups Projects

Modification of BkgCat behaviour to not throw exception

Merged Vava Gligorov requested to merge vava_bkgcat_noexception into master
2 files
+ 40
7
Compare changes
  • Side-by-side
  • Inline
Files
2
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* (c) Copyright 2000-2019 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
@@ -73,6 +73,11 @@ BackgroundCategory::category( const LHCb::Particle* reconstructed_mother,
//all the categories mean, please visit IBackgroundCategory.h
{
//Set the global variable used to jump out with status Undefined to false
//this is used because the places where we may need to signal Undefined are
//in recursive code which is difficult to exit elegantly without a global flag
m_undefined = false;
//Check if the tool was actually given a particle to categorise
if ( !reconstructed_mother )
{
@@ -163,6 +168,8 @@ BackgroundCategory::category( const LHCb::Particle* reconstructed_mother,
// "physics" backgrounds (meaning we have reconstructed some actual decay
// that occured, even if not the one we were after).
if (isTheDecayFullyReconstructed(mc_particles_linked_to_decay) ) {
if (m_undefined)
return {Undefined, LogicError};
if (msgLevel(MSG::VERBOSE)) verbose() << "Checked if fully reconstructed" << endmsg;
if (areAllFinalStateParticlesCorrectlyIdentified(particles_in_decay,
mc_particles_linked_to_decay) ) {
@@ -170,10 +177,14 @@ BackgroundCategory::category( const LHCb::Particle* reconstructed_mother,
if (isTheMotherCorrectlyIdentified(reconstructed_mother) ) {
if (msgLevel(MSG::VERBOSE)) verbose() << "Checked if correct mother" << endmsg;
if (!wereAnyResonancesMissed(reconstructed_mother) ) {
if (m_undefined)
return {Undefined, LogicError};
if (msgLevel(MSG::VERBOSE)) verbose() << "This is signal" << endmsg;
//This is a signal decay
return {Signal, Good};
} else {
if (m_undefined)
return {Undefined, LogicError};
if (msgLevel(MSG::VERBOSE)) verbose() << "This is quasi-signal" << endmsg;
//This is a quasi-signal decay
return {QuasiSignal, Good};
@@ -191,6 +202,8 @@ BackgroundCategory::category( const LHCb::Particle* reconstructed_mother,
}
else
{
if (m_undefined)
return {Undefined, LogicError};
if (msgLevel(MSG::VERBOSE)) verbose() << "Is it an inclusive decay?" << endmsg;
if ( m_inclusiveDecay )
{
@@ -381,8 +394,13 @@ int BackgroundCategory::topologycheck(const LHCb::MCParticle* topmother)
//Check for an MCMother with a null endvertex -- really shouldn't happen
//here though, but the Cat is often betrayed by other pieces of code...
const SmartRefVector<LHCb::MCVertex>& motherEndVertices = topmother->endVertices();
if ( motherEndVertices.empty() )
Exception("The Cat found a common MC mother but it has no daughters, please report this as a bug.");
if ( motherEndVertices.empty() ) {
Warning("The Cat found a common MC mother but it has no daughters!"\
"You may be trying to process an input file which does not"\
"contain the necessary information, returning Undefined.");
m_undefined = true;
return -1;
}
//Assuming all went well...
//We need to find the first end vertex which is actually a decay vertex
SmartRefVector<LHCb::MCVertex>::const_iterator iV;
@@ -522,8 +540,13 @@ BackgroundCategory::create_finalstatedaughterarray_for_mcmother(const LHCb::MCPa
//Check for an MCMother with a null endvertex -- really shouldn't happen
//here though, but the Cat is often betrayed by other pieces of code...
const SmartRefVector<LHCb::MCVertex>& motherEndVertices = topmother->endVertices();
if (motherEndVertices.empty() )
Exception("The Cat found a common MC mother but it has no daughters, please report this as a bug.");
if (motherEndVertices.empty() ) {
Warning("The Cat found a common MC mother but it has no daughters!"\
"You may be trying to process an input file which does not"\
"contain the necessary information, returning Undefined.");
m_undefined = true;
return finalstateproducts;
}
//Assuming all went well...
//We need to find the first end vertex which is actually a decay vertex
SmartRefVector<LHCb::MCVertex>::const_iterator iV;
@@ -947,7 +970,11 @@ bool BackgroundCategory::isTheDecayFullyReconstructed(const MCParticleVector & m
int neutrinosFound = 0;
MCParticleVector finalstateproducts = create_finalstatedaughterarray_for_mcmother(m_commonMother);
MCParticleVector::const_iterator iPP = finalstateproducts.begin();
if (finalstateproducts.empty() ) Exception("Condition B : No final states, please report the bug.");
if (finalstateproducts.empty() ) {
Warning("Common MC mother has empty daughters array, returning Undefined").ignore();
m_undefined = true;
return false;
}
MCParticleVector::const_iterator iP = mc_particles_linked_to_decay.begin();
//Because of the special case of the merged pi0, the only non stable particle made without any
@@ -973,6 +1000,11 @@ bool BackgroundCategory::isTheDecayFullyReconstructed(const MCParticleVector & m
//this is only relevant for checking condition B, which is why
//we use a temp array to do it
merged_pi0_daughters = create_finalstatedaughterarray_for_mcmother(*iP);
if (merged_pi0_daughters.empty() ) {
Warning("Merged Pi0 has empty daughters array, returning Undefined").ignore();
m_undefined = true;
return false;
}
mc_particles_linked_to_decay_without_pi0.insert(
mc_particles_linked_to_decay_without_pi0.end(),
merged_pi0_daughters.begin(),
Loading