CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CMSMonopolePhysics.cc
Go to the documentation of this file.
4 
5 #include "G4ParticleDefinition.hh"
6 #include "G4ProcessManager.hh"
7 
8 #include "G4StepLimiter.hh"
9 #include "G4Transportation.hh"
10 #include "G4MonopoleTransportation.hh"
11 #include "G4mplIonisation.hh"
12 #include "G4mplIonisationWithDeltaModel.hh"
13 #include "G4hMultipleScattering.hh"
14 #include "G4hIonisation.hh"
15 #include "G4hhIonisation.hh"
16 
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
20  sim::ChordFinderSetter * cfs_,
21  const edm::ParameterSet & p) :
22  G4VPhysicsConstructor("Monopole Physics"), chordFinderSetter(cfs_) {
23 
24  verbose = p.getUntrackedParameter<int>("Verbosity",0);
25  magCharge = p.getUntrackedParameter<int>("MonopoleCharge",1);
26  deltaRay = p.getUntrackedParameter<bool>("MonopoleDeltaRay",true);
27  multiSc = p.getUntrackedParameter<bool>("MonopoleMultiScatter",false);
28  transport = p.getUntrackedParameter<bool>("MonopoleTransport",true);
29  double mass = p.getUntrackedParameter<double>("MonopoleMass",200);
30  if (pdt && mass > 0.0) {
31  int ii=0;
32  for (HepPDT::ParticleDataTable::const_iterator p=pdt->begin();
33  p != pdt->end(); ++p,++ii) {
34  HepPDT::ParticleData particle = (p->second);
35  std::string particleName = (particle.name()).substr(0,8);
36  if (strcmp(particleName.c_str(),"Monopole") == 0) {
37  names.push_back(particle.name());
38  masses.push_back(mass*CLHEP::GeV);
39  elCharges.push_back((int)(particle.charge()));
40  pdgEncodings.push_back(particle.pid());
41  monopoles.push_back(0);
42  //std::cout << "CMSMonopolePhysics: Monopole[" << ii
43  if (verbose > 0) G4cout << "CMSMonopolePhysics: Monopole[" << ii
44  << "] " << particleName << " Mass "
45  << particle.mass() << " GeV, Magnetic Charge "
46  << magCharge << ", Electric Charge "
47  << particle.charge() << G4endl;
48  } else if(strcmp(particleName.c_str(),"AntiMono") == 0) {
49  names.push_back(particle.name());
50  masses.push_back(mass*CLHEP::GeV);
51  elCharges.push_back((int)(particle.charge()));
52  pdgEncodings.push_back(particle.pid());
53  monopoles.push_back(0);
54  //std::cout << "CMSMonopolePhysics: Monopole[" << ii
55  if (verbose > 0) G4cout << "CMSMonopolePhysics: Monopole[" << ii
56  << "] " << particleName << " Mass "
57  << particle.mass() << " GeV, Magnetic Charge "
58  << magCharge << ", Electric Charge "
59  << particle.charge() << G4endl;
60  }
61  }
62  }
63  // std::cout << "CMSMonopolePhysics has " << names.size()
64  if (verbose > 0) G4cout << "CMSMonopolePhysics has " << names.size()
65  << " monopole candidates and delta Ray option "
66  << deltaRay << G4endl;
67 }
68 
70 
72 
73  for (unsigned int ii=0; ii<names.size(); ++ii) {
74  if (!monopoles[ii]) {
75  G4Monopole* mpl = new G4Monopole(names[ii], pdgEncodings[ii],
76  masses[ii], ((pdgEncodings[ii] > 0 ) ? magCharge : -magCharge), elCharges[ii]);;
77  monopoles[ii] = mpl;
78  //std::cout << "Create G4Monopole " << names[ii]
79  if (verbose > 0) G4cout << "Create G4Monopole " << names[ii]
80  << " of mass " << masses[ii]/CLHEP::GeV
81  << " GeV, magnetic charge " << ((pdgEncodings[ii] > 0) ? magCharge : -magCharge)
82  << ", electric charge " << elCharges[ii]
83  << " and PDG encoding " << pdgEncodings[ii]
84  << " at " << monopoles[ii] << G4endl;
85  }
86  }
87 }
88 
90  // Add standard EM Processes
91 
92  if (verbose > 0)
93  G4cout << "### CMSMonopolePhysics ConstructProcess()" << G4endl;
94  for (unsigned int ii=0; ii<monopoles.size(); ++ii) {
95  if (monopoles[ii]) {
96  G4Monopole* mpl = monopoles[ii];
97  G4ProcessManager *pmanager = mpl->GetProcessManager();
98  if(!pmanager) {
99  std::ostringstream o;
100  o << "Monopole without a Process Manager";
101  G4Exception("CMSMonopolePhysics::ConstructProcess()","",
102  FatalException,o.str().c_str());
103  }
104 
105  // Clear process list, for some reason G4Transportation is added
106  // somewhere, and it is not wanted (at least that was the
107  // behaviour before MT)
108  const G4int procLength = pmanager->GetProcessListLength();
109  for(G4int ip=procLength-1; ip >= 0; --ip) {
110  G4VProcess *proc = pmanager->RemoveProcess(ip);
111  if(!proc) {
112  std::ostringstream o;
113  o << "Clearing Monopole Process Manager failed for process " << ip << ", total number of processes " << procLength;
114  G4Exception("CMSMonopolePhysics::ConstructProcess()","",
115  FatalException,o.str().c_str());
116  }
117  }
118 
119  G4String particleName = mpl->GetParticleName();
120  G4double magn = mpl->MagneticCharge();
121  G4double mass = mpl->GetPDGMass();
122  if (verbose > 1)
123  G4cout << "### CMSMonopolePhysics instantiates for " << particleName
124  << " at " << mpl << " Mass " << mass/CLHEP::GeV
125  << " GeV Mag " << magn << " Process manager " << pmanager
126  << G4endl;
127 
128  // defined monopole parameters and binning
129 
130  G4double emin = mass/20000.;
131  if(emin < CLHEP::keV) emin = CLHEP::keV;
132  G4double emax = std::max(10.*CLHEP::TeV, mass*100);
133  G4int nbin = G4int(std::log10(emax/emin));
134  if (nbin < 1) nbin = 1;
135  nbin *= 10;
136 
137  G4int idx = 1;
138  if (verbose > 1)
139  G4cout << "### Magnetic charge " << magn << " and electric charge "
140  << mpl->GetPDGCharge() <<"\n # of bins in dE/dx table = "
141  << nbin << " in the range " << emin << ":" << emax << G4endl;
142 
143  if (magn == 0.0 || (!transport)) {
144  pmanager->AddProcess( new G4Transportation(verbose), -1, 0, 0);
145  } else {
146  pmanager->AddProcess( new G4MonopoleTransportation(mpl,chordFinderSetter,verbose), -1, 0, 0);
147  }
148 
149  if (mpl->GetPDGCharge() != 0.0) {
150  if (multiSc) {
151  G4hMultipleScattering* hmsc = new G4hMultipleScattering();
152  pmanager->AddProcess(hmsc, -1, idx, idx);
153  ++idx;
154  }
155  if (deltaRay) {
156  G4hIonisation* hhioni = new G4hIonisation();
157  hhioni->SetDEDXBinning(nbin);
158  hhioni->SetMinKinEnergy(emin);
159  hhioni->SetMaxKinEnergy(emax);
160  pmanager->AddProcess(hhioni, -1, idx, idx);
161  } else {
162  G4hhIonisation* hhioni = new G4hhIonisation();
163  hhioni->SetDEDXBinning(nbin);
164  hhioni->SetMinKinEnergy(emin);
165  hhioni->SetMaxKinEnergy(emax);
166  pmanager->AddProcess(hhioni, -1, idx, idx);
167  }
168  ++idx;
169  }
170  if(magn != 0.0) {
171  G4mplIonisation* mplioni = new G4mplIonisation(magn);
172  mplioni->SetDEDXBinning(nbin);
173  mplioni->SetMinKinEnergy(emin);
174  mplioni->SetMaxKinEnergy(emax);
175  if (!deltaRay) {
176  G4mplIonisationWithDeltaModel* mod =
177  new G4mplIonisationWithDeltaModel(magn,"PAI");
178  mplioni->AddEmModel(0,mod,mod);
179  }
180  pmanager->AddProcess(mplioni, -1, idx, idx);
181  ++idx;
182  }
183  pmanager->AddProcess( new G4StepLimiter(), -1, -1, idx);
184  if (verbose > 1) pmanager->DumpInfo();
185  }
186  }
187 }
T getUntrackedParameter(std::string const &, T const &) const
const double GeV
Definition: MathUtil.h:16
std::vector< int > pdgEncodings
HepPDT::ParticleDataTable ParticleDataTable
TrainProcessor *const proc
Definition: MVATrainer.cc:101
int ii
Definition: cuy.py:588
std::vector< G4Monopole * > monopoles
CMSMonopolePhysics(const HepPDT::ParticleDataTable *table_, sim::ChordFinderSetter *cfs_, const edm::ParameterSet &p)
std::vector< int > elCharges
HepPDT::ParticleData ParticleData
std::vector< std::string > names
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
sim::ChordFinderSetter * chordFinderSetter
std::vector< double > masses
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4