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 ()
 
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
 

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  , m_backupCalculator("BarrelCryostatCalibrationLArCalculator",name)
446  {
447  declareProperty("BackupCalculator",m_backupCalculator);
448  }

◆ ~CalibrationCalculator()

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

Definition at line 479 of file CryostatCalibrationCalculator.cxx.

480  {
481  // Cleanup pointers.
482  //delete m_backupCalculator;
483  //m_backupCalculator = 0;
484  }

Member Function Documentation

◆ initialize()

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

Definition at line 450 of file CryostatCalibrationCalculator.cxx.

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

◆ Process()

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

Definition at line 486 of file CryostatCalibrationCalculator.cxx.

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

Member Data Documentation

◆ m_backupCalculator

ServiceHandle<ILArCalibCalculatorSvc> LArG4::BarrelCryostat::CalibrationCalculator::m_backupCalculator
private

◆ m_energyCalculator

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

The documentation for this class was generated from the following files:
grepfile.info
info
Definition: grepfile.py:38
beamspotman.r
def r
Definition: beamspotman.py:676
test_pyathena.eta
eta
Definition: test_pyathena.py:10
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
LArG4::BarrelCryostat::CalibrationCalculator::m_energyCalculator
CaloG4::SimulationEnergies m_energyCalculator
Definition: LArG4Barrel/src/CryostatCalibrationCalculator.h:70
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:42
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
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:221
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