Changeset 5812 for trunk/MagicSoft/Mars/mcalib
- Timestamp:
- 01/12/05 20:41:09 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityRelTimeCam.cc
r5660 r5812 47 47 #include "MGeomPix.h" 48 48 49 #include "MHCamera.h" 50 49 51 #include "MLogManip.h" 50 52 51 53 #include <TOrdCollection.h> 52 54 #include <TGraphErrors.h> 55 #include <TH1D.h> 56 #include <TF1.h> 53 57 54 58 ClassImp(MCalibrationIntensityRelTimeCam); … … 177 181 const Float_t sqrt2 = 1.414; 178 182 const Float_t fadc2ns = 3.333; 179 183 const Float_t norm = fadc2ns / sqrt2; 184 180 185 TArrayF res(size); 181 186 TArrayF reserr(size); … … 185 190 Int_t cnt = 0; 186 191 192 TH1D *h = 0; 193 187 194 for (Int_t i=0;i<GetSize();i++) 188 195 { … … 193 200 MCalibrationChargeCam *cam = (MCalibrationChargeCam*)chargecam.GetCam(i); 194 201 195 if (col != MCalibrationCam::kNONE) 196 if (relcam->GetPulserColor() != col) 197 continue; 202 if (relcam->GetPulserColor() != col) 203 continue; 198 204 199 205 const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx); … … 208 214 Double_t var = 0.; 209 215 Int_t num = 0; 210 // 216 217 MHCamera camres(geom,"CamRes","Time Resolution;Time Resolution [ns];channels"); 218 // 211 219 // Get the area calibration pix from the calibration cam 212 220 // 213 for (Int_t i=0; i<cam->GetSize(); i++)221 for (Int_t j=0; j<cam->GetSize(); j++) 214 222 { 215 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[ i];216 const MCalibrationRelTimePix &relpix = (MCalibrationRelTimePix&)(*relcam)[ i];223 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[j]; 224 const MCalibrationRelTimePix &relpix = (MCalibrationRelTimePix&)(*relcam)[j]; 217 225 // 218 226 // Don't use bad pixels … … 222 230 // 223 231 // 224 if (aidx != geom[ i].GetAidx())232 if (aidx != geom[j].GetAidx()) 225 233 continue; 226 234 227 resol += relpix.GetTimePrecision(); 228 resol2 += relpix.GetTimePrecision()*relpix.GetTimePrecision(); 235 const Float_t pres = relpix.GetTimePrecision(); 236 237 resol += pres; 238 resol2 += pres; 229 239 num++; 240 241 camres.Fill(j,pres); 242 camres.SetUsed(j); 230 243 } 231 244 … … 235 248 var = (resol2 - resol*resol*num) / (num-1); 236 249 237 res[cnt] = resol * fadc2ns / sqrt2;250 res[cnt] = resol; 238 251 if (var > 0.) 239 reserr[cnt] = TMath::Sqrt(var) / sqrt2 * fadc2ns;252 reserr[cnt] = TMath::Sqrt(var); 240 253 else 241 254 reserr[cnt] = 0.; 255 256 // 257 // Make also a Gauss-fit to the distributions. The RMS can be determined by 258 // outlier, thus we look at the sigma and the RMS and take the smaller one, afterwards. 259 // 260 h = camres.ProjectionS(TArrayI(),TArrayI(1,&aidx),"_py",750); 261 h->SetDirectory(NULL); 262 h->Fit("gaus","QL"); 263 TF1 *fit = h->GetFunction("gaus"); 264 265 Float_t ci2 = fit->GetChisquare(); 266 Float_t sigma = fit->GetParameter(2); 267 268 if (ci2 > 500. || sigma > reserr[cnt]) 269 { 270 h->Fit("gaus","QLM"); 271 fit = h->GetFunction("gaus"); 272 273 ci2 = fit->GetChisquare(); 274 sigma = fit->GetParameter(2); 275 } 276 277 const Float_t mean = fit->GetParameter(1); 278 const Float_t ndf = fit->GetNDF(); 279 280 281 *fLog << inf << "Mean number photo-electrons: " << sig[cnt] << endl; 282 *fLog << inf << "Time Resolution area idx: " << aidx << " Results: " << endl; 283 *fLog << inf << "Mean: " << Form("%4.3f",mean) 284 << "+-" << Form("%4.3f",fit->GetParError(1)) 285 << " Sigma: " << Form("%4.3f",sigma) << "+-" << Form("%4.3f",fit->GetParError(2)) 286 << " Chisquare: " << Form("%4.3f",fit->GetChisquare()) << " NDF : " << ndf << endl; 287 288 delete h; 289 gROOT->GetListOfFunctions()->Remove(fit); 290 291 if (sigma < reserr[cnt] && ndf > 2) 292 { 293 res [cnt] = mean; 294 reserr[cnt] = sigma; 295 } 296 297 res[cnt] *= norm; 298 reserr[cnt] *= norm; 242 299 } 243 300 else … … 247 304 } 248 305 cnt++; 249 306 } 250 307 251 308 TGraphErrors *gr = new TGraphErrors(size,
Note:
See TracChangeset
for help on using the changeset viewer.