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 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 66 of file CustomParticleFactory.cc.

References funct::abs(), DeDxDiscriminatorTools::charge(), CustomParticle::GetCloud(), CustomParticle::GetSpectator(), 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.

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

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

289  {
290 
291  std::vector<std::string> name(4);
292  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
293 
294  std::string parentName = theParticleTable->FindParticle(-pdgId)->GetParticleName();
295  G4DecayTable *decaytable= new G4DecayTable();
296 
297  for(int i=0;i<theDecayTable->entries();i++){
298  //G4PhaseSpaceDecayChannel *theDecayChannel = theDecayTable->GetDecayChannel(i);
299  G4VDecayChannel *theDecayChannel = theDecayTable->GetDecayChannel(i);
300  for(int j=0;j<theDecayChannel->GetNumberOfDaughters();j++){
301  int id = theDecayChannel->GetDaughter(j)->GetAntiPDGEncoding();
302  std::string nameTmp = theParticleTable->FindParticle(id)->GetParticleName();
303  name[j] = nameTmp;
304  }
305  G4PhaseSpaceDecayChannel *aDecayChannel =
306  new G4PhaseSpaceDecayChannel(parentName,
307  theDecayChannel->GetBR(),
308  theDecayChannel->GetNumberOfDaughters(),
309  name[0],name[1],name[2],name[3]);
310  decaytable->Insert(aDecayChannel);
311  }
312  return decaytable;
313 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
G4DecayTable * CustomParticleFactory::getDecayTable ( std::ifstream *  configFile,
int  pdgId 
)
staticprivate

Definition at line 244 of file CustomParticleFactory.cc.

References beamvalidation::br, i, mergeVDriftHistosByStation::name, AlCaHLTBitMon_QueryRunRegistry::string, runonSM::text, and tmp.

244  {
245 
246  double br;
247  int nDaughters;
248  std::vector<int> pdg(4);
250  std::vector<std::string> name(4);
251 
252  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
253 
254  std::string parentName = theParticleTable->FindParticle(pdgId)->GetParticleName();
255  G4DecayTable *decaytable= new G4DecayTable();
256 
257  getline(*configFile,tmp);
258 
259  while(!configFile->eof()){
260  pdg.clear();
261  name.clear();
262  (*configFile)>>br>>nDaughters;
263  for(int i=0;i<nDaughters;i++) (*configFile)>>pdg[i];
264  getline(*configFile,tmp);
265  for(int i=0;i<nDaughters;i++){
266  if(!theParticleTable->FindParticle(pdg[i])){
267  //std::cout<<pdg[i]<<" CustomParticleFactory::getDecayTable(): not found in the table!"<<std::endl;
268  continue;
269  }
270  name[i] = theParticleTable->FindParticle(pdg[i])->GetParticleName();
271  }
273  G4PhaseSpaceDecayChannel *aDecayChannel = new G4PhaseSpaceDecayChannel(parentName, br, nDaughters,
274  name[0],name[1],name[2],name[3]);
275  decaytable->Insert(aDecayChannel);
276 
278 
279  char text[200];
280  configFile->get(text,2);
281  tmp.clear();
282  tmp.append(text);
283  if(tmp.find("#")<tmp.npos) break;
284  }
285 
286  return decaytable;
287 }
int i
Definition: DBlmapReader.cc:9
tuple text
Definition: runonSM.py:42
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void CustomParticleFactory::getMassTable ( std::ifstream *  configFile)
staticprivate

Definition at line 192 of file CustomParticleFactory.cc.

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

192  {
193 
194  int pdgId;
195  double mass;
198  // This should be compatible IMO to SLHA
199  while(getline(*configFile,line))
200  {
201  if(tmp.find("Blo")<tmp.npos) break;
202  std::stringstream sstr(line);
203  sstr >>pdgId>>mass>>tmp>>name;
204 
205  addCustomParticle(pdgId, fabs(mass), name);
207  int pdgIdPartner = pdgId%100;
208  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
209  G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgIdPartner);
210  //Add antiparticles for SUSY particles only, not for rHadrons.
211  if(aParticle && !CustomPDGParser::s_isRHadron(pdgId) && !CustomPDGParser::s_isstopHadron(pdgId)&& pdgId!=1000006 && pdgId!=-1000006 && pdgId!=25 && pdgId!=35 && pdgId!=36 && pdgId!=37){
212  int sign = aParticle->GetAntiPDGEncoding()/pdgIdPartner;
213  if(abs(sign)!=1) {
214  std::cout<<"sgn: "<<sign<<" a "
215  <<aParticle->GetAntiPDGEncoding()
216  <<" b "<<pdgIdPartner
217  <<std::endl;
218  aParticle->DumpTable();
219  }
220  if(sign==-1 && pdgId!=25 && pdgId!=35 && pdgId!=36 && pdgId!=37 && pdgId!=1000039){
221  tmp = "anti_"+name;
222  addCustomParticle(-pdgId, mass, tmp);
223  theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
224  }
225  else theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId);
226  }
227 
228  if(pdgId==1000039) theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId);
229  if(pdgId==1000024 || pdgId==1000037 || pdgId==37) {
230  tmp = "anti_"+name;
231  addCustomParticle(-pdgId, mass, tmp);
232  theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
233  }
234 
235 /* getline(*configFile,tmp);
236  char text[100];
237  configFile->get(text,3);
238  tmp.clear();
239  tmp.append(text);
240  if(tmp.find("Bl")<tmp.npos) break;*/
241  }
242 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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
tuple cout
Definition: gather_cfg.py:121
static bool s_isstopHadron(int pdg)
bool CustomParticleFactory::isCustomParticle ( G4ParticleDefinition *  particle)
static

Definition at line 27 of file CustomParticleFactory.cc.

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

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

Definition at line 32 of file CustomParticleFactory.cc.

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

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

32  {
33  if(loaded) return;
34  loaded = true;
35 
36  std::ifstream configFile(filePath.c_str());
37 
39  // This should be compatible IMO to SLHA
40  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
41  while(getline(configFile,line)){
42  if(line.find("PDG code")<line.npos) getMassTable(&configFile);
43  if(line.find("DECAY")<line.npos){
44  int pdgId;
45  double width;
46  std::string tmpString;
47  std::stringstream lineStream(line);
48  lineStream>>tmpString>>pdgId>>width;
49  G4DecayTable* aDecayTable = getDecayTable(&configFile, pdgId);
50  G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgId);
51  G4ParticleDefinition *aAntiParticle = theParticleTable->FindAntiParticle(pdgId);
52  if(!aParticle) continue;
53  aParticle->SetDecayTable(aDecayTable);
54  aParticle->SetPDGStable(false);
55  aParticle->SetPDGLifeTime(1.0/(width*GeV)*6.582122e-22*MeV*s);
56  if(aAntiParticle && aAntiParticle->GetPDGEncoding()!=pdgId){
57  //aAntiParticle->SetDecayTable(getAntiDecayTable(pdgId,aDecayTable));
58  aAntiParticle->SetPDGStable(false);
59  aParticle->SetPDGLifeTime(1.0/(width*GeV)*6.582122e-22*MeV*s);
60  }
61  }
62  }
63 }
static void getMassTable(std::ifstream *configFile)
static G4DecayTable * getDecayTable(std::ifstream *configFile, int pdgId)

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.