Skip to content
Snippets Groups Projects

WIP: Modify TupleToolL0Calo to take Neutrals

Open Adrian Casais Vidal requested to merge acasasiv/l0calo into run2-patches
Files
2
@@ -106,8 +106,8 @@ StatusCode TupleToolL0Calo::fill( const LHCb::Particle* /* mother */, const LHCb
bool test = true;
if ( !( P->isBasicParticle() ) ) return StatusCode( test );
const std::string prefix = fullName( head );
bool isneutral = ( P->particleID().pid() == 22 || P->particleID().pid() == 111 );
const std::string prefix = fullName( head );
double trackET, xProjection, yProjection;
@@ -129,8 +129,24 @@ StatusCode TupleToolL0Calo::fill( const LHCb::Particle* /* mother */, const LHCb
yProjection = m_part2calo->caloState().y();
double triggerET( -1. ), triggerHCALET( -1. ), xtrigger( 0. ), ytrigger( 0. );
if ( m_fillTriggerEt ) { triggerET = getAssociatedCluster( triggerHCALET, xtrigger, ytrigger ); }
if ( isneutral ) {
const LHCb::ProtoParticle* proto = P->proto();
auto hypos = proto->calo();
if ( hypos.size() > 0 && proto != NULL ) {
auto x = hypos[0]->position()->x();
auto y = hypos[0]->position()->y();
auto z = hypos[0]->position()->z();
auto E = hypos[0]->e();
// Calculate a few observables
trackET = TMath::Sqrt( TMath::Power( x, 2 ) + TMath::Power( y, 2 ) ) /
TMath::Sqrt( TMath::Power( x, 2 ) + TMath::Power( y, 2 ) + TMath::Power( z, 2 ) ) * E;
xProjection = x;
yProjection = y;
if ( m_fillTriggerEt ) { triggerET = getAssociatedCluster( x, y, xtrigger, ytrigger ); }
}
} else {
if ( m_fillTriggerEt ) { triggerET = getAssociatedCluster( triggerHCALET, xtrigger, ytrigger ); }
};
// Fill the tuple
if ( m_calo == "HCAL" ) {
@@ -285,3 +301,36 @@ double TupleToolL0Calo::getAssociatedCluster( double& hcal_energy, double& xTrig
return result;
}
double TupleToolL0Calo::getAssociatedCluster( double xCell, double yCell, double& xTrigger, double& yTrigger ) {
// loop over the L0 candidates
LHCb::L0CaloCandidates* candidates = getIfExists<LHCb::L0CaloCandidates>( m_location );
LHCb::L0CaloCandidates::iterator cand;
double result = -1.;
double higherPT = -1;
double minDistance2 = 999999;
const double distOffset = 200;
for ( cand = candidates->begin(); candidates->end() != cand; ++cand ) {
LHCb::L0CaloCandidate* theCand = ( *cand );
if ( ( theCand->type() == L0DUBase::CaloType::Photon ) || ( theCand->type() == L0DUBase::CaloType::Electron ) ) {
double xtrig = theCand->position().x();
double ytrig = theCand->position().y();
double distance2 = ( xCell - xtrig ) * ( xCell - xtrig ) + ( yCell - ytrig ) * ( yCell - ytrig );
bool condition =
( distance2 < distOffset * distOffset && distance2 < minDistance2 && ( theCand->et() > higherPT ) );
if ( condition ) {
xTrigger = xtrig;
yTrigger = ytrig;
result = theCand->et();
higherPT = result;
minDistance2 = distance2;
}
}
}
return result;
}
Loading