00001
00002
00003
00004
00005
00006
00007
00008
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
00021
00022
00023 CVSID("$Id: CalStripAtten.cxx,v 1.7 2007/01/15 19:52:01 rhatcher Exp $\n \
00024 CVSID_DBIRESULTPTR ");
00025
00026
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
00036
00037
00038
00039
00040
00041 void CalStripAtten::Fill(DbiResultSet& rs,
00042 const DbiValidityRec* ) {
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 if ( rs.TableName() == "CALSTRIPATTEN" ) {
00063
00064 rs >> fSEIdEncoded >> fLambda1 >> fLambda2 >> fFrac1 >> fLambda1Err >> fLambda2Err >> fFrac1Err;
00065 fSEIdKey = PlexStripEndId(fSEIdEncoded).BuildPlnStripEndKey();
00066 }
00067
00068 else {
00069
00070
00071 Int_t numCol = rs.NumCols();
00072
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* ) const {
00103
00104
00105
00106
00107
00108
00109
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;
00125
00126 Float_t atten = fFrac1 * exp(-wlsLen/fLambda1)
00127 + (1.0-fFrac1) * exp(-wlsLen/fLambda2);
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)
00149 + (1.0-frac) * exp(-wlsLen/l2);
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