/home/cern/BDSIM_new/parser/gmad.h

00001 /*
00002  * GMAD interface 
00003  * I. Agapov 2005-2006
00004  * bdsim v.0.3
00005  *
00006  * modification history:
00007 */
00008 
00009 #ifndef _GMAD_H
00010 #define _GMAD_H
00011 
00012 #define _RESERVED 1
00013 
00014 #include <iostream>
00015 #include <cstdio>
00016 #include <list>
00017 #include <string>
00018 
00019 //using namespace std;
00020 
00021 // types of elements
00022 
00023 enum {
00024   _NONE = -1,
00025   _MARKER = 1,
00026   _DRIFT = 2,
00027   _RF = 3,
00028   _SBEND = 4, 
00029   _QUAD  = 5,
00030   _SEXTUPOLE  = 6,
00031   _OCTUPOLE = 7,
00032   _MULT  = 8,
00033   _SOLENOID = 9,
00034   _ELEMENT = 10,
00035   _LINE = 11,
00036   _REV_LINE= -11, //for line inversion in sublines
00037   _COLLIMATOR = 12,
00038   _ECOL = 13,
00039   _RCOL = 14,
00040   _LASER=15,
00041   _MATERIAL=16,
00042   _RBEND=17,
00043   _ATOM = 18,
00044 
00045   _VKICK=31,
00046   _HKICK=32,
00047   
00048   _SAMPLER = 41,
00049   _CSAMPLER = 42,
00050   _DUMP = 43,
00051   _GAS = 51,
00052   _TUNNEL = 52,
00053 
00054   _TRANSFORM3D = 61
00055 };
00056 
00057 const char *typestr(int type);
00058 
00059 
00060 // geometry and field formats
00061 enum {
00062   _GMAD = 0,
00063   _MOKKA = 1
00064 };
00065 
00066 enum {
00067   _GAUSSIAN = 0,
00068   _RING = 1,
00069   _SQUARE = 2,
00070   _CIRCLE = 3,
00071   _GUINEAPIG_BUNCH = 4,
00072   _GUINEAPIG_PAIRS = 5,
00073   _GUINEAPIG_SLAC = 6,
00074   _CAIN = 7,
00075   _ESHELL = 8,
00076   _UDEF = 32
00077 };
00078 
00079 // options passed with option and beam command
00080 
00081 struct Options {
00082 
00083   std::string physicsList;
00084 
00085   // beam parameters
00086   std::string particleName;
00087   std::string distribType;
00088   std::string distribFile;
00089 
00090   int numberOfParticles;
00091   int numberToGenerate;
00092   int nlinesIgnore; // ignore first lines in the input bunch file
00093 
00094   double beamEnergy;
00095   double X0, Y0, Z0;
00096   double Xp0, Yp0, Zp0;
00097   double T0, sigmaT;
00098 
00099   // for the gaussian beam distribution
00100   double sigmaX, sigmaXp, sigmaY, sigmaYp;
00101 
00102   // for the elliptic shell distribution
00103   double shellX, shellXp, shellY, shellYp;
00104 
00105   // for the ring beam distribution
00106   double Rmin, Rmax;
00107 
00108   // for the gaussian, elliptic shell, ring distributions
00109   double sigmaE;
00110 
00111   double betx, bety, alfx, alfy, emitx, emity; // initial twiss parameters
00112   int doTwiss;
00113 
00114   // for element specification
00115   double xsize, ysize;
00116 
00117   int numberOfEventsPerNtuple;
00118   unsigned long int eventNumberOffset;
00119   int backgroundScaleFactor;
00120 
00121   // default geometry parameters
00122   double componentBoxSize;
00123   double tunnelRadius;
00124   double beampipeRadius;
00125   double beampipeThickness;
00126   std::string pipeMaterial;
00127   std::string vacMaterial;
00128 
00129   double thresholdCutCharged;
00130   double thresholdCutPhotons;
00131   
00132   double prodCutPhotons;
00133   double prodCutPhotonsP;
00134   double prodCutElectrons;
00135   double prodCutElectronsP;
00136   double prodCutPositrons;
00137   double prodCutPositronsP;
00138 
00139   double trackWeightFactor;
00140   double deltaChord;
00141   double chordStepMinimum;
00142   double deltaIntersection;
00143   double minimumEpsilonStep;
00144   double maximumEpsilonStep;
00145   double deltaOneStep;
00146   bool turnOnInteractions;
00147   int useLowEMPhysics;
00148   int synchRadOn;
00149   int synchRescale;
00150   int synchTrackPhotons;
00151   double synchLowX;
00152   double synchLowGamE;
00153   int synchPhotonMultiplicity;
00154   int synchMeanFreeFactor;
00155   int planckOn;
00156   int eBremOn;
00157   double lengthSafety;
00158   long int randomSeed;
00159 
00160   int verboseStep;
00161   int verboseEventNumber;
00162 
00163   int useTimer;
00164   int useEMHadronic;
00165   int useMuonPairProduction;
00166   double muonProductionScaleFactor;
00167   double hadronInelasticScaleFactor;
00168   int storeMuonTrajectories;
00169   int storeNeutronTrajectories;
00170   int storeTrajectory;
00171   int stopTracks;
00172   int useMuonShowers;
00173   double muonLowestGeneratedEnergy;
00174 
00175   std::string fifo; // fifo for BDSIM-placet
00176 
00177 };
00178 
00179 // type of beamline list entries
00180 
00181 struct Element {
00182   short type;
00183   char * name;
00184 
00185   
00186   double l,ks,k0,k1,k2,k3,angle,aper,tilt,xsize,ysize,r,outR,hgap,B;
00187   double xdir, ydir, zdir, waveLength; // for laser wire and 3d transforms
00188 
00189   double gradient; // for rf cavities
00190 
00191   double phi, theta, psi; // for 3d transforms
00192 
00193   std::list<double> knl;
00194   std::list<double> ksl;
00195 
00196    // material properties
00197   double A; 
00198   double Z; 
00199   double density; 
00200   double temper;
00201   double pressure;
00202   std::string state;
00203   std::string symbol;
00204   std::list<char*> components;
00205   std::list<double> componentsFractions;
00206   std::list<int> componentsWeights;
00207 
00208   std::string geometryFile;
00209   std::string bmapFile;
00210   std::string material;
00211 
00212   std::string spec;  // arbitrary specification to pass to beamline builder
00213   
00214   // in case the element is a list itself (line)
00215   std::list <Element> *lst;
00216 
00217   
00218 };
00219 
00220 
00221 // parameters - used in the parser
00222 
00223 struct Parameters {
00224 
00225   // length, multipole coefficients
00226 
00227   double B;  int Bset;    // magnetic field
00228   double l;  int lset;    // length
00229   double k0; int k0set;   // dipole 
00230   double k1; int k1set;   // quadrupole
00231   double k2; int k2set;   // sextupole
00232   double k3; int k3set;   // octupole
00233   double ks; int ksset;   // solenoid
00234 
00235   std::list<double> knl;           // multipole expansion coefficients
00236   std::list<double> ksl;           // skew multipole expansion
00237   
00238   int knlset; int kslset;
00239 
00240   
00241   // placement, geometrical sizes etc.
00242 
00243   double r; int rset; //radius, i.e cylindrical sampler
00244   
00245   double angle; int angleset;   // bending angle
00246   double aper; int aperset;   // aperture (circular)
00247   double phi, theta, psi; // for 3d transforms
00248   int phiset, thetaset, psiset;
00249 
00250   double gradient; int gradientset;
00251 
00252   double outR; int outRset; // outer radius of magnets
00253   double hgap, hgapset;
00254   double xsize, ysize; int xsizeset, ysizeset; // aperture (or laser spotsize for laser)
00255   double xdir, ydir, zdir, waveLength; int xdirset, ydirset, zdirset, waveLengthset;
00256 
00257   double tilt; int tiltset;   // tilt
00258 
00259   // twiss parameters
00260   
00261 
00262   // for external geometry and field definition files
00263   char geometry[64]; int geomset;
00264   char bmap[64]; int bmapset;
00265   char emap[64];
00266   char material[64]; int materialset;
00267 
00268 
00269   // string to pass a custom type specification
00270   char spec[1024]; int specset;
00271 
00272   // material properties
00273   double A; int Aset;
00274   double Z; int Zset;
00275   double density; int densityset;
00276   double temper; int temperset;
00277   double pressure; int pressureset;
00278   char state[64]; int stateset;
00279   char symbol[64]; int symbolset;
00280   std::list<char*> components; int componentsset;
00281   std::list<double> componentsFractions; int componentsFractionsset;
00282   std::list<int> componentsWeights; int componentsWeightsset;
00283 
00284   // reset the parameters to defaults
00285   void flush() {
00286 
00287     l=0; lset = 0;
00288     r = 0; rset = 0;
00289 
00290     // materials' parameters
00291     A = 0; Aset = 0; //g*mol^-1
00292     Z = 0; Zset = 0; 
00293     density = 0; densityset = 0; //g*cm-3
00294     temper = 300; temperset = 0; //kelvin
00295     pressure = 1; pressureset = 0; //atm
00296     strcpy(state,"solid"); stateset = 0; // "solid", "liquid", or "gas"
00297     strcpy(symbol,""); symbolset = 0;
00298     componentsset = 0; componentsFractionsset = 0; componentsWeightsset = 0;
00299     components.erase(components.begin(),components.end());
00300     componentsFractions.erase(componentsFractions.begin(),componentsFractions.end());
00301     componentsWeights.erase(componentsWeights.begin(),componentsWeights.end());
00302 
00303 
00304     angle = 0; angleset = 0;
00305     xsize = 0; xsizeset = 0;
00306     ysize = 0; ysizeset = 0;
00307     hgap = 0; hgapset = 0;    
00308     xdir = 0; xdirset = 0;
00309     ydir = 0; ydirset = 0;
00310     zdir = 0; zdirset = 0; 
00311     waveLength = 0; waveLengthset = 0; 
00312 
00313     phi = 0; phiset = 0;
00314     theta = 0; thetaset = 0;
00315     psi = 0; psiset = 0;
00316 
00317     aper = 0; aperset = 0;
00318     outR = 0; outRset = 0;
00319     tilt = 0; tiltset = 0;
00320 
00321     B  = 0; Bset  = 0;
00322     k0 = 0; k0set = 0;
00323     k1 = 0; k1set = 0;
00324     k2 = 0; k2set = 0;
00325     k3 = 0; k3set = 0;
00326     ks = 0; ksset = 0;
00327 
00328     gradient = 0; gradientset = 0;
00329     
00330     knlset = 0; kslset=0;
00331 
00332     knl.erase(knl.begin(),knl.end());
00333     ksl.erase(ksl.begin(),ksl.end());
00334 
00335     strcpy(geometry,"");  geomset = 0;
00336 
00337     strcpy(bmap,""); bmapset = 0;
00338 
00339     strcpy(material,""); materialset = 0;
00340     strcpy(spec,""); specset = 0;
00341   }
00342   
00343 };
00344 
00345 
00346 extern std::list<Element> beamline_list;
00347 extern std::list<Element> material_list;
00348 extern std::list<Element> atom_list;
00349 
00350 extern Options options;
00351 
00352 // parse the input file and construct beamline_list and options 
00353 int gmad_parser(FILE *f);
00354 
00355 int gmad_parser(std::string name);
00356 
00357 
00358 #endif

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