ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MicromegasSensitiveDetector Class Reference

#include <MicromegasSensitiveDetector.h>

Inheritance diagram for MicromegasSensitiveDetector:
Collaboration diagram for MicromegasSensitiveDetector:

Public Member Functions

 MicromegasSensitiveDetector (const std::string &name, const std::string &hitCollectionName)
 construction/destruction More...
 
 ~MicromegasSensitiveDetector ()
 
void Initialize (G4HCofThisEvent *HCE) override final
 member functions More...
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist) override final
 

Private Member Functions

 FRIEND_TEST (MicromegasSensitiveDetectortest, Initialize)
 
 FRIEND_TEST (MicromegasSensitiveDetectortest, ProcessHits)
 

Private Attributes

SG::WriteHandle< MMSimHitCollectionm_MMSimHitCollection
 
const MicromegasHitIdHelperm_muonHelper
 

Detailed Description

Definition at line 15 of file MicromegasSensitiveDetector.h.

Constructor & Destructor Documentation

◆ MicromegasSensitiveDetector()

MicromegasSensitiveDetector::MicromegasSensitiveDetector ( const std::string &  name,
const std::string &  hitCollectionName 
)

construction/destruction

Definition at line 18 of file MicromegasSensitiveDetector.cxx.

19  : G4VSensitiveDetector( name )
20  , m_MMSimHitCollection( hitCollectionName )
21 {
23  //m_muonHelper->PrintFields();
24 }

◆ ~MicromegasSensitiveDetector()

MicromegasSensitiveDetector::~MicromegasSensitiveDetector ( )
inline

Definition at line 22 of file MicromegasSensitiveDetector.h.

22 {}

Member Function Documentation

◆ FRIEND_TEST() [1/2]

MicromegasSensitiveDetector::FRIEND_TEST ( MicromegasSensitiveDetectortest  ,
Initialize   
)
private

◆ FRIEND_TEST() [2/2]

MicromegasSensitiveDetector::FRIEND_TEST ( MicromegasSensitiveDetectortest  ,
ProcessHits   
)
private

◆ Initialize()

void MicromegasSensitiveDetector::Initialize ( G4HCofThisEvent *  HCE)
finaloverride

member functions

Definition at line 27 of file MicromegasSensitiveDetector.cxx.

28 {
29  if (!m_MMSimHitCollection.isValid()) m_MMSimHitCollection = std::make_unique<MMSimHitCollection>();
30 }

◆ ProcessHits()

G4bool MicromegasSensitiveDetector::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
finaloverride

Definition at line 32 of file MicromegasSensitiveDetector.cxx.

33 {
34  G4Track* currentTrack = aStep->GetTrack();
35  int charge=currentTrack->GetDefinition()->GetPDGCharge();
36  bool geantinoHit = (currentTrack->GetDefinition()==G4Geantino::GeantinoDefinition()) ||
37  (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition());
38 
39  if (!charge && (!geantinoHit)) return false;
40  // G4cout << "\t\t MicromegasSD: Hit in a sensitive layer!!!!! " << G4endl;
41  G4StepPoint* postStep=aStep->GetPostStepPoint();
42  const G4Step* post_Step=aStep->GetTrack()->GetStep();
43 
44  Amg::Vector3D position = Amg::Hep3VectorToEigen( postStep->GetPosition() );
45 
46  int pdgCode=currentTrack->GetDefinition()->GetPDGEncoding();
47 
48  float globalTime=postStep->GetGlobalTime();
49  float eKin=postStep->GetKineticEnergy();
50  if (eKin<= 0. && (!geantinoHit)) return false;
51 
52  Amg::Vector3D direction = Amg::Hep3VectorToEigen( postStep->GetMomentumDirection() );
53  float depositEnergy=post_Step->GetTotalEnergyDeposit();
54 
55  if (depositEnergy<0.0001 && (!geantinoHit)) return false;
56 
57  const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
58 
59  // int iDepth=touchHist->GetHistoryDepth();
60  // G4cout << "\t\t\t\t Touchable history dump " << G4endl;
61  int nLayer=touchHist->GetVolume(0)->GetCopyNo();
62  std::string chName=touchHist->GetVolume(1)->GetLogicalVolume()->GetName();
63  std::string subType=chName.substr(chName.find('-')+1);
64  if (subType[0]!='M') G4cout << " something is wrong, this is no Micromegas!" << G4endl;
65  std::string temp(&subType[1]);
66  std::istringstream is(temp);
67  int iRing;
68  is>>iRing;
69  // identifiers have eta naming 0-1, eta encoded in subtype is 1-2
70  iRing--;
71  // double phiDiff=2*M_PI;
72 
73  G4ThreeVector posH=postStep->GetPosition(); //posH is equivalent to position - eigen not used to avoid additional dependence on EventPrimitives
74  if (subType[2]=='L') posH.rotateZ(M_PI/8.);
75  double phiHit=posH.phi();
76  if(phiHit<=0) phiHit+=2.*M_PI;
77  int iPhi=1+int(phiHit/(M_PI/4.));
78  iPhi*=2;
79  if (subType[2]=='L') iPhi-=1;
80 
81  int iSide=1;
82  if (position.z()<0) iSide=-1;
83 
84  int mLayer= atoi((subType.substr(3,1)).c_str());
85  if (mLayer != 1 && mLayer !=2) G4cout << " something is wrong - multilayer index is " << mLayer << G4endl;
86 
87  // G4cout << "\t\t Chamber "<<chName<<" subType "<<subType<<" layer nr. "<<nLayer<<" ring "<<iRing<<" sector "<<iPhi<<" side "<<iSide << G4endl;
88  int MmId = m_muonHelper->BuildMicromegasHitId(subType, iPhi, iRing, mLayer,nLayer, iSide);
89 
90  TrackHelper trHelp(aStep->GetTrack());
91 
92  m_MMSimHitCollection->Emplace(MmId, globalTime,position,pdgCode,eKin,direction,depositEnergy,trHelp.GenerateParticleLink());
93 
94  // G4cout << "MMs "<<m_muonHelper->GetStationName(MmId)
95  // << " "<<m_muonHelper->GetFieldValue("PhiSector")
96  // << " "<<m_muonHelper->GetFieldValue("ZSector")
97  // << " "<<m_muonHelper->GetFieldValue("MultiLayer")
98  // << " "<<m_muonHelper->GetFieldValue("Layer")
99  // << " "<<m_muonHelper->GetFieldValue("Side") << G4endl;
100 
101  //G4cout << m_muonHelper->GetStationName(MmId)<<" "<<aHit->print() << G4endl;
102  // G4cout << aHit->print() << G4endl;
103 
104  return true;
105 }

Member Data Documentation

◆ m_MMSimHitCollection

SG::WriteHandle<MMSimHitCollection> MicromegasSensitiveDetector::m_MMSimHitCollection
private

Definition at line 30 of file MicromegasSensitiveDetector.h.

◆ m_muonHelper

const MicromegasHitIdHelper* MicromegasSensitiveDetector::m_muonHelper
private

Definition at line 31 of file MicromegasSensitiveDetector.h.


The documentation for this class was generated from the following files:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
M_PI
#define M_PI
Definition: ActiveFraction.h:11
MicromegasSensitiveDetector::m_muonHelper
const MicromegasHitIdHelper * m_muonHelper
Definition: MicromegasSensitiveDetector.h:31
Amg::Hep3VectorToEigen
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
Definition: CLHEPtoEigenConverter.h:137
TrackHelper
Definition: TrackHelper.h:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
charge
double charge(const T &p)
Definition: AtlasPID.h:494
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MicromegasHitIdHelper::GetHelper
static const MicromegasHitIdHelper * GetHelper()
Definition: MicromegasHitIdHelper.cxx:25
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:53
MicromegasHitIdHelper::BuildMicromegasHitId
int BuildMicromegasHitId(const std::string &, const int, const int, const int, const int, const int) const
Definition: MicromegasHitIdHelper.cxx:101
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
MicromegasSensitiveDetector::m_MMSimHitCollection
SG::WriteHandle< MMSimHitCollection > m_MMSimHitCollection
Definition: MicromegasSensitiveDetector.h:30