00001 #include "DataQualDB.h" 00002 00003 #include "RunQuality/RunQualityFinder.h" 00004 #include "DcsUser/HvStatusFinder.h" 00005 #include "DcsUser/CoilTools.h" 00006 #include "SpillTiming/SpillServerMonFinder.h" 00007 00008 // #include "CandNtupleSR/NtpSRDataQuality.h" 00009 00010 Bool_t DataUtil::IsGoodData(const NtpStRecord *st) { 00011 00012 // far detector data quality 00013 // ========================= 00014 // number of crates enabled 00015 // (superseded by DbuFarRunQuality table) 00016 00017 // Int_t cratemask = 0; 00018 // const NtpSRDataQuality *ntpDataQual; 00019 // ntpDataQual = &(st->dataquality); 00020 // cratemask = ntpDataQual->cratemask; 00021 // if( cratemask!=16 ) return 0; 00022 00023 // get validity context 00024 // ==================== 00025 const RecCandHeader* Header = &(st->GetHeader()); 00026 VldContext cx = Header->GetVldContext(); 00027 00028 return IsGoodData(cx); 00029 } 00030 00031 Bool_t DataUtil::IsGoodData(const VldContext& cx) 00032 { 00033 // If it's not real data, return kOK 00034 // ================================= 00035 if( cx.GetSimFlag() != SimFlag::kData ){ 00036 return 1; 00037 } 00038 00039 // Far Detector Data Selection 00040 // =========================== 00041 if( cx.GetDetector() == Detector::kFar ) { 00042 00043 // requirements for good far detector data: 00044 // (i) good run - IsGoodDataRUN(cx) 00045 // (ii) good hv - IsGoodDataHV(cx) 00046 // (iii) good coil - IsGoodDataCOIL(cx) 00047 // (iv) good gps error - IsGoodDataGPS(cx) 00048 00049 if( IsGoodDataRUN(cx) && IsGoodDataHV(cx) 00050 && IsGoodDataCOIL(cx) && IsGoodDataGPS(cx) ) return 1; 00051 else return 0; 00052 } 00053 00054 // Near Detector Data Selection 00055 // ============================ 00056 if( cx.GetDetector() == Detector::kNear ) { 00057 00058 // requirements for good near detector data: 00059 // (i) good run - IsGoodDataRUN(cx) 00060 // (ii) good coil - IsGoodDataCOIL(cx) 00061 00062 if( IsGoodDataRUN(cx) 00063 && IsGoodDataCOIL(cx) ) return 1; 00064 else return 0; 00065 } 00066 00067 return 1; 00068 } 00069 00070 Bool_t DataUtil::IsGoodDataRUN(const VldContext& cx) 00071 { 00072 // If it's not real data, return kOK 00073 // ================================= 00074 if( cx.GetSimFlag() != SimFlag::kData ){ 00075 return 1; 00076 } 00077 00078 // Far Detector Data - Check Run Status 00079 // ==================================== 00080 if( cx.GetDetector() == Detector::kFar ) { 00081 return RunQualityFinder::Instance().IsOK(cx); 00082 } 00083 00084 // Near Detector Data - Check Run Status 00085 // ===================================== 00086 if( cx.GetDetector() == Detector::kNear ) { 00087 return RunQualityFinder::Instance().IsOK(cx); 00088 } 00089 00090 return 1; 00091 } 00092 00093 Bool_t DataUtil::IsGoodDataHV(const VldContext& cx) 00094 { 00095 // If it's not real data, return kOK 00096 // ================================= 00097 if( cx.GetSimFlag() != SimFlag::kData ){ 00098 return 1; 00099 } 00100 00101 // Far Detector Data - Check HV Status 00102 // =================================== 00103 // check HV status within 60 secs of snarl 00104 // (N.B: arguments given to HvStatusFinder: 00105 // validity context, time window, task number) 00106 if( cx.GetDetector() == Detector::kFar ) { 00107 HvStatus::HvStatus_t hv_ok = 00108 HvStatusFinder::Instance().GetHvStatus(cx,60,1); 00109 return HvStatus::Good(hv_ok); 00110 } 00111 00112 // Near Detector Data, return kOK 00113 // ============================== 00114 if( cx.GetDetector() == Detector::kNear ) { 00115 return 1; 00116 } 00117 00118 return 1; 00119 } 00120 00121 Bool_t DataUtil::IsGoodDataCOIL(const VldContext& cx) 00122 { 00123 // If it's not real data, return kOK 00124 // ================================= 00125 if( cx.GetSimFlag() != SimFlag::kData ){ 00126 return 1; 00127 } 00128 00129 // Far Detector Data - Check Coil Status 00130 // ===================================== 00131 if( cx.GetDetector() == Detector::kFar ) { 00132 return CoilTools::IsOK(cx); 00133 } 00134 00135 // Near Detector Data - Check Coil Status 00136 // ====================================== 00137 if( cx.GetDetector() == Detector::kNear ) { 00138 return CoilTools::IsOK(cx); 00139 } 00140 00141 return 1; 00142 } 00143 00144 Bool_t DataUtil::IsGoodDataGPS(const VldContext& cx) 00145 { 00146 // If it's not real data, return kOK 00147 // ================================= 00148 if( cx.GetSimFlag() != SimFlag::kData ){ 00149 return 1; 00150 } 00151 00152 // Far Detector Data - Check GPS Status 00153 // ==================================== 00154 // get spillserver monitoring block for this snarl, 00155 // get GPS worst case uncertainty (nsec) 00156 // spill must be real and within 5 minutes 00157 if( cx.GetDetector() == Detector::kFar ) { 00158 00159 SpillServerMonFinder& smon = SpillServerMonFinder::Instance(); 00160 const SpillServerMon& spill_near = smon.GetNearestSpill(cx); 00161 VldTimeStamp dt = spill_near.GetSpillTime()-cx.GetTimeStamp(); 00162 00163 Int_t dt_sec = abs(dt.GetSec()); 00164 Int_t gps_error = spill_near.GetSpillTimeError(); 00165 Int_t spill_type = spill_near.GetSpillType(); 00166 00167 if( spill_type==1 && dt_sec<360 && gps_error>1000 ) return 0; 00168 else return 1; 00169 } 00170 00171 return 1; 00172 } 00173 00174 Bool_t DataUtil::IsGoodFDData(const NtpStRecord* st) 00175 { 00176 return IsGoodData(st); 00177 } 00178 00179 Bool_t DataUtil::IsGoodFDData(const VldContext& cx) 00180 { 00181 return IsGoodData(cx); 00182 } 00183 00184 Bool_t DataUtil::IsGoodFDDataRUN(const VldContext& cx) 00185 { 00186 return IsGoodDataRUN(cx); 00187 } 00188 00189 Bool_t DataUtil::IsGoodFDDataHV(const VldContext& cx) 00190 { 00191 return IsGoodDataHV(cx); 00192 } 00193 00194 Bool_t DataUtil::IsGoodFDDataCOIL(const VldContext& cx) 00195 { 00196 return IsGoodDataCOIL(cx); 00197 } 00198 00199 Bool_t DataUtil::IsGoodFDDataGPS(const VldContext& cx) 00200 { 00201 return IsGoodDataGPS(cx); 00202 } 00203 00204 Bool_t DataUtil::IsGoodNDData(const NtpStRecord* st) 00205 { 00206 return IsGoodData(st); 00207 } 00208 00209 Bool_t DataUtil::IsGoodNDData(const VldContext& cx) 00210 { 00211 return IsGoodData(cx); 00212 } 00213 00214 Bool_t DataUtil::IsGoodNDDataRUN(const VldContext& cx) 00215 { 00216 return IsGoodDataRUN(cx); 00217 } 00218 00219 Bool_t DataUtil::IsGoodNDDataCOIL(const VldContext& cx) 00220 { 00221 return IsGoodDataCOIL(cx); 00222 }
1.3.9.1