ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
LArG4::BarrelCryostat::CalibrationCalculator Class Reference

#include <CryostatCalibrationCalculator.h>

Inheritance diagram for LArG4::BarrelCryostat::CalibrationCalculator:
Collaboration diagram for LArG4::BarrelCryostat::CalibrationCalculator:

Public Member Functions

 CalibrationCalculator (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize () override final
 
virtual ~CalibrationCalculator ()=default
 
virtual G4bool Process (const G4Step *step, LArG4Identifier &identifier, std::vector< G4double > &energies, const eCalculatorProcessing process=kEnergyAndID) const override final
 

Private Attributes

CaloG4::SimulationEnergies m_energyCalculator {}
 
ServiceHandle< ILArCalibCalculatorSvcm_backupCalculator {this, "BackupCalculator", "BarrelCryostatCalibrationLArCalculator"}
 

Detailed Description

Definition at line 45 of file LArG4Barrel/src/CryostatCalibrationCalculator.h.

Constructor & Destructor Documentation

◆ CalibrationCalculator()

LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 443 of file CryostatCalibrationCalculator.cxx.

444  : LArCalibCalculatorSvcImp(name, pSvcLocator)
445  {
446  }

◆ ~CalibrationCalculator()

virtual LArG4::BarrelCryostat::CalibrationCalculator::~CalibrationCalculator ( )
virtualdefault

Member Function Documentation

◆ initialize()

StatusCode LArG4::BarrelCryostat::CalibrationCalculator::initialize ( )
finaloverride

Definition at line 448 of file CryostatCalibrationCalculator.cxx.

448  {
449  // Get the "backup" calculator.
450  ATH_CHECK(m_backupCalculator.retrieve());
451 
452 #if defined (DEBUG_HITS) || defined (DEBUG_MAPS)
453  G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - "
454  << " numberOfVolumes=" << numberOfVolumes
455  << ", sizeof(volumes)=" << sizeof(volumes)
456  << ", sizeof(VolumeInfo_t)=" << sizeof(VolumeInfo_t)
457  << G4endl;
458 #endif
459 
460  // Intialize the maps.
461  volumeMap();
462 
463 
464 
465 #if defined (DEBUG_HITS) || defined (DEBUG_MAPS)
466  G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - "
467  << G4endl
468  << " initialization complete; map size="
469  << volumeMap().size()
470  << G4endl;
471 #endif
472 
473  return StatusCode::SUCCESS;
474  }

◆ Process()

G4bool LArG4::BarrelCryostat::CalibrationCalculator::Process ( const G4Step *  step,
LArG4Identifier identifier,
std::vector< G4double > &  energies,
const eCalculatorProcessing  process = kEnergyAndID 
) const
finaloverridevirtual

Definition at line 476 of file CryostatCalibrationCalculator.cxx.

479  {
480  // Use the calculators to determine the energies and the
481  // identifier associated with this G4Step. Note that the
482  // default is to process both the energy and the ID.
483 
484  if ( process == kEnergyAndID || process == kOnlyEnergy ) {
485  m_energyCalculator.Energies( step, energies );
486  }
487  else {
488  for (unsigned int i=0; i != 4; i++) energies.push_back( 0. );
489  }
490 
491  identifier.clear();
492  if ( process == kEnergyAndID || process == kOnlyID )
493  {
494  // Calculate the identifier.
495 
496  // First, find the physical volume copy number, and the
497  // logical volume name.
498 
499  G4VPhysicalVolume* physical = step->GetPreStepPoint()->GetPhysicalVolume();
500  G4int copyNumber = physical->GetCopyNo();
501  G4String volumeName = physical->GetLogicalVolume()->GetName();
502 
503 #ifdef DEBUG_HITS
504  G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - "
505  << G4endl
506  << " searching for volume '"
507  << volumeName
508  << "' copyNumber="
509  << copyNumber
510  << G4endl;
511 #endif
512 
513  if(volumeName.find("LArMgr::") == 0) volumeName.erase(0,8);
514  if(volumeName.find("LAr::Barrel::Cryostat::Sector")==0) { // ears, legs, Ti blocks
515  volumeName = "LAr::Barrel::Cryostat::Sector";
516  if(copyNumber != 7 && copyNumber !=12) copyNumber=1; // assignment arbitrary copyNumber to Ti block
517  }else if(volumeName.find("LAr::Barrel::Cryostat::Cylinder")==0){
518  volumeName = "LAr::Barrel::Cryostat::Cylinder";
519  }else if(volumeName.find("LAr::Barrel::Cryostat::InnerWall")==0){
520  volumeName = "LAr::Barrel::Cryostat::InnerWall";
521  copyNumber = 1; // assignment arbitrary copyNumber
522  }
523 
524  // Search the maps for this volume/copy number combination.
525  const auto v = volumeMap().find( volumeName );
526  if ( v != volumeMap().end() )
527  {
528 
529  // Recall that maps are made from pair <key,value>, and
530  // you access a pair with the "first" and "second"
531  // members. In this case, "second" is a map. We don't
532  // need to copy the entire map; it's enough to get its
533  // reference.
534 
535  const identifierMap_t& identifierMap = (*v).second;
536  const auto i = identifierMap.find( copyNumber );
537 
538  if ( i != identifierMap.end() )
539  {
540  const IdentifierInfo_t* info = (*i).second;
541 
542  // Find our (x,y,z) location from the G4Step.
543 
544  G4StepPoint* pre_step_point = step->GetPreStepPoint();
545  G4StepPoint* post_step_point = step->GetPostStepPoint();
546  G4ThreeVector startPoint = pre_step_point->GetPosition();
547  G4ThreeVector endPoint = post_step_point->GetPosition();
548  G4ThreeVector p = (startPoint + endPoint) * 0.5;
549 
550  // Determine the geometric eta and phi. Note that we do not
551  // adjust for any endcap shifts; the values are assigned to
552  // the volumes based on their design positions.
553 
554  G4double eta = fabs( p.pseudoRapidity() );
555  G4double phi = p.phi();
556  // For this calculation, we need 0<phi<2*PI. (The
557  // official ATLAS standard of -PI<phi<PI is
558  // meaningless here.)
559  if ( phi < 0 ) phi += 2*M_PI;
560 
561  // The region can depend on eta. Search through the
562  // list of regions within this IdentifierInfo record
563  // to find which one has etaMin<eta<etaMax.
564 
565  G4int regions = info->numberOfRegions;
566  const RegionInfo_t* region = info->regionInfoArray;
567 
568 #ifdef DEBUG_HITS
569  G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - "
570  << G4endl
571  << " found volume, number of regions="
572  << regions
573  << " eta=" << eta << " phi=" << phi
574  << G4endl;
575 #endif
576 
577  G4int r;
578  for ( r = 0; r < regions; r++, region++ )
579  {
580  if ( eta > region->etaMin &&
581  eta < region->etaMax )
582  break;
583  }
584 
585  // If the following statement is not true, we're in
586  // trouble. It means that the eta of our energy
587  // deposit is outside the assumed eta limits of the
588  // volume.
589 
590  if ( r < regions )
591  {
592  // Convert eta and phi to their integer equivalents for the
593  // identifier.
594 
595  G4int etaInteger = G4int( (eta - region->etaMin) / region->deltaEta );
596  G4int phiInteger = G4int( phi / region->deltaPhi );
597  // phiInteger should be less than 64
598  if (phiInteger > 63) phiInteger = 0;
599 
600 #ifdef DEBUG_HITS
601  G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - "
602  << G4endl
603  << " found region="
604  << region->regionNumber
605  << " eta bin=" << etaInteger << " phi bin=" << phiInteger
606  << G4endl;
607 #endif
608 
609  // The sign of subdet will depend on whether z is positive
610  // or negative.
611  G4int subDetSign = 1;
612  if ( p.z() < 0 ) subDetSign = -1;
613 
614  // A quick check against a bad value of etaMin.
615  if ( etaInteger >= 0 )
616  {
617  // Build the full identifier.
618  identifier << info->detector
619  << info->subdet * subDetSign
620  << info->type
621  << info->sampling
622  << region->regionNumber
623  << etaInteger
624  << phiInteger;
625 
626  } // etaInteger valid
627  } // eta valid
628  } // copy number valid
629  } // volume name valid
630 
631  // If a volume is not found on one of the above tables, try
632  // the "backup identifier" calculator.
633 
634  if ( identifier == LArG4Identifier() )
635  {
636 #if defined (DEBUG_HITS) || defined (DEBUG_VOLUMES)
637  std::cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process"
638  << std::endl
639  << " volume '"
640  << volumeName
641  << "' copy# "
642  << copyNumber
643  << " not found on tables, using backup calculator"
644  << std::endl;
645 #endif
646  m_backupCalculator->Process(step, identifier, energies, process);
647  }
648  } // calculate identifier
649 
650 #ifdef DEBUG_HITS
651  //G4double energy = accumulate(energies.begin(),energies.end(),0.);
652  std::cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process"
653  << " vName " << step->GetPreStepPoint()->GetPhysicalVolume()->GetName()
654  << " ID=" << std::string(identifier)
655  // << " energy=" << energy
656  << " energies=(" << energies[0]
657  << "," << energies[1]
658  << "," << energies[2]
659  << "," << energies[3] << ")"
660  << std::endl;
661 #endif
662 
663  // Check for bad result.
664  return ( identifier != LArG4Identifier() );
665  }

Member Data Documentation

◆ m_backupCalculator

ServiceHandle<ILArCalibCalculatorSvc> LArG4::BarrelCryostat::CalibrationCalculator::m_backupCalculator {this, "BackupCalculator", "BarrelCryostatCalibrationLArCalculator"}
private

◆ m_energyCalculator

CaloG4::SimulationEnergies LArG4::BarrelCryostat::CalibrationCalculator::m_energyCalculator {}
private

The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:672
CaloG4::SimulationEnergies::Energies
void Energies(const G4Step *, std::vector< G4double > &) const
The simple method to call from a calibration calculator: Examine the G4Step and return the energies r...
LArG4Identifier
Definition: LArG4Identifier.h:121
LArG4::BarrelCryostat::volumeMap
const volumeMap_t & volumeMap()
volumeMap singleton
Definition: CryostatCalibrationCalculator.cxx:379
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
LArG4::BarrelCryostat::CalibrationCalculator::m_energyCalculator
CaloG4::SimulationEnergies m_energyCalculator
Definition: LArG4Barrel/src/CryostatCalibrationCalculator.h:70
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
LArG4::kOnlyEnergy
@ kOnlyEnergy
Definition: LArG4EnumDefs.h:10
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:43
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCalibCalculatorSvcImp::LArCalibCalculatorSvcImp
LArCalibCalculatorSvcImp(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArCalibCalculatorSvcImp.cxx:7
LArG4::BarrelCryostat::identifierMap_t
std::map< G4int, const IdentifierInfo_t * > identifierMap_t
Definition: CryostatCalibrationCalculator.cxx:372
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArG4::kOnlyID
@ kOnlyID
Definition: LArG4EnumDefs.h:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
python.PyAthena.v
v
Definition: PyAthena.py:154
LArCellBinning.step
step
Definition: LArCellBinning.py:158
LArG4::kEnergyAndID
@ kEnergyAndID
Definition: LArG4EnumDefs.h:10
LArG4::BarrelCryostat::CalibrationCalculator::m_backupCalculator
ServiceHandle< ILArCalibCalculatorSvc > m_backupCalculator
Definition: LArG4Barrel/src/CryostatCalibrationCalculator.h:74
python.ParticleTypeUtil.info
def info
Definition: ParticleTypeUtil.py:87