ATLAS Offline Software
Loading...
Searching...
No Matches
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, LArG4Identifier &identifier_sr, std::vector< double > &energies, const LArG4::eCalculatorProcessing process) const override final

Private Attributes

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

Detailed Description

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 }
LArCalibCalculatorSvcImp(const std::string &name, ISvcLocator *pSvcLocator)

◆ ~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 }
#define ATH_CHECK
Evaluate an expression and check for errors.
const volumeMap_t & volumeMap()
volumeMap singleton
static const VolumeInfo_t volumes[]

◆ Process()

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

Definition at line 476 of file CryostatCalibrationCalculator.cxx.

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

Member Data Documentation

◆ m_backupCalculator

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

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

76{this, "BackupCalculator", "BarrelCryostatCalibrationLArCalculator"};

◆ m_energyCalculator

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

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

72{};

The documentation for this class was generated from the following files: