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

CalStripAtten.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CalStripAtten.cxx,v 1.7 2007/01/15 19:52:01 rhatcher Exp $
00003 //
00004 // CalStripAtten
00005 //
00006 // DB Row class corresponding to the double-exponential attenuation curve along a strip.
00007 //
00008 // Nathaniel Tagg n.tagg1@physics.ox.ac.uk
00010 
00011 #include "Calibrator/CalStripAtten.h"
00012 #include "MessageService/MsgService.h"
00013 #include "DatabaseInterface/DbiOutRowStream.h"
00014 #include "DatabaseInterface/DbiResultSet.h"
00015 #include "DatabaseInterface/DbiValidityRec.h"
00016 #include <cmath>
00017 
00018 ClassImp(CalStripAtten)
00019 
00020 //   Definition of static data members
00021 //   *********************************
00022 
00023 CVSID("$Id: CalStripAtten.cxx,v 1.7 2007/01/15 19:52:01 rhatcher Exp $\n  \
00024       CVSID_DBIRESULTPTR ");
00025 
00026 //  Instantiate associated Result Pointer class.
00027 //  *******************************************
00028 
00029 #include "DatabaseInterface/DbiResultPtr.tpl"
00030 template class  DbiResultPtr<CalStripAtten>;
00031 
00032 #include "DatabaseInterface/DbiWriter.tpl"
00033 template class  DbiWriter<CalStripAtten>;
00034 
00035 // Definition of member functions (alphabetical order)
00036 // ***************************************************
00037 
00038 
00039 //.....................................................................
00040 
00041 void CalStripAtten::Fill(DbiResultSet& rs, 
00042                               const DbiValidityRec* /* vrec */) {
00043 
00044 //
00045 //
00046 //  Purpose:  Fill object from Result Set
00047 //
00048 //  Arguments: 
00049 //    rs           in    Result Set used to fill object
00050 //    vrec         in    Associated validity record (or 0 if filling
00051 //                                                    DbiValidityRec)
00052 //
00053 //  o Fill object from current row of Result Set.
00054 
00055 //  Program Notes:-
00056 //  =============
00057 
00058 //  This method demonstrates both the "dumb" fill method (just
00059 //  load the data as it comes) and the smart method (check column
00060 //  name and load according to column order). 
00061 
00062    if ( rs.TableName() == "CALSTRIPATTEN" ) {
00063       // Dumb method.
00064      rs  >> fSEIdEncoded >> fLambda1 >> fLambda2 >> fFrac1 >> fLambda1Err >> fLambda2Err >> fFrac1Err; 
00065      fSEIdKey = PlexStripEndId(fSEIdEncoded).BuildPlnStripEndKey();
00066    }
00067 
00068    else {
00069       
00070       // Smart method
00071       Int_t numCol = rs.NumCols();
00072       //  The first column (SeqNo) has already been processed.
00073       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00074          string colName = rs.CurColName();
00075          if ( colName == "SEIDENCODED" ) {
00076            rs >> fSEIdEncoded; 
00077            fSEIdKey =  PlexStripEndId(fSEIdEncoded).BuildPlnStripEndKey();       
00078          }
00079          else if( colName == "LAMBDA1" )     rs >> fLambda1;
00080          else if( colName == "LAMBDA2" )     rs >> fLambda2;
00081          else if( colName == "FRAC1"   )     rs >> fFrac1;
00082          else if( colName == "LAMBDA1ERR" )     rs >> fLambda1Err;
00083          else if( colName == "LAMBDA2ERR" )     rs >> fLambda2Err;
00084          else if( colName == "FRAC1ERR"   )     rs >> fFrac1Err;
00085 
00086          else {
00087            MSG("Dbi",Msg::kDebug) << "Ignoring column " << curCol 
00088                                   << "(" << colName << ")"
00089                                   << "; not part of CalStripAtten" 
00090                                   << endl;
00091            rs.IncrementCurCol();
00092          }
00093       }
00094    }
00095    
00096    
00097 }
00098 
00099 
00100 //.....................................................................
00101 void CalStripAtten::Store(DbiOutRowStream& ors,
00102                                const DbiValidityRec* /* vrec */) const {
00103   //
00104   //
00105   //  Purpose:  Stream object to output row stream
00106   //
00107   //  Arguments: 
00108   //    ors          in     Output row stream.
00109   //    vrec         in    Associated validity record (or 0 if filling
00110   
00111   ors << fSEIdEncoded  << fLambda1 << fLambda2 << fFrac1
00112       << fLambda1Err << fLambda2Err << fFrac1Err; 
00113 }
00114 //.....................................................................
00115 
00116 
00117 
00118 
00119 Float_t  CalStripAtten::GetAttenuation(const Float_t wlsLen) const
00120 {
00123 
00124   if(wlsLen<0) return 1; // Disallow nonphysical queries.
00125 
00126   Float_t atten =  fFrac1  * exp(-wlsLen/fLambda1) // Short atten length
00127             + (1.0-fFrac1) * exp(-wlsLen/fLambda2); // Long atten length
00128 
00129   return  atten;
00130 }
00131 
00132 
00133 Float_t  CalStripAtten::GetAttenuation(const Float_t wlsLen, 
00134                                        const Float_t* sigma_err) const
00135 {
00141 
00142   if(wlsLen<0) return 1;
00143 
00144   Float_t frac = fFrac1 + fFrac1Err*sigma_err[0];
00145   Float_t l1  = fLambda1 + fLambda1Err*sigma_err[1];
00146   Float_t l2  = fLambda2 + fLambda2Err*sigma_err[2];
00147 
00148   Float_t atten =  frac  * exp(-wlsLen/l1) // Short atten length
00149             + (1.0-frac) * exp(-wlsLen/l2); // Long atten length
00150 
00151   return atten;
00152 
00153 
00154 }
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 

Generated on Mon Feb 15 11:06:27 2010 for loon by  doxygen 1.3.9.1