Changeset 7121 for trunk/MagicSoft/Mars
- Timestamp:
- 06/01/05 17:14:46 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7120 r7121 21 21 22 22 -*-*- END OF LINE -*-*- 23 2005/06/01 Thomas Bretz 24 25 * mjobs/MJOptimize.[h,cc]: 26 - moved code for cut optimization to MJOptimizeCuts 27 - moved code for energy optimization to MJOptimizeEnergy 28 29 * mjobs/MJOptimizeCuts.[h,cc], mjobs/MJOptimizeEnergy.[h,cc]: 30 - added 31 32 * mjobs/Makefile, mjobs/JobsLinkDef.h: 33 - added MJOptimizeCuts 34 - added MJOptimizeEnergy 35 36 37 23 38 2005/06/01 Daniela Dorner 24 39 -
trunk/MagicSoft/Mars/NEWS
r7116 r7121 47 47 For details about the requirements of these plots look 48 48 at the corresponding classes 49 50 - MJOptimize: For On/Off and Wobble optimization MJOptimize 51 has been replaced by MJOptimizeCuts. To use MHThetaSq instead 52 of MHAlpha call MJOptimizeCuts("MHThetaSq"). Make sure in this 53 case MAlphaFitter is setup correctly. For On-Only optimization 54 MJOptimize has been Replaced by MJOptimizeCuts, too. Call 55 RunOn() instead of Run(). For energy estimation MJOptimize 56 has been replaced by MJOptimizeEnergy 49 57 50 58 - sponde: The input MC spectrum can now be weighted to fake a -
trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h
r6958 r7121 17 17 #pragma link C++ class MJStar+; 18 18 #pragma link C++ class MJCut+; 19 #pragma link C++ class MJOptimize+;20 19 #pragma link C++ class MJSpectrum+; 21 20 21 #pragma link C++ class MJOptimize+; 22 #pragma link C++ class MJOptimizeCuts+; 23 #pragma link C++ class MJOptimizeEnergy+; 24 22 25 #endif -
trunk/MagicSoft/Mars/mjobs/MJOptimize.cc
r7071 r7121 90 90 #include <TMultiGraph.h> 91 91 92 #include "MHMatrix.h" 93 94 // environment 95 #include "MLog.h" 96 #include "MLogManip.h" 97 98 #include "MDirIter.h" 99 #include "MStatusDisplay.h" 100 101 // eventloop 92 102 #include "MParList.h" 93 103 #include "MTaskList.h" 94 #include "MGeomCamCT1.h" 95 #include "MFEventSelector.h" 96 #include "MFDataMember.h" 104 #include "MEvtLoop.h" 105 106 // parameters 107 #include "MParameters.h" 108 109 // tasks 97 110 #include "MReadTree.h" 98 #include "MHMatrix.h"99 #include "MEnergyEstimate.h"100 111 #include "MMatrixLoop.h" 101 #include "MChisqEval.h"102 #include "MEvtLoop.h"103 #include "MDataElement.h"104 #include "MDataMember.h"105 #include "MLog.h"106 #include "MLogManip.h"107 #include "MParameters.h"108 112 #include "MFillH.h" 113 114 // filters 109 115 #include "MF.h" 110 116 #include "MFilterList.h" 111 #include "../mfilter/MFMagicCuts.h"112 #include "MContinue.h"113 #include "MGeomCamMagic.h"114 #include "MHillasSrcCalc.h"115 #include "MHMatrix.h"116 #include "MMatrixLoop.h"117 #include "../mhflux/MHAlpha.h"118 #include "MStatusDisplay.h"119 #include "../mhflux/MHEnergyEst.h"120 #include "MDirIter.h"121 #include "MSequence.h"122 117 123 118 using namespace std; … … 507 502 Bool_t MJOptimize::Optimize(MEvtLoop &evtloop) 508 503 { 504 if (fParameters.GetSize()==0) 505 { 506 *fLog << err << GetDescriptor() << "::Optimize: ERROR - Sorry, no parameters defined." << endl; 507 return kFALSE; 508 } 509 509 510 if (fType==kNone) 510 511 return kTRUE; … … 806 807 *fLog << endl; 807 808 } 808 809 //------------------------------------------------------------------------810 //811 Bool_t MJOptimize::Run(const char *fname, MFilter *filter, MAlphaFitter *fit)812 {813 if (fParameters.GetSize()==0)814 {815 *fLog << err << "Sorry, no parameters defined." << endl;816 return kFALSE;817 }818 819 fLog->Separator("Preparing On-only-optimization");820 821 MParList parlist;822 823 MGeomCamMagic geom; // For GetConvMm2Deg824 parlist.AddToList(&geom);825 826 MHMatrix m("M");827 AddRulesToMatrix(m);828 parlist.AddToList(&m);829 830 MHAlpha hist;831 hist.SkipHistTime();832 hist.SkipHistTheta();833 hist.SkipHistEnergy();834 hist.InitMapping(&m);835 836 if (filter && filter->InheritsFrom(MFMagicCuts::Class()))837 ((MFMagicCuts*)filter)->InitMapping(&m);838 839 MReadTree read("Events");840 read.DisableAutoScheme(); // AutoScheme doesn't seem to be faster!841 if (fname)842 read.AddFile(fname);843 else844 AddSequences(read, fNamesOn);845 if (!FillMatrix(read, parlist))846 return kFALSE;847 848 MTaskList tasklist;849 parlist.Replace(&tasklist);850 if (fit)851 parlist.AddToList(fit);852 853 MFilterList list;854 SetupFilters(list, filter);855 856 MContinue contin(&list);857 parlist.AddToList(&list);858 859 MFillH fill(&hist);860 861 MMatrixLoop loop(&m);862 863 tasklist.AddToList(&loop);864 tasklist.AddToList(&list);865 tasklist.AddToList(&contin);866 tasklist.AddToList(&fill);867 868 // Optimize with the tasklist in this parameterlist869 if (!Optimize(parlist))870 return kFALSE;871 872 // Copy the result back to be accessible by the user873 if (fit)874 hist.GetAlphaFitter().Copy(*fit);875 // Print the result876 hist.GetAlphaFitter().Print("result");877 878 // Store result if requested879 TObjArray cont;880 cont.Add(&contin);881 return WriteContainer(cont, fNameOut);882 }883 884 //------------------------------------------------------------------------885 //886 // Make sure, that filter->GetDataMember is correctly implemented!!!!887 //888 Bool_t MJOptimize::RunOnOff(const char *fname, MFilter *filter, MAlphaFitter *fit, const char *tree)889 {890 if (fParameters.GetSize()==0)891 {892 *fLog << err << "Sorry, no parameters defined." << endl;893 return kFALSE;894 }895 896 fLog->Separator("Preparing On/Off-optimization");897 898 MParList parlist;899 900 MGeomCamMagic geom; // For GetConvMm2Deg901 parlist.AddToList(&geom);902 903 MHMatrix m("M");904 AddRulesToMatrix(m);905 parlist.AddToList(&m);906 907 const Int_t idxdatatype = m.AddColumn("DataType.fVal");908 909 MHAlpha histon, histof("MHAlphaOff");910 histon.SkipHistTime();911 histon.SkipHistTheta();912 //histon.SkipHistEnergy();913 histof.SkipHistTime();914 histof.SkipHistTheta();915 //histof.SkipHistEnergy();916 histon.ForceUsingSize();917 histof.ForceUsingSize();918 histon.InitMapping(&m, 1);919 histof.InitMapping(&m, 1);920 921 if (filter && filter->InheritsFrom(MFMagicCuts::Class()))922 ((MFMagicCuts*)filter)->InitMapping(&m);923 924 parlist.AddToList(&histon);925 parlist.AddToList(&histof);926 927 if (fname)928 {929 MReadTree read(tree);930 read.DisableAutoScheme(); // AutoScheme doesn't seem to be faster!931 read.AddFile(fname);932 if (!FillMatrix(read, parlist))933 return kFALSE;934 }935 else936 {937 MParameterI par("DataType");938 parlist.AddToList(&par);939 940 gLog.Separator("Reading On-Data");941 par.SetVal(1);942 MReadTree readon(tree);943 readon.DisableAutoScheme(); // AutoScheme doesn't seem to be faster!944 AddSequences(readon, fNamesOn);945 if (!FillMatrix(readon, parlist))946 return kFALSE;947 948 gLog.Separator("Reading Off-Data");949 par.SetVal(0);950 MReadTree readoff(tree);951 readoff.DisableAutoScheme(); // AutoScheme doesn't seem to be faster!952 AddSequences(readoff, fNamesOff);953 if (!FillMatrix(readoff, parlist))954 return kFALSE;955 }956 957 MTaskList tasklist;958 parlist.Replace(&tasklist);959 if (fit)960 parlist.AddToList(fit);961 962 MFilterList list;963 SetupFilters(list, filter);964 965 MContinue contin(&list);966 parlist.AddToList(&list);967 968 MFillH fillof(&histof, "", "FillHistOff");969 MFillH fillon(&histon, "", "FillHistOn");970 971 MF f0(Form("M[%d]<0.5", idxdatatype), "FilterOffData");972 MF f1(Form("M[%d]>0.5", idxdatatype), "FilterOnData");973 974 fillof.SetFilter(&f0);975 fillon.SetFilter(&f1);976 977 MMatrixLoop loop(&m);978 979 tasklist.AddToList(&loop);980 tasklist.AddToList(&list);981 tasklist.AddToList(&contin);982 tasklist.AddToList(&f0);983 tasklist.AddToList(&f1);984 tasklist.AddToList(&fillof);985 tasklist.AddToList(&fillon);986 987 // Optimize with the tasklist in this parameterlist988 if (!Optimize(parlist))989 return kFALSE;990 991 // Copy the result back to be accessible by the user992 if (fit)993 histon.GetAlphaFitter().Copy(*fit);994 // Print the result995 histon.GetAlphaFitter().Print("result");996 997 // Store result if requested998 TObjArray cont;999 cont.Add(&contin);1000 return WriteContainer(cont, fNameOut);1001 }1002 1003 //------------------------------------------------------------------------1004 //1005 // Read all events from file which do match rules and optimize1006 // energy estimator.1007 //1008 Bool_t MJOptimize::RunEnergy(const char *fname, const char *rule)1009 {1010 if (fParameters.GetSize()==0)1011 {1012 *fLog << err << "Sorry, no parameters defined." << endl;1013 return kFALSE;1014 }1015 1016 fLog->Separator("Preparing Energy optimization");1017 1018 MParList parlist;1019 1020 MParameterI par("DataType");1021 par.SetVal(1);1022 parlist.AddToList(&par);1023 1024 MFDataMember filter("DataType.fVal", '>', 0.5);1025 fPreCuts.Add(&filter);1026 1027 MGeomCamMagic geom; // For GetConvMm2Deg1028 parlist.AddToList(&geom);1029 1030 MHMatrix m("M");1031 AddRulesToMatrix(m);1032 parlist.AddToList(&m);1033 1034 MHEnergyEst hist;1035 hist.InitMapping(&m);1036 1037 MEnergyEstimate est("MParameters");1038 est.SetRule(rule);1039 parlist.AddToList(&est);1040 1041 MReadTree read("Events");1042 // NECESSARY BECAUSE OF MDataFormula GetRules missing1043 read.DisableAutoScheme();1044 if (fname)1045 read.AddFile(fname);1046 else1047 AddSequences(read, fNamesOn);1048 if (!FillMatrix(read, parlist, kTRUE))1049 return kFALSE;1050 1051 fPreCuts.Remove(&filter);1052 1053 MTaskList tasklist;1054 parlist.Replace(&tasklist);1055 1056 MFillH fill(&hist);1057 1058 MMatrixLoop loop(&m);1059 1060 tasklist.AddToList(&loop);1061 tasklist.AddToList(&est);1062 tasklist.AddToList(&fill);1063 1064 // Optimize with the tasklist in this parameterlist1065 if (!Optimize(parlist))1066 return kFALSE;1067 1068 // Print the result1069 hist.Print();1070 1071 // Store result if requested1072 TObjArray cont;1073 cont.Add(&est);1074 return WriteContainer(cont, fNameOut);1075 } -
trunk/MagicSoft/Mars/mjobs/MJOptimize.h
r6948 r7121 46 46 TList fRules; 47 47 TList fFilter; 48 TList fPreCuts;49 50 TList fNamesOn;51 TList fNamesOff;52 53 TString fNameOut;54 48 55 49 void AddPoint(TList *l, Int_t idx, Float_t val) const; 56 50 TList *GetPlots() const; 57 51 58 void AddRulesToMatrix(MHMatrix &m) const;59 void SetupFilters(MFilterList &list, MFilter *filter=0) const;60 Bool_t FillMatrix(MReadTree &read, MParList &l, Bool_t userules=kFALSE);61 62 52 MEvtLoop *fEvtLoop; //! 63 64 Bool_t AddSequences(MRead &read, TList &list) const;65 53 66 54 // Minuit Interface … … 87 75 88 76 Bool_t Optimize(MEvtLoop &evtloop); 77 78 protected: 79 TList fPreCuts; 80 81 TList fNamesOn; 82 TList fNamesOff; 83 84 TString fNameOut; 85 86 void AddRulesToMatrix(MHMatrix &m) const; 87 void SetupFilters(MFilterList &list, MFilter *filter=0) const; 88 Bool_t AddSequences(MRead &read, TList &list) const; 89 Bool_t FillMatrix(MReadTree &read, MParList &l, Bool_t userules=kFALSE); 89 90 90 91 public: … … 153 154 Bool_t Optimize(MParList &list); 154 155 155 // Special optimizing routines156 Bool_t Run(const char *fname, MFilter *filter, MAlphaFitter *fit=0);157 Bool_t Run(const char *fname, MAlphaFitter *fit=0)158 {159 return Run(fname, 0, fit);160 }161 162 Bool_t Run(MFilter *filter, MAlphaFitter *fit=0)163 {164 return Run(0, filter, fit);165 }166 Bool_t Run(MAlphaFitter *fit=0)167 {168 return Run(0, 0, fit);169 }170 171 Bool_t RunOnOff(const char *fname, MFilter *filter, MAlphaFitter *fit=0, const char *tree="Events");172 Bool_t RunOnOff(const char *fname, MAlphaFitter *fit=0, const char *tree="Events")173 {174 return RunOnOff(fname, 0, fit, tree);175 }176 Bool_t RunEnergy(const char *fname, const char *rule);177 178 Bool_t RunOnOff(MFilter *filter, MAlphaFitter *fit=0, const char *tree="Events")179 {180 return RunOnOff(0, filter, fit, tree);181 }182 Bool_t RunOnOff(MAlphaFitter *fit=0, const char *tree="Events")183 {184 return RunOnOff(fit, tree);185 }186 Bool_t RunEnergy(const char *rule)187 {188 return RunEnergy(0, rule);189 }190 191 156 ClassDef(MJOptimize, 0) // Class for optimization of the Supercuts 192 157 }; -
trunk/MagicSoft/Mars/mjobs/Makefile
r7099 r7121 36 36 MJCut.cc \ 37 37 MJOptimize.cc \ 38 MJOptimizeCuts.cc \ 39 MJOptimizeEnergy.cc \ 38 40 MJSpectrum.cc 39 41
Note:
See TracChangeset
for help on using the changeset viewer.