PulserTimeCalScheme Class Reference

#include <PulserTimeCalScheme.h>

Inheritance diagram for PulserTimeCalScheme:
CalScheme CfgPromptConfigurable

List of all members.

Public Member Functions

 PulserTimeCalScheme ()
virtual void DoReset (const VldContext &context)
virtual void ConfigModified ()
virtual void PrintConfig (std::ostream &os) const
virtual DoubleErr GetCalibratedTime (DoubleErr rawtime, FloatErr rawcharge, const PlexStripEndId &seid) const
virtual DoubleErr DecalTime (DoubleErr caltime, FloatErr rawcharge, const PlexStripEndId &seid) const

Private Member Functions

DoubleErr CalibrateByJumps (DoubleErr caltime, const RawChannelId &rcid, Bool_t calibrate) const
DoubleErr CalibrateByPulser (DoubleErr rawtime, const RawChannelId &rcid, Bool_t calibrate) const
DoubleErr CalibrateByMuon (DoubleErr caltime, const PlexStripEndId &seid, Bool_t calibrate) const
DoubleErr WalkCorrection (FloatErr rawcharge, const PlexStripEndId &seid) const
DoubleErr CalibrateShield (DoubleErr rawtime, FloatErr rawcharge, const PlexStripEndId &sied, Bool_t calibrate) const
Bool_t GetPulserCalibration (Int_t iled, UInt_t index, const PulserTimeDrift *&drift, const PulserTimeDrift *&ref) const
 ClassDef (PulserTimeCalScheme, 0)

Private Attributes

Int_t fUseMuonCalibration
Int_t fMuonTask
Int_t fMuonTaskND
Int_t fUseShieldCalibration
Int_t fUseJumps
Int_t fJumpTask
Int_t fUsePulserCalibration
Int_t fDoWalkCorrection
Int_t fPulserLed [kMaxLeds]
Double_t fDefaultTimingCardSetting
Double_t fOverallOffset
VldTimeStamp fReferenceTime
DbiResultPtr< CalTimeCalibrationfMuonResPtr
DbiResultPtr< CalTimeCalibrationfShieldResPtr
DbiResultPtr< CalTimeJumpfJumpResPtr
DbiResultPtr< PulserTimeDriftfDriftPtr [kMaxLeds]
DbiResultPtr< PulserTimeDriftfDriftRefPtr [kMaxLeds]
DbiResultPtr
< PulserTimingCardSetting
fTimingCardResPtr
DbiResultPtr
< PulserTimingCardSetting
fTimingCardReferencePtr

Detailed Description

Definition at line 23 of file PulserTimeCalScheme.h.


Constructor & Destructor Documentation

PulserTimeCalScheme::PulserTimeCalScheme (  ) 

Definition at line 27 of file PulserTimeCalScheme.cxx.

References Registry::Set().

00028 {
00029   Registry r;
00030   // Set configurable options.
00031   r.Set("UseMuonCalibration",1);
00032   r.Set("UsePulserCalibration",0);
00033   r.Set("UseShieldCalibration",1);
00034   r.Set("UseJumps",1);
00035   r.Set("JumpTask",1); // (Obsolete - now tied to MuonTask)
00036   r.Set("DoWalkCorrection",1);
00037   r.Set("PulserLed1",2);
00038   r.Set("PulserLed2",3);
00039   r.Set("PulserLed3",4);
00040   r.Set("DefaultTimingCardSetting",260.);
00041   //r.Set("OverallOffset",30.*Munits::ns);
00042   r.Set("ReferenceDate",20040930);
00043   r.Set("ReferenceTime",0);
00044   r.Set("MuonTask","DogwoodToF");
00045   InitializeConfig(r); 
00046 }


Member Function Documentation

DoubleErr PulserTimeCalScheme::CalibrateByJumps ( DoubleErr  caltime,
const RawChannelId rcid,
Bool_t  calibrate 
) const [private]

Definition at line 295 of file PulserTimeCalScheme.cxx.

References fJumpResPtr, CalTimeJump::GetIndex(), CalTimeJump::GetJump(), and DbiResultPtr< T >::GetRowByIndex().

Referenced by DecalTime(), and GetCalibratedTime().

00298 {
00299   // Find index number into table.
00300   UInt_t index = CalTimeJump::GetIndex(rcid);
00301 
00302   // If a jump entry exists, apply it.
00303 
00304   const CalTimeJump* jump = fJumpResPtr.GetRowByIndex(index);
00305   if(jump) {
00306     if(calibrate)
00307       return rawtime - (double)jump->GetJump();
00308     else
00309       return rawtime + (double)jump->GetJump();
00310   }
00311 
00312   // Otherwise, do nothing.
00313 
00314   return rawtime;
00315 }

DoubleErr PulserTimeCalScheme::CalibrateByMuon ( DoubleErr  caltime,
const PlexStripEndId seid,
Bool_t  calibrate 
) const [private]

Definition at line 318 of file PulserTimeCalScheme.cxx.

References PlexStripEndId::AsString(), PlexStripEndId::BuildPlnStripEndKey(), fMuonResPtr, DbiResultPtr< T >::GetNumRows(), CalTimeCalibration::GetOffset(), DbiResultPtr< T >::GetRowByIndex(), CalTimeCalibration::GetScale(), CalScheme::IncrementErrors(), CalScheme::kMissingRow, CalScheme::kTimeCalibrator, Msg::kWarning, MAXMSG, and Munits::ns.

Referenced by DecalTime(), and GetCalibratedTime().

00321 {
00322   // Now need to get the row which corresponds to the stripendnum.
00323   const CalTimeCalibration* dpgc = fMuonResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00324 
00325   if(dpgc==0) {
00326     if(fMuonResPtr.GetNumRows()>0) {
00327       MAXMSG("Calib",Msg::kWarning,10) 
00328         << "PulserTimeCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00329       
00330       IncrementErrors(kTimeCalibrator,kMissingRow,seid);
00331     }
00332     return rawtime + DoubleErr(0,20.*Munits::ns); // Show there's no calib constant.
00333   }
00334   if(calibrate)
00335     return (rawtime/(double)dpgc->GetScale()) -  (double)dpgc->GetOffset();
00336 
00337   // else decalibrate:
00338   // No inverse function exists in the row function, so I'll kludge one here.
00339   // NJT 7/04
00340   return (rawtime +  (double)dpgc->GetOffset())*(double)dpgc->GetScale();
00341 }

DoubleErr PulserTimeCalScheme::CalibrateByPulser ( DoubleErr  rawtime,
const RawChannelId rcid,
Bool_t  calibrate 
) const [private]

Definition at line 346 of file PulserTimeCalScheme.cxx.

References RawChannelId::AsString(), fDefaultTimingCardSetting, fPulserLed, fTimingCardReferencePtr, fTimingCardResPtr, RawChannelId::GetCrate(), PulserTimingCardSetting::GetDelayNanoSecs(), PulserTimeDrift::GetEntries(), PulserTimeDrift::GetIndex(), PulserTimeDrift::GetMean(), DbiResultPtr< T >::GetNumRows(), GetPulserCalibration(), PulserTimeDrift::GetRms(), DbiResultPtr< T >::GetRowByIndex(), Calibrator::GetTDCConvert(), CalScheme::IncrementErrors(), Calibrator::Instance(), Msg::kDebug, kMaxLeds, CalScheme::kMissingRow, CalScheme::kTimeCalibrator, kVaRcid, Msg::kWarning, MAXMSG, MSG, and Munits::ns.

Referenced by DecalTime(), and GetCalibratedTime().

00349 {
00350   // Find index number into table.
00351   UInt_t index = PulserTimeDrift::GetIndex(rcid);
00352   
00353   const PulserTimeDrift* drift    = 0;
00354   const PulserTimeDrift* driftref = 0;
00355 
00356   // Get drift point and drift reference point
00357   Int_t whichled = 0;
00358   bool driftok = GetPulserCalibration(whichled,index,drift,driftref);
00359   
00360   // If not good, look through the list of backups.
00361   while(!driftok){
00362     whichled++;
00363     if(whichled<kMaxLeds) {
00364       driftok = GetPulserCalibration(whichled,index,drift,driftref);
00365       MSG("Calib",Msg::kDebug) << "PulserTiming: " << rcid.AsString() << " Fell back to LED " << fPulserLed[whichled] << endl;
00366     } else {
00367       MAXMSG("Calib",Msg::kWarning,10) 
00368         << "PulserTimeCalScheme: Failed to find calibration for channel " 
00369         << rcid.AsString() << " index " << index << " in primary or fallback tables.\n";
00370       IncrementErrors(kTimeCalibrator,kMissingRow,rcid);
00371       return rawtime + DoubleErr(0,50.*Munits::ns); // no calibration. Add 50ns error to show.
00372     }
00373   }
00374   
00375   
00376   // Get Settings row, if it exists.
00377   const PulserTimingCardSetting* cardSetting = 
00378     fTimingCardResPtr.GetRowByIndex(rcid.GetCrate());
00379   const PulserTimingCardSetting* refCardSetting = 
00380     fTimingCardReferencePtr.GetRowByIndex(rcid.GetCrate());
00381 
00382   Double_t tpmt_delay_ns = fDefaultTimingCardSetting;
00383   Double_t ref_delay_ns  = fDefaultTimingCardSetting;
00384   
00385   // Check for errors getting setting.
00386   if(cardSetting==0) {
00387     if(fTimingCardResPtr.GetNumRows()>0) {
00388       MAXMSG("Calib",Msg::kWarning,10) << "Incomplete PulserTimingCardSettings table!" << endl;      
00389     }
00390     IncrementErrors(kTimeCalibrator,kMissingRow,rcid);    
00391   } else {
00392     tpmt_delay_ns = cardSetting->GetDelayNanoSecs();
00393   }
00394   
00395   
00396   // Check for errors getting reference setting.
00397   if(refCardSetting==0) {
00398     if(fTimingCardReferencePtr.GetNumRows()>0) {
00399       MAXMSG("Calib",Msg::kWarning,10) << "Incomplete PulserTimingCardSettings table!" << endl;      
00400     }
00401     IncrementErrors(kTimeCalibrator,kMissingRow,rcid);    
00402   } else {
00403     ref_delay_ns = cardSetting->GetDelayNanoSecs();
00404   }
00405   
00406   
00407   // Finally, do the correction:
00408   
00409   // Crate offset due to changed timing card setting:
00410   double crate_offset_t = (tpmt_delay_ns - ref_delay_ns)*Munits::ns;
00411   
00412   // Offset as calibrated by LI. Longer timing card settings
00413   // mean that the drift point is too big a number.
00414   double drift_tdcs = (drift->GetMean() - driftref->GetMean());
00415   double drift_err  = (drift->GetRms() / sqrt(drift->GetEntries()));
00416   double convert = Calibrator::Instance().GetTDCConvert(kVaRcid); // s per tick
00417   DoubleErr drift_t(drift_tdcs * convert,
00418                     drift_err  * convert);
00419   
00420   // And the time walk.
00421   
00422   
00423   DoubleErr offset = drift_t - crate_offset_t;
00424   
00425   if(calibrate) 
00426     return rawtime - offset;
00427   
00428   // else:
00429   return rawtime + offset;
00430 }

DoubleErr PulserTimeCalScheme::CalibrateShield ( DoubleErr  rawtime,
FloatErr  rawcharge,
const PlexStripEndId sied,
Bool_t  calibrate 
) const [private]

Definition at line 505 of file PulserTimeCalScheme.cxx.

References PlexStripEndId::AsString(), PlexStripEndId::BuildPlnStripEndKey(), fDoWalkCorrection, fShieldResPtr, DbiResultPtr< T >::GetNumRows(), CalTimeCalibration::GetOffset(), DbiResultPtr< T >::GetRowByIndex(), CalTimeCalibration::GetScale(), CalTimeCalibration::GetSlewC1(), CalTimeCalibration::GetSlewC2(), CalTimeCalibration::GetSlewC3(), CalTimeCalibration::GetSlewC4(), CalScheme::IncrementErrors(), CalScheme::kMissingRow, CalScheme::kTimeCalibrator, Msg::kWarning, MAXMSG, Munits::ns, and WalkCorrection().

Referenced by DecalTime(), and GetCalibratedTime().

00509 {
00510    // Now need to get the row which corresponds to the stripendnum.
00511   const CalTimeCalibration* dpgc = fShieldResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00512 
00513   if(dpgc==0) {
00514     if(fShieldResPtr.GetNumRows()>0) {
00515       MAXMSG("Calib",Msg::kWarning,10) 
00516         << "PulserTimeCalScheme: No database row for shield StripEnd " << seid.AsString() << "\n";      
00517       IncrementErrors(kTimeCalibrator,kMissingRow,seid);
00518     }
00519     return rawtime - DoubleErr(-30.0*Munits::ns, // -30ns is the usual average
00520                                20.*Munits::ns); // Show there's no calib constant.
00521   }
00522 
00523   // apply the 'extra' walk correction for shield hits.
00524   if(rawcharge<1) rawcharge=1; // Protect against -ve numbers
00525   Double_t logq = log(rawcharge);
00526 
00527   Double_t walk = 0;
00528   if(fDoWalkCorrection) {
00529     const float kgainadjust=60./90.; // I think this compensates for the extra gain in the shield
00530     walk = WalkCorrection(rawcharge*kgainadjust,seid);
00531     walk += dpgc->GetSlewC1()
00532     + dpgc->GetSlewC2()*logq
00533     + dpgc->GetSlewC3()*logq*logq
00534     + dpgc->GetSlewC4()*logq*logq*logq;
00535   }
00536 
00537 
00538   if(calibrate)
00539     return rawtime - walk + (double)dpgc->GetOffset();
00540   
00541   // else decalibrate:
00542   return  rawtime +  walk - (double)dpgc->GetScale();
00543 
00544 }

PulserTimeCalScheme::ClassDef ( PulserTimeCalScheme  ,
 
) [private]

Reimplemented from CalScheme.

void PulserTimeCalScheme::ConfigModified ( void   )  [virtual]

Reimplemented from CalScheme.

Definition at line 49 of file PulserTimeCalScheme.cxx.

References fDefaultTimingCardSetting, fDoWalkCorrection, fMuonTask, fMuonTaskND, Form(), fPulserLed, fReferenceTime, fUseJumps, fUseMuonCalibration, fUsePulserCalibration, fUseShieldCalibration, Registry::Get(), CfgPromptConfigurable::GetConfig(), CalScheme::GetContext(), kMaxLeds, Msg::kWarning, MSG, Registry::PrettyPrint(), and CalScheme::Reset().

00050 {                                       
00051   Int_t refDate = 0;
00052   Int_t refTime = 0;;
00053   
00054   const char* taskname;
00055 
00056   bool ok = true;
00057   ok = ok && GetConfig().Get("UseMuonCalibration",fUseMuonCalibration);
00058   ok = ok && GetConfig().Get("UseShieldCalibration",fUseShieldCalibration);
00059   ok = ok && GetConfig().Get("UsePulserCalibration",fUsePulserCalibration);
00060   ok = ok && GetConfig().Get("UseJumps",fUseJumps);
00061   //ok = ok && GetConfig().Get("JumpTask",fJumpTask);
00062   ok = ok && GetConfig().Get("DoWalkCorrection",fDoWalkCorrection);
00063   ok = ok && GetConfig().Get("DefaultTimingCardSetting",fDefaultTimingCardSetting);
00064   //ok = ok && GetConfig().Get("OverallOffset",fOverallOffset);
00065   ok = ok && GetConfig().Get("ReferenceDate",refDate);
00066   ok = ok && GetConfig().Get("ReferenceTime",refTime);
00067   for(int i=0;i<kMaxLeds; i++) {
00068     ok = ok && GetConfig().Get(Form("PulserLed%d",i+1),fPulserLed[i]);
00069   }
00070   ok = ok && GetConfig().Get("MuonTask",taskname);
00071 
00072   if(!ok){
00073     MSG("Calib",Msg::kWarning) << "PulserTimeCalScheme couldn't configure properly!" << endl;
00074     GetConfig().PrettyPrint(std::cerr);
00075   }
00076 
00077   if     (0==strcasecmp(taskname,"Ginkgo"     )){ fMuonTask = 2; fMuonTaskND = 50; }
00078   else if(0==strcasecmp(taskname,"Fir"        )){ fMuonTask = 2; fMuonTaskND = 50; }
00079   else if(0==strcasecmp(taskname,"Elm"        )){ fMuonTask = 2; fMuonTaskND = 50; }
00080   else if(0==strcasecmp(taskname,"DogwoodToF" )){ fMuonTask = 2; fMuonTaskND = 50; }
00081   else if(0==strcasecmp(taskname,"Dogwood"    )){ fMuonTask = 2; fMuonTaskND = 0;  }
00082   else if(0==strcasecmp(taskname,"Andys"      )){ fMuonTask = 1; fMuonTaskND = 0;  }
00083   else if(0==strcasecmp(taskname,"Brians"     )){ fMuonTask = 0; fMuonTaskND = 0;  }
00084   else{
00085     // Feh?
00086     MSG("Calib",Msg::kWarning) << "PulserTimeCalScheme doesn't recognise task " << taskname << endl;
00087   }  
00088 
00089    fReferenceTime = VldTimeStamp(refDate,refTime,0);
00090 
00091   // Ensure that the DB has been changed for this event.
00092   Reset(GetContext(),true); 
00093 }

DoubleErr PulserTimeCalScheme::DecalTime ( DoubleErr  caltime,
FloatErr  rawcharge,
const PlexStripEndId seid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Go from calibrated time to raw time

Input: True time Raw charge Strip end

Output: Raw, uncalibrated time.

Must be implimented by: TimeCalibrator

Reimplemented from CalScheme.

Definition at line 250 of file PulserTimeCalScheme.cxx.

References CalibrateByJumps(), CalibrateByMuon(), CalibrateByPulser(), CalibrateShield(), fDoWalkCorrection, fUseJumps, fUseMuonCalibration, fUsePulserCalibration, fUseShieldCalibration, CalScheme::GetContext(), DataUtil::GetDetector(), PlexHandle::GetRawChannelId(), PlexPlaneId::IsVetoShield(), Detector::kFar, and WalkCorrection().

00253 {
00267 
00268   // Find raw channel.
00269   DoubleErr time = caltime;
00270 
00271   if(seid.IsVetoShield()) {
00272 
00273     // Shield hits:
00274     if(fUseShieldCalibration) time = CalibrateShield(time,rawcharge,seid,false); 
00275 
00276   } else {
00277 
00278     // Non-shield hits:
00279 
00280     if(GetContext().GetDetector()==Detector::kFar) {
00281       PlexHandle plex(GetContext());
00282       RawChannelId rcid = plex.GetRawChannelId(seid);
00283       if(fUseJumps)             time = CalibrateByJumps(time,rcid,false);
00284       if(fUsePulserCalibration) time = CalibrateByPulser(time,rcid,false);
00285     }
00286     if(fUseMuonCalibration)   time = CalibrateByMuon(time,seid,false);
00287     if(fDoWalkCorrection)     time+= WalkCorrection(rawcharge,seid);
00288   }
00289 
00290   return time;
00291 }

void PulserTimeCalScheme::DoReset ( const VldContext context  )  [virtual]

Reimplemented from CalScheme.

Definition at line 124 of file PulserTimeCalScheme.cxx.

References VldContext::AsString(), fDriftPtr, fDriftRefPtr, fJumpResPtr, fMuonResPtr, fMuonTask, fMuonTaskND, fPulserLed, fReferenceTime, fShieldResPtr, fTimingCardReferencePtr, fTimingCardResPtr, fUseJumps, fUseMuonCalibration, fUsePulserCalibration, fUseShieldCalibration, VldContext::GetDetector(), DbiResultPtr< T >::GetNumRows(), VldContext::GetSimFlag(), CalScheme::IncrementErrors(), Detector::kFar, kMaxLeds, CalScheme::kMissingTable, Detector::kNear, CalScheme::kTimeCalibrator, Msg::kVerbose, Msg::kWarning, MAXMSG, MSG, and DbiResultPtr< T >::NewQuery().

00125 {
00126   MSG("Calib",Msg::kVerbose) << "PulserTimeCalScheme::DoReset()" << endl;
00127   
00128   if(fUseMuonCalibration) {
00129     if(context.GetDetector()==Detector::kNear) 
00130          fMuonResPtr.NewQuery(context,fMuonTaskND);
00131     else fMuonResPtr.NewQuery(context,fMuonTask);
00132     
00133     if(fMuonResPtr.GetNumRows()==0) {
00134       MAXMSG("Calib",Msg::kWarning,10) 
00135         << "No rows in CALTIMECALIBRATION with validity context "
00136         << context.AsString() << "  No muon timing calibration will be applied." << endl;
00137       IncrementErrors(kTimeCalibrator,kMissingTable);
00138     }
00139   }
00140   
00141   if(fUseShieldCalibration && context.GetDetector()==Detector::kFar) {
00142     fShieldResPtr.NewQuery(context,99); // Task 99 is for shield.
00143     if(fShieldResPtr.GetNumRows()==0) {
00144         MAXMSG("Calib",Msg::kWarning,10) 
00145           << "No rows for FD shield timing calibration CALTIMECALIBRATION task " 
00146           << 99 << " with validity context "
00147           << context.AsString() << endl;
00148         IncrementErrors(kTimeCalibrator,kMissingTable);
00149     }
00150   }
00151 
00152   if(fUseJumps) {
00153     if(context.GetDetector()==Detector::kNear) 
00154                            fJumpResPtr.NewQuery(context,fMuonTaskND);
00155     else if( fMuonTask>0 ) fJumpResPtr.NewQuery(context,fMuonTask);
00156     // No errors if no data.
00157   }
00158 
00159   VldContext refContext(context.GetDetector(),
00160                         context.GetSimFlag(),
00161                         fReferenceTime);
00162 
00163   if(fUsePulserCalibration) {
00164     // Note: we use the LED number to set the Task in the DB call.
00165     // This allows us to use different LEDs for the calibration if we desire.
00166 
00167     for(int iled=0;iled<kMaxLeds;iled++) {
00168       fDriftPtr[iled].NewQuery(context,fPulserLed[iled]);
00169       if(fDriftPtr[iled].GetNumRows()==0) {
00170         MAXMSG("Calib",Msg::kWarning,10) 
00171           << "No rows in PULSERTIMEDRIFT task " << fPulserLed[iled] << " with validity context "
00172           << context.AsString() << endl;
00173         IncrementErrors(kTimeCalibrator,kMissingTable);
00174       }
00175 
00176       
00177       fDriftRefPtr[iled].NewQuery(refContext,fPulserLed[iled]);
00178       if(fDriftRefPtr[iled].GetNumRows()==0) {
00179         MAXMSG("Calib",Msg::kWarning,10) 
00180           << "No rows in PULSERTIMEDRIFT task " << fPulserLed[iled] << " with reference context "
00181           << refContext.AsString() << endl;
00182         IncrementErrors(kTimeCalibrator,kMissingTable);
00183       }
00184       
00185     }
00186 
00187     // Time card and reference.
00188 
00189     fTimingCardResPtr.NewQuery(context,0);
00190     if(fTimingCardResPtr.GetNumRows()==0) {
00191       MAXMSG("Calib",Msg::kWarning,10) 
00192         << "No rows in PULSERTIMINGCARDSETTING with validity context "
00193         << context.AsString() << endl;
00194       IncrementErrors(kTimeCalibrator,kMissingTable);
00195     }
00196 
00197     fTimingCardReferencePtr.NewQuery(refContext,0);
00198     if(fTimingCardReferencePtr.GetNumRows()==0) {
00199       MAXMSG("Calib",Msg::kWarning,10) 
00200         << "No rows in PULSERTIMINGCARDSETTING with reference context "
00201         << refContext.AsString() << endl;
00202       IncrementErrors(kTimeCalibrator,kMissingTable);
00203     }
00204 
00205   }
00206 }

DoubleErr PulserTimeCalScheme::GetCalibratedTime ( DoubleErr  rawtime,
FloatErr  rawcharge,
const PlexStripEndId seid 
) const [virtual]

Purpose: Apply time calibration

In: raw time in seconds raw charge strip end

Out: calibrated time.

Must be implimented by: TimeCalibrator

Reimplemented from CalScheme.

Definition at line 209 of file PulserTimeCalScheme.cxx.

References CalibrateByJumps(), CalibrateByMuon(), CalibrateByPulser(), CalibrateShield(), fDoWalkCorrection, fUseJumps, fUseMuonCalibration, fUsePulserCalibration, fUseShieldCalibration, CalScheme::GetContext(), DataUtil::GetDetector(), PlexHandle::GetRawChannelId(), PlexPlaneId::IsVetoShield(), Detector::kFar, and WalkCorrection().

00212 {
00224 
00225   // Find raw channel.
00226   DoubleErr time = rawtime;
00227 
00228   if(seid.IsVetoShield()) {
00229 
00230     // Shield hits:
00231     if(fUseShieldCalibration) time = CalibrateShield(time,rawcharge,seid,true);     
00232   } else {
00233 
00234     // Non-shield hits:
00235 
00236     if(GetContext().GetDetector()==Detector::kFar) {
00237       PlexHandle plex(GetContext());
00238       RawChannelId rcid = plex.GetRawChannelId(seid);
00239       if(fUseJumps)             time = CalibrateByJumps(time,rcid,true);
00240       if(fUsePulserCalibration) time = CalibrateByPulser(time,rcid,true);
00241     }
00242     if(fUseMuonCalibration)   time = CalibrateByMuon(time,seid,true);
00243     if(fDoWalkCorrection)     time-= WalkCorrection(rawcharge,seid);
00244   }
00245 
00246   return time;
00247 }

Bool_t PulserTimeCalScheme::GetPulserCalibration ( Int_t  iled,
UInt_t  index,
const PulserTimeDrift *&  drift,
const PulserTimeDrift *&  ref 
) const [private]

Definition at line 433 of file PulserTimeCalScheme.cxx.

References fDriftPtr, fDriftRefPtr, PulserTimeDrift::GetEntries(), PulserTimeDrift::GetRms(), and DbiResultPtr< T >::GetRowByIndex().

Referenced by CalibrateByPulser().

00436 {
00437   // Retrieve rows from the DB. Return true if the rows exist and
00438   // are good, false if they are bad.
00439 
00440   drift = fDriftPtr[iled].GetRowByIndex(index);
00441   ref   = fDriftRefPtr[iled].GetRowByIndex(index);
00442 
00443   // Do they exist?
00444   if(drift==0) return false;
00445   if(ref==0) return false;
00446 
00447   // Are the means valid to a good precision?
00448   // Error limit: 0.2 ticks.
00449   // So, want to fail if RMS/Entries > 0.2 ticks
00450   // Rearrange to get below:
00451   // (The clever bit here is that this automatically checks for entries==0)
00452 
00453   if( drift->GetRms() >= sqrt(drift->GetEntries())*0.2 ) return false;
00454   if(   ref->GetRms() >= sqrt(  ref->GetEntries())*0.2 ) return false;
00455 
00456 
00457   return true;
00458 }

void PulserTimeCalScheme::PrintConfig ( std::ostream &  os  )  const [virtual]

Reimplemented from CalScheme.

Definition at line 96 of file PulserTimeCalScheme.cxx.

References VldTimeStamp::AsString(), fDoWalkCorrection, fMuonTask, fMuonTaskND, fPulserLed, fReferenceTime, fUseJumps, fUseMuonCalibration, fUsePulserCalibration, fUseShieldCalibration, and kMaxLeds.

00097 {
00098   char taskname[100];
00099   if     ( fMuonTask==0 ) sprintf(taskname,"Brians");
00100   else if( fMuonTask==1 ) sprintf(taskname,"Andys");
00101   else if( fMuonTask==2 ) {  
00102      if( fMuonTaskND==0 ) sprintf(taskname,"Dogwood");
00103      else                 sprintf(taskname,"DogwoodToF"); }
00104   else                    sprintf(taskname,"Unknown");
00105 
00106   os << "  UseMuonCalibration:   " << ((fUseMuonCalibration)?("On"):("Off")) << endl;
00107   os << "  MuonTask:             " << taskname << endl;
00108   os << "  UseShieldCalibration: " << ((fUseShieldCalibration)?("On"):("Off")) << endl;
00109   os << "  UseJumps:             " << ((fUseJumps)?("On"):("Off")) << endl;
00110   // os << "  JumpTask:             " << fJumpTask << endl;
00111   os << "  UsePulserCalibration: " << ((fUsePulserCalibration)?("On"):("Off")) << endl;  
00112   os << "  DoWalkCorrection:     " << ((fDoWalkCorrection)?("On"):("Off")) << endl;  
00113   os << "  Reference date:       " << fReferenceTime.AsString() << endl;
00114   os << "  PulserLeds to use:    ";
00115   for(int i=0;i<kMaxLeds;i++) {
00116     os << fPulserLed[i];
00117     if(i!=kMaxLeds-1) os << ",";
00118   }
00119   os << endl;
00120     
00121 }

DoubleErr PulserTimeCalScheme::WalkCorrection ( FloatErr  rawcharge,
const PlexStripEndId seid 
) const [private]

Return the walk correction. Low charges result in slowly-rising pulse shapes, This function should return large numbers (~2 ns) at small charges, and 0 for high charge.

Definition at line 463 of file PulserTimeCalScheme.cxx.

References Munits::c_light, CalScheme::GetContext(), DataUtil::GetDetector(), Detector::kFar, and SimFlag::kMC.

Referenced by CalibrateShield(), DecalTime(), and GetCalibratedTime().

00465 {
00471 
00472   // These are Andy's paramaterisations for the FD, hard-coded for now.
00473   if(GetContext().GetDetector()==Detector::kFar) {
00474 
00475     const float kParData[4] = {  5.44066e+00,
00476                               -5.94887e-01,
00477                               -7.36609e-02,
00478                               7.66637e-03 };
00479 
00480     const float kParMC[4] = { 4.18608e+00,
00481                               -3.75033e-01,
00482                               -9.50218e-02,
00483                               9.52560e-03 };
00484     
00485     const float* par = kParData;
00486     if(GetContext().GetSimFlag()==SimFlag::kMC) par = kParMC;
00487       
00488     if(rawcharge<=0) rawcharge = 1; // Be careful.
00489     double cx = log(rawcharge()/2.3);
00490     double walk = (
00491                    par[0]
00492                    + (par[1] * cx)
00493                    + (par[2] * cx *cx)
00494                    + (par[3] * cx * cx *cx) 
00495                    );
00496     // These parameters are in units of meters, so convert to time:
00497     return walk / Munits::c_light; // Fixme: does not paramaterize error.
00498       
00499   }
00500 
00501   return 0;
00502 }


Member Data Documentation

Definition at line 47 of file PulserTimeCalScheme.h.

Referenced by CalibrateByPulser(), and ConfigModified().

Definition at line 59 of file PulserTimeCalScheme.h.

Referenced by DoReset(), and GetPulserCalibration().

Definition at line 60 of file PulserTimeCalScheme.h.

Referenced by DoReset(), and GetPulserCalibration().

Definition at line 56 of file PulserTimeCalScheme.h.

Referenced by CalibrateByJumps(), and DoReset().

Definition at line 43 of file PulserTimeCalScheme.h.

Definition at line 52 of file PulserTimeCalScheme.h.

Referenced by CalibrateByMuon(), and DoReset().

Definition at line 39 of file PulserTimeCalScheme.h.

Referenced by ConfigModified(), DoReset(), and PrintConfig().

Definition at line 40 of file PulserTimeCalScheme.h.

Referenced by ConfigModified(), DoReset(), and PrintConfig().

Definition at line 48 of file PulserTimeCalScheme.h.

Definition at line 46 of file PulserTimeCalScheme.h.

Referenced by CalibrateByPulser(), ConfigModified(), DoReset(), and PrintConfig().

Definition at line 49 of file PulserTimeCalScheme.h.

Referenced by ConfigModified(), DoReset(), and PrintConfig().

Definition at line 53 of file PulserTimeCalScheme.h.

Referenced by CalibrateShield(), and DoReset().

Definition at line 64 of file PulserTimeCalScheme.h.

Referenced by CalibrateByPulser(), and DoReset().

Definition at line 63 of file PulserTimeCalScheme.h.

Referenced by CalibrateByPulser(), and DoReset().


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

Generated on 13 Sep 2017 for loon by  doxygen 1.6.1