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

#include <CSCSensitiveDetector.h>

Inheritance diagram for CSCSensitiveDetector:
Collaboration diagram for CSCSensitiveDetector:

Public Member Functions

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

Private Member Functions

 FRIEND_TEST (CSCSensitiveDetectortest, Initialize)
 
 FRIEND_TEST (CSCSensitiveDetectortest, ProcessHits)
 

Private Attributes

SG::WriteHandle< CSCSimHitCollectionm_myCSCHitColl
 member data More...
 
const CscHitIdHelperm_muonHelper
 

Detailed Description

Author
ketev.nosp@m.i@bn.nosp@m.l.gov

Class methods and properties

The method CSCSensitiveDetector::ProcessHits is executed by the G4 kernel each time a charged particle (or a geantino) crosses one of the CSC Gas Gaps.

Navigating with the toucahbleHistory method GetHistoryDepth() through the hierarchy of the volumes crossed by the particles, the CSCSensitiveDetector determinates the correct set of geometry parameters to be folded in the Simulation Identifier associated to each hit. The CSC SimIDs are 32-bit unsigned integers, built using the MuonSimEvent/CscHitIdHelper class which inherits from the MuonHitIdHelper base class.

We describe in the following, how each field of the identifier is retrieved.

1) stationName, stationEta, stationPhi: when a volume is found in the hierarchy, whose name contains the substring "station", the stationName is extracted from the volume's name; stationPhi and stationEta are calculated starting from the volume copy number, assigned by MuonGeoModel.

2) multilayer: when a volume is found in the hierarchy, whose name contains the substring "component", the multilayer is set to 1 or to 2, according to the component number (multilayer=1 if the component copy number is 1, multilayer=3 if the component copy number is 2).

3) wireLayer: when a volume is found in the hierarchy, whose name contains the substring "CscArCO2", the wire Layer is calculated, increasing with |z| Atlas global coordinate.

notes:

1) for each hit, the time of flight (the G4 globalTime), is recorded and associated to the hit.

2) the CSCHit object contains: the SimID, the globalTime, the energy deposited, the start and end point of the step in local coordinates (chamber reference system), the particle pdg and the track identifier.

Definition at line 61 of file CSCSensitiveDetector.h.

Constructor & Destructor Documentation

◆ CSCSensitiveDetector()

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

construction/destruction

Definition at line 17 of file CSCSensitiveDetector.cxx.

19  : G4VSensitiveDetector( name )
20  , m_myCSCHitColl( hitCollectionName )
21 {
23 }

◆ ~CSCSensitiveDetector()

CSCSensitiveDetector::~CSCSensitiveDetector ( )
inline

Definition at line 68 of file CSCSensitiveDetector.h.

68 {}

Member Function Documentation

◆ FRIEND_TEST() [1/2]

CSCSensitiveDetector::FRIEND_TEST ( CSCSensitiveDetectortest  ,
Initialize   
)
private

◆ FRIEND_TEST() [2/2]

CSCSensitiveDetector::FRIEND_TEST ( CSCSensitiveDetectortest  ,
ProcessHits   
)
private

◆ Initialize()

void CSCSensitiveDetector::Initialize ( G4HCofThisEvent *  HCE)
finaloverride

member functions

Definition at line 26 of file CSCSensitiveDetector.cxx.

27 {
28  if (!m_myCSCHitColl.isValid()) m_myCSCHitColl = std::make_unique<CSCSimHitCollection>();
29 }

◆ ProcessHits()

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

CSCs sensitive to charged particle only; plus energy threshold

attributes of the CSC identifier construction

hit information to be recorded

scan geometry tree to identify the gas layer

station: name, eta and phi (-> chamber!)

station name, station eta and station phi

station name

station eta and station phi

chamber layer

chamber layer

the wire layer number

get the particle ID

the track id

record global time

energy deposit

get the transformation

local position of HitStart and HitEnd

get the end of the step as return by G4 - could be at the beginning of the next volume

construct the hit identifier

insert hit in collection

Definition at line 31 of file CSCSensitiveDetector.cxx.

31  {
32 
33  G4Track* currentTrack = aStep->GetTrack();
34 
36  auto trackDef = currentTrack->GetDefinition();
37  if (trackDef->GetPDGCharge() == 0.0) {
38  if (trackDef != G4Geantino::GeantinoDefinition()) return true;
39  else if (trackDef == G4ChargedGeantino::ChargedGeantinoDefinition()) return true;
40  }
41 
42  const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
43  G4ThreeVector startPos=aStep->GetPreStepPoint()->GetPosition();
44  G4ThreeVector endPos=aStep->GetPostStepPoint()->GetPosition();
45  double kinEnergy = aStep->GetPreStepPoint()->GetKineticEnergy();
46 
49  std::string stationName="";
50  int stationEta=1;
51  int stationPhi=1;
52  int multiLayer=1;
53  int wireLayer=0;
54 
57  Amg::Vector3D HitStart = Amg::Vector3D(-1000,-1000,-1000);
58  Amg::Vector3D HitEnd = Amg::Vector3D(-1000,-1000,-1000);
59  double globalTime = -1;
60  double energyDeposit= -1;
61  G4int lundcode = -1;
62  // int trackid = -1;
63 
66  bool isAssembly = false;
67  for (int i = touchHist->GetHistoryDepth(); i>=0; --i) {
68  std::string::size_type npos;
69  std::string volName = touchHist->GetVolume(i)->GetName();
70 
71  //G4cout << "Csc SD: swimming through the tree: level "<<i-touchHist->GetHistoryDepth() << G4endl;
72  //G4cout << "Csc SD: name "<<volName << G4endl;
73 
75  if ((npos = volName.find("av_")) != std::string::npos &&
76  (npos = volName.find("impr_")) != std::string::npos) isAssembly = true;
77 
78  if ((npos = volName.find("station")) != std::string::npos && (!isAssembly)) {
79 
81  volName.resize(npos-2);
82  int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
83  stationName = volName;
84  //stationEta = volCopyNo/100;
85  // bug fix for 14.2.0 to cope with non-mirrored chambers as proposed by
86  // S.Spagnolo
87  stationEta = (volCopyNo%1000)/100;
88  stationPhi = abs(volCopyNo%100);
89 
90  } else if ((npos = volName.find("CSC")) != std::string::npos && isAssembly ) {
91  // vol name for Assembly components are
92  // av_WWW_impr_XXX_Muon::BMSxMDTxx_pv_ZZZ_NAME
93  // where WWW is ass. istance nr.
94  // XXX is comp. imprint nr.
95  // BMSxMDTxx is the name of the comp. log.Vol.
96  // x station sub-type; xx technology subtype
97  // ZZZ is No of order of this daugther
98  // NAME is the comp. tag (geoIdentifierTag)
99  // for CSCs it is cl[1] or cl[2]
100  // copy numbers for Ass.components are =
101  // CopyNoBase(= geoIdentifierTag of the assembly) + geoIdentifierTag of the component
102  // geoIdentifierTag of the component = Job
103  // geoIdentifierTag of the assembly = (sideC*10000 +
104  // mirsign*1000 + abs(zi)*100 + fi+1)*100000;
105  // mirsign*1000 + abs(zi)*100 + fi+1)*100000;
106 
108  std::string::size_type loc1,loc2;
109  if ((loc1 = volName.find("Muon::")) != std::string::npos) {
110  stationName = volName.substr(loc1+6,3); //type only
111  }
112 
114  int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
115  int copyNrBase = int(volCopyNo/100000);
116  int sideC = int(copyNrBase/10000);
117  int zi = int((copyNrBase%1000)/100);
118  // int mirfl = int((copyNrBase%10000)/1000);
119  int fi = int(copyNrBase%100);
120  if (sideC == 1) zi = -zi;
121  stationEta = zi;
122  stationPhi = fi;
123 
124  // now get the geoIdentifierTag of the rpc components
125  int gmID = 0;
126  if ((loc1 = volName.find('[')) != std::string::npos) {
127  if ((loc2 = volName.find(']', loc1+1)) != std::string::npos) {
128  std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
129  istrvar>>gmID;
130  }
131  }
133  multiLayer = gmID;
134  } else if ((npos = volName.find("component")) != std::string::npos && (!isAssembly)) {
135 
137  multiLayer = touchHist->GetVolume(i)->GetCopyNo();
138  if(multiLayer==3) multiLayer=2; //multilayer index
139  } else if ((npos = volName.find("CscArCO2")) != std::string::npos) {
140 
142  wireLayer=touchHist->GetVolume(i)->GetCopyNo();
143  wireLayer+=1;
144  if(wireLayer==4) wireLayer=1;
145  else if(wireLayer==3) wireLayer=2;
146  else if(wireLayer==2) wireLayer=3;
147  else if(wireLayer==1) wireLayer=4;
148  // G4cout << "CSC:::::: wireLayer "<<wireLayer << G4endl;
149 
151  G4String particle=aStep->GetTrack()->GetDefinition()->GetParticleName();
152  // http://www.slac.stanford.edu/BFROOT/www/Computing/Environment/NewUser/htmlbug/node51.html #GEANT code
153  if (particle=="gamma") lundcode=1;
154  else if (particle=="e+") lundcode=2;
155  else if (particle=="e-") lundcode=3;
156  else if (particle=="mu+") lundcode=5;
157  else if (particle=="mu-") lundcode=6;
158  else if (particle=="pi+") lundcode=8;
159  else if (particle=="pi-") lundcode=9;
160  else if (particle=="kaon+") lundcode=11;
161  else if (particle=="kaon-") lundcode=12;
162  else if (particle=="proton") lundcode=14;
163  else if (particle=="anti_proton") lundcode=15;
164  else if (particle=="sigma+") lundcode=19;
165  else if (particle=="sigma-") lundcode=21;
166  else if (particle=="anti_sigma-") lundcode=27;
167  else if (particle=="anti_sigma+") lundcode=29;
168  else if (particle=="deuteron") lundcode=45;
169  //else if (particle=="geantino") lundcode=999;
170  //else lundcode=999;
171 
172  if (lundcode < 0)
173  G4cout << "WP CSCSensitiveDetector.cxx have exceptional particlue out of selection:: "
174  << particle<< G4endl;
175 
177  // trackid=aStep->GetTrack()->GetTrackID();
178 
180  globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
181 
183  energyDeposit = aStep->GetTotalEnergyDeposit();
184 
186  const G4AffineTransform transform = touchHist->GetHistory()->GetTopTransform();
187 
189  HitStart = Amg::Hep3VectorToEigen( transform.TransformPoint(startPos) );
190 
193  HitEnd = Amg::Hep3VectorToEigen( transform.TransformPoint(endPos) );
194 
195  }
196  }
197 
198  TrackHelper trHelp(aStep->GetTrack());
199 
202  stationEta, multiLayer, wireLayer);
203 
205  m_myCSCHitColl->Emplace(CSCid, globalTime, energyDeposit,
206  HitStart, HitEnd, lundcode,
207  trHelp.GenerateParticleLink(), kinEnergy);
208 
209  return true;
210 }

Member Data Documentation

◆ m_muonHelper

const CscHitIdHelper* CSCSensitiveDetector::m_muonHelper
private

Definition at line 77 of file CSCSensitiveDetector.h.

◆ m_myCSCHitColl

SG::WriteHandle<CSCSimHitCollection> CSCSensitiveDetector::m_myCSCHitColl
private

member data

Definition at line 76 of file CSCSensitiveDetector.h.


The documentation for this class was generated from the following files:
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:129
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ZDC::sideC
BySideTypeMod sideC(-1)
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:41
Trk::energyDeposit
@ energyDeposit
Definition: MeasurementType.h:32
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
CscHitIdHelper::GetHelper
static const CscHitIdHelper * GetHelper()
Definition: CscHitIdHelper.cxx:23
CscHitIdHelper::BuildCscHitId
int BuildCscHitId(const std::string &, const int, const int, const int, const int) const
Definition: CscHitIdHelper.cxx:89
lumiFormat.i
int i
Definition: lumiFormat.py:92
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CSCSensitiveDetector::m_muonHelper
const CscHitIdHelper * m_muonHelper
Definition: CSCSensitiveDetector.h:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
checkFileSG.fi
fi
Definition: checkFileSG.py:65
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:127
HitID
int HitID
Definition: GenericMuonSimHit.h:13
Trk::loc1
@ loc1
Definition: ParamDefs.h:40
sTgcDigitEffiDump.multiLayer
int multiLayer
Definition: sTgcDigitEffiDump.py:36
CSCSensitiveDetector::m_myCSCHitColl
SG::WriteHandle< CSCSimHitCollection > m_myCSCHitColl
member data
Definition: CSCSensitiveDetector.h:76