Changeset 3015 for trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.cc
- Timestamp:
- 02/04/04 15:03:44 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.