Skip to content
Snippets Groups Projects
Commit d6eede62 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Merge branch 'mveghel-hcalfix' into 'master'

Hcal pid fix

See merge request lhcb/Rec!3252
parents ae3ccab2 38a95dbb
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,7 @@ namespace LHCb::Calo { ...@@ -52,7 +52,7 @@ namespace LHCb::Calo {
int acceptance( LHCb::StateVector& state, MyState const& ref_state, DeCalorimeter const& calo, int acceptance( LHCb::StateVector& state, MyState const& ref_state, DeCalorimeter const& calo,
Gaudi::Plane3D const& plane, bool const fiducial ) { Gaudi::Plane3D const& plane, bool const fiducial ) {
// linear extrapolation to calo // linear extrapolation to calo
if ( !propagateToCalo<MyState>( state, ref_state, plane ) ) return 0; if ( !propagateToCalo( state, ref_state, plane ) ) return 0;
// check position // check position
const auto cell = calo.Cell_( state.position() ); const auto cell = calo.Cell_( state.position() );
if ( !cell || !cell->valid() ) { return 0; } if ( !cell || !cell->valid() ) { return 0; }
...@@ -65,7 +65,7 @@ namespace LHCb::Calo { ...@@ -65,7 +65,7 @@ namespace LHCb::Calo {
// incomplete neibours: border of 2 zones ? // incomplete neibours: border of 2 zones ?
return std::any_of( std::next( neighbours.begin() ), neighbours.end(), return std::any_of( std::next( neighbours.begin() ), neighbours.end(),
[area = cell->cellID().area()]( const auto& n ) { return n.area() != area; } ) [area = cell->cellID().area()]( const auto& n ) { return n.area() != area; } )
? LHCb::Detector::Calo::Index{cell->cellID()} ? cell->cellID().all()
: 0; : 0;
} }
......
...@@ -50,9 +50,9 @@ namespace LHCb::Calo { ...@@ -50,9 +50,9 @@ namespace LHCb::Calo {
// DLL parametrization locations // DLL parametrization locations
Gaudi::Property<std::string> m_histo_location{this, "HistLocation", "", Gaudi::Property<std::string> m_histo_location{this, "HistLocation", "",
"Histogram location for histoSvc/ParamFiles"}; "Histogram location for histoSvc/ParamFiles"};
Gaudi::Property<std::string> m_paramfiles_location{this, "ParamFilesLocation", Gaudi::Property<std::string> m_paramfiles_location{
"paramfile://data/CaloPID/DLLs_parametrization_histograms.root", this, "ParamFilesLocation", "paramfile://data/CaloPID/DLLs_parametrization_histograms_122022.root",
"Location of ROOT file for charged calo PID DLL histograms"}; "Location of ROOT file for charged calo PID DLL histograms"};
ServiceHandle<IFileAccess> m_file{this, "FileAccessor", "ParamFileSvc", "Service used to retrieve file contents"}; ServiceHandle<IFileAccess> m_file{this, "FileAccessor", "ParamFileSvc", "Service used to retrieve file contents"};
// DLL histograms // DLL histograms
......
...@@ -44,9 +44,9 @@ namespace LHCb::Calo { ...@@ -44,9 +44,9 @@ namespace LHCb::Calo {
// DLL parametrization locations // DLL parametrization locations
Gaudi::Property<std::string> m_histo_location{this, "HistLocation", "", Gaudi::Property<std::string> m_histo_location{this, "HistLocation", "",
"Histogram location for histoSvc/ParamFiles"}; "Histogram location for histoSvc/ParamFiles"};
Gaudi::Property<std::string> m_paramfiles_location{this, "ParamFilesLocation", Gaudi::Property<std::string> m_paramfiles_location{
"paramfile://data/CaloPID/DLLs_parametrization_histograms.root", this, "ParamFilesLocation", "paramfile://data/CaloPID/DLLs_parametrization_histograms_122022.root",
"Location of ROOT file for charged calo PID DLL histograms"}; "Location of ROOT file for charged calo PID DLL histograms"};
ServiceHandle<IFileAccess> m_file{this, "FileAccessor", "ParamFileSvc", "Service used to retrieve file contents"}; ServiceHandle<IFileAccess> m_file{this, "FileAccessor", "ParamFileSvc", "Service used to retrieve file contents"};
// DLL histograms // DLL histograms
......
...@@ -40,15 +40,23 @@ namespace LHCb::Calo { ...@@ -40,15 +40,23 @@ namespace LHCb::Calo {
float getEnergy( LHCb::StateVector const& state, CaloDigits const& digits, DeCalorimeter const& calo, float getEnergy( LHCb::StateVector const& state, CaloDigits const& digits, DeCalorimeter const& calo,
float const deltaZ, int const nPlanes ) { float const deltaZ, int const nPlanes ) {
float energy = 0.f; float energy = 0.f;
// cellid bookkeeping
auto prev_cellid = LHCb::Detector::Calo::CellID();
// scan at different planes in the calo // scan at different planes in the calo
auto position = state.position(); auto position = state.position();
auto const slopes = state.slopes(); auto const slopes = state.slopes();
for ( int i = 0; i < nPlanes; ++i ) { for ( int i = 0; i < nPlanes; ++i ) {
const auto cell = calo.Cell_( position ); const auto cell = calo.Cell_( position );
if ( !cell || !cell->valid() ) continue; if ( !cell || !cell->valid() ) continue;
const auto digit = digits( cell->cellID() ); // check if it is the same as last one
auto cellid = cell->cellID();
if ( prev_cellid == cellid ) continue;
// if not, add energy
const auto digit = digits( cellid );
if ( digit ) energy += digit->energy(); if ( digit ) energy += digit->energy();
// next position
position += deltaZ * slopes; position += deltaZ * slopes;
prev_cellid = cellid;
} }
return energy; return energy;
} }
...@@ -116,14 +124,14 @@ namespace LHCb::Calo { ...@@ -116,14 +124,14 @@ namespace LHCb::Calo {
// miscellaneous info // miscellaneous info
LHCb::StateVector calo_state; LHCb::StateVector calo_state;
auto const calo_front = calo.plane( CaloPlane::Front ); auto const calo_front = calo.plane( CaloPlane::Front );
float const calo_zsize = calo.zSize(); float const calo_dz = calo.zSize() / ( m_nplanes > 1 ? m_nplanes - 1 : m_nplanes.value() );
// loop over input tracks // loop over input tracks
for ( auto const& trackincalo : tracksincalo.scalar() ) { for ( auto const& trackincalo : tracksincalo.scalar() ) {
auto track = trackincalo.from(); auto track = trackincalo.from();
auto ref_state = track.state( state_loc.value() ); auto ref_state = track.state( state_loc.value() );
if ( !propagateToCalo( calo_state, ref_state, calo_front ) ) continue; if ( !propagateToCalo( calo_state, ref_state, calo_front ) ) continue;
float energy = getEnergy( calo_state, digits, calo, calo_zsize, m_nplanes ); float energy = getEnergy( calo_state, digits, calo, calo_dz, m_nplanes );
// save result for this index in tracks // save result for this index in tracks
output_table.add( track, energy ); output_table.add( track, energy );
// statistics // statistics
...@@ -153,6 +161,7 @@ namespace LHCb::Calo { ...@@ -153,6 +161,7 @@ namespace LHCb::Calo {
: TrackToCaloEnergyAlg<TracksInHcal, TracksHcalEnergy>( name, pSvc ) { : TrackToCaloEnergyAlg<TracksInHcal, TracksHcalEnergy>( name, pSvc ) {
updateHandleLocation( *this, "Calorimeter", CaloFutureAlgUtils::DeCaloFutureLocation( "Hcal" ) ); updateHandleLocation( *this, "Calorimeter", CaloFutureAlgUtils::DeCaloFutureLocation( "Hcal" ) );
updateHandleLocation( *this, "Digits", CaloDigitLocation::Hcal ); updateHandleLocation( *this, "Digits", CaloDigitLocation::Hcal );
setProperty( "nPlanes", 5 ).ignore();
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment