- Timestamp:
- 02/04/04 15:03:44 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3014 r3015 14 14 Thomas Bretz. Some modifications had to be done, however. 15 15 - Class to hold MHPedestalPixel is still MPedestalCam 16 - MPedCalcPedRun does nothing any more (except from what is was 17 doing before) 18 16 19 17 20 2004/02/03: Markus Gaug -
trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.cc
r2974 r3015 48 48 const Float_t gkSq2Pi = 2.506628274631; 49 49 const Float_t gkProbLimit = 0.01; 50 const Int_t MHPedestalPixel::gkChargeNbins = 500 ; 51 const Int_t MHPedestalPixel::gkChargevsNbins = 1000; 52 const Axis_t MHPedestalPixel::gkChargevsNFirst = -0.5; 53 const Axis_t MHPedestalPixel::gkChargevsNLast = 999.5; 54 const Axis_t MHPedestalPixel::gkChargeFirst = -0.5; 55 const Axis_t MHPedestalPixel::gkChargeLast = 499.5; 50 56 51 57 // -------------------------------------------------------------------------- … … 53 59 // Default Constructor. 54 60 // 55 MHPedestalPixel::MHPedestalPixel( const char *name, const char *title)61 MHPedestalPixel::MHPedestalPixel() 56 62 : fPixId(-1), 57 fChargeNbins(500),58 fChargeFirst(-0.5),59 fChargeLast(499.5),60 fChargevsNbins(1000),61 fChargevsNFirst(-0.5),62 fChargevsNLast(999.5),63 63 fGausFit(NULL) 64 64 { 65 66 fName = name ? name : "MHPedestalPixel"; 67 fTitle = title ? title : "Fill the accumulated charges and times of all events and perform fits"; 68 69 // Create a large number of bins, later we will rebin 70 fHPedestalCharge = new TH1F("HPedestalCharge","Distribution of Summed FADC Pedestal Slices Pixel ", 71 fChargeNbins,fChargeFirst,fChargeLast); 72 fHPedestalCharge->SetXTitle("Sum FADC Slices"); 73 fHPedestalCharge->SetYTitle("Nr. of events"); 74 fHPedestalCharge->Sumw2(); 75 76 // We define a reasonable number and later enlarge it if necessary 77 fHPedestalChargevsN = new TH1I("HChargevsN","Sum of Charges vs. Event Number Pixel ", 78 fChargevsNbins,fChargevsNFirst,fChargevsNLast); 79 fHPedestalChargevsN->SetXTitle("Event Nr."); 80 fHPedestalChargevsN->SetYTitle("Sum of FADC slices"); 81 82 fHPedestalCharge->SetDirectory(NULL); 83 fHPedestalChargevsN->SetDirectory(NULL); 84 85 Clear(); 65 66 // Create a large number of bins, later we will rebin 67 fHPedestalCharge = new TH1F("HPedestalCharge","Distribution of Summed FADC Pedestal Slices Pixel ", 68 gkChargeNbins,gkChargeFirst,gkChargeLast); 69 fHPedestalCharge->SetXTitle("Sum FADC Slices"); 70 fHPedestalCharge->SetYTitle("Nr. of events"); 71 fHPedestalCharge->Sumw2(); 72 73 // We define a reasonable number and later enlarge it if necessary 74 fHPedestalChargevsN = new TH1I("HChargevsN","Sum of Charges vs. Event Number Pixel ", 75 gkChargevsNbins,gkChargevsNFirst,gkChargevsNLast); 76 fHPedestalChargevsN->SetXTitle("Event Nr."); 77 fHPedestalChargevsN->SetYTitle("Sum of FADC slices"); 78 79 fHPedestalCharge->SetDirectory(NULL); 80 fHPedestalChargevsN->SetDirectory(NULL); 81 82 Clear(); 86 83 } 87 84 … … 91 88 delete fHPedestalCharge; 92 89 delete fHPedestalChargevsN; 93 90 94 91 if (fGausFit) 95 92 delete fGausFit; … … 111 108 fChargeNdf = -1; 112 109 113 fChargeFirst = -0.5;114 fChargeLast = 499.5;110 fChargeFirst = gkChargeFirst; 111 fChargeLast = gkChargeLast; 115 112 116 113 if (fGausFit) 117 114 delete fGausFit; 118 115 116 CLRBIT(fFlags,kFitted); 117 CLRBIT(fFlags,kFitOK); 118 CLRBIT(fFlags,kOscillating); 119 119 120 return; 120 121 } … … 160 161 fPixId = id; 161 162 162 TString nameQ = TString(fHPedestalCharge->GetName()); 163 nameQ += id; 164 fHPedestalCharge->SetName(nameQ.Data()); 165 166 TString nameQvsN = TString(fHPedestalChargevsN->GetName()); 167 nameQvsN += id; 168 fHPedestalChargevsN->SetName(nameQvsN.Data()); 169 170 TString titleQ = TString(fHPedestalCharge->GetTitle()); 171 titleQ += id; 172 fHPedestalCharge->SetTitle(titleQ.Data()); 173 174 TString titleQvsN = TString(fHPedestalChargevsN->GetTitle()); 175 titleQvsN += id; 176 fHPedestalChargevsN->SetTitle(titleQvsN.Data()); 177 178 } 179 180 181 Bool_t MHPedestalPixel::SetupFill(const MParList *plist) 182 { 183 184 Reset(); 185 186 return kTRUE; 187 } 188 189 190 163 fHPedestalCharge->SetName(Form("%s%d", fHPedestalCharge->GetName(), id)); 164 fHPedestalChargevsN->SetName(Form("%s%d", fHPedestalChargevsN->GetName(), id)); 165 fHPedestalCharge->SetTitle(Form("%s%d", fHPedestalCharge->GetTitle(), id)); 166 fHPedestalChargevsN->SetTitle(Form("%s%d", fHPedestalChargevsN->GetTitle(), id)); 167 168 } 191 169 192 170 TObject *MHPedestalPixel::DrawClone(Option_t *option) const … … 223 201 gROOT->SetSelectedPad(NULL); 224 202 225 TCanvas *c = M akeDefCanvas(this,600,900);203 TCanvas *c = MH::MakeDefCanvas(this,600,900); 226 204 227 205 c->Divide(1,2); … … 233 211 if (fHPedestalCharge->Integral() > 0) 234 212 gPad->SetLogy(1); 235 else236 gPad->SetLogy(0);237 213 238 214 fHPedestalCharge->Draw(opt); … … 243 219 if (fGausFit) 244 220 { 245 if (IsFitOK()) 246 fGausFit->SetLineColor(kGreen); 247 else 248 fGausFit->SetLineColor(kRed); 249 221 fGausFit->SetLineColor(IsFitOK() ? kGreen : kRed); 250 222 fGausFit->Draw("same"); 251 223 } … … 265 237 266 238 239 // -------------------------------------------------------------------------- 240 // 241 // 1) Return if the charge distribution is already succesfully fitted 242 // or if the histogram is empty 243 // 2) Cut the histograms empty edges 244 // 3) Fit the histograms with a Gaussian 245 // 4) In case of failure print out the fit results 246 // 5) Retrieve the results and store them in this class 247 // 267 248 Bool_t MHPedestalPixel::FitCharge(Option_t *option) 268 249 { … … 282 263 // 283 264 const Stat_t entries = fHPedestalCharge->Integral(); 284 const Double_t area_guess = entries/gkSq2Pi;285 265 const Double_t mu_guess = fHPedestalCharge->GetBinCenter(fHPedestalCharge->GetMaximumBin()); 286 266 const Double_t sigma_guess = mu_guess/15.; 287 288 TString name = TString("GausFit"); 289 name += fPixId; 290 291 fGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 267 const Double_t area_guess = entries/gkSq2Pi/sigma_guess; 268 269 fGausFit = new TF1(Form("%s%d","GausFit ",fPixId),"gaus",rmin,rmax); 292 270 293 271 if (!fGausFit) … … 312 290 { 313 291 314 Axis_t rtry = fGausFit->GetParameter(1) - 3.0*fGausFit->GetParameter(2);292 Axis_t rtry = fGausFit->GetParameter(1) - 2.0*fGausFit->GetParameter(2); 315 293 rmin = (rtry < rmin ? rmin : rtry); 316 rmax = fGausFit->GetParameter(1) + 3.0*fGausFit->GetParameter(2);294 rmax = fGausFit->GetParameter(1) + 2.0*fGausFit->GetParameter(2); 317 295 fGausFit->SetRange(rmin,rmax); 318 296 … … 353 331 { 354 332 355 Int_t nbins = 50;356 357 CutEdges(fHPedestalCharge,nbins);333 Int_t nbins = 30; 334 335 MH::CutEdges(fHPedestalCharge,nbins); 358 336 359 337 fChargeFirst = fHPedestalCharge->GetBinLowEdge(fHPedestalCharge->GetXaxis()->GetFirst()); 360 338 fChargeLast = fHPedestalCharge->GetBinLowEdge(fHPedestalCharge->GetXaxis()->GetLast()) 361 362 363 CutEdges(fHPedestalChargevsN,0);339 +fHPedestalCharge->GetBinWidth(0); 340 341 MH::CutEdges(fHPedestalChargevsN,0); 364 342 365 343 } … … 370 348 *fLog << all << "Pedestal Fits Pixel: " << fPixId << endl; 371 349 372 if (TESTBIT(fFlags,kFitted)) 373 { 374 375 *fLog << all << "Results of the Summed Charges Fit: " << endl; 376 *fLog << all << "Chisquare: " << fChargeChisquare << endl; 377 *fLog << all << "DoF: " << fChargeNdf << endl; 378 *fLog << all << "Probability: " << fChargeProb << endl; 379 *fLog << all << "Results of fit: " ; 380 if (TESTBIT(fFlags,kFitOK)) 381 *fLog << inf << "OK" << endl; 382 else 383 *fLog << err << "NOT OK" << endl; 384 *fLog << all << endl; 385 } 386 else 387 { 388 *fLog << all << "Pedestal Histogram has not yet been fitted" << endl; 389 *fLog << all << endl; 390 } 350 if (!TESTBIT(fFlags,kFitted)) 351 { 352 gLog << "Pedestal Histogram has not yet been fitted" << endl; 353 return; 354 } 355 356 gLog << "Results of the Summed Charges Fit: " << endl; 357 gLog << "Chisquare: " << fChargeChisquare << endl; 358 gLog << "DoF: " << fChargeNdf << endl; 359 gLog << "Probability: " << fChargeProb << endl; 360 gLog << "Results of fit: " << (TESTBIT(fFlags,kFitOK) ? "Ok.": "Not OK!") << endl; 391 361 392 362 } -
trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h
r2997 r3015 14 14 private: 15 15 16 static const Int_t gkChargeNbins; 17 static const Int_t gkChargevsNbins; 18 static const Axis_t gkChargevsNFirst; 19 static const Axis_t gkChargevsNLast; 20 static const Axis_t gkChargeFirst; 21 static const Axis_t gkChargeLast; 22 16 23 Int_t fPixId; // Pixel Nr 17 24 18 const Int_t fChargeNbins;19 25 Axis_t fChargeFirst; 20 26 Axis_t fChargeLast; 21 27 22 28 const Int_t fChargevsNbins; 23 29 const Axis_t fChargevsNFirst; … … 41 47 Byte_t fFlags; 42 48 43 enum { kFitted, kFitOK};49 enum { kFitted, kFitOK, kOscillating }; 44 50 45 51 public: 46 52 47 MHPedestalPixel( const char *name=NULL, const char *title=NULL);53 MHPedestalPixel(); 48 54 ~MHPedestalPixel(); 49 55 … … 73 79 Bool_t FillChargevsN(Float_t q); 74 80 75 Bool_t SetupFill(const MParList *pList);76 Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }77 78 81 // Fits 79 82 Bool_t FitCharge(Option_t *option="RQ0"); -
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
r3005 r3015 124 124 fNumPixels = 0; 125 125 fNumSamplesTot = 0; 126 fUseHists = kFALSE;127 126 128 127 fRawEvt = NULL; … … 160 159 161 160 fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam"); 162 163 if (!fSignals && fUseHists)164 {165 *fLog << warn << "Cannot find MExtractedSignalCam... will not use histograms!" << endl;166 fUseHists = kFALSE;167 }168 161 169 162 fNumSamplesTot=0; … … 207 200 // the other one 208 201 fNumHiGainSamples = runheader->GetNumSamplesHiGain() & ~1; 209 210 if (fUseHists)211 fPedestals->InitUseHists();212 202 213 203 return kTRUE; … … 260 250 fSumx2[idx] += msum*msum; 261 251 262 if (fUseHists)263 {264 MExtractedSignalPix &sig = (*fSignals)[idx];265 const Float_t signal = sig.GetExtractedSignalHiGain();266 (*fPedestals)[idx].FillHists(signal);267 }268 252 } 269 253 … … 290 274 while (pixel.Next()) 291 275 { 292 const UInt_t pixid = pixel.GetPixelId();276 const Int_t pixid = pixel.GetPixelId(); 293 277 294 278 const Float_t sum = fSumx.At(pixid); … … 307 291 (*fPedestals)[pixid].Set(higainped, higainrms); 308 292 309 if (fUseHists)310 (*fPedestals)[pixid].FitCharge();311 312 293 } 313 294 314 fPedestals->SetNumTotSlices(fNumSamplesTot); 315 316 if (fUseHists) 317 fPedestals->SetNumExtractSlices(fSignals->GetNumUsedHiGainFADCSlices()); 295 fPedestals->SetTotalEntries(fNumSamplesTot); 318 296 319 297 return kTRUE; -
trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc
r3007 r3015 630 630 // so that we can use it for the fit 631 631 // 632 if (fPedestals-> IsUseHists())632 if (fPedestals->GetHistSize() > fBlindPixelId) 633 633 { 634 634 // 635 635 // retrieve the pedestal pix of the blind pixel 636 636 // 637 MPedestalPix &ped = (*fPedestals)[fBlindPixelId]; 637 MHPedestalPixel &pedhist = (*fPedestals)(fBlindPixelId); 638 MPedestalPix &pedpix = (*fPedestals)[fBlindPixelId]; 638 639 // 639 640 // retrieve the histogram containers 640 641 // 641 642 MHCalibrationBlindPixel *hist = blindpixel.GetHist(); 642 MHPedestalPixel *pedhist = ped.GetHist();643 643 // 644 644 // Set the corresponding values 645 645 // 646 646 const Float_t nslices = (Float_t)fSignals->GetNumUsedFADCSlices(); 647 const Int_t nentries = pedhist->GetTotalEntries(); 648 649 const Float_t peddiff = ped.GetMean() - ped.GetPedestal()*nslices; 650 651 Float_t pederr = ped.GetMeanErr()*ped.GetMeanErr(); 652 pederr += ped.GetPedestalRms()*ped.GetPedestalRms()*nslices*nslices/nentries/nentries; 653 pederr = TMath::Sqrt(pederr); 654 655 const Float_t pedsigma = ped.GetSigma(); 656 const Float_t pedsigmaerr = ped.GetSigmaErr(); 647 const ULong_t nentries = fPedestals->GetTotalEntries(); 648 649 const Float_t peddiff = (pedhist.GetChargeMean()-pedpix.GetPedestal())*nslices; 650 651 const Float_t sqrslice = TMath::Sqrt(nslices); 652 653 Float_t pederr = pedhist.GetChargeMeanErr()*pedhist.GetChargeMeanErr(); 654 pederr += pedpix.GetPedestalRms()*pedpix.GetPedestalRms()/nentries; 655 pederr = TMath::Sqrt(pederr)*sqrslice; 656 657 const Float_t pedsigma = pedhist.GetChargeSigma()*sqrslice; 658 const Float_t pedsigmaerr = pedhist.GetChargeSigmaErr()*sqrslice; 657 659 658 660 hist->SetMeanPedestal(peddiff);
Note:
See TracChangeset
for help on using the changeset viewer.