Changeset 2931 for trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc
- Timestamp:
- 01/27/04 20:32:42 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc
r2922 r2931 44 44 // 45 45 MCalibrationPINDiode::MCalibrationPINDiode(const char *name, const char *title) 46 : fHist(NULL), 47 fCharge(-1.), 48 fErrCharge(-1.), 49 fPed(-1.), 50 fPedRms(-1.), 51 fSigmaCharge(-1.), 52 fErrSigmaCharge(-1.), 53 fTime(-1.), 54 fErrTime(-1.) 46 : fChargeLimit(3.), 47 fChargeErrLimit(0.), 48 fChargeRelErrLimit(1.), 49 fFlags(0) 55 50 { 56 51 … … 62 57 if (!fHist) 63 58 *fLog << warn << dbginf << " Could not create MHCalibrationPINDiode " << endl; 64 59 60 Clear(); 61 65 62 } 66 63 … … 77 74 { 78 75 fHist->Reset(); 76 77 CLRBIT(fFlags, kExcluded); 78 CLRBIT(fFlags, kFitValid); 79 CLRBIT(fFlags, kFitted); 80 81 fCharge = -1.; 82 fErrCharge = -1.; 83 fSigmaCharge = -1.; 84 fErrSigmaCharge = -1.; 85 fRSigmaSquare = -1.; 86 fChargeProb = -1.; 87 fPed = -1.; 88 fPedRms = -1.; 89 fTime = -1.; 90 fSigmaTime = -1.; 91 fTimeChiSquare = -1.; 92 93 } 94 95 96 // -------------------------------------------------------------------------- 97 // 98 // Set the pedestals from outside 99 // 100 void MCalibrationPINDiode::SetPedestal(Float_t ped, Float_t pedrms) 101 { 102 103 fPed = ped; 104 fPedRms = pedrms; 105 106 } 107 108 // -------------------------------------------------------------------------- 109 // 110 // Set the Excluded Bit from outside 111 // 112 void MCalibrationPINDiode::SetExcluded(Bool_t b ) 113 { 114 b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded); 115 } 116 117 118 // -------------------------------------------------------------------------- 119 // 120 // Set the Excluded Bit from outside 121 // 122 void MCalibrationPINDiode::SetExcludeQualityCheck(Bool_t b ) 123 { 124 b ? SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck); 125 } 126 127 // -------------------------------------------------------------------------- 128 // 129 // Set the Excluded Bit from outside 130 // 131 void MCalibrationPINDiode::SetFitValid(Bool_t b ) 132 { 133 b ? SETBIT(fFlags, kFitValid) : CLRBIT(fFlags, kFitValid); 134 } 135 136 // -------------------------------------------------------------------------- 137 // 138 // Set the Excluded Bit from outside 139 // 140 void MCalibrationPINDiode::SetFitted(Bool_t b ) 141 { 142 b ? SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted); 143 } 144 145 Bool_t MCalibrationPINDiode::IsExcluded() const 146 { 147 return TESTBIT(fFlags,kExcluded); 148 } 149 150 Bool_t MCalibrationPINDiode::IsFitValid() const 151 { 152 return TESTBIT(fFlags, kFitValid); 153 } 154 155 Bool_t MCalibrationPINDiode::IsFitted() const 156 { 157 return TESTBIT(fFlags, kFitted); 79 158 } 80 159 81 160 Bool_t MCalibrationPINDiode::FitCharge() 82 161 { 83 if(!fHist->FitCharge()) 84 return kFALSE; 85 162 163 // 164 // 1) Return if the charge distribution is already succesfully fitted 165 // or if the histogram is empty 166 // 167 if (fHist->IsFitOK() || fHist->IsEmpty()) 168 return kTRUE; 169 170 // 171 // 4) Fit the Lo Gain histograms with a Gaussian 172 // 173 if(fHist->FitCharge()) 174 { 175 SETBIT(fFlags,kFitted); 176 } 177 else 178 { 179 *fLog << warn << "WARNING: Could not fit charges of PINDiode " << endl; 180 // 181 // 5) In case of failure print out the fit results 182 // 183 // fHist->PrintChargeFitResult(); 184 CLRBIT(fFlags,kFitted); 185 } 186 187 // 188 // 6) Retrieve the results and store them in this class 189 // 86 190 fCharge = fHist->GetChargeMean(); 87 191 fErrCharge = fHist->GetChargeMeanErr(); 88 192 fSigmaCharge = fHist->GetChargeSigma(); 89 193 fErrSigmaCharge = fHist->GetChargeSigmaErr(); 194 fChargeProb = fHist->GetChargeProb(); 195 196 if (CheckChargeFitValidity()) 197 SETBIT(fFlags,kFitValid); 198 else 199 { 200 CLRBIT(fFlags,kFitValid); 201 return kFALSE; 202 } 90 203 91 204 return kTRUE; … … 93 206 } 94 207 208 // 209 // The check return kTRUE if: 210 // 211 // 1) PINDiode has a fitted charge greater than 5*PedRMS 212 // 2) PINDiode has a fit error greater than 0. 213 // 3) PINDiode has a fitted charge greater its charge error 214 // 4) PINDiode has a fit Probability greater than 0.0001 215 // 5) PINDiode has a charge sigma bigger than its Pedestal RMS 216 // 217 Bool_t MCalibrationPINDiode::CheckChargeFitValidity() 218 { 219 220 if (TESTBIT(fFlags,kExcludeQualityCheck)) 221 return kTRUE; 222 223 if (fCharge < fChargeLimit*GetPedRms()) 224 { 225 *fLog << warn << "WARNING: Fitted Charge is smaller than " 226 << fChargeLimit << " Pedestal RMS in PINDiode " << endl; 227 return kFALSE; 228 } 229 230 if (fErrCharge < fChargeErrLimit) 231 { 232 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than " 233 << fChargeErrLimit << " in PINDiode " << endl; 234 return kFALSE; 235 } 236 237 if (fCharge < fChargeRelErrLimit*fErrCharge) 238 { 239 *fLog << warn << "WARNING: Fitted Charge is smaller than " 240 << fChargeRelErrLimit << "* its error in PINDiode " << endl; 241 return kFALSE; 242 } 243 244 if (!fHist->IsFitOK()) 245 { 246 *fLog << warn << "WARNING: Probability of Fitted Charge too low in PINDiode " << endl; 247 return kFALSE; 248 } 249 250 if (fSigmaCharge < GetPedRms()) 251 { 252 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl; 253 return kFALSE; 254 } 255 return kTRUE; 256 } 257 258 259 // -------------------------------------------------------------------------- 260 // 261 // 1) Fit the arrival times 262 // 2) Retrieve the results 263 // 3) Note that because of the low number of bins, the NDf is sometimes 0, so 264 // Root does not give a reasonable Probability, the Chisquare is more significant 265 // 95 266 Bool_t MCalibrationPINDiode::FitTime() 96 267 { 97 268 98 269 if(!fHist->FitTimeHiGain()) 99 return kFALSE; 100 101 fTime = fHist->GetTime(); 102 fErrTime = fHist->GetErrTime(); 103 270 { 271 *fLog << warn << "WARNING: Could not fit Hi Gain times of PIN Diode" << endl; 272 fHist->PrintTimeFitResult(); 273 return kFALSE; 274 } 275 276 fTime = fHist->GetTimeMean(); 277 fSigmaTime = fHist->GetTimeSigma(); 278 fTimeChiSquare = fHist->GetTimeChiSquare(); 279 fTimeProb = fHist->GetTimeProb(); 280 281 if (CheckTimeFitValidity()) 282 SETBIT(fFlags,kFitValid); 283 else 284 CLRBIT(fFlags,kFitValid); 285 104 286 return kTRUE; 105 106 } 287 } 288 289 // 290 // The check returns kTRUE if: 291 // 292 // The mean arrival time is at least 1.0 slices from the used edge slices 293 // 294 Bool_t MCalibrationPINDiode::CheckTimeFitValidity() 295 { 296 297 if (TESTBIT(fFlags,kExcludeQualityCheck)) 298 return kTRUE; 299 300 return kTRUE; 301 } 302
Note:
See TracChangeset
for help on using the changeset viewer.