Changeset 2357 for trunk/MagicSoft/Mars
- Timestamp:
- 09/24/03 13:29:00 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2350 r2357 1 1 -*-*- END OF LINE -*-*- 2 3 4 2003/09/24: Wolfgang Wittek 5 6 * mfilter/MFEventSelector2.[h,cc] 7 - execution statistics added 8 9 * mhist/MHFindSignificance.cc 10 - add fHist->UseCurrentStyle() 11 to get the y-axis + labels drawn 12 13 * mhist/MHMatrix.h 14 - replace Int_t fNumRow //! 15 by Int_t fNumRow // 16 because otherwise fNumRow is not defined when MHMatrix object is read in 17 after it had been written out 18 19 * mhist/MHCT1Supercuts.cc 20 - change title of object 21 22 * manalysis/MMinuitInterface.cc 23 - add arguments maxcalls and tolerance to SIMPLEX call 24 25 * manalysis/MCT1SupercutsCalc.[h,cc] 26 - add variables asymmetry, conc, leakage 27 28 * manalysis/MCT1Supercuts.[h,cc] 29 - add variables asymmetry, conc, leakage 30 - add TArrayD fStepsizes (initial step sizes for the parameters) 31 32 * manalysis/MCT1FindSupercuts.cc 33 - replace MGeomCamCT1Daniel by MGeomCamCT1 34 - arguments 'parSCinit', 'params' and 'steps' added in FindParams() ; 35 parSCinit is the name of the file containing the initial 36 values of the parameters 37 'params' and 'steps' are the initial values in case parSCinit == "" 38 - add member functions GetMatrixTrain() and GetMatrixTest() 39 - remove member function WriteMatrix() 40 because it didn't work; now the matrices are written out in 41 DefineTrainMatrix(), DefineTestMatri() and DefineTrainTestMatrix() 42 43 * macros/CT1EgyEst.C 44 - don't use Daniel's energy estimator 45 46 * mmontecarlo/MMcEnergyEst.cc 47 - extend printout of comments 48 49 2 50 3 51 2003/09/17: Abelardo Moralejo … … 51 99 - added 'Time Spectra of Cosmics' button 52 100 - added size argument to instatiation of MHFadcCam 53 54 101 55 102 -
trunk/MagicSoft/Mars/macros/CT1Analysis.C
r2317 r2357 22 22 #include "MWriteRootFile.h" 23 23 24 //#include "TH3D.h" 24 25 25 26 … … 77 78 78 79 MBinning *binth = new MBinning("BinningTheta"); 79 //Double_t yedge[9] =80 // {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50., 60., 70.};81 80 // this is Daniel's binning in theta 82 Double_t yedge[8] = 83 {9.41, 16.22, 22.68, 28.64, 34.03, 38.84, 43.08, 44.99}; 84 //TArrayD yed(9,yedge); 81 //Double_t yedge[8] = 82 // {9.41, 16.22, 22.68, 28.64, 34.03, 38.84, 43.08, 44.99}; 83 // this is our binning 84 Double_t yedge[9] = 85 {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50., 60., 70.}; 85 86 TArrayD yed; 86 yed.Set( 8,yedge);87 yed.Set(9,yedge); 87 88 binth->SetEdges(yed); 88 89 plist->AddToList(binth); … … 94 95 zedge[8-i] = cos(yedge[i]/kRad2Deg); 95 96 } 96 TArrayD zed(9,zedge); 97 TArrayD zed; 98 zed.Set(9,zedge); 97 99 bincosth->SetEdges(zed); 98 100 plist->AddToList(bincosth); … … 116 118 } 117 119 120 118 121 void DeleteBinnings(MParList *plist) 119 122 { … … 122 125 TObject *bin; 123 126 127 //-------------------------------------------- 128 bin = plist->FindObject("BinningE"); 129 if (bin) delete bin; 130 131 //-------------------------------------------- 132 124 133 bin = plist->FindObject("BinningSize"); 125 134 if (bin) delete bin; … … 159 168 if (bin) delete bin; 160 169 161 //robert 170 171 // robert ---------------------------------------------- 162 172 bin = plist->FindObject("BinningAlphaFlux"); 163 173 if (bin) delete bin; … … 170 180 } 171 181 182 172 183 //************************************************************************ 173 184 void CT1Analysis() 174 185 { 186 187 gLog << "Entry CT1Analysis()" << endl; 188 175 189 gLog.SetNoColors(); 176 190 … … 189 203 190 204 // path for input for Mars 191 TString inPath = "~magican/ct1test/wittek/marsoutput/option B/";205 TString inPath = "~magican/ct1test/wittek/marsoutput/optionC/"; 192 206 193 207 // path for output from Mars 194 TString outPath = "~magican/ct1test/wittek/marsoutput/option B/";208 TString outPath = "~magican/ct1test/wittek/marsoutput/optionC/"; 195 209 196 210 //----------------------------------------------- … … 217 231 Bool_t JobA_MC = kFALSE; 218 232 Bool_t WMC1 = kFALSE; // write out root file MC1.root ? 219 220 221 // Job B_NN_UP : read ON1.root (or MC1.root) file222 // - depending on RlookNN : create (or read in) hadron and gamma matrix223 // - calculate hadroness for method of NEAREST NEIGHBORS224 // and for the SUPERCUTS225 // - update the input files with the hadronesses (ON1.root or MC1.root)226 227 Bool_t JobB_NN_UP = kFALSE;228 Bool_t RLookNN = kFALSE; // read in look-alike events229 Bool_t WNN = kFALSE; // update input root file ?230 231 232 // Job B_SC_UP : read ON1.root (or MC1.root) file233 // - depending on WParSC : create (or read in) supercuts parameter values234 // - calculate hadroness for the SUPERCUTS235 // - update the input files with the hadroness (ON1.root or MC1.root)236 237 Bool_t JobB_SC_UP = kTRUE;238 Bool_t RMatrix = kFALSE; // read matrices from file239 Bool_t WParSC = kTRUE; // do optimization and write supercuts240 // parameter values onto a file241 Bool_t WSC = kFALSE; // update input root file ?242 233 243 234 … … 252 243 Bool_t RTree = kFALSE; // read in trees 253 244 Bool_t WRF = kFALSE; // update input root file ? 245 246 247 248 249 // Job B_SC_UP : read ON1.root (or MC1.root) file 250 // - depending on WParSC : create (or read in) supercuts parameter values 251 // - calculate hadroness for the SUPERCUTS 252 // - update the input files with the hadroness (ON1.root or MC1.root) 253 254 Bool_t JobB_SC_UP = kFALSE; 255 Bool_t RMatrix = kFALSE; // read training and test matrices from file 256 Bool_t WParSC = kFALSE; // do optimization and write supercuts 257 // parameter values onto a file 258 Bool_t WSC = kFALSE; // update input root file ? 254 259 255 260 … … 299 304 // - write root file for ON data after final cuts 300 305 301 Bool_t JobF_XX = kFALSE; 302 Bool_t WFX = kFALSE; // write out root file ? 306 gLog << "before setting switches for JobF_XX" << endl; 307 308 Bool_t JobF_XX = kTRUE; 309 Bool_t WFX = kTRUE; // write out root file ? 310 Bool_t WRobert = kTRUE; // write out Robert's file ? 303 311 304 312 … … 327 335 gLog << "" << endl; 328 336 gLog << "Macro CT1Analysis : JobA_ON, WHistON, WON1 = " 329 << JobA_ON << ", " << WHistON << ", " << WON1 << endl; 337 << (JobA_ON ? "kTRUE" : "kFALSE") << ", " 338 << (WHistON ? "kTRUE" : "kFALSE") << ", " 339 << (WON1 ? "kTRUE" : "kFALSE") << endl; 330 340 331 341 … … 424 434 contstandard.SetName("SelStandard"); 425 435 426 if (WON1) 427 { 428 MWriteRootFile &write = *(new MWriteRootFile(outNameImage)); 436 //MWriteRootFile &write = *(new MWriteRootFile(outNameImage)); 437 MWriteRootFile write(outNameImage, "RECREATE"); 429 438 430 439 write.AddContainer("MRawRunHeader", "RunHeaders"); … … 438 447 write.AddContainer("MHillasSrc", "Events"); 439 448 write.AddContainer("MNewImagePar", "Events"); 440 } 449 441 450 442 451 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$ … … 500 509 501 510 Int_t maxevents = -1; 502 //Int_t maxevents = 1000;503 511 if ( !evtloop.Eventloop(maxevents) ) 504 512 return; … … 587 595 gLog << "" << endl; 588 596 gLog << "Macro CT1Analysis : JobA_MC, WMC1 = " 589 << JobA_MC << ", " << WMC1 << endl; 597 << (JobA_MC ? "kTRUE" : "kFALSE") << ", " 598 << (WMC1 ? "kTRUE" : "kFALSE") << endl; 590 599 591 600 … … 688 697 MCT1ReadPreProc read(filenamein); 689 698 699 MBlindPixelCalc blindbeforepad; 700 blindbeforepad.SetUseBlindPixels(); 701 blindbeforepad.SetName("BlindBeforePadding"); 702 690 703 MBlindPixelCalc blind; 691 704 blind.SetUseBlindPixels(); 705 blind.SetName("BlindAfterPadding"); 692 706 693 707 MFCT1SelBasic selbasic; … … 758 772 759 773 760 if (WMC1) 761 { 762 MWriteRootFile &write = *(new MWriteRootFile(outNameImage)); 774 //MWriteRootFile &write = *(new MWriteRootFile(outNameImage)); 775 MWriteRootFile write(outNameImage, "RECREATE"); 763 776 764 777 write.AddContainer("MRawRunHeader", "RunHeaders"); … … 772 785 write.AddContainer("MHillasSrc", "Events"); 773 786 write.AddContainer("MNewImagePar", "Events"); 774 } 787 775 788 776 789 … … 788 801 789 802 tlist.AddToList(&read); 803 tlist.AddToList(&blindbeforepad); 790 804 tlist.AddToList(&padthomas); 791 805 tlist.AddToList(&blind); … … 855 869 } 856 870 857 858 859 871 //--------------------------------------------------------------------- 860 // Job B_ NN_UP872 // Job B_RF_UP 861 873 //============ 862 874 863 // - read in the matrices of look-alike events for gammas and hadrons 864 865 // then read ON1.root (or MC1.root) file866 // 867 // - calculate the hadroness for the method of nearest neighbors868 // 869 // - update input root file , includingthe hadroness870 871 872 if (JobB_ NN_UP)875 876 // - create (or read in) the matrices of look-alike events for gammas 877 // and hadrons 878 // - create (or read in) the trees 879 // - then read ON1.root (or MC1.root) file 880 // - calculate the hadroness for the method of RANDOM FOREST 881 // - update input root file with the hadroness 882 883 884 if (JobB_RF_UP) 873 885 { 874 886 gLog << "=====================================================" << endl; 875 gLog << "Macro CT1Analysis : Start of Job B_ NN_UP" << endl;887 gLog << "Macro CT1Analysis : Start of Job B_RF_UP" << endl; 876 888 877 889 gLog << "" << endl; 878 gLog << "Macro CT1Analysis : JobB_NN_UP, RLookNN, WNN = " 879 << JobB_NN_UP << ", " << RLookNN << ", " << WNN << endl; 880 890 gLog << "Macro CT1Analysis : JobB_RF_UP, RLookRF, RTree, WRF = " 891 << (JobB_RF_UP ? "kTRUE" : "kFALSE") << ", " 892 << (RLookRF ? "kTRUE" : "kFALSE") << ", " 893 << (RTree ? "kTRUE" : "kFALSE") << ", " 894 << (WRF ? "kTRUE" : "kFALSE") << endl; 895 896 897 //-------------------------------------------- 898 // parameters for the random forest 899 Int_t NumTrees = 100; 900 Int_t NumTry = 3; 901 Int_t NdSize = 1; 881 902 882 903 … … 898 919 outNameImage += typeInput; 899 920 outNameImage += "2.root"; 900 901 921 //TString outNameImage = filenameData; 902 922 … … 909 929 filenameON += "ON"; 910 930 filenameON += "1.root"; 911 Int_t howManyHadrons = 500000;931 Int_t howManyHadrons = 35000; 912 932 gLog << "filenameON = " << filenameON << ", howManyHadrons = " 913 933 << howManyHadrons << endl; … … 918 938 filenameMC += "MC"; 919 939 filenameMC += "1.root"; 920 Int_t howManyGammas = 50000;940 Int_t howManyGammas = 35000; 921 941 gLog << "filenameMC = " << filenameMC << ", howManyGammas = " 922 942 << howManyGammas << endl; … … 926 946 927 947 TString outNameGammas = outPath; 928 outNameGammas += " matrix_gammas_";948 outNameGammas += "RFmatrix_gammas_"; 929 949 outNameGammas += "MC"; 930 950 outNameGammas += ".root"; … … 934 954 935 955 TString outNameHadrons = outPath; 936 outNameHadrons += " matrix_hadrons_";956 outNameHadrons += "RFmatrix_hadrons_"; 937 957 outNameHadrons += typeMatrixHadrons; 938 958 outNameHadrons += ".root"; … … 940 960 941 961 MHMatrix matrixg("MatrixGammas"); 962 matrixg.EnableGraphicalOutput(); 963 942 964 MHMatrix matrixh("MatrixHadrons"); 965 matrixh.EnableGraphicalOutput(); 966 967 //-------------------------------------------- 968 // file of trees of the random forest 969 970 TString outRF = outPath; 971 outRF += "RF.root"; 972 943 973 944 974 //************************************************************************* 945 975 // read in matrices of look-alike events 946 if (RLook NN)976 if (RLookRF) 947 977 { 948 978 const char* mtxName = "MatrixGammas"; … … 961 991 962 992 matrixg.Read(mtxName); 963 matrixg.Print(" cols");993 matrixg.Print("SizeCols"); 964 994 965 995 … … 981 1011 982 1012 matrixh.Read(mtxName); 983 matrixh.Print(" cols");1013 matrixh.Print("SizeCols"); 984 1014 } 985 1015 … … 987 1017 //************************************************************************* 988 1018 // create matrices of look-alike events 989 if (!RLook NN)1019 if (!RLookRF) 990 1020 { 991 1021 gLog << "" << endl; … … 1011 1041 MFParticleId fgamma("MMcEvt", '=', kGAMMA); 1012 1042 fgamma.SetName("gammaID"); 1043 1013 1044 MFParticleId fhadrons("MMcEvt", '!', kGAMMA); 1014 1045 fhadrons.SetName("hadronID)"); 1015 1046 1016 MFEventSelector selectorg; 1017 selectorg.SetNumSelectEvts(howManyGammas); 1047 TString mgname("costhg"); 1048 MBinning bing("Binning"+mgname); 1049 bing.SetEdges(10, 0., 1.0); 1050 1051 MH3 gref("cos(MMcEvt.fTelescopeTheta)"); 1052 gref.SetName(mgname); 1053 MH::SetBinning(&gref.GetHist(), &bing); 1054 for (Int_t i=1; i<=gref.GetNbins(); i++) 1055 gref.GetHist().SetBinContent(i, 1.0); 1056 1057 1058 MFEventSelector2 selectorg(gref); 1059 selectorg.SetNumMax(howManyGammas); 1018 1060 selectorg.SetName("selectGammas"); 1019 MFEventSelector selectorh; 1020 selectorh.SetNumSelectEvts(howManyHadrons); 1021 selectorh.SetName("selectHadrons"); 1061 1022 1062 1023 1063 MFillH fillmatg("MatrixGammas"); … … 1029 1069 fillmath.SetName("fillHadrons"); 1030 1070 1031 1071 1032 1072 //***************************** fill gammas *** 1033 1073 // entries in MFilterList … … 1065 1105 tlistg.PrintStatistics(0, kTRUE); 1066 1106 1067 1107 1068 1108 //***************************** fill hadrons *** 1069 1109 1070 1110 gLog << " Hadrons :" << endl; 1111 1112 TString mhname("costhh"); 1113 MBinning binh("Binning"+mhname); 1114 binh.SetEdges(10, 0., 1.0); 1115 1116 MH3 href("cos(MMcEvt.fTelescopeTheta)"); 1117 href.SetName(mhname); 1118 MH::SetBinning(&href.GetHist(), &binh); 1119 for (Int_t i=1; i<=href.GetNbins(); i++) 1120 href.GetHist().SetBinContent(i, 1.0); 1121 1122 MFEventSelector2 selectorh(href); 1123 //selectorh.SetNumMax(howManyHadrons); 1124 // select as many hadrons as gammas 1125 selectorh.SetNumMax(matrixg.GetM().GetNrows()); 1126 selectorh.SetName("selectHadrons"); 1127 1128 1071 1129 // entries in MFilterList 1072 1130 … … 1102 1160 1103 1161 tlisth.PrintStatistics(0, kTRUE); 1162 1163 1164 1104 1165 //***************************************************** 1105 1166 1106 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^1107 //1108 // ----------------------------------------------------------1109 // Definition of the reference sample of look-alike events1110 // (this is a subsample of the original sample)1111 // ----------------------------------------------------------1112 //1113 gLog << "" << endl;1114 gLog << "========================================================" << endl;1115 // Select a maximum of nmaxevts events from the sample of look-alike1116 // events. They will form the reference sample.1117 Int_t nmaxevts = 2000;1118 1119 // target distribution for the variable in column refcolumn (start at 0);1120 //Int_t refcolumn = 0;1121 //Int_t nbins = 5;1122 //Float_t frombin = 0.5;1123 //Float_t tobin = 1.0;1124 //TH1F *thsh = new TH1F("thsh","target distribution",1125 // nbins, frombin, tobin);1126 //thsh->SetDirectory(NULL);1127 //thsh->SetXTitle("cos( \\Theta)");1128 //thsh->SetYTitle("Counts");1129 //Float_t dbin = (tobin-frombin)/nbins;1130 //Float_t lbin = frombin +dbin*0.5;1131 //for (Int_t j=1; j<=nbins; j++)1132 //{1133 // thsh->Fill(lbin,1.0);1134 // lbin += dbin;1135 //}1136 1137 Int_t refcolumn = 0;1138 MBinning *binscostheta = (MBinning*)plistg->FindObject("BinningCosTheta", "MBinning");1139 TH1F *thsh = new TH1F();1140 thsh->SetNameTitle("thsh","target distribution");1141 MH::SetBinning(thsh, binscostheta);1142 Int_t nbins = thsh->GetNbinsX();1143 Double_t cont[8] = {1500, 1500, 1500, 3250, 3250, 3900, 3900, 3900};1144 for (Int_t j=1; j<=nbins; j++)1145 {1146 thsh->Fill(thsh->GetBinCenter(j), cont[j-1]);1147 }1148 1149 gLog << "" << endl;1150 gLog << "========================================================" << endl;1151 gLog << "Macro CT1Analysis : define reference sample for gammas" << endl;1152 gLog << "Macro CT1Analysis : Parameters for reference sample : refcolumn, nmaxevts = "1153 << refcolumn << ", " << nmaxevts << endl;1154 1155 matrixg.EnableGraphicalOutput();1156 Bool_t matrixok = matrixg.DefRefMatrix(refcolumn, *thsh, nmaxevts);1157 1158 if ( !matrixok )1159 {1160 gLog << "Macro CT1Analysis : Reference matrix for gammas cannot be defined" << endl;1161 return;1162 }1163 1164 gLog << "" << endl;1165 gLog << "========================================================" << endl;1166 gLog << "Macro CT1Analysis : define reference sample for hadrons" << endl;1167 gLog << "Macro CT1Analysis : Parameters for reference sample : refcolumn, nmaxevts = "1168 << refcolumn << ", " << nmaxevts << endl;1169 1170 matrixh.EnableGraphicalOutput();1171 matrixok = matrixh.DefRefMatrix(refcolumn, *thsh, nmaxevts);1172 delete thsh;1173 1174 if ( !matrixok )1175 {1176 gLog << "Macro CT1Analysis : Reference matrix for hadrons cannot be defined" << endl;1177 return;1178 }1179 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^1180 1167 1181 1168 // write out look-alike events … … 1189 1176 // "gammas" 1190 1177 gLog << "Gammas :" << endl; 1191 matrixg.Print(" cols");1178 matrixg.Print("SizeCols"); 1192 1179 1193 1180 TFile writeg(outNameGammas, "RECREATE", ""); … … 1201 1188 // "hadrons" 1202 1189 gLog << "Hadrons :" << endl; 1203 matrixh.Print(" cols");1190 matrixh.Print("SizeCols"); 1204 1191 1205 1192 TFile writeh(outNameHadrons, "RECREATE", ""); … … 1214 1201 1215 1202 1203 MRanForest *fRanForest; 1204 MRanTree *fRanTree; 1216 1205 //----------------------------------------------------------------- 1217 // Update the input files with the NN and SC hadronness 1218 // 1219 1220 if (WNN) 1206 // read in the trees of the random forest 1207 if (RTree) 1208 { 1209 MParList plisttr; 1210 MTaskList tlisttr; 1211 plisttr.AddToList(&tlisttr); 1212 1213 MReadTree readtr("TREE", outRF); 1214 readtr.DisableAutoScheme(); 1215 1216 MRanForestFill rffill; 1217 rffill.SetNumTrees(NumTrees); 1218 1219 // list of tasks for the loop over the trees 1220 1221 tlisttr.AddToList(&readtr); 1222 tlisttr.AddToList(&rffill); 1223 1224 //------------------- 1225 // Execute tree loop 1226 // 1227 MEvtLoop evtlooptr; 1228 evtlooptr.SetParList(&plisttr); 1229 if (!evtlooptr.Eventloop()) 1230 return; 1231 1232 tlisttr.PrintStatistics(0, kTRUE); 1233 1234 1235 // get adresses of objects which are used in the next eventloop 1236 fRanForest = (MRanForest*)plisttr->FindObject("MRanForest"); 1237 if (!fRanForest) 1238 { 1239 *fLog << err << dbginf << "MRanForest not found... aborting." << endl; 1240 return kFALSE; 1241 } 1242 1243 fRanTree = (MRanTree*)plisttr->FindObject("MRanTree"); 1244 if (!fRanTree) 1245 { 1246 *fLog << err << dbginf << "MRanTree not found... aborting." << endl; 1247 return kFALSE; 1248 } 1249 1250 } 1251 1252 //----------------------------------------------------------------- 1253 // grow the trees of the random forest (event loop = tree loop) 1254 1255 if (!RTree) 1256 { 1257 1258 gLog << "" << endl; 1259 gLog << "========================================================" << endl; 1260 gLog << "Macro CT1Analysis : start growing trees" << endl; 1261 1262 MTaskList tlist2; 1263 MParList plist2; 1264 plist2.AddToList(&tlist2); 1265 1266 plist2.AddToList(&matrixg); 1267 plist2.AddToList(&matrixh); 1268 1269 MRanForestGrow rfgrow2; 1270 rfgrow2.SetNumTrees(NumTrees); 1271 rfgrow2.SetNumTry(NumTry); 1272 rfgrow2.SetNdSize(NdSize); 1273 1274 MWriteRootFile rfwrite2(outRF); 1275 rfwrite2.AddContainer("MRanTree", "TREE"); 1276 1277 // list of tasks for the loop over the trees 1278 1279 tlist2.AddToList(&rfgrow2); 1280 tlist2.AddToList(&rfwrite2); 1281 1282 //------------------- 1283 // Execute tree loop 1284 // 1285 MEvtLoop treeloop; 1286 treeloop.SetParList(&plist2); 1287 1288 if ( !treeloop.Eventloop() ) 1289 return; 1290 1291 tlist2.PrintStatistics(0, kTRUE); 1292 1293 // get adresses of objects which are used in the next eventloop 1294 fRanForest = (MRanForest*)plist2->FindObject("MRanForest"); 1295 if (!fRanForest) 1296 { 1297 *fLog << err << dbginf << "MRanForest not found... aborting." << endl; 1298 return kFALSE; 1299 } 1300 1301 fRanTree = (MRanTree*)plist2->FindObject("MRanTree"); 1302 if (!fRanTree) 1303 { 1304 *fLog << err << dbginf << "MRanTree not found... aborting." << endl; 1305 return kFALSE; 1306 } 1307 1308 } 1309 // end of growing the trees of the random forest 1310 //----------------------------------------------------------------- 1311 1312 1313 1314 1315 //----------------------------------------------------------------- 1316 // Update the input files with the RF hadronness 1317 // 1318 1319 if (WRF) 1221 1320 { 1222 1321 gLog << "" << endl; 1223 1322 gLog << "========================================================" << endl; 1224 1323 gLog << "Update input file '" << filenameData 1225 << "' with the NN and SChadronness" << endl;1324 << "' with the RF hadronness" << endl; 1226 1325 1227 1326 MTaskList tliston; … … 1246 1345 1247 1346 //....................................................................... 1248 // calculation of hadroness for method of Nearest Neighbors 1249 1250 TString hadNNName = "HadNN"; 1251 MMultiDimDistCalc nncalc; 1252 nncalc.SetUseNumRows(25); 1253 nncalc.SetUseKernelMethod(kFALSE); 1254 nncalc.SetHadronnessName(hadNNName); 1255 1256 //....................................................................... 1257 // calculation of hadroness for the supercuts 1258 // (=0.25 if fullfilled, =0.75 otherwise) 1259 1260 TString hadSCName = "HadSC"; 1261 MCT1SupercutsCalc sccalc(fHilName, fHilNameSrc); 1262 sccalc.SetHadronnessName(hadSCName); 1347 // calculate hadronnes for method of RANDOM FOREST 1348 1349 TString hadRFName = "HadRF"; 1350 MRanForestCalc rfcalc; 1351 rfcalc.SetHadronnessName(hadRFName); 1263 1352 1264 1353 //....................................................................... … … 1278 1367 write.AddContainer("MNewImagePar", "Events"); 1279 1368 1280 write.AddContainer("HadNN", "Events"); 1281 write.AddContainer("HadSC", "Events"); 1369 write.AddContainer(hadRFName, "Events"); 1282 1370 1283 1371 … … 1287 1375 (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam"); 1288 1376 1377 1289 1378 Float_t maxhadronness = 0.40; 1290 1379 Float_t maxalpha = 20.0; … … 1293 1382 MFCT1SelFinal selfinalgh(fHilNameSrc); 1294 1383 selfinalgh.SetCuts(maxhadronness, 100.0, maxdist); 1295 selfinalgh.SetHadronnessName(had NNName);1384 selfinalgh.SetHadronnessName(hadRFName); 1296 1385 selfinalgh.SetName("SelFinalgh"); 1297 1386 MContinue contfinalgh(&selfinalgh); 1298 1387 contfinalgh.SetName("ContSelFinalgh"); 1299 1388 1300 MFillH fillhadnn("hadNN[MHHadronness]", hadNNName); 1301 fillhadnn.SetName("HhadNN"); 1302 MFillH fillhadsc("hadSC[MHHadronness]", hadSCName); 1303 fillhadsc.SetName("HhadSC"); 1389 MFillH fillranfor("MHRanForest"); 1390 fillranfor.SetName("HRanForest"); 1391 1392 MFillH fillhadrf("hadRF[MHHadronness]", hadRFName); 1393 fillhadrf.SetName("HhadRF"); 1304 1394 1305 1395 MFCT1SelFinal selfinal(fHilNameSrc); 1306 1396 selfinal.SetCuts(maxhadronness, maxalpha, maxdist); 1307 selfinal.SetHadronnessName(had NNName);1397 selfinal.SetHadronnessName(hadRFName); 1308 1398 selfinal.SetName("SelFinal"); 1309 1399 MContinue contfinal(&selfinal); 1310 1400 contfinal.SetName("ContSelFinal"); 1311 1401 1402 TString mh3name = "abs(Alpha)"; 1403 MBinning binsalphaabs("Binning"+mh3name); 1404 binsalphaabs.SetEdges(50, -2.0, 98.0); 1405 1406 MH3 alphaabs("abs(MHillasSrc.fAlpha)"); 1407 alphaabs.SetName(mh3name); 1408 MFillH alpha(&alphaabs); 1409 alpha.SetName("FillAlphaAbs"); 1312 1410 1313 1411 MFillH hfill1("MHHillas", fHilName); … … 1332 1430 InitBinnings(&pliston); 1333 1431 1334 pliston.AddToList(&matrixg); 1335 pliston.AddToList(&matrixh); 1336 1432 pliston.AddToList(fRanForest); 1433 pliston.AddToList(fRanTree); 1434 1435 pliston.AddToList(&binsalphaabs); 1436 pliston.AddToList(&alphaabs); 1337 1437 1338 1438 //***************************** … … 1341 1441 tliston.AddToList(&read); 1342 1442 1343 tliston.AddToList(&nncalc); 1344 tliston.AddToList(&sccalc); 1345 tliston.AddToList(&fillhadnn); 1346 tliston.AddToList(&fillhadsc); 1347 1443 tliston.AddToList(&rfcalc); 1444 tliston.AddToList(&fillranfor); 1445 tliston.AddToList(&fillhadrf); 1446 1447 tliston.AddToList(&write); 1448 tliston.AddToList(&contfinalgh); 1449 1450 tliston.AddToList(&alpha); 1348 1451 tliston.AddToList(&hfill1); 1349 1452 tliston.AddToList(&hfill2); … … 1352 1455 tliston.AddToList(&hfill5); 1353 1456 1354 tliston.AddToList(&write);1355 1356 tliston.AddToList(&contfinalgh);1357 1457 tliston.AddToList(&contfinal); 1358 1458 … … 1373 1473 tliston.PrintStatistics(0, kTRUE); 1374 1474 1475 1375 1476 //------------------------------------------- 1376 1477 // Display the histograms 1377 1478 // 1378 pliston.FindObject(" hadNN", "MHHadronness")->DrawClone();1379 pliston.FindObject("had SC", "MHHadronness")->DrawClone();1479 pliston.FindObject("MHRanForest")->DrawClone(); 1480 pliston.FindObject("hadRF", "MHHadronness")->DrawClone(); 1380 1481 1381 1482 pliston.FindObject("MHHillas")->DrawClone(); … … 1385 1486 pliston.FindObject("MHStarMap")->DrawClone(); 1386 1487 1488 //------------------------------------------- 1489 // fit alpha distribution to get the number of excess events and 1490 // calculate significance of gamma signal in the alpha plot 1491 1492 MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3")); 1493 TH1 &alphaHist = absalpha->GetHist(); 1494 alphaHist.SetXTitle("|alpha| [\\circ]"); 1495 1496 Double_t alphasig = 13.1; 1497 Double_t alphamin = 30.0; 1498 Double_t alphamax = 90.0; 1499 Int_t degree = 4; 1500 Double_t significance = -99.0; 1501 Bool_t drawpoly = kTRUE; 1502 Bool_t fitgauss = kTRUE; 1503 Bool_t print = kTRUE; 1504 1505 MHFindSignificance findsig; 1506 findsig.SetRebin(kTRUE); 1507 findsig.SetReduceDegree(kFALSE); 1508 1509 findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 1510 alphasig, drawpoly, fitgauss, print); 1511 significance = findsig.GetSignificance(); 1512 Float_t alphasi = findsig.GetAlphasi(); 1513 1514 gLog << "For file '" << filenameData << "' : " << endl; 1515 gLog << "Significance of gamma signal after supercuts : " 1516 << significance << " (for |alpha| < " << alphasi << " degrees)" 1517 << endl; 1518 1519 findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print); 1520 1521 //------------------------------------------- 1522 1523 1387 1524 DeleteBinnings(&pliston); 1388 1525 } 1389 1526 1390 1391 1392 gLog << "Macro CT1Analysis : End of Job B_NN_UP" << endl; 1527 gLog << "Macro CT1Analysis : End of Job B_RF_UP" << endl; 1393 1528 gLog << "=======================================================" << endl; 1394 1529 } 1395 1530 //--------------------------------------------------------------------- 1531 1532 1396 1533 1397 1534 … … 1413 1550 1414 1551 gLog << "" << endl; 1415 //gLog << "Macro CT1Analysis : JobB_SC_UP, WParSC, WSC = " 1416 // << JobB_SC_UP << ", " << WParSC << ", " << WSC << endl; 1417 1552 gLog << "Macro CT1Analysis : JobB_SC_UP, WParSC, WSC = " 1553 << (JobB_SC_UP ? "kTRUE" : "kFALSE") << ", " 1554 << (WParSC ? "kTRUE" : "kFALSE") << ", " 1555 << (WSC ? "kTRUE" : "kFALSE") << endl; 1556 1557 1558 1559 //-------------------------------------------- 1560 // file which contains the initial parameter values for the supercuts 1561 // if parSCinit ="" the initial values are taken from the constructor of 1562 // MCT1Supercuts 1563 1564 TString parSCinit = outPath; 1565 //parSCinit += "parSC_1709d"; 1566 parSCinit = ""; 1567 1568 gLog << "parSCinit = " << parSCinit << endl; 1569 1570 //--------------- 1571 // file onto which the optimal parameter values for the supercuts 1572 // are written 1573 1574 TString parSCfile = outPath; 1575 parSCfile += "parSC_2209a"; 1576 1577 gLog << "parSCfile = " << parSCfile << endl; 1418 1578 1419 1579 //-------------------------------------------- 1420 1580 // file to be updated (either ON or MC) 1421 1581 1422 TString typeInput = "ON";1423 //TString typeInput = "MC";1582 //TString typeInput = "ON"; 1583 TString typeInput = "MC"; 1424 1584 gLog << "typeInput = " << typeInput << endl; 1425 1585 … … 1434 1594 outNameImage += typeInput; 1435 1595 outNameImage += "3.root"; 1436 outNameImage += "xxxxx";1437 1596 1438 1597 … … 1447 1606 TString filenameTrain = outPath; 1448 1607 filenameTrain += "ON"; 1449 filenameTrain += " 2.root";1608 filenameTrain += "1.root"; 1450 1609 Int_t howManyTrain = 800000; 1451 1610 gLog << "filenameTrain = " << filenameTrain << ", howManyTrain = " … … 1455 1614 TString filenameTest = outPath; 1456 1615 filenameTest += "ON"; 1457 filenameTest += " 2.root";1458 Int_t howManyTest = 100000;1616 filenameTest += "1.root"; 1617 Int_t howManyTest = 800000; 1459 1618 1460 1619 gLog << "filenameTest = " << filenameTest << ", howManyTest = " … … 1479 1638 1480 1639 1481 //--------------------------------------------1482 // file which contains the optimum parameter values for the supercuts1483 1484 TString parSCfile = outPath;1485 parSCfile += "parSC";1486 1487 gLog << "parSCfile = " << parSCfile << endl;1488 1489 1640 1490 1641 //--------------------------------------------------------------------- 1491 // optimize supercuts using the training sample1492 // and test them using the test sample1493 1494 if (WParSC) 1495 { 1642 // Training and test matrices : 1643 // - either create them and write them onto a file 1644 // - or read them from a file 1645 1646 1496 1647 MCT1FindSupercuts findsuper; 1497 1648 findsuper.SetFilenameParam(parSCfile); … … 1500 1651 1501 1652 //-------------------------- 1502 // create matrices 1653 // create matrices and write them onto files 1503 1654 if (!RMatrix) 1504 1655 { … … 1509 1660 { 1510 1661 if ( !findsuper.DefineTrainTestMatrix(filenameTrain, 1511 howManyTrain,mh3,1512 howManyTest, mh3))1662 howManyTrain, mh3, howManyTest, mh3, 1663 fileMatrixTrain, fileMatrixTest) ) 1513 1664 { 1514 1665 *fLog << "CT1Analysis.C : DefineTrainTestMatrix failed" << endl; … … 1519 1670 else 1520 1671 { 1521 if ( !findsuper.DefineTrainMatrix(filenameTrain, howManyTrain, mh3) ) 1672 if ( !findsuper.DefineTrainMatrix(filenameTrain, 1673 howManyTrain, mh3, fileMatrixTrain) ) 1522 1674 { 1523 1675 *fLog << "CT1Analysis.C : DefineTrainMatrix failed" << endl; … … 1525 1677 } 1526 1678 1527 if ( !findsuper.DefineTestMatrix( filenameTest, howManyTest, mh3) ) 1679 if ( !findsuper.DefineTestMatrix( filenameTest, 1680 howManyTest, mh3, fileMatrixTest) ) 1528 1681 { 1529 1682 *fLog << "CT1Analysis.C : DefineTestMatrix failed" << endl; … … 1531 1684 } 1532 1685 } 1533 1534 // writing doesn't work ??? 1535 //findsuper.WriteMatrix(fileMatrixTrain, fileMatrixTest); 1536 } 1686 } 1537 1687 1538 1688 //-------------------------- 1539 1689 // read matrices from files 1540 // NOT YET TESTED 1541 //if (RMatrix) 1542 // findsuper.ReadMatrix(fileMatrixTrain, fileMatrixTest); 1690 // 1691 1692 if (RMatrix) 1693 findsuper.ReadMatrix(fileMatrixTrain, fileMatrixTest); 1543 1694 //-------------------------- 1544 1695 1545 1696 1546 //-------------------------- 1547 // optimize the supercuts 1548 Bool_t rf = findsuper.FindParams(); 1697 1698 //--------------------------------------------------------------------- 1699 // optimize supercuts using the training sample 1700 // 1701 // the initial values are taken 1702 // - from the file parSCinit (if != "") 1703 // - or from the arrays params and steps (if their sizes are != 0) 1704 // - or from the MCT1Supercuts constructor 1705 1706 1707 if (WParSC) 1708 { 1709 TArrayD params(0); 1710 TArrayD steps(0); 1711 1712 if (parSCinit == "") 1713 { 1714 Double_t vparams[104] = { 1715 // LengthUp 1716 0.315585, 0.001455, 0.203198, 0.005532, -0.001670, -0.020362, 1717 0.007388, -0.013463, 1718 // LengthLo 1719 0.151530, 0.028323, 0.510707, 0.053089, 0.013708, 2.357993, 1720 0.000080, -0.007157, 1721 // WidthUp 1722 0.145412, -0.001771, 0.054462, 0.022280, -0.009893, 0.056353, 1723 0.020711, -0.016703, 1724 // WidthLo 1725 0.089187, -0.006430, 0.074442, 0.003738, -0.004256, -0.014101, 1726 0.006126, -0.002849, 1727 // DistUp 1728 1.787943, 0.0, 2.942310, 0.199815, 0.0, 0.249909, 1729 0.189697, 0.0, 1730 // DistLo 1731 0.589406, 0.0, -0.083964,-0.007975, 0.0, 0.045374, 1732 -0.001750, 0.0, 1733 // AsymUp 1734 1.e10, 0.0, 0.0, 0.0, 0.0, 0.0, 1735 0.0, 0.0, 1736 // AsymLo 1737 -1.e10, 0.0, 0.0, 0.0, 0.0, 0.0, 1738 0.0, 0.0, 1739 // ConcUp 1740 1.e10, 0.0, 0.0, 0.0, 0.0, 0.0, 1741 0.0, 0.0, 1742 // ConcLo 1743 -1.e10, 0.0, 0.0, 0.0, 0.0, 0.0, 1744 0.0, 0.0, 1745 // Leakage1Up 1746 1.e10, 0.0, 0.0, 0.0, 0.0, 0.0, 1747 0.0, 0.0, 1748 // Leakage1Lo 1749 -1.e10, 0.0, 0.0, 0.0, 0.0, 0.0, 1750 0.0, 0.0, 1751 // AlphaUp 1752 13.12344, 0.0, 0.0, 0.0, 0.0, 0.0, 1753 0.0, 0.0 }; 1754 1755 Double_t vsteps[104] = { 1756 // LengthUp 1757 0.03, 0.0002, 0.02, 0.0006, 0.0002, 0.002, 1758 0.0008, 0.002, 1759 // LengthLo 1760 0.02, 0.003, 0.05, 0.006, 0.002, 0.3, 1761 0.0001, 0.0008, 1762 // WidthUp 1763 0.02, 0.0002, 0.006, 0.003, 0.002, 0.006, 1764 0.002, 0.002, 1765 // WidthLo 1766 0.009, 0.0007, 0.008, 0.0004, 0.0005, 0.002, 1767 0.0007, 0.003, 1768 // DistUp 1769 0.2, 0.0, 0.3, 0.02, 0.0, 0.03, 1770 0.02, 0.0 1771 // DistLo 1772 0.06, 0.0, 0.009, 0.0008, 0.0, 0.005, 1773 0.0002, 0.0 1774 // AsymUp 1775 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1776 0.0, 0.0, 1777 // AsymLo 1778 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1779 0.0, 0.0, 1780 // ConcUp 1781 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1782 0.0, 0.0, 1783 // ConcLo 1784 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1785 0.0, 0.0, 1786 // Leakage1Up 1787 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1788 0.0, 0.0, 1789 // Leakage1Lo 1790 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1791 0.0, 0.0, 1792 // AlphaUp 1793 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1794 0.0, 0.0 }; 1795 1796 params.Set(104, vparams); 1797 steps.Set (104, vsteps ); 1798 } 1799 1800 Bool_t rf; 1801 rf = findsuper.FindParams(parSCinit, params, steps); 1549 1802 1550 1803 if (!rf) 1551 1804 { 1552 *fLog << "CT1Analysis.C : optimization of supercuts failed" << endl;1805 gLog << "CT1Analysis.C : optimization of supercuts failed" << endl; 1553 1806 return; 1554 1807 } … … 1565 1818 // 1566 1819 1567 1820 if (WSC) 1821 { 1568 1822 gLog << "" << endl; 1569 1823 gLog << "========================================================" << endl; … … 1580 1834 inparam.Close(); 1581 1835 1582 gLog << " Optimum parameter values for supercuts were read in from file '"1836 gLog << "Parameter values for supercuts were read in from file '" 1583 1837 << parSCfile << "'" << endl; 1584 1838 … … 1586 1840 supercutsPar = scin.GetParameters(); 1587 1841 1588 gLog << "Optimum parameter values for supercuts : " << endl; 1589 for (Int_t i=0; i<72; i++) 1842 TArrayD supercutsStep; 1843 supercutsStep = scin.GetStepsizes(); 1844 1845 gLog << "Parameter values for supercuts : " << endl; 1846 for (Int_t i=0; i<supercutsPar.GetSize(); i++) 1590 1847 { 1591 1848 gLog << supercutsPar[i] << ", "; 1849 } 1850 gLog << endl; 1851 1852 gLog << "Step values for supercuts : " << endl; 1853 for (Int_t i=0; i<supercutsStep.GetSize(); i++) 1854 { 1855 gLog << supercutsStep[i] << ", "; 1592 1856 } 1593 1857 gLog << endl; … … 1604 1868 << filenameData << "'" << endl; 1605 1869 supercutsPar = supercuts.GetParameters(); 1606 for (Int_t i=0; i< 72; i++)1870 for (Int_t i=0; i<supercutsPar.GetSize(); i++) 1607 1871 { 1608 1872 gLog << supercutsPar[i] << ", "; … … 1640 1904 1641 1905 1642 if (WSC)1643 {1644 1906 //MWriteRootFile write(outNameImage, "UPDATE"); 1645 MWriteRootFile write = new MWriteRootFile(outNameImage, "RECREATE"); 1907 //MWriteRootFile write = new MWriteRootFile(outNameImage, "RECREATE"); 1908 MWriteRootFile write(outNameImage, "RECREATE"); 1646 1909 1647 1910 write.AddContainer("MRawRunHeader", "RunHeaders"); … … 1656 1919 write.AddContainer("MNewImagePar", "Events"); 1657 1920 1658 write.AddContainer("HadNN", "Events"); 1659 write.AddContainer("HadSC", "Events"); 1660 } 1921 write.AddContainer("HadRF", "Events"); 1922 write.AddContainer(hadSCName, "Events"); 1661 1923 1662 1924 … … 1693 1955 MH3 alphaabs("abs(MHillasSrc.fAlpha)"); 1694 1956 alphaabs.SetName(mh3name); 1957 1958 TH1 &alphahist = alphaabs->GetHist(); 1959 1695 1960 MFillH alpha(&alphaabs); 1696 1961 alpha.SetName("FillAlphaAbs"); … … 1716 1981 pliston.AddToList(&tliston); 1717 1982 InitBinnings(&pliston); 1983 1984 pliston.AddToList(&supercuts); 1985 1718 1986 pliston.AddToList(&binsalphaabs); 1719 1987 pliston.AddToList(&alphaabs); 1720 pliston.AddToList(&supercuts);1721 1988 1722 1989 //***************************** … … 1727 1994 tliston.AddToList(&sccalc); 1728 1995 tliston.AddToList(&fillhadsc); 1996 1997 tliston.AddToList(&write); 1729 1998 tliston.AddToList(&contfinalgh); 1730 1999 … … 1735 2004 tliston.AddToList(&hfill4); 1736 2005 tliston.AddToList(&hfill5); 1737 1738 if (WSC)1739 tliston.AddToList(&write);1740 2006 1741 2007 tliston.AddToList(&contfinal); … … 1776 2042 TH1 &alphaHist = absalpha->GetHist(); 1777 2043 alphaHist.SetXTitle("|alpha| [\\circ]"); 2044 alphaHist.SetName("alpha-macro"); 1778 2045 1779 2046 Double_t alphasig = 13.1; 1780 2047 Double_t alphamin = 30.0; 1781 2048 Double_t alphamax = 90.0; 1782 Int_t degree = 4;2049 Int_t degree = 2; 1783 2050 Double_t significance = -99.0; 1784 2051 Bool_t drawpoly = kTRUE; … … 1788 2055 MHFindSignificance findsig; 1789 2056 findsig.SetRebin(kTRUE); 1790 findsig.SetReduceDegree(k TRUE);2057 findsig.SetReduceDegree(kFALSE); 1791 2058 1792 2059 findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, … … 1805 2072 1806 2073 DeleteBinnings(&pliston); 2074 } 2075 1807 2076 1808 2077 gLog << "Macro CT1Analysis : End of Job B_SC_UP" << endl; … … 1810 2079 } 1811 2080 //--------------------------------------------------------------------- 1812 1813 1814 //---------------------------------------------------------------------1815 // Job B_RF_UP1816 //============1817 1818 1819 // - create (or read in) the matrices of look-alike events for gammas1820 // and hadrons1821 // - create (or read in) the trees1822 // - then read ON1.root (or MC1.root) file1823 // - calculate the hadroness for the method of RANDOM FOREST1824 // - update input root file with the hadroness1825 1826 1827 if (JobB_RF_UP)1828 {1829 gLog << "=====================================================" << endl;1830 gLog << "Macro CT1Analysis : Start of Job B_RF_UP" << endl;1831 1832 gLog << "" << endl;1833 gLog << "Macro CT1Analysis : JobB_RF_UP, RLookRF, RTree, WRF = "1834 << JobB_RF_UP << ", " << RLookRF << ", " << RTree << ", "1835 << WRF << endl;1836 1837 1838 1839 //--------------------------------------------1840 // parameters for the random forest1841 Int_t NumTrees = 100;1842 Int_t NumTry = 3;1843 Int_t NdSize = 3;1844 1845 1846 //--------------------------------------------1847 // file to be updated (either ON or MC)1848 1849 TString typeInput = "ON";1850 //TString typeInput = "MC";1851 gLog << "typeInput = " << typeInput << endl;1852 1853 // name of input root file1854 TString filenameData = outPath;1855 filenameData += typeInput;1856 filenameData += "2.root";1857 gLog << "filenameData = " << filenameData << endl;1858 1859 // name of output root file1860 TString outNameImage = outPath;1861 outNameImage += typeInput;1862 outNameImage += "3.root";1863 //TString outNameImage = filenameData;1864 1865 gLog << "outNameImage = " << outNameImage << endl;1866 1867 //--------------------------------------------1868 // files to be read for generating the look-alike events1869 // "hadrons" :1870 TString filenameON = outPath;1871 filenameON += "ON";1872 filenameON += "1.root";1873 Int_t howManyHadrons = 1000000;1874 gLog << "filenameON = " << filenameON << ", howManyHadrons = "1875 << howManyHadrons << endl;1876 1877 1878 // "gammas" :1879 TString filenameMC = outPath;1880 filenameMC += "MC";1881 filenameMC += "1.root";1882 Int_t howManyGammas = 50000;1883 gLog << "filenameMC = " << filenameMC << ", howManyGammas = "1884 << howManyGammas << endl;1885 1886 //--------------------------------------------1887 // files of look-alike events1888 1889 TString outNameGammas = outPath;1890 outNameGammas += "RFmatrix_gammas_";1891 outNameGammas += "MC";1892 outNameGammas += ".root";1893 1894 TString typeMatrixHadrons = "ON";1895 gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl;1896 1897 TString outNameHadrons = outPath;1898 outNameHadrons += "RFmatrix_hadrons_";1899 outNameHadrons += typeMatrixHadrons;1900 outNameHadrons += ".root";1901 1902 1903 MHMatrix matrixg("MatrixGammas");1904 MHMatrix matrixh("MatrixHadrons");1905 1906 //--------------------------------------------1907 // file of trees of the random forest1908 1909 TString outRF = outPath;1910 outRF += "RF.root";1911 1912 1913 //*************************************************************************1914 // read in matrices of look-alike events1915 if (RLookRF)1916 {1917 const char* mtxName = "MatrixGammas";1918 1919 gLog << "" << endl;1920 gLog << "========================================================" << endl;1921 gLog << "Get matrix for (gammas)" << endl;1922 gLog << "matrix name = " << mtxName << endl;1923 gLog << "name of root file = " << outNameGammas << endl;1924 gLog << "" << endl;1925 1926 1927 // read in the object with the name 'mtxName' from file 'outNameGammas'1928 //1929 TFile fileg(outNameGammas);1930 1931 matrixg.Read(mtxName);1932 matrixg.Print("cols");1933 1934 1935 //*****************************************************************1936 1937 const char* mtxName = "MatrixHadrons";1938 1939 gLog << "" << endl;1940 gLog << "========================================================" << endl;1941 gLog << " Get matrix for (hadrons)" << endl;1942 gLog << "matrix name = " << mtxName << endl;1943 gLog << "name of root file = " << outNameHadrons << endl;1944 gLog << "" << endl;1945 1946 1947 // read in the object with the name 'mtxName' from file 'outNameHadrons'1948 //1949 TFile fileh(outNameHadrons);1950 1951 matrixh.Read(mtxName);1952 matrixh.Print("cols");1953 }1954 1955 1956 //*************************************************************************1957 // create matrices of look-alike events1958 if (!RLookRF)1959 {1960 gLog << "" << endl;1961 gLog << "========================================================" << endl;1962 gLog << " Create matrices of look-alike events" << endl;1963 gLog << " Gammas :" << endl;1964 1965 1966 MParList plistg;1967 MTaskList tlistg;1968 MFilterList flistg;1969 1970 MParList plisth;1971 MTaskList tlisth;1972 MFilterList flisth;1973 1974 MReadMarsFile readg("Events", filenameMC);1975 readg.DisableAutoScheme();1976 1977 MReadMarsFile readh("Events", filenameON);1978 readh.DisableAutoScheme();1979 1980 MFParticleId fgamma("MMcEvt", '=', kGAMMA);1981 fgamma.SetName("gammaID");1982 MFParticleId fhadrons("MMcEvt", '!', kGAMMA);1983 fhadrons.SetName("hadronID)");1984 1985 MFEventSelector selectorg;1986 selectorg.SetNumSelectEvts(howManyGammas);1987 selectorg.SetName("selectGammas");1988 MFEventSelector selectorh;1989 selectorh.SetNumSelectEvts(howManyHadrons);1990 selectorh.SetName("selectHadrons");1991 1992 MFillH fillmatg("MatrixGammas");1993 fillmatg.SetFilter(&flistg);1994 fillmatg.SetName("fillGammas");1995 1996 MFillH fillmath("MatrixHadrons");1997 fillmath.SetFilter(&flisth);1998 fillmath.SetName("fillHadrons");1999 2000 2001 //***************************** fill gammas ***2002 // entries in MFilterList2003 2004 flistg.AddToList(&fgamma);2005 flistg.AddToList(&selectorg);2006 2007 //*****************************2008 // entries in MParList2009 2010 plistg.AddToList(&tlistg);2011 InitBinnings(&plistg);2012 2013 plistg.AddToList(&matrixg);2014 2015 //*****************************2016 // entries in MTaskList2017 2018 tlistg.AddToList(&readg);2019 tlistg.AddToList(&flistg);2020 tlistg.AddToList(&fillmatg);2021 2022 //*****************************2023 2024 MProgressBar matrixbar;2025 MEvtLoop evtloopg;2026 evtloopg.SetParList(&plistg);2027 evtloopg.ReadEnv(env, "", printEnv);2028 evtloopg.SetProgressBar(&matrixbar);2029 2030 Int_t maxevents = -1;2031 if (!evtloopg.Eventloop(maxevents))2032 return;2033 2034 tlistg.PrintStatistics(0, kTRUE);2035 2036 2037 //***************************** fill hadrons ***2038 2039 gLog << " Hadrons :" << endl;2040 // entries in MFilterList2041 2042 flisth.AddToList(&fhadrons);2043 flisth.AddToList(&selectorh);2044 2045 //*****************************2046 // entries in MParList2047 2048 plisth.AddToList(&tlisth);2049 InitBinnings(&plisth);2050 2051 plisth.AddToList(&matrixh);2052 2053 //*****************************2054 // entries in MTaskList2055 2056 tlisth.AddToList(&readh);2057 tlisth.AddToList(&flisth);2058 tlisth.AddToList(&fillmath);2059 2060 //*****************************2061 2062 MProgressBar matrixbar;2063 MEvtLoop evtlooph;2064 evtlooph.SetParList(&plisth);2065 evtlooph.ReadEnv(env, "", printEnv);2066 evtlooph.SetProgressBar(&matrixbar);2067 2068 Int_t maxevents = -1;2069 if (!evtlooph.Eventloop(maxevents))2070 return;2071 2072 tlisth.PrintStatistics(0, kTRUE);2073 //*****************************************************2074 2075 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^2076 //2077 // ----------------------------------------------------------2078 // Definition of the reference sample of look-alike events2079 // (this is a subsample of the original sample)2080 // ----------------------------------------------------------2081 //2082 gLog << "" << endl;2083 gLog << "========================================================" << endl;2084 // Select a maximum of nmaxevts events from the sample of look-alike2085 // events. They will form the reference sample.2086 Int_t nmaxevts = 10000;2087 2088 // target distribution for the variable in column refcolumn (start at 0);2089 //Int_t refcolumn = 0;2090 //Int_t nbins = 5;2091 //Float_t frombin = 0.5;2092 //Float_t tobin = 1.0;2093 //TH1F *thsh = new TH1F("thsh","target distribution",2094 // nbins, frombin, tobin);2095 //thsh->SetDirectory(NULL);2096 //thsh->SetXTitle("cos( \\Theta)");2097 //thsh->SetYTitle("Counts");2098 //Float_t dbin = (tobin-frombin)/nbins;2099 //Float_t lbin = frombin +dbin*0.5;2100 //for (Int_t j=1; j<=nbins; j++)2101 //{2102 // thsh->Fill(lbin,1.0);2103 // lbin += dbin;2104 //}2105 2106 Int_t refcolumn = 0;2107 MBinning *binscostheta = (MBinning*)plistg->FindObject("BinningCosTheta", "MBinning");2108 TH1F *thsh = new TH1F();2109 thsh->SetNameTitle("thsh","target distribution");2110 MH::SetBinning(thsh, binscostheta);2111 Int_t nbins = thsh->GetNbinsX();2112 Double_t cont[8] = {1500, 1500, 1500, 3250, 3250, 3900, 3900, 3900};2113 for (Int_t j=1; j<=nbins; j++)2114 {2115 thsh->Fill(thsh->GetBinCenter(j), cont[j-1]);2116 }2117 2118 gLog << "" << endl;2119 gLog << "========================================================" << endl;2120 gLog << "Macro CT1Analysis : define reference sample for gammas" << endl;2121 gLog << "Macro CT1Analysis : Parameters for reference sample : refcolumn, nmaxevts = "2122 << refcolumn << ", " << nmaxevts << endl;2123 2124 matrixg.EnableGraphicalOutput();2125 Bool_t matrixok = matrixg.DefRefMatrix(refcolumn, *thsh, nmaxevts);2126 2127 if ( !matrixok )2128 {2129 gLog << "Macro CT1Analysis : Reference matrix for gammas cannot be defined" << endl;2130 return;2131 }2132 2133 gLog << "" << endl;2134 gLog << "========================================================" << endl;2135 gLog << "Macro CT1Analysis : define reference sample for hadrons" << endl;2136 gLog << "Macro CT1Analysis : Parameters for reference sample : refcolumn, nmaxevts = "2137 << refcolumn << ", " << nmaxevts << endl;2138 2139 matrixh.EnableGraphicalOutput();2140 matrixok = matrixh.DefRefMatrix(refcolumn, *thsh, nmaxevts);2141 delete thsh;2142 2143 if ( !matrixok )2144 {2145 gLog << "Macro CT1Analysis : Reference matrix for hadrons cannot be defined" << endl;2146 return;2147 }2148 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^2149 2150 // write out look-alike events2151 2152 gLog << "" << endl;2153 gLog << "========================================================" << endl;2154 gLog << "Write out look=alike events" << endl;2155 2156 2157 //-------------------------------------------2158 // "gammas"2159 gLog << "Gammas :" << endl;2160 matrixg.Print("cols");2161 2162 TFile writeg(outNameGammas, "RECREATE", "");2163 matrixg.Write();2164 2165 gLog << "" << endl;2166 gLog << "Macro CT1Analysis : matrix of look-alike events for gammas written onto file "2167 << outNameGammas << endl;2168 2169 //-------------------------------------------2170 // "hadrons"2171 gLog << "Hadrons :" << endl;2172 matrixh.Print("cols");2173 2174 TFile writeh(outNameHadrons, "RECREATE", "");2175 matrixh.Write();2176 2177 gLog << "" << endl;2178 gLog << "Macro CT1Analysis : matrix of look-alike events for hadrons written onto file "2179 << outNameHadrons << endl;2180 2181 }2182 //********** end of creating matrices of look-alike events ***********2183 2184 2185 MRanForest *fRanForest;2186 MRanTree *fRanTree;2187 //-----------------------------------------------------------------2188 // read in the trees of the random forest2189 if (RTree)2190 {2191 MParList plisttr;2192 MTaskList tlisttr;2193 plisttr.AddToList(&tlisttr);2194 2195 MReadTree readtr("TREE", outRF);2196 readtr.DisableAutoScheme();2197 2198 MRanForestFill rffill;2199 rffill.SetNumTrees(NumTrees);2200 2201 // list of tasks for the loop over the trees2202 2203 tlisttr.AddToList(&readtr);2204 tlisttr.AddToList(&rffill);2205 2206 //-------------------2207 // Execute tree loop2208 //2209 MEvtLoop evtlooptr;2210 evtlooptr.SetParList(&plisttr);2211 if (!evtlooptr.Eventloop())2212 return;2213 2214 tlisttr.PrintStatistics(0, kTRUE);2215 2216 2217 // get adresses of objects which are used in the next eventloop2218 fRanForest = (MRanForest*)plisttr->FindObject("MRanForest");2219 if (!fRanForest)2220 {2221 *fLog << err << dbginf << "MRanForest not found... aborting." << endl;2222 return kFALSE;2223 }2224 2225 fRanTree = (MRanTree*)plisttr->FindObject("MRanTree");2226 if (!fRanTree)2227 {2228 *fLog << err << dbginf << "MRanTree not found... aborting." << endl;2229 return kFALSE;2230 }2231 2232 }2233 2234 //-----------------------------------------------------------------2235 // grow the trees of the random forest (event loop = tree loop)2236 2237 if (!RTree)2238 {2239 2240 gLog << "" << endl;2241 gLog << "========================================================" << endl;2242 gLog << "Macro CT1Analysis : start growing trees" << endl;2243 2244 MTaskList tlist2;2245 MParList plist2;2246 plist2.AddToList(&tlist2);2247 2248 plist2.AddToList(&matrixg);2249 plist2.AddToList(&matrixh);2250 2251 MRanForestGrow rfgrow2;2252 rfgrow2.SetNumTrees(NumTrees);2253 rfgrow2.SetNumTry(NumTry);2254 rfgrow2.SetNdSize(NdSize);2255 2256 MWriteRootFile rfwrite2(outRF);2257 rfwrite2.AddContainer("MRanTree", "TREE");2258 2259 // list of tasks for the loop over the trees2260 2261 tlist2.AddToList(&rfgrow2);2262 tlist2.AddToList(&rfwrite2);2263 2264 //-------------------2265 // Execute tree loop2266 //2267 MEvtLoop treeloop;2268 treeloop.SetParList(&plist2);2269 2270 if ( !treeloop.Eventloop() )2271 return;2272 2273 tlist2.PrintStatistics(0, kTRUE);2274 2275 // get adresses of objects which are used in the next eventloop2276 fRanForest = (MRanForest*)plist2->FindObject("MRanForest");2277 if (!fRanForest)2278 {2279 *fLog << err << dbginf << "MRanForest not found... aborting." << endl;2280 return kFALSE;2281 }2282 2283 fRanTree = (MRanTree*)plist2->FindObject("MRanTree");2284 if (!fRanTree)2285 {2286 *fLog << err << dbginf << "MRanTree not found... aborting." << endl;2287 return kFALSE;2288 }2289 2290 }2291 // end of growing the trees of the random forest2292 //-----------------------------------------------------------------2293 2294 2295 2296 2297 //-----------------------------------------------------------------2298 // Update the input files with the RF hadronness2299 //2300 2301 if (WRF)2302 {2303 gLog << "" << endl;2304 gLog << "========================================================" << endl;2305 gLog << "Update input file '" << filenameData2306 << "' with the RF hadronness" << endl;2307 2308 MTaskList tliston;2309 MParList pliston;2310 2311 2312 // geometry is needed in MHHillas... classes2313 MGeomCam *fGeom =2314 (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");2315 2316 //-------------------------------------------2317 // create the tasks which should be executed2318 //2319 2320 MReadMarsFile read("Events", filenameData);2321 read.DisableAutoScheme();2322 2323 TString fHilName = "MHillas";2324 TString fHilNameExt = "MHillasExt";2325 TString fHilNameSrc = "MHillasSrc";2326 TString fImgParName = "MNewImagePar";2327 2328 //.......................................................................2329 // calculate hadronnes for method of RANDOM FOREST2330 2331 TString hadRFName = "HadRF";2332 MRanForestCalc rfcalc;2333 rfcalc.SetHadronnessName(hadRFName);2334 2335 //.......................................................................2336 2337 //MWriteRootFile write(outNameImage, "UPDATE");2338 MWriteRootFile write(outNameImage, "RECREATE");2339 2340 write.AddContainer("MRawRunHeader", "RunHeaders");2341 write.AddContainer("MTime", "Events");2342 write.AddContainer("MMcEvt", "Events");2343 write.AddContainer("ThetaOrig", "Events");2344 write.AddContainer("MSrcPosCam", "Events");2345 write.AddContainer("MSigmabar", "Events");2346 write.AddContainer("MHillas", "Events");2347 write.AddContainer("MHillasExt", "Events");2348 write.AddContainer("MHillasSrc", "Events");2349 write.AddContainer("MNewImagePar", "Events");2350 2351 write.AddContainer("HadNN", "Events");2352 write.AddContainer("HadSC", "Events");2353 2354 write.AddContainer(hadRFName, "Events");2355 2356 2357 //-----------------------------------------------------------------2358 // geometry is needed in MHHillas... classes2359 MGeomCam *fGeom =2360 (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");2361 2362 2363 Float_t maxhadronness = 0.40;2364 Float_t maxalpha = 20.0;2365 Float_t maxdist = 10.0;2366 2367 MFCT1SelFinal selfinalgh(fHilNameSrc);2368 selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);2369 selfinalgh.SetHadronnessName(hadRFName);2370 selfinalgh.SetName("SelFinalgh");2371 MContinue contfinalgh(&selfinalgh);2372 contfinalgh.SetName("ContSelFinalgh");2373 2374 MFillH fillranfor("MHRanForest");2375 fillranfor.SetName("HRanForest");2376 2377 MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);2378 fillhadrf.SetName("HhadRF");2379 2380 MFCT1SelFinal selfinal(fHilNameSrc);2381 selfinal.SetCuts(maxhadronness, maxalpha, maxdist);2382 selfinal.SetHadronnessName(hadRFName);2383 selfinal.SetName("SelFinal");2384 MContinue contfinal(&selfinal);2385 contfinal.SetName("ContSelFinal");2386 2387 2388 MFillH hfill1("MHHillas", fHilName);2389 hfill1.SetName("HHillas");2390 2391 MFillH hfill2("MHStarMap", fHilName);2392 hfill2.SetName("HStarMap");2393 2394 MFillH hfill3("MHHillasExt", fHilNameSrc);2395 hfill3.SetName("HHillasExt");2396 2397 MFillH hfill4("MHHillasSrc", fHilNameSrc);2398 hfill4.SetName("HHillasSrc");2399 2400 MFillH hfill5("MHNewImagePar", fImgParName);2401 hfill5.SetName("HNewImagePar");2402 2403 //*****************************2404 // entries in MParList2405 2406 pliston.AddToList(&tliston);2407 InitBinnings(&pliston);2408 2409 pliston.AddToList(fRanForest);2410 pliston.AddToList(fRanTree);2411 2412 //*****************************2413 // entries in MTaskList2414 2415 tliston.AddToList(&read);2416 2417 tliston.AddToList(&rfcalc);2418 tliston.AddToList(&fillranfor);2419 tliston.AddToList(&fillhadrf);2420 2421 tliston.AddToList(&hfill1);2422 tliston.AddToList(&hfill2);2423 tliston.AddToList(&hfill3);2424 tliston.AddToList(&hfill4);2425 tliston.AddToList(&hfill5);2426 2427 tliston.AddToList(&write);2428 2429 tliston.AddToList(&contfinalgh);2430 tliston.AddToList(&contfinal);2431 2432 //*****************************2433 2434 //-------------------------------------------2435 // Execute event loop2436 //2437 MProgressBar bar;2438 MEvtLoop evtloop;2439 evtloop.SetParList(&pliston);2440 evtloop.SetProgressBar(&bar);2441 2442 Int_t maxevents = -1;2443 if ( !evtloop.Eventloop(maxevents) )2444 return;2445 2446 tliston.PrintStatistics(0, kTRUE);2447 2448 2449 //-------------------------------------------2450 // Display the histograms2451 //2452 pliston.FindObject("MHRanForest")->DrawClone();2453 pliston.FindObject("hadRF", "MHHadronness")->DrawClone();2454 2455 pliston.FindObject("MHHillas")->DrawClone();2456 pliston.FindObject("MHHillasExt")->DrawClone();2457 pliston.FindObject("MHHillasSrc")->DrawClone();2458 pliston.FindObject("MHNewImagePar")->DrawClone();2459 pliston.FindObject("MHStarMap")->DrawClone();2460 2461 DeleteBinnings(&pliston);2462 }2463 2464 gLog << "Macro CT1Analysis : End of Job B_RF_UP" << endl;2465 gLog << "=======================================================" << endl;2466 }2467 //---------------------------------------------------------------------2468 2469 2081 2470 2082 … … 2484 2096 2485 2097 gLog << "" << endl; 2486 gLog << "Macro CT1Analysis : JobC = " << JobC << endl; 2098 gLog << "Macro CT1Analysis : JobC = " 2099 << (JobC ? "kTRUE" : "kFALSE") << endl; 2487 2100 2488 2101 … … 2522 2135 // names of hadronness containers 2523 2136 2524 TString hadNNName = "HadNN";2137 //TString hadNNName = "HadNN"; 2525 2138 TString hadSCName = "HadSC"; 2526 2139 TString hadRFName = "HadRF"; … … 2540 2153 MFCT1SelFinal selfinalgh(fHilNameSrc); 2541 2154 selfinalgh.SetCuts(maxhadronness, 100.0, maxdist); 2542 selfinalgh.SetHadronnessName(had NNName);2155 selfinalgh.SetHadronnessName(hadSCName); 2543 2156 selfinalgh.SetName("SelFinalgh"); 2544 2157 MContinue contfinalgh(&selfinalgh); 2545 2158 contfinalgh.SetName("ContSelFinalgh"); 2546 2159 2547 MFillH fillhadnn("hadNN[MHHadronness]", hadNNName);2548 fillhadnn.SetName("HhadNN");2160 //MFillH fillhadnn("hadNN[MHHadronness]", hadNNName); 2161 //fillhadnn.SetName("HhadNN"); 2549 2162 MFillH fillhadsc("hadSC[MHHadronness]", hadSCName); 2550 2163 fillhadsc.SetName("HhadSC"); … … 2554 2167 MFCT1SelFinal selfinal(fHilNameSrc); 2555 2168 selfinal.SetCuts(maxhadronness, maxalpha, maxdist); 2556 selfinal.SetHadronnessName(had NNName);2169 selfinal.SetHadronnessName(hadSCName); 2557 2170 selfinal.SetName("SelFinal"); 2558 2171 MContinue contfinal(&selfinal); … … 2588 2201 tliston.AddToList(&read); 2589 2202 2590 tliston.AddToList(&fillhadnn);2203 //tliston.AddToList(&fillhadnn); 2591 2204 tliston.AddToList(&fillhadsc); 2592 2205 tliston.AddToList(&fillhadrf); … … 2623 2236 // 2624 2237 2625 pliston.FindObject("hadNN", "MHHadronness")->DrawClone();2238 //pliston.FindObject("hadNN", "MHHadronness")->DrawClone(); 2626 2239 pliston.FindObject("hadSC", "MHHadronness")->DrawClone(); 2627 2240 pliston.FindObject("hadRF", "MHHadronness")->DrawClone(); … … 2657 2270 gLog << "" << endl; 2658 2271 gLog << "Macro CT1Analysis : JobD = " 2659 << JobD << endl; 2272 << (JobD ? "kTRUE" : "kFALSE") << endl; 2273 2660 2274 2661 2275 // type of data to be analysed … … 2868 2482 gLog << "" << endl; 2869 2483 gLog << "Macro CT1Analysis : JobE_XX, WXX = " 2870 << JobE_XX << ", " << WXX << endl; 2484 << (JobE_XX ? "kTRUE" : "kFALSE") << ", " 2485 << (WXX ? "kTRUE" : "kFALSE") << endl; 2486 2871 2487 2872 2488 // type of data to be analysed … … 3060 2676 gLog << "Macro CT1Analysis.C : returning from CT1EEst" << endl; 3061 2677 2678 2679 if (WXX) 2680 { 3062 2681 //----------------------------------------------------------- 3063 2682 // … … 3119 2738 //....................................................................... 3120 2739 3121 if (WXX) 3122 {3123 MWriteRootFile &write = *(new MWriteRootFile(filenameDataout));2740 2741 //MWriteRootFile &write = *(new MWriteRootFile(filenameDataout)); 2742 MWriteRootFile write(filenameDataout, "RECREATE"); 3124 2743 3125 2744 write.AddContainer("MRawRunHeader", "RunHeaders"); … … 3139 2758 3140 2759 write.AddContainer("MEnergyEst", "Events"); 3141 } 2760 3142 2761 3143 2762 //----------------------------------------------------------------- … … 3265 2884 3266 2885 DeleteBinnings(&pliston); 2886 2887 } 3267 2888 3268 2889 gLog << "Macro CT1Analysis : End of Job E_XX" << endl; … … 3292 2913 gLog << "" << endl; 3293 2914 gLog << "Macro CT1Analysis : JobF_XX, WFX = " 3294 << JobF_XX << ", " << WFX << endl; 2915 << (JobF_XX ? "kTRUE" : "kFALSE") << ", " 2916 << (WFX ? "kTRUE" : "kFALSE") << endl; 2917 3295 2918 3296 2919 // type of data to be analysed … … 3493 3116 gLog << "Macro CT1Analysis.C : returning from CT1EEst" << endl; 3494 3117 3118 3119 if (WFX) 3120 { 3495 3121 //----------------------------------------------------------- 3496 3122 // … … 3552 3178 //....................................................................... 3553 3179 3554 //if (WFX)3555 //{3556 3180 gLog << "CT1Analysis.C : write root file '" << filenameDataout 3557 3181 << "'" << endl; 3558 3182 3559 3183 //MWriteRootFile &write = *(new MWriteRootFile(filenameDataout)); 3184 /* 3560 3185 MWriteRootFile write(filenameDataout, "RECREATE"); 3561 3186 … … 3571 3196 write.AddContainer("MNewImagePar", "Events"); 3572 3197 3573 write.AddContainer("HadNN", "Events");3198 //write.AddContainer("HadNN", "Events"); 3574 3199 write.AddContainer("HadSC", "Events"); 3575 3200 write.AddContainer("HadRF", "Events"); 3576 3201 3577 3202 write.AddContainer("MEnergyEst", "Events"); 3578 //}3203 */ 3579 3204 3580 3205 //----------------------------------------------------------------- … … 3590 3215 contfinalgh.SetName("ContSelFinalgh"); 3591 3216 3592 MFillH fillhadnn("hadNN[MHHadronness]", "HadNN");3593 fillhadnn.SetName("HhadNN");3217 //MFillH fillhadnn("hadNN[MHHadronness]", "HadNN"); 3218 //fillhadnn.SetName("HhadNN"); 3594 3219 MFillH fillhadsc("hadSC[MHHadronness]", "HadSC"); 3595 3220 fillhadsc.SetName("HhadSC"); … … 3600 3225 // calculate estimated energy 3601 3226 3602 //MEnergyEstParam eeston(fHilName);3603 //eeston.Add(fHilNameSrc);3604 3605 //eeston.SetCoeffA(parA);3606 //eeston.SetCoeffB(parB);3227 MEnergyEstParam eeston(fHilName); 3228 eeston.Add(fHilNameSrc); 3229 3230 eeston.SetCoeffA(parA); 3231 eeston.SetCoeffB(parB); 3607 3232 3608 3233 //--------------------------- 3609 3234 // calculate estimated energy using Daniel's parameters 3610 3235 3611 MEnergyEstParamDanielMkn421 eeston(fHilName);3612 eeston.Add(fHilNameSrc);3236 //MEnergyEstParamDanielMkn421 eeston(fHilName); 3237 //eeston.Add(fHilNameSrc); 3613 3238 //eeston.SetCoeffA(parA); 3614 3239 //eeston.SetCoeffB(parB); … … 3684 3309 tliston.AddToList(&eeston); 3685 3310 3686 if (WFX) 3687 tliston.AddToList(&write); 3688 3689 tliston.AddToList(&fillhadnn); 3311 //tliston.AddToList(&write); 3312 3313 //tliston.AddToList(&fillhadnn); 3690 3314 tliston.AddToList(&fillhadsc); 3691 3315 tliston.AddToList(&fillhadrf); … … 3727 3351 // 3728 3352 3729 pliston.FindObject("hadNN", "MHHadronness")->DrawClone(); 3353 //pliston.FindObject("hadNN", "MHHadronness")->DrawClone(); 3354 3355 gLog << "before hadRF" << endl; 3730 3356 pliston.FindObject("hadRF", "MHHadronness")->DrawClone(); 3357 3358 gLog << "before hadSC" << endl; 3731 3359 pliston.FindObject("hadSC", "MHHadronness")->DrawClone(); 3732 3360 3361 gLog << "before MHHillas" << endl; 3733 3362 pliston.FindObject("MHHillas")->DrawClone(); 3363 3364 gLog << "before MHHillasExt" << endl; 3734 3365 pliston.FindObject("MHHillasExt")->DrawClone(); 3366 3367 gLog << "before MHHillasSrc" << endl; 3735 3368 pliston.FindObject("MHHillasSrc")->DrawClone(); 3369 3370 gLog << "before MHNewImagePar" << endl; 3736 3371 pliston.FindObject("MHNewImagePar")->DrawClone(); 3372 3373 gLog << "before MHStarMap" << endl; 3737 3374 pliston.FindObject("MHStarMap")->DrawClone(); 3738 3375 3376 gLog << "before DeleteBinnings" << endl; 3377 3739 3378 //DeleteBinnings(&pliston); 3740 3379 3380 gLog << "before Robert's code" << endl; 3381 3741 3382 3742 3383 //rwagner write all relevant histograms onto a file 3743 3384 3385 if (WRobert) 3386 { 3744 3387 gLog << "=======================================================" << endl; 3745 3388 gLog << "Write results onto file '" << filenameResults << "'" << endl; … … 3751 3394 TH1F* alphaHist = (TH1F*)(hillasSrc->GetHistAlpha()); 3752 3395 alphaHist->Write(); 3753 3396 gLog << "Alpha plot has been written out" << endl; 3397 3398 3754 3399 MHAlphaEnergyTheta* aetH = 3755 3400 (MHAlphaEnergyTheta*)(pliston->FindObject("MHAlphaEnergyTheta")); … … 3757 3402 aetHist->SetName("aetHist"); 3758 3403 aetHist->Write(); 3404 gLog << "AlphaEnergyTheta plot has been written out" << endl; 3759 3405 3760 3406 MHAlphaEnergyTime* aetH2 = … … 3764 3410 // aetHist2->DrawClone(); 3765 3411 aetHist2->Write(); 3412 gLog << "AlphaEnergyTime plot has been written out" << endl; 3766 3413 3767 3414 MHThetabarTime* tbt = … … 3770 3417 tbtHist->SetName("tbtHist"); 3771 3418 tbtHist->Write(); 3419 gLog << "ThetabarTime plot has been written out" << endl; 3772 3420 3773 3421 MHEnergyTime* ent = … … 3776 3424 entHist->SetName("entHist"); 3777 3425 entHist->Write(); 3426 gLog << "EnergyTime plot has been written out" << endl; 3778 3427 3779 3428 MHTimeDiffTheta *time = (MHTimeDiffTheta*)pliston.FindObject("MHTimeDiffTheta"); … … 3782 3431 timeHist->SetTitle("Time diffs"); 3783 3432 timeHist->Write(); 3433 gLog << "TimeDiffTheta plot has been written out" << endl; 3434 3784 3435 3785 3436 MHTimeDiffTime *time2 = (MHTimeDiffTime*)pliston.FindObject("MHTimeDiffTime"); … … 3788 3439 timeHist2->SetTitle("Time diffs"); 3789 3440 timeHist2->Write(); 3441 gLog << "TimeDiffTime plot has been written out" << endl; 3790 3442 3791 3443 //rwagner write also collareas to same file … … 3793 3445 collarea->GetHAll()->Write(); 3794 3446 collarea->GetHSel()->Write(); 3795 3447 gLog << "Effective collection areas have been written out" << endl; 3448 3796 3449 //rwagner todo: write alpha_cut, type of g/h sep (RF, SC, NN), type of data 3797 3450 //rwagner (ON/OFF/MC), MJDmin, MJDmax to this file 3798 3451 3452 gLog << "before closing outfile" << endl; 3453 3799 3454 //outfile.Close(); 3800 3455 gLog << "Results were written onto file '" << filenameResults 3456 << "'" << endl; 3801 3457 gLog << "=======================================================" << endl; 3802 3458 } 3459 3460 } 3803 3461 3804 3462 gLog << "Macro CT1Analysis : End of Job F_XX" << endl; -
trunk/MagicSoft/Mars/macros/CT1EgyEst.C
r2272 r2357 33 33 #include "MHMatrix.h" 34 34 #include "MEnergyEstParam.h" 35 #include "MEnergyEstParamDanielMkn421.h"35 //#include "MEnergyEstParamDanielMkn421.h" 36 36 #include "MMatrixLoop.h" 37 37 #include "MChisqEval.h" … … 206 206 // 207 207 208 //MEnergyEstParam eest2(hilName); 208 MEnergyEstParam eest2(hilName); 209 eest2.Add(hilSrcName); 210 211 eest2.SetCoeffA(parA); 212 eest2.SetCoeffB(parB); 213 214 // estimate energy using Daniel's parameters 215 //MEnergyEstParamDanielMkn421 eest2(hilName); 209 216 //eest2.Add(hilSrcName); 210 211 //eest2.SetCoeffA(parA);212 //eest2.SetCoeffB(parB);213 214 // estimate energy using Daniel's parameters215 MEnergyEstParamDanielMkn421 eest2(hilName);216 eest2.Add(hilSrcName);217 217 218 218 -
trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.cc
r2318 r2357 57 57 #include "MFEventSelector2.h" 58 58 #include "MFillH.h" 59 #include "MGeomCamCT1Daniel.h" 59 //#include "MGeomCamCT1Daniel.h" 60 #include "MGeomCamCT1.h" 60 61 #include "MH3.h" 61 62 #include "MHCT1Supercuts.h" … … 95 96 Double_t *par, Int_t iflag) 96 97 { 98 //cout << "entry fcnSupercuts" << endl; 99 97 100 //------------------------------------------------------------- 98 101 // save pointer to the MINUIT object for optimizing the supercuts … … 106 109 107 110 MParList *plistfcn = (MParList*)evtloopfcn->GetParList(); 111 //MTaskList *tasklistfcn = (MTaskList*)plistfcn->FindObject("MTaskList"); 108 112 109 113 MCT1Supercuts *super = (MCT1Supercuts*)plistfcn->FindObject("MCT1Supercuts"); … … 130 134 // for testing 131 135 //TArrayD checkparameters = super->GetParameters(); 136 //gLog << "fcnsupercuts : fNpari, fNparx =" << fNpari << ", " 137 // << fNparx << endl; 132 138 //gLog << "fcnsupercuts : i, par, checkparameters =" << endl; 133 139 //for (Int_t i=0; i<fNparx; i++) … … 142 148 evtloopfcn->Eventloop(); 143 149 150 //tasklistfcn->PrintStatistics(0, kTRUE); 151 144 152 MH3* alpha = (MH3*)plistfcn->FindObject("AlphaFcn", "MH3"); 145 153 if (!alpha) … … 147 155 148 156 TH1 &alphaHist = alpha->GetHist(); 149 //alphaHist.SetXTitle("|\\alpha| [\\circ]");157 alphaHist.SetName("alpha-fcnSupercuts"); 150 158 151 159 //------------------------------------------- … … 161 169 const Double_t alphamin = 30.0; 162 170 const Double_t alphamax = 90.0; 163 const Int_t degree = 4;171 const Int_t degree = 2; 164 172 165 173 Bool_t drawpoly; … … 240 248 //--------------------------- 241 249 // camera geometry is needed for conversion mm ==> degree 242 fCam = new MGeomCamCT1Daniel; 243 244 // matrices to contain the the training/test samples 250 //fCam = new MGeomCamCT1Daniel; 251 fCam = new MGeomCamCT1; 252 253 // matrices to contain the training/test samples 245 254 fMatrixTrain = new MHMatrix("MatrixTrain"); 246 255 fMatrixTest = new MHMatrix("MatrixTest"); … … 277 286 // 278 287 Bool_t MCT1FindSupercuts::DefineTrainMatrix(const TString &nametrain, 279 const Int_t howmanytrain, MH3 &hreftrain) 288 const Int_t howmanytrain, MH3 &hreftrain, 289 const TString &filetrain) 280 290 { 281 291 if (nametrain.IsNull() || howmanytrain <= 0) … … 343 353 *fLog << "=============================================" << endl; 344 354 355 //-------------------------- 356 // write out training matrix 357 358 if (filetrain != "") 359 { 360 TFile filetr(filetrain, "RECREATE"); 361 fMatrixTrain->Write(); 362 filetr.Close(); 363 364 *fLog << "MCT1FindSupercuts::DefineTrainMatrix; Training matrix was written onto file '" 365 << filetrain << "'" << endl; 366 } 367 368 345 369 return kTRUE; 346 370 } … … 356 380 // 357 381 Bool_t MCT1FindSupercuts::DefineTestMatrix(const TString &nametest, 358 const Int_t howmanytest, MH3 &hreftest) 382 const Int_t howmanytest, MH3 &hreftest, 383 const TString &filetest) 359 384 { 360 385 if (nametest.IsNull() || howmanytest<=0) … … 422 447 *fLog << "=============================================" << endl; 423 448 449 //-------------------------- 450 // write out test matrix 451 452 if (filetest != "") 453 { 454 TFile filete(filetest, "RECREATE", ""); 455 fMatrixTest->Write(); 456 filete.Close(); 457 458 *fLog << "MCT1FindSupercuts::DefineTestMatrix; Test matrix was written onto file '" 459 << filetest << "'" << endl; 460 } 461 462 424 463 return kTRUE; 425 464 } … … 434 473 const TString &name, 435 474 const Int_t howmanytrain, MH3 &hreftrain, 436 const Int_t howmanytest, MH3 &hreftest) 475 const Int_t howmanytest, MH3 &hreftest, 476 const TString &filetrain, const TString &filetest) 437 477 { 438 478 *fLog << "=============================================" << endl; … … 511 551 evtloop.SetProgressBar(&bar); 512 552 513 if (!evtloop.Eventloop()) 553 Int_t maxev = -1; 554 if (!evtloop.Eventloop(maxev)) 514 555 return kFALSE; 515 556 … … 520 561 if (TMath::Abs(generatedtrain-howmanytrain) > TMath::Sqrt(9.*howmanytrain)) 521 562 { 522 *fLog << "MCT1FindSupercuts::DefineTrain Matrix; no.of generated events ("563 *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; no.of generated events (" 523 564 << generatedtrain 524 565 << ") is incompatible with the no.of requested events (" … … 530 571 if (TMath::Abs(generatedtest-howmanytest) > TMath::Sqrt(9.*howmanytest)) 531 572 { 532 *fLog << "MCT1FindSupercuts::DefineT estMatrix; no.of generated events ("573 *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; no.of generated events (" 533 574 << generatedtest 534 575 << ") is incompatible with the no.of requested events (" … … 541 582 542 583 584 //-------------------------- 585 // write out training matrix 586 587 if (filetrain != "") 588 { 589 TFile filetr(filetrain, "RECREATE"); 590 fMatrixTrain->Write(); 591 filetr.Close(); 592 593 *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; Training matrix was written onto file '" 594 << filetrain << "'" << endl; 595 } 596 597 //-------------------------- 598 // write out test matrix 599 600 if (filetest != "") 601 { 602 TFile filete(filetest, "RECREATE", ""); 603 fMatrixTest->Write(); 604 filete.Close(); 605 606 *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; Test matrix was written onto file '" 607 << filetest << "'" << endl; 608 } 609 543 610 return kTRUE; 544 611 } … … 548 615 // Read training and test matrices from files 549 616 // 550 //551 // $$$$$$$$$$$$$$ this does not work !!! ??? $$$$$$$$$$$$$$$$$$$$$$552 617 // 553 618 … … 563 628 *fLog << "MCT1FindSupercuts::ReadMatrix; Training matrix was read in from file '" 564 629 << filetrain << "'" << endl; 630 filetr.Close(); 565 631 566 632 … … 574 640 *fLog << "MCT1FindSupercuts::ReadMatrix; Test matrix was read in from file '" 575 641 << filetest << "'" << endl; 576 642 filete.Close(); 577 643 578 644 return kTRUE; 579 645 } 580 646 581 // --------------------------------------------------------------------------582 //583 // Write training and test matrices onto files584 //585 //586 // $$$$$$$$$$$$$$ this does not work !!! ??? $$$$$$$$$$$$$$$$$$$$$$587 //588 //589 Bool_t MCT1FindSupercuts::WriteMatrix(const TString &filetrain, const TString &filetest)590 {591 //--------------------------592 // write out training matrix593 594 TFile filetr(filetrain, "RECREATE");595 596 *fLog << "nach TFile" << endl;597 598 fMatrixTrain->Write();599 600 *fLog << "MCT1FindSupercuts::WriteMatrix; Training matrix was written onto file '"601 << filetrain << "'" << endl;602 603 604 //--------------------------605 // write out test matrix606 607 TFile filete(filetest, "RECREATE");608 fMatrixTest->Print("SizeCols");609 fMatrixTest->Write();610 611 *fLog << "MCT1FindSupercuts::WriteMatrix; Test matrix was written onto file '"612 << filetest << "'" << endl;613 614 615 return kTRUE;616 }617 647 618 648 //------------------------------------------------------------------------ … … 645 675 // put the supercuts hadronness 646 676 // 647 // - for the minimization, the starting values of the parameters are taken as 648 // MCT1Supercuts::GetParameters(fVinit) 677 // - for the minimization, the starting values of the parameters are taken 678 // - from file parSCinit (if it is != "") 679 // - or from the arrays params and/or steps 649 680 // 650 681 //---------------------------------------------------------------------- 651 Bool_t MCT1FindSupercuts::FindParams() 682 Bool_t MCT1FindSupercuts::FindParams(TString parSCinit, 683 TArrayD ¶ms, TArrayD &steps) 652 684 { 653 685 // Setup the event loop which will be executed in the 654 686 // fcnSupercuts function of MINUIT 655 687 // 688 // parSCinit is the name of the file containing the initial values 689 // of the parameters; 690 // if parSCinit = "" 'params' and 'steps' are taken as initial values 656 691 657 692 *fLog << "=============================================" << endl; … … 685 720 MMatrixLoop loop(fMatrixTrain); 686 721 722 //-------------------------------- 687 723 // create container for the supercut parameters 688 // and set them to their defaultvalues724 // and set them to their initial values 689 725 MCT1Supercuts super; 690 726 727 // take initial values from file parSCinit 728 if (parSCinit != "") 729 { 730 TFile inparam(parSCinit); 731 super.Read("MCT1Supercuts"); 732 inparam.Close(); 733 *fLog << "MCT1FindSupercuts::FindParams; initial values of parameters are taken from file " 734 << parSCinit << endl; 735 } 736 737 // take initial values from 'params' and/or 'steps' 738 else if (params.GetSize() != 0 || steps.GetSize() != 0 ) 739 { 740 if (params.GetSize() != 0) 741 { 742 *fLog << "MCT1FindSupercuts::FindParams; initial values of parameters are taken from 'params'" 743 << endl; 744 super.SetParameters(params); 745 } 746 if (steps.GetSize() != 0) 747 { 748 *fLog << "MCT1FindSupercuts::FindParams; initial step sizes are taken from 'steps'" 749 << endl; 750 super.SetStepsizes(steps); 751 } 752 } 753 else 754 { 755 *fLog << "MCT1FindSupercuts::FindParams; initial values and step sizes are taken from the MCT1Supercits constructor" 756 << endl; 757 } 758 759 760 //-------------------------------- 691 761 // calculate supercuts hadronness 692 762 fCalcHadTrain->SetHadronnessName(fHadronnessName); … … 761 831 // 762 832 763 // get initial values of parameters from MCT1Supercuts833 // get initial values of parameters 764 834 fVinit = super.GetParameters(); 835 fStep = super.GetStepsizes(); 765 836 766 837 TString name[fVinit.GetSize()]; … … 776 847 name[i] = "p"; 777 848 name[i] += i+1; 778 fStep[i] = TMath::Abs(fVinit[i]/10.0);849 //fStep[i] = TMath::Abs(fVinit[i]/10.0); 779 850 fLimlo[i] = -100.0; 780 851 fLimup[i] = 100.0; 781 852 fFix[i] = 0; 782 783 // vary only first 48 parameters 784 if (i >= 48) 785 { 786 fStep[i] = 0.0; 787 fFix[i] = 1; 788 } 789 } 853 } 854 855 // these parameters make no sense, fix them at 0.0 856 fVinit[33] = 0.0; 857 fStep[33] = 0.0; 858 fFix[33] = 1; 859 860 fVinit[36] = 0.0; 861 fStep[36] = 0.0; 862 fFix[36] = 1; 863 864 fVinit[39] = 0.0; 865 fStep[39] = 0.0; 866 fFix[39] = 1; 867 868 fVinit[41] = 0.0; 869 fStep[41] = 0.0; 870 fFix[41] = 1; 871 872 fVinit[44] = 0.0; 873 fStep[44] = 0.0; 874 fFix[44] = 1; 875 876 fVinit[47] = 0.0; 877 fStep[47] = 0.0; 878 fFix[47] = 1; 879 880 // vary only first 48 parameters 881 //for (UInt_t i=0; i<fNpar; i++) 882 //{ 883 // if (i >= 48) 884 // { 885 // fStep[i] = 0.0; 886 // fFix[i] = 1; 887 // } 888 //} 889 790 890 791 891 // ------------------------------------------- … … 910 1010 MH3 alphabefore("MatrixTest[7]"); 911 1011 alphabefore.SetName(mh3NameB); 1012 1013 TH1 &alphahistb = alphabefore.GetHist(); 1014 alphahistb.SetName("alphaBefore-TestParams"); 1015 912 1016 MFillH fillalphabefore(&alphabefore); 913 1017 fillalphabefore.SetName("FillAlphaBefore"); … … 924 1028 MH3 alphaafter("MatrixTest[7]"); 925 1029 alphaafter.SetName(mh3NameA); 1030 1031 TH1 &alphahista = alphaafter.GetHist(); 1032 alphahista.SetName("alphaAfter-TestParams"); 1033 926 1034 MFillH fillalphaafter(&alphaafter); 927 1035 fillalphaafter.SetName("FillAlphaAfter"); … … 978 1086 TH1 &alphaHist2 = alphaAfter->GetHist(); 979 1087 alphaHist2.SetXTitle("|\\alpha| [\\circ]"); 1088 alphaHist2.SetName("alpha-TestParams)"); 980 1089 981 1090 TCanvas *c = new TCanvas("AlphaAfterSC", "AlphaTest", 600, 300); … … 999 1108 const Double_t alphamin = 30.0; 1000 1109 const Double_t alphamax = 90.0; 1001 const Int_t degree = 4;1110 const Int_t degree = 2; 1002 1111 const Bool_t drawpoly = kTRUE; 1003 1112 const Bool_t fitgauss = kFALSE; … … 1025 1134 return kTRUE; 1026 1135 } 1136 -
trunk/MagicSoft/Mars/manalysis/MCT1FindSupercuts.h
r2310 r2357 89 89 90 90 Bool_t DefineTrainMatrix(const TString &name, const Int_t howmany, 91 MH3 &href );91 MH3 &href, const TString &filetrain); 92 92 93 93 Bool_t DefineTestMatrix(const TString &name, const Int_t howmany, 94 MH3 &href );94 MH3 &href, const TString &filetest); 95 95 96 96 Bool_t DefineTrainTestMatrix(const TString &name, 97 const Int_t howmanytrain, MH3 &hreftrain, 98 const Int_t howmanytest, MH3 &hreftest); 97 const Int_t howmanytrain, MH3 &hreftrain, 98 const Int_t howmanytest, MH3 &hreftest, 99 const TString &filetrain, const TString &filetest); 100 101 MHMatrix *GetMatrixTrain() { return fMatrixTrain; } 102 MHMatrix *GetMatrixTest() { return fMatrixTest; } 99 103 100 104 Bool_t ReadMatrix( const TString &filetrain, const TString &filetest); 101 Bool_t WriteMatrix(const TString &filetrain, const TString &filetest);102 105 103 Bool_t FindParams( );106 Bool_t FindParams(TString parSCinit, TArrayD ¶ms, TArrayD &steps); 104 107 Bool_t TestParams(); 105 108 -
trunk/MagicSoft/Mars/manalysis/MCT1Supercuts.cc
r2318 r2357 50 50 // 51 51 MCT1Supercuts::MCT1Supercuts(const char *name, const char *title) 52 : fParameters(72),53 fLengthUp(fParameters.GetArray()), fLengthLo(fParameters.GetArray()+8),52 : fParameters(104), fStepsizes(104), 53 fLengthUp(fParameters.GetArray()), fLengthLo(fParameters.GetArray()+8), 54 54 fWidthUp(fParameters.GetArray()+16), fWidthLo(fParameters.GetArray()+24), 55 fDistUp(fParameters.GetArray()+32), fDistLo(fParameters.GetArray()+40), 56 fAsymUp(fParameters.GetArray()+48), fAsymLo(fParameters.GetArray()+56), 57 fAlphaUp(fParameters.GetArray()+64) 55 fDistUp(fParameters.GetArray()+32), fDistLo(fParameters.GetArray()+40), 56 fAsymUp(fParameters.GetArray()+48), fAsymLo(fParameters.GetArray()+56), 57 fConcUp(fParameters.GetArray()+64), fConcLo(fParameters.GetArray()+72), 58 fLeakage1Up(fParameters.GetArray()+80), fLeakage1Lo(fParameters.GetArray()+88), 59 fAlphaUp(fParameters.GetArray()+96) 58 60 { 59 61 fName = name ? name : "MCT1Supercuts"; … … 71 73 void MCT1Supercuts::InitParameters() 72 74 { 75 //--------------------------------------------------- 76 // these are Daniel's original values for Mkn 421 77 73 78 fLengthUp[0] = 0.315585; 74 79 fLengthUp[1] = 0.001455; … … 80 85 fLengthUp[7] = -0.013463; 81 86 87 fLengthLo[0] = 0.151530; 88 fLengthLo[1] = 0.028323; 89 fLengthLo[2] = 0.510707; 90 fLengthLo[3] = 0.053089; 91 fLengthLo[4] = 0.013708; 92 fLengthLo[5] = 2.357993; 93 fLengthLo[6] = 0.000080; 94 fLengthLo[7] = -0.007157; 95 82 96 fWidthUp[0] = 0.145412; 83 97 fWidthUp[1] = -0.001771; … … 89 103 fWidthUp[7] = -0.016703; 90 104 105 fWidthLo[0] = 0.089187; 106 fWidthLo[1] = -0.006430; 107 fWidthLo[2] = 0.074442; 108 fWidthLo[3] = 0.003738; 109 fWidthLo[4] = -0.004256; 110 fWidthLo[5] = -0.014101; 111 fWidthLo[6] = 0.006126; 112 fWidthLo[7] = -0.002849; 113 91 114 fDistUp[0] = 1.787943; 92 115 fDistUp[1] = 0; … … 98 121 fDistUp[7] = 0; 99 122 100 fLengthLo[0] = 0.151530;101 fLengthLo[1] = 0.028323;102 fLengthLo[2] = 0.510707;103 fLengthLo[3] = 0.053089;104 fLengthLo[4] = 0.013708;105 fLengthLo[5] = 2.357993;106 fLengthLo[6] = 0.000080;107 fLengthLo[7] = -0.007157;108 109 fWidthLo[0] = 0.089187;110 fWidthLo[1] = -0.006430;111 fWidthLo[2] = 0.074442;112 fWidthLo[3] = 0.003738;113 fWidthLo[4] = -0.004256;114 fWidthLo[5] = -0.014101;115 fWidthLo[6] = 0.006126;116 fWidthLo[7] = -0.002849;117 118 123 fDistLo[0] = 0.589406; 119 124 fDistLo[1] = 0; … … 124 129 fDistLo[6] = -0.001750; 125 130 fDistLo[7] = 0; 126 127 fAsymUp[0] = 0.061267; 128 fAsymUp[1] = 0.014462; 129 fAsymUp[2] = 0.014327; 130 fAsymUp[3] = 0.014540; 131 fAsymUp[4] = 0.013391; 132 fAsymUp[5] = 0.012319; 133 fAsymUp[6] = 0.010444; 134 fAsymUp[7] = 0.008328; 135 136 fAsymLo[0] = -0.012055; 137 fAsymLo[1] = 0.009157; 138 fAsymLo[2] = 0.005441; 139 fAsymLo[3] = 0.000399; 140 fAsymLo[4] = 0.001433; 141 fAsymLo[5] = -0.002050; 142 fAsymLo[6] = -0.000104; 143 fAsymLo[7] = -0.001188; 131 132 133 // dummy values 134 135 fAsymUp[0] = 1.e10; 136 fAsymUp[1] = 0.0; 137 fAsymUp[2] = 0.0; 138 fAsymUp[3] = 0.0; 139 fAsymUp[4] = 0.0; 140 fAsymUp[5] = 0.0; 141 fAsymUp[6] = 0.0; 142 fAsymUp[7] = 0.0; 143 144 fAsymLo[0] = -1.e10; 145 fAsymLo[1] = 0.0; 146 fAsymLo[2] = 0.0; 147 fAsymLo[3] = 0.0; 148 fAsymLo[4] = 0.0; 149 fAsymLo[5] = 0.0; 150 fAsymLo[6] = 0.0; 151 fAsymLo[7] = 0.0; 152 153 fConcUp[0] = 1.e10; 154 fConcUp[1] = 0.0; 155 fConcUp[2] = 0.0; 156 fConcUp[3] = 0.0; 157 fConcUp[4] = 0.0; 158 fConcUp[5] = 0.0; 159 fConcUp[6] = 0.0; 160 fConcUp[7] = 0.0; 161 162 fConcLo[0] = -1.e10; 163 fConcLo[1] = 0.0; 164 fConcLo[2] = 0.0; 165 fConcLo[3] = 0.0; 166 fConcLo[4] = 0.0; 167 fConcLo[5] = 0.0; 168 fConcLo[6] = 0.0; 169 fConcLo[7] = 0.0; 170 171 fLeakage1Up[0] = 1.e10; 172 fLeakage1Up[1] = 0.0; 173 fLeakage1Up[2] = 0.0; 174 fLeakage1Up[3] = 0.0; 175 fLeakage1Up[4] = 0.0; 176 fLeakage1Up[5] = 0.0; 177 fLeakage1Up[6] = 0.0; 178 fLeakage1Up[7] = 0.0; 179 180 fLeakage1Lo[0] = -1.e10; 181 fLeakage1Lo[1] = 0.0; 182 fLeakage1Lo[2] = 0.0; 183 fLeakage1Lo[3] = 0.0; 184 fLeakage1Lo[4] = 0.0; 185 fLeakage1Lo[5] = 0.0; 186 fLeakage1Lo[6] = 0.0; 187 fLeakage1Lo[7] = 0.0; 144 188 145 189 fAlphaUp[0] = 13.123440; … … 151 195 fAlphaUp[6] = 0; 152 196 fAlphaUp[7] = 0; 197 198 //--------------------------------------------------- 199 // fStepsizes 200 // if == 0.0 the parameter will be fixed in the minimization 201 // != 0.0 initial step sizes for the parameters 202 203 // LengthUp 204 fStepsizes[0] = 0.03; 205 fStepsizes[1] = 0.0002; 206 fStepsizes[2] = 0.02; 207 fStepsizes[3] = 0.0006; 208 fStepsizes[4] = 0.0002; 209 fStepsizes[5] = 0.002; 210 fStepsizes[6] = 0.0008; 211 fStepsizes[7] = 0.002; 212 213 // LengthLo 214 fStepsizes[8] = 0.02; 215 fStepsizes[9] = 0.003; 216 fStepsizes[10] = 0.05; 217 fStepsizes[11] = 0.006; 218 fStepsizes[12] = 0.002; 219 fStepsizes[13] = 0.3; 220 fStepsizes[14] = 0.0001; 221 fStepsizes[15] = 0.0008; 222 223 // WidthUp 224 fStepsizes[16] = 0.02; 225 fStepsizes[17] = 0.0002; 226 fStepsizes[18] = 0.006; 227 fStepsizes[19] = 0.003; 228 fStepsizes[20] = 0.002; 229 fStepsizes[21] = 0.006; 230 fStepsizes[22] = 0.002; 231 fStepsizes[23] = 0.002; 232 233 // WidthLo 234 fStepsizes[24] = 0.009; 235 fStepsizes[25] = 0.0007; 236 fStepsizes[26] = 0.008; 237 fStepsizes[27] = 0.0004; 238 fStepsizes[28] = 0.0005; 239 fStepsizes[29] = 0.002; 240 fStepsizes[30] = 0.0007; 241 fStepsizes[31] = 0.003; 242 243 // DistUp 244 fStepsizes[32] = 0.2; 245 fStepsizes[33] = 0.0; 246 fStepsizes[34] = 0.3; 247 fStepsizes[35] = 0.02; 248 fStepsizes[36] = 0.0; 249 fStepsizes[37] = 0.03; 250 fStepsizes[38] = 0.02; 251 fStepsizes[39] = 0.0; 252 253 // DistLo 254 fStepsizes[40] = 0.06; 255 fStepsizes[41] = 0.0; 256 fStepsizes[42] = 0.009; 257 fStepsizes[43] = 0.0008; 258 fStepsizes[44] = 0.0; 259 fStepsizes[45] = 0.005; 260 fStepsizes[46] = 0.0002; 261 fStepsizes[47] = 0.0; 262 263 // AsymUp 264 fStepsizes[48] = 0.0; 265 fStepsizes[49] = 0.0; 266 fStepsizes[50] = 0.0; 267 fStepsizes[51] = 0.0; 268 fStepsizes[52] = 0.0; 269 fStepsizes[53] = 0.0; 270 fStepsizes[54] = 0.0; 271 fStepsizes[55] = 0.0; 272 273 // AsymLo 274 fStepsizes[56] = 0.0; 275 fStepsizes[57] = 0.0; 276 fStepsizes[58] = 0.0; 277 fStepsizes[59] = 0.0; 278 fStepsizes[60] = 0.0; 279 fStepsizes[61] = 0.0; 280 fStepsizes[62] = 0.0; 281 fStepsizes[63] = 0.0; 282 283 // ConcUp 284 fStepsizes[64] = 0.0; 285 fStepsizes[65] = 0.0; 286 fStepsizes[66] = 0.0; 287 fStepsizes[67] = 0.0; 288 fStepsizes[68] = 0.0; 289 fStepsizes[69] = 0.0; 290 fStepsizes[70] = 0.0; 291 fStepsizes[71] = 0.0; 292 293 // ConcLo 294 fStepsizes[72] = 0.0; 295 fStepsizes[73] = 0.0; 296 fStepsizes[74] = 0.0; 297 fStepsizes[75] = 0.0; 298 fStepsizes[76] = 0.0; 299 fStepsizes[77] = 0.0; 300 fStepsizes[78] = 0.0; 301 fStepsizes[79] = 0.0; 302 303 // Leakage1Up 304 fStepsizes[80] = 0.0; 305 fStepsizes[81] = 0.0; 306 fStepsizes[82] = 0.0; 307 fStepsizes[83] = 0.0; 308 fStepsizes[84] = 0.0; 309 fStepsizes[85] = 0.0; 310 fStepsizes[86] = 0.0; 311 fStepsizes[87] = 0.0; 312 313 // Leakage1Lo 314 fStepsizes[88] = 0.0; 315 fStepsizes[89] = 0.0; 316 fStepsizes[90] = 0.0; 317 fStepsizes[91] = 0.0; 318 fStepsizes[92] = 0.0; 319 fStepsizes[93] = 0.0; 320 fStepsizes[94] = 0.0; 321 fStepsizes[95] = 0.0; 322 323 // AlphaUp 324 fStepsizes[96] = 0.0; 325 fStepsizes[97] = 0.0; 326 fStepsizes[98] = 0.0; 327 fStepsizes[99] = 0.0; 328 fStepsizes[100] = 0.0; 329 fStepsizes[101] = 0.0; 330 fStepsizes[102] = 0.0; 331 fStepsizes[103] = 0.0; 153 332 } 154 333 … … 173 352 } 174 353 175 176 177 178 179 180 181 182 183 184 185 354 // -------------------------------------------------------------------------- 355 // 356 // Set the step sizes from the array 'd' 357 // 358 // 359 Bool_t MCT1Supercuts::SetStepsizes(const TArrayD &d) 360 { 361 if (d.GetSize() != fStepsizes.GetSize()) 362 { 363 *fLog << err << "Sizes of d and of fStepsizes are different : " 364 << d.GetSize() << ", " << fStepsizes.GetSize() << endl; 365 return kFALSE; 366 } 367 368 fStepsizes = d; 369 370 return kTRUE; 371 } 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 -
trunk/MagicSoft/Mars/manalysis/MCT1Supercuts.h
r2311 r2357 14 14 private: 15 15 TArrayD fParameters; // supercut parameters 16 TArrayD fStepsizes; // step sizes of supercut parameters 16 17 17 18 Double_t *fLengthUp; //! … … 23 24 Double_t *fAsymUp; //! 24 25 Double_t *fAsymLo; //! 26 27 Double_t *fConcUp; //! 28 Double_t *fConcLo; //! 29 Double_t *fLeakage1Up; //! 30 Double_t *fLeakage1Lo; //! 31 25 32 Double_t *fAlphaUp; //! 33 26 34 27 35 public: … … 31 39 32 40 Bool_t SetParameters(const TArrayD &d); 41 Bool_t SetStepsizes(const TArrayD &d); 42 33 43 const TArrayD &GetParameters() const { return fParameters; } 44 const TArrayD &GetStepsizes() const { return fStepsizes; } 34 45 35 46 const Double_t *GetLengthUp() const { return fLengthUp; } … … 41 52 const Double_t *GetAsymUp() const { return fAsymUp; } 42 53 const Double_t *GetAsymLo() const { return fAsymLo; } 54 55 const Double_t *GetConcUp() const { return fConcUp; } 56 const Double_t *GetConcLo() const { return fConcLo; } 57 58 const Double_t *GetLeakage1Up() const { return fLeakage1Up; } 59 const Double_t *GetLeakage1Lo() const { return fLeakage1Lo; } 60 43 61 const Double_t *GetAlphaUp() const { return fAlphaUp; } 44 62 … … 47 65 48 66 #endif 67 68 69 -
trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc
r2308 r2357 44 44 #include "MHillasExt.h" 45 45 #include "MHillasSrc.h" 46 #include "MNewImagePar.h" 46 47 #include "MMcEvt.hxx" 47 48 #include "MCerPhotEvt.h" … … 65 66 66 67 MCT1SupercutsCalc::MCT1SupercutsCalc(const char *hilname, 67 const char *hilsrcname, const char *name, const char *title) 68 const char *hilsrcname, 69 const char *name, const char *title) 68 70 : fHadronnessName("MHadronness"), fHilName(hilname), fHilSrcName(hilsrcname), 69 fSuperName("MCT1Supercuts") 71 fHilExtName("MHillasExt"), fNewParName("MNewImagePar"), 72 fSuperName("MCT1Supercuts") 70 73 { 71 74 fName = name ? name : "MCT1SupercutsCalc"; … … 101 104 return kFALSE; 102 105 } 103 104 106 105 107 if (fMatrix) … … 114 116 } 115 117 118 fHilExt = (MHillasExt*)pList->FindObject(fHilExtName, "MHillasExt"); 119 if (!fHilExt) 120 { 121 *fLog << err << fHilExtName << " [MHillasExt] not found... aborting." << endl; 122 return kFALSE; 123 } 124 116 125 fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc"); 117 126 if (!fHilSrc) 118 127 { 119 128 *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl; 129 return kFALSE; 130 } 131 132 fNewPar = (MNewImagePar*)pList->FindObject(fNewParName, "MNewImagePar"); 133 if (!fNewPar) 134 { 135 *fLog << err << fNewParName << " [MNewImagePar] not found... aborting." << endl; 120 136 return kFALSE; 121 137 } … … 172 188 Double_t MCT1SupercutsCalc::GetVal(Int_t i) const 173 189 { 174 return (*fMatrix)[fMap[i]]; 190 191 Double_t val = (*fMatrix)[fMap[i]]; 192 193 194 //*fLog << "MCT1SupercutsCalc::GetVal; i, fMatrix, fMap, val = " 195 // << i << ", " << fMatrix << ", " << fMap[i] << ", " << val << endl; 196 197 198 return val; 175 199 } 176 200 … … 187 211 { 188 212 if (fMatrix) 189 213 return; 190 214 191 215 fMatrix = mat; … … 199 223 fMap[6] = fMatrix->AddColumn("MHillasSrc.fDist"); 200 224 fMap[7] = fMatrix->AddColumn("fabs(MHillasSrc.fAlpha)"); 225 fMap[8] = fMatrix->AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)"); 226 fMap[9] = fMatrix->AddColumn("MNewImagePar.fConc"); 227 fMap[10]= fMatrix->AddColumn("MNewImagePar.fLeakage1"); 201 228 } 202 229 203 230 // --------------------------------------------------------------------------- 204 231 // 205 // Evaluate dynamical supercuts for CT1 Mkn421 2001 (Daniel Kranich) 206 // optimized for mkn 421 2001 data 232 // Evaluate dynamical supercuts 207 233 // 208 234 // set hadronness to 0.25 if cuts are fullfilled … … 222 248 const Double_t dist0 = fMatrix ? GetVal(6) : fHilSrc->GetDist(); 223 249 250 Double_t help; 251 if (!fMatrix) 252 help = TMath::Sign(fHilExt->GetM3Long(), 253 fHilSrc->GetCosDeltaAlpha()); 254 const Double_t asym0 = fMatrix ? GetVal(8) : help; 255 const Double_t conc = fMatrix ? GetVal(9) : fNewPar->GetConc(); 256 const Double_t leakage = fMatrix ? GetVal(10): fNewPar->GetLeakage1(); 257 224 258 const Double_t newdist = dist0 * fMm2Deg; 225 259 … … 236 270 const Double_t length = length0 * fMm2Deg; 237 271 const Double_t width = width0 * fMm2Deg; 238 239 if (newdist < 1.05 && 272 const Double_t asym = asym0 * fMm2Deg; 273 274 /* 275 *fLog << "newdist, length, width, asym, dist, conc, leakage = " 276 << newdist << ", " << length << ", " << width << ", " 277 << asym << ", " << dist << ", " << conc << ", " << leakage 278 << endl; 279 280 *fLog << "upper cuts in newdist, length, width, asym, dist, conc, leakage = " 281 << CtsMCut (fSuper->GetDistUp(), dmls, dmcza, dmls2, dd2) << ", " 282 << CtsMCut (fSuper->GetDistLo(), dmls, dmcza, dmls2, dd2) << ", " 283 284 << CtsMCut (fSuper->GetLengthUp(), dmls, dmcza, dmls2, dd2) << ", " 285 << CtsMCut (fSuper->GetLengthLo(), dmls, dmcza, dmls2, dd2) << ", " 286 287 << CtsMCut (fSuper->GetWidthUp(), dmls, dmcza, dmls2, dd2) << ", " 288 << CtsMCut (fSuper->GetWidthLo(), dmls, dmcza, dmls2, dd2) << ", " 289 290 << CtsMCut (fSuper->GetAsymUp(), dmls, dmcza, dmls2, dd2) << ", " 291 << CtsMCut (fSuper->GetAsymLo(), dmls, dmcza, dmls2, dd2) << ", " 292 293 << CtsMCut (fSuper->GetDistUp(), dmls, dmcza, dmls2, dd2) << ", " 294 << CtsMCut (fSuper->GetDistLo(), dmls, dmcza, dmls2, dd2) << ", " 295 296 << CtsMCut (fSuper->GetConcUp(), dmls, dmcza, dmls2, dd2) << ", " 297 << CtsMCut (fSuper->GetConcLo(), dmls, dmcza, dmls2, dd2) << ", " 298 299 << CtsMCut (fSuper->GetLeakage1Up(), dmls, dmcza, dmls2, dd2) << ", " 300 << CtsMCut (fSuper->GetLeakage1Lo(), dmls, dmcza, dmls2, dd2) << ", " 301 << endl; 302 */ 303 304 305 if ( 306 //dist < 1.05 && 307 //newdist < 1.05 && 308 240 309 newdist < CtsMCut (fSuper->GetDistUp(), dmls, dmcza, dmls2, dd2) && 241 310 newdist > CtsMCut (fSuper->GetDistLo(), dmls, dmcza, dmls2, dd2) && 242 dist < 1.05 && 311 243 312 length < CtsMCut (fSuper->GetLengthUp(), dmls, dmcza, dmls2, dd2) && 244 313 length > CtsMCut (fSuper->GetLengthLo(), dmls, dmcza, dmls2, dd2) && 314 245 315 width < CtsMCut (fSuper->GetWidthUp(), dmls, dmcza, dmls2, dd2) && 246 316 width > CtsMCut (fSuper->GetWidthLo(), dmls, dmcza, dmls2, dd2) && 247 //asym < CtsMCut (fSuper->GetAsymUp(), dmls, dmcza, dmls2, dd2) && 248 //asym > CtsMCut (fSuper->GetAsymLo(), dmls, dmcza, dmls2, dd2) && 317 318 asym < CtsMCut (fSuper->GetAsymUp(), dmls, dmcza, dmls2, dd2) && 319 asym > CtsMCut (fSuper->GetAsymLo(), dmls, dmcza, dmls2, dd2) && 320 249 321 dist < CtsMCut (fSuper->GetDistUp(), dmls, dmcza, dmls2, dd2) && 250 dist > CtsMCut (fSuper->GetDistLo(), dmls, dmcza, dmls2, dd2) ) 251 fHadronness->SetHadronness(0.25); 322 dist > CtsMCut (fSuper->GetDistLo(), dmls, dmcza, dmls2, dd2) && 323 324 conc < CtsMCut (fSuper->GetConcUp(), dmls, dmcza, dmls2, dd2) && 325 conc > CtsMCut (fSuper->GetConcLo(), dmls, dmcza, dmls2, dd2) && 326 327 leakage < CtsMCut (fSuper->GetLeakage1Up(),dmls, dmcza, dmls2, dd2) && 328 leakage > CtsMCut (fSuper->GetLeakage1Lo(),dmls, dmcza, dmls2, dd2) ) 329 330 fHadronness->SetHadronness(0.25); 252 331 else 253 fHadronness->SetHadronness(0.75); 332 fHadronness->SetHadronness(0.75); 333 334 //*fLog << "SChadroness = " << fHadronness->GetHadronness() << endl; 254 335 255 336 fHadronness->SetReadyToSave(); … … 257 338 return kTRUE; 258 339 } 340 341 342 343 344 345 346 347 348 -
trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.h
r2308 r2357 13 13 class MHillas; 14 14 class MHillasSrc; 15 class MHillasExt; 16 class MNewImagePar; 15 17 class MMcEvt; 16 18 class MCerPhotEvt; … … 25 27 MHillas *fHil; 26 28 MHillasSrc *fHilSrc; 29 MHillasExt *fHilExt; 30 MNewImagePar *fNewPar; 27 31 MMcEvt *fMcEvt; 28 32 MHadronness *fHadronness; //! output container for hadronness … … 32 36 TString fHilName; 33 37 TString fHilSrcName; 38 TString fHilExtName; 39 TString fNewParName; 34 40 TString fSuperName; // name of container for supercut parameters 35 41 36 42 Double_t fMm2Deg; //! 37 43 38 Int_t fMap[ 8];//!44 Int_t fMap[11]; //! 39 45 MHMatrix *fMatrix; //! 40 46 … … 63 69 64 70 #endif 71 72 73 74 75 76 77 78 79 80 81 82 -
trunk/MagicSoft/Mars/manalysis/MMinuitInterface.cc
r2318 r2357 103 103 // 3 maximum output, showing progress of minimizations 104 104 // 105 minuit.SetPrintLevel( 1);105 minuit.SetPrintLevel(-1); 106 106 107 107 //.............................................. … … 175 175 176 176 //.............................................. 177 // This doesn't seem to have any effect 177 178 // Set maximum number of iterations (default = 500) 178 179 //Int_t maxiter = 100000; 179 minuit.SetMaxIterations(10);180 //minuit.SetMaxIterations(maxiter); 180 181 181 182 //.............................................. … … 211 212 if (nulloutput) 212 213 fLog->SetNullOutput(kTRUE); 213 Double_t tmp = 0; 214 minuit.mnexcm("SIMPLEX", &tmp, 0, fErrMinimize); 214 Int_t maxcalls = 3000; 215 Double_t tolerance = 0.1; 216 Double_t tmp[2]; 217 tmp[0] = maxcalls; 218 tmp[1] = tolerance; 219 minuit.mnexcm("SIMPLEX", &tmp[0], 2, fErrMinimize); 215 220 if (nulloutput) 216 221 fLog->SetNullOutput(kFALSE); 217 //*fLog << "return from SIMPLEX" << endl;222 *fLog << "return from SIMPLEX" << endl; 218 223 } 219 224 … … 269 274 // 2 values, errors, step sizes, internal values 270 275 // 3 values, errors, step sizes, 1st derivatives 271 // 4 values, parabol oc errors, MINOS errors276 // 4 values, parabolic errors, MINOS errors 272 277 273 278 //Int_t nkode = 4; … … 292 297 return kTRUE; 293 298 } 299 300 301 302 303 304 305 306 307 -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc
r2206 r2357 188 188 } 189 189 190 *fLog << "-------------------------" << endl; 191 *fLog << "MFEventSelector2::ReadDistribution; read input file to generate the original distribution" << endl; 192 190 193 MEvtLoop run(GetName()); 191 194 MParList plist; … … 215 218 } 216 219 220 tlist.PrintStatistics(0, kTRUE); 221 222 *fLog << "MFEventSelector2::ReadDistribution; Original distribution has " 223 << fHistOrig->GetHist().GetEntries() << " entries" << endl; 224 *fLog << "-------------------------" << endl; 225 217 226 return read.Rewind(); 218 227 } … … 259 268 if (fNumMax>0) 260 269 { 261 cout << "SCALE: " << fNumMax/hn.Integral() << endl; 262 cout << "SCALE: " << fNumMax << endl; 263 cout << "SCALE: " << hn.Integral() << endl; 270 *fLog << "MFEventSelector2::PrepareHistograms; SCALE : fNumMax = " 271 << fNumMax << ", hn.Integral() = " << hn.Integral() 272 << ", fNumMax/hn.Integral() = " << fNumMax/hn.Integral() 273 << endl; 274 264 275 hn.Scale(fNumMax/hn.Integral()); 265 276 } … … 329 340 Int_t MFEventSelector2::PreProcess(MParList *parlist) 330 341 { 342 memset(fErrors, 0, sizeof(fErrors)); 343 331 344 MTaskList *tasklist = (MTaskList*)parlist->FindObject("MTaskList"); 332 345 if (!tasklist) … … 383 396 const Double_t valz=fDataZ.GetValue(); 384 397 398 385 399 // get corresponding bin number 386 400 const Int_t bin = fHistNom->FindFixBin(valx, valy, valz)-1; … … 389 403 if (bin<0) 390 404 return kTRUE; 405 391 406 392 407 if (gRandom->Rndm()*fIs[bin]<=fNom[bin]) … … 404 419 fIs[bin]-=1; 405 420 421 //---------------------- 422 Int_t rc; 423 if (fResult) 424 { 425 rc = 0; 426 fErrors[rc]++; 427 return kTRUE; 428 } 429 rc = 1; 430 fErrors[rc]++; 431 //---------------------- 432 406 433 return kTRUE; 407 434 } … … 413 440 Int_t MFEventSelector2::PostProcess() 414 441 { 442 //--------------------------------- 443 if (GetNumExecutions() != 0) 444 { 445 *fLog << inf << endl; 446 *fLog << GetDescriptor() << " execution statistics:" << endl; 447 *fLog << dec << setfill(' '); 448 *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) 449 << (int)(fErrors[1]*100/GetNumExecutions()) 450 << "%) Events not selected" << endl; 451 452 *fLog << " " << fErrors[0] << " (" 453 << (int)(fErrors[0]*100/GetNumExecutions()) 454 << "%) Events selected!" << endl; 455 *fLog << endl; 456 } 457 //--------------------------------- 458 415 459 if (!fCanvas || !fDisplay) 416 460 return kTRUE; -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h
r2206 r2357 42 42 43 43 Bool_t fResult; 44 Int_t fErrors[2]; 44 45 45 46 TH1 &InitHistogram(MH3* &hist); -
trunk/MagicSoft/Mars/mhist/MHCT1Supercuts.cc
r2310 r2357 61 61 // 62 62 fName = name ? name : "MHCT1Supercuts"; 63 fTitle = title ? title : "Container for supercuts";63 fTitle = title ? title : "Container for histograms for the supercuts"; 64 64 65 65 -
trunk/MagicSoft/Mars/mhist/MHFindSignificance.cc
r2318 r2357 353 353 fHistOrig = fhist; 354 354 355 fHist = (TH1*)fHistOrig->Clone("|alpha| plot"); 355 fHist = (TH1*)fHistOrig->Clone(); 356 fHist->SetName(fhist->GetName()); 356 357 if ( !fHist ) 357 358 { … … 362 363 363 364 fHist->Sumw2(); 364 fHist->SetNameTitle("Alpha", "alpha plot");365 //fHist->SetNameTitle("Alpha", "alpha plot"); 365 366 fHist->SetXTitle("|alpha| [\\circ]"); 366 367 fHist->SetYTitle("Counts"); 368 fHist->UseCurrentStyle(); 367 369 368 370 fAlphamin = alphamin; … … 502 504 fHistOrig = fhist; 503 505 504 fHist = (TH1*)fHistOrig->Clone("|alpha| plot"); 506 fHist = (TH1*)fHistOrig->Clone(); 507 fHist->SetName(fhist->GetName()); 505 508 fHist->Sumw2(); 506 fHist->SetNameTitle("alpha", "alpha plot");509 //fHist->SetNameTitle("alpha", "alpha plot"); 507 510 fHist->SetXTitle("|alpha| [\\circ]"); 508 511 fHist->SetYTitle("Counts"); 509 512 fHist->UseCurrentStyle(); 510 513 511 514 fAlphamin = alphamin; … … 754 757 755 758 nrebin += 1; 756 //if (fHist)757 758 759 TString histname = fHist->GetName(); 760 delete fHist; 761 fHist = NULL; 759 762 760 763 *fLog << "MHFindSignificance::FitPolynomial; rebin the |alpha| plot, grouping " … … 766 769 fHist = new TH1F; 767 770 fHist->Sumw2(); 768 fHist->SetNameTitle( "Rebinned", "Rebinned alpha plot");769 771 fHist->SetNameTitle(histname, histname); 772 fHist->UseCurrentStyle(); 770 773 771 774 // do rebinning such that x0 remains a lower bin edge … … 911 914 } 912 915 913 *fLog << "FitPolynomial : before CallMinuit()" << endl;916 //*fLog << "FitPolynomial : before CallMinuit()" << endl; 914 917 915 918 MMinuitInterface inter; … … 918 921 kFALSE); 919 922 920 *fLog << "FitPolynomial : after CallMinuit()" << endl;923 //*fLog << "FitPolynomial : after CallMinuit()" << endl; 921 924 922 925 if (rc != 0) … … 1909 1912 // get errors 1910 1913 1914 /* 1911 1915 Double_t eplus; 1912 1916 Double_t eminus; … … 1943 1947 } 1944 1948 } 1949 */ 1945 1950 1946 1951 //---------------------------------------- 1952 /* 1947 1953 *fLog << "Covariance matrix :" << endl; 1948 1954 for (Int_t j=0; j<=fDegree; j++) … … 1966 1972 *fLog << endl; 1967 1973 } 1974 */ 1968 1975 1969 1976 *fLog << "---------------------------" << endl; -
trunk/MagicSoft/Mars/mhist/MHMatrix.h
r2328 r2357 30 30 static const TString gsDefTitle; //! Default Title 31 31 32 Int_t fNumRow; // !Number of dimensions of histogram32 Int_t fNumRow; // Number of dimensions of histogram 33 33 Int_t fRow; //! Present row 34 34 TMatrix fM; // Matrix to be filled -
trunk/MagicSoft/Mars/mmontecarlo/MMcEnergyEst.cc
r2179 r2357 219 219 // 220 220 *fLog << inf << "--------------------------------------" << endl; 221 *fLog << inf << "Start minimization " << endl;221 *fLog << inf << "Start minimization for the energy estimator" << endl; 222 222 223 223 gMinuit = new TMinuit(12); … … 316 316 // eest.Print(); 317 317 eest.StopMapping(); 318 *fLog << inf << "Minimization f inished" << endl;318 *fLog << inf << "Minimization for the energy estimator finished" << endl; 319 319 320 320 }
Note:
See TracChangeset
for help on using the changeset viewer.