CalLinearity Class Reference

#include <CalLinearity.h>

Inheritance diagram for CalLinearity:
DbiTableRow

List of all members.

Classes

struct  spline

Public Member Functions

 CalLinearity ()
virtual ~CalLinearity ()
 CalLinearity (int aggno, PlexStripEndId &seid, int task)
 CalLinearity (int aggno, PlexStripEndId &seid, vector< float > &x, vector< float > &y, vector< float > &ex, vector< float > &ey, CalLinearity &lin, bool horizontal)
 CalLinearity (int aggno, PlexStripEndId &seid, vector< float > &x, vector< float > &y)
Int_t GetAggregateNo () const
UInt_t GetIndex (UInt_t) const
Int_t GetStripEnd () const
Int_t GetTask () const
Int_t GetNumXPoints ()
Float_t GetLimit () const
virtual DbiTableRowCreateTableRow () const
virtual void Fill (DbiResultSet &rs, const DbiValidityRec *vrec)
virtual void Store (DbiOutRowStream &ors, const DbiValidityRec *vrec) const
Float_t ADCtoLin (const Float_t charge) const
Float_t LintoADC (const Float_t charge) const

Private Member Functions

 CalLinearity (const CalLinearity &from)

Private Attributes

Int_t fAggregateNo
Int_t fStripEndKey
Int_t fStripEndId
Int_t fTask
Int_t fNumber
Float_t fParam [40]
spline fSplines [8]
int fNsplines
int fNumXPoints

Detailed Description

Definition at line 20 of file CalLinearity.h.


Constructor & Destructor Documentation

CalLinearity::CalLinearity (  )  [inline]

Definition at line 26 of file CalLinearity.h.

References LEA_CTOR.

00026                  {
00027       LEA_CTOR; }

virtual CalLinearity::~CalLinearity (  )  [inline, virtual]

Definition at line 28 of file CalLinearity.h.

References LEA_DTOR.

00028 { LEA_DTOR; };

CalLinearity::CalLinearity ( int  aggno,
PlexStripEndId seid,
int  task 
)

Definition at line 38 of file CalLinearity.cxx.

References CalLinearity::spline::alpha, CalLinearity::spline::endx, CalLinearity::spline::endy, fNsplines, fSplines, fTask, Msg::kWarning, MSG, CalLinearity::spline::slope, CalLinearity::spline::startx, and CalLinearity::spline::starty.

00038                                                                    : fAggregateNo(aggno), fStripEndKey(seid.BuildPlnStripEndKey()), fStripEndId(seid.GetEncoded())
00039 {
00040   fTask = task;
00041   switch (task) {
00042   case 2:
00043     fSplines[0].startx = 0;
00044     fSplines[0].starty = 0;
00045     fSplines[0].slope = 1;
00046     fSplines[0].alpha = 0;
00047     fSplines[0].endx = 7000;
00048     fSplines[0].endy = 7000;
00049     fNsplines = 1;
00050     break;
00051   default:
00052     MSG("Calib",Msg::kWarning)<<"CalLinearity doesn't know how to construct a default map for task "<<task<<endl;
00053   };
00054 
00055 }

CalLinearity::CalLinearity ( int  aggno,
PlexStripEndId seid,
vector< float > &  x,
vector< float > &  y,
vector< float > &  ex,
vector< float > &  ey,
CalLinearity lin,
bool  horizontal 
)

Definition at line 211 of file CalLinearity.cxx.

References ADCtoLin(), CalLinearity::spline::alpha, CalLinearity::spline::endx, CalLinearity::spline::endy, fNsplines, fNumXPoints, fSplines, fTask, GetLimit(), CalLinearity::spline::slope, CalLinearity::spline::startx, CalLinearity::spline::starty, and zero().

00211                                                                                                                                                                                       :fAggregateNo(aggno), fStripEndKey(seid.BuildPlnStripEndKey()), fStripEndId(seid.GetEncoded())
00212 {
00213   bool zero = false;
00214   fTask = 2;
00215  top:
00216   if (zero||x.size()==0||y.size()==0) {
00217     fSplines[0].startx = 0;
00218     fSplines[0].starty = 0;
00219     fSplines[0].slope = 1;
00220     fSplines[0].alpha = 0;
00221     fSplines[0].endx = 7000;
00222     fSplines[0].endy = 7000;
00223     fNsplines = 1;
00224     fNumXPoints = 0;
00225   } 
00226   else {
00227 
00228   // This is basically the old IterFit()
00229   // Fit y against x', where x' is the x linearised by the func parameterised
00230   // in lin. Gives a mapping from y to "a linear scale"
00231 
00232   // First convert x to the linear scale.
00233  vector<float> xlin;
00234  //cout<<"x size: "<<x.size()<<" y size: "<<y.size()<<" limit: "<<lin.GetLimit()<<endl;
00235   int middle=0;
00236   for (unsigned int i=0;i<x.size();i++) {
00237     if (x[i]<lin.GetLimit()) {
00238       xlin.push_back(lin.ADCtoLin(x[i]));
00239       //   cout<<"x: "<<x[i]<<"  xlin: "<<i<<" "<<xlin[i]<<endl;
00240     } else {
00241       break;
00242     }
00243     if (middle==0) {
00244       if (y[i]>7000) middle = i-1;
00245     }
00246   }
00247   if (xlin.size()==0) {
00248     zero = true;
00249     goto top;
00250   }
00251   if (middle==0) middle = xlin.size()-1;
00252   fNumXPoints = xlin.size();
00253   TGraph graph(xlin.size(),&(xlin[0]),&(y[0]));
00254   // graph.Print();
00255   TF1 line("line","x*[0]",0,xlin[middle] + 1);
00256    graph.Fit("line","RQ");
00257   //  TCanvas c("C","C",0,0,500,500);
00258   //  graph.Draw("AP");
00259   // c.Update();
00260   //getchar();
00261   fSplines[0].startx = 0;
00262   fSplines[0].starty = 0;
00263   fSplines[0].slope = line.GetParameter(0);
00264   fSplines[0].alpha = 0;
00265   fSplines[0].endx = xlin[middle] + 1;
00266   fSplines[0].endy = (xlin[middle] + 1)*fSplines[0].slope;
00267   int target=0;
00268   //    cout<<target<<" "<<fSplines[target].startx<<" "<<fSplines[target].endx<<" "
00269   //    <<fSplines[target].starty<<" "<<fSplines[target].endy<<" "
00270   //    <<fSplines[target].slope<<" "<<fSplines[target].alpha<<endl;
00271     ++target;
00272   for (unsigned int i=middle+1;i<xlin.size();i++) {
00273     // Now fSplines-interpolate all the way up.
00274     if (target>6) target=6;
00275     fSplines[target].startx = fSplines[target-1].endx;
00276     fSplines[target].endx = xlin[i];
00277     fSplines[target].endy = y[i];
00278     fSplines[target].starty = fSplines[target-1].endy;
00279     fSplines[target].slope = fSplines[target-1].slope + fSplines[target-1].alpha*(fSplines[target-1].endx-fSplines[target-1].startx);
00280     fSplines[target].alpha = (fSplines[target].endy-fSplines[target].starty - 
00281                             fSplines[target].slope*
00282                             (fSplines[target].endx-fSplines[target].startx))/
00283       ((fSplines[target].endx-fSplines[target].startx)*(fSplines[target].endx-fSplines[target].startx));
00284 
00285     //   cout<<target<<" "<<fSplines[target].startx<<" "<<fSplines[target].endx<<" "
00286     //  <<fSplines[target].starty<<" "<<fSplines[target].endy<<" "
00287     //  <<fSplines[target].slope<<" "<<fSplines[target].alpha<<endl;
00288     ++target;
00289   }
00290 
00291   // And now the linear extrapolation
00292   if (horizontal) {
00293     fSplines[target].startx = fSplines[target-1].endx;
00294     fSplines[target].starty = fSplines[target-1].endy;
00295     fSplines[target].endx = 160000;
00296     fSplines[target].endy = fSplines[target].starty;
00297     fSplines[target].slope = 0;
00298     fSplines[target].alpha = 0;
00299     //    cout<<target<<" "<<fSplines[target].startx<<" "<<fSplines[target].endx<<" "
00300     //  <<fSplines[target].starty<<" "<<fSplines[target].endy<<" "
00301     //  <<fSplines[target].slope<<" "<<fSplines[target].alpha<<endl;
00302   } 
00303   else {
00304     fSplines[target].startx = fSplines[target-1].endx;
00305     fSplines[target].starty = fSplines[target-1].endy;
00306     fSplines[target].endx = 160000;
00307     fSplines[target].slope = fSplines[target-1].slope + fSplines[target-1].alpha*(fSplines[target-1].endx-fSplines[target-1].startx);
00308     fSplines[target].endy = fSplines[target].starty + fSplines[target].slope*(fSplines[target].endx-fSplines[target].startx);
00309     fSplines[target].alpha = 0;
00310     //    cout<<target<<" "<<fSplines[target].startx<<" "<<fSplines[target].endx<<" "
00311     //  <<fSplines[target].starty<<" "<<fSplines[target].endy<<" "
00312     //  <<fSplines[target].slope<<" "<<fSplines[target].alpha<<endl;
00313   }
00314   fNsplines = target + 1;
00315   //  for (float i=0;i<10001;i+=1000) cout<<i<<"  "<<ADCtoLin(LintoADC(i))<<endl;
00316   // Now fiddle the numbers - our linear scale is x, and we want to fiddle
00317   // the scale to have a 1:1 mapping for the linear region.
00318   float xscale = fSplines[0].slope;
00319   // cout<<xscale<<endl;
00320   // so we have y = y0 + m(x-x0) + a(x-x0)(x-x0), and map x->sx, x0->sx0, so
00321   // y = y0 + (m/s)(sx-sx0) + (a/s^2)(sx-sx0)(sx-sx0)
00322 
00323   for (int i=0;i<fNsplines;i++) {
00324     fSplines[i].startx*=xscale;
00325     fSplines[i].endx*=xscale;
00326     fSplines[i].slope/=xscale;
00327     fSplines[i].alpha/=(xscale*xscale);
00328   }
00329 
00330   // Final sanity check
00331   if (this->ADCtoLin(8000) < 8000)
00332     {
00333       cout<<" "<<this->ADCtoLin(8000)<<"   ^^^^^^^^^^^^^\n";
00334       fNsplines=1;
00335       fSplines[0].startx = 0;
00336       fSplines[0].starty = 0;
00337       fSplines[0].slope = 1;
00338       fSplines[0].alpha = 0;
00339       fSplines[0].endx = 20000;
00340       fSplines[0].endy = 20000;
00341 
00342 
00343     }
00344 
00345   }
00346 }

CalLinearity::CalLinearity ( int  aggno,
PlexStripEndId seid,
vector< float > &  x,
vector< float > &  y 
)

Definition at line 57 of file CalLinearity.cxx.

References ADCtoLin(), CalLinearity::spline::alpha, CalLinearity::spline::endx, CalLinearity::spline::endy, fNsplines, fSplines, fTask, CalLinearity::spline::slope, CalLinearity::spline::startx, and CalLinearity::spline::starty.

00058                                                              : fAggregateNo(aggno), fStripEndKey(seid.BuildPlnStripEndKey()),fStripEndId(seid.GetEncoded())
00059 {
00060   // y is the data for this channel, x is the data for the "linear" scale.
00061   assert(x.size()==y.size());
00062   fTask=2;
00063   // Go up to 7000 in y
00064   unsigned int i;
00065 unsigned int q;
00066   int target=0;
00067 for (q=0;q<x.size();q++) {
00068   //    cout<<"****"<<q<<" "<<x[q]<<" "<<y[q]<<endl;
00069 if (x[q]>100 && y[q]>100) break;
00070 }
00071 // Don't fit to small numbers!
00072 
00073   for (i=q;i<x.size();i++) {
00074     //  cout<<"****"<<i<<" "<<x[i]<<" "<<y[i]<<endl;
00075     if (y[i]>6000) break;
00076 
00077   }
00078   if (i==q) {
00079    fSplines[0].startx = 0;
00080    fSplines[0].starty = 0;
00081    fSplines[0].slope = 1;
00082    fSplines[0].alpha = 0;
00083    fSplines[0].endx = 16000;
00084    fSplines[0].endy = 16000;
00085    ++target;
00086    goto banana;
00087 
00088   }
00089  
00090   {
00091   TGraph g1(i-q,&(x[q]),&(y[q]));
00092   TF1 line("line","x*[0]",0,x[i-1] + 1);
00093    g1.Fit("line","RQ");
00094    fSplines[0].startx = 0;
00095    fSplines[0].starty = 0;
00096    fSplines[0].slope = line.GetParameter(0);
00097    fSplines[0].alpha = 0;
00098    fSplines[0].endx = x[i-1];
00099    fSplines[0].endy = (x[i-1])*fSplines[0].slope;
00100 //   cout<<fSplines[0].endx<<" "<<fSplines[0].endy<<" "
00101 //       <<fSplines[0].slope<<" "<<fSplines[0].alpha
00102 //       <<" "<<fSplines[0].slope+2*(fSplines[0].endx- fSplines[0].startx)* 
00103 //                                   fSplines[0].alpha<<endl;
00104    ++target;
00105   }
00106   cout<<fSplines[0].slope<<fSplines[0].endx<<" "<<fSplines[0].endy<<endl;
00107 
00108   {
00109 // Suck up up to 2000 ADC counts in X.
00110 TGraph g2(x.size(),&(x[0]),&(y[0]));
00111 for(;;){
00112   unsigned int j;
00113    for (j=i;j<x.size();j++) {
00114       if (x[j]-x[i]>1000) break;
00115    }
00116    if (j==x.size()) break;
00117    if (target>8) target=8;
00118    if ((j-i)>1) {
00119      cout<<"target "<<target<<" Fit from "<<i<<" to "<<j<<" of "<<x.size()<< " ["<<x[i]<<":"<<x[j]<<" "<<y[i]<<":"<<y[j]<<"]\n";
00120    fSplines[target].startx = fSplines[target-1].endx;
00121    fSplines[target].starty = fSplines[target-1].endy;
00122    TF1 func("func","[0]+[2]*(x-[1]) + [3]*(x-[1])*(x-[1])",x[i]-1,x[j]+1);
00123    func.SetParameter(0,fSplines[target].starty);
00124    func.SetParameter(1,fSplines[target].startx);
00125    func.SetParLimits(0,fSplines[target].starty,fSplines[target].starty); // 1>0, so this means fixed
00126    func.SetParLimits(1,fSplines[target].startx,fSplines[target].startx); // 1>0, so this means fixed
00127    func.SetParLimits(3,-10,0);
00128    g2.Fit("func","RQ");
00129    fSplines[target].endx = x[j];
00130    fSplines[target].endy = func.Eval(x[j]);
00131    fSplines[target].slope = func.GetParameter(2);
00132    fSplines[target].alpha = func.GetParameter(3);
00133 }
00134 else if ((j-i)==1) {
00135   cout<<"Line from "<<i<<" to "<<j<<" ["<<x[i]<<":"<<x[j]<<"]\n";
00136    fSplines[target].startx = fSplines[target-1].endx;
00137    fSplines[target].starty = fSplines[target-1].endy;
00138    fSplines[target].endx = x[j];
00139    fSplines[target].endy = y[j];
00140    fSplines[target].slope = (fSplines[target].endy-fSplines[target].starty)/(fSplines[target].endx-fSplines[target].startx);
00141    fSplines[target].alpha = 0;
00142 }
00143 else if ((j-i)==0) {
00144   cout<<"No data\n";
00145 --target;
00146 }
00147    i=j;
00148 ++target;
00149 cout<<" "<<fSplines[target-1].endx<<" "<<fSplines[target-1].endy<<endl;
00150 }
00151   }
00152 
00153  banana:
00154 
00155    // and now extrapolate
00156     fSplines[target].startx = fSplines[target-1].endx;
00157     fSplines[target].starty = fSplines[target-1].endy;
00158     fSplines[target].endx = 160000;
00159     fSplines[target].slope = fSplines[target-1].slope + 2*fSplines[target-1].alpha*(fSplines[target-1].endx-fSplines[target-1].startx); 
00160     if (  fSplines[target].slope<0)  fSplines[target].slope =0;
00161     fSplines[target].endy = fSplines[target].starty + fSplines[target].slope*(fSplines[target].endx-fSplines[target].startx);
00162     fSplines[target].alpha = 0;
00163 
00164   fNsplines = target+1;
00165   // Now fiddle the numbers - our linear scale is x, and we want to fiddle
00166   // the scale to have a 1:1 mapping for the linear region.
00167   float xscale = fSplines[0].slope;
00168   // cout<<xscale<<endl;
00169   // so we have y = y0 + m(x-x0) + a(x-x0)(x-x0), and map x->sx, x0->sx0, so
00170   // y = y0 + (m/s)(sx-sx0) + (a/s^2)(sx-sx0)(sx-sx0)
00171 
00172 
00173   cout<<xscale<<" "<<fSplines[fNsplines-1].endx<<" "<<fSplines[fNsplines-1].endy<<endl;
00174      
00175     for (int i=0;i<fNsplines;i++) { 
00176       fSplines[i].startx*=xscale;   
00177     fSplines[i].endx*=xscale;
00178     fSplines[i].slope/=xscale;
00179     fSplines[i].alpha/=(xscale*xscale);
00180     }
00181 
00182  // Final sanity check
00183   if (this->ADCtoLin(8000) < 8000)
00184     {
00185       cout<<" "<<this->ADCtoLin(8000)<<"   ^^^^^^^^^^^^^\n";
00186       fNsplines=1;
00187       fSplines[0].startx = 0;
00188       fSplines[0].starty = 0;
00189       fSplines[0].slope = 1;
00190       fSplines[0].alpha = 0;
00191       fSplines[0].endx = 20000;
00192       fSplines[0].endy = 20000;
00193 
00194 
00195     }
00196 
00197 
00198     if (fSplines[fNsplines-1].endx < 20000) {
00199       fSplines[fNsplines-1].endx = 20000 ;
00200       fSplines[fNsplines-1].endy = fSplines[fNsplines-1].starty + fSplines[fNsplines-1].slope*(fSplines[fNsplines-1].endx-fSplines[fNsplines-1].startx) ;
00201 
00202     }
00203 
00204   cout<<xscale<<" "<<fSplines[fNsplines-1].endx<<" "<<fSplines[fNsplines-1].endy<<endl;
00205      
00206 }

CalLinearity::CalLinearity ( const CalLinearity from  )  [inline, private]

Definition at line 65 of file CalLinearity.h.

References LEA_CTOR.

00066     : DbiTableRow(from) { LEA_CTOR; *this = from; }


Member Function Documentation

Float_t CalLinearity::ADCtoLin ( const Float_t  charge  )  const

Definition at line 396 of file CalLinearity.cxx.

References MuELoss::a, CalLinearity::spline::alpha, CalLinearity::spline::endx, fNsplines, fSplines, fTask, Msg::kWarning, Munits::m, MSG, CalLinearity::spline::slope, CalLinearity::spline::startx, and CalLinearity::spline::starty.

Referenced by PulserSigLinCalScheme::ApplyBendyCalib(), and CalLinearity().

00397 {
00398   switch (fTask) {
00399   default:
00400     MSG("Calib",Msg::kWarning)<<"CalLinearity::ADCtoLin has task "
00401                                    << fTask <<" but doesn't know how to decode it. \n Defaulting to task 2\n";
00402   case 2:
00403     // This is the straight line plus a set of quadratic splines.
00404     // Everything is represented by a quadratic spline, though.
00405     for (int i=0;i<fNsplines; i++) {
00406       if (fSplines[i].endy >= charge && fSplines[i].starty<= charge) {
00407         // use segment i
00408         float m = fSplines[i].slope;
00409         float a = fSplines[i].alpha;
00410         float c = charge - fSplines[i].starty;
00411         float x0 = fSplines[i].startx;
00412         if (a==0) return x0 + c/m;
00413         return x0 + (a/fabs(a)) * (-m + TMath::Sqrt(m*m+4*a*c))/(2*fabs(a));
00414       }
00415     }
00416     // No suitable spline segment - return xmax.
00417     //   (but not the max of the extrapolation spline!)
00418     if (fNsplines==1) return fSplines[0].endx;
00419     return fSplines[fNsplines-2].endx;
00420     break;
00421   };
00422 }

virtual DbiTableRow* CalLinearity::CreateTableRow (  )  const [inline, virtual]

Implements DbiTableRow.

Definition at line 52 of file CalLinearity.h.

00052                                              { 
00053       return new CalLinearity; }  

void CalLinearity::Fill ( DbiResultSet rs,
const DbiValidityRec vrec 
) [virtual]

Implements DbiTableRow.

Definition at line 349 of file CalLinearity.cxx.

References CalLinearity::spline::alpha, CalLinearity::spline::endx, CalLinearity::spline::endy, fAggregateNo, fNsplines, fNumber, fParam, fSplines, fStripEndId, fStripEndKey, fTask, CalLinearity::spline::slope, CalLinearity::spline::startx, and CalLinearity::spline::starty.

00351 {
00352   rs >> fAggregateNo >> fTask >> fStripEndKey >> fStripEndId >> fNumber;
00353   for (int i=0;i<40;i++) rs >> fParam[i];
00354 
00355   // Unpack Param[] into fSplines[].
00356   fNsplines = fNumber;
00357   int pos = 0;
00358   for (int i=0;i<fNsplines;i++) {
00359     fSplines[i].startx =  fParam[pos++];
00360     fSplines[i].starty = fParam[pos++]; 
00361     fSplines[i].slope = fParam[pos++];
00362     fSplines[i].alpha = fParam[pos++];
00363     if (i>0) {
00364       fSplines[i-1].endx = fSplines[i].startx;
00365       fSplines[i-1].endy = fSplines[i].starty;
00366     }
00367   }
00368   fSplines[fNsplines-1].endx = fParam[pos];
00369   fSplines[fNsplines-1].endy = fSplines[fNsplines-1].starty + 
00370                                fSplines[fNsplines-1].slope*(fSplines[fNsplines-1].endx-fSplines[fNsplines-1].startx) + 
00371                                fSplines[fNsplines-1].alpha*(fSplines[fNsplines-1].endx-fSplines[fNsplines-1].startx)*
00372                                                            (fSplines[fNsplines-1].endx-fSplines[fNsplines-1].startx);
00373 }

Int_t CalLinearity::GetAggregateNo (  )  const [inline, virtual]

Reimplemented from DbiTableRow.

Definition at line 37 of file CalLinearity.h.

References fAggregateNo.

00037 { return fAggregateNo; }

UInt_t CalLinearity::GetIndex ( UInt_t   )  const [inline, virtual]

Reimplemented from DbiTableRow.

Definition at line 38 of file CalLinearity.h.

References fStripEndKey.

00038 { return fStripEndKey; }

Float_t CalLinearity::GetLimit (  )  const [inline]

Definition at line 42 of file CalLinearity.h.

References CalLinearity::spline::endy, fNsplines, and fSplines.

Referenced by CalLinearity().

00042                            {
00043     if (fNsplines==1) {
00044       return fSplines[fNsplines-1].endy;
00045     }
00046     else {
00047       // Don't use the extrapolation spline for the limit
00048       return fSplines[fNsplines-2].endy;
00049     }
00050   };

Int_t CalLinearity::GetNumXPoints (  )  [inline]

Definition at line 41 of file CalLinearity.h.

References fNumXPoints.

00041 {return fNumXPoints;}  

Int_t CalLinearity::GetStripEnd (  )  const [inline]

Definition at line 39 of file CalLinearity.h.

References fStripEndId.

00039 {return fStripEndId;}

Int_t CalLinearity::GetTask (  )  const [inline]

Definition at line 40 of file CalLinearity.h.

References fTask.

00040 { return fTask; }

Float_t CalLinearity::LintoADC ( const Float_t  charge  )  const

Definition at line 424 of file CalLinearity.cxx.

References MuELoss::a, CalLinearity::spline::alpha, CalLinearity::spline::endy, fNsplines, fSplines, fTask, Msg::kWarning, Munits::m, MSG, CalLinearity::spline::slope, CalLinearity::spline::startx, and CalLinearity::spline::starty.

00425 {
00426   switch (fTask) {
00427   default:
00428     MSG("Calib",Msg::kWarning)<<"CalLinearity::ADCtoLin has task "
00429                                    << fTask <<" but doesn't know how to decode it. \n Defaulting to task 2\n";
00430   case 2:
00431     // This is the straight line plus a set of quadratic splines.
00432     // Everything is represented by a quadratic spline, though.
00433     for (int i=0;i<fNsplines; i++) {
00434       if (fSplines[i].endx >= charge && fSplines[i].startx<= charge) {
00435         // use segment i
00436         float m = fSplines[i].slope;
00437         float a = fSplines[i].alpha;
00438         float y0 = fSplines[i].starty;
00439         float x0 = fSplines[i].startx;
00440         return y0 + m*(charge-x0) + a*(charge-x0)*(charge-x0);
00441       }
00442     }
00443     // No suitable spline segment - return xmax.
00444     //   (but not the max of the extrapolation spline!)
00445     // WOn't happe - we'll always extrapolate.
00446     if (fNsplines==1) return fSplines[0].endy;
00447     return fSplines[fNsplines-2].endy;
00448     break;
00449   };
00450 }

void CalLinearity::Store ( DbiOutRowStream ors,
const DbiValidityRec vrec 
) const [virtual]

Reimplemented from DbiTableRow.

Definition at line 376 of file CalLinearity.cxx.

References CalLinearity::spline::alpha, CalLinearity::spline::endx, fAggregateNo, fNsplines, fNumber, fParam, fSplines, fStripEndId, fStripEndKey, fTask, CalLinearity::spline::slope, CalLinearity::spline::startx, and CalLinearity::spline::starty.

00378 {
00379   // Pack fSplines[] into fParam[]
00380   int pos = 0;
00381   for (int i=0;i<fNsplines;i++) {
00382     fParam[pos++] = fSplines[i].startx;
00383     fParam[pos++] = fSplines[i].starty;
00384     fParam[pos++] = fSplines[i].slope;
00385     fParam[pos++] = fSplines[i].alpha;
00386   }
00387   fParam[pos] = fSplines[fNsplines-1].endx;
00388   for (int i=pos+1;i<40;i++) fParam[i] =0;
00389   fNumber = fNsplines;
00390   ors << fAggregateNo << fTask << fStripEndKey << fStripEndId << fNumber;
00391   for (int i=0;i<40;i++) ors << fParam[i];
00392 
00393 }


Member Data Documentation

Int_t CalLinearity::fAggregateNo [private]

Definition at line 78 of file CalLinearity.h.

Referenced by Fill(), GetAggregateNo(), and Store().

int CalLinearity::fNsplines [private]

Definition at line 86 of file CalLinearity.h.

Referenced by ADCtoLin(), CalLinearity(), Fill(), GetLimit(), LintoADC(), and Store().

Int_t CalLinearity::fNumber [mutable, private]

Definition at line 82 of file CalLinearity.h.

Referenced by Fill(), and Store().

Definition at line 87 of file CalLinearity.h.

Referenced by CalLinearity(), and GetNumXPoints().

Float_t CalLinearity::fParam[40] [mutable, private]

Definition at line 83 of file CalLinearity.h.

Referenced by Fill(), and Store().

Definition at line 85 of file CalLinearity.h.

Referenced by ADCtoLin(), CalLinearity(), Fill(), GetLimit(), LintoADC(), and Store().

Int_t CalLinearity::fStripEndId [private]

Definition at line 80 of file CalLinearity.h.

Referenced by Fill(), GetStripEnd(), and Store().

Int_t CalLinearity::fStripEndKey [private]

Definition at line 79 of file CalLinearity.h.

Referenced by Fill(), GetIndex(), and Store().

Int_t CalLinearity::fTask [private]

Definition at line 81 of file CalLinearity.h.

Referenced by ADCtoLin(), CalLinearity(), Fill(), GetTask(), LintoADC(), and Store().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1