TimeImpl Class Reference

List of all members.


Detailed Description

class TimeImpl -- class implementation of a time dependence.

Public Member Functions

 TimeImpl (int n, G4double t[], G4double b[], G4double e[]=0)
 Constructor. n is # points in the arrays, t[] is the list of time values (ns), b[] and e[] are the factors for B field and E field. t[], b[], and e[] are copied so the caller can delete them after calling this routine.
void setPeriod (G4double v)
G4double factorB (G4double t)
G4double factorE (G4double t)

Static Public Member Functions

static TimeImplreadTime (InputFile &in, BLArgumentVector argv, BLArgumentMap namedArgs)

Private Attributes

BTSpline1D B
BTSpline1D E
G4double tMin
G4double tMax
G4double period

Constructor & Destructor Documentation

TimeImpl::TimeImpl ( int  n,
G4double  t[],
G4double  b[],
G4double  e[] = 0 
) [inline]

Constructor. n is # points in the arrays, t[] is the list of time values (ns), b[] and e[] are the factors for B field and E field. t[], b[], and e[] are copied so the caller can delete them after calling this routine.

References period, tMax, and tMin.

Referenced by readTime().

00186                                                                     :
00187                                                 B(n,t,b), E(n,t,(e?e:b)) {
00188                 tMin = t[0];
00189                 tMax = t[n-1];
00190                 period = -1.0;
00191         }
        void setPeriod(G4double v) { period = v; }


Member Function Documentation

void TimeImpl::setPeriod ( G4double  v  )  [inline]

References period.

Referenced by BLFieldMap::createTimeDependence(), and readTime().

00192 { period = v; }

G4double TimeImpl::factorB ( G4double  t  )  [inline]

References B, period, tMax, and tMin.

Referenced by BLFieldMap::getFieldValue(), and BLFieldMap::getTimeFactor().

00193                                      { 
00194                 if(period > 0.0) {
00195                         t -= floor(t/period)*period;
00196                 } else {
00197                         if(t < tMin) t = tMin;
00198                         if(t > tMax) t = tMax;
00199                 }
00200                 return B(t);
00201         }

G4double TimeImpl::factorE ( G4double  t  )  [inline]

References E, period, tMax, and tMin.

Referenced by BLFieldMap::getFieldValue(), and BLFieldMap::getTimeFactor().

00202                                      { 
00203                 if(period > 0.0) {
00204                         t -= floor(t/period)*period;
00205                 } else {
00206                         if(t < tMin) t = tMin;
00207                         if(t > tMax) t = tMax;
00208                 }
00209                 return E(t);
00210         }

TimeImpl * TimeImpl::readTime ( InputFile in,
BLArgumentVector  argv,
BLArgumentMap  namedArgs 
) [static]

References argDouble(), B, E, InputFile::getline(), period, InputFile::repeatLine(), setPeriod(), and TimeImpl().

Referenced by BLFieldMap::readFile().

00373 {
00374         G4double period=-1.0;
00375         argDouble(period,"period",namedArgs);
00376 
00377         std::vector<G4double> T;
00378         std::vector<G4double> B;
00379         std::vector<G4double> E;
00380 
00381         char *line;
00382         while((line=in.getline()) != 0) {
00383                 if(isalpha(line[0])) {
00384                         in.repeatLine();
00385                         break;
00386                 }
00387                 G4double t,b,e;
00388                 int j = sscanf(line,"%lf%lf%lf",&t,&b,&e);
00389                 if(j < 2 || j > 3) return 0;
00390                 if(j == 2) e = b;
00391                 T.push_back(t);
00392                 B.push_back(b);
00393                 E.push_back(e);
00394         }
00395 
00396         if(T.size() > 0) {
00397                 TimeImpl *impl =
00398                         new TimeImpl(T.size(),&T[0],&B[0],&E[0]);
00399                 impl->setPeriod(period);
00400                 return impl;
00401         }
00402 
00403         return 0;
00404 }


Member Data Documentation

Referenced by factorB(), and readTime().

Referenced by factorE(), and readTime().

G4double TimeImpl::tMin [private]

Referenced by factorB(), factorE(), and TimeImpl().

G4double TimeImpl::tMax [private]

Referenced by factorB(), factorE(), and TimeImpl().

G4double TimeImpl::period [private]


The documentation for this class was generated from the following file:
g4beamline