Changeset 5506 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 11/29/04 19:03:54 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
r5428 r5506 31 31 #include "MJPedestal.h" 32 32 33 #include "MLog.h" 34 #include "MLogManip.h" 35 36 #include "MTaskEnv.h" 37 #include "MSequence.h" 38 #include "MRunIter.h" 39 #include "MParList.h" 40 #include "MTaskList.h" 41 #include "MEvtLoop.h" 42 #include "MExtractor.h" 43 44 #include "MStatusDisplay.h" 45 46 #include "MGeomCam.h" 47 #include "MHCamera.h" 48 #include "MPedestalCam.h" 49 #include "MPedestalPix.h" 50 #include "MBadPixelsCam.h" 51 52 #include "MCalibrationPedCam.h" 53 #include "MCalibrationPix.h" 54 #include "MHPedestalCam.h" 55 #include "MHPedestalPix.h" 56 #include "MFillH.h" 57 58 59 #include "MReadMarsFile.h" 60 #include "MRawFileRead.h" 61 #include "MGeomApply.h" 62 #include "MBadPixelsMerge.h" 63 #include "MPedCalcPedRun.h" 64 #include "MPedCalcFromLoGain.h" 65 33 66 #include <TF1.h> 34 67 #include <TEnv.h> … … 40 73 #include <TSystem.h> 41 74 #include <TLegend.h> 42 43 #include "MLog.h" 44 #include "MLogManip.h" 45 46 #include "MTaskEnv.h" 47 #include "MSequence.h" 48 #include "MRunIter.h" 49 #include "MParList.h" 50 #include "MTaskList.h" 51 #include "MEvtLoop.h" 52 #include "MExtractor.h" 53 54 #include "MStatusDisplay.h" 55 56 #include "MGeomCam.h" 57 #include "MHCamera.h" 58 #include "MPedestalCam.h" 59 #include "MBadPixelsCam.h" 60 61 #include "MReadMarsFile.h" 62 #include "MRawFileRead.h" 63 #include "MGeomApply.h" 64 #include "MBadPixelsMerge.h" 65 #include "MPedCalcPedRun.h" 66 #include "MPedCalcFromLoGain.h" 75 #include <TPad.h> 67 76 68 77 ClassImp(MJPedestal); … … 85 94 const Float_t MJPedestal::fgRefPedRmsGalacticOuter = 4.2; 86 95 96 const TString MJPedestal::fgNameExtractorCam = "ExtractorResolution"; 87 97 // -------------------------------------------------------------------------- 88 98 // … … 95 105 // - fExtractType to kUsePedRun 96 106 // - fStorage to Normal Storage 107 // - fExtractorResolution to kFALSE 108 // - fNameExtractorCam to "ExtractorResolution" 97 109 // 98 110 MJPedestal::MJPedestal(const char *name, const char *title) … … 105 117 SetNormalStorage(); 106 118 SetUsePedRun(); 119 SetPathIn(""); 120 SetExtractorResolution(kFALSE); 121 SetNameExtractorCam(); 107 122 } 108 123 … … 142 157 143 158 TFile file(fname, "READ"); 144 if (fPedestalCam.Read()<=0) 145 { 146 *fLog << err << "Unable to read MPedestalCam from " << fname << endl; 159 if (fPedestalCamIn.Read()<=0) 160 { 161 *fLog << err << "Unable to read incoming MPedestalCam from " << fname << endl; 162 return kFALSE; 163 } 164 165 if (fPedestalCamOut.Read()<=0) 166 { 167 *fLog << err << "Unable to read outgoing MPedestalCam from " << fname << endl; 147 168 return kFALSE; 148 169 } … … 167 188 MExtractor *MJPedestal::ReadCalibration() const 168 189 { 169 const TString fname = Form("%s/calib%06d.root", 190 const TString fname = Form("%s/calib%06d.root",fPathIn.Data(), fSequence.GetSequence()); 170 191 171 192 *fLog << inf << "Reading from file: " << fname << endl; … … 213 234 // Get container from list 214 235 // 215 MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam"); 236 MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam"); 237 MCalibrationPedCam &calpedcam = *(MCalibrationPedCam*)plist.FindObject("MCalibrationPedCam"); 216 238 217 239 // 218 240 // Create container to display 219 241 // 220 MHCamera disp0(geomcam, "MPedestalCam;ped", "Mean Pedestal"); 221 MHCamera disp1(geomcam, "MPedestalCam;RMS", "Pedestal RMS"); 222 223 disp0.SetCamContent(fPedestalCam, 0); 224 disp0.SetCamError (fPedestalCam, 1); 225 226 disp1.SetCamContent(fPedestalCam, 2); 227 disp1.SetCamError (fPedestalCam, 3); 242 MHCamera disp0 (geomcam, "MPedestalCam;ped", "Mean Pedestal"); 243 MHCamera disp1 (geomcam, "MPedestalCam;RMS", "Pedestal RMS"); 244 MHCamera disp2 (geomcam, "MCalibPedCam;histmean", "Mean Pedestal (Hist.)"); 245 MHCamera disp3 (geomcam, "MCalibPedCam;histsigma", "Pedestal RMS (Hist.)"); 246 MHCamera disp4 (geomcam, "MCalibPedCam;ped", "Mean Pedestal"); 247 MHCamera disp5 (geomcam, "MCalibPedCam;RMS", "Pedestal RMS"); 248 MHCamera disp6 (geomcam, "MCalibDiffCam;ped", "Diff. Mean Pedestal (Hist.)"); 249 MHCamera disp7 (geomcam, "MCalibDiffCam;RMS", "Diff. Pedestal RMS (Hist.)"); 250 MHCamera disp8 (geomcam, "MCalibDiffCam;ped", "Diff. Mean Pedestal"); 251 MHCamera disp9 (geomcam, "MCalibDiffCam;AbsRMS", "Diff. Abs. Pedestal RMS"); 252 MHCamera disp10(geomcam, "MCalibDiffCam;RelRMS", "Diff. Rel. Pedestal RMS"); 253 254 disp0.SetCamContent(fPedestalCamOut, 0); 255 disp0.SetCamError (fPedestalCamOut, 1); 256 257 disp1.SetCamContent(fPedestalCamOut, 2); 258 disp1.SetCamError (fPedestalCamOut, 3); 259 260 if (fExtractType == kUseHists) 261 { 262 disp2.SetCamContent(calpedcam, 0); 263 disp2.SetCamError (calpedcam, 1); 264 265 disp3.SetCamContent(calpedcam, 2); 266 disp3.SetCamError (calpedcam, 3); 267 268 disp4.SetCamContent(calpedcam, 5); 269 disp4.SetCamError (calpedcam, 6); 270 271 disp5.SetCamContent(calpedcam, 7); 272 disp5.SetCamError (calpedcam, 8); 273 274 for (UInt_t i=0;i<geomcam.GetNumPixels();i++) 275 { 276 277 MPedestalPix &ped = fPedestalCamOut[i]; 278 MCalibrationPix &hist = calpedcam [i]; 279 MBadPixelsPix &bad = fBadPixels[i]; 280 281 if (bad.IsUnsuitable()) 282 continue; 283 284 disp6.Fill(i,ped.GetPedestal()-hist.GetHiGainMean()); 285 disp6.SetUsed(i); 286 287 disp7.Fill(i,hist.GetHiGainSigma()-ped.GetPedestalRms()); 288 if (TMath::Abs(ped.GetPedestalRms()-hist.GetHiGainSigma()) < 4.0) 289 disp7.SetUsed(i); 290 291 disp8.Fill(i,ped.GetPedestal()-hist.GetLoGainMean()); 292 disp8.SetUsed(i); 293 294 disp9.Fill(i,hist.GetLoGainSigma()-ped.GetPedestalRms()); 295 if (TMath::Abs(hist.GetLoGainSigma() - ped.GetPedestalRms()) < 4.0) 296 disp9.SetUsed(i); 297 } 298 } 299 300 if (fExtractorResolution) 301 { 302 for (UInt_t i=0;i<geomcam.GetNumPixels();i++) 303 { 304 305 MPedestalPix &pedo = fPedestalCamOut[i]; 306 MPedestalPix &pedi = fPedestalCamIn[i]; 307 MBadPixelsPix &bad = fBadPixels[i]; 308 309 if (bad.IsUnsuitable()) 310 continue; 311 312 const Float_t diff = pedo.GetPedestalRms()-pedi.GetPedestalRms(); 313 const Float_t sum = 0.5*(pedo.GetPedestalRms()+pedi.GetPedestalRms()); 314 315 disp9.Fill(i,pedo.GetPedestalRms()-pedi.GetPedestalRms()); 316 if (pedo.IsValid() && pedi.IsValid()) 317 disp9.SetUsed(i); 318 319 disp10.Fill(i,sum == 0. ? 0. : diff/sum); 320 if (pedo.IsValid() && pedi.IsValid() && sum != 0.) 321 disp10.SetUsed(i); 322 } 323 } 228 324 229 325 disp0.SetYTitle("Pedestal [counts/slice]"); 230 326 disp1.SetYTitle("RMS [counts/slice]"); 327 disp2.SetYTitle("Hist. Mean [counts/slice]"); 328 disp3.SetYTitle("Hist. Sigma [counts/slice]"); 329 disp4.SetYTitle("Calc. Mean [counts/slice]"); 330 disp5.SetYTitle("Calc. RMS [counts/slice]"); 331 disp6.SetYTitle("Diff. Mean [counts/slice]"); 332 disp7.SetYTitle("Diff. RMS [counts/slice]"); 333 disp8.SetYTitle("Diff. Mean [counts/slice]"); 334 disp9.SetYTitle("Abs. Diff. RMS [counts/slice]"); 335 disp10.SetYTitle("Rel. Diff. RMS [1]"); 231 336 232 337 // 233 338 // Display data 234 339 // 235 TCanvas &c3 = fDisplay->AddTab("Pedestals"); 236 c3.Divide(2,3); 237 238 if (fDisplayType != kDataCheckDisplay) 239 { 340 if (fDisplayType != kDataCheckDisplay && fExtractType != kUseHists && !fExtractorResolution) 341 { 342 TCanvas &c3 = fDisplay->AddTab("Pedestals"); 343 c3.Divide(2,3); 344 345 disp0.CamDraw(c3, 1, 2, 1); 346 disp1.CamDraw(c3, 2, 2, 6); 347 return; 348 } 349 350 if (fExtractorResolution) 351 { 352 353 TCanvas &c3 = fDisplay->AddTab("Extr.Res."); 354 c3.Divide(2,3); 355 240 356 disp0.CamDraw(c3, 1, 2, 1); 241 357 disp1.CamDraw(c3, 2, 2, 6); 358 359 TCanvas &c13 = fDisplay->AddTab("Diff.(Extr.-Pedestal)"); 360 c13.Divide(2,3); 361 362 disp9.CamDraw(c13, 1, 2, 5); 363 disp10.CamDraw(c13, 2, 2, 5); 242 364 return; 243 } 365 } 366 367 if (fExtractType == kUseHists) 368 { 369 370 TCanvas &c3 = fDisplay->AddTab("Extractor Hist."); 371 c3.Divide(2,3); 372 373 disp2.CamDraw(c3, 1, 2, 1); 374 disp3.CamDraw(c3, 2, 2, 5); 375 376 TCanvas &c4 = fDisplay->AddTab("Extractor Calc."); 377 c4.Divide(2,3); 378 379 disp4.CamDraw(c4, 1, 2, 1); 380 disp5.CamDraw(c4, 2, 2, 5); 381 382 383 TCanvas &c5 = fDisplay->AddTab("Difference Hist."); 384 c5.Divide(2,3); 385 386 disp6.CamDraw(c5, 1, 2, 1); 387 disp7.CamDraw(c5, 2, 2, 5); 388 389 TCanvas &c6 = fDisplay->AddTab("Difference Calc."); 390 c6.Divide(2,3); 391 392 disp8.CamDraw(c6, 1, 2, 1); 393 disp9.CamDraw(c6, 2, 2, 5); 394 return; 395 } 396 397 TCanvas &c3 = fDisplay->AddTab(fExtractorResolution ? "Extr.Res." : "Pedestals"); 398 c3.Divide(2,3); 244 399 245 400 c3.cd(1); … … 386 541 } 387 542 leg2->Draw(); 543 delete leg2; 388 544 } 389 } 390 } 545 546 } 547 548 } 549 391 550 392 551 void MJPedestal::DisplayReferenceLines(MHCamera *cam, const Int_t what) const … … 440 599 leg->AddEntry(l3, "Closed Lids","l"); 441 600 leg->Draw(); 601 delete leg; 442 602 } 443 603 … … 525 685 Bool_t MJPedestal::CheckEnvLocal() 526 686 { 527 SetDataCheck(GetEnv("DataCheck", fDataCheck)); 528 529 if (HasEnv("DataCheckDisplay")) 530 fDisplayType = GetEnv("DataCheckDisplay", kFALSE) ? kDataCheckDisplay : kNormalDisplay; 531 532 if (HasEnv("UseData")) 533 fExtractType = GetEnv("UseData",kFALSE) ? kUseData : kUsePedRun; 534 535 if (HasEnv("UseExtractor")) 536 if (GetEnv("UseExtractor",kFALSE)) 537 fExtractType = kUseExtractor; 538 539 SetNoStorage(GetEnv("DisableOutput", IsNoStorage())); 540 541 return kTRUE; 687 688 SetDataCheck(GetEnv("DataCheck", fDataCheck)); 689 690 if (HasEnv("DataCheckDisplay")) 691 fDisplayType = GetEnv("DataCheckDisplay", kFALSE) ? kDataCheckDisplay : kNormalDisplay; 692 693 if (HasEnv("UseData")) 694 fExtractType = GetEnv("UseData",kFALSE) ? kUseData : kUsePedRun; 695 696 if (HasEnv("UseHists")) 697 if (GetEnv("UseHists",kFALSE)) 698 fExtractType = kUseHists; 699 700 SetExtractorResolution(GetEnv("ExtractorResolution", fExtractorResolution)); 701 SetNameExtractorCam(GetEnv("NameExtractorCam", fNameExtractorCam)); 702 703 SetNoStorage(GetEnv("DisableOutput", IsNoStorage())); 704 705 return kTRUE; 542 706 } 543 707 … … 575 739 } 576 740 577 if (fPedestalCam .Write()<=0)741 if (fPedestalCamOut.Write()<=0) 578 742 { 579 743 *fLog << err << "Unable to write MPedestalCam to " << oname << endl; … … 677 841 678 842 // Setup Tasklist 679 plist.AddToList(&fPedestalCam );843 plist.AddToList(&fPedestalCamOut); 680 844 plist.AddToList(&fBadPixels); 681 845 682 846 MGeomApply geomapl; 683 847 MBadPixelsMerge merge(&fBadPixels); 684 848 685 849 MPedCalcPedRun pedcalc; 850 pedcalc.SetPedestalUpdate(kFALSE); 686 851 MPedCalcFromLoGain pedlogain; 852 pedlogain.SetPedestalUpdate(kFALSE); 853 854 MHPedestalCam hpedcam; 855 hpedcam.SetRenorm(kTRUE); 856 857 MFillH fillped(&hpedcam, "MExtractedSignalCam"); 858 fillped.SetBit(MFillH::kDoNotDisplay); 859 860 tlist.AddToList(&geomapl); 861 tlist.AddToList(&merge); 687 862 688 863 if (!fPathIn.IsNull()) … … 702 877 { 703 878 case kUseData: 704 taskenv.SetDefault(&pedlogain); 705 if (!fExtractor) 706 break; 879 taskenv.SetDefault(&pedlogain); 880 if (!fExtractor) 881 break; 882 tlist.AddToList(&taskenv); 883 if (fExtractorResolution && fExtractor->InheritsFrom("MExtractTimeAndCharge")) 884 { 885 plist.AddToList(&fPedestalCamIn); 886 fPedestalCamOut.SetName(fNameExtractorCam.Data()); 887 pedlogain.SetNamePedestalCamOut(fNameExtractorCam.Data()); 888 pedlogain.SetExtractor((MExtractTimeAndCharge*)fExtractor); 889 } 890 else 707 891 pedlogain.SetExtractWindow(15, (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples())); 708 pedlogain.SetPedestalUpdate(kFALSE); 892 break; 893 894 case kUsePedRun: 895 taskenv.SetDefault(&pedcalc); 896 if (!fExtractor) 709 897 break; 710 711 case kUsePedRun: 712 taskenv.SetDefault(&pedcalc); 713 if (!fExtractor) 714 break; 715 pedcalc.SetWindowSize((Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples())); 716 pedcalc.SetRange(fExtractor->GetHiGainFirst(), fExtractor->GetHiGainLast()); 717 break; 718 719 case kUseExtractor: 720 if (!fExtractor) 898 tlist.AddToList(&taskenv); 899 if (fExtractorResolution && fExtractor->InheritsFrom("MExtractTimeAndCharge")) 721 900 { 722 *fLog << err << GetDescriptor(); 723 *fLog << "Extraction Type kUseExtractor is chosen, but no extractor has been handed over" << endl; 724 return kFALSE; 901 plist.AddToList(&fPedestalCamIn); 902 fPedestalCamOut.SetName(fNameExtractorCam.Data()); 903 pedcalc.SetNamePedestalCamOut(fNameExtractorCam.Data()); 904 pedcalc.SetExtractor((MExtractTimeAndCharge*)fExtractor); 725 905 } 726 taskenv.SetDefault(fExtractor); 727 if (fExtractor->IsNoiseCalculation()) 728 break; 729 906 else 907 pedcalc.SetExtractWindow(fExtractor->GetHiGainFirst(),TMath::Nint(fExtractor->GetNumHiGainSamples())); 908 break; 909 910 case kUseHists: 911 if (!fExtractor) 912 { 913 *fLog << err << GetDescriptor(); 914 *fLog << ": Extraction Type kUseExtractor is chosen, but no extractor has been handed over" 915 << endl; 916 return kFALSE; 917 } 918 919 plist.AddToList(&hpedcam); 920 tlist.AddToList(fExtractor); 921 tlist.AddToList(&fillped); 922 923 break; 924 } 925 926 // 927 // Check that the extractor has the bit Noise Calculation() set which 928 // means that the each "sliding" of the sliding window is not applied 929 // 930 if (fExtractorResolution && !fExtractor->IsNoiseCalculation()) 931 { 730 932 *fLog << warn << GetDescriptor(); 731 *fLog <<"Extraction type is kUseExtractor, but extractor has kNoiseCalculation not set... set." << endl; 933 *fLog <<": Extraction type is kUseExtractor, but extractor has kNoiseCalculation not set... set." 934 << endl; 732 935 fExtractor->SetNoiseCalculation(); 733 return kFALSE; 734 } 735 936 } 937 736 938 if (!fPathIn.IsNull()) 737 939 { 738 delete fExtractor; 739 fExtractor = 0; 740 } 741 742 tlist.AddToList(&geomapl); 743 tlist.AddToList(&merge); 744 tlist.AddToList(&taskenv); 940 delete fExtractor; 941 fExtractor = 0; 942 } 745 943 746 944 // -
trunk/MagicSoft/Mars/mjobs/MJPedestal.h
r5387 r5506 41 41 static const Float_t fgRefPedRmsGalacticOuter; //! Ref. line ped. RMS for galactic source - outer pixels 42 42 43 static const TString fgNameExtractorCam; //! "ExtractorResolution" 44 43 45 MRunIter *fRuns; // Used pedestal runs 44 46 MExtractor *fExtractor; // Signal extractor, used to find the nr. of used FADC slices 45 47 46 MPedestalCam fPedestalCam; // Created pedestal results 48 MPedestalCam fPedestalCamIn; // Handed over pedestal results 49 MPedestalCam fPedestalCamOut; // Created pedestal results 47 50 MBadPixelsCam fBadPixels; // Bad Pixels 51 52 TString fNameExtractorCam; // Name of the outgoing MPedestalCam if fExtractorResolution 48 53 49 54 enum Display_t {kDataCheckDisplay, kNormalDisplay}; // Possible Display types … … 55 60 Bool_t fDataCheck; // Flag if the data check is run on raw data 56 61 57 enum Extract_t {kUseData, kUsePedRun, kUse Extractor};// Possible flags for the extraction of the pedestal62 enum Extract_t {kUseData, kUsePedRun, kUseHists }; // Possible flags for the extraction of the pedestal 58 63 Extract_t fExtractType; // Chosen extractor type 64 65 Bool_t fExtractorResolution; // Flag if the extractor is used to calculate the pedestals 59 66 60 67 MExtractor *ReadCalibration() const; … … 76 83 MJPedestal(const char *name=NULL, const char *title=NULL); 77 84 78 MPedestalCam &GetPedestalCam() { return fPedestalCam ; }85 MPedestalCam &GetPedestalCam() { return fPedestalCamOut; } 79 86 const MBadPixelsCam &GetBadPixels() const { return fBadPixels; } 80 87 … … 82 89 const Bool_t IsDataCheck() const { return fDataCheck; } 83 90 const Bool_t IsUseData() const { return fExtractType == kUseData; } 84 const Bool_t IsUseExtractor() const { return fExtractType == kUseExtractor; }85 const Bool_t IsUsePedRun() const { return fExtractType == kUsePedRun; }86 91 87 92 Bool_t Process (); … … 89 94 90 95 void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); } 96 void SetPedestals(const MPedestalCam &ped) { ped.Copy(fPedestalCamIn); } 91 97 void SetExtractor(MExtractor* ext) { fExtractor = ext; } 92 98 void SetInput(MRunIter *iter) { fRuns = iter; } 93 void SetUseData() { fExtractType = kUseData; 94 void SetUse Extractor() { fExtractType = kUseExtractor;}95 void SetUsePedRun() { fExtractType = kUsePedRun; 99 void SetUseData() { fExtractType = kUseData; } 100 void SetUseHists() { fExtractType = kUseHists; } 101 void SetUsePedRun() { fExtractType = kUsePedRun; } 96 102 void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; b ? SetDataCheckDisplay() : SetNormalDisplay(); } 97 103 void SetDataCheckDisplay() { fDisplayType = kDataCheckDisplay; } 98 104 void SetNormalDisplay() { fDisplayType = kNormalDisplay; } 105 void SetExtractorResolution(const Bool_t b=kTRUE) { fExtractorResolution = b; } 106 void SetNameExtractorCam( const char* name= fgNameExtractorCam.Data()) { fNameExtractorCam = name; } 99 107 100 void SetPedContainerName(const char *name) { fPedestalCam.SetName(name); }101 108 102 109 // Storage
Note:
See TracChangeset
for help on using the changeset viewer.