- Timestamp:
- 12/04/03 12:17:22 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2596 r2599 4 4 5 5 -*-*- END OF LINE -*-*- 6 2003/12/04: Markus Gaug 7 8 * manalysis/MCalibration* 9 - implemented some of Thomas Bretz suggestions to make the code nicer 10 - implemented the possibility to have cosmics in the calibration data 11 and still fit it 12 - conversion HiGain/LoGain now left out (it seems to be already done in 13 the data) 14 15 * mhist/MHCalibration* 16 - implemented some of Thomas Bretz suggestions to make the code nicer 17 - implemented the possibility to have cosmics in the calibration data 18 and still fit it 19 20 * macros/calibration.C 21 - MStatusDisplay of calibration histograms a little bit more readable 22 6 23 2003/12/03: Abelardo Moralejo 7 24 -
trunk/MagicSoft/Mars/macros/calibration.C
r2581 r2599 62 62 tlist.AddToList(&fill); 63 63 64 MStatusDisplay *d1 = new MStatusDisplay;64 // MStatusDisplay *d1 = new MStatusDisplay; 65 65 66 66 // Set update time to 3s 67 d1->SetUpdateTime(3000);67 // d1->SetUpdateTime(3000); 68 68 69 69 // … … 72 72 MEvtLoop evtloop; 73 73 evtloop.SetParList(&plist); 74 evtloop.SetDisplay(d1);74 // evtloop.SetDisplay(d1); 75 75 76 76 // … … 82 82 tlist.PrintStatistics(); 83 83 84 MPedestalCam *ped = plist.FindObject("MPedestalCam");85 ped.Print();86 84 87 85 // … … 122 120 123 121 MHCamEvent hist2; 124 hist2.SetType( 0);122 hist2.SetType(8); 125 123 plist2.AddToList(&hist2); 126 124 MFillH fill2("MHCamEvent", "MCalibrationCam"); … … 145 143 // 146 144 MCalibrationCam *cam = plist2.FindObject("MCalibrationCam"); 147 MCalibrationPix *pix = cam->GetCalibrationPix(523); 148 pix->Draw(); 149 145 cam.Print(); 146 147 Int_t pixnr; 148 149 while (1) 150 { 151 152 cout << "Which pixel number do you want to display? (Press 0 to exit)" << endl; 153 cin >> pixnr; 154 if (pixnr == 0) 155 break; 156 157 if (pixnr >= 577) 158 break; 159 160 MCalibrationPix *pix = cam->GetCalibrationPix(pixnr); 161 pix->Draw(); 162 163 } 164 150 165 // 151 166 // Here we are confronted to a serious bug in ROOT: … … 170 185 MHCamera disp11 (geomcam, "MCalibrationCam;rq", "Reduced Charges"); 171 186 MHCamera disp12 (geomcam, "MCalibrationCam;errrq", "Error of Reduced Charges"); 187 MHCamera disp13 (geomcam, "MCalibrationCam;phe", "Nr. of Phe's (F-Factor Method)"); 188 MHCamera disp14 (geomcam, "MCalibrationCam;convphe", "Conversion Factor (F-Factor Method)"); 172 189 173 190 disp1.SetCamContent(*cam, 0); … … 183 200 disp11.SetCamContent(*cam, 10); 184 201 disp12.SetCamContent(*cam, 11); 202 disp12.SetCamContent(*cam, 12); 203 disp13.SetCamContent(*cam, 13); 185 204 186 205 disp1.SetYTitle("Q [FADC counts]"); … … 196 215 disp11.SetYTitle("Q [FADC counts]"); 197 216 disp12.SetYTitle("\\Delta_{Q} [FADC counts]"); 217 disp13.SetYTitle("Nr Phe's"); 218 disp14.SetYTitle("Conversion Factor [Phe/FADC count]"); 198 219 199 220 MStatusDisplay *d2 = new MStatusDisplay; … … 202 223 d2->SetUpdateTime(1000); 203 224 204 TCanvas *c1 = &d2->AddTab(" Fitted Charges");205 c1->Divide( 5, 2);225 TCanvas *c1 = &d2->AddTab("Charges Mean"); 226 c1->Divide(2, 2); 206 227 207 228 TObject *obj; … … 211 232 obj=disp1.DrawCopy("hist"); 212 233 213 c1->cd( 6);234 c1->cd(3); 214 235 gPad->SetBorderMode(0); 215 236 obj->Draw(); … … 219 240 obj=disp2.DrawCopy("hist"); 220 241 221 c1->cd(7); 222 gPad->SetBorderMode(0); 223 obj->Draw(); 224 225 c1->cd(3); 242 c1->cd(4); 243 gPad->SetBorderMode(0); 244 obj->Draw(); 245 246 TCanvas *c11 = &d2->AddTab("Charges Sigma"); 247 c11->Divide(2, 2); 248 249 c11->cd(1); 226 250 gStyle->SetOptStat(1101); 227 251 obj=disp3.DrawCopy("hist"); 228 252 229 c1 ->cd(8);230 gPad->SetBorderMode(0); 231 obj->Draw(); 232 233 c1 ->cd(4);253 c11->cd(3); 254 gPad->SetBorderMode(0); 255 obj->Draw(); 256 257 c11->cd(2); 234 258 gStyle->SetOptStat(1101); 235 259 obj=disp4.DrawCopy("hist"); 236 260 237 c1->cd(9); 238 gPad->SetBorderMode(0); 239 obj->Draw(); 240 241 c1->cd(5); 261 c11->cd(4); 262 gPad->SetBorderMode(0); 263 obj->Draw(); 264 265 266 TCanvas *c12 = &d2->AddTab("Fit Prob."); 267 c12->Divide(1, 2); 268 269 c12->cd(1); 242 270 gStyle->SetOptStat(1101); 243 271 obj=disp5.DrawCopy("hist"); 244 272 245 c1 ->cd(10);273 c12->cd(2); 246 274 gPad->SetBorderMode(0); 247 275 obj->Draw(); … … 282 310 283 311 c3->cd(2); 284 gStyle->SetOptStat(11 01);312 gStyle->SetOptStat(1111); 285 313 obj=disp10.DrawCopy("hist"); 286 314 … … 305 333 obj->Draw(); 306 334 335 TCanvas *c5 = &d2->AddTab("F-Factor Method"); 336 c5->Divide(2, 2); 337 338 c5->cd(1); 339 gStyle->SetOptStat(1111); 340 obj=disp13.DrawCopy("hist"); 341 342 c5->cd(3); 343 obj->Draw(); 344 345 c5->cd(2); 346 gStyle->SetOptStat(1101); 347 obj=disp14.DrawCopy("hist"); 348 349 c5->cd(4); 350 obj->Draw(); 351 352 307 353 #endif 308 354 -
trunk/MagicSoft/Mars/manalysis/MCalibrationBlindPix.h
r2525 r2599 51 51 Float_t GetErrT() const { return fErrT; } 52 52 53 Bool_t FillQ(Int_t q) { return fHist->FillB PQ(q); }54 Bool_t FillT(Int_t t) { return fHist->FillB PT(t); }55 Bool_t FillRQvsT(Float_t rq, Int_t t) { return fHist->FillB PQvsN(rq,t); }53 Bool_t FillQ(Int_t q) { return fHist->FillBlindPixelQ(q); } 54 Bool_t FillT(Int_t t) { return fHist->FillBlindPixelT(t); } 55 Bool_t FillRQvsT(Float_t rq, Int_t t) { return fHist->FillBlindPixelQvsN(rq,t); } 56 56 57 57 Bool_t IsValid() { return fLambda > 0. || fErrLambda > 0.; } -
trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc
r2581 r2599 163 163 } 164 164 165 //166 // fRawEvt->GetNumPixels() does not work !!!!!!!!!!167 //168 fCalibrations->InitSize(577);169 165 170 166 switch (fColor) … … 189 185 } 190 186 191 192 // MTime does not work!!!!193 194 // fEvtTime = (MTime*)pList->FindObject("MRawEvtTime");195 // if (!fEvtTime)196 // {197 // *fLog << dbginf << "MTime could not be created ... ¡!¡!¡!¡!" << endl;198 // }199 200 // fEvtTime->SetTime(0.);201 202 187 203 188 return kTRUE; … … 222 207 fNumHiGainSamples = fRunHeader->GetNumSamplesHiGain(); 223 208 fNumLoGainSamples = fRunHeader->GetNumSamplesLoGain(); 224 209 210 // 211 // FIXME: The next statement simply does not work: 212 // fRawEvt->GetNumPixels() returns always 0 213 // fCalibrations->InitSize(fRawEvt->GetNumPixels()); 214 // 215 216 fCalibrations->InitSize(577); 217 218 for (Int_t i=0;i<577;i++) 219 { 220 MCalibrationPix &pix = (*fCalibrations)[i]; 221 pix.ChangePixId(i); 222 } 223 225 224 return kTRUE; 226 225 … … 238 237 fEvents++; 239 238 240 Bool_t cosmic = kFALSE;239 Int_t cosmicpix = 0; 241 240 242 241 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel()); … … 251 250 const Int_t pixid = pixel.GetPixelId(); 252 251 253 if (!fCalibrations->IsPixelUsed(pixid))254 if (!fCalibrations->AddPixel(pixid))255 *fLog << err << dbginf << "MCalibrationPix(" << pixid << ") could not be created !!" << endl;256 257 252 Byte_t *ptr = pixel.GetHiGainSamples(); 258 253 Byte_t mid = pixel.GetIdxMaxHiGainSample(); … … 270 265 mid = pixel.GetIdxMaxLoGainSample(); 271 266 272 sum = (max == gkSaturationLimit // overflow of LoGain ??? -> GimmeABreak!!! 273 ? fHistOverFlow++, gkLoGainOverFlow // OUCH (Florian was maybe right) 274 : sum*gkConversionHiLo ); // OUFF (Florian was wrong) !! 275 276 // *fLog << warn << "Warning: Saturation of HiGain reached in slice " << (int)mid << " !!! " << endl; 277 // *fLog << warn << "Max = " << max << endl; 267 // 268 // FIXME: It seems the conversion HiGain LoGain is already 269 // performed in the data?!? 270 // 271 sum = (max > gkSaturationLimit // overflow of LoGain ??? -> GimmeABreak!!! 272 ? fHistOverFlow++, gkLoGainOverFlow // OUCH (Florian was maybe right) 273 : sum ); // OUFF (Florian was wrong) !! 274 // : sum*gkConversionHiLo ); // OUFF (Florian was wrong) !! 278 275 279 276 if (fHistOverFlow) … … 282 279 283 280 } 284 285 281 286 282 MPedestalPix &ped = (*fPedestals)[pixid]; … … 298 294 299 295 // 300 // This is a very primitive check for the number of cosmic s296 // This is a very primitive check for the number of cosmicpixs 301 297 // The cut will be applied in the fit, but for the blind pixel, 302 298 // we need to remove this event … … 305 301 // 306 302 307 if ((float)sum < pedes+ 5.*pedrms)308 cosmic = kTRUE;303 if ((float)sum < pedes+4.*pedrms) 304 cosmicpix++; 309 305 310 306 Float_t rsum = (float)sum - pedes; … … 314 310 315 311 case gkCalibrationBlindPixelId: 312 316 313 // 317 314 // FIXME: This works only when the blind pixel ID is much larger than 318 315 // the rest of the pixels (which is the case right now) 319 316 // 320 // if (!cosmic) 321 if (!blindpixel.FillQ(sum)) 317 if (cosmicpix < 100.) 318 { 319 if (!blindpixel.FillQ(sum)) 322 320 *fLog << warn << 323 "Overflow or Underflow occurred filling Blind Pixel sum = " << sum << endl; 324 325 if (!blindpixel.FillT((int)mid)) 326 *fLog << warn << 327 "Overflow or Underflow occurred filling Blind Pixel time = " << (int)mid << endl; 328 329 if (!blindpixel.FillRQvsT(rsum,fEvents)) 330 *fLog << warn << 331 "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl; 332 321 "Overflow or Underflow occurred filling Blind Pixel sum = " << sum << endl; 322 323 if (!blindpixel.FillT((int)mid)) 324 *fLog << warn << 325 "Overflow or Underflow occurred filling Blind Pixel time = " << (int)mid << endl; 326 327 if (!blindpixel.FillRQvsT(rsum,fEvents)) 328 *fLog << warn << 329 "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl; 330 } 331 333 332 case gkCalibrationPINDiodeId: 334 333 if (!pindiode.FillQ(sum)) … … 364 363 } /* while (pixel.Next()) */ 365 364 366 if (cosmic )365 if (cosmicpix > 300.) 367 366 fCosmics++; 368 367 369 fCalibrations->SetReadyToSave();370 371 368 return kTRUE; 372 369 } … … 405 402 406 403 *fLog << GetDescriptor() << " Fitting the Normal Pixels" << endl; 404 407 405 // 408 406 // loop over the pedestal events and check if we have calibration … … 411 409 { 412 410 413 if (fCalibrations->IsPixelUsed(pixid)) 414 { 415 416 MCalibrationPix &pix = (*fCalibrations)[pixid]; 417 418 const Float_t ped = (*fPedestals)[pixid].GetPedestal() * fNumHiGainSamples; 419 const Float_t prms = (*fPedestals)[pixid].GetPedestalRms() * fNumHiGainSamples; 420 421 pix.SetPedestal(ped,prms); 422 423 if (TESTBIT(fFlags,kUseTFits)) 424 pix.FitT(); 425 426 if (!pix.FitQ()) 427 continue; 428 429 } 411 MCalibrationPix &pix = (*fCalibrations)[pixid]; 412 413 const Float_t ped = (*fPedestals)[pixid].GetPedestal() * fNumHiGainSamples; 414 const Float_t prms = (*fPedestals)[pixid].GetPedestalRms() * fNumHiGainSamples; 415 416 pix.SetPedestal(ped,prms); 417 418 if (TESTBIT(fFlags,kUseTFits)) 419 pix.FitT(); 420 421 pix.FitQ(); 430 422 } 431 423 -
trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc
r2582 r2599 61 61 fTitle = title ? title : "Storage container for the Calibration Information in the camera"; 62 62 63 fPixels = new TClonesArray("MCalibrationPix", 0);63 fPixels = new TClonesArray("MCalibrationPix",1); 64 64 fBlindPixel = new MCalibrationBlindPix(); 65 65 fPINDiode = new MCalibrationPINDiode(); … … 92 92 93 93 // 94 // Here it is important to use GetEntriesFast, 95 // We get the array index of the last "filled" fPixel entry 96 // (Not the number of "filled" fPixels!!) 94 // Here we get the number of "filled" fPixels!! 97 95 // 98 96 return fPixels->GetEntriesFast(); … … 116 114 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i)); 117 115 } 118 119 Bool_t MCalibrationCam::AddPixel(Int_t idx)120 {121 122 //123 // Check bounds first124 //125 if (!CheckBounds(idx))126 InitSize(idx);127 128 //129 // in case, new cannot allocate memory,130 // return FALSE131 //132 return (new ((*fPixels)[idx]) MCalibrationPix(idx));133 134 }135 136 116 137 117 // -------------------------------------------------------------------------- … … 173 153 Bool_t MCalibrationCam::IsPixelFitted(Int_t idx) const 174 154 { 175 if (!IsPixelUsed(idx))176 return kFALSE;177 178 155 return ((*this)[idx].GetRQ() > 0. && (*this)[idx].GetErrRQ() > 0.); 179 156 } … … 208 185 { 209 186 210 Int_t id = 0;211 212 187 TIter Next(fPixels); 213 188 MCalibrationPix *pix; 214 189 while ((pix=(MCalibrationPix*)Next())) 215 190 { 216 if (!IsPixelUsed(id++))217 continue;218 191 if (pix->FitQ()) 219 192 nsuccess++; … … 222 195 else // fit only the pixel with index i 223 196 { 224 if (!IsPixelUsed(i))225 return 0;226 197 if((*this)[i].FitQ()) 227 198 nsuccess++; … … 247 218 UShort_t nsuccess = 0; 248 219 249 Int_t id = 0;250 251 220 TIter Next(fPixels); 252 221 MCalibrationPix *pix; 253 222 while ((pix=(MCalibrationPix*)Next())) 254 223 { 255 if (!IsPixelUsed(id++))256 continue;257 224 if (pix->FitQ()) 258 225 nsuccess++; … … 293 260 { 294 261 295 Int_t id = 0;296 297 262 TIter Next(fPixels); 298 263 MCalibrationPix *pix; 299 264 while ((pix=(MCalibrationPix*)Next())) 300 265 { 301 if (!IsPixelUsed(id++)) 302 continue; 303 if (pix->FitT()) 266 if (pix->FitT()) 304 267 nsuccess++; 305 268 } … … 331 294 UShort_t nsuccess = 0; 332 295 333 Int_t id = 0;334 335 296 TIter Next(fPixels); 336 297 MCalibrationPix *pix; 337 298 while ((pix=(MCalibrationPix*)Next())) 338 299 { 339 if (!IsPixelUsed(id++))340 continue;341 300 if (pix->FitT()) 342 301 nsuccess++; … … 391 350 // we want to keep all pixel not used with a NULL pointer. 392 351 // 393 fPixels->Expand(size); 394 // 395 // Set all entries to the null pointer. 396 // Later we fill the array per pixId with the contruction: new (fPixels[i]) MCalibrationPix(pixid) 397 // To check, if pixels is already filled, we test the NULL pointer (see IsPixelUsed) 398 // 399 for (Int_t i=0; i< size; i++) 400 { 401 MCalibrationPix *pix = &(*this)[i]; 402 pix = NULL; 403 } 352 fPixels->ExpandCreate(size); 353 404 354 } 405 355 … … 413 363 while ((pix=(MCalibrationPix*)Next())) 414 364 { 415 if (!IsPixelUsed(id)) 416 continue; 417 418 *fLog << id << ": "; 365 366 *fLog << id << ": " << pix->GetPed() << " " << pix->GetPedRms() << " Charges: " ; 419 367 *fLog << pix->GetQ() << " " << pix->GetRQ() << endl; 420 368 … … 426 374 Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const 427 375 { 428 429 if (!IsPixelFitted(idx))430 return kFALSE;431 376 432 377 switch (type) … … 468 413 val = (*this)[idx].GetErrRQ(); 469 414 break; 415 case 12: 416 val = (*this)[idx].GetPheFFactorMethod(); 417 break; 418 case 13: 419 val = (*this)[idx].GetConversionFFactorMethod(); 420 break; 470 421 default: 471 422 return kFALSE; … … 474 425 } 475 426 476 void MCalibrationCam::DrawPixelContent(Int_t num) const 477 { 478 *fLog << warn << "MCalibrationCam::DrawPixelContent - not available." << endl; 427 void MCalibrationCam::DrawPixelContent(Int_t idx) const 428 { 429 430 (*this)[idx].Draw(); 431 479 432 } 480 433 -
trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h
r2525 r2599 77 77 Bool_t CheckBounds(Int_t i) const; 78 78 79 Bool_t AddPixel(Int_t idx);80 81 79 void Print(Option_t *o="") const; 82 80 -
trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc
r2581 r2599 40 40 using namespace std; 41 41 42 static const TString gsDefHTitle = "Calibration Histograms Pixel ";43 42 // -------------------------------------------------------------------------- 44 43 // 45 44 // Default Constructor. 46 45 // 47 MCalibrationPix::MCalibrationPix(Int_t pix, const char *name, const char *title) 48 : fPixId(pix) 46 MCalibrationPix::MCalibrationPix(const char *name, const char *title) 47 : fPixId(-1), 48 fQ(-1.), 49 fErrQ(-1.), 50 fSigmaQ(-1.), 51 fErrSigmaQ(-1.), 52 fQProb(-1.), 53 fPed(-1.), 54 fPedRms(-1.), 55 fT(-1.), 56 fSigmaT(-1.), 57 fTProb(-1.), 58 fRQ(-1.), 59 fErrRQ(-1.), 60 fFactor(1.3), 61 fPheFFactorMethod(-1.), 62 fConversionFFactorMethod(-1.) 49 63 { 50 64 … … 52 66 fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results"; 53 67 54 fHist = new MHCalibrationPixel(fPixId,"MHCalibrationPixel",gsDefHTitle.Data()+fPixId); 55 56 fQ = fErrQ = 0.; 57 fPed = fPedRms = 0.; 58 fT = fSigmaT = 0.; 59 fRQ = fErrRQ = 0.; 60 fSigmaQ = fErrSigmaQ = 0.; 61 fQProb = 0.; 62 68 fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel"); 63 69 } 64 70 … … 67 73 delete fHist; 68 74 } 75 76 77 void MCalibrationPix::ChangePixId(Int_t i) 78 { 79 80 fPixId = i; 81 fHist->ChangeHistId(i); 82 83 } 84 69 85 70 86 // ------------------------------------------------------------------------ … … 84 100 85 101 if (fPed && fPedRms) 86 fHist->SetLowerFitRange(fPed + 3.5*fPedRms);102 fHist->SetLowerFitRange(fPed + 2.0*fPedRms); 87 103 else 88 104 *fLog << warn << "Cannot set lower fit range to suppress cosmics: Pedestals not available" << endl; … … 101 117 fQProb = fHist->GetQProb(); 102 118 103 if (fPed) 119 if ((fPed > 0.) && (fPedRms > 0.)) 120 { 121 104 122 fRQ = fQ - fPed; 105 if (fPedRms)106 123 fErrRQ = TMath::Sqrt(fErrQ*fErrQ + fPedRms*fPedRms); 107 124 125 fPheFFactorMethod = 126 fFactor 127 * fRQ * fRQ 128 / (fSigmaQ * fSigmaQ - fPedRms*fPedRms) ; 129 130 fConversionFFactorMethod = fPheFFactorMethod / fRQ ; 131 132 } 108 133 109 134 return kTRUE; … … 142 167 } 143 168 144 void MCalibrationPix::Test()145 {146 *fLog << "TEST: pixid: " << fPixId << endl;147 } -
trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h
r2544 r2599 12 12 private: 13 13 14 //15 // FIXME: Derive class from MCerphotPix ??16 //17 14 Int_t fPixId; // the pixel Id 18 15 … … 32 29 Float_t fRQ; // The reduced mean charge after the fit 33 30 Float_t fErrRQ; // The error of the reduced mean charge after the fit 34 31 32 Float_t fFactor; // The F-factor 33 Float_t fPheFFactorMethod; // The number of Phe's calculated after the F-factor method 34 Float_t fConversionFFactorMethod; // The conversion factor to Phe's calculated after the F-factor method 35 35 36 MHCalibrationPixel *fHist; // Pointer to the histograms performing the fits, etc. 36 37 37 38 public: 38 39 39 MCalibrationPix( Int_t pix=-1,const char *name=NULL, const char *title=NULL);40 MCalibrationPix(const char *name=NULL, const char *title=NULL); 40 41 ~MCalibrationPix(); 41 42 … … 66 67 Bool_t IsValid() const { return fRQ >=0 || fErrRQ >= 0; } 67 68 Int_t GetPixId() const { return fPixId; } 68 69 void ChangePixId(Int_t i); 70 69 71 Bool_t FitQ(); 70 72 Bool_t FitT(); … … 73 75 virtual void Draw(Option_t *opt="") { fHist->Draw(opt); } 74 76 75 void Test(); 76 77 Float_t GetPheFFactorMethod() const { return fPheFFactorMethod; } 78 Float_t GetConversionFFactorMethod() const { return fConversionFFactorMethod; } 79 77 80 ClassDef(MCalibrationPix, 1) // Storage Container for Calibration information of one pixel 78 81 }; -
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
r2536 r2599 60 60 61 61 AddToBranchList("fHiGainPixId"); 62 //AddToBranchList("fLoGainPixId");63 62 AddToBranchList("fHiGainFadcSamples"); 64 //AddToBranchList("fLoGainFadcSamples");65 63 } 66 64 … … 98 96 fNumHiGainSamples = fRunheader->GetNumSamplesHiGain(); 99 97 98 fPedestals->InitSize(fRunheader->GetNumPixel()); 99 100 100 return kTRUE; 101 101 … … 105 105 Int_t MPedCalcPedRun::Process() 106 106 { 107 107 108 MRawEvtPixelIter pixel(fRawEvt); 108 109 109 110 while (pixel.Next()) 110 111 { 111 112 Byte_t *ptr = pixel.GetHiGainSamples(); 112 113 const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples(); 113 114 … … 115 116 const Float_t higainrms = CalcHiGainRms(ptr, end, higainped); 116 117 117 //const Float_t higainpederr = CalcHiGainMeanErr(higainrms);118 //const Float_t higainrmserr = CalcHiGainRmsErr(higainrms);119 120 118 const UInt_t pixid = pixel.GetPixelId(); 121 119 MPedestalPix &pix = (*fPedestals)[pixid]; 122 120 123 121 pix.Set(higainped, higainrms); 124 //pix.SetPedestalRms(higainpederr, higainrmserr); 122 125 123 } 126 124 -
trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.cc
r2525 r2599 69 69 70 70 // Create a large number of bins, later we will rebin 71 fB PQfirst = 0;72 fB PQlast = gkStartBlindPixelBinNr;73 fB PQnbins = gkStartBlindPixelBinNr;74 75 fHB PQ = new TH1I("HBPQ","Distribution of Summed FADC Slices",fBPQnbins,fBPQfirst,fBPQlast);76 fHB PQ->SetXTitle("Sum FADC Slices");77 fHB PQ->SetYTitle("Nr. of events");78 fHB PQ->Sumw2();79 80 fErrB PQfirst = 0.;81 fErrB PQlast = gkStartBlindPixelBinNr;82 fErrB PQnbins = gkStartBlindPixelBinNr;83 84 fHB PErrQ = new TH1F("HBPErrQ","Distribution of Variances of Summed FADC Slices",85 fErrB PQnbins,fErrBPQfirst,fErrBPQlast);86 fHB PErrQ->SetXTitle("Variance Summed FADC Slices");87 fHB PErrQ->SetYTitle("Nr. of events");88 fHB PErrQ->Sumw2();71 fBlindPixelQfirst = 0; 72 fBlindPixelQlast = gkStartBlindPixelBinNr; 73 fBlindPixelQnbins = gkStartBlindPixelBinNr; 74 75 fHBlindPixelQ = new TH1I("HBlindPixelQ","Distribution of Summed FADC Slices",fBlindPixelQnbins,fBlindPixelQfirst,fBlindPixelQlast); 76 fHBlindPixelQ->SetXTitle("Sum FADC Slices"); 77 fHBlindPixelQ->SetYTitle("Nr. of events"); 78 fHBlindPixelQ->Sumw2(); 79 80 fErrBlindPixelQfirst = 0.; 81 fErrBlindPixelQlast = gkStartBlindPixelBinNr; 82 fErrBlindPixelQnbins = gkStartBlindPixelBinNr; 83 84 fHBlindPixelErrQ = new TH1F("HBlindPixelErrQ","Distribution of Variances of Summed FADC Slices", 85 fErrBlindPixelQnbins,fErrBlindPixelQfirst,fErrBlindPixelQlast); 86 fHBlindPixelErrQ->SetXTitle("Variance Summed FADC Slices"); 87 fHBlindPixelErrQ->SetYTitle("Nr. of events"); 88 fHBlindPixelErrQ->Sumw2(); 89 89 90 90 Axis_t tfirst = -0.5; … … 92 92 Int_t nbins = 16; 93 93 94 fHB PT = new TH1I("HBPT","Distribution of Mean Arrival Times",nbins,tfirst,tlast);95 fHB PT->SetXTitle("Mean Arrival Times [FADC slice nr]");96 fHB PT->SetYTitle("Nr. of events");97 fHB PT->Sumw2();94 fHBlindPixelT = new TH1I("HBlindPixelT","Distribution of Mean Arrival Times",nbins,tfirst,tlast); 95 fHBlindPixelT->SetXTitle("Mean Arrival Times [FADC slice nr]"); 96 fHBlindPixelT->SetYTitle("Nr. of events"); 97 fHBlindPixelT->Sumw2(); 98 98 99 99 // We define a reasonable number and later enlarge it if necessary … … 102 102 Axis_t nlast = (Axis_t)nbins - 0.5; 103 103 104 fHB PQvsN = new TH1I("HBPQvsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast);105 fHB PQvsN->SetXTitle("Event Nr.");106 fHB PQvsN->SetYTitle("Sum of FADC slices");104 fHBlindPixelQvsN = new TH1I("HBlindPixelQvsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast); 105 fHBlindPixelQvsN->SetXTitle("Event Nr."); 106 fHBlindPixelQvsN->SetYTitle("Sum of FADC slices"); 107 107 108 108 fgSinglePheFitFunc = &gfKto8; … … 113 113 { 114 114 115 delete fHB PQ;116 delete fHB PT;117 delete fHB PErrQ;115 delete fHBlindPixelQ; 116 delete fHBlindPixelT; 117 delete fHBlindPixelErrQ; 118 118 119 119 if (fSinglePheFit) … … 127 127 void MHCalibrationBlindPixel::ResetBin(Int_t i) 128 128 { 129 fHB PQ->SetBinContent (i, 1.e-20);130 fHB PErrQ->SetBinContent (i, 1.e-20);131 fHB PT->SetBinContent(i, 1.e-20);129 fHBlindPixelQ->SetBinContent (i, 1.e-20); 130 fHBlindPixelErrQ->SetBinContent (i, 1.e-20); 131 fHBlindPixelT->SetBinContent(i, 1.e-20); 132 132 } 133 133 … … 209 209 gPad->SetTicks(); 210 210 211 fHB PQ->DrawCopy(opt);211 fHBlindPixelQ->DrawCopy(opt); 212 212 213 213 if (fSinglePheFit) … … 231 231 gPad->SetLogy(1); 232 232 gPad->SetBorderMode(0); 233 fHB PT->DrawCopy(opt);234 235 if (fHB PT->GetFunction("GausTime"))233 fHBlindPixelT->DrawCopy(opt); 234 235 if (fHBlindPixelT->GetFunction("GausTime")) 236 236 { 237 TF1 *tfit = fHB PT->GetFunction("GausTime");237 TF1 *tfit = fHBlindPixelT->GetFunction("GausTime"); 238 238 if (tfit->GetProb() < 0.01) 239 239 tfit->SetLineColor(kRed); … … 248 248 c->cd(4); 249 249 250 fHB PQvsN->DrawCopy(opt);250 fHBlindPixelQvsN->DrawCopy(opt); 251 251 252 252 c->Modified(); … … 260 260 gRandom->SetSeed(); 261 261 262 if (fHB PQ->GetEntries() != 0)262 if (fHBlindPixelQ->GetEntries() != 0) 263 263 { 264 *fLog << err << "Histogram " << fHB PQ->GetTitle() << " is already filled. " << endl;264 *fLog << err << "Histogram " << fHBlindPixelQ->GetTitle() << " is already filled. " << endl; 265 265 *fLog << err << "Create new class MHCalibrationBlindPixel for simulation! " << endl; 266 266 return kFALSE; … … 268 268 269 269 TF1 *simulateSinglePhe = new TF1("simulateSinglePhe",fgSinglePheFitFunc, 270 fB PQfirst,fBPQlast,fgSinglePheFitNPar);270 fBlindPixelQfirst,fBlindPixelQlast,fgSinglePheFitNPar); 271 271 272 272 simulateSinglePhe->SetParameters(lambda,mu0,mu1,sigma0,sigma1); 273 273 simulateSinglePhe->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1"); 274 simulateSinglePhe->SetNpx(fB PQnbins);274 simulateSinglePhe->SetNpx(fBlindPixelQnbins); 275 275 276 276 for (Int_t i=0;i<10000; i++) 277 277 { 278 fHB PQ->Fill(simulateSinglePhe->GetRandom());278 fHBlindPixelQ->Fill(simulateSinglePhe->GetRandom()); 279 279 } 280 280 … … 283 283 284 284 285 void MHCalibrationBlindPixel::ChangeFitFunc(B PFitFunc fitfunc, Int_t par)285 void MHCalibrationBlindPixel::ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par) 286 286 { 287 287 … … 303 303 // Get the fitting ranges 304 304 // 305 rmin = (rmin != 0.) ? rmin : fB PQfirst;306 rmax = (rmax != 0.) ? rmax : fB PQlast;305 rmin = (rmin != 0.) ? rmin : fBlindPixelQfirst; 306 rmax = (rmax != 0.) ? rmax : fBlindPixelQlast; 307 307 308 308 // … … 310 310 // otherwise the fit goes gaga because of high number of dimensions ... 311 311 // 312 const Stat_t entries = fHB PQ->GetSumOfWeights();312 const Stat_t entries = fHBlindPixelQ->GetSumOfWeights(); 313 313 const Double_t lambda_guess = 0.2; 314 const Double_t mu_0_guess = fHB PQ->GetBinCenter(fHBPQ->GetMaximumBin());315 const Double_t si_0_guess = mu_0_guess/ 500.;316 const Double_t mu_1_guess = mu_0_guess + 2.;314 const Double_t mu_0_guess = fHBlindPixelQ->GetBinCenter(fHBlindPixelQ->GetMaximumBin()); 315 const Double_t si_0_guess = mu_0_guess/10.; 316 const Double_t mu_1_guess = mu_0_guess + 50.; 317 317 const Double_t si_1_guess = si_0_guess + si_0_guess; 318 318 … … 325 325 fSinglePheFit->SetParLimits(3,1.0,rmax-rmin); 326 326 fSinglePheFit->SetParLimits(4,1.7,rmax-rmin); 327 fSinglePheFit->SetParLimits(5,0.,2. *entries);327 fSinglePheFit->SetParLimits(5,0.,2.5*entries); 328 328 // 329 329 // Normalize the histogram to facilitate faster fitting of the area … … 333 333 // ROOT gives us another nice example of user-unfriendly behavior: 334 334 // Although the normalization of the function fSinglePhe and the 335 // Histogram fHB PQ agree (!!), the fit does not normalize correctly INTERNALLY335 // Histogram fHBlindPixelQ agree (!!), the fit does not normalize correctly INTERNALLY 336 336 // in the fitting procedure !!! 337 337 // … … 342 342 // So, WE have to adapt to that internal flaw of ROOT: 343 343 // 344 const Int_t npx = fSinglePheFit->GetNpx();345 const Int_t bins = fHBPQ->GetXaxis()->GetLast()-fHBPQ->GetXaxis()->GetFirst();346 // fHB PQ->Scale(gkSq2Pi*(float)bins/npx/entries);344 // const Int_t npx = fSinglePheFit->GetNpx(); 345 // const Int_t bins = fHBlindPixelQ->GetXaxis()->GetLast()-fHBlindPixelQ->GetXaxis()->GetFirst(); 346 // fHBlindPixelQ->Scale(gkSq2Pi*(float)bins/npx/entries); 347 347 348 348 // … … 353 353 // fSinglePheFit->SetNpx(fQnbins); 354 354 355 fHB PQ->Fit("SinglePheFit",opt);355 fHBlindPixelQ->Fit(fSinglePheFit,opt); 356 356 357 357 fLambda = fSinglePheFit->GetParameter(0); … … 403 403 // If you find another solution which WORKS!!, please tell me!! 404 404 // 405 Int_t nbins = 100;406 407 *fLog << "New number of bins in HSinQ: " << CutEdges(fHB PQ,nbins) << endl;408 409 fB PQfirst = fHBPQ->GetBinLowEdge(fHBPQ->GetXaxis()->GetFirst());410 fB PQlast = fHBPQ->GetBinLowEdge(fHBPQ->GetXaxis()->GetLast())+fHBPQ->GetBinWidth(0);411 fB PQnbins = nbins;412 413 *fLog << "New number of bins in HErrQ: " << CutEdges(fHB PErrQ,30) << endl;414 fErrB PQfirst = fHBPErrQ->GetBinLowEdge(fHBPErrQ->GetXaxis()->GetFirst());415 fErrB PQlast = fHBPErrQ->GetBinLowEdge(fHBPErrQ->GetXaxis()->GetLast())+fHBPErrQ->GetBinWidth(0);416 fErrB PQnbins = nbins;417 418 CutEdges(fHB PQvsN,0);405 Int_t nbins = 50; 406 407 *fLog << "New number of bins in HSinQ: " << CutEdges(fHBlindPixelQ,nbins) << endl; 408 409 fBlindPixelQfirst = fHBlindPixelQ->GetBinLowEdge(fHBlindPixelQ->GetXaxis()->GetFirst()); 410 fBlindPixelQlast = fHBlindPixelQ->GetBinLowEdge(fHBlindPixelQ->GetXaxis()->GetLast())+fHBlindPixelQ->GetBinWidth(0); 411 fBlindPixelQnbins = nbins; 412 413 *fLog << "New number of bins in HErrQ: " << CutEdges(fHBlindPixelErrQ,30) << endl; 414 fErrBlindPixelQfirst = fHBlindPixelErrQ->GetBinLowEdge(fHBlindPixelErrQ->GetXaxis()->GetFirst()); 415 fErrBlindPixelQlast = fHBlindPixelErrQ->GetBinLowEdge(fHBlindPixelErrQ->GetXaxis()->GetLast())+fHBlindPixelErrQ->GetBinWidth(0); 416 fErrBlindPixelQnbins = nbins; 417 418 CutEdges(fHBlindPixelQvsN,0); 419 419 420 420 } … … 426 426 return kFALSE; 427 427 428 rmin = (rmin != 0.) ? rmin : 0.;429 rmax = (rmax != 0.) ? rmax : 16.;430 431 const Stat_t entries = fHB PT->GetEntries();432 const Double_t mu_guess = fHB PT->GetBinCenter(fHBPT->GetMaximumBin());428 rmin = (rmin != 0.) ? rmin : 4.; 429 rmax = (rmax != 0.) ? rmax : 9.; 430 431 const Stat_t entries = fHBlindPixelT->GetEntries(); 432 const Double_t mu_guess = fHBlindPixelT->GetBinCenter(fHBlindPixelT->GetMaximumBin()); 433 433 const Double_t sigma_guess = (rmax - rmin)/2.; 434 434 const Double_t area_guess = entries/gkSq2Pi; … … 441 441 fTimeGausFit->SetParLimits(2,0.,rmax-rmin); 442 442 443 fHBPT->Fit("GausTime",opt); 443 fHBlindPixelT->Fit(fTimeGausFit,opt); 444 445 rmin = fTimeGausFit->GetParameter(1) - 2.*fTimeGausFit->GetParameter(2); 446 rmax = fTimeGausFit->GetParameter(1) + 2.*fTimeGausFit->GetParameter(2); 447 fTimeGausFit->SetRange(rmin,rmax); 448 449 fHBlindPixelT->Fit(fTimeGausFit,opt); 450 444 451 445 452 fMeanT = fTimeGausFit->GetParameter(2); -
trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h
r2525 r2599 32 32 private: 33 33 34 TH1I* fHB PQ; //-> Histogram with the single Phe spectrum35 TH1F* fHB PErrQ; //-> Variance of summed FADC slices36 TH1I* fHB PT; //-> Variance of summed FADC slices37 TH1I* fHB PQvsN; //-> Summed Charge vs. Event Nr.34 TH1I* fHBlindPixelQ; //-> Histogram with the single Phe spectrum 35 TH1F* fHBlindPixelErrQ; //-> Variance of summed FADC slices 36 TH1I* fHBlindPixelT; //-> Variance of summed FADC slices 37 TH1I* fHBlindPixelQvsN; //-> Summed Charge vs. Event Nr. 38 38 39 39 TF1 *fSinglePheFit; 40 40 TF1 *fTimeGausFit; 41 41 42 Axis_t fB PQfirst;43 Axis_t fB PQlast;44 Int_t fB PQnbins;42 Axis_t fBlindPixelQfirst; 43 Axis_t fBlindPixelQlast; 44 Int_t fBlindPixelQnbins; 45 45 46 Axis_t fErrB PQfirst;47 Axis_t fErrB PQlast;48 Int_t fErrB PQnbins;46 Axis_t fErrBlindPixelQfirst; 47 Axis_t fErrBlindPixelQlast; 48 Int_t fErrBlindPixelQnbins; 49 49 50 50 void ResetBin(Int_t i); … … 54 54 Bool_t fFitOK; 55 55 56 B PFitFunc fgSinglePheFitFunc; // In the beginning,56 BlindPixelFitFunc fgSinglePheFitFunc; // In the beginning, 57 57 Int_t fgSinglePheFitNPar; // we want to be flexible using different functions 58 58 … … 83 83 ~MHCalibrationBlindPixel(); 84 84 85 Bool_t FillB PQ(Int_t q) { return fHBPQ->Fill(q) > -1; }86 Bool_t FillErrB PQ(Float_t errq) { return fHBPErrQ->Fill(errq) > -1; }87 Bool_t FillB PT(Int_t t) { return fHBPT->Fill(t) > -1; }88 Bool_t FillB PQvsN(Stat_t rq, Int_t t) { return fHBPQvsN->Fill(t,rq) > -1; }85 Bool_t FillBlindPixelQ(Int_t q) { return fHBlindPixelQ->Fill(q) > -1; } 86 Bool_t FillErrBlindPixelQ(Float_t errq) { return fHBlindPixelErrQ->Fill(errq) > -1; } 87 Bool_t FillBlindPixelT(Int_t t) { return fHBlindPixelT->Fill(t) > -1; } 88 Bool_t FillBlindPixelQvsN(Stat_t rq, Int_t t) { return fHBlindPixelQvsN->Fill(t,rq) > -1; } 89 89 90 90 const Double_t GetLambda() const { return fLambda; } … … 109 109 const Double_t GetSigmaTErr() const { return fSigmaTErr; } 110 110 111 const TH1F *GetHErrQ() { return fHB PErrQ; }112 const TH1F *GetHErrQ() const { return fHB PErrQ; }111 const TH1F *GetHErrQ() { return fHBlindPixelErrQ; } 112 const TH1F *GetHErrQ() const { return fHBlindPixelErrQ; } 113 113 114 114 Bool_t SimulateSinglePhe(Double_t lambda, … … 121 121 Bool_t FitT(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+"); 122 122 123 void ChangeFitFunc(B PFitFunc fitfunc, Int_t par=5);123 void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=5); 124 124 125 125 -
trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h
r2533 r2599 12 12 13 13 // Global rejection criteria for the acceptance of a fit: Prob=0.01 == 99% Probability 14 const Float_t gkProbLimit = 0.0 1;14 const Float_t gkProbLimit = 0.001; 15 15 16 16 // Starting number of bins for the histo: … … 30 30 31 31 // typedef to the fitting functions for the blind pixel 32 typedef Double_t (*B PFitFunc)(Double_t *, Double_t *);32 typedef Double_t (*BlindPixelFitFunc)(Double_t *, Double_t *); 33 33 34 34 #endif /* MARS_MHCalibrationBlindPixelConfig */ -
trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc
r2581 r2599 60 60 // Default Constructor. 61 61 // 62 MHCalibrationPixel::MHCalibrationPixel( Int_t pix,const char *name, const char *title)63 : fPixId( pix),62 MHCalibrationPixel::MHCalibrationPixel(const char *name, const char *title) 63 : fPixId(-1), 64 64 fQGausFit(NULL), 65 65 fTGausFit(NULL), 66 66 fFitLegend(NULL), 67 67 fLowerFitRange(0.), 68 fFitOK(kFALSE) 68 fFitOK(kFALSE), 69 fQChisquare(-1.), 70 fQProb(-1.), 71 fQNdf(-1), 72 fTChisquare(-1.), 73 fTProb(-1.), 74 fTNdf(-1) 69 75 { 70 76 … … 72 78 fTitle = title ? title : "Fill the accumulated charges and times of all events and perform fits"; 73 79 74 TString qname = "HQ";75 80 TString qtitle = "Distribution of Summed FADC Slices Pixel "; 76 qname += pix;77 qtitle += pix;78 81 79 82 // Create a large number of bins, later we will rebin … … 82 85 fQnbins = gkStartPixelBinNr; 83 86 84 fHQ = new TH1I( qname.Data(),qtitle.Data(),87 fHQ = new TH1I("HQ",qtitle.Data(), 85 88 fQnbins,fQfirst,fQlast); 86 89 fHQ->SetXTitle("Sum FADC Slices"); … … 88 91 fHQ->Sumw2(); 89 92 90 TString tname = "HT"; 93 fHQ->SetDirectory(NULL); 94 91 95 TString ttitle = "Distribution of Mean Arrival Times Pixel "; 92 tname += pix;93 ttitle += pix;94 96 95 97 Axis_t tfirst = -0.5; … … 97 99 Int_t nbins = 16; 98 100 99 fHT = new TH1I( tname.Data(),ttitle.Data(),101 fHT = new TH1I("HT",ttitle.Data(), 100 102 nbins,tfirst,tlast); 101 103 fHT->SetXTitle("Mean Arrival Times [FADC slice nr]"); … … 103 105 fHT->Sumw2(); 104 106 105 TString qvsnname = "HQvsN"; 107 fHT->SetDirectory(NULL); 108 106 109 TString qvsntitle = "Sum of Charges vs. Event Number Pixel "; 107 qvsnname += pix;108 qvsntitle += pix;109 110 110 111 // We define a reasonable number and later enlarge it if necessary … … 113 114 Axis_t nlast = (Axis_t)nbins - 0.5; 114 115 115 fHQvsN = new TH1I( qvsnname.Data(),qvsntitle.Data(),116 fHQvsN = new TH1I("HQvsN",qvsntitle.Data(), 116 117 nbins,nfirst,nlast); 117 118 fHQvsN->SetXTitle("Event Nr."); 118 119 fHQvsN->SetYTitle("Sum of FADC slices"); 119 120 120 fQChisquare = -1.; 121 fQProb = -1.; 122 fQNdf = -1; 123 124 fTChisquare = -1.; 125 fTProb = -1.; 126 fTNdf = -1; 121 fHQvsN->SetDirectory(NULL); 127 122 128 123 } … … 144 139 } 145 140 141 142 void MHCalibrationPixel::ChangeHistId(Int_t id) 143 { 144 145 fPixId = id; 146 147 TString nameQ = TString(fHQ->GetName()); 148 nameQ += id; 149 fHQ->SetName(nameQ.Data()); 150 151 TString nameT = TString(fHT->GetName()); 152 nameT += id; 153 fHT->SetName(nameT.Data()); 154 155 TString nameQvsN = TString(fHQvsN->GetName()); 156 nameQvsN += id; 157 fHQvsN->SetName(nameQvsN.Data()); 158 } 159 160 146 161 void MHCalibrationPixel::Reset() 147 162 { … … 206 221 207 222 char line8[32]; 208 sprintf(line8,"Probability: %4. 2f ",fQProb);223 sprintf(line8,"Probability: %4.3f ",fQProb); 209 224 fFitLegend->AddText(line8); 210 225 … … 266 281 fHT->DrawCopy(opt); 267 282 268 if (f HT->GetFunction("GausTime"))283 if (fTGausFit) 269 284 { 270 TF1 *tfit = fHT->GetFunction("GausTime"); 271 if (tfit->GetProb() < 0.01) 272 tfit->SetLineColor(kRed); 285 if (fTChisquare > 1.) 286 fTGausFit->SetLineColor(kRed); 273 287 else 274 tfit->SetLineColor(kGreen);275 276 tfit->DrawCopy("same");288 fTGausFit->SetLineColor(kGreen); 289 290 fTGausFit->DrawCopy("same"); 277 291 c->Modified(); 278 292 c->Update(); … … 290 304 Bool_t MHCalibrationPixel::FitT(Axis_t rmin, Axis_t rmax, Option_t *option) 291 305 { 292 306 293 307 if (fTGausFit) 294 308 return kFALSE; 295 309 296 rmin = (rmin != 0.) ? rmin : -0.5;297 rmax = (rmax != 0.) ? rmax : 15.5;310 rmin = (rmin != 0.) ? rmin : 4.; 311 rmax = (rmax != 0.) ? rmax : 9.; 298 312 299 313 const Stat_t entries = fHT->GetEntries(); … … 302 316 const Double_t area_guess = entries/gkSq2Pi; 303 317 304 fTGausFit = new TF1("GausTime","gaus",rmin,rmax); 318 TString name = TString("GausTime"); 319 name += fPixId; 320 fTGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 305 321 306 322 if (!fTGausFit) … … 314 330 fTGausFit->SetParLimits(0,0.,entries); 315 331 fTGausFit->SetParLimits(1,rmin,rmax); 316 fTGausFit->SetParLimits(2,0.,rmax-rmin); 317 318 fHT->Fit("GausTime",option); 332 fTGausFit->SetParLimits(2,0.,(rmax-rmin)/2.); 333 fTGausFit->SetRange(rmin,rmax); 334 335 fHT->Fit(fTGausFit,option); 336 337 rmin = fTGausFit->GetParameter(1) - 3.*fTGausFit->GetParameter(2); 338 rmax = fTGausFit->GetParameter(1) + 3.*fTGausFit->GetParameter(2); 339 fTGausFit->SetRange(rmin,rmax); 340 341 fHT->Fit(fTGausFit,option); 319 342 320 343 fTChisquare = fTGausFit->GetChisquare(); … … 324 347 fTSigma = fTGausFit->GetParameter(2); 325 348 326 if (fT Prob < gkProbLimit)349 if (fTChisquare > 1.) 327 350 { 328 351 *fLog << warn << "Fit of the Arrival times failed ! " << endl; … … 344 367 // 345 368 Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fQfirst; 369 Axis_t rmax = 0.; 346 370 347 371 // … … 352 376 const Double_t ar_guess = entries/gkSq2Pi; 353 377 const Double_t mu_guess = fHQ->GetBinCenter(fHQ->GetMaximumBin()); 354 const Double_t si_guess = mu_guess/500.; 355 356 fQGausFit = new TF1("QGausFit","gaus",rmin,fQlast); 378 const Double_t si_guess = mu_guess/50.; 379 380 TString name = TString("QGausFit"); 381 name += fPixId; 382 383 fQGausFit = new TF1(name.Data(),"gaus",rmin,fQlast); 357 384 358 385 if (!fQGausFit) … … 367 394 fQGausFit->SetParLimits(1,rmin,fQlast); 368 395 fQGausFit->SetParLimits(2,0.,fQlast-rmin); 369 370 fHQ->Fit("QGausFit",option); 396 fQGausFit->SetRange(rmin,fQlast); 397 fQGausFit->Update(); 398 399 fHQ->Fit(fQGausFit,option); 400 401 rmin = fQGausFit->GetParameter(1) - 3.*fQGausFit->GetParameter(2); 402 rmax = fQGausFit->GetParameter(1) + 3.*fQGausFit->GetParameter(2); 403 404 fQGausFit->SetRange(rmin,rmax); 405 fHQ->Fit(fQGausFit,option); 406 407 rmin = fQGausFit->GetParameter(1) - 3.5*fQGausFit->GetParameter(2); 408 rmax = fQGausFit->GetParameter(1) + 3.5*fQGausFit->GetParameter(2); 409 410 fQGausFit->SetRange(rmin,rmax); 411 fHQ->Fit(fQGausFit,option); 371 412 372 413 fQChisquare = fQGausFit->GetChisquare(); … … 399 440 { 400 441 401 // 402 // The number 100 is necessary because it is the internal binning 403 // of ROOT functions. A call to SetNpx() does NOT help 404 // If you find another solution which WORKS!!, please tell me!! 405 // 406 Int_t nbins = 100; 442 Int_t nbins = 50; 407 443 408 444 CutEdges(fHQ,nbins); -
trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h
r2581 r2599 68 68 public: 69 69 70 MHCalibrationPixel( Int_t pix=-1,const char *name=NULL, const char *title=NULL);70 MHCalibrationPixel(const char *name=NULL, const char *title=NULL); 71 71 ~MHCalibrationPixel(); 72 73 void ChangeHistId(Int_t i); 72 74 73 75 Bool_t SetupFill(const MParList *pList); … … 105 107 const TH1I *GetHQvsN() const { return fHQvsN; } 106 108 107 Bool_t FitQ(Option_t *option="RQ0 +");108 Bool_t FitT(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0 +");109 Bool_t FitQ(Option_t *option="RQ0"); 110 Bool_t FitT(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0"); 109 111 110 112 virtual void Draw(Option_t *option="");
Note:
See TracChangeset
for help on using the changeset viewer.