CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions | Static Private Member Functions | Static Private Attributes
CustomParticleFactory Class Reference

#include <CustomParticleFactory.h>

Static Public Member Functions

static bool isCustomParticle (G4ParticleDefinition *particle)
 
static void loadCustomParticles (const std::string &filePath)
 

Static Private Member Functions

static void addCustomParticle (int pdgCode, double mass, const std::string &name)
 
static G4DecayTable * getAntiDecayTable (int pdgId, G4DecayTable *theDecayTable)
 
static G4DecayTable * getDecayTable (std::ifstream *configFile, int pdgId)
 
static void getMassTable (std::ifstream *configFile)
 
static std::string ToLower (std::string str)
 

Static Private Attributes

static bool loaded = false
 
static std::set
< G4ParticleDefinition * > 
m_particles
 

Detailed Description

Definition at line 15 of file CustomParticleFactory.h.

Member Function Documentation

void CustomParticleFactory::addCustomParticle ( int  pdgCode,
double  mass,
const std::string &  name 
)
staticprivate

Definition at line 75 of file CustomParticleFactory.cc.

References funct::abs(), DeDxDiscriminatorTools::charge(), CustomParticle::GetCloud(), CustomParticle::GetSpectator(), GeV, MeV, NULL, CustomPDGParser::s_charge(), CustomPDGParser::s_isMesonino(), CustomPDGParser::s_isRHadron(), CustomPDGParser::s_isSbaryon(), CustomPDGParser::s_issbottomHadron(), CustomPDGParser::s_isSLepton(), CustomPDGParser::s_isstopHadron(), CustomPDGParser::s_spin(), CustomParticle::SetCloud(), CustomParticle::SetSpectator(), spin(), TopDecayID::stable, AlCaHLTBitMon_QueryRunRegistry::string, and create_public_lumi_plots::width.

75  {
76 
77  if(abs(pdgCode)%100 <14 && abs(pdgCode) / 1000000 == 0){
78  edm::LogError("") << "Pdg code too low " << pdgCode << " "<<abs(pdgCode) / 1000000;
79  return;
80  }
81 
82 
84  G4String pType="custom";
85  G4String pSubType="";
86  G4double spectatormass;
87  G4ParticleDefinition* spectator;
89  if(CustomPDGParser::s_isRHadron(pdgCode)) pType = "rhadron";
90  if(CustomPDGParser::s_isSLepton(pdgCode)) pType = "sLepton";
91  if(CustomPDGParser::s_isMesonino(pdgCode)) pType = "mesonino";
92  if(CustomPDGParser::s_isSbaryon(pdgCode)) pType = "sbaryon";
93 
94  double massGeV =mass*GeV;
95  double width = 0.0*MeV;
96  double charge = eplus* CustomPDGParser::s_charge(pdgCode);
97  if (name.compare(0,4,"~HIP") == 0)
98  {
99 
100  if ((name.compare(0,7,"~HIPbar") == 0)) {std::string str = name.substr (7); charge=eplus*atoi(str.c_str())/3.;}
101  else {std::string str = name.substr (4); charge=eplus*atoi(str.c_str())*-1./3.; }
102  }
103  if (name.compare(0,9,"anti_~HIP") == 0)
104  {
105 
106  if ((name.compare(0,12,"anti_~HIPbar") == 0)) {std::string str = name.substr (12); charge=eplus*atoi(str.c_str())*-1./3.;}
107  else {std::string str = name.substr (9); charge=eplus*atoi(str.c_str())*1./3.; }
108  }
109  int spin = (int)CustomPDGParser::s_spin(pdgCode)-1;
110  int parity = +1;
111  int conjugation = 0;
112  int isospin = 0;
113  int isospinZ = 0;
114  int gParity = 0;
115  int lepton = 0; //FIXME:
116  int baryon = 1; //FIXME:
117  bool stable = true;
118  double lifetime = -1;
119 
120  G4DecayTable *decaytable = NULL;
121  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
122 
123  CustomParticle *particle = new CustomParticle(name, massGeV, width, charge, spin,
124  parity, conjugation, isospin, isospinZ,
125  gParity, pType, lepton, baryon, pdgCode,
126  stable, lifetime, decaytable);
127 
128  if(pType == "rhadron" && name!="~g"){
129  G4String cloudname = name+"cloud";
130  G4String cloudtype = pType+"cloud";
131  spectator = theParticleTable->FindParticle(1000021);
132  spectatormass = spectator->GetPDGMass();
133  G4double cloudmass = mass-spectatormass/GeV;
134  CustomParticle *tmpParticle = new CustomParticle(
135  cloudname, cloudmass * GeV , 0.0*MeV, 0 ,
136  0, +1, 0,
137  0, 0, 0,
138  cloudtype, 0, +1, 0,
139  true, -1.0, NULL );
140  particle->SetCloud(tmpParticle);
141  particle->SetSpectator(spectator);
142 
143  edm::LogInfo("CustomPhysics")<<name<<" being assigned "
144  <<particle->GetCloud()->GetParticleName()
145  <<" and "<<particle->GetSpectator()->GetParticleName();
146  edm::LogInfo("CustomPhysics")<<"Masses: "
147  <<particle->GetPDGMass()/GeV<<" Gev, "
148  <<particle->GetCloud()->GetPDGMass()/GeV<<" GeV and "
149  <<particle->GetSpectator()->GetPDGMass()/GeV<<" GeV.";
150  } else if(pType == "mesonino" || pType == "sbaryon") {
151  int sign=1;
152  if(pdgCode < 0 ) sign=-1;
153 
154  G4String cloudname = name+"cloud";
155  G4String cloudtype = pType+"cloud";
156  if(CustomPDGParser::s_isstopHadron(pdgCode)) {
157  spectator = theParticleTable->FindParticle(1000006*sign);
158  }
159  else {
160  if (CustomPDGParser::s_issbottomHadron(pdgCode)) {
161  spectator = theParticleTable->FindParticle(1000005*sign);
162  } else {
163  spectator = 0;
164  edm::LogError("CustomPhysics")<< " Cannot find spectator parton";
165  }
166  }
167  spectatormass = spectator->GetPDGMass();
168  G4double cloudmass = mass-spectatormass/GeV;
169  CustomParticle *tmpParticle = new CustomParticle(
170  cloudname, cloudmass * GeV , 0.0*MeV, 0 ,
171  0, +1, 0,
172  0, 0, 0,
173  cloudtype, 0, +1, 0,
174  true, -1.0, NULL );
175  particle->SetCloud(tmpParticle);
176  particle->SetSpectator(spectator);
177 
178  edm::LogInfo("CustomPhysics")<<name<<" being assigned "
179  <<particle->GetCloud()->GetParticleName()
180  <<" and "<<particle->GetSpectator()->GetParticleName();
181  edm::LogInfo("CustomPhysics")<<"Masses: "
182  <<particle->GetPDGMass()/GeV<<" Gev, "
183  <<particle->GetCloud()->GetPDGMass()/GeV<<" GeV and "
184  <<particle->GetSpectator()->GetPDGMass()/GeV<<" GeV.";
185  }
186  else{
187  particle->SetCloud(0);
188  particle->SetSpectator(0);
189  }
190  m_particles.insert(particle);
191 }
const double GeV
Definition: MathUtil.h:16
static std::set< G4ParticleDefinition * > m_particles
static double s_charge(int pdg)
static const int stable
Definition: TopGenEvent.h:11
static bool s_isSbaryon(int pdg)
void SetCloud(G4ParticleDefinition *theCloud)
G4ParticleDefinition * GetCloud()
#define NULL
Definition: scimark2.h:8
double charge(const std::vector< uint8_t > &Ampls)
const double MeV
static bool s_isMesonino(int pdg)
static bool s_isSLepton(int pdg)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void SetSpectator(G4ParticleDefinition *theSpectator)
static double s_spin(int pdg)
G4ParticleDefinition * GetSpectator()
static bool s_isRHadron(int pdg)
static bool s_issbottomHadron(int pdg)
static bool s_isstopHadron(int pdg)
float spin(float ph)
G4DecayTable * CustomParticleFactory::getAntiDecayTable ( int  pdgId,
G4DecayTable *  theDecayTable 
)
staticprivate

Definition at line 321 of file CustomParticleFactory.cc.

References i, j, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

321  {
322 
323  std::vector<std::string> name(4);
324  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
325 
326  std::string parentName = theParticleTable->FindParticle(-pdgId)->GetParticleName();
327  G4DecayTable *decaytable= new G4DecayTable();
328 
329  for(int i=0;i<theDecayTable->entries();i++){
330  //G4PhaseSpaceDecayChannel *theDecayChannel = theDecayTable->GetDecayChannel(i);
331  G4VDecayChannel *theDecayChannel = theDecayTable->GetDecayChannel(i);
332  for(int j=0;j<theDecayChannel->GetNumberOfDaughters();j++){
333  int id = theDecayChannel->GetDaughter(j)->GetAntiPDGEncoding();
334  std::string nameTmp = theParticleTable->FindParticle(id)->GetParticleName();
335  name[j] = nameTmp;
336  }
337  G4PhaseSpaceDecayChannel *aDecayChannel =
338  new G4PhaseSpaceDecayChannel(parentName,
339  theDecayChannel->GetBR(),
340  theDecayChannel->GetNumberOfDaughters(),
341  name[0],name[1],name[2],name[3]);
342  decaytable->Insert(aDecayChannel);
343  }
344  return decaytable;
345 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
G4DecayTable * CustomParticleFactory::getDecayTable ( std::ifstream *  configFile,
int  pdgId 
)
staticprivate

Definition at line 265 of file CustomParticleFactory.cc.

References beamvalidation::br, i, geometryCSVtoXML::line, mergeVDriftHistosByStation::name, benchmark_cfg::pdgId, and AlCaHLTBitMon_QueryRunRegistry::string.

265  {
266 
267  double br;
268  int nDaughters;
269  std::vector<int> pdg(4);
271  std::vector<std::string> name(4);
272 
273  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
274 
275  std::string parentName = theParticleTable->FindParticle(pdgId)->GetParticleName();
276  G4DecayTable *decaytable= new G4DecayTable();
277 
278  while(getline(*configFile,line)) {
279 
280  line.erase(0, line.find_first_not_of(" \t")); // remove leading whitespace
281  if (line.length()==0) continue; // skip blank lines
282  if (line.at(0) == '#' &&
283  ToLower(line).find("br") < line.npos &&
284  ToLower(line).find("nda") < line.npos) continue; // skip a comment of the form: # BR NDA ID1 ID2
285  if (line.at(0) == '#') { // other comments signal the end of the decay block
286  edm::LogInfo("CustomPhysics") << " Finished the Decay Table ";
287  break;
288  }
289 
290  pdg.clear();
291  name.clear();
292 
293  std::stringstream sstr(line);
294  sstr >> br >> nDaughters; // assume SLHA format, e.g.: 1.49435135E-01 2 -15 16 # BR(H+ -> tau+ nu_tau)
295  edm::LogInfo("CustomPhysics") << " Branching Ratio: " << br << ", Number of Daughters: " << nDaughters;
296  if (nDaughters > 4) {
297  edm::LogError("CustomPhysics") << "Number of daughters is too large (max = 4): " << nDaughters << " for pdgId: " << pdgId;
298  break;
299  }
300  for(int i=0; i<nDaughters; i++) {
301  sstr >> pdg[i];
302  edm::LogInfo("CustomPhysics") << " Daughter ID " << pdg[i];
303  }
304  for (int i=0;i<nDaughters;i++) {
305  if (!theParticleTable->FindParticle(pdg[i])) {
306  edm::LogWarning("CustomPhysics")<<pdg[i]<<" CustomParticleFactory::getDecayTable(): not found in the table!";
307  continue;
308  }
309  name[i] = theParticleTable->FindParticle(pdg[i])->GetParticleName();
310  }
312  G4PhaseSpaceDecayChannel *aDecayChannel = new G4PhaseSpaceDecayChannel(parentName, br, nDaughters,
313  name[0],name[1],name[2],name[3]);
314  decaytable->Insert(aDecayChannel);
315 
316  }
317 
318  return decaytable;
319 }
int i
Definition: DBlmapReader.cc:9
static std::string ToLower(std::string str)
void CustomParticleFactory::getMassTable ( std::ifstream *  configFile)
staticprivate

Definition at line 193 of file CustomParticleFactory.cc.

References funct::abs(), geometryCSVtoXML::line, mergeVDriftHistosByStation::name, benchmark_cfg::pdgId, CustomPDGParser::s_isRHadron(), CustomPDGParser::s_isstopHadron(), AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

193  {
194 
195  int pdgId;
196  double mass;
199  // This should be compatible IMO to SLHA
200  while (getline(*configFile,line)) {
201  line.erase(0, line.find_first_not_of(" \t")); // remove leading whitespace
202  if (line.length()==0 || line.at(0) == '#') continue; // skip blank lines and comments
203  if (ToLower(line).find("block") < line.npos) {
204  edm::LogInfo("CustomPhysics") << " Finished the Mass Table ";
205  break;
206  }
207  std::stringstream sstr(line);
208  sstr >> pdgId >> mass >> tmp >> name; // Assume SLHA format, e.g.: 1000001 5.68441109E+02 # ~d_L
209 
210  edm::LogInfo("CustomPhysics") << "Calling addCustomParticle for pdgId: " << pdgId
211  << ", mass " << mass << ", name " << name;
212  addCustomParticle(pdgId, fabs(mass), name);
214  int pdgIdPartner = pdgId%100;
215  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
216  G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgIdPartner);
217  //Add antiparticles for SUSY particles only, not for rHadrons.
218  edm::LogInfo("CustomPhysics") << "Found aParticle = " << aParticle
219  << ", pdgId = " << pdgId
220  << ", pdgIdPartner = " << pdgIdPartner
221  << ", CustomPDGParser::s_isRHadron(pdgId) = " << CustomPDGParser::s_isRHadron(pdgId)
222  << ", CustomPDGParser::s_isstopHadron(pdgId) = " << CustomPDGParser::s_isstopHadron(pdgId);
223 
224  if (aParticle &&
225  !CustomPDGParser::s_isRHadron(pdgId) &&
227  pdgId!=1000006 &&
228  pdgId!=-1000006 &&
229  pdgId!=25 &&
230  pdgId!=35 &&
231  pdgId!=36 &&
232  pdgId!=37){
233  int sign = aParticle->GetAntiPDGEncoding()/pdgIdPartner;
234  edm::LogInfo("CustomPhysics") << "Found sign = " << sign
235  << ", aParticle->GetAntiPDGEncoding() " << aParticle->GetAntiPDGEncoding()
236  << ", pdgIdPartner = " << pdgIdPartner;
237  if(abs(sign)!=1) {
238  edm::LogInfo("CustomPhysics")<<"sgn: "<<sign<<" a "
239  <<aParticle->GetAntiPDGEncoding()
240  <<" b "<<pdgIdPartner;
241  aParticle->DumpTable();
242  }
243  if(sign==-1 && pdgId!=25 && pdgId!=35 && pdgId!=36 && pdgId!=37 && pdgId!=1000039){
244  tmp = "anti_"+name;
245  edm::LogInfo("CustomPhysics") << "Calling addCustomParticle for antiparticle with pdgId: " << -pdgId
246  << ", mass " << mass << ", name " << tmp;
247  addCustomParticle(-pdgId, mass, tmp);
248  theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
249  }
250  else theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId);
251  }
252 
253  if(pdgId==1000039) theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId); // gravitino
254  if(pdgId==1000024 || pdgId==1000037 || pdgId==37) {
255  tmp = "anti_"+name;
256  edm::LogInfo("CustomPhysics") << "Calling addCustomParticle for antiparticle (2) with pdgId: " << -pdgId
257  << ", mass " << mass << ", name " << tmp;
258  addCustomParticle(-pdgId, mass, tmp);
259  theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
260  }
261 
262  }
263 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static std::string ToLower(std::string str)
static void addCustomParticle(int pdgCode, double mass, const std::string &name)
static bool s_isRHadron(int pdg)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
static bool s_isstopHadron(int pdg)
bool CustomParticleFactory::isCustomParticle ( G4ParticleDefinition *  particle)
static

Definition at line 28 of file CustomParticleFactory.cc.

Referenced by CustomPhysicsList::addCustomPhysics(), and CustomPhysicsListSS::addCustomPhysics().

29 {
30  return (m_particles.find(particle)!=m_particles.end());
31 }
static std::set< G4ParticleDefinition * > m_particles
void CustomParticleFactory::loadCustomParticles ( const std::string &  filePath)
static

Definition at line 33 of file CustomParticleFactory.cc.

References HDQMDatabaseProducer::configFile, alignCSCRings::e, GeV, geometryCSVtoXML::line, MeV, benchmark_cfg::pdgId, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and create_public_lumi_plots::width.

Referenced by CustomPhysicsList::ConstructParticle(), and CustomPhysicsListSS::ConstructParticle().

33  {
34  if(loaded) return;
35  loaded = true;
36 
37  std::ifstream configFile(filePath.c_str());
38 
40  edm::LogInfo("CustomPhysics") << "Reading Custom Particle and G4DecayTable from " << filePath;
41  // This should be compatible IMO to SLHA
42  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
43  while(getline(configFile,line)){
44  line.erase(0, line.find_first_not_of(" \t")); // Remove leading whitespace.
45  if (line.length()==0 || line.at(0) == '#') continue; // Skip blank lines and comments.
46  if (ToLower(line).find("block") < line.npos && // The mass table begins with a line containing "BLOCK MASS".
47  ToLower(line).find("mass") < line.npos) {
48  edm::LogInfo("CustomPhysics") << " Retrieving mass table.";
50  }
51  if(line.find("DECAY")<line.npos){
52  int pdgId;
53  double width;
54  std::string tmpString;
55  std::stringstream lineStream(line);
56  lineStream >> tmpString >> pdgId >> width; // assume SLHA format, e.g.: DECAY 1000021 5.50675438E+00 # gluino decays
57  edm::LogInfo("CustomPhysics") << "G4DecayTable: pdgID, width " << pdgId << ", " << width;
58  G4DecayTable* aDecayTable = getDecayTable(&configFile, pdgId);
59  G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgId);
60  G4ParticleDefinition *aAntiParticle = theParticleTable->FindAntiParticle(pdgId);
61  if (!aParticle) continue;
62  aParticle->SetDecayTable(aDecayTable);
63  aParticle->SetPDGStable(false);
64  aParticle->SetPDGLifeTime(1.0/(width*GeV)*6.582122e-22*MeV*s);
65  if(aAntiParticle && aAntiParticle->GetPDGEncoding()!=pdgId){
66  aAntiParticle->SetDecayTable(getAntiDecayTable(pdgId,aDecayTable));
67  aAntiParticle->SetPDGStable(false);
68  aAntiParticle->SetPDGLifeTime(1.0/(width*GeV)*6.582122e-22*MeV*s);
69  }
70  }
71  }
72 }
const double GeV
Definition: MathUtil.h:16
const double MeV
static std::string ToLower(std::string str)
static void getMassTable(std::ifstream *configFile)
static G4DecayTable * getDecayTable(std::ifstream *configFile, int pdgId)
static G4DecayTable * getAntiDecayTable(int pdgId, G4DecayTable *theDecayTable)
std::string CustomParticleFactory::ToLower ( std::string  str)
staticprivate

Definition at line 348 of file CustomParticleFactory.cc.

References i.

348  {
349  std::locale loc;
350  for (std::string::size_type i=0; i<str.length(); ++i)
351  str.at(i) = std::tolower(str.at(i),loc);
352  return str;
353 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type

Member Data Documentation

bool CustomParticleFactory::loaded = false
staticprivate

Definition at line 28 of file CustomParticleFactory.h.

std::set< G4ParticleDefinition * > CustomParticleFactory::m_particles
staticprivate

Definition at line 29 of file CustomParticleFactory.h.