Changeset 8304 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 02/04/07 15:33:08 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
r8301 r8304 102 102 const TString MJPedestal::fgReferenceFile = "mjobs/pedestalref.rc"; 103 103 const TString MJPedestal::fgBadPixelsFile = "mjobs/badpixels_0_559.rc"; 104 const Float_t MJPedestal::fgExtractWinLeft = 2.5;105 const Float_t MJPedestal::fgExtractWinRight = 4.5;104 const Float_t MJPedestal::fgExtractWinLeft = 0; 105 const Float_t MJPedestal::fgExtractWinRight = 0; 106 106 107 107 // -------------------------------------------------------------------------- … … 859 859 return kTRUE; 860 860 861 Int_t numhigainsamples = 0; 862 Int_t numlogainsamples = 0; 863 864 Float_t meanpulsetime = 0.; 865 Float_t rmspulsetime = 0.; 866 867 if (IsUseMC()) 868 { 869 // 870 // FIXME: 871 // The MC cannot run over the first 2000 pedestal events since almost all 872 // events are empty, therefore a pulse pos. check is not possible, either. 873 // For the moment, have to fix the problem hardcoded... 874 // 875 // MMcEvt *evt = (MMcEvt*)plist.FindObject("MMcEvt"); 876 // const Float_t meanpulsetime = evt->GetFadcTimeJitter(); 877 meanpulsetime = 4.5; 878 rmspulsetime = 1.0; 879 880 numhigainsamples = 15; 881 numlogainsamples = 15; 882 883 } 884 else 861 // FIXME: 862 // The MC cannot run over the first 2000 pedestal events since almost all 863 // events are empty, therefore a pulse pos. check is not possible, either. 864 // For the moment, have to fix the problem hardcoded... 865 // 866 // MMcEvt *evt = (MMcEvt*)plist.FindObject("MMcEvt"); 867 // const Float_t meanpulsetime = evt->GetFadcTimeJitter(); 868 Float_t meanpulsetime = 4.5; 869 Float_t rmspulsetime = 1.0; 870 871 if (!IsUseMC()) 885 872 { 886 873 if (fIsPixelCheck) … … 909 896 meanpulsetime = cam->GetAverageArea(0).GetHiGainMean(); 910 897 rmspulsetime = cam->GetAverageArea(0).GetHiGainRms(); 911 912 MRawEvtData *data = (MRawEvtData*)plist.FindObject("MRawEvtData");913 if (!data)914 {915 *fLog << err << "MRawEvtData not found... abort." << endl;916 return kFALSE;917 }918 919 numhigainsamples = data->GetNumHiGainSamples();920 numlogainsamples = data->GetNumLoGainSamples();921 898 } 922 899 … … 924 901 *fLog << meanpulsetime << "+-" << rmspulsetime << endl; 925 902 926 const MExtractTimeAndCharge *ext = dynamic_cast<MExtractTimeAndCharge*>(fExtractor); 927 928 // 929 // Get the ranges for the new extractor setting 930 // 931 const Int_t newfirst = TMath::Nint(meanpulsetime-fExtractWinLeft); 932 933 Int_t wshigain = ext ? ext->GetWindowSizeHiGain() : 6; 934 if (wshigain > 6) 935 wshigain = 6; 936 937 Int_t wslogain = ext ? ext->GetWindowSizeLoGain() : 4; 938 if (wslogain > 4) 939 wslogain = 4; 940 941 const Int_t newlast = TMath::Nint(meanpulsetime+fExtractWinRight); 942 943 *fLog << underline; 944 *fLog << "Try to set new range limits: (" << newfirst << "," << newlast; 945 *fLog << "+" << wshigain << "," << newfirst-1 << "," << newlast << "+"; 946 *fLog << wslogain << ")" << endl; 947 948 // 949 // Check the ranges for the new extractor setting 950 // 951 if (newfirst < 0) 952 { 953 //*fLog << err << "Pulse is too much to the left, cannot go below 0!" << endl; 954 //return -1; 955 } 956 if (newlast+wshigain > numhigainsamples+numlogainsamples-1) 957 { 958 *fLog << err << "Pulse is too much to the right, cannot go beyond limits: "; 959 *fLog << numhigainsamples << "+" << numlogainsamples << "-1" << endl; 960 *fLog << " Cannot extract at all!" << endl; 961 return -3; 962 } 963 if (newlast+wslogain > numlogainsamples) 964 { 965 *fLog << err << "Pulse is too much to the right, cannot go beyond logain limits!" << endl; 966 *fLog << endl; 967 *fLog << "Try to use a different extractor (e.g. with a window size of only 4 sl.) or:" << endl; 968 *fLog << "Set the limit to a lower value (callisto.rc):" << endl; 969 *fLog << " MJPedestalY2:ExtractWinRight: 4.5" << endl; 970 *fLog << "(ATTENTION, you will lose late cosmics pulses!)" << endl; 903 MExtractTimeAndCharge *ext = dynamic_cast<MExtractTimeAndCharge*>(fExtractor); 904 if (!ext) 905 { 906 *fLog << warn << "WARNING - no extractor found inheriting from MExtractTimeAndCharge... no pulse position check." << endl; 907 return kTRUE; 908 } 909 910 const Int_t hi0 = ext->GetHiGainFirst(); 911 const Int_t lo1 = ext->GetLoGainLast(); 912 Int_t hi1 = ext->GetHiGainLast(); 913 Int_t lo0 = ext->GetLoGainFirst(); 914 915 // 916 // Get the ranges for the new extractor setting. The window 917 // size is always rounded to the next higher integer. 918 // 919 const Int_t wshigain = ext->GetWindowSizeHiGain(); 920 const Int_t wslogain = ext->GetWindowSizeLoGain(); 921 922 // 923 // Here we calculate the end of the lo-gain range 924 // as it is done in MExtractTimeAndCharge 925 // 926 const Double_t poshi = meanpulsetime; 927 const Double_t poslo = poshi + ext->GetOffsetLoGain(); 928 const Double_t poslo2 = poslo + ext->GetLoGainStartShift(); 929 930 // 931 // Do the right side checks range checks 932 // 933 if (poshi+wshigain+fExtractWinRight > hi1-0.5) 934 { 935 *fLog << err; 936 *fLog << "ERROR - Pulse is too much to the right, out of hi-gain range ["; 937 *fLog << hi0 << "," << hi1 << "]" << endl; 971 938 *fLog << endl; 972 939 return -2; 973 940 } 974 941 942 if (poslo+wslogain+fExtractWinRight > lo1-0.5) 943 { 944 *fLog << err; 945 *fLog << "ERROR - Pulse is too much to the right, out of lo-gain range ["; 946 *fLog << lo0 << "," << lo1 << "]" << endl; 947 return -2; 948 } 949 950 // 951 // Do the left side checks range checks 952 // 953 if (poshi-fExtractWinLeft < hi0+0.5) 954 { 955 *fLog << err; 956 *fLog << "ERROR - Pulse is too much to the left, out of hi-gain range ["; 957 *fLog << hi0 << "," << hi1 << "]" << endl; 958 return -3; 959 } 960 961 if (poslo2-fExtractWinLeft < lo0+0.5) 962 { 963 *fLog << warn; 964 *fLog << "WARNING - Pulse is too much to the left, out of lo-gain range ["; 965 *fLog << lo0 << "," << lo1 << "]" << endl; 966 *fLog << "Trying to match extraction window and pulse position..." << endl; 967 968 // 969 // Set and store the new ranges 970 // 971 Int_t shift = 0; 972 while (poslo2-fExtractWinLeft < lo0+0.5) 973 { 974 hi1--; 975 lo0--; 976 977 if (poshi+wshigain+fExtractWinRight > hi1-0.5) 978 { 979 *fLog << err << "ERROR - No proper extraction window found.... abort." << endl; 980 return -3; 981 } 982 } 983 984 *fLog << "Changed extraction window by " << shift; 985 *fLog << "slices to hi-gain [" << hi0 << "," << hi1; 986 *fLog << "] and lo-gain [" << lo0 << "," << lo1 << "]" << endl; 987 988 ext->SetRange(hi0, hi1, lo0, lo1); 989 } 990 975 991 return kTRUE; 976 /*977 //978 // Set and store the new ranges979 //980 const Int_t hi0 = newfirst;981 const Int_t hi1 = newlast+wshigain;982 983 const Int_t lo0 = newfirst>0 ? newfirst-1 : newfirst;984 const Int_t lo1 = numlogainsamples-1;985 986 fExtractor->SetRange(hi0, hi1, lo0, lo1);987 return kTRUE;*/988 992 } 989 993
Note:
See TracChangeset
for help on using the changeset viewer.