Changeset 2852 for trunk/MagicSoft
- Timestamp:
- 01/19/04 23:02:57 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2851 r2852 4 4 5 5 -*-*- END OF LINE -*-*- 6 7 2004/01/19: Markus Gaug 8 9 * mcalib/MHCalibrationBlindPixel.[h,cc] 10 - fixed a bug in fFitLegend due to which program crashed by calls 11 to DrawClone 12 - Modified way to change the fit function 13 14 * mcalib/MHCalibrationPixel.[h,cc] 15 - reordered function calls 16 - removed SetupFill 17 18 * mcalib/MHCalibrationPINDiode.h 19 - reordered function calls 20 21 * mcalib/MCalibrationPix.[h,cc] 22 - limits to define fFitValid now as variables in class 23 24 * mcalib/MCalibrationCam.[h,cc] 25 - reordered function calls 26 - incorporate option to exclude pixels 27 28 * mcalib/MCalibrationBlindPix.h 29 - Modified way to change the fit function 30 31 * mcalib/MCalibrationCalc.[h,cc] 32 - Modified way to change the fit function 33 - incorporate option to exclude pixels from configuration file 34 6 35 7 36 2004/01/19: Javier Rico -
trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.h
r2830 r2852 37 37 void Clear(Option_t *o=""); 38 38 39 // Getters 39 40 Float_t GetLambda() const { return fLambda; } 40 41 Float_t GetMu0() const { return fMu0; } … … 52 53 Float_t GetErrTime() const { return fErrTime; } 53 54 55 MHCalibrationBlindPixel *GetHist() const { return fHist; } 56 57 Bool_t IsFitOK() { return fHist->IsFitOK(); } 58 59 // Fill histos 54 60 Bool_t FillCharge(Float_t q) { return fHist->FillBlindPixelCharge(q); } 55 61 Bool_t FillTime(Int_t t) { return fHist->FillBlindPixelTime(t); } 56 62 Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillBlindPixelChargevsN(rq,t); } 57 63 58 Bool_t IsFitOK() { return fHist->IsFitOK(); } 59 64 // Fits 60 65 Bool_t FitCharge(); 61 66 Bool_t FitTime(); 67 void ChangeFitFunc(MHCalibrationBlindPixel::FitFunc_t f) { fHist->ChangeFitFunc(f); } 62 68 69 // Draws 63 70 void Draw(Option_t *opt="") { fHist->Draw(opt); } 64 71 TObject *DrawClone(Option_t *opt="") const { return fHist->DrawClone(opt); } 65 72 66 MHCalibrationBlindPixel *GetHist() const { return fHist; }67 73 68 74 ClassDef(MCalibrationBlindPix, 1) // Storage Container for Calibration information of one pixel -
trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc
r2840 r2852 98 98 #include "MTime.h" 99 99 #include "TMath.h" 100 #include "TSystem.h" 101 102 #include <fstream> 100 103 101 104 ClassImp(MCalibrationCalc); … … 111 114 fEvents(0), fHistOverFlow(0), fCosmics(0), 112 115 fNumHiGainSamples(0), fNumLoGainSamples(0), fConversionHiLo(0.), 116 fNumExcludedPixels(0), 113 117 fColor(kEBlue) 114 118 { … … 231 235 fNumHiGainSamples = fSignals->GetNumUsedHiGainFADCSlices(); 232 236 fNumLoGainSamples = fSignals->GetNumUsedLoGainFADCSlices(); 233 234 237 fSqrtHiGainSamples = TMath::Sqrt((Float_t)fNumHiGainSamples); 235 238 236 fCalibrations->InitSize(cam->GetNumPixels()); 237 238 for (UInt_t i=0;i<cam->GetNumPixels();i++) 239 { 240 239 UInt_t npixels = cam->GetNumPixels(); 240 241 fCalibrations->InitSize(npixels); 242 243 for (UInt_t i=0; i<npixels; i++) 244 { 245 241 246 MCalibrationPix &pix = (*fCalibrations)[i]; 242 247 pix.DefinePixId(i); 243 248 MHCalibrationPixel *hist = pix.GetHist(); 244 249 245 250 hist->SetTimeFitRangesHiGain(fSignals->GetFirstUsedSliceHiGain(), 246 fSignals->GetLastUsedSliceHiGain());251 fSignals->GetLastUsedSliceHiGain()); 247 252 hist->SetTimeFitRangesLoGain(fSignals->GetFirstUsedSliceLoGain(), 248 fSignals->GetLastUsedSliceLoGain()); 249 253 fSignals->GetLastUsedSliceLoGain()); 254 255 } 256 257 // 258 // Look for file to exclude pixels from analysis 259 // 260 if (!fExcludedPixelsFile.IsNull()) 261 { 262 263 *fLog << "HALLO: " << fExcludedPixelsFile.Data() << endl; 264 265 fExcludedPixelsFile = gSystem->ExpandPathName(fExcludedPixelsFile.Data()); 266 267 // 268 // Initialize reading the file 269 // 270 ifstream in(fExcludedPixelsFile.Data(),ios::in); 271 272 if (in) 273 { 274 *fLog << inf << "Use excluded pixels from file: '" << fExcludedPixelsFile.Data() << "'" << endl; 275 // 276 // Read the file and count the number of entries 277 // 278 UInt_t pixel = 0; 279 280 while (++fNumExcludedPixels) 281 { 282 283 in >> pixel; 284 285 if (!in.good()) 286 break; 287 // 288 // Check for out of range 289 // 290 if (pixel > npixels) 291 { 292 *fLog << warn << "WARNING: To be excluded pixel: " << pixel 293 << " is out of range " << endl; 294 continue; 295 } 296 // 297 // Exclude pixel 298 // 299 MCalibrationPix &pix = (*fCalibrations)[pixel]; 300 pix.SetExcluded(); 301 302 *fLog << GetDescriptor() << inf << ": Exclude Pixel: " << pixel << endl; 303 304 } 305 306 if (--fNumExcludedPixels == 0) 307 *fLog << warn << "WARNING: File '" << fExcludedPixelsFile.Data() 308 << "'" << " is empty " << endl; 309 else 310 fCalibrations->SetNumPixelsExcluded(fNumExcludedPixels); 311 312 } 313 else 314 *fLog << warn << dbginf << "Cannot open file '" << fExcludedPixelsFile.Data() << "'" << endl; 250 315 } 251 316 252 317 return kTRUE; 253 254 318 } 319 255 320 256 321 // -------------------------------------------------------------------------- -
trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h
r2760 r2852 14 14 #include "MTask.h" 15 15 #endif 16 17 #ifndef ROOT_TArrayI 18 #include "TArrayI.h" 19 #endif 20 21 #ifndef MARS_MCalibrationCam 22 #include "MCalibrationCam.h" 23 #endif 24 25 #include "TString.h" 16 26 17 27 class MRawEvtData; … … 45 55 Float_t fSqrtHiGainSamples; 46 56 57 Float_t fConversionHiLo; 47 58 Byte_t fFlags; // Flag for the fits used 48 49 Float_t fConversionHiLo; 59 60 TString fExcludedPixelsFile; 61 UInt_t fNumExcludedPixels; 50 62 51 enum { kUseTimeFits, kUseBlindPixelFit, kUsePinDiodeFit };52 53 63 public: 54 64 … … 68 78 MCalibrationCalc(const char *name=NULL, const char *title=NULL); 69 79 70 void SetSkipTimeFits(Bool_t b=kTRUE) 80 81 private: 82 83 enum { kUseTimeFits, kUseBlindPixelFit, kUsePinDiodeFit }; 84 85 public: 86 87 // Skipping fits 88 void SkipTimeFits(Bool_t b=kTRUE) 71 89 {b ? CLRBIT(fFlags, kUseTimeFits) : SETBIT(fFlags, kUseTimeFits);} 72 void S etSkipBlindPixelFit(Bool_t b=kTRUE)90 void SkipBlindPixelFit(Bool_t b=kTRUE) 73 91 {b ? CLRBIT(fFlags, kUseBlindPixelFit) : SETBIT(fFlags, kUseBlindPixelFit);} 74 void S etSkipPinDiodeFit(Bool_t b=kTRUE)92 void SkipPinDiodeFit(Bool_t b=kTRUE) 75 93 {b ? CLRBIT(fFlags, kUsePinDiodeFit) : SETBIT(fFlags, kUsePinDiodeFit);} 76 94 95 // Setters 77 96 void SetPulserColor(PulserColor_t color) { fColor = color; } 97 void SetConversionHiLo(Float_t conv) { fConversionHiLo = conv; } 78 98 79 void SetConversionHiLo(Float_t conv) { fConversionHiLo = conv; } 99 // Getters 100 MCalibrationBlindPix *GetBlindPixel() const { return fCalibrations->GetBlindPixel(); } 101 MCalibrationPINDiode *GetPINDiode() const { return fCalibrations->GetPINDiode(); } 102 103 // Exclude pixels from configuration file 104 void ExcludePixelsFromAsciiFile(const char *file) { fExcludedPixelsFile = file; } 80 105 81 106 ClassDef(MCalibrationCalc, 1) // Task to fill the Calibration Containers from raw data -
trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc
r2832 r2852 75 75 fOffsets(NULL), 76 76 fSlopes(NULL), 77 fOffvsSlope(NULL) 77 fOffvsSlope(NULL), 78 fNumExcludedPixels(0) 79 78 80 { 79 81 fName = name ? name : "MCalibrationCam"; … … 256 258 { 257 259 258 if (pix->IsFitValid() )260 if (pix->IsFitValid() && !pix->IsExcluded()) 259 261 { 260 262 … … 282 284 { 283 285 284 if (!pix->IsFitValid() )286 if (!pix->IsFitValid() && !pix->IsExcluded()) 285 287 { 286 288 … … 297 299 *fLog << all << id << " pixels with errors :-((" << endl; 298 300 301 *fLog << all << endl; 302 *fLog << all << "Excluded pixels:" << endl; 303 *fLog << all << endl; 304 305 *fLog << all << fNumExcludedPixels << " excluded pixels " << endl; 306 299 307 } 300 308 -
trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h
r2765 r2852 62 62 TH2D* fOffvsSlope; //! 63 63 64 UInt_t fNumExcludedPixels; 65 64 66 public: 65 67 … … 78 80 79 81 void InitSize(const Int_t i); 82 83 // Setters 84 void SetColor(const CalibrationColor_t color) { fColor = color; } 85 void SetNumPixelsExcluded(const UInt_t n) { fNumExcludedPixels = n; } 86 87 // Getters 80 88 Int_t GetSize() const; 81 82 89 UInt_t GetNumPixels() const { return fNumPixels; } 83 90 84 Bool_t IsPixelUsed(Int_t idx) const;85 Bool_t IsPixelFitted(Int_t idx) const;86 87 MCalibrationPix &operator[](Int_t i);88 MCalibrationPix &operator[](Int_t i) const;89 90 Bool_t CheckBounds(Int_t i) const;91 92 void Print(Option_t *o="") const;93 94 void CutEdges();95 96 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;97 void DrawPixelContent(Int_t num) const;98 99 91 MCalibrationBlindPix *GetBlindPixel() const { return fBlindPixel; } 100 92 MCalibrationPINDiode *GetPINDiode() const { return fPINDiode; } 101 102 void SetColor(CalibrationColor_t color) { fColor = color; }103 93 104 94 Bool_t GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma); … … 107 97 Bool_t GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma); 108 98 99 Bool_t IsPixelUsed(Int_t idx) const; 100 Bool_t IsPixelFitted(Int_t idx) const; 101 102 // Others 103 MCalibrationPix &operator[](Int_t i); 104 MCalibrationPix &operator[](Int_t i) const; 105 106 void CutEdges(); 107 Bool_t CheckBounds(Int_t i) const; 108 109 // Prints 110 void Print(Option_t *o="") const; 111 112 // Draws 113 void DrawPixelContent(Int_t num) const; 114 void DrawHiLoFits(); 115 116 // Others 117 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const; 118 109 119 Bool_t CalcNumPhotInsidePlexiglass(); 110 120 Bool_t CalcNumPhotOutsidePlexiglass(); 111 112 void DrawHiLoFits();113 121 114 122 ClassDef(MCalibrationCam, 1) // Storage Container for all calibration information of the camera -
trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
r2839 r2852 89 89 fBlindPixelMethodValid(kFALSE), 90 90 fFFactorMethodValid(kFALSE), 91 fPINDiodeMethodValid(kFALSE) 91 fPINDiodeMethodValid(kFALSE), 92 fChargeLimit(5.), 93 fChargeErrLimit(0.) 92 94 { 93 95 … … 375 377 equivpedestal /= fConversionHiLo; 376 378 377 if (fCharge < 5.*equivpedestal) 378 { 379 *fLog << warn << "WARNING: Fitted Charge is smaller than 5 Pedestal RMS in Pixel " << fPixId << endl; 380 return kFALSE; 381 } 382 383 if (fErrCharge < 0.) 384 { 385 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than 0 in Pixel " << fPixId << endl; 379 if (fCharge < fChargeLimit*equivpedestal) 380 { 381 *fLog << warn << "WARNING: Fitted Charge is smaller than " 382 << fChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl; 383 return kFALSE; 384 } 385 386 if (fErrCharge < fChargeErrLimit) 387 { 388 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than " 389 << fChargeErrLimit << " in Pixel " << fPixId << endl; 386 390 return kFALSE; 387 391 } … … 511 515 { 512 516 *fLog << warn << "WARNING: Could not fit Lo Gain times of pixel " << fPixId << endl; 513 fHist->PrintTimeFitResult();517 // fHist->PrintTimeFitResult(); 514 518 return kFALSE; 515 519 } … … 524 528 { 525 529 *fLog << warn << "WARNING: Could not fit Hi Gain times of pixel " << fPixId << endl; 526 fHist->PrintTimeFitResult();530 // fHist->PrintTimeFitResult(); 527 531 return kFALSE; 528 532 } -
trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h
r2839 r2852 63 63 MHCalibrationPixel *fHist; //! Pointer to the histograms performing the fits, etc. 64 64 65 Float_t fChargeLimit; 66 Float_t fChargeErrLimit; 67 65 68 Bool_t CheckChargeFitValidity(); 66 69 Bool_t CheckTimeFitValidity(); -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc
r2838 r2852 51 51 #include <TRandom.h> 52 52 53 #include <TText.h> 54 53 55 #include "MBinning.h" 54 56 #include "MParList.h" … … 65 67 // 66 68 MHCalibrationBlindPixel::MHCalibrationBlindPixel(const char *name, const char *title) 67 : fSinglePheFit(NULL), fTimeGausFit(NULL), fSinglePhePedFit(NULL), 68 fLambda(0.), fMu0(0.), fMu1(0.), fSigma0(0.), fSigma1(0.), 69 fLambdaErr(0.), fMu0Err(0.), fMu1Err(0.), fSigma0Err(0.), fSigma1Err(0.), 70 fChisquare(0.), fProb(0.), fNdf(0), 71 fMeanTime(0.), fMeanTimeErr(0.), fSigmaTime(0.), fSigmaTimeErr(0.), 72 fLambdaCheck(0.), fLambdaCheckErr(0.), 73 fgSinglePheFitFunc(&fKto4),fgSinglePheFitNPar(6) 74 69 : fFitLegend(NULL), fFitOK(kFALSE), 70 fLambda(0.), fMu0(0.), fMu1(0.), fSigma0(0.), fSigma1(0.), 71 fLambdaErr(0.), fMu0Err(0.), fMu1Err(0.), fSigma0Err(0.), fSigma1Err(0.), 72 fChisquare(0.), fProb(0.), fNdf(0), 73 fMeanTime(0.), fMeanTimeErr(0.), fSigmaTime(0.), fSigmaTimeErr(0.), 74 fLambdaCheck(0.), fLambdaCheckErr(0.), 75 fFitFunc(kEPoisson4) 75 76 { 76 77 … … 115 116 { 116 117 118 if (fFitLegend) 119 delete fFitLegend; 120 117 121 delete fHBlindPixelCharge; 118 122 delete fHBlindPixelTime; 119 120 if (fSinglePheFit) 121 delete fSinglePheFit; 122 if (fSinglePhePedFit) 123 delete fSinglePhePedFit; 124 if (fTimeGausFit) 125 delete fTimeGausFit; 123 delete fHBlindPixelChargevsN; 124 126 125 } 127 126 … … 154 153 const TString line1 = 155 154 Form("Mean: #lambda = %2.2f #pm %2.2f",GetLambda(),GetLambdaErr()); 156 fFitLegend->AddText(line1); 155 TText *t1 = fFitLegend->AddText(line1.Data()); 156 t1->SetBit(kCanDelete); 157 157 158 158 const TString line6 = 159 159 Form("Mean #lambda (check) = %2.2f #pm %2.2f",GetLambdaCheck(),GetLambdaCheckErr()); 160 fFitLegend->AddText(line6); 160 TText *t2 = fFitLegend->AddText(line6.Data()); 161 t2->SetBit(kCanDelete); 161 162 162 163 const TString line2 = 163 164 Form("Pedestal: #mu_{0} = %2.2f #pm %2.2f",GetMu0(),GetMu0Err()); 164 fFitLegend->AddText(line2); 165 TText *t3 = fFitLegend->AddText(line2.Data()); 166 t3->SetBit(kCanDelete); 165 167 166 168 const TString line3 = 167 169 Form("Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",GetSigma0(),GetSigma0Err()); 168 fFitLegend->AddText(line3); 170 TText *t4 = fFitLegend->AddText(line3.Data()); 171 t4->SetBit(kCanDelete); 169 172 170 173 const TString line4 = 171 174 Form("1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",GetMu1(),GetMu1Err()); 172 fFitLegend->AddText(line4); 175 TText *t5 = fFitLegend->AddText(line4.Data()); 176 t5->SetBit(kCanDelete); 173 177 174 178 const TString line5 = 175 179 Form("Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",GetSigma1(),GetSigma1Err()); 176 fFitLegend->AddText(line5); 180 TText *t6 = fFitLegend->AddText(line5.Data()); 181 t6->SetBit(kCanDelete); 177 182 178 183 const TString line7 = 179 184 Form("#chi^{2} / N_{dof}: %4.2f / %3i",GetChiSquare(),GetNdf()); 180 fFitLegend->AddText(line7); 185 TText *t7 = fFitLegend->AddText(line7.Data()); 186 t7->SetBit(kCanDelete); 181 187 182 188 const TString line8 = 183 189 Form("Probability: %4.2f ",GetProb()); 184 fFitLegend->AddText(line8); 190 TText *t8 = fFitLegend->AddText(line8.Data()); 191 t8->SetBit(kCanDelete); 185 192 186 193 if (fFitOK) 187 fFitLegend->AddText("Result of the Fit: OK"); 188 else 189 fFitLegend->AddText("Result of the Fit: NOT OK"); 190 194 { 195 TText *t = fFitLegend->AddText(0.,0.,"Result of the Fit: OK"); 196 t->SetBit(kCanDelete); 197 } 198 else 199 { 200 TText *t = fFitLegend->AddText("Result of the Fit: NOT OK"); 201 t->SetBit(kCanDelete); 202 } 203 191 204 fFitLegend->SetBit(kCanDelete); 192 205 fFitLegend->Draw(); 193 206 207 return; 194 208 } 195 209 … … 201 215 202 216 TObject *newobj = Clone(); 217 203 218 newobj->SetBit(kCanDelete); 204 205 219 if (!newobj) 206 220 return 0; 207 221 222 // ((MHCalibrationBlindPixel*)newobj)->Draw(opt); 208 223 newobj->Draw(opt); 209 224 return newobj; … … 220 235 221 236 gStyle->SetOptFit(0); 222 gStyle->SetOptStat(111111 1);237 gStyle->SetOptStat(111111); 223 238 224 239 TCanvas *c = MakeDefCanvas(this,550,700); … … 234 249 fHBlindPixelCharge->DrawCopy(opt); 235 250 236 if (fSinglePheFit) 237 { 238 if (fFitOK) 239 fSinglePheFit->SetLineColor(kGreen); 240 else 241 fSinglePheFit->SetLineColor(kRed); 242 243 fSinglePheFit->DrawCopy("same"); 244 c->Modified(); 245 c->Update(); 246 247 if (fSinglePhePedFit) 248 { 249 fSinglePhePedFit->SetLineColor(kBlue); 250 fSinglePhePedFit->DrawCopy("same"); 251 } 252 } 253 251 if (fFitOK) 252 fSinglePheFit.SetLineColor(kGreen); 253 else 254 fSinglePheFit.SetLineColor(kRed); 255 256 fSinglePheFit.DrawCopy("same"); 257 c->Modified(); 258 c->Update(); 259 260 fSinglePhePedFit.SetLineColor(kBlue); 261 fSinglePhePedFit.DrawCopy("same"); 254 262 255 263 c->cd(2); … … 257 265 c->Modified(); 258 266 c->Update(); 259 267 260 268 c->cd(3); 261 269 gPad->SetLogy(1); 262 270 gPad->SetBorderMode(0); 263 271 fHBlindPixelTime->DrawCopy(opt); 264 272 265 273 if (fHBlindPixelTime->GetFunction("GausTime")) 266 274 { … … 270 278 else 271 279 tfit->SetLineColor(kGreen); 272 280 273 281 tfit->DrawCopy("same"); 274 282 c->Modified(); … … 296 304 return kFALSE; 297 305 } 298 299 TF1 *simulateSinglePhe = new TF1("simulateSinglePhe",fgSinglePheFitFunc, 300 fBlindPixelChargefirst,fBlindPixelChargelast,fgSinglePheFitNPar); 301 302 simulateSinglePhe->SetParameters(lambda,mu0,mu1,sigma0,sigma1); 303 simulateSinglePhe->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1"); 304 simulateSinglePhe->SetNpx(fBlindPixelChargenbins); 305 306 307 TF1 simulateSinglePhe; 308 309 InitFit(simulateSinglePhe,fBlindPixelChargefirst,fBlindPixelChargelast); 310 306 311 for (Int_t i=0;i<10000; i++) 307 { 308 fHBlindPixelCharge->Fill(simulateSinglePhe->GetRandom()); 309 } 312 fHBlindPixelCharge->Fill(simulateSinglePhe.GetRandom()); 310 313 311 314 return kTRUE; 312 315 } 313 316 314 315 void MHCalibrationBlindPixel::ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par) 316 { 317 318 fgSinglePheFitFunc = fitfunc; 319 fgSinglePheFitNPar = par; 320 321 } 322 323 324 325 Bool_t MHCalibrationBlindPixel::FitSinglePhe(Axis_t rmin, Axis_t rmax, Option_t *opt) 326 { 327 328 if (fSinglePheFit) 329 return kFALSE; 330 331 332 // 333 // Get the fitting ranges 334 // 335 rmin = (rmin != 0.) ? rmin : fBlindPixelChargefirst; 336 rmax = (rmax != 0.) ? rmax : fBlindPixelChargelast; 337 317 void MHCalibrationBlindPixel::InitFit(TF1& f, Axis_t min, Axis_t max) 318 { 319 338 320 // 339 321 // First guesses for the fit (should be as close to reality as possible, … … 348 330 const Double_t norm = entries/gkSq2Pi; 349 331 350 fSinglePheFit = new TF1("SinglePheFit",fgSinglePheFitFunc,rmin,rmax,fgSinglePheFitNPar); 351 // fSinglePheFit = new TF1("SinglePheFit",fgSinglePheFitFunc,rmin,rmax,fgSinglePheFitNPar+1); 352 // fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess); 353 fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm); 354 // fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1"); 355 fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area"); 356 fSinglePheFit->SetParLimits(0,0.,1.); 357 fSinglePheFit->SetParLimits(1,rmin,(rmax-rmin)/1.5); 358 fSinglePheFit->SetParLimits(2,(rmax-rmin)/2.,(rmax-0.05*(rmax-rmin))); 359 fSinglePheFit->SetParLimits(3,1.0,(rmax-rmin)/2.0); 360 fSinglePheFit->SetParLimits(4,1.0,(rmax-rmin)/2.5); 361 fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1); 362 // fSinglePheFit->SetParLimits(5,entries/gkSq2Pi,entries/gkSq2Pi); 363 // fSinglePheFit->SetParLimits(5,0.,1.5*entries); 364 // 365 // Normalize the histogram to facilitate faster fitting of the area 366 // For speed reasons, fKto4 is normalized to Sqrt(2 pi). 367 // Therefore also normalize the histogram to that value 368 // 369 // fHBlindPixelCharge->Scale(gkSq2Pi*(float)bins/npx/entries); 370 // fHBlindPixelCharge->Scale(gkSq2Pi/entries); 371 // norm *= (Float_t)fSinglePheFit->GetNpx()/(Float_t)fBlindPixelChargenbins; 372 373 fHBlindPixelCharge->Fit(fSinglePheFit,opt); 374 375 fLambda = fSinglePheFit->GetParameter(0); 376 fMu0 = fSinglePheFit->GetParameter(1); 377 fMu1 = fSinglePheFit->GetParameter(2); 378 fSigma0 = fSinglePheFit->GetParameter(3); 379 fSigma1 = fSinglePheFit->GetParameter(4); 380 381 fLambdaErr = fSinglePheFit->GetParError(0); 382 fMu0Err = fSinglePheFit->GetParError(1); 383 fMu1Err = fSinglePheFit->GetParError(2); 384 fSigma0Err = fSinglePheFit->GetParError(3); 385 fSigma1Err = fSinglePheFit->GetParError(4); 386 387 fProb = fSinglePheFit->GetProb(); 388 fChisquare = fSinglePheFit->GetChisquare(); 389 fNdf = fSinglePheFit->GetNDF(); 332 // 333 // Initialize 334 // 335 switch (fFitFunc) 336 { 337 338 case kEPoisson4: 339 f = TF1("SinglePheFit",&fPoissonKto4,min,max,6); 340 f.SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm); 341 f.SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area"); 342 f.SetParLimits(0,0.,1.); 343 f.SetParLimits(1,min,(max-min)/1.5); 344 f.SetParLimits(2,(max-min)/2.,(max-0.05*(max-min))); 345 f.SetParLimits(3,1.0,(max-min)/2.0); 346 f.SetParLimits(4,1.0,(max-min)/2.5); 347 f.SetParLimits(5,norm-0.1,norm+0.1); 348 break; 349 350 case kEPoisson5: 351 f = TF1("SinglePheFit",&fPoissonKto5,min,max,6); 352 f.SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm); 353 f.SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area"); 354 f.SetParLimits(0,0.,1.); 355 f.SetParLimits(1,min,(max-min)/1.5); 356 f.SetParLimits(2,(max-min)/2.,(max-0.05*(max-min))); 357 f.SetParLimits(3,1.0,(max-min)/2.0); 358 f.SetParLimits(4,1.0,(max-min)/2.5); 359 f.SetParLimits(5,norm-0.1,norm+0.1); 360 break; 361 362 case kEPoisson6: 363 f = TF1("SinglePheFit",&fPoissonKto6,min,max,6); 364 f.SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm); 365 f.SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area"); 366 f.SetParLimits(0,0.,1.); 367 f.SetParLimits(1,min,(max-min)/1.5); 368 f.SetParLimits(2,(max-min)/2.,(max-0.05*(max-min))); 369 f.SetParLimits(3,1.0,(max-min)/2.0); 370 f.SetParLimits(4,1.0,(max-min)/2.5); 371 f.SetParLimits(5,norm-0.1,norm+0.1); 372 break; 373 374 case kEPoisson7: 375 break; 376 377 case kEPolya: 378 break; 379 380 case kEMichele: 381 break; 382 383 } 384 } 385 386 void MHCalibrationBlindPixel::ExitFit(TF1 &f) 387 { 388 389 390 // 391 // Finalize 392 // 393 switch (fFitFunc) 394 { 395 396 case kEPoisson4: 397 case kEPoisson5: 398 case kEPoisson6: 399 case kEPoisson7: 400 fLambda = fSinglePheFit.GetParameter(0); 401 fMu0 = fSinglePheFit.GetParameter(1); 402 fMu1 = fSinglePheFit.GetParameter(2); 403 fSigma0 = fSinglePheFit.GetParameter(3); 404 fSigma1 = fSinglePheFit.GetParameter(4); 405 406 fLambdaErr = fSinglePheFit.GetParError(0); 407 fMu0Err = fSinglePheFit.GetParError(1); 408 fMu1Err = fSinglePheFit.GetParError(2); 409 fSigma0Err = fSinglePheFit.GetParError(3); 410 fSigma1Err = fSinglePheFit.GetParError(4); 411 break; 412 default: 413 break; 414 } 415 416 } 417 418 419 Bool_t MHCalibrationBlindPixel::FitSinglePhe(Axis_t rmin, Axis_t rmax, Option_t *opt) 420 { 421 422 // 423 // Get the fitting ranges 424 // 425 rmin = (rmin != 0.) ? rmin : fBlindPixelChargefirst; 426 rmax = (rmax != 0.) ? rmax : fBlindPixelChargelast; 427 428 InitFit(fSinglePheFit,rmin,rmax); 429 430 fHBlindPixelCharge->Fit(&fSinglePheFit,opt); 431 432 ExitFit(fSinglePheFit); 433 434 fProb = fSinglePheFit.GetProb(); 435 fChisquare = fSinglePheFit.GetChisquare(); 436 fNdf = fSinglePheFit.GetNDF(); 390 437 391 438 // Perform the cross-check fitting only the pedestal: 392 fSinglePhePedFit = new TF1("GausPed","gaus",rmin,fMu0); 393 fHBlindPixelCharge->Fit(fSinglePhePedFit,opt); 394 395 Double_t pedarea = fSinglePhePedFit->GetParameter(0)*gkSq2Pi*fSinglePhePedFit->GetParameter(2); 439 fSinglePhePedFit = TF1("GausPed","gaus",rmin,fMu0); 440 fHBlindPixelCharge->Fit(&fSinglePhePedFit,opt); 441 442 const Stat_t entries = fHBlindPixelCharge->Integral("width"); 443 444 Double_t pedarea = fSinglePhePedFit.GetParameter(0)*gkSq2Pi*fSinglePhePedFit.GetParameter(2); 396 445 fLambdaCheck = TMath::Log(entries/pedarea); 397 fLambdaCheckErr = fSinglePhePedFit ->GetParError(0)/fSinglePhePedFit->GetParameter(0)398 + fSinglePhePedFit ->GetParError(2)/fSinglePhePedFit->GetParameter(2);446 fLambdaCheckErr = fSinglePhePedFit.GetParError(0)/fSinglePhePedFit.GetParameter(0) 447 + fSinglePhePedFit.GetParError(2)/fSinglePhePedFit.GetParameter(2); 399 448 400 449 *fLog << inf << "Results of the Blind Pixel Fit: " << endl; … … 429 478 } 430 479 else 431 *fLog << inf << GetDescriptor() << ": " << contSinglePhe 432 << " in Single Photo-Electron peak " << endl; 480 *fLog << inf << contSinglePhe << " in Single Photo-Electron peak " << endl; 433 481 434 482 fFitOK = kTRUE; … … 456 504 { 457 505 458 if (fTimeGausFit)459 return kFALSE;460 461 506 rmin = (rmin != 0.) ? rmin : 4.; 462 507 rmax = (rmax != 0.) ? rmax : 9.; … … 467 512 const Double_t area_guess = entries/gkSq2Pi; 468 513 469 fTimeGausFit = new TF1("GausTime","gaus",rmin,rmax); 470 fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess); 471 fTimeGausFit->SetParNames("Area","#mu","#sigma"); 472 fTimeGausFit->SetParLimits(0,0.,entries); 473 fTimeGausFit->SetParLimits(1,rmin,rmax); 474 fTimeGausFit->SetParLimits(2,0.,rmax-rmin); 475 476 fHBlindPixelTime->Fit(fTimeGausFit,opt); 477 478 rmin = fTimeGausFit->GetParameter(1) - 2.*fTimeGausFit->GetParameter(2); 479 rmax = fTimeGausFit->GetParameter(1) + 2.*fTimeGausFit->GetParameter(2); 480 fTimeGausFit->SetRange(rmin,rmax); 481 482 fHBlindPixelTime->Fit(fTimeGausFit,opt); 483 484 fMeanTime = fTimeGausFit->GetParameter(2); 485 fSigmaTime = fTimeGausFit->GetParameter(3); 486 fMeanTimeErr = fTimeGausFit->GetParError(2); 487 fSigmaTimeErr = fTimeGausFit->GetParError(3); 514 fTimeGausFit = TF1("GausTime","gaus",rmin,rmax); 515 fTimeGausFit.SetParameters(area_guess,mu_guess,sigma_guess); 516 fTimeGausFit.SetParNames("Area","#mu","#sigma"); 517 fTimeGausFit.SetParLimits(0,0.,entries); 518 fTimeGausFit.SetParLimits(1,rmin,rmax); 519 fTimeGausFit.SetParLimits(2,0.,rmax-rmin); 520 521 fHBlindPixelTime->Fit(&fTimeGausFit,opt); 522 rmin = fTimeGausFit.GetParameter(1) - 2.*fTimeGausFit.GetParameter(2); 523 rmax = fTimeGausFit.GetParameter(1) + 2.*fTimeGausFit.GetParameter(2); 524 fTimeGausFit.SetRange(rmin,rmax); 525 526 fHBlindPixelTime->Fit(&fTimeGausFit,opt); 527 528 fMeanTime = fTimeGausFit.GetParameter(2); 529 fSigmaTime = fTimeGausFit.GetParameter(3); 530 fMeanTimeErr = fTimeGausFit.GetParError(2); 531 fSigmaTimeErr = fTimeGausFit.GetParError(3); 488 532 489 533 *fLog << inf << "Results of the Times Fit: " << endl; 490 *fLog << inf << "Chisquare: " << fTimeGausFit ->GetChisquare() << endl;491 *fLog << inf << "Ndf: " << fTimeGausFit ->GetNDF() << endl;534 *fLog << inf << "Chisquare: " << fTimeGausFit.GetChisquare() << endl; 535 *fLog << inf << "Ndf: " << fTimeGausFit.GetNDF() << endl; 492 536 493 537 return kTRUE; -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h
r2835 r2852 38 38 TH1I* fHBlindPixelChargevsN; //-> Summed Charge vs. Event Nr. 39 39 40 TF1 *fSinglePheFit;41 TF1 *fTimeGausFit;42 TF1 *fSinglePhePedFit;40 TF1 fSinglePheFit; 41 TF1 fTimeGausFit; 42 TF1 fSinglePhePedFit; 43 43 44 44 Axis_t fBlindPixelChargefirst; … … 49 49 void DrawLegend(); 50 50 51 TPaveText *fFitLegend; 51 TPaveText *fFitLegend; //! 52 52 Bool_t fFitOK; 53 53 … … 81 81 ~MHCalibrationBlindPixel(); 82 82 83 typedef Double_t (*BlindPixelFitFunc)(Double_t *, Double_t *);84 85 83 Bool_t FillBlindPixelCharge(Float_t q) { return fHBlindPixelCharge->Fill(q) > -1; } 86 84 Bool_t FillBlindPixelTime(Int_t t) { return fHBlindPixelTime->Fill(t) > -1; } 87 85 Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t) { return fHBlindPixelChargevsN->Fill(t,rq) > -1; } 88 86 87 88 //Getters 89 89 const Double_t GetLambda() const { return fLambda; } 90 const Double_t GetLambdaCheck() const { return fLambdaCheck; }90 const Double_t GetLambdaCheck() const { return fLambdaCheck; } 91 91 const Double_t GetMu0() const { return fMu0; } 92 92 const Double_t GetMu1() const { return fMu1; } … … 95 95 96 96 const Double_t GetLambdaErr() const { return fLambdaErr; } 97 const Double_t GetLambdaCheckErr() const { return fLambdaCheckErr; }97 const Double_t GetLambdaCheckErr() const { return fLambdaCheckErr; } 98 98 const Double_t GetMu0Err() const { return fMu0Err; } 99 99 const Double_t GetMu1Err() const { return fMu1Err; } … … 102 102 103 103 const Double_t GetChiSquare() const { return fChisquare; } 104 const Double_t GetProb() 105 const Int_t GetNdf() 104 const Double_t GetProb() const { return fProb; } 105 const Int_t GetNdf() const { return fNdf; } 106 106 107 107 const Double_t GetMeanTime() const { return fMeanTime; } … … 110 110 const Double_t GetSigmaTimeErr() const { return fSigmaTimeErr; } 111 111 112 Bool_t SimulateSinglePhe(Double_t lambda, 113 Double_t mu0, 114 Double_t mu1, 115 Double_t sigma0, 116 Double_t sigma1); 117 112 const Bool_t IsFitOK() { return fFitOK; } 113 114 // Draws 115 TObject *DrawClone(Option_t *option="") const; 116 void Draw(Option_t *option=""); 117 118 // Fits 119 enum FitFunc_t { kEPoisson4, kEPoisson5, kEPoisson6, kEPoisson7, kEPolya, kEMichele }; 120 121 private: 122 FitFunc_t fFitFunc; 123 124 public: 118 125 Bool_t FitSinglePhe(Axis_t rmin=0, Axis_t rmax=0, Option_t *opt="RL0+Q"); 119 126 Bool_t FitTime(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+Q"); 120 121 void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=6); 122 127 void ChangeFitFunc(FitFunc_t func) { fFitFunc = func; } 128 129 // Simulation 130 Bool_t SimulateSinglePhe(Double_t lambda, 131 Double_t mu0,Double_t mu1, 132 Double_t sigma0,Double_t sigma1); 133 134 // Others 123 135 void CutAllEdges(); 124 136 125 TObject *DrawClone(Option_t *option="") const;126 void Draw(Option_t *option="");127 128 Bool_t IsFitOK() { return fFitOK; }129 130 137 private: 131 132 BlindPixelFitFunc fgSinglePheFitFunc; //! In the beginning,133 Int_t fgSinglePheFitNPar; //! we want to be flexible using different functions134 135 inline static Double_t f Ana(Double_t *x, Double_t *par)138 139 void InitFit(TF1& f, Axis_t min, Axis_t max); 140 void ExitFit(TF1& f); 141 142 inline static Double_t fFitFuncMichele(Double_t *x, Double_t *par) 136 143 { 137 144 … … 189 196 } 190 197 191 inline static Double_t f Kto4(Double_t *x, Double_t *par)198 inline static Double_t fPoissonKto4(Double_t *x, Double_t *par) 192 199 { 193 200 … … 246 253 247 254 248 inline static Double_t f Kto5(Double_t *x, Double_t *par)255 inline static Double_t fPoissonKto5(Double_t *x, Double_t *par) 249 256 { 250 257 … … 311 318 312 319 313 inline static Double_t f Kto6(Double_t *x, Double_t *par)320 inline static Double_t fPoissonKto6(Double_t *x, Double_t *par) 314 321 { 315 322 … … 382 389 } 383 390 384 ClassDef(MHCalibrationBlindPixel, 1) 391 ClassDef(MHCalibrationBlindPixel, 1) // Histograms from the Calibration Blind Pixel 385 392 }; 386 393 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.h
r2734 r2852 26 26 private: 27 27 28 TH1I* fHPCharge; 29 TH1F* fHErrCharge; 28 TH1I* fHPCharge; //-> Histogram containing the summed 32 PINDiode slices 29 TH1F* fHErrCharge; //-> Variance of summed FADC slices 30 30 TH1I* fHPTime; //-> Histogram with time evolution of summed charges 31 31 … … 45 45 const Double_t GetErrTime() const { return fVarGausFit->GetParameter(3); } 46 46 47 ClassDef(MHCalibrationPINDiode, 0) 47 ClassDef(MHCalibrationPINDiode, 0) // Histograms from the Calibration PIN Diode 48 48 }; 49 49 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
r2834 r2852 278 278 279 279 280 // -------------------------------------------------------------------------281 //282 // Set the binnings and prepare the filling of the histograms283 //284 Bool_t MHCalibrationPixel::SetupFill(const MParList *plist)285 {286 287 fHChargeHiGain->Reset();288 fHTimeHiGain->Reset();289 fHChargeLoGain->Reset();290 fHTimeLoGain->Reset();291 292 return kTRUE;293 }294 295 296 280 Bool_t MHCalibrationPixel::UseLoGain() 297 281 { … … 627 611 628 612 if (fTimeChisquare > 20.) // Cannot use Probability because Ndf is sometimes < 1 629 { 630 *fLog << warn << "WARNING: Fit of the Arrival times failed ! " << endl; 631 return kFALSE; 632 } 633 613 return kFALSE; 614 634 615 return kTRUE; 635 616 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h
r2792 r2852 103 103 void ChangeHistId(Int_t i); 104 104 105 Bool_t SetupFill(const MParList *pList); 106 Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; } 107 105 // Setters 108 106 void SetPointInGraph(Float_t qhi, Float_t qlo); 109 110 Bool_t FillChargeLoGain(Float_t q) { return (fHChargeLoGain->Fill(q) > -1); } 111 Bool_t FillTimeLoGain(Int_t t) { return (fHTimeLoGain->Fill(t) > -1); } 112 Bool_t FillChargevsNLoGain(Float_t q, Int_t n) { return (fHChargevsNLoGain->Fill(n,q) > -1); } 113 114 Bool_t FillChargeHiGain(Float_t q) { return (fHChargeHiGain->Fill(q) > -1); } 115 Bool_t FillTimeHiGain(Int_t t) { return (fHTimeHiGain->Fill(t) > -1); } 116 Bool_t FillChargevsNHiGain(Float_t q, Int_t n) { return (fHChargevsNHiGain->Fill(n,q) > -1); } 117 118 void SetUseLoGain() { fUseLoGain = kTRUE; } 119 Bool_t UseLoGain(); 107 void SetUseLoGain(Bool_t b = kTRUE) { fUseLoGain = b; } 120 108 121 109 void SetTimeFitRangesHiGain(Byte_t low, Byte_t up) { fTimeLowerFitRangeHiGain = low, … … 123 111 void SetTimeFitRangesLoGain(Byte_t low, Byte_t up) { fTimeLowerFitRangeLoGain = low, 124 112 fTimeUpperFitRangeLoGain = up ; } 125 113 114 void SetLowerFitRange(Axis_t min) { fLowerFitRange = min; } 115 116 // Getters 126 117 const TH1F *GetHCharge() { return fHChargeHiGain; } 127 118 const TH1F *GetHCharge() const { return fHChargeHiGain; } … … 158 149 Double_t GetOffset() { return fOffset; } 159 150 Double_t GetSlope() { return fSlope; } 151 152 Bool_t UseLoGain(); 153 154 Bool_t IsFitOK() { return fFitOK; } 155 Bool_t IsEmpty() { return !( (fHChargeHiGain->GetEntries()) 156 || (fHChargeLoGain->GetEntries()) ); } 160 157 158 // Fill histos 159 Bool_t FillChargeLoGain(Float_t q) { return (fHChargeLoGain->Fill(q) > -1); } 160 Bool_t FillTimeLoGain(Int_t t) { return (fHTimeLoGain->Fill(t) > -1); } 161 Bool_t FillChargevsNLoGain(Float_t q, Int_t n) { return (fHChargevsNLoGain->Fill(n,q) > -1); } 162 163 Bool_t FillChargeHiGain(Float_t q) { return (fHChargeHiGain->Fill(q) > -1); } 164 Bool_t FillTimeHiGain(Int_t t) { return (fHTimeHiGain->Fill(t) > -1); } 165 Bool_t FillChargevsNHiGain(Float_t q, Int_t n) { return (fHChargevsNHiGain->Fill(n,q) > -1); } 166 167 // Fits 161 168 Bool_t FitChargeHiGain(Option_t *option="RQ0"); 162 169 Bool_t FitTimeHiGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0"); … … 167 174 void FitHiGainvsLoGain(); 168 175 176 // Draws 169 177 virtual void Draw(Option_t *option=""); 178 179 // Prints 180 void PrintChargeFitResult(); 181 void PrintTimeFitResult(); 182 183 // Others 170 184 virtual void CutAllEdges(); 171 185 virtual void Reset(); 172 186 173 void SetLowerFitRange(Axis_t min) { fLowerFitRange = min; } 174 175 void PrintChargeFitResult(); 176 void PrintTimeFitResult(); 177 178 Bool_t IsFitOK() { return fFitOK; } 179 Bool_t IsEmpty() { return !( (fHChargeHiGain->GetEntries()) 180 || (fHChargeLoGain->GetEntries()) ); } 181 182 ClassDef(MHCalibrationPixel, 1) 187 ClassDef(MHCalibrationPixel, 1) // Histograms for each calibrated pixel 183 188 }; 184 189
Note:
See TracChangeset
for help on using the changeset viewer.