00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #include "DatabaseInterface/DbiOutRowStream.h"
00015 #include "MessageService/MsgService.h"
00016
00017 #include "Calibrator/CalDrift.h"
00018
00019 ClassImp(CalDrift)
00020
00021 CVSID("$Id: CalDrift.cxx,v 1.13 2009/05/22 10:57:19 tinti Exp $");
00022
00023 #include "DatabaseInterface/DbiResultPtr.tpl"
00024 #include "DatabaseInterface/DbiResultSet.h"
00025 #include "DatabaseInterface/DbiWriter.tpl"
00026 #include "DatabaseInterface/DbiValidityRec.h"
00027 #include "Validity/VldContext.h"
00028
00029 template class DbiResultPtr<CalDrift>;
00030 template class DbiWriter<CalDrift>;
00031
00032
00033 CalDrift::CalDrift() : DbiTableRow()
00034 {
00035 LEA_CTOR;
00036 fbackMedian = 0.0;
00037 fbackMedianErr = 0.0;
00038 ffrontMedian = 0.0;
00039 ffrontMedianErr = 0.0;
00040 fnonFidMedian = 0.0;
00041 fnonFidMedianErr = 0.0;
00042 fnumMuons = 0;
00043 fnumPlanes = 0;
00044 fmean = 0.0;
00045 fmeanErr = 0.0;
00046 fmedian = 0.0;
00047 fmedianErr = 0.0;
00048 fpeak = 0.0;
00049 fpeakErr = 0.0;
00050 fquantile50 = 0.0;
00051 frecoVersion = "Dogwood";
00052
00053 fdriftQuantity1 = 1.0;
00054 fdriftQuantity2 = 1.0;
00055 }
00056
00057
00058 CalDrift::~CalDrift()
00059 {
00060 LEA_DTOR;
00061 }
00062
00063
00064
00065 const Float_t
00066 CalDrift::CalibratedPH(const Float_t ph,
00067 const VldContext& cxNow,
00068 const VldContext& cxRef) const
00069 {
00070
00071
00072
00073
00074
00075
00076 Dbi::Task task = 1;
00077
00078 DbiResultPtr<CalDrift> nowTable("CALDRIFT",
00079 cxNow,
00080 task,
00081 Dbi::kTableMissing,
00082 false);
00083 DbiResultPtr<CalDrift> t0Table("CALDRIFT",
00084 cxRef,
00085 task,
00086 Dbi::kTableMissing,
00087 false);
00088
00089 Double_t multipFactor = 1.0;
00090 if (nowTable.GetNumRows() && t0Table.GetNumRows()){
00091 const CalDrift* nowRow = nowTable.GetRow(0);
00092 const CalDrift* t0Row = t0Table.GetRow(0);
00093 multipFactor =
00094 t0Row->GetMedianAsR1_18_2(cxRef.GetDetector())
00095 /nowRow->GetMedianAsR1_18_2(cxRef.GetDetector());
00096
00097
00098
00099
00100
00101
00102 }
00103
00104 return (Float_t) ((Double_t) ph)*multipFactor;
00105 }
00106
00107
00108 DbiTableRow* CalDrift::CreateTableRow() const
00109 {
00110 return new CalDrift;
00111 }
00112
00113
00114 void CalDrift::Fill(DbiResultSet& rs,
00115 const DbiValidityRec* )
00116 {
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 rs >> fbackMedian >> fbackMedianErr >> ffrontMedian
00135 >> ffrontMedianErr >> fnonFidMedian >> fnonFidMedianErr
00136 >> fnumMuons >> fnumPlanes >> fmean >> fmeanErr >> fmedian
00137 >> fmedianErr >> fquantile50 >> frecoVersion
00138 >> fdriftQuantity1 >> fdriftQuantity2;
00139 }
00140
00141
00142 Float_t CalDrift::GetMeanAsR1_18_2(const Detector::Detector_t det)
00143 const
00144 {
00145 Double_t recoFactor = 1.0;
00146 if (Detector::kNear == det){
00147 if ("R1_18"==frecoVersion){
00148 recoFactor = 1.00129;
00149 }
00150 if ("R1_18_2"==frecoVersion){
00151 recoFactor = 1.0;
00152 }
00153 if ("R1_18_4"==frecoVersion){
00154 recoFactor = 1.0;
00155 }
00156 if ("Cedar"==frecoVersion){
00157 recoFactor = 0.9719;
00158 }
00159 if ("Dogwood"==frecoVersion){
00160 recoFactor = 0.972141;
00161 }
00162
00163 }
00164 if (Detector::kFar == det){
00165 if ("R1_18"==frecoVersion){
00166 recoFactor = 1.0;
00167 }
00168 if ("R1_18_2"==frecoVersion){
00169 recoFactor = 1.0;
00170 }
00171 if ("R1_18_4"==frecoVersion){
00172 recoFactor = 1.0;
00173 }
00174 if ("Cedar"==frecoVersion){
00175 recoFactor = 0.92322;
00176 }
00177 if ("Dogwood"==frecoVersion){
00178 recoFactor = 1.01134;
00179 }
00180 }
00181 return fmean*recoFactor;
00182 }
00183
00184
00185 Float_t CalDrift::GetMedianRecoFactor(const Detector::Detector_t det)
00186 const
00187 {
00188
00189
00190 Double_t recoFactor = 1.0;
00191 if (Detector::kNear == det){
00192 if ("R1_18"==frecoVersion){
00193 recoFactor = 1.00129;
00194 }
00195 if ("R1_18_2"==frecoVersion){
00196 recoFactor = 1.0;
00197 }
00198 if ("R1_18_4"==frecoVersion){
00199 recoFactor = 1.0;
00200 }
00201 if ("Cedar"==frecoVersion){
00202 recoFactor = 1.0007;
00203 }
00204 if ("Dogwood"==frecoVersion){
00205 recoFactor = 0.950574;
00206 }
00207 }
00208 if (Detector::kFar == det){
00209 if ("R1_18"==frecoVersion){
00210 recoFactor = 1.0;
00211 }
00212 if ("R1_18_2"==frecoVersion){
00213 recoFactor = 1.0;
00214 }
00215 if ("R1_18_4"==frecoVersion){
00216 recoFactor = 1.0;
00217 }
00218 if ("Cedar"==frecoVersion){
00219 recoFactor = 0.96688;
00220 }
00221 if ("Dogwood"==frecoVersion){
00222 recoFactor = 0.964280;
00223 }
00224 }
00225 return recoFactor;
00226 }
00227
00228 Float_t CalDrift::GetMedianAsR1_18_2(const Detector::Detector_t det)
00229 const
00230 {
00231 Float_t recoFactor=GetMedianRecoFactor(det);
00232 Float_t calc=fmedian;
00233 if("Dogwood"==frecoVersion && det==Detector::kNear)
00234 calc=ffrontMedian;
00235 return calc*recoFactor;
00236
00237 }
00238
00239 Float_t CalDrift::GetMedianErrAsR1_18_2(const Detector::Detector_t det)
00240 const
00241 {
00242 Float_t recoFactor=GetMedianRecoFactor(det);
00243 Float_t calc=fmedianErr;
00244 if("Dogwood"==frecoVersion && det==Detector::kNear)
00245 calc=ffrontMedianErr;
00246 return calc*recoFactor;
00247 }
00248
00249 void CalDrift::Store(DbiOutRowStream& ors,
00250 const DbiValidityRec* ) const
00251 {
00252
00253
00254
00255
00256
00257
00258
00259 ors << fbackMedian << fbackMedianErr << ffrontMedian
00260 << ffrontMedianErr << fnonFidMedian << fnonFidMedianErr
00261 << fnumMuons << fnumPlanes << fmean << fmeanErr << fmedian
00262 << fmedianErr << fquantile50 << frecoVersion
00263 << fdriftQuantity1 << fdriftQuantity2;
00264 }