Changeset 8490 for trunk/MagicSoft/Mars/mpedestal
- Timestamp:
- 05/11/07 11:25:46 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mpedestal
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc
r8371 r8490 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.2 8 2007-03-05 15:54:55 tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.29 2007-05-11 10:25:45 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 21 21 ! Author(s): Thomas Bretz 01/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 22 22 ! 23 ! Copyright: MAGIC Software Development, 2000-200 623 ! Copyright: MAGIC Software Development, 2000-2007 24 24 ! 25 25 ! … … 238 238 fSectorFilled.Reset(); 239 239 fSectorValid.Reset(); 240 240 fNumEventsUsed.Reset(); 241 241 } 242 242 … … 523 523 fSumAB1.Set(npixels); 524 524 525 fNumEventsUsed.Set(npixels); 526 525 527 if (fUseSpecialPixels) 526 528 { … … 613 615 { 614 616 // This is the fast workaround to put hi- and lo-gains together 615 Byte_t *slices = fSignal->GetSamplesRaw(idx); //pixel.GetSamples();617 Byte_t *slices = fSignal->GetSamplesRaw(idx); 616 618 617 619 // Start 'real' work 618 U Short_t max = 0;619 U Short_t min = (UShort_t)-1;620 UInt_t max = 0; 621 UInt_t min = (UInt_t)-1; 620 622 621 623 // Find the maximum and minimum signal per slice in the high gain window … … 700 702 } 701 703 702 // -------------------------------------------------------------------------- 703 // 704 // The following resources are available: 705 // ExtractWindowFirst: 15 706 // ExtractWindowSize: 6 707 // PedestalUpdate: yes 708 // RandomCalculation: yes 709 // 710 Int_t MExtractPedestal::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 711 { 712 Bool_t rc=kFALSE; 713 714 // find resource for fUseSpecialPixels 715 if (IsEnvDefined(env, prefix, "UseSpecialPixels", print)) 716 { 717 SetUseSpecialPixels(GetEnvValue(env, prefix, "UseSpecialPixels", fUseSpecialPixels)); 718 rc = kTRUE; 719 } 720 721 if (IsEnvDefined(env, prefix, "IntermediateStorage", print)) 722 { 723 SetIntermediateStorage(GetEnvValue(env, prefix, "IntermediateStorage", fIntermediateStorage)); 724 rc = kTRUE; 725 } 726 727 // find resource for random calculation 728 if (IsEnvDefined(env, prefix, "RandomCalculation", print)) 729 { 730 SetRandomCalculation(GetEnvValue(env, prefix, "RandomCalculation", fRandomCalculation)); 731 rc = kTRUE; 732 } 733 734 // Find resources for ExtractWindow 735 Int_t ef = fExtractWinFirst; 736 Int_t es = fExtractWinSize; 737 if (IsEnvDefined(env, prefix, "ExtractWinFirst", print)) 738 { 739 ef = GetEnvValue(env, prefix, "ExtractWinFirst", ef); 740 rc = kTRUE; 741 } 742 if (IsEnvDefined(env, prefix, "ExtractWinSize", print)) 743 { 744 es = GetEnvValue(env, prefix, "ExtractWinSize", es); 745 rc = kTRUE; 746 } 747 748 SetExtractWindow(ef,es); 749 750 // Find resources for CheckWindow 751 Int_t cfs = fCheckWinFirst; 752 Int_t cls = fCheckWinLast; 753 if (IsEnvDefined(env, prefix, "CheckWinFirst", print)) 754 { 755 cfs = GetEnvValue(env, prefix, "CheckWinFirst", cfs); 756 rc = kTRUE; 757 } 758 if (IsEnvDefined(env, prefix, "CheckWinLast", print)) 759 { 760 cls = GetEnvValue(env, prefix, "CheckWinLast", cls); 761 rc = kTRUE; 762 } 763 764 SetCheckRange(cfs,cls); 765 766 // find resource for maximum signal variation 767 if (IsEnvDefined(env, prefix, "MaxSignalVar", print)) 768 { 769 SetMaxSignalVar(GetEnvValue(env, prefix, "MaxSignalVar", fMaxSignalVar)); 770 rc = kTRUE; 771 } 772 773 // find resource for MPedestalCam 774 if (IsEnvDefined(env, prefix, "NamePedestalCamIn", print)) 775 { 776 SetNamePedestalCamIn(GetEnvValue(env, prefix, "NamePedestalCamIn", fNamePedestalCamIn)); 777 rc = kTRUE; 778 } 779 780 if (IsEnvDefined(env, prefix, "NamePedestalCamInter", print)) 781 { 782 SetNamePedestalCamInter(GetEnvValue(env, prefix, "NamePedestalCamInter", fNamePedestalCamInter)); 783 rc = kTRUE; 784 } 785 786 if (IsEnvDefined(env, prefix, "NamePedestalCamOut", print)) 787 { 788 SetNamePedestalCamOut(GetEnvValue(env, prefix, "NamePedestalCamOut", fNamePedestalCamOut)); 789 rc = kTRUE; 790 } 791 792 return rc; 704 // --------------------------------------------------------------------------------- 705 // 706 // Check for the variation of the pixel. Return kFALSE if this pixel 707 // should not be used. 708 // Calculate the pedestal either with the extractor or by summing slices. 709 // And update all arrays. 710 // 711 Bool_t MExtractPedestal::CalcPixel(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t usespecialpixels) 712 { 713 const UInt_t idx = pixel.GetPixelId(); 714 if (!CheckVariation(idx)) 715 return kFALSE; 716 717 //extract pedestal 718 UInt_t ab[2]; 719 const Float_t sum = fExtractor ? 720 CalcExtractor(pixel, offset) : 721 CalcSums(pixel, offset, ab[0], ab[1]); 722 723 fNumEventsUsed[idx]++; 724 725 if (fIntermediateStorage) 726 (*fPedestalsInter)[idx].Set(sum, 0, 0, fNumEventsUsed[idx]); 727 728 const Float_t sqrsum = sum*sum; 729 730 fSumx[idx] += sum; 731 fSumx2[idx] += sqrsum; 732 733 if (!fExtractor && pixel.IsABFlagValid()) 734 { 735 fSumAB0[idx] += ab[0]; 736 fSumAB1[idx] += ab[1]; 737 } 738 739 if (usespecialpixels) 740 return kTRUE; 741 742 const UInt_t aidx = (*fGeom)[idx].GetAidx(); 743 const UInt_t sector = (*fGeom)[idx].GetSector(); 744 745 fAreaFilled[aidx]++; 746 fSectorFilled[sector]++; 747 748 fAreaSumx[aidx] += sum; 749 fAreaSumx2[aidx] += sqrsum; 750 fSectorSumx[sector] += sum; 751 fSectorSumx2[sector] += sqrsum; 752 753 if (!fExtractor && pixel.IsABFlagValid()) 754 { 755 fAreaSumAB0[aidx] += ab[0]; 756 fAreaSumAB1[aidx] += ab[1]; 757 fSectorSumAB0[aidx] += ab[0]; 758 fSectorSumAB1[aidx] += ab[1]; 759 } 760 761 return kTRUE; 793 762 } 794 763 … … 803 772 // Stores the results in MPedestalCam[pixid] 804 773 // 805 void MExtractPedestal::CalcPixResults(const UInt_t nevts, const UInt_t pixid) 806 { 774 void MExtractPedestal::CalcPixResults(const UInt_t pixid) 775 { 776 const UInt_t nevts = fNumEventsUsed[pixid]; 777 if (nevts<2) 778 return; 779 807 780 const Double_t sum = fSumx[pixid]; 808 781 const Double_t sum2 = fSumx2[pixid]; … … 843 816 // Stores the results in MPedestalCam::GetAverageArea(aidx) 844 817 // 845 void MExtractPedestal::CalcAreaResults(const UInt_t nevts, const UInt_t napix, const UInt_t aidx) 846 { 818 void MExtractPedestal::CalcAreaResults(const UInt_t aidx) 819 { 820 const UInt_t nevts = fAreaFilled[aidx]; 821 if (nevts<2) 822 return; 823 824 const UInt_t napix = fAreaValid[aidx]; 825 if (napix<1) 826 return; 827 847 828 const Double_t sum = fAreaSumx[aidx]; 848 829 const Double_t sum2 = fAreaSumx2[aidx]; … … 888 869 // Stores the results in MPedestalCam::GetAverageSector(sector) 889 870 // 890 void MExtractPedestal::CalcSectorResults(const UInt_t nevts, const UInt_t nspix, const UInt_t sector) 891 { 871 void MExtractPedestal::CalcSectorResults(const UInt_t sector) 872 { 873 const UInt_t nevts = fSectorFilled[sector]; 874 if (nevts<2) 875 return; 876 877 const UInt_t nspix = fSectorValid[sector]; 878 if (nspix<1) 879 return; 880 892 881 const Double_t sum = fSectorSumx[sector]; 893 882 const Double_t sum2 = fSectorSumx2[sector]; … … 923 912 } 924 913 914 // -------------------------------------------------------------------------- 915 // 916 // Loop over the pixels to get the averaged pedestal 917 // 918 void MExtractPedestal::CalcPixResult() 919 { 920 for (UInt_t idx=0; idx<fNumEventsUsed.GetSize(); idx++) 921 CalcPixResults(idx); 922 } 923 924 // -------------------------------------------------------------------------- 925 // 926 // Loop over the sector indices to get the averaged pedestal per sector 927 // 928 void MExtractPedestal::CalcSectorResult() 929 { 930 for (UInt_t sector=0; sector<fSectorFilled.GetSize(); sector++) 931 CalcSectorResults(sector); 932 } 933 934 // -------------------------------------------------------------------------- 935 // 936 // Loop over the (two) area indices to get the averaged pedestal per aidx 937 // 938 void MExtractPedestal::CalcAreaResult() 939 { 940 for (UInt_t aidx=0; aidx<fAreaFilled.GetSize(); aidx++) 941 CalcAreaResults(aidx); 942 } 943 925 944 //----------------------------------------------------------------------- 926 945 // … … 942 961 *fLog << "Max.allowed signal variation: " << fMaxSignalVar << endl; 943 962 } 963 964 // -------------------------------------------------------------------------- 965 // 966 // The following resources are available: 967 // ExtractWindowFirst: 15 968 // ExtractWindowSize: 6 969 // PedestalUpdate: yes 970 // RandomCalculation: yes 971 // 972 Int_t MExtractPedestal::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 973 { 974 Bool_t rc=kFALSE; 975 976 // find resource for fUseSpecialPixels 977 if (IsEnvDefined(env, prefix, "UseSpecialPixels", print)) 978 { 979 SetUseSpecialPixels(GetEnvValue(env, prefix, "UseSpecialPixels", fUseSpecialPixels)); 980 rc = kTRUE; 981 } 982 983 if (IsEnvDefined(env, prefix, "IntermediateStorage", print)) 984 { 985 SetIntermediateStorage(GetEnvValue(env, prefix, "IntermediateStorage", fIntermediateStorage)); 986 rc = kTRUE; 987 } 988 989 // find resource for random calculation 990 if (IsEnvDefined(env, prefix, "RandomCalculation", print)) 991 { 992 SetRandomCalculation(GetEnvValue(env, prefix, "RandomCalculation", fRandomCalculation)); 993 rc = kTRUE; 994 } 995 996 // Find resources for ExtractWindow 997 Int_t ef = fExtractWinFirst; 998 Int_t es = fExtractWinSize; 999 if (IsEnvDefined(env, prefix, "ExtractWinFirst", print)) 1000 { 1001 ef = GetEnvValue(env, prefix, "ExtractWinFirst", ef); 1002 rc = kTRUE; 1003 } 1004 if (IsEnvDefined(env, prefix, "ExtractWinSize", print)) 1005 { 1006 es = GetEnvValue(env, prefix, "ExtractWinSize", es); 1007 rc = kTRUE; 1008 } 1009 1010 SetExtractWindow(ef,es); 1011 1012 // Find resources for CheckWindow 1013 Int_t cfs = fCheckWinFirst; 1014 Int_t cls = fCheckWinLast; 1015 if (IsEnvDefined(env, prefix, "CheckWinFirst", print)) 1016 { 1017 cfs = GetEnvValue(env, prefix, "CheckWinFirst", cfs); 1018 rc = kTRUE; 1019 } 1020 if (IsEnvDefined(env, prefix, "CheckWinLast", print)) 1021 { 1022 cls = GetEnvValue(env, prefix, "CheckWinLast", cls); 1023 rc = kTRUE; 1024 } 1025 1026 SetCheckRange(cfs,cls); 1027 1028 // find resource for maximum signal variation 1029 if (IsEnvDefined(env, prefix, "MaxSignalVar", print)) 1030 { 1031 SetMaxSignalVar(GetEnvValue(env, prefix, "MaxSignalVar", fMaxSignalVar)); 1032 rc = kTRUE; 1033 } 1034 1035 // find resource for MPedestalCam 1036 if (IsEnvDefined(env, prefix, "NamePedestalCamIn", print)) 1037 { 1038 SetNamePedestalCamIn(GetEnvValue(env, prefix, "NamePedestalCamIn", fNamePedestalCamIn)); 1039 rc = kTRUE; 1040 } 1041 1042 if (IsEnvDefined(env, prefix, "NamePedestalCamInter", print)) 1043 { 1044 SetNamePedestalCamInter(GetEnvValue(env, prefix, "NamePedestalCamInter", fNamePedestalCamInter)); 1045 rc = kTRUE; 1046 } 1047 1048 if (IsEnvDefined(env, prefix, "NamePedestalCamOut", print)) 1049 { 1050 SetNamePedestalCamOut(GetEnvValue(env, prefix, "NamePedestalCamOut", fNamePedestalCamOut)); 1051 rc = kTRUE; 1052 } 1053 1054 return rc; 1055 } 1056 -
trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h
r8357 r8490 40 40 41 41 Bool_t fRandomCalculation; // Is pedestalextraction by extractor random? 42 42 43 // Helper functions 44 void CalcAreaResults(const UInt_t aidx); 45 void CalcSectorResults(const UInt_t sector); 46 43 47 protected: 44 48 45 49 Bool_t fIntermediateStorage; // Is pedestal stored every event? 46 50 … … 53 57 MExtractTimeAndCharge *fExtractor; // Possible Extractor 54 58 MPedestalSubtractedEvt *fSignal; //! 55 59 56 60 UShort_t fExtractWinFirst; // First FADC slice to extract pedestal from 57 61 UShort_t fExtractWinSize; // Number of slices to calculate the pedestal from … … 82 86 MArrayI fSectorValid; // number of valid pixels within sector idx 83 87 88 MArrayI fNumEventsUsed; // Number of events used for pedestal calc for each pixel 89 84 90 // MTask virtual functions 85 91 Int_t PreProcess(MParList *pList); … … 94 100 95 101 // Helper functions 96 void CalcPixResults (const UInt_t nevts, const UInt_t pixid); 97 void CalcAreaResults (const UInt_t nevts, const UInt_t napix, const UInt_t aidx); 98 void CalcSectorResults(const UInt_t nevts, const UInt_t nspix, const UInt_t sector); 102 void CalcPixResults(const UInt_t pixid); 99 103 104 void CalcPixResult(); 105 void CalcSectorResult(); 106 void CalcAreaResult(); 107 108 Bool_t CalcPixel(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t usespecialpixels=kFALSE); 100 109 Float_t CalcExtractor(const MRawEvtPixelIter &pixel, Int_t offset) const; 101 110 UInt_t CalcSums(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t &ab0, UInt_t &ab1) const; -
trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
r8361 r8490 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MPedCalcFromLoGain.cc,v 1.3 7 2007-03-04 12:00:30tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MPedCalcFromLoGain.cc,v 1.38 2007-05-11 10:25:45 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 26 26 ! Author(s): Nepomuk Otte 10/2004 <mailto:otte@mppmu.mpg.de> 27 27 ! 28 ! Copyright: MAGIC Software Development, 2000-200 628 ! Copyright: MAGIC Software Development, 2000-2007 29 29 ! 30 30 ! … … 145 145 #include "MRawEvtPixelIter.h" 146 146 147 #include "MPedestalPix.h"148 147 #include "MPedestalCam.h" 149 150 #include "MGeomPix.h"151 #include "MGeomCam.h"152 153 #include "MExtractPedestal.h"154 #include "MPedestalSubtractedEvt.h"155 148 156 149 ClassImp(MPedCalcFromLoGain); … … 177 170 SetPedestalUpdate(kTRUE); 178 171 SetNumDump(); 179 }180 181 // --------------------------------------------------------------------------182 //183 // Call MExtractPedestl::ResetArrays aand reset fNumAventsUsed and184 // fTotalCounter185 //186 void MPedCalcFromLoGain::ResetArrays()187 {188 MExtractPedestal::ResetArrays();189 190 fNumEventsUsed.Reset();191 fTotalCounter.Reset();192 172 } 193 173 … … 203 183 Bool_t MPedCalcFromLoGain::ReInit(MParList *pList) 204 184 { 205 // If the size is not yet set, set the size206 if (fSumx.GetSize()==0)207 {208 const Int_t npixels = fPedestalsOut->GetSize();209 fNumEventsUsed.Set(npixels);210 fTotalCounter.Set(npixels);211 }212 213 185 if (!MExtractPedestal::ReInit(pList)) 214 186 return kFALSE; … … 232 204 const Int_t nlo = fRunHeader->GetNumSamplesLoGain(); 233 205 206 const Int_t offset = nlo>0?nhi:0; 207 234 208 // Real Process 235 209 MRawEvtPixelIter pixel(fRawEvt); 236 210 while (pixel.Next()) 237 211 { 212 if (!CalcPixel(pixel, offset)) 213 continue; 214 238 215 const UInt_t idx = pixel.GetPixelId(); 239 240 if (!CheckVariation(idx))241 continue;242 243 //extract pedestal244 UInt_t ab[2];245 const Float_t sum = fExtractor ?246 CalcExtractor(pixel, nlo>0?nhi:0) :247 CalcSums(pixel, nlo>0?nhi:0, ab[0], ab[1]);248 249 const UInt_t aidx = (*fGeom)[idx].GetAidx();250 const UInt_t sector = (*fGeom)[idx].GetSector();251 252 const Float_t sqrsum = sum*sum;253 254 fSumx[idx] += sum;255 fSumx2[idx] += sqrsum;256 fAreaSumx[aidx] += sum;257 fAreaSumx2[aidx] += sqrsum;258 fSectorSumx[sector] += sum;259 fSectorSumx2[sector] += sqrsum;260 261 if (fIntermediateStorage)262 (*fPedestalsInter)[idx].Set(sum, 0, 0, fNumEventsUsed[idx]);263 264 fNumEventsUsed[idx] ++;265 fAreaFilled [aidx] ++;266 fSectorFilled [sector]++;267 268 if (!fExtractor && pixel.IsABFlagValid())269 {270 fSumAB0[idx] += ab[0];271 fSumAB1[idx] += ab[1];272 fAreaSumAB0[aidx] += ab[0];273 fAreaSumAB1[aidx] += ab[1];274 fSectorSumAB0[aidx] += ab[0];275 fSectorSumAB1[aidx] += ab[1];276 }277 278 216 if (!fPedestalUpdate || (UInt_t)fNumEventsUsed[idx]<fNumEventsDump) 279 217 continue; 280 218 281 CalcPixResults(fNumEventsDump, idx); 282 fTotalCounter[idx]++; 219 CalcPixResults(idx); 283 220 284 221 fNumEventsUsed[idx]=0; … … 289 226 } 290 227 291 if (!(GetNumExecutions() % fNumAreasDump)) 228 if (fNumAreasDump>0 && !(GetNumExecutions() % fNumAreasDump)) 229 { 292 230 CalcAreaResult(); 293 294 if (!(GetNumExecutions() % fNumSectorsDump)) 231 fAreaFilled.Reset(); 232 } 233 234 if (fNumSectorsDump>0 && !(GetNumExecutions() % fNumSectorsDump)) 235 { 295 236 CalcSectorResult(); 237 fSectorFilled.Reset(); 238 } 296 239 297 240 if (fPedestalUpdate) … … 299 242 300 243 return kTRUE; 301 }302 303 // --------------------------------------------------------------------------304 //305 // Loop over the sector indices to get the averaged pedestal per sector306 //307 void MPedCalcFromLoGain::CalcSectorResult()308 {309 for (UInt_t sector=0; sector<fSectorFilled.GetSize(); sector++)310 if (fSectorValid[sector]>0)311 CalcSectorResults(fSectorFilled[sector], fSectorValid[sector], sector);312 }313 314 // --------------------------------------------------------------------------315 //316 // Loop over the (two) area indices to get the averaged pedestal per aidx317 //318 void MPedCalcFromLoGain::CalcAreaResult()319 {320 for (UInt_t aidx=0; aidx<fAreaFilled.GetSize(); aidx++)321 if (fAreaValid[aidx]>0)322 CalcAreaResults(fAreaFilled[aidx], fAreaValid[aidx], aidx);323 324 244 } 325 245 … … 336 256 *fLog << flush << inf << "Calculating Pedestals..." << flush; 337 257 338 const Int_t npix = fGeom->GetNumPixels(); 339 for (Int_t idx=0; idx<npix; idx++) 340 { 341 const ULong_t n = fNumEventsUsed[idx]; 342 if (n>1) 343 { 344 CalcPixResults(n, idx); 345 fTotalCounter[idx]++; 346 } 347 } 348 258 CalcPixResult(); 349 259 CalcAreaResult(); 350 260 CalcSectorResult(); -
trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h
r8357 r8490 4 4 #ifndef MARS_MExtractPedestal 5 5 #include "MExtractPedestal.h" 6 #endif7 8 #ifndef ROOT_TArrayI9 #include <TArrayI.h>10 6 #endif 11 7 … … 28 24 UInt_t fNumSectorsDump; // Number of events after which averaged sectors gets updated 29 25 30 TArrayI fNumEventsUsed; //! Number of events used for pedestal calc for each pixel31 TArrayI fTotalCounter; //! Counter for dumping values to Pedestal Container32 33 26 Bool_t fPedestalUpdate; // Flag if the pedestal shall be updated after every fNumEventsDump 34 27 … … 43 36 Int_t Calc(); 44 37 45 //Helper function to extract slice values by slice number46 //void CalcExtractor(const MRawEvtPixelIter &pixel, Float_t &sum, MPedestalPix &ped);47 void ResetArrays();48 49 void CalcSectorResult();50 void CalcAreaResult();51 52 38 public: 53 39 MPedCalcFromLoGain(const char *name=NULL, const char *title=NULL); 54 40 55 41 // Getters 56 TArrayI *GetNumEventsUsed() { return &fNumEventsUsed; }57 58 42 void SetNumEventsDump (UInt_t dumpevents=fgNumDump) { fNumEventsDump = dumpevents; } 59 43 void SetNumAreasDump (UInt_t dumpevents=fgNumDump) { fNumAreasDump = dumpevents; } -
trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
r8296 r8490 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MPedCalcPedRun.cc,v 1.5 0 2007-02-03 20:03:35 tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MPedCalcPedRun.cc,v 1.51 2007-05-11 10:25:45 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 24 24 ! Author(s): Markus Gaug 01/2004 <mailto:markus@ifae.es> 25 25 ! 26 ! Copyright: MAGIC Software Development, 2000-200 626 ! Copyright: MAGIC Software Development, 2000-2007 27 27 ! 28 28 ! … … 127 127 #include "MLogManip.h" 128 128 129 #include "MRawRunHeader.h" 130 #include "MRawEvtHeader.h" 129 #include "MRawRunHeader.h" 131 130 #include "MRawEvtPixelIter.h" 132 #include "MRawEvtData.h" 133 134 #include "MPedestalPix.h" 131 135 132 #include "MPedestalCam.h" 136 137 #include "MGeomPix.h"138 #include "MGeomCam.h"139 140 #include "MExtractPedestal.h"141 #include "MPedestalSubtractedEvt.h"142 133 143 134 #include "MTriggerPattern.h" … … 160 151 // 161 152 MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title) 162 : fIsFirstPedRun(kFALSE), f UsedEvents(0), fTrigPattern(NULL)153 : fIsFirstPedRun(kFALSE), fTrigPattern(NULL) 163 154 { 164 155 fName = name ? name : "MPedCalcPedRun"; … … 170 161 // -------------------------------------------------------------------------- 171 162 // 172 // Call MExtractPedestal:: reset and set fUsedEvents to 0.163 // Call MExtractPedestal::ResetArrays 173 164 // 174 165 void MPedCalcPedRun::Reset() 175 166 { 176 167 MExtractPedestal::ResetArrays(); 177 fUsedEvents = 0;178 168 } 179 169 … … 184 174 Int_t MPedCalcPedRun::PreProcess(MParList *pList) 185 175 { 186 fUsedEvents = 0;187 176 fIsFirstPedRun = kTRUE; 188 177 fIsNotPedRun = kFALSE; … … 272 261 return kTRUE; 273 262 274 fUsedEvents++;275 276 263 MRawEvtPixelIter pixel(fRawEvt); 277 264 while (pixel.Next()) 278 { 279 const UInt_t idx = pixel.GetPixelId(); 280 281 if (!CheckVariation(idx)) 282 continue; 283 284 //extract pedestal 285 UInt_t ab[2]; 286 const Float_t sum = fExtractor ? 287 CalcExtractor(pixel, 0) : 288 CalcSums(pixel, 0, ab[0], ab[1]); 289 290 if (fIntermediateStorage) 291 (*fPedestalsInter)[idx].Set(sum, 0, 0, fUsedEvents); 292 293 const Float_t sqrsum = sum*sum; 294 295 fSumx[idx] += sum; 296 fSumx2[idx] += sqrsum; 297 298 fSumAB0[idx] += ab[0]; 299 fSumAB1[idx] += ab[1]; 300 301 if (fUseSpecialPixels) 302 continue; 303 304 const UInt_t aidx = (*fGeom)[idx].GetAidx(); 305 const UInt_t sector = (*fGeom)[idx].GetSector(); 306 307 fAreaSumx[aidx] += sum; 308 fAreaSumx2[aidx] += sqrsum; 309 fSectorSumx[sector] += sum; 310 fSectorSumx2[sector] += sqrsum; 311 312 fAreaSumAB0[aidx] += ab[0]; 313 fAreaSumAB1[aidx] += ab[1]; 314 fSectorSumAB0[aidx] += ab[0]; 315 fSectorSumAB1[aidx] += ab[1]; 316 } 265 CalcPixel(pixel, 0, fUseSpecialPixels); 317 266 318 267 fPedestalsOut->SetReadyToSave(); … … 327 276 Int_t MPedCalcPedRun::Finalize() 328 277 { 329 if (fUsedEvents == 0)330 return kTRUE;331 332 278 // 333 279 // Necessary check for extraction of special pixels … … 337 283 return kTRUE; 338 284 339 MRawEvtPixelIter pixel(fRawEvt); 340 while (pixel.Next()) 341 CalcPixResults(fUsedEvents, pixel.GetPixelId()); 285 CalcPixResult(); 342 286 343 287 if (!fUseSpecialPixels) 344 288 { 345 346 // 347 // Loop over the (two) area indices to get the averaged pedestal per aidx 348 // 349 for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++) 350 if (fAreaValid[aidx]>0) 351 CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx); 352 353 // 354 // Loop over the (six) sector indices to get the averaged pedestal per sector 355 // 356 for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++) 357 if (fSectorValid[sector]>0) 358 CalcSectorResults(fUsedEvents, fSectorValid[sector], sector); 289 CalcAreaResult(); 290 CalcSectorResult(); 359 291 } 360 292 361 fPedestalsOut->Set TotalEntries(fUsedEvents*fExtractWinSize);293 fPedestalsOut->SetNumSlices(fExtractWinSize); 362 294 fPedestalsOut->SetReadyToSave(); 363 295 … … 405 337 406 338 *fLog << "First pedrun out of sequence: " << (fIsFirstPedRun?"yes":"no") << endl; 407 *fLog << "Number of used events so far: " << fUsedEvents << endl; 408 } 339 } -
trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h
r8357 r8490 18 18 Bool_t fIsFirstPedRun; //! Flag to tell if the first run out of many is used 19 19 Bool_t fIsNotPedRun; //! Flag to tell if the current run is a pedestal run 20 UInt_t fUsedEvents; // Number of used (not skipped) events21 20 22 21 MTriggerPattern *fTrigPattern; //! Trigger pattern decoded -
trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc
r7804 r8490 20 20 ! Author(s): Florian Goebel 06/2004 <mailto:fgoebel@mppmu.mpg.de> 21 21 ! 22 ! Copyright: MAGIC Software Development, 2000-200 422 ! Copyright: MAGIC Software Development, 2000-2007 23 23 ! 24 24 ! … … 26 26 27 27 ///////////////////////////////////////////////////////////////////////////// 28 // // 29 // MPedestalCam // 30 // // 31 // Hold the Pedestal information for all pixels in the camera // 32 // // 28 // 29 // MPedestalCam 30 // 31 // Hold the Pedestal information for all pixels in the camera 32 // 33 // Class Version 2: 34 // ---------------- 35 // + fNumSlices 36 // - fTotalEntries 37 // 33 38 ///////////////////////////////////////////////////////////////////////////// 34 39 #include "MPedestalCam.h" … … 73 78 // 74 79 MPedestalCam::MPedestalCam(const char *name, const char *title) 75 : f TotalEntries(0)80 : fNumSlices(0) 76 81 { 77 82 fName = name ? name : "MPedestalCam"; 78 83 fTitle = title ? title : "Storage container for all Pedestal Information in the camera"; 79 84 80 85 fArray = new TClonesArray("MPedestalPix", 1); 81 86 fAverageAreas = new TClonesArray("MPedestalPix", 1); … … 107 112 108 113 MPedestalCam &cam = (MPedestalCam&)obj; 109 114 110 115 Int_t n = GetSize(); 111 116 112 117 if (n==0) 113 118 return; 114 119 115 120 cam.InitSize(n); 116 121 for (int i=0; i<n; i++) … … 272 277 { fAverageAreas->R__FOR_EACH(TObject, Clear)(); } 273 278 { fAverageSectors->R__FOR_EACH(TObject, Clear)(); } 274 275 f TotalEntries = 0;279 280 fNumSlices = 0; 276 281 } 277 282 … … 512 517 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 513 518 continue; 514 519 515 520 const UInt_t sector = geom[i].GetSector(); 516 521 517 522 if (sec != sector) 518 523 continue; 519 524 520 525 const MPedestalPix &pix = (*this)[i]; 521 526 522 527 rms += pix.GetPedestalRms(); 523 528 rms2 += pix.GetPedestalRms()*pix.GetPedestalRms(); 524 529 nr ++; 525 530 526 531 } 527 532 … … 530 535 arr[1] = nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0; 531 536 return arr; 532 533 537 } 534 538 … … 542 546 return kFALSE; 543 547 544 const Float_t ped 545 const Float_t rms 548 const Float_t ped = (*this)[idx].GetPedestal(); 549 const Float_t rms = (*this)[idx].GetPedestalRms(); 546 550 547 551 switch (type) … … 551 555 break; 552 556 case 1: 553 val = f TotalEntries >0 ?554 rms/TMath::Sqrt((Float_t)f TotalEntries)555 : (*this)[idx].GetPedestalError();557 val = fNumSlices>0 ? 558 rms/TMath::Sqrt((Float_t)fNumSlices*(*this)[idx].GetNumEvents()) 559 : (*this)[idx].GetPedestalError(); 556 560 break; 557 561 case 2: … … 559 563 break; 560 564 case 3: 561 val = f TotalEntries >0 ?562 rms/TMath::Sqrt((Float_t)f TotalEntries*2.)565 val = fNumSlices>0 ? 566 rms/TMath::Sqrt((Float_t)fNumSlices*(*this)[idx].GetNumEvents()*2.) 563 567 : (*this)[idx].GetPedestalRmsError(); 564 568 break; -
trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h
r7188 r8490 23 23 TClonesArray *fAverageSectors; //-> Array of MPedestalPix, one per camera sector 24 24 25 UInt_t f TotalEntries; // Total number of times, the Process was executed (to estimate the error of pedestal)25 UInt_t fNumSlices; // Total number of slices 26 26 27 27 void PrintArr(const TCollection &list) const; … … 45 45 Float_t GetPedestalMax ( const MGeomCam *cam ) const; 46 46 Int_t GetSize () const; 47 ULong_t Get TotalEntries () const { return fTotalEntries; }47 ULong_t GetNumSlices() const { return fNumSlices; } 48 48 49 49 TArrayF GetAveragedPedPerArea ( const MGeomCam &geom, const UInt_t ai=0, MBadPixelsCam *bad=NULL ); … … 63 63 64 64 // Setters 65 void Set TotalEntries(const ULong_t n) { fTotalEntries = n; }65 void SetNumSlices(const ULong_t n) { fNumSlices = n; } 66 66 67 67 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const; 68 68 void DrawPixelContent(Int_t idx) const; 69 69 70 ClassDef(MPedestalCam, 1) // Storage Container for all pedestal information of the camera70 ClassDef(MPedestalCam, 2) // Storage Container for all pedestal information of the camera 71 71 }; 72 72
Note:
See TracChangeset
for help on using the changeset viewer.