ATLAS Offline Software
G4DebuggingHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "G4Electron.hh"
8 #include "G4Positron.hh"
9 #include "G4Gamma.hh"
10 #include "G4Neutron.hh"
11 #include "G4Proton.hh"
12 #include "G4PionPlus.hh"
13 #include "G4PionMinus.hh"
14 #include "G4PionZero.hh"
15 #include "G4Version.hh"
16 #include <string_view>
17 
18 namespace G4DebuggingHelpers {
19  bool G4StrContains(const std::string_view& s, const char* v)
20  {
21  return s.find(v) != std::string_view::npos;
22  }
23 
24  const G4String ClassifyParticle( const G4ParticleDefinition* def ) {
25  if (def == G4Electron::Electron())
26  return "e-";
27  else if (def == G4Positron::Positron())
28  return "e+";
29  else if (def == G4Gamma::Gamma())
30  return "gamma";
31  else if (def == G4Neutron::Neutron())
32  return "neutron";
33  else if (def == G4Proton::Proton())
34  return "proton";
35  else if (def == G4PionPlus::PionPlus() || def == G4PionMinus::PionMinus() || def == G4PionZero::PionZero())
36  return "pion";
37  return "other";
38  }
39 
40  const G4String ClassifyMaterial( const G4String &nom ) {
41  if (nom == "FCal1Absorber"
42  || nom == "LiquidArgon"
43  || nom == "Copper"
44  || nom == "Lead"
45  || nom == "Aluminum"
46  || nom == "FCal23Absorber"
47  || nom == "Iron"
48  || nom == "Air"
49  || nom == "myLead"
50  || nom == "shieldIron"
51  || nom == "FCal23Slugs"
52  || nom == "Glue"
53  || nom == "KaptonC"
54  || nom == "Kapton"
55  || nom == "ShieldSteel"
56  || nom == "myIron"
57  || nom == "ShieldBrass"
58  || nom == "Straw"
59  || nom == "XeCO2O2"
60  || nom == "CO2"
61  || nom == "Valmat"
62  || nom == "BoratedPolyethelyne"
63  || nom == "FoilRadiatorB"
64  || nom == "G10"
65  || nom == "FoilRadiatorAC"
66  || nom == "PyrogelXT"
67  || nom == "Vacuum")
68  return nom;
69  else if (nom.compare(0,12,"pix::IBL_Fwd")==0)
70  return "IBL_Fwd";
71  return "other";
72  }
73 
74  const G4String ClassifyVolume( const G4String &nomstr ) {
75  std::string_view nom(nomstr); //Avoid copying characters during comparison
76  if ( nom.length() >= 17 && nom.substr(13, 4) == "EMEC" ) {
77  return "EMEC";
78  }
79  else if ( nom.length() >= 16 && nom.substr(13, 3) == "EMB" ) {
80  return "EMB";
81  }
82  else if ( nom.length() >= 25 && nom.substr(21, 4) == "Cryo" ) {
83  return "Cryo";
84  }
85  else if ( nom.length() >= 26 && nom.substr(13, 13) == "FCAL::Module1" ) {
86  return "FC1";
87  }
88  else if ( nom.length() >= 25 && nom.substr(13, 12) == "FCAL::Module" ) {
89  return "FC23";
90  }
91  else if ( nom.length() >= 17 && nom.substr(13, 4) == "FCAL" ) {
92  return "FCOther";
93  }
94  else if ( nom.length() >= 16 && nom.substr(13, 3) == "HEC" ) {
95  return "HEC";
96  }
97  else if ( nom.length() >= 31 && nom.substr(21, 10) == "Presampler" ) {
98  return "Presampler";
99  }
100  else if ( nom.length() >= 3 && nom.substr(0, 3) == "LAr" ) {
101  return "LAr";
102  }
103  else if ( ( nom.substr(0, 4) == "MUON" )
104  || ( nom.length() >= 4 && nom.substr(0, 4) == "Muon" )
105  || ( nom.length() >= 9 && nom.substr(0, 9) == "DriftTube" )
106  || ( nom.length() >= 12 && nom.substr(0, 12) == "SensitiveGas" )
107 #if G4VERSION_NUMBER < 1100
108  || nomstr.contains("MDT")
109  || nomstr.contains("station") ) {
110 #else
111  || G4StrContains(nom, "MDT")
112  || G4StrContains(nom, "station") ) {
113 #endif
114  return "Muon";
115  }
116  else if ( nom.length() >= 8 && nom.substr(0, 8) == "ITkPixel" ) {
117  return "ITkPixel";
118  }
119  else if ( nom.length() >= 8 && nom.substr(0, 8) == "ITkStrip" ) {
120  return "ITkStrip";
121  }
122  else if ( ( nom.length() >= 5 && nom.substr(0, 5) == "Pixel" )
123  || nom == "Outside Barrel Service") {
124  return "Pixel";
125  }
126  else if ( nom.length() >= 3 && nom.substr(0, 3) == "SCT" ) {
127  return "SCT";
128  }
129  else if ( ( nom.length() >= 3 && nom.substr(0, 3) == "TRT" )
130  || nom == "GasMANeg" ) {
131  return "TRT";
132  }
133  else if ( nom.length() >= 4 && nom.substr(0, 4) == "Tile" ) {
134  return "Tile";
135  }
136  else if (nom.length() >= 7 && nom.substr(0, 7) == "Section" )
137  return "Section";
138  else if ( ( nom.length() >= 12 && nom.substr(0, 12) == "InDetServMat" )
139  || ( nom.length() >= 4 && nom.substr(0, 4) == "IDET" )
140  || ( nom.length() >= 3 && nom.substr(0, 3) == "ITK" )
141  || ( nom.length() >= 8 && nom.substr(0, 8) == "BeamPipe" )
142  || ( nom.length() >= 3 &&
143  ( nom.substr(0, 3) == "BLM" || nom.substr(0, 3) == "BCM" || nom.substr(0, 3) == "PLR" ) )
144  || ( nom.length() >= 8 && nom.substr(0, 8) == "BCMPrime") ) {
145  return "Service";
146  }
147  return "other";
148  }
149 
150 } // end namespace G4DebuggingHelpers
G4DebuggingHelpers
Definition: G4DebuggingHelper.h:13
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
G4DebuggingHelper.h
G4DebuggingHelpers::ClassifyParticle
const G4String ClassifyParticle(const G4ParticleDefinition *def)
Definition: G4DebuggingHelper.cxx:24
VP1PartSpect::Neutron
@ Neutron
Definition: VP1PartSpectFlags.h:25
G4DebuggingHelpers::ClassifyVolume
const G4String ClassifyVolume(const G4String &nom)
Definition: G4DebuggingHelper.cxx:74
VP1PartSpect::Gamma
@ Gamma
Definition: VP1PartSpectFlags.h:22
G4DebuggingHelpers::G4StrContains
bool G4StrContains(const std::string_view &s, const char *v)
Definition: G4DebuggingHelper.cxx:19
PlotSFuncertainty.nom
nom
Definition: PlotSFuncertainty.py:141
python.PyAthena.v
v
Definition: PyAthena.py:157
G4DebuggingHelpers::ClassifyMaterial
const G4String ClassifyMaterial(const G4String &nom)
Definition: G4DebuggingHelper.cxx:40
VP1PartSpect::Proton
@ Proton
Definition: VP1PartSpectFlags.h:28