Changeset 7098 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 05/27/05 16:25:27 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MC_weights46.dat
r7013 r7098 43 43 # Low Gain Weights: 6 10 44 44 # (Amplitude) (Time) 45 0.0 138311 -0.016591946 0.0 117372 -0.035400547 0.0 0232654 -0.058101848 -0.00791094 -0.0631271 49 -0.0131845 -0.0558022 50 -0.0154786 -0.048077251 -0.0171358 -0.0420274 52 -0.0199068 -0.0340744 53 -0.02688 -0.0117278 54 -0.0404328 0.0754397 55 -0.0357035 0.342673 56 0. 00409834 0.84927457 0. 248584 1.5218158 0. 528673 1.6797459 0. 67261 1.4706860 0. 735023 1.2496561 0. 778865 1.1039562 0.832049 1.02856 63 0.907609 1.00924 64 1. 07304 1.0920865 1. 25051 1.1490666 1.3 7475 1.025367 1.5 2056 0.65311268 1.5 3175 0.16307669 1. 49683 -0.1527370 1.47 188 -0.34425271 1.45 258 -0.5012972 1.4 2348 -0.67021873 1.3 673 -0.8775674 1. 19832 -1.2055775 0.99973 -1.5324876 0.808836 -1.68211 77 0.533208 -1.45238 78 0.446023 -0.900265 79 0.459037 -0.529769 80 0. 470945 -0.36805381 0. 465845 -0.31352582 0. 446981 -0.31192683 0. 415815 -0.34231784 0. 348688 -0.42543985 0. 271752 -0.49543786 0. 211195 -0.50387987 0. 131582 -0.41327688 0. 109187 -0.24515689 0. 114005 -0.13900690 0. 117671 -0.093911691 0. 116527 -0.07857292 0. 11177 -0.077289693 0. 103901 -0.084009894 0. 0871027 -0.10235795 0. 0758618 -0.11901996 0. 0611863 -0.11899197 0. 0430436 -0.093081498 0. 0390695 -0.051716299 0. 0409257 -0.027711100 0. 0420581 -0.0186558101 0. 0419035 -0.0164813102 0. 0408279 -0.0174564103 0. 0389147 -0.0202082104 0. 0345678 -0.02523245 0.0446612 -0.385273 46 0.038191 -0.00418687 47 0.0386966 0.0212324 48 0.0402881 0.0744799 49 0.0415794 0.229615 50 0.0598731 0.44332 51 0.0758477 0.661518 52 0.101509 1.10641 53 0.159323 1.64997 54 0.497256 2.83685 55 0.245087 3.27499 56 0.140546 2.46177 57 0.58086 2.2849 58 0.632721 2.45587 59 0.72819 2.52835 60 0.889583 2.48099 61 0.980812 2.50031 62 1.09885 2.55892 63 1.21374 2.78769 64 1.61928 3.08069 65 1.38544 1.95583 66 1.31998 1.1792 67 1.50633 0.591226 68 1.50916 0.0793899 69 1.5008 -0.33188 70 1.47339 -0.575386 71 1.45362 -0.915309 72 1.40214 -1.31593 73 1.34175 -1.77904 74 1.0661 -2.05471 75 1.31087 -1.49798 76 1.33793 -1.34758 77 1.10172 -1.21719 78 1.08133 -1.09356 79 1.04007 -0.981455 80 0.976745 -1.08299 81 0.930979 -1.14774 82 0.874203 -1.18348 83 0.816708 -1.20126 84 0.587354 -1.92869 85 0.783078 -1.89621 86 0.792771 -1.03439 87 0.622278 -0.781807 88 0.61184 -0.745831 89 0.578792 -0.683741 90 0.537336 -0.596328 91 0.51443 -0.592858 92 0.482294 -0.560586 93 0.462351 -0.827587 94 0.317989 -1.05649 95 0.459672 -0.775035 96 0.468287 -0.619961 97 0.374182 -0.31635 98 0.376946 -0.225242 99 0.367075 -0.347444 100 0.340737 -0.393231 101 0.321054 -0.187384 102 0.320654 -0.225558 103 0.302148 -0.399499 104 0.232954 -0.607578 -
trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc
r7043 r7098 181 181 case 8: 182 182 case 10: 183 case 12: 183 184 SetResolutionPerPheLoGain(0.011); 184 185 break; 185 186 default: 186 187 *fLog << warn << GetDescriptor() << ": Could not set the lo-gain extractor resolution/phe for window size " << wslogain << endl; 188 SetResolutionPerPheLoGain(0.011); 187 189 } 188 190 } -
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc
r7043 r7098 30 30 // Hendrik has promised to write more documentation 31 31 // 32 //33 32 // The following variables have to be set by the derived class and 34 33 // do not have defaults: … … 38 37 // - fSqrtLoGainSamples 39 38 // 39 // The reading of automatic weights files (color, type) can be switched 40 // off using EnableAutomaticWeights(kFALSE). 41 // 42 // An empty name or "-" as the weights file name is a synonym for 43 // setting all weights to 1 44 // 40 45 // Input Containers: 41 46 // MRawEvtData 42 47 // MRawRunHeader 43 48 // MPedestalCam 49 // [MCalibrationPattern] 44 50 // 45 51 // Output Containers: … … 53 59 #include <fstream> 54 60 55 #include <TFile.h> 56 #include <TH1F.h> 57 #include <TH2F.h> 58 #include <TString.h> 61 #include <TH1.h> 62 #include <TH2.h> 59 63 #include <TMatrix.h> 60 64 61 65 #include "MLog.h" 62 66 #include "MLogManip.h" 67 68 #include "MParList.h" 69 70 #include "MRawRunHeader.h" 71 #include "MCalibrationPattern.h" 63 72 64 73 #include "MPedestalPix.h" … … 78 87 const Int_t MExtractTimeAndChargeDigitalFilter::fgSignalStartBinHiGain = 4; 79 88 const Int_t MExtractTimeAndChargeDigitalFilter::fgSignalStartBinLoGain = 4; 80 const TString MExtractTimeAndChargeDigitalFilter::fgNameWeightsFile = "msignal/cosmics_weights.dat";81 89 const Float_t MExtractTimeAndChargeDigitalFilter::fgOffsetLoGain = 1.7; // 5 ns 82 90 const Float_t MExtractTimeAndChargeDigitalFilter::fgLoGainStartShift = -1.8; … … 94 102 // 95 103 MExtractTimeAndChargeDigitalFilter::MExtractTimeAndChargeDigitalFilter(const char *name, const char *title) 96 : fTimeShiftHiGain(0.), fTimeShiftLoGain(0.), f WeightsSet(kFALSE), fRandomIter(0)104 : fTimeShiftHiGain(0.), fTimeShiftLoGain(0.), fAutomaticWeights(kTRUE), fRandomIter(0) 97 105 { 98 106 fName = name ? name : "MExtractTimeAndChargeDigitalFilter"; … … 104 112 SetSignalStartBin(); 105 113 106 SetNameWeightsFile();107 114 SetOffsetLoGain(fgOffsetLoGain); 108 115 SetLoGainStartShift(fgLoGainStartShift); … … 184 191 // -------------------------------------------------------------------------- 185 192 // 193 // Executing MExtractTimeAndCharge::PreProcess and searching for 194 // MCalibrationPattern 195 // 196 Int_t MExtractTimeAndChargeDigitalFilter::PreProcess(MParList *pList) 197 { 198 if (!MExtractTimeAndCharge::PreProcess(pList)) 199 return kFALSE; 200 201 fCalibPattern = (MCalibrationPattern*)pList->FindObject("MCalibrationPattern"); 202 return kTRUE; 203 } 204 205 // -------------------------------------------------------------------------- 206 // 186 207 // InitArrays 187 208 // … … 190 211 Bool_t MExtractTimeAndChargeDigitalFilter::InitArrays() 191 212 { 192 193 Int_t range = (Int_t)(fHiGainLast - fHiGainFirst + 1 + fHiLoLast); 194 195 fHiGainSignal.Set(range); 196 197 range = (Int_t)(fLoGainLast - fLoGainFirst + 1); 198 199 fLoGainSignal.Set(range); 200 201 if (!fWeightsSet) 202 if (!ReadWeightsFile(fNameWeightsFile)) 203 return kFALSE; 204 205 fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain; 206 fTimeShiftLoGain = 0.5 + 1./fBinningResolutionLoGain; 207 // 208 // We need here the effective number of samples which is about 2.5 in the case of a window 209 // size of 6. The exact numbers have to be found still. 210 // 211 fNumHiGainSamples = (Float_t)fWindowSizeHiGain/2.4; 212 fNumLoGainSamples = (Float_t)fWindowSizeLoGain/2.4; 213 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples); 214 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 215 216 return kTRUE; 213 if (!fRunHeader) 214 return kFALSE; 215 216 const Int_t rangehi = (Int_t)(fHiGainLast - fHiGainFirst + 1 + fHiLoLast); 217 const Int_t rangelo = (Int_t)(fLoGainLast - fLoGainFirst + 1); 218 219 fHiGainSignal.Set(rangehi); 220 fLoGainSignal.Set(rangelo); 221 222 // Try to get automatic weights 223 if (!ReadAutomaticWeightsFile()) 224 return kFALSE; 225 226 // If still no weights set try conservative way 227 if (fNameWeightsFileSet.IsNull()) 228 if (!ReadWeightsFile(fNameWeightsFile)) 229 return kFALSE; 230 231 fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain; 232 fTimeShiftLoGain = 0.5 + 1./fBinningResolutionLoGain; 233 // 234 // We need here the effective number of samples which is about 2.5 in the case of a window 235 // size of 6. The exact numbers have to be found still. 236 // 237 fNumHiGainSamples = (Float_t)fWindowSizeHiGain/2.4; 238 fNumLoGainSamples = (Float_t)fWindowSizeLoGain/2.4; 239 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples); 240 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 241 242 return kTRUE; 217 243 } 218 244 … … 556 582 // MJPedestal.MExtractor.BinningResolutionLoGain: 10 557 583 // MJPedestal.MExtractor.WeightsFile: filename 584 // MJPedestal.MExtractor.AutomaticWeights: off 558 585 // 559 586 Int_t MExtractTimeAndChargeDigitalFilter::ReadEnv(const TEnv &env, TString prefix, Bool_t print) … … 563 590 Byte_t lw = fWindowSizeLoGain; 564 591 Bool_t rc = kFALSE; 565 592 593 if (IsEnvDefined(env, prefix, "AutomaticWeights", print)) 594 { 595 EnableAutomaticWeights(GetEnvValue(env, prefix, "AutomaticWeights", fAutomaticWeights)); 596 rc = kTRUE; 597 } 598 566 599 if (IsEnvDefined(env, prefix, "WindowSizeHiGain", print)) 567 600 { … … 601 634 if (IsEnvDefined(env, prefix, "WeightsFile", print)) 602 635 { 603 if (!ReadWeightsFile(GetEnvValue(env, prefix, "WeightsFile", "")))604 return kERROR;605 rc = kTRUE;636 SetNameWeightsFile(GetEnvValue(env, prefix, "WeightsFile", "")); 637 *fLog << all << "**********> " << fNameWeightsFile << endl; 638 rc = kTRUE; 606 639 } 607 640 … … 621 654 // This is a fix for TEnv files edited with windows editors 622 655 filename.ReplaceAll("\015", ""); 623 624 SetNameWeightsFile(filename);625 656 626 657 fAmpWeightsHiGain .Set(fBinningResolutionHiGain*fWindowSizeHiGain); … … 629 660 fTimeWeightsLoGain.Set(fBinningResolutionLoGain*fWindowSizeLoGain); 630 661 631 if (fNameWeightsFile.IsNull() )662 if (fNameWeightsFile.IsNull() || fNameWeightsFile=="-") 632 663 { 633 664 fAmpWeightsHiGain.Reset(1); … … 635 666 fAmpWeightsLoGain.Reset(1); 636 667 fTimeWeightsLoGain.Reset(1); 668 fNameWeightsFileSet = "-"; 637 669 return kTRUE; 638 670 } 671 672 //filename = MJob::ExpandPath(filename); 673 674 if (fNameWeightsFileSet==filename) 675 return kTRUE; 639 676 640 677 ifstream fin(filename.Data()); … … 646 683 } 647 684 648 *fLog << inf << "Reading weights file" << filename << "..." << flush;685 *fLog << all << "DigitalFilter: Reading weights in " << filename << "..." << flush; 649 686 650 687 Int_t len = 0; … … 780 817 } 781 818 782 f WeightsSet = kTRUE;819 fNameWeightsFileSet = filename; 783 820 784 821 return kTRUE; 822 } 823 824 825 //---------------------------------------------------------------------------- 826 // 827 // If automatic weight disabled or run type is pedestal no action is taken 828 // and kTRUE is returned. 829 // 830 // Otherwise: 831 // - If runtype is kRTData and filename starts with "MC_weights" "MC" is 832 // replaced by "cosmics" 833 // - If runtype is kRTMonteCarlo and filename starts with "cosmics_weights" 834 // "cosmics" is replaced by "MC" 835 // - If name filename begins with "calibration_weights_" for blue and green 836 // "UV" is replaced by "blue" 837 // - If name filename begins with "calibration_weights_" for UV and CT1 838 // "blue" is replaced by "UV" 839 // 840 // The replacements are done in this order. If no match is found no 841 // replacement is done. Afterwards ReadWeightsFile for the resulting 842 // path-/filename is called. 843 // 844 Bool_t MExtractTimeAndChargeDigitalFilter::ReadAutomaticWeightsFile() 845 { 846 if (!fAutomaticWeights || fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal) 847 return kTRUE; 848 849 *fLog << dbg << endl; 850 *fLog << underline << GetDescriptor() << endl; 851 *fLog << " Trying to get automatic weight for " << fNameWeightsFile << endl; 852 853 const Ssiz_t pos = fNameWeightsFile.Last('/')+1; 854 const Ssiz_t len = fNameWeightsFile.Length(); 855 856 TString path = fNameWeightsFile(0, pos>=0?pos:len); 857 TString name = fNameWeightsFile(pos>=0?pos:0, len); 858 859 if (name.BeginsWith("cosmics_weights") && fRunHeader->GetRunType()==MRawRunHeader::kRTMonteCarlo) 860 { 861 name.Remove(0, 7); 862 name.Prepend("MC"); 863 *fLog << "Run type: Monte Carlo data" << endl; 864 } 865 if (name.BeginsWith("MC_weights") && fRunHeader->GetRunType()==MRawRunHeader::kRTData) 866 { 867 name.Remove(0, 2); 868 name.Prepend("cosmics"); 869 *fLog << "Run type: Cosmics data" << endl; 870 } 871 872 if (name.BeginsWith("calibration_weights_") && fCalibPattern) 873 { 874 *fLog << " Run type: Calibration with color " << (int)fCalibPattern->GetPulserColor() << ", setting "; 875 switch (fCalibPattern->GetPulserColor()) 876 { 877 case MCalibrationCam::kBLUE: // 2 878 case MCalibrationCam::kGREEN: // 1 879 *fLog << "blue/green" << endl; 880 name.ReplaceAll("UV", "blue"); 881 break; 882 883 case MCalibrationCam::kUV: // 3 884 case MCalibrationCam::kCT1: // 0 885 *fLog << "UV/CT1" << endl; 886 name.ReplaceAll("blue", "UV"); 887 break; 888 case MCalibrationCam::kNONE: 889 *fLog << "None" << endl; 890 break; 891 default: // kNONE=4 892 *fLog << "???" << endl; 893 } 894 } 895 896 path += name; 897 898 return ReadWeightsFile(path); 785 899 } 786 900 … … 1065 1179 *fLog << " Window Size HiGain: " << fWindowSizeHiGain << " LoGain: " << fWindowSizeLoGain << endl; 1066 1180 *fLog << " Binning Res HiGain: " << fBinningResolutionHiGain << " LoGain: " << fBinningResolutionHiGain << endl; 1067 *fLog << " Weights File: " << fNameWeightsFile << endl; 1181 *fLog << " Weights File desired: " << (fNameWeightsFile.IsNull()?"-":fNameWeightsFile) << endl; 1182 if (!fNameWeightsFileSet.IsNull()) 1183 *fLog << " Weights File set: " << fNameWeightsFileSet << endl; 1068 1184 1069 1185 TString opt(o);
Note:
See TracChangeset
for help on using the changeset viewer.