Calibrator Class Reference

#include <Calibrator.h>

Inheritance diagram for Calibrator:
PlexCalib CalScheme CfgPromptConfigurable

List of all members.

Classes

struct  Cleaner

Public Member Functions

CalSchemeGetTimeCalibrator ()
CalSchemeGetPeCalibrator ()
CalSchemeGetVALinCalibrator ()
CalSchemeGetDriftCalibrator ()
CalSchemeGetLinCalibrator ()
CalSchemeGetStripCalibrator ()
CalSchemeGetAttenCalibrator ()
CalSchemeGetMIPCalibrator ()
CalSchemeGetThermometer ()
PlexSEIdAltLItem CalibStripEnd (const PlexStripEndId &seid, const PlexPixelSpotId &spotid, Int_t adc, Double_t time) const
FloatErr GetAttenCorrectedTpos (FloatErr sigcorr, FloatErr lpos, const PlexStripEndId &seid) const
FloatErr DecalAttenCorrectedTpos (FloatErr sigcorr, FloatErr lpos, const PlexStripEndId &seid) const
Float_t GetTemperature (Int_t mode=0) const
DoubleErr GetTimeFromTDC (Int_t tdc, const RawChannelId &rcid) const
Int_t GetTDCFromTime (Double_t time, const RawChannelId &rcid) const
Double_t GetTDCConvert (const RawChannelId &) const
DoubleErr GetCalibratedTime (DoubleErr rawtime, FloatErr charge, const PlexStripEndId &seid) const
FloatErr GetPhotoElectrons (FloatErr rawcharge, const PlexStripEndId &seid) const
FloatErr GetLinearizedVA (FloatErr rawcharge, const RawChannelId &rcid) const
FloatErr GetDriftCorrected (FloatErr rawcharge, const PlexStripEndId &seid) const
FloatErr GetLinearized (FloatErr sigdrift, const PlexStripEndId &seid) const
FloatErr GetStripToStripCorrected (FloatErr siglin, const PlexStripEndId &seid) const
FloatErr GetAttenCorrected (FloatErr sigcorr, FloatErr stripX, const PlexStripEndId &seid) const
FloatErr GetMIP (FloatErr sigmap, const PlexStripEndId &seid=PlexStripEndId()) const
DoubleErr DecalTime (DoubleErr caltime, FloatErr charge, const PlexStripEndId &seid) const
void DecalGainAndWidth (FloatErr &gain, FloatErr &width, const PlexStripEndId &seid) const
void DecalGainAndWidth (FloatErr &gain, FloatErr &width, const PlexPixelSpotId &psid) const
FloatErr DecalVALinearity (FloatErr adc, const RawChannelId &rcid) const
FloatErr DecalDrift (FloatErr undrifted, const PlexStripEndId &seid) const
FloatErr DecalLinearity (FloatErr lin, const PlexStripEndId &seid) const
FloatErr DecalStripToStrip (FloatErr sigcorr, const PlexStripEndId &seid) const
FloatErr DecalAttenCorrected (FloatErr sigmap, FloatErr stripX, const PlexStripEndId &seid) const
FloatErr DecalMIP (FloatErr sigmip, const PlexStripEndId &seid=PlexStripEndId()) const
void ReInitialise (const VldContext &vldc)
const RegistryGetCompleteConfiguration () const
void SetLogLevel (Int_t lvl)
void PrintConfig (std::ostream &os) const
 ~Calibrator ()
void ResetEventStats ()
void ResetHistograms ()
void PrintEventStats () const
DoubleErr GetEventTotal (CalScheme::SchemeType_t type) const
DoubleErr GetEventCalls (CalScheme::SchemeType_t type) const
void DrawHistograms ()
TH1 * GetFracErrorHist (CalScheme::SchemeType_t type)
TH1 * GetErrorHist (CalScheme::SchemeType_t type)

Static Public Member Functions

static CalibratorInstance ()
static CalSchemeTimeCalibrator ()
static CalSchemePeCalibrator ()
static CalSchemeVALinCalibrator ()
static CalSchemeDriftCalibrator ()
static CalSchemeLinCalibrator ()
static CalSchemeStripCalibrator ()
static CalSchemeAttenCalibrator ()
static CalSchemeMIPCalibrator ()
static CalSchemeThermometer ()
static CalibratorCreateCustomCalibrator ()

Public Attributes

DoubleErr fEventTotal [CalScheme::kNumberOfSchemeTypes]
Double_t fEventCalls [CalScheme::kNumberOfSchemeTypes]
TH1 * fFracErrorHist [CalScheme::kNumberOfSchemeTypes]
TH1 * fErrorHist [CalScheme::kNumberOfSchemeTypes]

Protected Member Functions

 Calibrator ()
void DoReset (const VldContext &context)
void ConfigModified ()
void SetScheme (CalScheme *&scheme, const char *name)
void ConfigScheme (const char *masterRegKey, CalScheme *scheme)

Private Member Functions

 Calibrator (const Calibrator &)
void operator= (const Calibrator &)

Private Attributes

CalSchemefTimeCalibrator
CalSchemefPeCalibrator
CalSchemefVALinCalibrator
CalSchemefDriftCalibrator
CalSchemefLinCalibrator
CalSchemefStripCalibrator
CalSchemefAttenCalibrator
CalSchemefMIPCalibrator
CalSchemefThermometer
Int_t fCalibratorIsDirty [CalScheme::kNumberOfSchemeTypes]

Static Private Attributes

static CalibratorfgInstance = 0

Friends

struct Cleaner

Detailed Description

Definition at line 32 of file Calibrator.h.


Constructor & Destructor Documentation

Calibrator::~Calibrator (  ) 

Definition at line 1037 of file Calibrator.cxx.

References fAttenCalibrator, fDriftCalibrator, fErrorHist, fFracErrorHist, fLinCalibrator, fMIPCalibrator, fPeCalibrator, fStripCalibrator, fThermometer, fTimeCalibrator, fVALinCalibrator, CalScheme::kNumberOfSchemeTypes, and CalScheme::PrintErrorStats().

01038 { 
01039   cout << endl << "Calibrator shutting down." << endl;
01040   PrintErrorStats();
01041   if(fTimeCalibrator)  delete fTimeCalibrator;   fTimeCalibrator = 0;
01042   if(fPeCalibrator)    delete fPeCalibrator;     fPeCalibrator = 0;
01043   if(fVALinCalibrator) delete fVALinCalibrator;  fVALinCalibrator = 0;
01044   if(fDriftCalibrator) delete fDriftCalibrator;  fDriftCalibrator= 0;
01045   if(fLinCalibrator)   delete fLinCalibrator;    fLinCalibrator = 0;
01046   if(fStripCalibrator) delete fStripCalibrator;  fStripCalibrator = 0;
01047   if(fAttenCalibrator) delete fAttenCalibrator;  fAttenCalibrator = 0;
01048   if(fMIPCalibrator)   delete fMIPCalibrator;    fMIPCalibrator = 0;
01049   if(fThermometer)     delete fThermometer;      fThermometer = 0;
01050 
01051   for(int i=0; i<CalScheme::kNumberOfSchemeTypes; i++) {
01052     if(fErrorHist[i])     delete fErrorHist[i];
01053     if(fFracErrorHist[i]) delete fFracErrorHist[i];
01054   }
01055 }

Calibrator::Calibrator (  )  [protected]

Definition at line 988 of file Calibrator.cxx.

References fCalibratorIsDirty, fErrorHist, fFracErrorHist, CfgPromptConfigurable::InitializeConfig(), CalScheme::kNumberOfSchemeTypes, ResetEventStats(), ResetHistograms(), and Registry::Set().

Referenced by Instance().

00988                        :
00989   fTimeCalibrator(0), 
00990   fPeCalibrator(0),
00991   fVALinCalibrator(0),
00992   fDriftCalibrator(0),
00993   fLinCalibrator(0),
00994   fStripCalibrator(0),
00995   fAttenCalibrator(0),
00996   fMIPCalibrator(0),
00997   fThermometer(0)
00998 {
00999   // Use this to define global default. 
01000   //Load this from a file, like the AlgConfigs?
01001   Registry r;
01002   r.SetName("Calibrator");
01003   r.Set("TimeCalibrator", "PulserTimeCalScheme");
01004   r.Set("PeCalibrator",   "PEGainAggCalScheme");
01005   r.Set("VALinCalibrator","VaLinearityCalScheme");
01006   r.Set("DriftCalibrator","MuonDriftCalScheme");
01007   r.Set("LinCalibrator",  "PulserLinearityCalScheme");
01008   r.Set("StripCalibrator","StripToStripCalScheme");
01009   r.Set("AttenCalibrator","StripAttenCalScheme");
01010   r.Set("MIPCalibrator",  "MIPCalScheme");
01011   r.Set("Thermometer",    "TemperatureCalScheme");
01012 
01013   r.Set("TimeCalibratorConfig",Registry());
01014   r.Set("PeCalibratorConfig",Registry());
01015   r.Set("VALinCalibratorConfig",Registry());
01016   r.Set("DriftCalibratorConfig",Registry());
01017   r.Set("LinCalibratorConfig",Registry());
01018   r.Set("StripCalibratorConfig",Registry());
01019   r.Set("AttenCalibratorConfig",Registry());
01020   r.Set("MIPCalibratorConfig",Registry());
01021   r.Set("ThermometerConfig",Registry());
01022   InitializeConfig(r);
01023   
01024   for(int i=0;i<kNumberOfSchemeTypes; i++) {
01025     fCalibratorIsDirty[i]=1;
01026     fFracErrorHist[i] = 0;
01027     fErrorHist[i] = 0;
01028   }
01029 
01030   ResetEventStats();
01031   ResetHistograms();
01032 }

Calibrator::Calibrator ( const Calibrator  )  [private]

Member Function Documentation

static CalScheme& Calibrator::AttenCalibrator (  )  [inline, static]

Definition at line 45 of file Calibrator.h.

References GetAttenCalibrator(), and Instance().

00045 { return Instance().GetAttenCalibrator(); };

PlexSEIdAltLItem Calibrator::CalibStripEnd ( const PlexStripEndId seid,
const PlexPixelSpotId spotid,
Int_t  adc,
Double_t  time 
) const [virtual]

Implimentation of PlexCalib::CalibStripEnd()

Purpose: Called by the DigitListModule by way of the Plex. Calibrates a a given possible strip end alternative.

Input: strip end id pixel spot id raw adc (pedestal-subtracted) raw time (in seconds)

Output: a calibrated PlexSEIdAltLItem

Implements PlexCalib.

Definition at line 45 of file Calibrator.cxx.

References GetCalibratedTime(), GetDriftCorrected(), GetLinearized(), GetPhotoElectrons(), GetStripToStripCorrected(), Msg::kVerbose, and MSG.

00048 {
00062 
00063   MSG("Calib", Msg::kVerbose)
00064       << "Calibrator::CalibStripEnd" << endl;
00065   FloatErr seidWeight=0;                       //Will be set by the Plex
00066   FloatErr seidPE = this->GetPhotoElectrons(adc, seid);
00067   FloatErr seidSigLin = this->GetLinearized(adc, seid);
00068   FloatErr seidSigDrift = this->GetDriftCorrected(seidSigLin, seid);
00069   FloatErr seidSigCorr = this->GetStripToStripCorrected(seidSigDrift, seid);
00070   DoubleErr seidTime = this->GetCalibratedTime(rawtime, adc, seid);
00071   
00072   MSG("Calib", Msg::kVerbose)
00073     << seid  << "   ADC: "
00074     << adc << " PE: " << seidPE << " SigLin: " << seidSigLin
00075     << " SigCor: " << seidSigCorr << endl
00076     << " Time: " << rawtime << " TimeCor: " << seidTime << std::endl;
00077   
00078   // Used in debugging phase.
00079   //if((adc/seidPE)<10 ) MSG("Calib",Msg::kError) << "Abnormally high gain ( " << (adc/seidPE) << " adc/pe) returned for SEID " << seid.AsString() << endl;
00080   //if((adc/seidPE)>500) MSG("Calib",Msg::kError) << "Abnormally low  gain ( " << (adc/seidPE) << " adc/pe) returned for SEID " << seid.AsString() << endl;
00081 
00082   PlexSEIdAltLItem item(seid, spotid, seidWeight, seidPE, seidSigDrift,
00083                         seidSigCorr, seidTime);
00084   return item;  
00085 }

void Calibrator::ConfigModified ( void   )  [protected, virtual]

This routine actually sets everything up if the configuration has changed.

It creates each of the Calibrators (which are implimentations of the CalScheme class), pulls in their default config, and makes it jive with the current config.

Reimplemented from CalScheme.

Definition at line 874 of file Calibrator.cxx.

References ConfigScheme(), DoReset(), fAttenCalibrator, fDriftCalibrator, fLinCalibrator, fMIPCalibrator, fPeCalibrator, fStripCalibrator, fThermometer, fTimeCalibrator, fVALinCalibrator, Registry::GetCharString(), CfgPromptConfigurable::GetConfig(), CalScheme::GetContext(), and SetScheme().

00875 {
00884   
00885   const Registry& r = this->GetConfig();
00886   
00887   // First, create the Schema.
00888   SetScheme(fTimeCalibrator,   r.GetCharString("TimeCalibrator"));
00889   SetScheme(fPeCalibrator,     r.GetCharString("PeCalibrator"));
00890   SetScheme(fVALinCalibrator,  r.GetCharString("VALinCalibrator"));
00891   SetScheme(fDriftCalibrator,  r.GetCharString("DriftCalibrator"));
00892   SetScheme(fLinCalibrator,    r.GetCharString("LinCalibrator"));
00893   SetScheme(fStripCalibrator,  r.GetCharString("StripCalibrator"));
00894   SetScheme(fAttenCalibrator,  r.GetCharString("AttenCalibrator"));
00895   SetScheme(fMIPCalibrator,    r.GetCharString("MIPCalibrator"));
00896   SetScheme(fThermometer,      r.GetCharString("Thermometer"));
00897 
00898   // If we wanted to be good, we would now check that each scheme
00899   // implimented the routines we want. But that's a lot of work.
00900   
00901   // Now, merge in any configuration that we have.
00902   // The SubCalibrators hold the definative version of the configuration.
00903   // The main Calibrator object holds only _modifications_ to them.
00904 
00905   // Because of this, we now _delete_ any calibration we have after sending it on.
00906   ConfigScheme("TimeCalibratorConfig", fTimeCalibrator);
00907   ConfigScheme("PeCalibratorConfig",   fPeCalibrator);
00908   ConfigScheme("VALinCalibratorConfig",fVALinCalibrator);
00909   ConfigScheme("DriftCalibratorConfig",fDriftCalibrator);
00910   ConfigScheme("LinCalibratorConfig",  fLinCalibrator);
00911   ConfigScheme("StripCalibratorConfig",fStripCalibrator);
00912   ConfigScheme("AttenCalibratorConfig",fAttenCalibrator);
00913   ConfigScheme("MIPCalibratorConfig",  fMIPCalibrator); 
00914   ConfigScheme("ThermometerConfig",    fThermometer);
00915 
00916   // Make sure that all the calibrators have their contexts set:
00917   DoReset(GetContext());
00918 }

void Calibrator::ConfigScheme ( const char *  masterRegKey,
CalScheme scheme 
) [protected]

Copy the stuff in the Calibrator sub-registry to the sub-calibrator. Then, delete the stuff in the sub-registry since it has been applied.

Definition at line 965 of file Calibrator.cxx.

References CfgPromptConfigurable::GetConfig(), Registry::GetRegistry(), CfgPromptConfigurable::Set(), and Registry::Size().

Referenced by ConfigModified().

00966 {
00972 
00973   Registry rs = GetConfig().GetRegistry(masterRegKey);
00974 
00975   if(rs.Size()<=0) return;
00976   scheme->Set(rs);
00977   
00978   Registry blank;
00979   Set(masterRegKey,blank);
00980 }

Calibrator * Calibrator::CreateCustomCalibrator (  )  [static]

Definition at line 32 of file Calibrator.cxx.

References Msg::kWarning, and MSG.

Referenced by EnergyCorrections::CalibrationGroupEnergyCorrections().

00033 {
00034   MSG("Calib",Msg::kWarning) << "*  Some joker has just created a custom Calibrator object." << endl;
00035   MSG("Calib",Msg::kWarning) << "*  I'll do as I'm told, but doing this is usually not neccessary" << endl;
00036   MSG("Calib",Msg::kWarning) << "*  except for rare testing cases." << endl;
00037   MSG("Calib",Msg::kWarning) << "*  (Error/call statistics reporting will now be screwed up.)" << endl;
00038   return new Calibrator();
00039 }

FloatErr Calibrator::DecalAttenCorrected ( FloatErr  sigmap,
FloatErr  stripX,
const PlexStripEndId seid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Get atttenuation correction

Input: Light expected if energy deposited in middle of strip True position of hit along strip Strip end

Output: Light seen at end of WLS pigtail

Must be implimented by: AttenCalibrator

Calls the current fAttenCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 582 of file Calibrator.cxx.

References CalScheme::DecalAttenCorrected(), fAttenCalibrator, fCalibratorIsDirty, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kAttenCalibrator, and CalScheme::Reset().

Referenced by PhotonCalibratedBlueComputer::ComputePhotons(), PhotonCalibratedPeComputer::ComputePhotons(), DecalAttenCorrectedTpos(), PhotonCompositeGreenTracker::GreenPhotonToPe(), and PhotonInjector::SimulateEvent().

00583 {
00598   CalScheme::IncrementCalls(CalScheme::kAttenCalibrator);
00599   if(fCalibratorIsDirty[kAttenCalibrator]) {
00600     // Lazy context update.
00601     fAttenCalibrator->Reset(GetContext()); 
00602     fCalibratorIsDirty[kAttenCalibrator]=0;
00603   }
00604    
00605   return fAttenCalibrator->DecalAttenCorrected(sigmap,stripX,seid);      
00606 }

FloatErr Calibrator::DecalAttenCorrectedTpos ( FloatErr  sigcorr,
FloatErr  lpos,
const PlexStripEndId seid 
) const

Purpose: Gets SigCor Called by the Track, Shower, and Event algorithms.

Input: Charge on end seid. Position of hit in 'tpos' of neighboring plane (i.e. 'lpos'): transverse strip coordinate. Which strip end to calibrate.

Output: SigCorr

Notes: Guts are ripped from old StripCalibrator. Massage the "lpos" coordinate, which is a tpos-like, into a 'strip-X' coordinate, which is strip-centered.

Definition at line 140 of file Calibrator.cxx.

References DecalAttenCorrected(), CalScheme::GetContext(), DataUtil::GetDetector(), PlexPlaneId::GetPlaneView(), UgliGeomHandle::GetStripHandle(), UgliStripHandle::GlobalPos(), Detector::kNear, kU, PlaneView::kU, and kV.

00143 { 
00159 
00160   FloatErr stripX = 0.;
00161     
00162   // Caldet and Far are both symettric.
00163   if(GetContext().GetDetector()!=Detector::kNear) {
00164     if (seid.GetPlaneView()==PlaneView::kU) {
00165       stripX = -tpos;
00166     } else {
00167       stripX = tpos;
00168     }
00169     return DecalAttenCorrected(sigmap, stripX, seid); 
00170   }
00171 
00172   UgliGeomHandle ugli(GetContext());
00173   UgliStripHandle ustrip = ugli.GetStripHandle(seid);
00174   
00175   const double rsqrt2 = 1.0/sqrt(2.0);
00176   const TVector3 kU(rsqrt2,rsqrt2,0.);
00177   const TVector3 kV(-rsqrt2,rsqrt2,0.);
00178   
00179   if (seid.GetPlaneView()==PlaneView::kU) {
00180     float lambda = kV.Dot(ustrip.GlobalPos(0.));
00181     stripX = -tpos + lambda;
00182   } else {
00183     float lambda = kU.Dot(ustrip.GlobalPos(0.));
00184     stripX = tpos - lambda;
00185   }
00186   return DecalAttenCorrected(sigmap, stripX, seid); 
00187 }

FloatErr Calibrator::DecalDrift ( FloatErr  undrifted,
const PlexStripEndId seid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Get gain drift

Input: True gain of phototube in PEs, Strip end

Output: Drifted gain of phototube

Must be implimented by: DriftCalibrator

Calls the current fDriftCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 411 of file Calibrator.cxx.

References CalScheme::DecalDrift(), fCalibratorIsDirty, fDriftCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kDriftCalibrator, and CalScheme::Reset().

Referenced by PhotonCalibratedPeComputer::ComputePhotons(), and MeuPlots::DriftDecalTwice().

00412 {
00426   CalScheme::IncrementCalls(CalScheme::kDriftCalibrator);
00427   if(fCalibratorIsDirty[kDriftCalibrator]) {
00428     // Lazy context update.
00429     fDriftCalibrator->Reset(GetContext()); 
00430     fCalibratorIsDirty[kDriftCalibrator]=0;
00431   }
00432    
00433   return fDriftCalibrator->DecalDrift(undrifted,seid);
00434 }

void Calibrator::DecalGainAndWidth ( FloatErr gain,
FloatErr width,
const PlexPixelSpotId psid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Get PMT gain and width of single PE response

Input: Pixel spot id

Output: Gain and and width of 1-pe response in ADCs

Must be implimented by: PeCalibrator

Calls the current fPeCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 298 of file Calibrator.cxx.

References CalScheme::DecalGainAndWidth(), fCalibratorIsDirty, fPeCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kPeCalibrator, and CalScheme::Reset().

00300 {
00313   CalScheme::IncrementCalls(CalScheme::kPeCalibrator);
00314   if(fCalibratorIsDirty[kPeCalibrator]) {
00315     // Lazy context update.
00316     fPeCalibrator->Reset(GetContext()); 
00317     fCalibratorIsDirty[kPeCalibrator]=0;
00318   }
00319    
00320   fPeCalibrator->DecalGainAndWidth(gain,width,psid);
00321 }

void Calibrator::DecalGainAndWidth ( FloatErr gain,
FloatErr width,
const PlexStripEndId seid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Get PMT gain and width of single PE response

Input: Strip end

Output: Gain and and width of 1-pe response in ADCs

Must be implimented by: PeCalibrator

Calls the current fPeCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 274 of file Calibrator.cxx.

References CalScheme::DecalGainAndWidth(), fCalibratorIsDirty, fPeCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kPeCalibrator, and CalScheme::Reset().

Referenced by SimPmt::GetGainAndWidth().

00275 {
00288   CalScheme::IncrementCalls(CalScheme::kPeCalibrator);
00289   if(fCalibratorIsDirty[kPeCalibrator]) {
00290     // Lazy context update.
00291     fPeCalibrator->Reset(GetContext()); 
00292     fCalibratorIsDirty[kPeCalibrator]=0;
00293   }
00294    
00295   fPeCalibrator->DecalGainAndWidth(gain,width,seid);
00296 }

FloatErr Calibrator::DecalLinearity ( FloatErr  lin,
const PlexStripEndId seid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Apply nonlinearity function.

Input: Linear charge expected from a perfect phototube, Strip end

Output: Realistic charge after PMT and electronics nonlinearity

Must be implimented by: LinCalibrator

Calls the current fLinCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 467 of file Calibrator.cxx.

References CalScheme::DecalLinearity(), fCalibratorIsDirty, fLinCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kLinCalibrator, and CalScheme::Reset().

Referenced by SimVaElectronics::GenSimulatedADC(), SimQiePerfectElectronics::GenSimulatedADC(), and SimQieElectronics::GenSimulatedADC().

00468 {
00482   CalScheme::IncrementCalls(CalScheme::kLinCalibrator);
00483   if(fCalibratorIsDirty[kLinCalibrator]) {
00484     // Lazy context update.
00485     fLinCalibrator->Reset(GetContext()); 
00486     fCalibratorIsDirty[kLinCalibrator]=0;
00487   }
00488    
00489   return fLinCalibrator->DecalLinearity(lin,seid);  
00490 }

FloatErr Calibrator::DecalMIP ( FloatErr  sigmip,
const PlexStripEndId seid = PlexStripEndId() 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Get atttenuation correction

Input: True energy of hit in MIPs Strip end (may be ignored, depending on implimentation)

Output: SigMaps that this hit will result in.

Must be implimented by: MIPCalibrator

Calls the current fStripCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 641 of file Calibrator.cxx.

References CalScheme::DecalMIP(), fCalibratorIsDirty, fMIPCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kMIPCalibrator, and CalScheme::Reset().

Referenced by PhotonCalibratedBlueComputer::ComputePhotons(), and PhotonCalibratedPeComputer::ComputePhotons().

00642 {
00656   CalScheme::IncrementCalls(CalScheme::kMIPCalibrator);
00657   if(fCalibratorIsDirty[kMIPCalibrator]) {
00658     // Lazy context update.
00659     fMIPCalibrator->Reset(GetContext()); 
00660     fCalibratorIsDirty[kMIPCalibrator]=0;
00661   }
00662    
00663   return fMIPCalibrator->DecalMIP(sigmip,seid);     
00664 }

FloatErr Calibrator::DecalStripToStrip ( FloatErr  sigcorr,
const PlexStripEndId seid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Get strip-to-strip variation

Input: Charge expected from a perfect strip with a perfect phototube Strip end

Output: Charge expected from this strip, including PMT gain

Must be implimented by: StripCalibrator

Calls the current fStripCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 525 of file Calibrator.cxx.

References CalScheme::DecalStripToStrip(), fCalibratorIsDirty, fStripCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kStripCalibrator, and CalScheme::Reset().

Referenced by PhotonCalibratedBlueComputer::ComputePhotons(), PhotonCalibratedPeComputer::ComputePhotons(), NtpSRModule::FillNtpShower(), NtpSRModule::FillNtpTrack(), UberModule::FillNtpTrack(), and UberModuleLite::FillNtpTrack().

00526 {
00540   CalScheme::IncrementCalls(CalScheme::kStripCalibrator);
00541   if(fCalibratorIsDirty[kStripCalibrator]) {
00542     // Lazy context update.
00543     fStripCalibrator->Reset(GetContext()); 
00544     fCalibratorIsDirty[kStripCalibrator]=0;
00545   }
00546    
00547   return fStripCalibrator->DecalStripToStrip(sigcorr,seid);    
00548 }

DoubleErr Calibrator::DecalTime ( DoubleErr  caltime,
FloatErr  charge,
const PlexStripEndId seid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Go from calibrated time to raw time

Input: True time Strip end

Output: Raw, uncalibrated time.

Calls the current fTimeCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 219 of file Calibrator.cxx.

References CalScheme::DecalTime(), fCalibratorIsDirty, fTimeCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kTimeCalibrator, and CalScheme::Reset().

Referenced by NtpSRModule::FillNtpShower(), NtpSRModule::FillNtpTrack(), UberModule::FillNtpTrack(), and UberModuleLite::FillNtpTrack().

00220 {
00232   CalScheme::IncrementCalls(CalScheme::kTimeCalibrator);
00233   if(fCalibratorIsDirty[kTimeCalibrator]) {
00234     // Lazy context update.
00235     fTimeCalibrator->Reset(GetContext()); 
00236     fCalibratorIsDirty[kTimeCalibrator]=0;
00237   }
00238    
00239   return fTimeCalibrator->DecalTime(caltime,charge,seid);
00240 }     

FloatErr Calibrator::DecalVALinearity ( FloatErr  adc,
const RawChannelId rcid 
) const [virtual]

Inverse-calibration for use by Monte-Carlo

Purpose: Apply VA nonlinearity

Input: linear charge channel ID

Output: nonlinear charge

Must be implimented by: VALinCalibrator

Reimplemented from CalScheme.

Definition at line 354 of file Calibrator.cxx.

References CalScheme::DecalVALinearity(), fCalibratorIsDirty, fVALinCalibrator, CalScheme::GetContext(), CalScheme::IncrementCalls(), CalScheme::kVALinCalibrator, and CalScheme::Reset().

00355 {
00368   CalScheme::IncrementCalls(CalScheme::kVALinCalibrator);
00369   if(fCalibratorIsDirty[kVALinCalibrator]) {
00370     // Lazy context update.
00371     fVALinCalibrator->Reset(GetContext()); 
00372     fCalibratorIsDirty[kVALinCalibrator]=0;
00373   }
00374    
00375   return fVALinCalibrator->DecalVALinearity(adc,rcid);
00376 }

void Calibrator::DoReset ( const VldContext context  )  [protected, virtual]

Resets the current context to update all calibrators and all database tables.

Reimplemented from CalScheme.

Definition at line 779 of file Calibrator.cxx.

References fCalibratorIsDirty, and CalScheme::kNumberOfSchemeTypes.

Referenced by ConfigModified().

00780 {
00785   for(int i=0;i<kNumberOfSchemeTypes; i++) {
00786     fCalibratorIsDirty[i]=1;
00787   }
00788 }

void Calibrator::DrawHistograms (  ) 

Definition at line 1128 of file Calibrator.cxx.

References fErrorHist, fFracErrorHist, CalScheme::kAttenCalibrator, CalScheme::kDriftCalibrator, CalScheme::kLinCalibrator, CalScheme::kMIPCalibrator, CalScheme::kPeCalibrator, CalScheme::kStripCalibrator, CalScheme::kTimeCalibrator, and CalScheme::kVALinCalibrator.

01129 {
01130   static TCanvas* sCanvas1 = 0;
01131   if(!sCanvas1) sCanvas1 = new TCanvas("calCanvas1","Calibrator Summary 1");
01132   sCanvas1->cd();
01133   sCanvas1->Divide(2,4,0,0,kWhite);
01134 
01135   static TCanvas* sCanvas2 = 0;
01136   if(!sCanvas2) sCanvas2 = new TCanvas("calCanvas2","Calibrator Summary 2");
01137   sCanvas2->cd();
01138   sCanvas2->Divide(2,4,0,0,kWhite);
01139 
01140   int ipad = 0;
01141   int types[] = { CalScheme::kTimeCalibrator,
01142                   CalScheme::kVALinCalibrator,
01143                   CalScheme::kPeCalibrator,
01144                   CalScheme::kLinCalibrator,
01145                   CalScheme::kDriftCalibrator,
01146                   CalScheme::kStripCalibrator,
01147                   CalScheme::kAttenCalibrator,
01148                   CalScheme::kMIPCalibrator };
01149 
01150   for(int itype=0; itype<8; itype++) {
01151     int type = types[itype];
01152 
01153     ipad++;
01154     sCanvas1->cd(ipad);    
01155     fErrorHist[type]->Draw();
01156     sCanvas2->cd(ipad);    
01157     fFracErrorHist[type]->Draw();    
01158   }
01159 }

static CalScheme& Calibrator::DriftCalibrator (  )  [inline, static]
CalScheme& Calibrator::GetAttenCalibrator (  )  [inline]

Definition at line 55 of file Calibrator.h.

References fAttenCalibrator.

Referenced by AttenCalibrator(), and MinosCompactEvent::MinosCompactEvent().

00055 { return *fAttenCalibrator; };

FloatErr Calibrator::GetAttenCorrected ( FloatErr  sigcorr,
FloatErr  stripX,
const PlexStripEndId seid 
) const [virtual]

Purpose: Correct for attenuation along strip.

In: sigcorr, position along strip (in strip coordinates: 0 is center of strip.) strip end

Out: position-corrected charge (SigMap)

Must be implimented by: AttenCalibrator

Calls the current fAttenCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 553 of file Calibrator.cxx.

References fAttenCalibrator, fCalibratorIsDirty, fErrorHist, fEventCalls, fEventTotal, fFracErrorHist, CalScheme::GetAttenCorrected(), CalScheme::GetContext(), ValueErr< T >::GetError(), ValueErr< T >::GetFracError(), ValueErr< T >::GetValue(), CalScheme::IncrementCalls(), CalScheme::kAttenCalibrator, and CalScheme::Reset().

Referenced by NtpMaker::FillFitTrackInfo(), NtpMaker::FillShowerInfo(), NtpMaker::FillStripInfo(), NtpMaker::FillTrackInfo(), Anp::FillMuonId::Get(), GetAttenCorrectedTpos(), AlgFarDetEvent::GetShower(), MinosCompactEvent::MinosCompactEvent(), and Anp::FillShortVar::OtherStripEnergy().

00554 {
00567   CalScheme::IncrementCalls(CalScheme::kAttenCalibrator);
00568   if(fCalibratorIsDirty[kAttenCalibrator]) {
00569     // Lazy context update.
00570     fAttenCalibrator->Reset(GetContext()); 
00571     fCalibratorIsDirty[kAttenCalibrator]=0;
00572   }
00573    
00574   FloatErr result = fAttenCalibrator->GetAttenCorrected(sigcorr,stripX,seid);     
00575   fEventTotal[CalScheme::kAttenCalibrator]+= DoubleErr(result.GetValue(),result.GetError());
00576   fEventCalls[CalScheme::kAttenCalibrator]++;
00577   fErrorHist[CalScheme::kAttenCalibrator]    ->Fill(result.GetError());
00578   fFracErrorHist[CalScheme::kAttenCalibrator]->Fill(result.GetFracError());
00579   return result;
00580 }

FloatErr Calibrator::GetAttenCorrectedTpos ( FloatErr  sigcorr,
FloatErr  lpos,
const PlexStripEndId seid 
) const

Purpose: Gets SigMap Called by the Track, Shower, and Event algorithms.

Input: Charge on end seid. Position of hit in 'tpos' of neighboring plane (i.e. 'lpos'): transverse strip coordinate. Which strip end to calibrate.

Output: SigMap

Notes: Guts are ripped from old StripCalibrator. Massage the "lpos" coordinate, which is a tpos-like, into a 'strip-X' coordinate, which is strip-centered.

Definition at line 90 of file Calibrator.cxx.

References GetAttenCorrected(), CalScheme::GetContext(), DataUtil::GetDetector(), PlexPlaneId::GetPlaneView(), UgliGeomHandle::GetStripHandle(), UgliStripHandle::GlobalPos(), Detector::kNear, kU, PlaneView::kU, and kV.

Referenced by MeuPlots::CalAttenSyst(), AlgShowerCam::CalculateShowerEnergy(), AlgReco::Calibrate(), Anp::FillShortVar::OtherStripEnergy(), MeuAnalysis::Recalibrate(), MeuAnalysis::RecalibrateAtNu(), AlgTrackAtNu::RunAlg(), and AlgShowerAtNu::RunAlg().

00093 { 
00109 
00110   FloatErr stripX = 0.;
00111 
00112   // Caldet and Far are both symettric.
00113   if(GetContext().GetDetector()!=Detector::kNear) {
00114     if (seid.GetPlaneView()==PlaneView::kU) {
00115       stripX = -tpos;
00116     } else {
00117       stripX = tpos;
00118     }
00119     return GetAttenCorrected(sigcorr, stripX, seid);
00120   }
00121 
00122   UgliGeomHandle ugli(GetContext());
00123   UgliStripHandle ustrip = ugli.GetStripHandle(seid);
00124   
00125   const double rsqrt2 = 1.0/sqrt(2.0);
00126   const TVector3 kU(rsqrt2,rsqrt2,0.);
00127   const TVector3 kV(-rsqrt2,rsqrt2,0.);
00128   
00129   if (seid.GetPlaneView()==PlaneView::kU) {
00130     float lambda = kV.Dot(ustrip.GlobalPos(0.));
00131     stripX = -tpos + lambda;
00132   } else {
00133     float lambda = kU.Dot(ustrip.GlobalPos(0.));
00134     stripX = tpos - lambda;
00135   }
00136   return GetAttenCorrected(sigcorr, stripX, seid);
00137 }

DoubleErr Calibrator::GetCalibratedTime ( DoubleErr  rawtime,
FloatErr  charge,
const PlexStripEndId seid 
) const [virtual]

Purpose: Apply time calibration

In: raw time in seconds strip end

Out: calibrated time.

Calls the current fTimeCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 193 of file Calibrator.cxx.

References fCalibratorIsDirty, fErrorHist, fEventCalls, fEventTotal, fFracErrorHist, fTimeCalibrator, CalScheme::GetCalibratedTime(), CalScheme::GetContext(), ValueErr< T >::GetError(), ValueErr< T >::GetFracError(), CalScheme::IncrementCalls(), CalScheme::kTimeCalibrator, and CalScheme::Reset().

Referenced by CalibStripEnd(), and NtpSRModule::FillNtpShieldStrip().

00194 {
00205   CalScheme::IncrementCalls(CalScheme::kTimeCalibrator);
00206   if(fCalibratorIsDirty[kTimeCalibrator]) {
00207     // Lazy context update.
00208     fTimeCalibrator->Reset(GetContext()); 
00209     fCalibratorIsDirty[kTimeCalibrator]=0;
00210   }
00211   DoubleErr result = fTimeCalibrator->GetCalibratedTime(rawtime,charge,seid);
00212   fEventTotal[CalScheme::kTimeCalibrator] += result;
00213   fEventCalls[CalScheme::kTimeCalibrator]++;
00214   fErrorHist[CalScheme::kTimeCalibrator]    ->Fill(result.GetError());
00215   fFracErrorHist[CalScheme::kTimeCalibrator]->Fill(result.GetFracError());
00216   return result;
00217 }

const Registry & Calibrator::GetCompleteConfiguration (  )  const

Returns an amalgam of the complete configuration of the entire calibration scheme at present.

This can be re-applied to the current calibrator using Calibrator::Instance().Set()

Definition at line 800 of file Calibrator.cxx.

References fAttenCalibrator, fDriftCalibrator, fLinCalibrator, fMIPCalibrator, fPeCalibrator, fStripCalibrator, fThermometer, fTimeCalibrator, fVALinCalibrator, CfgPromptConfigurable::GetConfig(), and Registry::Set().

00801 {
00809 
00810   static Registry r;
00811   r = GetConfig();
00812   r.Set("TimeCalibratorConfig",  fTimeCalibrator ->GetConfig());
00813   r.Set("PeCalibratorConfig",    fPeCalibrator   ->GetConfig());
00814   r.Set("VALinCalibratorConfig", fVALinCalibrator->GetConfig());
00815   r.Set("DriftCalibratorConfig", fDriftCalibrator->GetConfig());
00816   r.Set("LinCalibratorConfig",   fLinCalibrator  ->GetConfig());
00817   r.Set("StripCalibratorConfig", fStripCalibrator->GetConfig());
00818   r.Set("AttenCalibratorConfig", fAttenCalibrator->GetConfig());
00819   r.Set("MIPCalibratorConfig",   fMIPCalibrator  ->GetConfig());
00820   r.Set("ThermometerConfig",     fThermometer  ->GetConfig());
00821   return r;
00822 }

CalScheme& Calibrator::GetDriftCalibrator (  )  [inline]

Definition at line 52 of file Calibrator.h.

References fDriftCalibrator.

Referenced by DriftCalibrator(), and CDAnalysis::SetRootFileObjects().

00052 { return *fDriftCalibrator; };

FloatErr Calibrator::GetDriftCorrected ( FloatErr  rawcharge,
const PlexStripEndId seid 
) const [virtual]
TH1* Calibrator::GetErrorHist ( CalScheme::SchemeType_t  type  )  [inline]

Definition at line 167 of file Calibrator.h.

References fErrorHist.

00167 { return fErrorHist[(int)type]; };

DoubleErr Calibrator::GetEventCalls ( CalScheme::SchemeType_t  type  )  const [inline]

Definition at line 163 of file Calibrator.h.

References fEventCalls.

00163 { return fEventCalls[(int)type]; };

DoubleErr Calibrator::GetEventTotal ( CalScheme::SchemeType_t  type  )  const [inline]

Definition at line 162 of file Calibrator.h.

References fEventTotal.

00162 { return fEventTotal[(int)type]; };

TH1* Calibrator::GetFracErrorHist ( CalScheme::SchemeType_t  type  )  [inline]

Definition at line 166 of file Calibrator.h.

References fFracErrorHist.

00166 { return fFracErrorHist[(int)type]; };

CalScheme& Calibrator::GetLinCalibrator (  )  [inline]

Definition at line 53 of file Calibrator.h.

References fLinCalibrator.

Referenced by LinCalibrator(), and LIAnalysis::WriteGainsTextFile().

00053 { return *fLinCalibrator; };

FloatErr Calibrator::GetLinearized ( FloatErr  sigdrift,
const PlexStripEndId seid 
) const [virtual]

Purpose: Apply linearity correction

In: drifted-corrected or raw ADC, strip end

Out: linearized adc (siglin)

Must be implimented by: LinCalibrator

Calls the current fStripCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 439 of file Calibrator.cxx.

References fCalibratorIsDirty, fErrorHist, fEventCalls, fEventTotal, fFracErrorHist, fLinCalibrator, CalScheme::GetContext(), ValueErr< T >::GetError(), ValueErr< T >::GetFracError(), CalScheme::GetLinearized(), ValueErr< T >::GetValue(), CalScheme::IncrementCalls(), CalScheme::kLinCalibrator, and CalScheme::Reset().

Referenced by CalibStripEnd(), MeuAnalysis::Recalibrate(), MeuAnalysis::RecalibrateAtNu(), and LIAnalysis::WriteGainsTextFile().

00440 {
00452   CalScheme::IncrementCalls(CalScheme::kLinCalibrator);
00453   if(fCalibratorIsDirty[kLinCalibrator]) {
00454     // Lazy context update.
00455     fLinCalibrator->Reset(GetContext()); 
00456     fCalibratorIsDirty[kLinCalibrator]=0;
00457   }
00458 
00459   FloatErr result = fLinCalibrator->GetLinearized(sigdrift,seid);  
00460   fEventTotal[CalScheme::kLinCalibrator]+= DoubleErr(result.GetValue(),result.GetError());
00461   fEventCalls[CalScheme::kLinCalibrator]++;
00462   fErrorHist[CalScheme::kLinCalibrator]    ->Fill(result.GetError());
00463   fFracErrorHist[CalScheme::kLinCalibrator]->Fill(result.GetFracError());
00464   return result;
00465 }

FloatErr Calibrator::GetLinearizedVA ( FloatErr  rawcharge,
const RawChannelId rcid 
) const [virtual]

Purpose: Linearize a VA channel to charge injection data. Usually applies only to pin diodes

In: raw adc raw channel ID

Out: number of pes.

Must be implimented by: VALinCalibrator

Reimplemented from CalScheme.

Definition at line 325 of file Calibrator.cxx.

References fCalibratorIsDirty, fErrorHist, fEventCalls, fEventTotal, fFracErrorHist, fVALinCalibrator, CalScheme::GetContext(), ValueErr< T >::GetError(), ValueErr< T >::GetFracError(), CalScheme::GetLinearizedVA(), ValueErr< T >::GetValue(), CalScheme::IncrementCalls(), CalScheme::kVALinCalibrator, and CalScheme::Reset().

00326 {
00338  
00339   CalScheme::IncrementCalls(CalScheme::kVALinCalibrator);
00340   if(fCalibratorIsDirty[kVALinCalibrator]) {
00341     // Lazy context update.
00342     fVALinCalibrator->Reset(GetContext()); 
00343     fCalibratorIsDirty[kVALinCalibrator]=0;
00344   }
00345    
00346   FloatErr result = fVALinCalibrator->GetLinearizedVA(rawcharge,rcid);
00347   fEventTotal[CalScheme::kVALinCalibrator]+= DoubleErr(result.GetValue(),result.GetError());
00348   fEventCalls[CalScheme::kVALinCalibrator]++;
00349   fErrorHist[CalScheme::kVALinCalibrator]    ->Fill(result.GetError());
00350   fFracErrorHist[CalScheme::kVALinCalibrator]->Fill(result.GetFracError());
00351   return result;
00352 }

FloatErr Calibrator::GetMIP ( FloatErr  sigmap,
const PlexStripEndId seid = PlexStripEndId() 
) const [virtual]

Purpose: Convert from corrected charge to energy units. MIPs are usually defined as the the light seen from a muon going in the Z-direction through the center of the strip (i.e. ~2 MeV of muon energy)

In: sigcorr or sigmap Strip end (May be ignored, depending upon implimentation)

Out: energy in MIPs

Must be implimented by: MIPCalibrator

Calls the current fStripCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 611 of file Calibrator.cxx.

References fCalibratorIsDirty, fErrorHist, fEventCalls, fEventTotal, fFracErrorHist, fMIPCalibrator, CalScheme::GetContext(), ValueErr< T >::GetError(), ValueErr< T >::GetFracError(), CalScheme::GetMIP(), ValueErr< T >::GetValue(), CalScheme::IncrementCalls(), CalScheme::kMIPCalibrator, and CalScheme::Reset().

Referenced by AlgEventSSList::AddStripToEvent(), UberDST::Ana(), AlgSubShowerSR::CalculateEnergyVertexAngle(), AlgShowerCam::CalculateShowerEnergy(), AlgReco::Calibrate(), AlgSubShowerSRList::CleanUp(), NtpMaker::FillFitTrackInfo(), NtpMaker::FillShowerInfo(), NtpMaker::FillStripInfo(), NtpMaker::FillTrackInfo(), AlgSubShowerSRList::FindCluster(), Anp::FillMuonId::Get(), CDTrackedHits::GetCCStripInfo(), AlgFarDetEvent::GetShower(), CDTrackedHits::GetTrackedStripInfo(), CDUnidentifiedHits::GetUnidentifiedStripInfo(), CDCrossTalker::GetXTalkStripInfo(), Anp::FillShortVar::OtherStripEnergy(), UberModule::Reco(), UberModuleLite::Reco(), AlgTrackAtNu::RunAlg(), AlgShowerAtNu::RunAlg(), AlgSubShowerSRList::RunAlg(), AlgShowerEM::RunAlg(), and FitterEM::SetUpStripInfo().

00612 {
00626   CalScheme::IncrementCalls(CalScheme::kMIPCalibrator);
00627   if(fCalibratorIsDirty[kMIPCalibrator]) {
00628     // Lazy context update.
00629     fMIPCalibrator->Reset(GetContext()); 
00630     fCalibratorIsDirty[kMIPCalibrator]=0;
00631   }
00632    
00633   FloatErr result = fMIPCalibrator->GetMIP(sigmap,seid);     
00634   fEventTotal[CalScheme::kMIPCalibrator]+= DoubleErr(result.GetValue(),result.GetError());
00635   fEventCalls[CalScheme::kMIPCalibrator]++;
00636   fErrorHist[CalScheme::kMIPCalibrator]    ->Fill(result.GetError());
00637   fFracErrorHist[CalScheme::kMIPCalibrator]->Fill(result.GetFracError());
00638   return result;
00639 }

CalScheme& Calibrator::GetMIPCalibrator (  )  [inline]

Definition at line 56 of file Calibrator.h.

References fMIPCalibrator.

Referenced by MIPCalibrator().

00056 { return *fMIPCalibrator; };

CalScheme& Calibrator::GetPeCalibrator (  )  [inline]

Definition at line 50 of file Calibrator.h.

References fPeCalibrator.

Referenced by PeCalibrator().

00050 { return *fPeCalibrator; };

FloatErr Calibrator::GetPhotoElectrons ( FloatErr  rawcharge,
const PlexStripEndId seid 
) const [virtual]
CalScheme& Calibrator::GetStripCalibrator (  )  [inline]

Definition at line 54 of file Calibrator.h.

References fStripCalibrator.

Referenced by StripCalibrator().

00054 { return *fStripCalibrator; };

FloatErr Calibrator::GetStripToStripCorrected ( FloatErr  siglin,
const PlexStripEndId seid 
) const [virtual]

Purpose: Apply strip-to-strip correction i.e. scintillator light output, PMT gain, and light loss By default, assumes hit is in center of strip.

In: linearized or raw adc (siglin) strip end

Out: corrected adc (sigcorr)

Must be implimented by: StripCalibrator

Calls the current fStripCalibrator to do the calibration.

Reimplemented from CalScheme.

Definition at line 495 of file Calibrator.cxx.

References fCalibratorIsDirty, fErrorHist, fEventCalls, fEventTotal, fFracErrorHist, fStripCalibrator, CalScheme::GetContext(), ValueErr< T >::GetError(), ValueErr< T >::GetFracError(), CalScheme::GetStripToStripCorrected(), ValueErr< T >::GetValue(), CalScheme::IncrementCalls(), CalScheme::kStripCalibrator, and CalScheme::Reset().

Referenced by CalibStripEnd(), MeuAnalysis::Recalibrate(), CDAnalysis::ReCalibrate(), MeuAnalysis::RecalibrateAtNu(), and MeuPlots::ugliClearFibre().

00496 {
00511   CalScheme::IncrementCalls(CalScheme::kStripCalibrator);
00512   if(fCalibratorIsDirty[kStripCalibrator]) {
00513     // Lazy context update.
00514     fStripCalibrator->Reset(GetContext()); 
00515     fCalibratorIsDirty[kStripCalibrator]=0;
00516   }
00517    
00518   FloatErr result = fStripCalibrator->GetStripToStripCorrected(siglin,seid);  
00519   fEventTotal[CalScheme::kStripCalibrator]+= DoubleErr(result.GetValue(),result.GetError());
00520   fEventCalls[CalScheme::kStripCalibrator]++;
00521   fErrorHist[CalScheme::kStripCalibrator]    ->Fill(result.GetError());
00522   fFracErrorHist[CalScheme::kStripCalibrator]->Fill(result.GetFracError());
00523   return result;
00524 }

Double_t Calibrator::GetTDCConvert ( const RawChannelId rcid  )  const

Definition at line 696 of file Calibrator.cxx.

References RawChannelId::GetDetector(), RawChannelId::GetElecType(), Detector::kCalDet, ElecType::kQIE, ElecType::kVA, Munits::ns, and tdc_convert.

Referenced by PulserTimeCalScheme::CalibrateByPulser(), GetTDCFromTime(), GetTimeFromTDC(), and SimQieClock::Reset().

00697 {
00698    // This code shamelessly lifted from AlgDigit.
00699   
00700   // Convert from 0.1*Munits:ns to standard Munits base time units (sec).
00701   Double_t tdc_convert = 0.1;   // REROOT, non-VA, non-QIE scale factor
00702   
00703   // Switch on type of readout electronics
00704   switch (rcid.GetElecType()) {
00705     
00706     // VA electronics, tick = 1.5625 ns (640MHz)
00707   case (ElecType::kVA):
00708     tdc_convert = 1.5625;
00709     break;
00710 
00711     // QIE electronics, tick = 18.832 ns (RF clock)
00712   case (ElecType::kQIE):
00713     tdc_convert =  1000./53.1;  // clock is 53.1MHz
00714     
00715     // CalDet has yet a different clock frequency
00716     if (rcid.GetDetector() == Detector::kCalDet)
00717       tdc_convert = 1.5625*16.0*58.0/77.0;
00718     break;
00719     
00720     // Use whatever value we started with
00721   default:
00722     break;
00723   }
00724   return tdc_convert * Munits::ns;
00725 }

Int_t Calibrator::GetTDCFromTime ( Double_t  time,
const RawChannelId rcid 
) const

Purpose: Convert from TDC ticks to nanoseconds. Does not calibrate.

In: raw time in TDC ticks raw channel id

Out: time in ns

Definition at line 751 of file Calibrator.cxx.

References GetTDCConvert().

Referenced by SimDetector::AdjustTimeWithinSec(), ChopModule::Ana(), DetSim::CalculateAddTDC(), SimVaElectronics::GenSimulatedTDC(), ChopHelper::GetChopHelp(), MnvRawDigitSuppression::Reco(), AlgChopListSharp2::RunAlg(), AlgChopListMitre::RunAlg(), AlgChopListSharp::RunAlg(), and AlgChopListGeneric::RunAlg().

00752 {
00761 
00762   // This code shamelessly lifted from AlgDigit.
00763   
00764   // Convert TDC counts to Double_t.  
00765   Double_t tdc = time / GetTDCConvert(rcid);
00766   
00767   //return (int)round(tdc);  // round() not available on IRIX
00768   return TMath::Nint(tdc);
00769 }

Float_t Calibrator::GetTemperature ( Int_t  mode = 0  )  const [virtual]

Request temperature at current vld context

Purpose: Get temperature

Input: User-defined.

Output: Temperature in degrees Celcius

Must be implimented by: Thermometer

Reimplemented from CalScheme.

Definition at line 670 of file Calibrator.cxx.

References fCalibratorIsDirty, fThermometer, CalScheme::GetContext(), CalScheme::GetTemperature(), CalScheme::IncrementCalls(), CalScheme::kThermometer, and CalScheme::Reset().

Referenced by CDTrackerModule::Ana(), PhotonStatSummarizer::FillTrees(), StripToStripCalScheme::GetTemperatureCorrection(), PulserDriftCalScheme::GetVATemperatureCorrection(), PulserSigLinCalScheme::GetVATemperatureCorrection(), CDAnalysis::ReCalibrate(), and CDAnalysis::StoppingMuonCalibration().

00671 {
00683   CalScheme::IncrementCalls(CalScheme::kThermometer);
00684   if(fCalibratorIsDirty[kThermometer]) {
00685     // Lazy context update.
00686     fThermometer->Reset(GetContext()); 
00687     fCalibratorIsDirty[kThermometer]=0;
00688   }
00689    
00690   return fThermometer->GetTemperature(mode);
00691 }

CalScheme& Calibrator::GetThermometer (  )  [inline]

Definition at line 57 of file Calibrator.h.

References fThermometer.

Referenced by Thermometer().

00057 { return *fThermometer; };

CalScheme& Calibrator::GetTimeCalibrator (  )  [inline]

Definition at line 49 of file Calibrator.h.

References fTimeCalibrator.

Referenced by TimeCalibrator().

00049 { return *fTimeCalibrator; };

DoubleErr Calibrator::GetTimeFromTDC ( Int_t  tdc,
const RawChannelId rcid 
) const

Purpose: Convert from TDC ticks to nanoseconds. Does not calibrate.

In: raw time in TDC ticks raw channel id

Out: time in ns

Definition at line 727 of file Calibrator.cxx.

References GetTDCConvert().

Referenced by EvtAddRawDigitBlockModule::Ana(), NoiseFilterModule::Ana(), SimDigit::ComputeTime(), NtpSRModule::FillNtpEventSummary(), EvtOverlaySingleton::GetCrateT0s(), BiggestChopModule::Reco(), MergeEvent::Reco(), AlgMCDigit::RunAlg(), AlgCaldetDigit::RunAlg(), AlgDigit::RunAlg(), and AlgDIConvert::RunAlg().

00728 {
00737   
00738   // Convert TDC counts to Double_t.  
00739 
00740   DoubleErr tdc_and_err(tdc,1.0);
00741 
00742   // Flag error on FD:
00743   //if(rcid.GetElecType==ElecType::kVA)
00744   //  if( (tdc & 0x1F) == 0x08 )  tdc_and_err.SetError(8.);
00745 
00746   DoubleErr t = tdc_and_err * GetTDCConvert(rcid);
00747   
00748   return t;
00749 }

CalScheme& Calibrator::GetVALinCalibrator (  )  [inline]

Definition at line 51 of file Calibrator.h.

References fVALinCalibrator.

Referenced by VALinCalibrator().

00051 { return *fVALinCalibrator; };

Calibrator & Calibrator::Instance (  )  [inline, static]

Instance() returns the singleton handle.

Definition at line 184 of file Calibrator.h.

References Calibrator(), fgInstance, CalScheme::ResetStatistics(), and Calibrator::Cleaner::UseMe().

Referenced by AlgEventSSList::AddStripToEvent(), SimDetector::AdjustTimeWithinSec(), UberDST::Ana(), NtpMaker::Ana(), NoiseFilterModule::Ana(), EvtAddRawDigitBlockModule::Ana(), DatabaseToucher::Ana(), ChopModule::Ana(), CDTrackerModule::Ana(), atmo_set_calibrator(), AttenCalibrator(), MeuPlots::CalAttenSyst(), DetSim::CalculateAddTDC(), AlgSubShowerSR::CalculateEnergyVertexAngle(), AlgShowerCam::CalculateShowerEnergy(), AlgReco::Calibrate(), PulserTimeCalScheme::CalibrateByPulser(), AlgSubShowerSRList::CleanUp(), PhotonCalibratedPeComputer::ComputePhotons(), PhotonCalibratedBlueComputer::ComputePhotons(), SimDigit::ComputeTime(), MeuPlots::DriftCalibrate(), DriftCalibrator(), MeuPlots::DriftDecalTwice(), far_mc_set_calibrator(), far_set_calibrator(), NtpMaker::FillFitTrackInfo(), NtpSRModule::FillNtpEventSummary(), NtpSRModule::FillNtpShieldStrip(), NtpSRModule::FillNtpShower(), UberModuleLite::FillNtpTrack(), UberModule::FillNtpTrack(), NtpSRModule::FillNtpTrack(), NtpMaker::FillShowerInfo(), NtpMaker::FillStripInfo(), NtpMaker::FillTrackInfo(), PhotonStatSummarizer::FillTrees(), AlgSubShowerSRList::FindCluster(), SimVaElectronics::GenSimulatedADC(), SimQiePerfectElectronics::GenSimulatedADC(), SimQieElectronics::GenSimulatedADC(), SimVaElectronics::GenSimulatedTDC(), PhotonTransport::Get(), PhotonInjector::Get(), Anp::FillMuonId::Get(), DigitListModule::Get(), DetSim::Get(), CDTrackedHits::GetCCStripInfo(), ChopHelper::GetChopHelp(), CDCrossTalker::GetCleanStripMap(), SimPmt::GetGainAndWidth(), AlgFarDetEvent::GetShower(), StripToStripCalScheme::GetTemperatureCorrection(), CDTrackedHits::GetTrackedStripInfo(), CDUnidentifiedHits::GetUnidentifiedStripInfo(), PulserSigLinCalScheme::GetVATemperatureCorrection(), PulserDriftCalScheme::GetVATemperatureCorrection(), CDCrossTalker::GetXTalkStripInfo(), PhotonCompositeGreenTracker::GreenPhotonToPe(), LinCalibrator(), load_better_mipcal(), main(), MinosCompactEvent::MinosCompactEvent(), MIPCalibrator(), near_mc_set_calibrator(), near_set_calibrator(), Anp::FillShortVar::OtherStripEnergy(), PeCalibrator(), pmt_plot(), MeuAnalysis::Recalibrate(), CDAnalysis::ReCalibrate(), MeuAnalysis::RecalibrateAtNu(), UberModuleLite::Reco(), UberModule::Reco(), TrackSRListModule::Reco(), ShowerSRListModule::Reco(), ShowerEMListModule::Reco(), NtpSRModule::Reco(), MnvRawDigitSuppression::Reco(), MergeEvent::Reco(), EventSRListModule::Reco(), BiggestChopModule::Reco(), SimQieClock::Reset(), AlgTrackCam::RunAlg(), AlgTrackAtNu::RunAlg(), AlgSubShowerSRList::RunAlg(), AlgShowerEM::RunAlg(), AlgShowerCam::RunAlg(), AlgShowerAtNu::RunAlg(), AlgPassThru::RunAlg(), AlgMCDigit::RunAlg(), AlgFarDetEvent::RunAlg(), AlgDigit::RunAlg(), AlgDIConvert::RunAlg(), AlgChopListSharp2::RunAlg(), AlgChopListSharp::RunAlg(), AlgChopListMitre::RunAlg(), AlgChopListGeneric::RunAlg(), AlgCaldetDigit::RunAlg(), set_calibrator_far(), set_calibrator_far_mc(), set_calibrator_near(), set_calibrator_near_mc(), SetCalibrator(), SetLogLevel(), AlgFitTrackCam::SetPropertiesFromFinderTrack(), CDAnalysis::SetRootFileObjects(), AlgFitTrackCam::SetTrackProperties(), FitterEM::SetUpStripInfo(), PhotonInjector::SimulateEvent(), CDAnalysis::StoppingMuonCalibration(), StripCalibrator(), Thermometer(), TimeCalibrator(), MeuPlots::ugliClearFibre(), VALinCalibrator(), and LIAnalysis::WriteGainsTextFile().

00185 {
00189   
00190   // Cleaner destructor calls DigitCalibrator dtor
00191   static Cleaner cleaner;
00192   
00193   // Calibrator mode "1" the default.  This is hardwired for now.
00194   if (!fgInstance) {
00195     cleaner.UseMe();           // dummy call to quiet compiler warnings
00196     fgInstance = new Calibrator();
00197     if(!fgInstance){
00198       cout << "No DigitCalibrator Instance - fatal." << endl;
00199       assert(fgInstance);               // Kill job is there is no instance
00200     }
00201     CalScheme::ResetStatistics();
00202   }
00203   
00204   return *fgInstance;
00205 }

static CalScheme& Calibrator::LinCalibrator (  )  [inline, static]

Definition at line 43 of file Calibrator.h.

References GetLinCalibrator(), and Instance().

00043 { return Instance().GetLinCalibrator(); };

static CalScheme& Calibrator::MIPCalibrator (  )  [inline, static]

Definition at line 46 of file Calibrator.h.

References GetMIPCalibrator(), and Instance().

00046 { return Instance().GetMIPCalibrator(); };

void Calibrator::operator= ( const Calibrator  )  [private]
static CalScheme& Calibrator::PeCalibrator (  )  [inline, static]

Definition at line 40 of file Calibrator.h.

References GetPeCalibrator(), and Instance().

00040 { return Instance().GetPeCalibrator(); };

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

Reimplemented from CalScheme.

Definition at line 824 of file Calibrator.cxx.

References fAttenCalibrator, fDriftCalibrator, fLinCalibrator, fMIPCalibrator, fPeCalibrator, fStripCalibrator, fThermometer, fTimeCalibrator, fVALinCalibrator, Registry::GetCharString(), CfgPromptConfigurable::GetConfig(), and CalScheme::PrintConfig().

Referenced by MeuAnalysis::RecalibrateAtNu(), and CDAnalysis::SetRootFileObjects().

00825 {
00826   // Printout of current configuration.
00827   os << endl;
00828   os << "-----------------------------------------------------" << endl;
00829   os << "TimeCalibrator:  " << GetConfig().GetCharString("TimeCalibrator") << endl;
00830   fTimeCalibrator->PrintConfig(os);
00831 
00832   os << endl;
00833   os << "-----------------------------------------------------" << endl;
00834   os << "PeCalibrator:    " << GetConfig().GetCharString("PeCalibrator") << endl;
00835   fPeCalibrator->PrintConfig(os);
00836 
00837   os << endl;
00838   os << "-----------------------------------------------------" << endl;
00839   os << "VALinCalibrator: " << GetConfig().GetCharString("VALinCalibrator") << endl;
00840   fVALinCalibrator->PrintConfig(os);
00841 
00842   os << endl;
00843   os << "-----------------------------------------------------" << endl;
00844   os << "DriftCalibrator: " << GetConfig().GetCharString("DriftCalibrator") << endl;
00845   fDriftCalibrator->PrintConfig(os);
00846 
00847   os << endl;
00848   os << "-----------------------------------------------------" << endl;
00849   os << "LinCalibrator:   " << GetConfig().GetCharString("LinCalibrator") << endl;
00850   fLinCalibrator->PrintConfig(os);
00851   
00852   os << endl;
00853   os << "-----------------------------------------------------" << endl;
00854   os << "StripCalibrator: " << GetConfig().GetCharString("StripCalibrator") << endl;
00855   fStripCalibrator->PrintConfig(os);
00856 
00857   os << endl;
00858   os << "-----------------------------------------------------" << endl;
00859   os << "AttenCalibrator: " << GetConfig().GetCharString("AttenCalibrator") << endl;
00860   fAttenCalibrator->PrintConfig(os);
00861 
00862   os << endl;
00863   os << "-----------------------------------------------------" << endl;
00864   os << "MIPCalibrator:   " << GetConfig().GetCharString("MIPCalibrator") << endl;
00865   fMIPCalibrator->PrintConfig(os);
00866 
00867   os << endl;
00868   os << "-----------------------------------------------------" << endl;
00869   os << "Thermometer:     " << GetConfig().GetCharString("Thermometer") << endl;
00870   fThermometer->PrintConfig(os);
00871 }

void Calibrator::PrintEventStats (  )  const

Definition at line 1104 of file Calibrator.cxx.

References fEventCalls, fEventTotal, Form(), Msg::kInfo, CalScheme::kNumberOfSchemeTypes, CalScheme::kUnknown, MSG, CalScheme::SchemeTypeName(), and CalScheme::UnitName().

01105 {
01106   MSG("Calib",Msg::kInfo) << "Event statistics: ----------------------" << endl;
01107   
01108   for(int i=0; i<CalScheme::kNumberOfSchemeTypes; i++) {
01109     if(i==CalScheme::kUnknown) continue;
01110     else {
01111       MSG("Calib",Msg::kInfo) << Form("%16s | Total %8s: %10.1f +- %8.1f   Mean %8s: %6.1f +- %6.1f", 
01112                                       CalScheme::SchemeTypeName(i),
01113                                       CalScheme::UnitName(i),
01114                                       fEventTotal[i].GetValue(),
01115                                       fEventTotal[i].GetError(),
01116                                       CalScheme::UnitName(i),
01117                                       (fEventCalls[i]>0) ? 
01118                                         (fEventTotal[i]/fEventCalls[i]).GetValue()  : -1
01119                                       ,
01120                                       (fEventCalls[i]>0) ? 
01121                                          (fEventTotal[i]/fEventCalls[i]).GetError() : -1                                      
01122                                       )
01123                               << endl;
01124     }
01125   }
01126 }

void Calibrator::ReInitialise ( const VldContext vldc  )  [inline]
void Calibrator::ResetEventStats (  ) 

Definition at line 1058 of file Calibrator.cxx.

References fEventCalls, fEventTotal, CalScheme::kNumberOfSchemeTypes, and ValueErr< T >::Set().

Referenced by Calibrator().

01059 {
01060   for(int i=0; i<CalScheme::kNumberOfSchemeTypes; i++) {
01061     fEventTotal[i].Set(0,0);
01062     fEventCalls[i] = 0;
01063   }
01064 }

void Calibrator::ResetHistograms (  ) 

Rebuild histograms.

Definition at line 1066 of file Calibrator.cxx.

References fErrorHist, fFracErrorHist, Form(), CalScheme::kNumberOfSchemeTypes, CalScheme::kTimeCalibrator, Munits::ns, CalScheme::SchemeTypeName(), and CalScheme::UnitName().

Referenced by Calibrator().

01067 {
01071   for(int i=0; i<CalScheme::kNumberOfSchemeTypes; i++) {
01072    
01073     if(fErrorHist[i]) {
01074       fErrorHist[i]->Reset();
01075     } else {
01076       if(i==CalScheme::kTimeCalibrator) 
01077         fErrorHist[i] = new TH1F(Form("hError_%s",SchemeTypeName(i)),
01078                                  Form("Error, %s",SchemeTypeName(i)),
01079                                  500,0,100.*Munits::ns);
01080       else
01081         fErrorHist[i] = new TH1F(Form("hError_%s",SchemeTypeName(i)),
01082                                  Form("Error, %s",SchemeTypeName(i)),
01083                                  500,0,1e4);
01084       
01085       fErrorHist[i] -> SetXTitle(Form("Error per calibration (%s)",CalScheme::UnitName(i)));
01086       fErrorHist[i] -> SetYTitle("Number of calibrations");
01087     }
01088     fErrorHist[i] -> SetDirectory(0); // Make sure it's only memory-resident.
01089     
01090     if(fFracErrorHist[i]) {
01091       delete fFracErrorHist[i];
01092     } else {
01093       fFracErrorHist[i] = new TH1F(Form("hFracError_%s",SchemeTypeName(i)),
01094                                    Form("Fractional Error, %s",SchemeTypeName(i)),
01095                                    20,0,1.0);
01096       fFracErrorHist[i] -> SetXTitle("Fractional error");
01097       fFracErrorHist[i] -> SetYTitle("Number of calibrations");    
01098     }
01099     fFracErrorHist[i] -> SetDirectory(0); // Make sure it's only memory-resident.
01100     
01101   }
01102 }

void Calibrator::SetLogLevel ( Int_t  lvl  ) 

Definition at line 795 of file Calibrator.cxx.

References Instance(), and SetLogLevel().

Referenced by SetLogLevel().

00796 {
00797   MsgService::Instance()->GetStream("Calib")->SetLogLevel((Msg::LogLevel_t)lvl);
00798 }

void Calibrator::SetScheme ( CalScheme *&  scheme,
const char *  name 
) [protected]

Definition at line 921 of file Calibrator.cxx.

References Msg::kError, and MSG.

Referenced by ConfigModified().

00922 {
00923   if(scheme) {
00924     // object exists. Is it the right kind?
00925     if(strcmp(scheme->GetName(),name)==0) {
00926       // It is. Do nothing.
00927       return;
00928     }
00929   }
00930   
00931   // Make a new one.
00932   CalScheme* newscheme = 0;
00933   assert(gROOT);
00934 
00935   TClass* theclass = gROOT->GetClass(name);
00936   if(!theclass) {
00937     MSG("Calib",Msg::kError) << "Calibrator: Unable to find requested Scheme: " << name << endl;
00938   } else {
00939     void* p = theclass->New();
00940     TObject* obj = (TObject*) p;
00941     newscheme = dynamic_cast<CalScheme*>(obj);
00942     if(!newscheme) {
00943       MSG("Calib",Msg::kError) << "Calibrator: " << name << " is not a CalScheme!" << endl;
00944     }
00945   }
00946   
00947   if(!newscheme) {
00948     if(!scheme) {
00949       MSG("Calib",Msg::kError) << " Cannot generate calibration scheme " << name 
00950                                     << " so I have to die! Sorry! ";
00951       assert(0);
00952     } else {
00953       MSG("Calib",Msg::kError) << " Cannot generate calibration scheme " << name 
00954                                     << " so I'll keep the old one: " << scheme->GetName() << endl;
00955       return;
00956     }
00957   }
00958 
00959   // All is well. Make the sucker.
00960   if(scheme) delete scheme;
00961   scheme = newscheme;
00962 }

static CalScheme& Calibrator::StripCalibrator (  )  [inline, static]

Definition at line 44 of file Calibrator.h.

References GetStripCalibrator(), and Instance().

Referenced by apply_spectrometer_fudge(), and SetCalibrator().

00044 { return Instance().GetStripCalibrator(); };

static CalScheme& Calibrator::Thermometer (  )  [inline, static]

Definition at line 47 of file Calibrator.h.

References GetThermometer(), and Instance().

00047 { return Instance().GetThermometer(); };

static CalScheme& Calibrator::TimeCalibrator (  )  [inline, static]

Definition at line 39 of file Calibrator.h.

References GetTimeCalibrator(), and Instance().

Referenced by atmo_set_calibrator(), far_set_calibrator(), and set_calibrator_far().

00039 { return Instance().GetTimeCalibrator(); };

static CalScheme& Calibrator::VALinCalibrator (  )  [inline, static]

Definition at line 41 of file Calibrator.h.

References GetVALinCalibrator(), and Instance().

00041 { return Instance().GetVALinCalibrator(); };


Friends And Related Function Documentation

friend struct Cleaner [friend]

Definition at line 143 of file Calibrator.h.


Member Data Documentation

Int_t Calibrator::fCalibratorIsDirty[CalScheme::kNumberOfSchemeTypes] [mutable, private]
TH1* Calibrator::fErrorHist[CalScheme::kNumberOfSchemeTypes] [mutable]
Double_t Calibrator::fEventCalls[CalScheme::kNumberOfSchemeTypes] [mutable]
DoubleErr Calibrator::fEventTotal[CalScheme::kNumberOfSchemeTypes] [mutable]
TH1* Calibrator::fFracErrorHist[CalScheme::kNumberOfSchemeTypes] [mutable]
Calibrator * Calibrator::fgInstance = 0 [static, private]

Definition at line 144 of file Calibrator.h.

Referenced by Instance(), and Calibrator::Cleaner::~Cleaner().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1