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

00383 {
00384         G4double period=-1.0;
00385         argDouble(period,"period",namedArgs);
00386 
00387         std::vector<G4double> T;
00388         std::vector<G4double> B;
00389         std::vector<G4double> E;
00390 
00391         char *line;
00392         while((line=in.getline()) != 0) {
00393                 if(isalpha(line[0])) {
00394                         in.repeatLine();
00395                         break;
00396                 }
00397                 G4double t,b,e;
00398                 int j = sscanf(line,"%lf%lf%lf",&t,&b,&e);
00399                 if(j < 2 || j > 3) return 0;
00400                 if(j == 2) e = b;
00401                 T.push_back(t);
00402                 B.push_back(b);
00403                 E.push_back(e);
00404         }
00405 
00406         if(T.size() > 0) {
00407                 TimeImpl *impl =
00408                         new TimeImpl(T.size(),&T[0],&B[0],&E[0]);
00409                 impl->setPeriod(period);
00410                 return impl;
00411         }
00412 
00413         return 0;
00414 }


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