ATLAS Offline Software
Loading...
Searching...
No Matches
CustomMonopoleFactory Class Reference

#include <CustomMonopoleFactory.h>

Collaboration diagram for CustomMonopoleFactory:

Public Member Functions

void loadCustomMonopoles ()
bool isCustomMonopole (CustomMonopole *particle) const

Static Public Member Functions

static const CustomMonopoleFactoryinstance ()

Private Member Functions

 CustomMonopoleFactory ()

Private Attributes

std::set< CustomMonopole * > m_particles

Detailed Description

Definition at line 18 of file CustomMonopoleFactory.h.

Constructor & Destructor Documentation

◆ CustomMonopoleFactory()

CustomMonopoleFactory::CustomMonopoleFactory ( )
private

Definition at line 33 of file CustomMonopoleFactory.cxx.

Member Function Documentation

◆ instance()

const CustomMonopoleFactory & CustomMonopoleFactory::instance ( )
static

Definition at line 22 of file CustomMonopoleFactory.cxx.

23{
24 static const CustomMonopoleFactory factory;
25 return factory;
26}

◆ isCustomMonopole()

bool CustomMonopoleFactory::isCustomMonopole ( CustomMonopole * particle) const

Definition at line 28 of file CustomMonopoleFactory.cxx.

29{
30 return (particle && m_particles.find(particle)!=m_particles.end());
31}
std::set< CustomMonopole * > m_particles

◆ loadCustomMonopoles()

void CustomMonopoleFactory::loadCustomMonopoles ( )

Definition at line 38 of file CustomMonopoleFactory.cxx.

39{
40 std::ifstream configFile("particles.txt");
41 // std::ifstream configFile("stophadrons.txt");
42 G4String pType="custom";
43 G4String pSubType="";
44 // bool first = true;
45 int pdgCode;
46 double mass;
47 double elCharge;
48 double magCharge;
49 std::string name,line;
50 // This should be compatible IMO to SLHA
51 while(getline(configFile,line))
52 {
53 std::string::size_type beg_idx,end_idx;
54 bool isQball = false;
55 bool isFCP = false; // Wendy Taylor: fractionally charged particle
56 bool isDyon = false; // Ethan Brooks Dyons
57
58 beg_idx = line.find_first_not_of("\t #");
59 if(beg_idx > 0 && line[beg_idx-1] == '#') continue;
60 end_idx = line.find_first_of( "\t ", beg_idx);
61 if (end_idx == std::string::npos) continue;
62 char *endptr;
63 pdgCode = strtol(line.substr( beg_idx, end_idx - beg_idx ).c_str(), &endptr, 0);
64 if (endptr[0] != '\0') {
65 throw std::invalid_argument("CustomMonopoleFactory::loadCustomMonopoles: Could not convert string to int: " + line.substr( beg_idx, end_idx - beg_idx ));
66 }
67
68 G4cout << "CustomMonopoleFactory: pdgCode = " << pdgCode << G4endl;
69
70 beg_idx = line.find_first_not_of("\t ",end_idx);
71 end_idx = line.find_first_of( "\t #", beg_idx);
72 if (end_idx == std::string::npos) continue;
73
74 mass = atof(line.substr( beg_idx, end_idx - beg_idx ).c_str());
75
76 beg_idx = line.find_first_not_of("\t ",end_idx);
77 end_idx = line.find_first_of( "\t #", beg_idx);
78 if (end_idx == std::string::npos) continue;
79
80 elCharge = atof(line.substr( beg_idx, end_idx - beg_idx ).c_str());
81
82 beg_idx = line.find_first_not_of("\t ",end_idx);
83 end_idx = line.find_first_of( "\t #", beg_idx);
84
85 if (end_idx == std::string::npos) continue;
86 magCharge = atof(line.substr( beg_idx, end_idx - beg_idx ).c_str());
87
88 beg_idx = line.find_first_not_of("\t# ",end_idx);
89 end_idx = line.length();
90 name = line.substr( beg_idx, end_idx - beg_idx );
91 while(name.c_str()[0] == ' ') name.erase(0,1);
92 while(name[name.size()-1] == ' ') name.erase(name.size()-1,1);
93 std::string lowerCaseName(name);
94 for(unsigned int il=0; il < lowerCaseName.length(); ++il) lowerCaseName[il] = std::tolower(lowerCaseName[il]);
95 isQball = (lowerCaseName.find("qball") != std::string::npos) ? true : false;
96
97 isFCP = (lowerCaseName.find("fcp") != std::string::npos) ? true : false;
98
99 isDyon = (lowerCaseName.find("dyonss") != std::string::npos || lowerCaseName.find("dyonos") != std::string::npos) ? true : false; // Set Dyon boolean True if dyon same sign or opposite sign is present
100 G4cout << "CustomMonopoleFactory: name = " << name << G4endl;
101
102 if(abs(pdgCode) / 1000000 == 0)
103 {
104 G4cout << "CustomMonopoleFactory: pdgCode too low: " << pdgCode << " " << abs(pdgCode) / 1000000 << G4endl;
105 continue;
106 }
107 else
108 {
109
110 double elChargeFromPDGcode = (isQball) ? (pdgCode/10)%10000/10. : (pdgCode/10)%1000/1. ;
111
112 if (isFCP)
113 {
114 // pdgCode charge encoding scheme developed by quanyin.li@cern.ch
115 float XX, YY; // XX = numerator, YY = denominator
116 XX = (abs(pdgCode)/1000)%100;
117 YY = (abs(pdgCode)/10)%100;
118 G4cout << "CustomMonopoleFactory: XX = " << XX << ", YY = " << YY << G4endl;
119
120 elChargeFromPDGcode = (pdgCode>0) ? round(100.*XX/YY)/100. : -round(100.*XX/YY)/100.;
121 G4cout << "CustomMonopoleFactory: elChargeFromPDGcode = " << elChargeFromPDGcode << G4endl;
122 }
123
124 if(isDyon) // Ethan Brooks Dyons
125 {
126 elChargeFromPDGcode = (abs((int)(pdgCode/10000)) == 412) ? -pdgCode%4120000/10 : pdgCode%4110000/10; // encoding of electric charge in the dyon PDGID
127 magCharge = (pdgCode>0) ? 1 : -1; // sign matches PDG sign, only allow for plus or minus one magnetic charge
128 G4cout << "Loading Dyons: " << magCharge << G4endl;
129 }
130
131 if (!isQball && !isFCP && !isDyon && abs((int)(pdgCode/10000)) == 412) elChargeFromPDGcode = -elChargeFromPDGcode;
132
133 if (elChargeFromPDGcode != elCharge) {
134 G4cout << "CustomMonopoleFactory: El. charges for "<< name <<" from PDGcode and 3d col. of particles.txt file do not agree: " << elChargeFromPDGcode << " / " << elCharge << G4endl;
135 G4Exception("CustomMonopoleFactory::loadCustomMonopoles","WrongElCharges",FatalException,"El charge from PDGcode and 3d col. of particles.txt file do not agree");
136 }
137 if (elCharge == 0.0 && magCharge == 0.0) {
138 G4cout << "CustomMonopoleFactory: Both electric and magnetic charges are ZEROs. Skip the particle. " << G4endl;
139 continue;
140 }
141
142 }
143
144 G4cout << "CustomMonopoleFactory: pType is " << pType << G4endl;
145 G4cout << "CustomMonopoleFactory: PDGcode of " << name << " is " << pdgCode << G4endl;
146 G4cout << "CustomMonopoleFactory: Mass of " << name << " is " << mass << G4endl;
147 G4cout << "CustomMonopoleFactory: Electrical Charge of " << name << " is "<< elCharge << G4endl;
148 G4cout << "CustomMonopoleFactory: Magnetic Charge of " << name << " is "<< magCharge << G4endl;
149
150 // CustomMonopole *particle = CustomMonopole::MonopoleDefinition(
151 CustomMonopole *particle = new CustomMonopole(
152 name, mass * CLHEP::GeV , 0.0*CLHEP::MeV, CLHEP::eplus*elCharge,
153 0, +1, 0,
154 0, 0, 0,
155 pType, 0, +1, pdgCode,
156 true, -1.0, NULL);
157 // magCharge);
158
159 particle->SetMagneticCharge(magCharge);
160 particle->PrintMonopoleInfo();
161 m_particles.insert(particle);
162 }
163
164 configFile.close();
165
166 if (m_particles.empty()) {
167 G4cout << "CustomMonopoleFactory: No particles have been loaded." << G4endl;
168 G4Exception("CustomMonopoleFactory::loadCustomMonopoles","NoParticlesLoaded",FatalException,"No particles have been loaded");
169 }
170 return;
171}
double atof(std::string_view str)
Converts a string into a double / float.
float round(const float toRound, const unsigned int decimals)
Definition Mdt.cxx:27
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses

Member Data Documentation

◆ m_particles

std::set<CustomMonopole *> CustomMonopoleFactory::m_particles
private

Definition at line 27 of file CustomMonopoleFactory.h.


The documentation for this class was generated from the following files: