/home/cern/BDSIM_new/src/BDSGlobalConstants.cc

00001 
00007 const int DEBUG = 0;
00008 
00009 #include "BDSGlobalConstants.hh"
00010 
00011 #include "G4UniformMagField.hh"
00012 
00013 #include <cstdlib>
00014 
00015 #include <assert.h>
00016 
00017 #include<string>
00018 #include<stack>
00019 
00020 using namespace std;
00021 
00022 G4double NumSpoilerRadLen=1.;
00023 
00024 BDSGlobalConstants::BDSGlobalConstants(struct Options& opt)
00025 {
00026 
00027   // defaults:
00028   itsEnergyOffset=0.;
00029   itsTrackWeightFactor=1.0;
00030   
00031   if(opt.physicsList == "") 
00032     itsPhysListName = "standard";
00033   else
00034     itsPhysListName = opt.physicsList;
00035 
00036   if(opt.pipeMaterial == "") 
00037     itsPipeMaterial = "Vacuum";
00038   else
00039     itsPipeMaterial = opt.pipeMaterial;
00040 
00041   if(opt.vacMaterial == "") 
00042     itsVacMaterial = "Vacuum";
00043   else
00044     itsVacMaterial = opt.vacMaterial;
00045   
00046   
00047   tmpParticleName = G4String(opt.particleName);
00048   
00049   itsBeamTotalEnergy = opt.beamEnergy * GeV;
00050 
00051   //not yet implemented!
00052   if (opt.backgroundScaleFactor > 1e-9)
00053     itsBackgroundScaleFactor = opt.backgroundScaleFactor;
00054   else
00055     itsBackgroundScaleFactor = 1.0;
00056 
00057   itsComponentBoxSize = opt.componentBoxSize *m;
00058   itsTunnelRadius = opt.tunnelRadius * m;
00059   itsBeampipeRadius = opt.beampipeRadius * m;
00060   itsBeampipeThickness = opt.beampipeThickness * m;
00061     
00062   itsThresholdCutCharged = opt.thresholdCutCharged * GeV;
00063   itsThresholdCutPhotons = opt.thresholdCutPhotons * GeV;
00064   itsTrackWeightFactor = opt.trackWeightFactor;
00065   itsProdCutPhotons = opt.prodCutPhotons * m;
00066   itsProdCutPhotonsP = opt.prodCutPhotonsP * m;
00067   itsProdCutElectrons = opt.prodCutElectrons * m;
00068   itsProdCutElectronsP = opt.prodCutElectronsP * m;
00069   itsProdCutPositrons = opt.prodCutPositrons * m;
00070   itsProdCutPositronsP = opt.prodCutPositronsP * m;
00071 
00072   itsDeltaChord = opt.deltaChord * m;
00073   itsChordStepMinimum = opt.chordStepMinimum * m;
00074   itsDeltaIntersection= opt.deltaIntersection * m;
00075   itsMinimumEpsilonStep = opt.minimumEpsilonStep;
00076   itsMaximumEpsilonStep = opt.maximumEpsilonStep;
00077   itsDeltaOneStep = opt.deltaOneStep * m;
00078 
00079 
00080   doTwiss = opt.doTwiss;
00081 
00082   itsTurnOnInteractions = opt.turnOnInteractions;
00083 
00084   itsUseLowEMPhysics = opt.useLowEMPhysics;
00085 
00086   itsSynchRadOn = opt.synchRadOn;
00087 
00088   itsSynchRescale = opt.synchRescale; // rescale due to synchrotron
00089 
00090   itsSynchTrackPhotons= opt.synchTrackPhotons;
00091 
00092   itsSynchPrimaryGen = 0;
00093 
00094   itsSynchLowX = opt.synchLowX;
00095 
00096   itsSynchLowGamE = opt.synchLowGamE * GeV;  // lowest gamma energy
00097 
00098   itsSynchPhotonMultiplicity = opt.synchPhotonMultiplicity;
00099 
00100   itsSynchMeanFreeFactor = opt.synchMeanFreeFactor;
00101 
00102   itsPlanckOn = opt.planckOn;
00103 
00104   itsBDSeBremOn = opt.eBremOn;
00105 
00106   itsLengthSafety = opt.lengthSafety * m;
00107 
00108   itsNumberOfParticles = opt.numberOfParticles;
00109 
00110   itsNumberToGenerate = opt.numberToGenerate;
00111 
00112   itsNumberOfEventsPerNtuple = opt.numberOfEventsPerNtuple;
00113   
00114   itsEventNumberOffset = opt.eventNumberOffset;
00115   
00116   itsRandomSeed = opt.randomSeed;
00117  
00118   if(opt.useTimer) {
00119     itsTimer=new G4Timer();
00120     itsUseTimer = opt.useTimer;
00121   }  
00122 
00123   itsUseEMHadronic = opt.useEMHadronic;
00124 
00125   itsUseMuonPairProduction = opt.useMuonPairProduction;
00126 
00127   itsMuonProductionScaleFactor = opt.muonProductionScaleFactor;
00128 
00129   itsHadronInelasticScaleFactor = opt.hadronInelasticScaleFactor;
00130 
00131   itsStoreMuonTrajectories = opt.storeMuonTrajectories;
00132   itsStoreNeutronTrajectories = opt.storeNeutronTrajectories;
00133   itsStoreTrajectory = opt.storeTrajectory;
00134 
00135   //G4cout<<"STOREA TRAJ = "<< itsStoreTrajectory<<G4endl;
00136 
00137   itsUseMuonShowers = opt.useMuonShowers;
00138 
00139   itsMuonLowestGeneratedEnergy = opt.muonLowestGeneratedEnergy * GeV;
00140 
00141   stopTracks = opt.stopTracks; 
00142 
00143   // defaults - parameters of the laserwire process
00144 
00145   itsLaserwireWavelength = 0.4 * micrometer;
00146   itsLaserwireDir = G4ThreeVector(1,0,0);
00147   itsLaserwireTrackPhotons = 1;
00148   itsLaserwireTrackElectrons = 1;
00149 
00150 
00151   isWaitingForDump = false;
00152   isDumping = false;
00153   isReading = false;
00154   isReadFromStack = false;
00155 
00156   itsFifo = opt.fifo;
00157 
00158   itsIncludeIronMagFields = 0;
00159 
00160  //  else if(name=="INCLUDE_IRON_MAG_FIELDS")
00161 //     {
00162 //       _READ(itsIncludeIronMagFields);
00163 //     }
00164 
00165 
00166 //  else if(name  =="OUTPUT_NTUPLE_FILE_NAME")
00167 //     {_READ(itsOutputNtupleFileName);}
00168 
00169 //   else if(name=="NUMBER_OF_EVENTS_PER_NTUPLE")
00170 //     {_READ(itsNumberOfEventsPerNtuple);}
00171 
00172 
00173 //   else if(name=="USE_SYNCH_PRIMARY_GEN")
00174 //     {
00175 //       _READ(itsSynchPrimaryGen);
00176 //     }
00177 //   else if(name=="SYNCH_PRIMARY_GEN_ANGLE")
00178 //     {
00179 //       _READ(itsSynchPrimaryAngle);
00180 //       itsSynchPrimaryAngle*=radian;
00181 //     }
00182 //   else if(name=="SYNCH_PRIMARY_GEN_LENGTH")
00183 //     {
00184 //       _READ(itsSynchPrimaryLength);
00185 //       itsSynchPrimaryLength*=m;
00186 //     }
00187 
00188 //   else if(name=="USE_LAST_MATERIAL_POINT")
00189 //     {
00190 //       _READ(itsUseLastMaterialPoint);
00191 //     }
00192 
00193 //   else
00194 //     {
00195 //       G4cout<<" Unknown card in BDSInput.cards:"<<name<<G4endl;
00196 //       G4Exception("BDSGlobalConstants: UNRECOGNISED CARD");
00197 //     } 
00198  
00199 
00200   itsOutputNtupleFileName="sampler_output.rz";
00201   // end of defaults
00202 
00203   
00204   // default value (can be renamed later)
00205 
00206   G4UniformMagField* magField = new G4UniformMagField(G4ThreeVector());
00207   itsZeroFieldManager=new G4FieldManager();
00208   itsZeroFieldManager->SetDetectorField(magField);
00209   itsZeroFieldManager->CreateChordFinder(magField);
00210    
00211 }
00212 
00213 
00214 // a robust compiler-invariant method to convert from integer to G4String
00215 G4String BDSGlobalConstants::StringFromInt(G4int N) 
00216 {
00217   if (N==0) return "0";
00218  
00219   G4int nLocal=N, nDigit=0, nMax=1;
00220 
00221   do { nDigit++;
00222       nMax*=10;} while(N > nMax-1);
00223   
00224   nMax/=10;
00225   G4String Cnum;
00226   do {Cnum+=StringFromDigit(nLocal/nMax);
00227       nLocal-= nLocal/nMax * nMax;
00228       nMax/=10;}   while(nMax>1);
00229   if(nMax!=0)Cnum+=StringFromDigit(nLocal/nMax);
00230 
00231   return Cnum;
00232 }
00233 
00234 // a robust compiler-invariant method to convert from digit to G4String
00235 G4String BDSGlobalConstants::StringFromDigit(G4int N) 
00236 {
00237   if(N<0 || N>9)
00238     G4Exception("Invalid Digit in BDSGlobalConstants::StringFromDigit");
00239 
00240   G4String Cnum;
00241 
00242   if(N==0)Cnum="0";
00243   else if(N==1)Cnum="1";
00244   else if(N==2)Cnum="2";
00245   else if(N==3)Cnum="3";
00246   else if(N==4)Cnum="4";
00247   else if(N==5)Cnum="5";
00248   else if(N==6)Cnum="6";
00249   else if(N==7)Cnum="7";
00250   else if(N==8)Cnum="8";
00251   else if(N==9)Cnum="9"; 
00252 
00253   return Cnum;
00254 }
00255 
00256 BDSGlobalConstants::~BDSGlobalConstants()
00257 {  
00258     
00259 }

Generated on Wed Mar 5 17:25:22 2008 for BDSIM by  doxygen 1.5.3