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().

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


Member Function Documentation

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

References period.

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

00191 { period = v; }

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

References B, period, tMax, and tMin.

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

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

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

References E, period, tMax, and tMin.

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

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

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().

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


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