Changeset 8706
- Timestamp:
- 08/24/07 13:58:50 (17 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/macros/optim/optimonoff.C
r8671 r8706 6 6 7 7 // ------------------- Xi ----------------------- 8 opt.FixParameter(0, 1.3245); 9 opt.FixParameter(6, 8.2957); 10 opt.FixParameter(7, 0.8677); 11 8 opt.FixParameter( 0, 1.15136); 9 opt.FixParameter( 8, 0.0681437); 10 opt.FixParameter( 9, 2.62932); 11 opt.FixParameter(10, 1.51279); 12 opt.FixParameter(11, 0.0507821); 13 12 14 // --------------- Theta Sq --------------------- 13 opt. SetParameter(1, 0.204);15 opt.FixParameter( 1, 0.215); 14 16 15 17 // ----------------- Area ----------------------- 16 opt.SetParameter( 2, 0.215);17 opt.SetParameter( 3, 5.486);18 opt.SetParameter( 4, 0.0897);18 opt.SetParameter( 2, 0.21); 19 opt.SetParameter( 3, 5.6); 20 opt.SetParameter( 4, 0.083); 19 21 20 22 // ----------------- M3L ------------------------ 21 opt.FixParameter(5, -0.07); 23 opt.FixParameter( 5, -0.07); 24 25 // ---------------- Slope ----------------------- 26 opt.FixParameter( 6, 7.2); 27 opt.FixParameter( 7, 0.5); 22 28 23 29 // ----------------- Fit ------------------------ -
trunk/MagicSoft/Mars/macros/optim/optimwobble.C
r8671 r8706 6 6 7 7 // ------------------- Xi ----------------------- 8 opt.FixParameter(0, 1.221); 9 opt.FixParameter(6, 13.425); 10 opt.FixParameter(7, 1.04343); 8 opt.FixParameter( 0, 1.15136); 9 opt.FixParameter( 8, 0.0681437); 10 opt.FixParameter( 9, 2.62932); 11 opt.FixParameter(10, 1.51279); 12 opt.FixParameter(11, 0.0507821); 11 13 12 14 // --------------- Theta Sq --------------------- 13 opt. SetParameter(1, 0.23);15 opt.FixParameter( 1, 0.215); 14 16 15 17 // ----------------- Area ----------------------- 16 opt.SetParameter( 2, 0.25);17 opt.SetParameter( 3, 5.21);18 opt.SetParameter( 4, 0.11);18 opt.SetParameter( 2, 0.21); 19 opt.SetParameter( 3, 5.6); 20 opt.SetParameter( 4, 0.083); 19 21 20 22 // ----------------- M3L ------------------------ 21 opt.SetParameter(5, -0.089); 23 opt.FixParameter( 5, -0.07); 24 25 // ---------------- Slope ----------------------- 26 opt.FixParameter( 6, 7.2); 27 opt.FixParameter( 7, 0.5); 22 28 23 29 // ----------------- Fit ------------------------ … … 28 34 fit.SetMinimizationStrategy(MAlphaFitter::kSignificanceLogExcess); 29 35 36 // For wobble mode with three off-regions 37 // (sets also ScaleMode to kUser) 38 fit.SetScaleUser(1./3); 39 30 40 // ----------------- Cuts ----------------------- 31 41 32 42 MFMagicCuts cuts; 33 cuts.SetThetaCut(MFMagicCuts::k Wobble);43 cuts.SetThetaCut(MFMagicCuts::kOn); 34 44 35 45 /* You can also try (switch on scaling): … … 47 57 opt.SetDisplay(d); 48 58 49 // opt.SetPathOut("optimwobble.root"); 50 opt.RunOnOff("wobblelza-abs.root", &cuts, &fit); 59 opt.RunOnOff("ganymed00000001-summary.root", &cuts, &fit); 51 60 } -
trunk/MagicSoft/Mars/macros/train/traindisp.C
r8634 r8706 1 /* ======================================================================== *\ 2 ! 3 ! * 4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction 5 ! * Software. It is distributed to you in the hope that it can be a useful 6 ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. 7 ! * It is distributed WITHOUT ANY WARRANTY. 8 ! * 9 ! * Permission to use, copy, modify and distribute this software and its 10 ! * documentation for any purpose is hereby granted without fee, 11 ! * provided that the above copyright notice appear in all copies and 12 ! * that both that copyright notice and this permission notice appear 13 ! * in supporting documentation. It is provided "as is" without express 14 ! * or implied warranty. 15 ! * 16 ! 17 ! 18 ! Author(s): Thomas Bretz, 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2007 21 ! 22 ! 23 \* ======================================================================== *////////////////////////////////////////////////////////////////////////////// 24 25 ///////////////////////////////////////////////////////////////////////////// 26 // 27 // traindisp.C 28 // =========== 29 // 30 // Trains a random forest for disp estimation. 31 // 32 // The additional code below shows how the MagicCuts can be used in 33 // training and testing. There is also code which allows to change the 34 // slope of the input spectrum. If a min- or max-break energy is given 35 // the new slope is only applied in this region. Further possibilities 36 // for additional cuts are shown. 37 // 38 // SequencesOn: Monte Carlo Sequences used for training 39 // SequencesOff: Monte Carlo Sequences used for testing 40 // 41 // Use: 42 // opt.AddPreCut to use cut for test and training 43 // opt.AddTestCut to use cut for test only 44 // opt.AddTrainCut to use cut for train only 45 // opt.AddPreTask a task executed before filling the matrix/evaluating the RF 46 // opt.AddPostTask a task executed before training, after evaluating the RF 47 // 48 ///////////////////////////////////////////////////////////////////////////// 49 1 50 void traindisp() 2 51 { 3 MDataSet set("mc testtrain.txt");52 MDataSet set("mcsponde/mcdataset-for-training.txt"); 4 53 set.SetNumAnalysis(1); // Necessary 5 54 … … 10 59 //opt.SetDebug(); 11 60 61 // These are control parameters how to train the random forest (use with care!) 62 //opt.SetNumTrees(100); 63 //opt.SetNdSize(5); 64 //opt.SetNumTry(0); 65 12 66 // ------- Parameters to train Random Forest -------- 13 67 opt.AddParameter("MHillas.fLength"); … … 15 69 opt.AddParameter("MHillas.fSize"); 16 70 opt.AddParameter("MNewImagePar.fLeakage1"); 17 opt.AddParameter("MNewImagePar.fLeakage2");18 opt.AddParameter("MNewImagePar.fConc");19 opt.AddParameter("MNewImagePar.fConc1");20 71 opt.AddParameter("MPointingPos.fZd"); 21 opt.AddParameter("MNewImagePar.fUsedArea"); 22 opt.AddParameter("MNewImagePar.fCoreArea"); 23 opt.AddParameter("MNewImagePar.fNumUsedPixels"); 24 opt.AddParameter("MNewImagePar.fNumCorePixels"); 25 opt.AddParameter("MImagePar.fSizeSinglePixels"); 26 opt.AddParameter("MHillasExt.fM3Long*sign(MHillasSrc.fCosDeltaAlpha)"); 27 opt.AddParameter("MHillasExt.fAsym*sign(MHillasSrc.fCosDeltaAlpha)"); 72 opt.AddParameter("MHillasExt.fSlopeLong*sign(MHillasSrc.fCosDeltaAlpha)"); 73 //opt.AddParameter("MNewImagePar.fLeakage2"); 74 //opt.AddParameter("MNewImagePar.fConc"); 75 //opt.AddParameter("MNewImagePar.fConc1"); 76 //opt.AddParameter("MNewImagePar.fUsedArea"); 77 //opt.AddParameter("MNewImagePar.fCoreArea"); 78 //opt.AddParameter("MNewImagePar.fNumUsedPixels"); 79 //opt.AddParameter("MNewImagePar.fNumCorePixels"); 80 //opt.AddParameter("MImagePar.fSizeSinglePixels"); 81 //opt.AddParameter("MHillasExt.fM3Long*sign(MHillasSrc.fCosDeltaAlpha)"); 82 //opt.AddParameter("MHillasExt.fAsym*sign(MHillasSrc.fCosDeltaAlpha)"); 28 83 29 84 // -------------------- Run ---------------------------- … … 38 93 cuts.SetThetaCut(MFMagicCuts::kOn); 39 94 40 TArrayD arr(10); 41 arr[0]= 1.3245; 42 arr[1]= 0.208700; 43 arr[2]= 0.229200; 44 arr[3]= 5.305200; 45 arr[4]= 0.098930; 46 arr[5]= -0.082950; 47 arr[6]= 8.2957; 48 arr[7]= 0.8677; 95 TArrayD arr(13); 96 arr[0] = 1.15136; 97 arr[1] = 0.215; 98 arr[2] = 0.215468; 99 arr[3] = 5.63973; 100 arr[4] = 0.0836169; 101 arr[5] = -0.07; 102 arr[6] = 7.2; 103 arr[7] = 0.5; 104 arr[8] = 0.0681437; 105 arr[9] = 2.62932; 106 arr[10] = 1.51279; 107 arr[11] = 0.0507821; 49 108 50 109 cuts.SetVariables(arr); … … 58 117 -------------------- Other cuts ---------------------- 59 118 opt.AddPreCut("MNewImagePar.fLeakage1<0.0001"); 60 */61 62 119 opt.AddPreCut("MHillas.fSize>200"); 63 120 opt.AddPreCut("MHillasSrc.fDCA*MGeomCam.fConvMm2Deg<0.3"); 121 opt.AddPreCut("MPointingPos.fZd<25"); 122 123 ------------------ Zd distribution ------------------- 124 TFile file("ganymed00001111.root"); 125 126 MStatusArray arr; 127 if (arr.Read()<=0) 128 return; 129 TH1D *vstime = (TH1D*)arr.FindObjectInCanvas("Theta", "TH1D", "OnTime"); 130 if (!vstime) 131 return; 132 133 MMcSpectrumWeight weight; 134 weight.SetWeightsZd(vstime); 135 opt.AddPreTask(&weight); 136 137 ---------------------- Histogram -------------------- 138 139 MHn hist("MyHist", "Energy Residual (lg E_{est} - lg E_{mc})"); 140 141 MBinning bins(50, -0.5, 0.5); 142 143 hist.AddHist("MHillasExt.fM3Long*sign(MHillasSrc.fCosDeltaAlpha)*3.37e-3", "Disp.fVal-MHillasSrc.fDist*3.37e-3"); 144 hist.InitName("ResM3l;M3Long;ResidualDist"); 145 hist.InitTitle(";M3l [\\circ];Disp-Dist [\\circ];"); 146 hist.SetDrawOption("colz profx"); 147 hist.SetBinnings(&bins); 148 149 hist.AddHist("MHillasExt.fAsym*sign(MHillasSrc.fCosDeltaAlpha)*3.37e-3", "Disp.fVal-MHillasSrc.fDist*3.37e-3"); 150 hist.InitName("ResAsym;M3Long;ResidualDist"); 151 hist.InitTitle(";Asym [\\circ];Disp-Dist [\\circ];"); 152 hist.SetDrawOption("colz profx"); 153 hist.SetBinnings(&bins); 154 155 MFillH fill(&hist, "", "FillMyHist"); 156 //fill.SetWeight(); // Enable weights to be used to fill this histogram 157 opt.AddTestTask(&fill); 158 159 ------------------------------------------------------ 160 */ 64 161 65 162 // The number is the number of events read from the file … … 67 164 opt.Train("rf-disp.root", set, 30000); 68 165 } 69 /*70 // SequencesOn: Monte Carlo Sequences used for training71 // SequencesOff: Monte Carlo Sequences used for testing72 73 // Use:74 // opt.AddPreCut to use cut for test and training75 // opt.AddTestCut to use cut for test only76 // opt.AddTrainCut to use cut for train only77 */ -
trunk/MagicSoft/Mars/macros/train/trainenergy.C
r8634 r8706 18 18 ! Author(s): Thomas Bretz, 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 620 ! Copyright: MAGIC Software Development, 2000-2007 21 21 ! 22 22 ! … … 36 36 // for additional cuts are shown. 37 37 // 38 // SequencesOn: Monte Carlo Sequences used for training 39 // SequencesOff: Monte Carlo Sequences used for testing 40 // 41 // Use: 42 // opt.AddPreCut to use cut for test and training 43 // opt.AddTestCut to use cut for test only 44 // opt.AddTrainCut to use cut for train only 45 // opt.AddPreTask a task executed before filling the matrix/evaluating the RF 46 // opt.AddPostTask a task executed before training, after evaluating the RF 47 // 38 48 ///////////////////////////////////////////////////////////////////////////// 39 49 void trainenergy() 40 50 { 41 MDataSet set("mc dataset.txt");51 MDataSet set("mcsponde/mcdataset-for-training.txt"); 42 52 set.SetNumAnalysis(1); // Necessary 43 53 … … 48 58 //opt.SetDebug(); 49 59 60 // These are control parameters how to train the random forest (use with care!) 61 //opt.SetNumTrees(100); 62 //opt.SetNdSize(5); 63 //opt.SetNumTry(0); 64 50 65 // ------- Parameters to train Random Forest -------- 66 // The following parameters are the best parameters 51 67 opt.AddParameter("MHillas.fSize"); 52 68 opt.AddParameter("MHillasSrc.fDist"); 53 69 opt.AddParameter("MPointingPos.fZd"); 54 opt.AddParameter("MHillas.GetArea");55 opt.AddParameter("MNewImagePar.fUsedArea");56 opt.AddParameter("MNewImagePar.fCoreArea");57 70 opt.AddParameter("MNewImagePar.fLeakage1"); 58 opt.AddParameter("MNewImagePar.fLeakage2"); 59 opt.AddParameter("MNewImagePar.fConc"); 60 opt.AddParameter("MNewImagePar.fConc1"); 71 opt.AddParameter("MHillasExt.fSlopeLong*sign(MHillasSrc.fCosDeltaAlpha)"); 72 // The influence of these parameters is unclear 73 //opt.AddParameter("MHillasExt.fM3Long*sign(MHillasSrc.fCosDeltaAlpha)"); 74 //opt.AddParameter("MNewImagePar.fConcCOG"); 75 //opt.AddParameter("MHillas.GetArea"); 76 //opt.AddParameter("MNewImagePar.fConc1"); 77 //opt.AddParameter("MNewImagePar.fConc"); 78 //opt.AddParameter("MNewImagePar.fUsedArea"); 79 //opt.AddParameter("MNewImagePar.fCoreArea"); 80 //opt.AddParameter("MNewImagePar.fLeakage2"); 81 82 // Setup how to train the RF. This one gives best results so far 83 opt.SetTrainFunc("log(MMcEvt.fEnergy)/log(MHillas.fSize)", "MHillas.fSize^x"); 84 // opt.SetTrainLog(); // Train in log-energy 85 // opt.SetTrainLin(); // Train just in energy 61 86 62 87 // -------------------- Run ---------------------------- … … 65 90 opt.SetDisplay(d); 66 91 92 // -------------------- Magic-Cuts ---------------------- 93 // It is recommended to test with your cuts, but train with all events 94 95 MFMagicCuts cuts; 96 cuts.SetHadronnessCut(MFMagicCuts::kArea); 97 cuts.SetThetaCut(MFMagicCuts::kOn); 98 99 TArrayD arr(13); 100 arr[0] = 1.15136; 101 arr[1] = 0.215; 102 arr[2] = 0.215468; 103 arr[3] = 5.63973; 104 arr[4] = 0.0836169; 105 arr[5] = -0.07; 106 arr[6] = 7.2; 107 arr[7] = 0.5; 108 arr[8] = 0.0681437; 109 arr[9] = 2.62932; 110 arr[10] = 1.51279; 111 arr[11] = 0.0507821; 112 113 cuts.SetVariables(arr); 114 115 // opt.AddPreCut(&cuts); // add cut for training and testing 116 // opt.AddTrainCut(&cuts); // add cut for training only 117 opt.AddTestCut(&cuts); // add cut for testing only 118 67 119 /* 68 -------------------- Magic-Cuts ----------------------69 MFMagicCuts cuts;70 cuts.SetHadronnessCut(MFMagicCuts::kArea);71 cuts.SetThetaCut(MFMagicCuts::kOn);120 -------------------- Energy Slope -------------------- 121 // This is a way to throw away events to a different slope 122 MFEnergySlope slope(-4.0); // New slope for mc spectrum 123 opt.AddPreCut(&slope); // throw away events to change slope 72 124 73 TArrayD arr(10); 74 arr[0]= 1.3245; 75 arr[1]= 0.208700; 76 arr[2]= 0.229200; 77 arr[3]= 5.305200; 78 arr[4]= 0.098930; 79 arr[5]= -0.082950; 80 arr[6]= 8.2957; 81 arr[7]= 0.8677; 82 83 cuts.SetVariables(arr); 84 85 opt.AddPreCut(&cuts); 86 87 -------------------- Energy Slope -------------------- 88 MFEnergySlope slope(-2.8); // New slope for mc spectrum 89 slope.SetMcMinEnergy(80); // Set break energy from -2.6 to -2.8 90 opt.AddPreCut(&slope); // throw away events to change slope 125 // This is a way to weight the events to a different spectrum 126 MMcSpectrumWeight weight; 127 weight.SetFormula("pow(X/300, -2.31-0.26*log10(X/300))"); 128 opt.SetWeights(&weight); 91 129 92 130 -------------------- Other cuts ---------------------- 93 131 opt.AddPreCut("MHillasSrc.fDist*MGeomCam.fConvMm2Deg<1.0"); 94 132 opt.AddPreCut("MHillas.fSize>200"); 133 134 ------------------ Zd distribution ------------------- 135 TFile file("ganymed00001111.root"); 136 137 MStatusArray arr; 138 if (arr.Read()<=0) 139 return; 140 TH1D *vstime = (TH1D*)arr.FindObjectInCanvas("Theta", "TH1D", "OnTime"); 141 if (!vstime) 142 return -1; 143 144 MMcSpectrumWeight weight; 145 weight.SetWeightsZd(vstime); 146 opt.AddPreTask(&weight); 147 148 ---------------------- Histogram -------------------- 149 MHn hist("MyHist", "Energy Residual (lg E_{est} - lg E_{mc})"); 150 151 hist.AddHist("MNewImagePar.fConcCOG", "log10(MEnergyEst.fVal)-log10(MMcEvt.fEnergy)"); 152 hist.InitName("ResConc;Conc;EnergyResidual"); 153 hist.InitTitle(";C;\\Delta lg E;"); 154 hist.SetDrawOption("colz profx"); 155 156 MBinning bins(50, 0, 1); 157 hist.SetBinnings(&bins); 158 159 MFillH fill(&hist, "", "FillMyHist"); 160 //fill.SetWeight(); // Enable weights to be used to fill this histogram 161 opt.AddTestTask(&fill); 162 163 ------------------------------------------------------ 95 164 */ 96 97 // Things which could be implemented in a future version98 // PreCut in Energy oder Size?99 // PreCut in Max Dist100 // PreCut in Theta^2 (0.25 oder 0.3)101 // New spectral slope102 // Zenith angle distribution in OnTime103 165 104 166 opt.Train("rf-energy.root", set, 30000); 105 167 } 106 /*107 // SequencesOn: Monte Carlo Sequences used for training108 // SequencesOff: Monte Carlo Sequences used for testing109 110 // Use:111 // opt.AddPreCut to use cut for test and training112 // opt.AddTestCut to use cut for test only113 // opt.AddTrainCut to use cut for train only114 */ -
trunk/MagicSoft/Mars/mfbase/MFDataPhrase.cc
r8310 r8706 107 107 // the class description above. 108 108 // 109 MFDataPhrase::MFDataPhrase(const char *text, const char *name, const char *title) : f AllowEmpty(kFALSE)109 MFDataPhrase::MFDataPhrase(const char *text, const char *name, const char *title) : fData(NULL), fAllowEmpty(kFALSE) 110 110 { 111 111 fName = name ? name : gsDefName.Data(); 112 112 fTitle = title ? title : gsDefTitle.Data(); 113 114 if (!text) 115 return; 113 116 114 117 *fLog << inf << "Parsing filter rule... " << flush; … … 162 165 Int_t MFDataPhrase::Process() 163 166 { 164 if (fData) 165 fResult = fData->GetValue()>0.5; 167 fResult = fData ? fData->GetValue()>0.5 : fDefault; 166 168 167 169 return kTRUE; -
trunk/MagicSoft/Mars/mfbase/MFDataPhrase.h
r8091 r8706 18 18 MData *fData; 19 19 Bool_t fAllowEmpty; // Not a Bit to be stored 20 Bool_t fDefault; // Default for empty case 20 21 21 22 Bool_t fResult; //! … … 38 39 void SetAllowEmpty(Bool_t b=kTRUE) { fAllowEmpty = b; } 39 40 Bool_t IsAllowEmpty() const { return fAllowEmpty; } 41 42 void SetDefault(Bool_t b) { fDefault = b; } 43 Bool_t GetDefault() const { return fDefault; } 40 44 41 45 // MFilter -
trunk/MagicSoft/Mars/mjobs/MJCut.cc
r8695 r8706 666 666 667 667 // Filter for VsSize 668 MFDataPhrase ftheta("", "CutT"); 669 ftheta.SetAllowEmpty(); 668 MFDataPhrase ftheta(0, "CutT"); 670 669 671 670 // ------------- Loop Off Data -------------------- -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.h
r8701 r8706 53 53 void PrintSetup(const MAlphaFitter &fit) const; 54 54 Bool_t DisplayResult(const TH2D &mh1) const; 55 Bool_t IntermediateLoop(MParList &plist, MH3 &h1, TH1D &temp1, const MDataSet &set, MMcSpectrumWeight &w) const;55 //Bool_t IntermediateLoop(MParList &plist, MH3 &h1, TH1D &temp1, const MDataSet &set, MMcSpectrumWeight &w) const; 56 56 TArrayD FitSpectrum(TH1D &spectrum) const; 57 57 TArrayD DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const; -
trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
r8704 r8706 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1. 29 2007-08-24 08:33:48tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MRanForestCalc.cc,v 1.30 2007-08-24 12:58:49 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 167 167 // In the case weights should be used initialize the 168 168 // corresponding array 169 Double_t sum = 0; 170 169 171 TArrayF weights(nrows); 170 172 if (fLastDataColumnHasWeights) 173 { 171 174 for (Int_t j=0; j<nrows; j++) 172 175 { 173 176 weights[j] = matrixtrain.GetM()(j, ncols-nobs); 174 if (j%250==0) 175 cout << weights[j] << " "; 177 sum += weights[j]; 176 178 } 179 } 180 181 *fLog << inf << "MRanForestCalc::Train: Sum of weights " << sum << endl; 177 182 178 183 // Setup the matrix such that the last comlumn contains
Note:
See TracChangeset
for help on using the changeset viewer.