#include <vector>
#include <stdio.h>
#include "G4VisAttributes.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4Color.hh"
#include "G4UserLimits.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4SteppingManager.hh"
#include "G4Material.hh"
#include "G4Transportation.hh"
#include "gsl/gsl_sf_bessel.h"
#include "BLElement.hh"
#include "BLElementField.hh"
#include "BLGlobalField.hh"
#include "BLManager.hh"
#include "BLParam.hh"
#include "BLFieldMap.hh"
#include "BLTune.hh"
#include "BLKillTrack.hh"
#include "gsl/gsl_sys.h"
#define TINY_NONZERO_GRADIENT (pi*pi*1.E-10*megavolt/meter) |
Referenced by RFdeviceField::addFieldValue().
#define ATFIX_OFFSET 1 |
#define ATFIX_OFFSETINCR 2 |
#define ATFIX_GRADIENT 4 |
#define ATFIX_PHASE 8 |
#define ATFIX_OUTPUT 16 |
Referenced by BLCMDrfdevice::argChanged(), and RFdeviceField::show1step().
#define ATFIX_DE 32 |
#define ATFIX_P 64 |
#define ATFIX_DT 128 |
#define ATFIX_XDEFL 256 |
#define ATFIX_YDEFL 512 |
#define ATFIX_ZLOCAL 1024 |
Referenced by BLCMDrfdevice::argChanged(), and BLCMDrfdevice::BLCMDrfdevice().
#define ATFIX_ANYOUT (ATFIX_DE|ATFIX_P|ATFIX_DT|ATFIX_XDEFL|ATFIX_YDEFL) |
Referenced by BLCMDrfdevice::argChanged().
#define ESSENTIALLY_UNCHANGED 1.E-6 |
Referenced by RFdeviceField::UserSteppingAction().
enum AutoTimingMethod |
00091 { AUTOTIMING_OFF, AUTOTIMING_ATZ, 00092 AUTOTIMING_MINENERGY, AUTOTIMING_NOENERGY, AUTOTIMING_MAXENERGY, 00093 AUTOTIMING_MINTIME, AUTOTIMING_NOMTIME, AUTOTIMING_MAXTIME, 00094 AUTOTIMING_MAXDXP, AUTOTIMING_NODXP, AUTOTIMING_MINDXP, 00095 AUTOTIMING_MAXDYP, AUTOTIMING_NODYP, AUTOTIMING_MINDYP, 00096 AUTOTIMING_UNKNOWN };
AUTOADJUST_UNKNOWN | |
AUTOADJUST_PHASE | |
AUTOADJUST_GRADIENT | |
AUTOADJUST_OUTPUT | |
AUTOADJUST_UNNEEDED |
00098 { AUTOADJUST_UNKNOWN, AUTOADJUST_PHASE, 00099 AUTOADJUST_GRADIENT, AUTOADJUST_OUTPUT, AUTOADJUST_UNNEEDED };
enum AutoTimingState |
ATWORKING_UNKNOWN | |
ATWORKING_RESET | |
ATWORKING_OFFSET | |
ATWORKING_BYPASS | |
ATWORKING_BASE | |
ATWORKING_ESTIMATE | |
ATWORKING_FINETUNE | |
ATWORKING_FINAL | |
ATWORKING_DONE | |
ATWORKING_INFLUX |
00102 { ATWORKING_UNKNOWN, ATWORKING_RESET, ATWORKING_OFFSET, ATWORKING_BYPASS, 00103 ATWORKING_BASE, ATWORKING_ESTIMATE, ATWORKING_FINETUNE, 00104 ATWORKING_FINAL, ATWORKING_DONE, ATWORKING_INFLUX };
void g4bl_exit | ( | int | ) |
const char* autotimingstate2text | ( | AutoTimingState | state | ) |
References ATWORKING_BASE, ATWORKING_BYPASS, ATWORKING_DONE, ATWORKING_ESTIMATE, ATWORKING_FINAL, ATWORKING_FINETUNE, ATWORKING_INFLUX, ATWORKING_OFFSET, ATWORKING_RESET, and ATWORKING_UNKNOWN.
Referenced by RFdeviceField::show1step().
00108 { 00109 //returns pointer to text form of state 00110 switch(state) 00111 { 00112 case ATWORKING_UNKNOWN: 00113 return("ATWORKING_UNKNOWN"); 00114 case ATWORKING_RESET: 00115 return("ATWORKING_RESET"); 00116 case ATWORKING_OFFSET: 00117 return("ATWORKING_OFFSET"); 00118 case ATWORKING_BYPASS: 00119 return("ATWORKING_BYPASS"); 00120 case ATWORKING_BASE: 00121 return("ATWORKING_BASE"); 00122 case ATWORKING_ESTIMATE: 00123 return("ATWORKING_ESTIMATE"); 00124 case ATWORKING_FINETUNE: 00125 return("ATWORKING_FINETUNE"); 00126 case ATWORKING_FINAL: 00127 return("ATWORKING_FINAL"); 00128 case ATWORKING_DONE: 00129 return("ATWORKING_DONE"); 00130 case ATWORKING_INFLUX: 00131 return("ATWORKING_INFLUX"); 00132 } 00133 00134 return("?"); 00135 }
const char* state2desc | ( | AutoTimingState | state | ) |
References ATWORKING_BASE, ATWORKING_BYPASS, ATWORKING_DONE, ATWORKING_ESTIMATE, ATWORKING_FINAL, ATWORKING_FINETUNE, ATWORKING_INFLUX, ATWORKING_OFFSET, ATWORKING_RESET, and ATWORKING_UNKNOWN.
Referenced by BLCMDrfdevice::isOK(), and RFdeviceField::UserSteppingAction().
00138 { 00139 return state==ATWORKING_UNKNOWN ? "unknown" : 00140 state==ATWORKING_RESET ? "reset" : 00141 state==ATWORKING_OFFSET ? "offset" : 00142 state==ATWORKING_BYPASS ? "bypass" : 00143 state==ATWORKING_BASE ? "base" : 00144 state==ATWORKING_ESTIMATE ? "estimate" : 00145 state==ATWORKING_FINETUNE ? "finetune" : 00146 state==ATWORKING_FINAL ? "final" : 00147 state==ATWORKING_DONE ? "done" : 00148 state==ATWORKING_INFLUX ? "influx" : "?????"; 00149 }
AutoTimingChange autoTimingIn2Out | ( | AutoTimingSnapshot | in, | |
AutoTimingSnapshot | out | |||
) |
References AutoTimingChange::dE, AutoTimingChange::dT, AutoTimingSnapshot::KE, AutoTimingChange::Pout, AutoTimingSnapshot::Ptot, AutoTimingSnapshot::Px, AutoTimingSnapshot::Py, AutoTimingSnapshot::Pz, AutoTimingSnapshot::t, AutoTimingChange::Xdefl, and AutoTimingChange::Ydefl.
Referenced by RFdeviceField::UserSteppingAction().
00184 { 00185 AutoTimingChange dif; 00186 00187 dif.dE= out.KE - in.KE; 00188 dif.Pout= out.Ptot; 00189 dif.dT= out.t - in.t; 00190 00191 dif.Xdefl= asin((in.Pz*out.Px-in.Px*out.Pz)/in.Ptot/out.Ptot); 00192 dif.Ydefl= -asin((in.Pz*out.Py-in.Py*out.Pz)/in.Ptot/out.Ptot); 00193 00194 return(dif); 00195 }
G4int howmanyfixed | ( | G4int | whatisfixed | ) |
References ATFIX_DE, ATFIX_DT, ATFIX_P, ATFIX_XDEFL, and ATFIX_YDEFL.
Referenced by BLCMDrfdevice::argChanged(), and whatFixedOk().
00199 { 00200 // return # of fixed quantities in bit-packed list (excluding ZLOCAL) 00201 00202 int N=0; 00203 if(whatisfixed & ATFIX_P) ++N; 00204 if(whatisfixed & ATFIX_DE) ++N; 00205 if(whatisfixed & ATFIX_DT) ++N; 00206 if(whatisfixed & ATFIX_XDEFL) ++N; 00207 if(whatisfixed & ATFIX_YDEFL) ++N; 00208 return(N); 00209 }
G4bool whatFixedOk | ( | char * | rfname, | |
G4int | whatisfixed | |||
) |
References ATFIX_DE, ATFIX_DT, ATFIX_GRADIENT, ATFIX_OFFSET, ATFIX_OFFSETINCR, ATFIX_P, ATFIX_PHASE, ATFIX_XDEFL, ATFIX_YDEFL, and howmanyfixed().
Referenced by RFdeviceField::UserSteppingAction().
00213 { 00214 // given the bit-packed list of fixed quantities, 00215 // return whether it is sufficient and unambiguous - 00216 // actually causes abort upon failure 00217 G4bool ok,okOff,ok1out,okPh,okV,noOut,okIncr; 00218 00219 const char *where= rfname!=NULL ? rfname : "whatFixedOk"; 00220 00221 //look at fixed quantities 00222 int Nfixed= howmanyfixed(whatisfixed); 00223 00224 ok1out= Nfixed==1; 00225 noOut= Nfixed==0; 00226 okPh= whatisfixed & ATFIX_PHASE; 00227 okV= whatisfixed & ATFIX_GRADIENT; 00228 00229 okIncr= whatisfixed & ATFIX_OFFSETINCR; 00230 okOff= whatisfixed & ATFIX_OFFSET; 00231 00232 ok= !(okOff && okIncr); 00233 if(!ok) 00234 { 00235 G4Exception(where,"Cannot set both timeOffset and timeIncrement",FatalException,""); //abort 00236 return(ok); 00237 } 00238 00239 //know time & voltage or require exactly 2 of 3 00240 ok= okOff && okV || okV && okPh && noOut || ok1out && okV && !okPh || ok1out && !okV && okPh; 00241 00242 if(ok) return(ok); 00243 00244 if(!ok1out && !noOut) 00245 { 00246 printf("rfdevice(%s):whatFixedOk: ",where); 00247 if(whatisfixed & ATFIX_P) printf("fixP=Y "); 00248 if(whatisfixed & ATFIX_DE) printf("fixDE=Y "); 00249 if(whatisfixed & ATFIX_DT) printf("fixD& "); 00250 if(whatisfixed & ATFIX_XDEFL) printf("fixXdeflection=Y "); 00251 if(whatisfixed & ATFIX_YDEFL) printf("fixYdeflection=Y "); 00252 printf("- only 1 allowed!\n"); 00253 G4Exception(where,"Maximum of 1 fixed output setting allowed",FatalException,""); //abort 00254 return(ok); 00255 } 00256 else if(noOut) 00257 { 00258 printf("rfdevice(%s):whatFixedOk: ",where); 00259 printf("maxGradient=%s ", whatisfixed & ATFIX_GRADIENT? "Y": "N"); 00260 printf("phaseAcc=%s ", whatisfixed & ATFIX_DE? "Y": "N"); 00261 printf("- require both iff no output settings requested.\n"); 00262 G4Exception(where,"Insufficient info to specify timing",FatalException,""); //abort 00263 return(ok); 00264 } 00265 else 00266 { 00267 if(okPh && okV) 00268 G4Exception(where,"Cannot set both phase and gradient with fixed output setting",FatalException,""); 00269 else 00270 G4Exception(where,"Require phase xor gradient with fixed output setting",FatalException,""); 00271 } 00272 00273 return(ok); 00274 }
AutoTimingSnapshot step2snapshot | ( | const G4Step * | step, | |
G4double | toff, | |||
G4double | L, | |||
G4RotationMatrix * | rot, | |||
G4bool | within | |||
) |
References AutoTimingSnapshot::estTransit, AutoTimingSnapshot::KE, AutoTimingSnapshot::m, AutoTimingSnapshot::Ptot, AutoTimingSnapshot::Px, AutoTimingSnapshot::Py, AutoTimingSnapshot::Pz, AutoTimingSnapshot::q, AutoTimingSnapshot::t, AutoTimingSnapshot::timeOff, AutoTimingSnapshot::v, AutoTimingSnapshot::within, AutoTimingSnapshot::x, AutoTimingSnapshot::y, and AutoTimingSnapshot::z.
Referenced by RFdeviceField::UserSteppingAction().
00278 { 00279 AutoTimingSnapshot snapshot; 00280 00281 G4Track *trk = step->GetTrack(); 00282 00283 G4StepPoint *pnt = step->GetPostStepPoint(); 00284 00285 const G4ThreeVector& globalxyz= pnt->GetPosition(); 00286 00287 const G4ThreeVector& globalPxyz= pnt->GetMomentum(); 00288 00289 G4ThreeVector localPxyz= globalPxyz; 00290 00291 if(rot) 00292 localPxyz= *rot * localPxyz; 00293 00294 snapshot.x= globalxyz.getX(); 00295 snapshot.y= globalxyz.getY(); 00296 snapshot.z= globalxyz.getZ(); 00297 00298 snapshot.Px= localPxyz.getX(); 00299 snapshot.Py= localPxyz.getY(); 00300 snapshot.Pz= localPxyz.getZ(); 00301 snapshot.Ptot= sqrt(snapshot.Px*snapshot.Px+snapshot.Py*snapshot.Py+snapshot.Pz*snapshot.Pz); 00302 00303 snapshot.m= trk->GetDefinition()->GetPDGMass(); 00304 snapshot.t= pnt->GetGlobalTime(); 00305 snapshot.KE= trk->GetKineticEnergy(); 00306 snapshot.v= trk->GetVelocity(); 00307 snapshot.q= trk->GetDefinition()->GetPDGCharge(); 00308 00309 snapshot.timeOff= toff; 00310 snapshot.estTransit= L/trk->GetVelocity(); /*estimated transit time over timing volume*/ 00311 snapshot.within= within; 00312 00313 return(snapshot); 00314 }
AutoTimingMethod autotiming2method | ( | G4String | autotimingpreference | ) |
References AUTOTIMING_ATZ, AUTOTIMING_MAXDXP, AUTOTIMING_MAXDYP, AUTOTIMING_MAXENERGY, AUTOTIMING_MAXTIME, AUTOTIMING_MINDXP, AUTOTIMING_MINDYP, AUTOTIMING_MINENERGY, AUTOTIMING_MINTIME, AUTOTIMING_NODXP, AUTOTIMING_NODYP, AUTOTIMING_NOENERGY, AUTOTIMING_NOMTIME, and AUTOTIMING_UNKNOWN.
Referenced by BLCMDrfdevice::construct(), RFdeviceField::show1step(), and RFdeviceField::UserSteppingAction().
00318 { 00319 //KBB convert string into enumerated type to control the automatic RF tuning 00320 00321 if(!strcasecmp(autotimingpreference,"atZlocal") || !strcasecmp(autotimingpreference,"atZ")) 00322 return(AUTOTIMING_ATZ); //drift to center (usually) 00323 else if(!strcasecmp(autotimingpreference,"maxEnergyGain") || !strcasecmp(autotimingpreference,"maxE")) 00324 return(AUTOTIMING_MAXENERGY); //maximum dE 00325 else if(!strcasecmp(autotimingpreference,"noEnergyGain") || !strcasecmp(autotimingpreference,"noE")) 00326 return(AUTOTIMING_NOENERGY); //dE=0 00327 else if(!strcasecmp(autotimingpreference,"minEnergyGain") || !strcasecmp(autotimingpreference,"minE")) 00328 return(AUTOTIMING_MINENERGY); //minimum dE 00329 else if(!strcasecmp(autotimingpreference,"minTransitTime") || !strcasecmp(autotimingpreference,"minT")) 00330 return(AUTOTIMING_MINTIME); //minimum dT 00331 else if(!strcasecmp(autotimingpreference,"nomTransitTime") || !strcasecmp(autotimingpreference,"noT")) 00332 return(AUTOTIMING_NOMTIME); //drift dT 00333 else if(!strcasecmp(autotimingpreference,"maxTransitTime") || !strcasecmp(autotimingpreference,"maxT")) 00334 return(AUTOTIMING_MAXTIME); //maximum dT 00335 else if(!strcasecmp(autotimingpreference,"maxXdeflection") || !strcasecmp(autotimingpreference,"maxX")) 00336 return(AUTOTIMING_MAXDXP); //max local delta-x' change 00337 else if(!strcasecmp(autotimingpreference,"minXdeflection") || !strcasecmp(autotimingpreference,"minX")) 00338 return(AUTOTIMING_MINDXP); //min local delta-x' 00339 else if(!strcasecmp(autotimingpreference,"noXdeflection") || !strcasecmp(autotimingpreference,"noX")) 00340 return(AUTOTIMING_NODXP); //no local delta-x' 00341 else if(!strcasecmp(autotimingpreference,"maxYdeflection") || !strcasecmp(autotimingpreference,"maxY")) 00342 return(AUTOTIMING_MAXDYP); //max local delta-y' change 00343 else if(!strcasecmp(autotimingpreference,"minYdeflection") || !strcasecmp(autotimingpreference,"minY")) 00344 return(AUTOTIMING_MINDYP); //min local delta-y' change 00345 else if(!strcasecmp(autotimingpreference,"noYdeflection") || !strcasecmp(autotimingpreference,"noY")) 00346 return(AUTOTIMING_NODYP); //no local delta-y' change 00347 00348 G4Exception("autotiming2method:","Unsupported method",FatalException,""); //abort 00349 00350 return(AUTOTIMING_UNKNOWN); 00351 }
const char* automethod2text | ( | AutoTimingMethod | method | ) |
References AUTOTIMING_ATZ, AUTOTIMING_MAXDXP, AUTOTIMING_MAXDYP, AUTOTIMING_MAXENERGY, AUTOTIMING_MAXTIME, AUTOTIMING_MINDXP, AUTOTIMING_MINDYP, AUTOTIMING_MINENERGY, AUTOTIMING_MINTIME, AUTOTIMING_NODXP, AUTOTIMING_NODYP, AUTOTIMING_NOENERGY, AUTOTIMING_NOMTIME, AUTOTIMING_OFF, and AUTOTIMING_UNKNOWN.
Referenced by BLCMDrfdevice::construct(), RFdeviceField::show1step(), and RFdeviceField::UserSteppingAction().
00355 { 00356 //KBB convert enumerated type to a string 00357 00358 switch(method) 00359 { 00360 case AUTOTIMING_OFF: 00361 return("off"); 00362 case AUTOTIMING_ATZ: 00363 return("atZlocal"); 00364 case AUTOTIMING_MINENERGY: 00365 return("minEnergyGain"); 00366 case AUTOTIMING_NOENERGY: 00367 return("noEnergyGain"); 00368 case AUTOTIMING_MAXENERGY: 00369 return("maxEnergyGain"); 00370 case AUTOTIMING_MINTIME: 00371 return("minTransitTime"); 00372 case AUTOTIMING_NOMTIME: 00373 return("nomTransitTime"); 00374 case AUTOTIMING_MAXTIME: 00375 return("maxTransitTime"); 00376 case AUTOTIMING_MAXDXP: 00377 return("maxXdeflection"); 00378 case AUTOTIMING_NODXP: 00379 return("noXdeflection"); 00380 case AUTOTIMING_MINDXP: 00381 return("minXdeflection"); 00382 case AUTOTIMING_MAXDYP: 00383 return("maxYdeflection"); 00384 case AUTOTIMING_NODYP: 00385 return("noYdeflection"); 00386 case AUTOTIMING_MINDYP: 00387 return("minYdeflection"); 00388 case AUTOTIMING_UNKNOWN: 00389 return("unknown"); 00390 } 00391 00392 return("unknown?"); 00393 }
G4double automethod2timingphase | ( | AutoTimingMethod | method, | |
G4double | q | |||
) |
References AUTOTIMING_ATZ, AUTOTIMING_MAXDXP, AUTOTIMING_MAXDYP, AUTOTIMING_MAXENERGY, AUTOTIMING_MAXTIME, AUTOTIMING_MINDXP, AUTOTIMING_MINDYP, AUTOTIMING_MINENERGY, AUTOTIMING_MINTIME, AUTOTIMING_NODXP, AUTOTIMING_NODYP, AUTOTIMING_NOENERGY, AUTOTIMING_NOMTIME, AUTOTIMING_OFF, and AUTOTIMING_UNKNOWN.
Referenced by RFdeviceField::UserSteppingAction().
00397 { 00398 // returns the g4bl-style phase angle corresponding 00399 // to the tuning method and particle charge 00400 G4bool pos= q>=0; 00401 00402 00403 switch(method) 00404 { 00405 case AUTOTIMING_OFF: 00406 return(0*deg); 00407 case AUTOTIMING_ATZ: 00408 return(90*deg); 00409 case AUTOTIMING_MAXENERGY: 00410 case AUTOTIMING_MINTIME: 00411 case AUTOTIMING_MAXDXP: 00412 case AUTOTIMING_MAXDYP: 00413 return(pos? 90*deg : -90*deg); 00414 case AUTOTIMING_MINENERGY: 00415 case AUTOTIMING_MAXTIME: 00416 case AUTOTIMING_MINDXP: 00417 case AUTOTIMING_MINDYP: 00418 return(pos? -90*deg : 90*deg); 00419 case AUTOTIMING_NOENERGY: 00420 case AUTOTIMING_NOMTIME: 00421 case AUTOTIMING_NODXP: 00422 case AUTOTIMING_NODYP: 00423 case AUTOTIMING_UNKNOWN: 00424 return(pos? 0*deg : 180*deg); 00425 default: 00426 return(0*deg); 00427 } 00428 00429 return(0*deg); 00430 }
long long global_2TraceCounter = 1 [static] |
Referenced by RFdeviceField::show1step().
G4bool TrackOfInterest = true [static] |
Referenced by BLCMDrfdevice::trackOfInterest(), and RFdeviceField::UserSteppingAction().
G4double lastFound_maxGradient = 0 [static] |
Referenced by RFdeviceField::UserSteppingAction().
const G4int ITERATION_LIMIT = 1000 |