Skip to content
Snippets Groups Projects

CALO_DD4HEP

Merged Daniele Manuzzi requested to merge dmanuzzi_CALO_DD4HEP into master
Compare and
9 files
+ 1024
877
Compare changes
  • Side-by-side
  • Inline
Files
9
@@ -576,9 +576,9 @@ namespace LHCb::Detector::Calo {
}
// ============================================================================
/** return parameters of cell, which contains the global point.
* the function shodul be a bit more fast and efficent,
* the function should be a bit more fast and efficient,
* @param globalPoint point to be checked
* @return cell parameters (null if point is not in Calorimter
* @return cell parameters (null if point is not in Calorimeter)
*/
// ============================================================================
const CellParam* Cell_( const ROOT::Math::XYZPoint& globalPoint ) const {
@@ -603,7 +603,7 @@ namespace LHCb::Detector::Calo {
int side = ( sub.id() == 1 ) ? -1 : +1; // ID, Left:0 , Right: 1
// find sub subcalorimeter - assumes they are sorted from the beamline outwards (Inner, Middle, Outer)
const dd4hep::DetElement::Children& subSubCalos = ( *i ).second.children();
const dd4hep::DetElement::Children& subSubCalos = sub.children();
for ( dd4hep::DetElement::Children::const_iterator j = subSubCalos.begin(); j != subSubCalos.end(); ++j ) {
dd4hep::DetElement subSub = ( *j ).second;
@@ -727,5 +727,122 @@ namespace LHCb::Detector::Calo {
int pileUpSubstractionMethod() const { return this->access()->puMeth; }
int pileUpSubstractionBin() const { return this->access()->puBin; }
int pileUpSubstractionMin() const { return this->access()->puMin; }
CellID cellIDfromVolumeID( const dd4hep::DDSegmentation::VolumeID& volumeID ) const {
// decode the volume ID
const unsigned int detectorMask = ( ( ( (unsigned int)1 ) << 8 ) - 1 ) << 0;
const unsigned int detectorID = ( volumeID & detectorMask );
if ( detectorID == 60 ) {
if ( this->index() != CellCode::Index::EcalCalo ) {
dd4hep::printout( dd4hep::ERROR, "DeCalorimeter",
"The volumeID says this DeCalorimeter object is a Ecal, while its 'index' is %d.\nThere's "
"probabaly an error in the decoding of the volumeID\n",
this->index() );
}
return cellIDfromVolumeID_ECAL( volumeID );
} else if ( detectorID == 70 ) {
if ( this->index() != CellCode::Index::HcalCalo ) {
dd4hep::printout( dd4hep::ERROR, "DeCalorimeter",
"The volumeID says this DeCalorimeter object is a Hcal, while its 'index' is %d.\nThere's "
"probabaly an error in the decoding of the volumeID\n",
this->index() );
}
return cellIDfromVolumeID_HCAL( volumeID );
} else {
dd4hep::printout( dd4hep::ERROR, "DeCalorimeter",
"The volumeID says this DeCalorimeter object is a neither and Ecal or a Hcal.\nThere's "
"probabaly an error in the decoding of the volumeID\n" );
return CellID();
}
}
CellID cellIDfromVolumeID_ECAL( const dd4hep::DDSegmentation::VolumeID& volumeID ) const {
const unsigned int sideMask = ( ( ( (unsigned int)1 ) << 1 ) - 1 ) << 8;
const unsigned int regionMask = ( ( ( (unsigned int)1 ) << 2 ) - 1 ) << 9;
const unsigned int blockMask = ( ( ( (unsigned int)1 ) << 6 ) - 1 ) << 11;
const unsigned int moduleMask = ( ( ( (unsigned int)1 ) << 5 ) - 1 ) << 17;
const unsigned int cellMask = ( ( ( (unsigned int)1 ) << 4 ) - 1 ) << 22;
const unsigned int sideID = ( volumeID & sideMask ) >> 8;
const unsigned int regionID = ( volumeID & regionMask ) >> 9;
const unsigned int blockID = ( volumeID & blockMask ) >> 11;
const unsigned int moduleID = ( volumeID & moduleMask ) >> 17;
const unsigned int cellID = ( volumeID & cellMask ) >> 22;
unsigned int region = regionID;
unsigned int row = 0;
unsigned int col = 0;
if ( region == 2 ) {
unsigned int row_inModule = cellID % 3;
unsigned int col_inModule = cellID / 3;
unsigned int row_inBlock = moduleID % 2;
unsigned int col_inBlock = moduleID / 2;
unsigned int row_inRegion = blockID;
unsigned int col_offset = ( sideID ? 8 : 32 );
unsigned int row_offset = 14;
row = row_inModule + 3 * row_inBlock + 6 * row_inRegion + row_offset;
col = col_inModule + 3 * col_inBlock + col_offset;
if ( col > 23 && col < 40 && row > 25 && row < 38 )
return LHCb::Detector::Calo::CellID(); // mask the not instrumented central cells
} else if ( region == 1 ) {
unsigned int row_inModule = cellID % 2;
unsigned int col_inModule = cellID / 2;
unsigned int row_inBlock = moduleID % 2;
unsigned int col_inBlock = moduleID / 2;
unsigned int row_inRegion = blockID % 10;
unsigned int col_inRegion = blockID / 10;
unsigned int col_offset = ( sideID ? 0 : 32 );
unsigned int row_offset = 12;
row = row_inModule + 2 * row_inBlock + 4 * row_inRegion + row_offset;
col = col_inModule + 2 * col_inBlock + 16 * col_inRegion + col_offset;
} else if ( region == 0 ) {
unsigned int row_inBlock = moduleID % 2;
unsigned int col_inBlock = moduleID / 2;
unsigned int row_inRegion = blockID % 26;
unsigned int col_inRegion = blockID / 26;
unsigned int col_offset = ( sideID ? 0 : 32 );
unsigned int row_offset = 6;
row = row_inBlock + 2 * row_inRegion + row_offset;
col = col_inBlock + 16 * col_inRegion + col_offset;
}
return CellID( this->index(), region, row, col );
}
CellID cellIDfromVolumeID_HCAL( const dd4hep::DDSegmentation::VolumeID& volumeID ) const {
// decode the volumeID
const unsigned int sideMask = ( ( ( (unsigned int)1 ) << 1 ) - 1 ) << 8;
const unsigned int regionMask = ( ( ( (unsigned int)1 ) << 1 ) - 1 ) << 9;
const unsigned int moduleMask = ( ( ( (unsigned int)1 ) << 7 ) - 1 ) << 10;
const unsigned int submoduleMask = ( ( ( (unsigned int)1 ) << 4 ) - 1 ) << 17;
const unsigned int cellMask = ( ( ( (unsigned int)1 ) << 3 ) - 1 ) << 21;
const unsigned int sideID = ( volumeID & sideMask ) >> 8;
const unsigned int regionID = ( volumeID & regionMask ) >> 9;
const unsigned int moduleID = ( volumeID & moduleMask ) >> 10;
const unsigned int submoduleID = ( volumeID & submoduleMask ) >> 17;
const unsigned int cellID = ( volumeID & cellMask ) >> 21;
unsigned int region = regionID;
unsigned int row = 0;
unsigned int col = 0;
if ( region == 1 ) {
unsigned int row_inSubmodule = cellID % 2;
unsigned int col_inSubmodule = cellID / 2;
unsigned int col_inModule = submoduleID;
unsigned int row_inRegion = moduleID;
unsigned int col_offset = ( sideID ? 0 : 16 );
unsigned int row_offset = 2;
row = row_inSubmodule + 2 * row_inRegion + row_offset;
col = col_inSubmodule + 2 * col_inModule + col_offset;
// if ( col > 13 && col < 18 && row > 13 && row < 18 ) return CellID(); //<--unnecessary since no HCAL cell is present in this region
} else if ( region == 0 ) {
unsigned int col_inModule = submoduleID;
unsigned int row_inRegion = moduleID % 26;
unsigned int col_inRegion = moduleID / 26;
unsigned int col_offset = ( sideID ? 0 : 16 );
unsigned int row_offset = 3;
row = row_inRegion + row_offset;
col = col_inModule + 8 * col_inRegion + col_offset;
}
return CellID( this->index(), region, row, col );
}
};
} // End namespace LHCb::Detector::Calo
Loading