ATLAS Offline Software
Loading...
Searching...
No Matches
FCALFastSimDedicatedSD.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
11#include "GeoModelKernel/GeoTubs.h"
13#include "CLHEP/Geometry/Transform3D.h"
14#include "CLHEP/Geometry/Point3D.h"
16
17using HepGeom::Transform3D;
18using HepGeom::Point3D;
19
20// Constructor:
22 : IFastSimDedicatedSD("FCALFastSimDedicatedSD", detStore)
23 , m_fcalManager(nullptr)
24{
25 if (verbose) { G4cout << GetName() << "::initialize()" << G4endl; }
26 if ( detStore->retrieve(m_fcalManager).isFailure() ){
27 throw std::runtime_error("Could not retrieve FCAL manager");
28 }
29}
30
31// ProcessHitsMethod
32void FCALFastSimDedicatedSD::ProcessSpot(const EnergySpot & spot, double weight){
33 // Fill the identifier.
34
35 static const Transform3D xfNeg[3] = {
36 Amg::EigenTransformToCLHEP(m_fcalManager->getFCAL(FCALModule::Module(1),FCALModule::Endcap(0))->getAbsoluteTransform().inverse()),
37 Amg::EigenTransformToCLHEP(m_fcalManager->getFCAL(FCALModule::Module(2),FCALModule::Endcap(0))->getAbsoluteTransform().inverse()),
38 Amg::EigenTransformToCLHEP(m_fcalManager->getFCAL(FCALModule::Module(3),FCALModule::Endcap(0))->getAbsoluteTransform().inverse())};
39
40 static const Transform3D xfPos[3] = {
41 Amg::EigenTransformToCLHEP(m_fcalManager->getFCAL(FCALModule::Module(1),FCALModule::Endcap(1))->getAbsoluteTransform().inverse()),
42 Amg::EigenTransformToCLHEP(m_fcalManager->getFCAL(FCALModule::Module(2),FCALModule::Endcap(1))->getAbsoluteTransform().inverse()),
43 Amg::EigenTransformToCLHEP(m_fcalManager->getFCAL(FCALModule::Module(3),FCALModule::Endcap(1))->getAbsoluteTransform().inverse())};
44
45 static const GeoTubs * const fcalTubs[3] = {
46 (const GeoTubs *) m_fcalManager->getFCAL(FCALModule::Module(1),FCALModule::Endcap(0))->getMaterialGeom()->getLogVol()->getShape(),
47 (const GeoTubs *) m_fcalManager->getFCAL(FCALModule::Module(2),FCALModule::Endcap(0))->getMaterialGeom()->getLogVol()->getShape(),
48 (const GeoTubs *) m_fcalManager->getFCAL(FCALModule::Module(3),FCALModule::Endcap(0))->getMaterialGeom()->getLogVol()->getShape()};
49
50
51 // Fill the identifier.
52 Point3D<double> globalPosition=spot.GetPosition();
53
54 // Figure out if it is in the positive endcap or the netative endcap:
55 bool iAmPositive=globalPosition.z()>0.;
56 int module=1;
57 Point3D<double> localPosition= iAmPositive ? (xfPos[0]*globalPosition) : (xfNeg[0]*globalPosition);
58 if (fabs(localPosition.z()) > fcalTubs[0]->getZHalfLength()) {
59 module=2;
60 localPosition= iAmPositive ? (xfPos[1]*globalPosition) : (xfNeg[1]*globalPosition);
61 if (fabs(localPosition.z()) > fcalTubs[1]->getZHalfLength()) {
62 module=3;
63 localPosition= iAmPositive ? (xfPos[2]*globalPosition) : (xfNeg[2]*globalPosition);
64 if (fabs(localPosition.z()) > fcalTubs[2]->getZHalfLength()) {
65 module=0;
66 }
67 }
68 }
69
70 if (!module) {
71 // std::cout << "Warning in FCALFastSimDedicatedSD: Cannot locate module" << std::endl;
72 return;
73 }
74
75 const FCAL_ChannelMap *cmap = m_fcalManager->getChannelMap();
76 int sampling=module;
77 int etaIndex=0, phiIndex=0;
78 bool ok = cmap->getTileID(sampling,
79 localPosition.x(),
80 localPosition.y(),
81 etaIndex,
82 phiIndex);
83
84
85 // zSide is negative if z<0.
86 int zSide = iAmPositive ? 2:-2;
87 //static LArG4Identifier id;
88 m_larID.clear();
89 if (ok){
90 m_larID << 4 // LArCalorimeter
91 << 3 // LArFCAL
92 << zSide // EndCap
93 << sampling // FCal Module #
94 << etaIndex
95 << phiIndex;
96 } else {
97 return;
98 }
99
100 // call process to add this to the collection
101 SimpleHit(m_larID, spot.GetTime(), spot.GetEnergy()*weight);
102 return;
103}
Eigen::Affine3d Transform3D
G4ThreeVector GetPosition() const
Definition EnergySpot.h:40
G4double GetEnergy() const
Definition EnergySpot.h:37
G4double GetTime() const
Definition EnergySpot.h:43
FCALDetectorManager * m_fcalManager
virtual void ProcessSpot(const EnergySpot &spot, double weight) override final
ProcessHitsMethod.
LArG4Identifier m_larID
My LAr identifier.
FCALFastSimDedicatedSD(StoreGateSvc *, bool verbose)
This class contains the tube and tile maps for the FCAL A tile is of a set of FCAL tubes.
bool getTileID(int isam, float x, float y, int &eta, int &phi) const
-— For the new LArFCAL_ID Identifier
IFastSimDedicatedSD(const std::string &name, StoreGateSvc *detStore)
Simple constructor and destructor.
G4bool SimpleHit(const LArG4Identifier &lar_id, G4double time, G4double energy)
First method translates to this - also for fast sims.
The Athena Transient Store API.
bool verbose
Definition hcg.cxx:73
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.