Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SimpleCalScheme.cxx

Go to the documentation of this file.
00001 #include "SimpleCalScheme.h"
00002 #include "MessageService/MsgService.h"
00003 #include "UgliGeometry/UgliGeomHandle.h"
00004 
00005 CVSID("$Id: SimpleCalScheme.cxx,v 1.15 2007/03/01 17:35:34 rhatcher Exp $");
00006 ClassImp(SimpleCalScheme)
00007 
00008 
00009 SimpleCalScheme::SimpleCalScheme()
00010 {
00016 
00017   // Defaults:
00018   Registry r;
00019   r.SetName(this->GetName());
00020   r.Set("defaultGainFD",60.0);
00021   r.Set("defaultGainND",100.0);
00022   r.Set("defaultDrift",1.0);
00023   r.Set("defaultLinearity",1.0);
00024   r.Set("defaultStripToStrip",1.0);
00025   r.Set("defaultAttenLength1",1.0);
00026   r.Set("defaultAttenLength2",7.0);
00027   r.Set("defaultAttenN1",0.3333);
00028   r.Set("defaultSigCorPerMip",750.);
00029   r.Set("defaultTemp",18.0);
00030   this->InitializeConfig(r);
00031 }
00032 
00033 SimpleCalScheme::~SimpleCalScheme()
00034 {}
00035   
00036 void SimpleCalScheme::ConfigModified()
00037 {
00044 
00045   // This bit of deathless code is nice because
00046   // it typo-checks your config to ensure that the stuff above
00047   // matches the stuff here.  If something is missing or is not the right
00048   // type, it prints a warning message.
00049   bool ok = true;
00050   ok = ok && GetConfig().Get("defaultGainFD",fDefaultGainFD);
00051   ok = ok && GetConfig().Get("defaultGainND",fDefaultGainND);
00052   ok = ok && GetConfig().Get("defaultDrift",fDefaultDrift);
00053   ok = ok && GetConfig().Get("defaultLinearity",fDefaultLinearity);
00054   ok = ok && GetConfig().Get("defaultStripToStrip",fDefaultStripToStrip);
00055   ok = ok && GetConfig().Get("defaultAttenLength1",fDefaultAttenLength1);
00056   ok = ok && GetConfig().Get("defaultAttenLength2",fDefaultAttenLength2);
00057   ok = ok && GetConfig().Get("defaultAttenN1",fDefaultAttenN1);
00058   ok = ok && GetConfig().Get("defaultSigCorPerMip",fDefaultSigCorPerMip);
00059   ok = ok && GetConfig().Get("defaultTemp",fDefaultTemp);
00060   if(!ok) MSG("Calib",Msg::kError) << "Problem configuring SimpleCalScheme. Something's missing." << endl;
00061 }
00062 
00063 
00064 
00065 void SimpleCalScheme::DoReset( const VldContext& context )
00066 {
00072 
00073   // People who recognize this example are obviously fellow victims of a liberal education.
00074   // --Nathaniel
00075 
00076   const char* grue;
00077 
00078   if(context.GetTimeStamp()>VldTimeStamp(2000,1,1,0,0,0,0)) grue = "blue";
00079   else grue="green";
00080 }
00081 
00084 // Calibration methods
00087 
00088 DoubleErr  SimpleCalScheme::GetCalibratedTime(DoubleErr rawtime,      
00089                                              FloatErr ,
00090                                              const PlexStripEndId&) const
00091 {
00101  
00102   return rawtime + DoubleErr(0,50*Munits::ns);
00103 }
00104   
00105 FloatErr   SimpleCalScheme::GetPhotoElectrons(FloatErr rawcharge, 
00106                                              const PlexStripEndId&) const
00107 {
00118 
00119   // Should really look up in the plex to see what kind of channel it is.
00120   FloatErr res(rawcharge,rawcharge); // 100% error.
00121 
00122   if(GetContext().GetDetector()==Detector::kNear) {
00123     return res/=fDefaultGainND;
00124   }
00125   
00126   return res/=fDefaultGainFD;
00127 }
00128 
00129 FloatErr  SimpleCalScheme::GetLinearizedVA(FloatErr rawcharge, const RawChannelId&  ) const
00130 {
00142  
00143   return FloatErr(rawcharge,rawcharge);
00144 }
00145 
00146 
00147 FloatErr   SimpleCalScheme::GetDriftCorrected(FloatErr rawcharge, 
00148                                              const PlexStripEndId& ) const
00149 {
00160   FloatErr result = rawcharge/(float)fDefaultDrift;
00161   result.SetError(result.GetValue()); // 100% error;
00162   return result;
00163 }
00164 
00165 FloatErr   SimpleCalScheme::GetLinearized(FloatErr sigdrift,      
00166                                           const PlexStripEndId&) const
00167 {
00178   FloatErr result = sigdrift/(float)fDefaultLinearity;
00179   result.SetError(result.GetValue()); // 100% error;
00180   return result;
00181 }
00182 
00183 
00184 FloatErr   SimpleCalScheme::GetStripToStripCorrected(FloatErr siglin,           
00185                                                     const PlexStripEndId&) const
00186 {
00200   float result = siglin/(float)fDefaultStripToStrip;
00201   return FloatErr(result,result);
00202 }
00203 
00204 FloatErr   SimpleCalScheme::GetAttenCorrected(FloatErr sigcorr, 
00205                                              FloatErr stripX, 
00206                                              const PlexStripEndId& seid) const
00207 {
00219   UgliGeomHandle ugli(GetContext());
00220   UgliStripHandle ustrip = ugli.GetStripHandle(seid);
00221 
00222   double halfgreen = ustrip.GetHalfLength() + ustrip.WlsPigtail(seid.GetEnd());
00223   double wlsLen = halfgreen;
00224   if(seid.GetEnd()==StripEnd::kPositive) wlsLen -= stripX;
00225   if(seid.GetEnd()==StripEnd::kNegative) wlsLen += stripX;
00226   // If not +ve or -ve, do nothing.
00227 
00228   // The correction is for the center of the strip to the new position
00229   // on the strip.
00230   
00231   float a = fDefaultAttenN1 * exp(-halfgreen/fDefaultAttenLength1)
00232     + (1.0 - fDefaultAttenN1)* exp(-halfgreen/fDefaultAttenLength2);
00233 
00234   float b = fDefaultAttenN1 * exp(-wlsLen/fDefaultAttenLength1)
00235     + (1.0 - fDefaultAttenN1)* exp(-wlsLen/fDefaultAttenLength2);
00236 
00237   if(b<=0) return FloatErr(sigcorr,sigcorr);
00238   return FloatErr(sigcorr * (a/b), sigcorr * (a/b));
00239 }
00240 
00241 FloatErr   SimpleCalScheme::GetMIP(FloatErr sigmap,     
00242                                   const PlexStripEndId&) const
00243 {
00256   float result = sigmap/(float)fDefaultSigCorPerMip;
00257   return FloatErr(result,result);
00258 }  
00259 
00262 // Decalibration methods
00265 
00266 
00267 DoubleErr  SimpleCalScheme::DecalTime(DoubleErr caltime,
00268                                      FloatErr ,
00269                                      const PlexStripEndId&) const
00270 {
00282   return caltime;
00283 }
00284 
00285 void      SimpleCalScheme::DecalGainAndWidth(FloatErr& gain,
00286                                              FloatErr& width,
00287                                              const PlexStripEndId&) const
00288 {
00300   if(GetContext().GetDetector()==Detector::kNear) {
00301     gain.Set(fDefaultGainND,fDefaultGainND);
00302     width.Set(fDefaultGainND* 0.5,fDefaultGainND* 0.5);
00303  } else {
00304     gain.Set(fDefaultGainFD);
00305     width.Set(fDefaultGainFD* 0.5,fDefaultGainFD* 0.5);
00306   }    
00307 }
00308 
00309 void      SimpleCalScheme::DecalGainAndWidth(FloatErr& gain,
00310                                              FloatErr& width,
00311                                              const PlexPixelSpotId& psid) const
00312 {
00324   if(psid.GetElecType()==ElecType::kQIE) {
00325     gain.Set(fDefaultGainND,fDefaultGainND);
00326     width.Set(fDefaultGainND* 0.5,fDefaultGainND* 0.5);
00327  } else {
00328     gain.Set(fDefaultGainFD);
00329     width.Set(fDefaultGainFD* 0.5,fDefaultGainFD* 0.5);
00330   }    
00331 }
00332 
00333 FloatErr SimpleCalScheme::DecalVALinearity(FloatErr lincharge, const RawChannelId& ) const
00334 {
00347   return lincharge;
00348 }
00349 
00350 FloatErr   SimpleCalScheme::DecalDrift(FloatErr undrifted,
00351                                       const PlexStripEndId&) const
00352 {
00365   float result = undrifted*(float)fDefaultDrift;
00366   return FloatErr(result,result);
00367 }
00368 
00369 FloatErr   SimpleCalScheme::DecalLinearity(FloatErr lin,
00370                                           const PlexStripEndId&) const
00371 {
00384   float result = lin*(float)fDefaultLinearity;
00385   return FloatErr(result,result);
00386 }
00387 
00388 FloatErr   SimpleCalScheme::DecalStripToStrip(FloatErr sigcorr,
00389                                              const PlexStripEndId&) const
00390 {
00403   float result = sigcorr*(float)fDefaultStripToStrip;
00404   return FloatErr(result,result);
00405 }
00406 
00407 FloatErr   SimpleCalScheme::DecalAttenCorrected(FloatErr sigmap,
00408                                                FloatErr stripX,
00409                                                const PlexStripEndId& seid) const
00410 {
00424   UgliGeomHandle ugli(GetContext());
00425   UgliStripHandle ustrip = ugli.GetStripHandle(seid);
00426 
00427   double halfgreen = ustrip.GetHalfLength() + ustrip.WlsPigtail(seid.GetEnd());
00428   double wlsLen = halfgreen;
00429   if(seid.GetEnd()==StripEnd::kPositive) wlsLen -= stripX;
00430   if(seid.GetEnd()==StripEnd::kNegative) wlsLen += stripX;
00431   // If not +ve or -ve, do nothing.
00432 
00433   // The correction is for the center of the strip to the new position
00434   // on the strip.
00435   
00436   float a = fDefaultAttenN1 * exp(-halfgreen/fDefaultAttenLength1)
00437     + (1.0 - fDefaultAttenN1)* exp(-halfgreen/fDefaultAttenLength2);
00438 
00439   float b = fDefaultAttenN1 * exp(-wlsLen/fDefaultAttenLength1)
00440     + (1.0 - fDefaultAttenN1)* exp(-wlsLen/fDefaultAttenLength2);
00441 
00442   if(a<=0) return FloatErr(sigmap,sigmap);
00443   return FloatErr(sigmap * (b/a),sigmap * (b/a));
00444 }
00445 
00446 FloatErr   SimpleCalScheme::DecalMIP(FloatErr sigmip,
00447                                     const PlexStripEndId&) const
00448 {
00461   float result =  sigmip*(float)fDefaultSigCorPerMip;
00462   return FloatErr(result,result);
00463 }
00464 
00465 
00466 Float_t SimpleCalScheme::GetTemperature(Int_t) const
00467 {
00471   return fDefaultTemp;
00472 }
00473 
00474 
00475 
00476 
00477 

Generated on Mon Feb 15 11:07:37 2010 for loon by  doxygen 1.3.9.1