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

#include <CSCSensitiveDetectorCosmics.h>

Inheritance diagram for CSCSensitiveDetectorCosmics:
Collaboration diagram for CSCSensitiveDetectorCosmics:

Public Member Functions

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

Private Member Functions

 FRIEND_TEST (CSCSensitiveDetectorCosmicstest, Initialize)
 
 FRIEND_TEST (CSCSensitiveDetectorCosmicstest, ProcessHits)
 

Private Attributes

Amg::Vector3D m_mom
 
double m_momMag
 
Amg::Vector3D m_vertex
 
Amg::Vector3D m_currVertex
 
Amg::Vector3D m_globH
 
double m_globalTime
 
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 CSCSensitiveDetectorCosmics::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 CSCSensitiveDetectorCosmics 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.

The modified version (Daniela Rebuzzi, 16/12/2005) calculates the tof for the cosmics, using as t0 the time to the closest approach of the track to (0,0,0). This implementation works also for slow particles, since the discrimination physics event/cosmics is done relying on the G4Track vertex (not on the tof).

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 66 of file CSCSensitiveDetectorCosmics.h.

Constructor & Destructor Documentation

◆ CSCSensitiveDetectorCosmics()

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

construction/destruction

Definition at line 20 of file CSCSensitiveDetectorCosmics.cxx.

21  : G4VSensitiveDetector( name )
22  // START OF COSMICS-SPECIFIC CODE
23  , m_momMag(0.)
24  , m_globalTime(0.)
25  // END OF COSMICS-SPECIFIC CODE
26  , m_myCSCHitColl( hitCollectionName )
27 {
29 }

◆ ~CSCSensitiveDetectorCosmics()

CSCSensitiveDetectorCosmics::~CSCSensitiveDetectorCosmics ( )
inline

Definition at line 72 of file CSCSensitiveDetectorCosmics.h.

72 {}

Member Function Documentation

◆ FRIEND_TEST() [1/2]

CSCSensitiveDetectorCosmics::FRIEND_TEST ( CSCSensitiveDetectorCosmicstest  ,
Initialize   
)
private

◆ FRIEND_TEST() [2/2]

CSCSensitiveDetectorCosmics::FRIEND_TEST ( CSCSensitiveDetectorCosmicstest  ,
ProcessHits   
)
private

◆ Initialize()

void CSCSensitiveDetectorCosmics::Initialize ( G4HCofThisEvent *  HCE)
finaloverride

member functions

Definition at line 32 of file CSCSensitiveDetectorCosmics.cxx.

33 {
34  if (!m_myCSCHitColl.isValid()) m_myCSCHitColl = std::make_unique<CSCSimHitCollection>();
35  // START OF COSMICS-SPECIFIC CODE
36  m_mom = Amg::Vector3D(0.,0.,0.);
37  m_globH = Amg::Vector3D(0.,0.,0.);
38  // END OF COSMICS-SPECIFIC CODE
39 }

◆ ProcessHits()

G4bool CSCSensitiveDetectorCosmics::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

the track id

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

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 41 of file CSCSensitiveDetectorCosmics.cxx.

41  {
42 
43  G4Track* currentTrack = aStep->GetTrack();
44 
46  auto trackDef = currentTrack->GetDefinition();
47  if (trackDef->GetPDGCharge() == 0.0) {
48  if (trackDef != G4Geantino::GeantinoDefinition()) return true;
49  else if (trackDef == G4ChargedGeantino::ChargedGeantinoDefinition()) return true;
50  }
51 
52  const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
53  G4ThreeVector startPos=aStep->GetPreStepPoint()->GetPosition();
54  G4ThreeVector endPos=aStep->GetPostStepPoint()->GetPosition();
55  double kinEnergy = aStep->GetPreStepPoint()->GetKineticEnergy();
56 
59  std::string stationName="";
60  int stationEta=0;
61  int stationPhi=0;
62  int multiLayer=0;
63  int wireLayer=0;
64 
67  Amg::Vector3D HitStart = Amg::Vector3D(-1000,-1000,-1000);
68  Amg::Vector3D HitEnd = Amg::Vector3D(-1000,-1000,-1000);
69  double globalTime = -1;
70  double energyDeposit= -1;
71  G4int lundcode = -1;
73  //const int trackid(aStep->GetTrack()->GetTrackID());
74 
75  // START OF COSMICS-SPECIFIC CODE
76  // global coordinates
77  Amg::Vector3D globVrtx = Amg::Hep3VectorToEigen( aStep->GetPreStepPoint()->GetPosition() );
78 
79  // distance of the hit from (0,0,0) vertex - calculated from the PreStepPoint (approximation)
80  const double dist = globVrtx.mag();
81  const double lightspeed = 299.792458; /* in vacuo speed of light [mm/ns] */ //FIXME this should be taken from standard headers
82  const double tOrigin = dist / lightspeed;
83 
84  m_currVertex = Amg::Hep3VectorToEigen( aStep->GetTrack()->GetVertexPosition() );
85 
86  // for cosmics: only primary muon tracks - track momentum when first entering the spectrometer (one muon per event)
87  if ((m_currVertex != m_vertex) && (aStep->GetTrack()->GetTrackID() == 1)) {
88  // after calculationg the momentum magnidude, normalize it
89  m_mom = Amg::Hep3VectorToEigen( currentTrack->GetMomentum() );
90  m_momMag = m_mom.mag();
91  m_mom.normalize();
92  // the direction of the primary mu is used to calculate the t0, the position to the t0, m_globH, is ONE for a track
93  Amg::Vector3D globVrtxFix = globVrtx;
94  const double AlphaGlobal = -1*(globVrtxFix[0]*m_mom[0] + globVrtxFix[1]*m_mom[1] + globVrtxFix[2]*m_mom[2])/(m_mom[0]*m_mom[0] + m_mom[1]*m_mom[1] + m_mom[2]*m_mom[2]);
95  m_globH = globVrtxFix + AlphaGlobal*m_mom;
96  // G4cout << "COSMICS MAIN TRACK IN THES CSC!" << G4endl;
97  }
98  const double globalDist = sqrt((m_globH[0] - globVrtx[0])*(m_globH[0] - globVrtx[0]) +
99  (m_globH[1] - globVrtx[1])*(m_globH[1] - globVrtx[1]) +
100  (m_globH[2] - globVrtx[2])*(m_globH[2] - globVrtx[2]));
101  double tof = globalDist / lightspeed;
102  // END OF COSMICS SPECIFIC CODE
103 
106  bool isAssembly = false;
107  for (int i = touchHist->GetHistoryDepth(); i>=0; --i) {
108  std::string::size_type npos;
109  std::string volName = touchHist->GetVolume(i)->GetName();
110 
112  if ((npos = volName.find("av_")) != std::string::npos &&
113  (npos = volName.find("impr_")) != std::string::npos) isAssembly = true;
114 
115  if ((npos = volName.find("station")) != std::string::npos && (!isAssembly)) {
116 
118  volName.resize(npos-2);
119  int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
120  stationName = volName;
121  //stationEta = volCopyNo/100;
122  // bug fix for 14.2.0 to cope with non-mirrored chambers as proposed by
123  // S.Spagnolo (ported from CSCSensitiveDetector.cxx for rel 20.3.3)
124  stationEta = (volCopyNo%1000)/100;
125  stationPhi = abs(volCopyNo%100);
126 
127  } else if ((npos = volName.find("CSC")) != std::string::npos && isAssembly ) {
128  // vol name for Assembly components are
129  // av_WWW_impr_XXX_Muon::BMSxMDTxx_pv_ZZZ_NAME
130  // where WWW is ass. istance nr.
131  // XXX is comp. imprint nr.
132  // BMSxMDTxx is the name of the comp. log.Vol.
133  // x station sub-type; xx technology subtype
134  // ZZZ is No of order of this daugther
135  // NAME is the comp. tag (geoIdentifierTag)
136  // for CSCs it is cl[1] or cl[2]
137  // copy numbers for Ass.components are =
138  // CopyNoBase(= geoIdentifierTag of the assembly) + geoIdentifierTag of the component
139  // geoIdentifierTag of the component = Job
140  // geoIdentifierTag of the assembly = (sideC*10000 +
141  // mirsign*1000 + abs(zi)*100 + fi+1)*100000;
142  // mirsign*1000 + abs(zi)*100 + fi+1)*100000;
143 
145  std::string::size_type loc1,loc2;
146  if ((loc1 = volName.find("Muon::")) != std::string::npos) {
147  stationName = volName.substr(loc1+6,3); //type only
148  }
149 
151  int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
152  int copyNrBase = int(volCopyNo/100000);
153  int sideC = int(copyNrBase/10000);
154  int zi = int((copyNrBase%1000)/100);
155  // int mirfl = int((copyNrBase%10000)/1000);
156  int fi = int(copyNrBase%100);
157  if (sideC == 1) zi = -zi;
158  stationEta = zi;
159  stationPhi = fi;
160 
161  // now get the geoIdentifierTag of the rpc components
162  int gmID = 0;
163  if ((loc1 = volName.find('[')) != std::string::npos) {
164  if ((loc2 = volName.find(']', loc1+1)) != std::string::npos) {
165  std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
166  istrvar>>gmID;
167  }
168  }
170  multiLayer = gmID;
171  } else if ((npos = volName.find("component")) != std::string::npos && (!isAssembly)) {
172 
174  multiLayer = touchHist->GetVolume(i)->GetCopyNo();
175  if(multiLayer==3) multiLayer=2; //multilayer index
176  // G4cout << "CSC:::::: multiLayer "<<multiLayer << G4endl;
177  } else if ((npos = volName.find("CscArCO2")) != std::string::npos) {
178 
180  wireLayer=touchHist->GetVolume(i)->GetCopyNo();
181  wireLayer+=1;
182  if(wireLayer==4) wireLayer=1;
183  else if(wireLayer==3) wireLayer=2;
184  else if(wireLayer==2) wireLayer=3;
185  else if(wireLayer==1) wireLayer=4;
186  // G4cout << "CSC:::::: wireLayer "<<wireLayer << G4endl;
187 
189  G4String particle=aStep->GetTrack()->GetDefinition()->GetParticleName();
190  // http://www.slac.stanford.edu/BFROOT/www/Computing/Environment/NewUser/htmlbug/node51.html #GEANT code
191  if (particle=="gamma") lundcode=1; // FIXME was photon, but changed to gamma to match CSCSensitiveDetctor
192  else if (particle=="e+") lundcode=2;
193  else if (particle=="e-") lundcode=3;
194  else if (particle=="mu+") lundcode=5;
195  else if (particle=="mu-") lundcode=6;
196  else if (particle=="pi+") lundcode=8;
197  else if (particle=="pi-") lundcode=9;
198  else if (particle=="kaon+") lundcode=11;
199  else if (particle=="kaon-") lundcode=12;
200  else if (particle=="proton") lundcode=14;
201  else if (particle=="anti_proton") lundcode=15;
202  else if (particle=="sigma+") lundcode=19;
203  else if (particle=="sigma-") lundcode=21;
204  else if (particle=="anti_sigma-") lundcode=27;
205  else if (particle=="anti_sigma+") lundcode=29;
206  else if (particle=="deuteron") lundcode=45;
207  else if (particle=="geantino") lundcode=999;
208  else lundcode=0;
209 
211  globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
212 
214  energyDeposit = aStep->GetTotalEnergyDeposit();
215 
217  const G4AffineTransform transform = touchHist->GetHistory()->GetTopTransform();
218 
220  HitStart = Amg::Hep3VectorToEigen( transform.TransformPoint(startPos) );
221 
224  HitEnd = Amg::Hep3VectorToEigen( transform.TransformPoint(endPos) );
225 
226  }
227  }
228 
229  // START OF COSMICS SPECIFIC CODE
230  m_vertex = Amg::Hep3VectorToEigen( aStep->GetTrack()->GetVertexPosition() );
231  // if the track vertex is far from (0,0,0), takes the tof, otherwise take the "usual" g4 globalTime
232  (((m_vertex.mag() < 100) || ((fabs(globalTime - tOrigin)) < 0.1) ) ? (m_globalTime = globalTime)
233  : (m_globalTime = tof));
234  // if m_globalTime != globalTime and m_globalTime != tof in the output, this is due to multiple hits
235  // before founding the good one (small approximation)
236  // END OF COSMICS SPECIFIC CODE
237 
238  TrackHelper trHelp(aStep->GetTrack());
239 
242  stationEta, multiLayer, wireLayer);
243 
245  m_myCSCHitColl->Emplace(CSCid, m_globalTime, energyDeposit,
246  HitStart, HitEnd, lundcode,
247  trHelp.GenerateParticleLink(), kinEnergy);
248 
249  // #ifndef CSCG4_DEBUG
250  //
251  // // printouts for cosmics
252  // G4cout << "------------------CSC------------------" << G4endl;
253  // G4cout << "Track "<<aStep->GetTrack()->GetTrackID() << G4endl;
254  // G4cout << "Track m_vertex "<<m_vertex[0]<<" " <<m_vertex[1]<<" " <<m_vertex[2] << G4endl;
255 // G4cout << "Global position of the hit " << globVrtx[0] <<" " << globVrtx[1] <<" " << globVrtx[2] << G4endl;
256 // G4cout << "Distance from (0,0,0) and time " << dist << " " <<tOrigin << G4endl;
257 // G4cout << "Momentum "<<m_momMag << G4endl;
258 // G4cout << "Momentum director cosines " <<m_mom[0]<<" " <<m_mom[1]<<" " <<m_mom[2] << G4endl;
259 // G4cout << "Eta and phi "<<m_mom.eta()<<" " <<m_mom.phi() << G4endl;
260 // G4cout << "Closest approach position and distance from (0,0,0) "
261 // << m_globH[0] <<" "<<m_globH[1]<<" "<<m_globH[2]<<" "
262 // << sqrt(m_globH[0]*m_globH[0] + m_globH[1]*m_globH[1] + m_globH[2]*m_globH[2]) << G4endl;
263 // G4cout << "Distance from t0 and tof " << globalDist <<" " <<tof << G4endl;
264 // G4cout << "g4 globalTime " << globalTime << G4endl;
265 // G4cout << "Time " << m_globalTime << G4endl;
266 //
267 // G4cout << "TUB "<<m_muonHelper->GetStationName(CSCid)
268 // << " "<<m_muonHelper->GetFieldValue("PhiSector")
269 // << " "<<m_muonHelper->GetFieldValue("ZSector")
270 // << " "<<m_muonHelper->GetFieldValue("ChamberLayer")
271 // << " "<<m_muonHelper->GetFieldValue("WireLayer") << G4endl;
272 //
273 // G4cout << m_muonHelper->GetStationName(CSCid)<<" "<<newHit->print() << G4endl;
274 //
275 // #endif
276 
277  return true;
278 }

Member Data Documentation

◆ m_currVertex

Amg::Vector3D CSCSensitiveDetectorCosmics::m_currVertex
private

Definition at line 82 of file CSCSensitiveDetectorCosmics.h.

◆ m_globalTime

double CSCSensitiveDetectorCosmics::m_globalTime
private

Definition at line 84 of file CSCSensitiveDetectorCosmics.h.

◆ m_globH

Amg::Vector3D CSCSensitiveDetectorCosmics::m_globH
private

Definition at line 83 of file CSCSensitiveDetectorCosmics.h.

◆ m_mom

Amg::Vector3D CSCSensitiveDetectorCosmics::m_mom
private

Definition at line 79 of file CSCSensitiveDetectorCosmics.h.

◆ m_momMag

double CSCSensitiveDetectorCosmics::m_momMag
private

Definition at line 80 of file CSCSensitiveDetectorCosmics.h.

◆ m_muonHelper

const CscHitIdHelper* CSCSensitiveDetectorCosmics::m_muonHelper
private

Definition at line 88 of file CSCSensitiveDetectorCosmics.h.

◆ m_myCSCHitColl

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

member data

Definition at line 87 of file CSCSensitiveDetectorCosmics.h.

◆ m_vertex

Amg::Vector3D CSCSensitiveDetectorCosmics::m_vertex
private

Definition at line 81 of file CSCSensitiveDetectorCosmics.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
CSCSensitiveDetectorCosmics::m_mom
Amg::Vector3D m_mom
Definition: CSCSensitiveDetectorCosmics.h:79
CSCSensitiveDetectorCosmics::m_myCSCHitColl
SG::WriteHandle< CSCSimHitCollection > m_myCSCHitColl
member data
Definition: CSCSensitiveDetectorCosmics.h:87
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:41
CSCSensitiveDetectorCosmics::m_currVertex
Amg::Vector3D m_currVertex
Definition: CSCSensitiveDetectorCosmics.h:82
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
CSCSensitiveDetectorCosmics::m_globalTime
double m_globalTime
Definition: CSCSensitiveDetectorCosmics.h:84
CSCSensitiveDetectorCosmics::m_muonHelper
const CscHitIdHelper * m_muonHelper
Definition: CSCSensitiveDetectorCosmics.h:88
CSCSensitiveDetectorCosmics::m_momMag
double m_momMag
Definition: CSCSensitiveDetectorCosmics.h:80
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
CSCSensitiveDetectorCosmics::m_globH
Amg::Vector3D m_globH
Definition: CSCSensitiveDetectorCosmics.h:83
CSCSensitiveDetectorCosmics::m_vertex
Amg::Vector3D m_vertex
Definition: CSCSensitiveDetectorCosmics.h:81