Changeset 2436 for trunk/MagicSoft/Mars
- Timestamp:
- 10/27/03 08:58:48 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/macros/CT1Analysis.C
r2368 r2436 210 210 //----------------------------------------------- 211 211 212 TEnv env("macros/CT1env.rc");213 Bool_t printEnv = kFALSE;212 //TEnv env("macros/CT1env.rc"); 213 //Bool_t printEnv = kFALSE; 214 214 215 215 //************************************************************************ … … 219 219 // - write root file for ON data (ON1.root); 220 220 221 Bool_t JobA_ON = k TRUE;222 Bool_t WHistON = k TRUE; // write out histogram sigmabar vs. Theta ?223 Bool_t WON1 = k TRUE; // write out root file ON1.root ?221 Bool_t JobA_ON = kFALSE; 222 Bool_t WHistON = kFALSE; // write out histogram sigmabar vs. Theta ? 223 Bool_t WON1 = kFALSE; // write out root file ON1.root ? 224 224 225 225 … … 234 234 235 235 // Job B_RF_UP : read ON1.root (or MC1.root) file 236 // - depending on RLook : create (or read in) hadron and gamma matrix 237 // - depending on RTree : create (or read in) trees 236 // - if RTrainRF = TRUE : read in training matrices for hadrons and gammas 237 // - if CTrainRF = TRUE : create training matrices for hadrons and gammas 238 // - if RTree = TRUE : read in trees, otherwise create trees 238 239 // - calculate hadroness for method of RANDOM FOREST 239 // - update the input files with the hadroness ( ON1.root or MC1.root)240 // - update the input files with the hadroness (==>ON2.root or MC2.root) 240 241 241 242 Bool_t JobB_RF_UP = kFALSE; 242 Bool_t RLookRF = kFALSE; // read in look-alike events 243 Bool_t RTrainRF = kFALSE; // read in matrices of training events 244 Bool_t CTrainRF = kFALSE; // create matrices of training events 243 245 Bool_t RTree = kFALSE; // read in trees 244 246 Bool_t WRF = kFALSE; // update input root file ? … … 247 249 248 250 249 // Job B_SC_UP : read ON 1.root (or MC1.root) file251 // Job B_SC_UP : read ON2.root (or MC2.root) file 250 252 // - depending on WParSC : create (or read in) supercuts parameter values 251 253 // - calculate hadroness for the SUPERCUTS 252 // - update the input files with the hadroness ( ON1.root or MC1.root)254 // - update the input files with the hadroness (==>ON3.root or MC3.root) 253 255 254 256 Bool_t JobB_SC_UP = kFALSE; … … 263 265 264 266 // Job C: 265 // - read ON 1.root and MC1.root files267 // - read ON3.root and MC3.root files 266 268 // which should have been updated to contain the hadronnesses 267 269 // for the method of 268 // NEAREST NEIGHBORS270 // RF 269 271 // SUPERCUTS and 270 // RF271 272 // - produce Neyman-Pearson plots 272 273 … … 276 277 // Job D : 277 278 // - select g/h separation method XX 278 // - read ON 2 (or MC2) root file279 // - read ON3 (or MC3) root file 279 280 // - apply cuts in hadronness 280 281 // - make plots … … 296 297 297 298 Bool_t JobE_XX = kFALSE; 298 Bool_t WEX = kFALSE; // write out root file ? 299 Bool_t OEEst = kFALSE; // optimize energy estimator 300 Bool_t WEX = kFALSE; // update root file ? 299 301 Bool_t WRobert = kFALSE; // write out Robert's file ? 300 302 … … 492 494 MEvtLoop evtloop; 493 495 evtloop.SetParList(&pliston); 494 evtloop.ReadEnv(env, "", printEnv);496 //evtloop.ReadEnv(env, "", printEnv); 495 497 evtloop.SetProgressBar(&bar); 496 498 //if (WON1) … … 822 824 MEvtLoop evtloop; 823 825 evtloop.SetParList(&plist); 824 evtloop.ReadEnv(env, "", printEnv);826 //evtloop.ReadEnv(env, "", printEnv); 825 827 evtloop.SetProgressBar(&bar); 826 828 //if (WMC1) … … 863 865 864 866 865 // - create (or read in) the matrices of look-alikeevents for gammas867 // - create (or read in) the matrices of training events for gammas 866 868 // and hadrons 867 869 // - create (or read in) the trees … … 877 879 878 880 gLog << "" << endl; 879 gLog << "Macro CT1Analysis : JobB_RF_UP, R LookRF, RTree, WRF = "881 gLog << "Macro CT1Analysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = " 880 882 << (JobB_RF_UP ? "kTRUE" : "kFALSE") << ", " 881 << (RLookRF ? "kTRUE" : "kFALSE") << ", " 883 << (RTrainRF ? "kTRUE" : "kFALSE") << ", " 884 << (CTrainRF ? "kTRUE" : "kFALSE") << ", " 882 885 << (RTree ? "kTRUE" : "kFALSE") << ", " 883 886 << (WRF ? "kTRUE" : "kFALSE") << endl; … … 890 893 Int_t NdSize = 1; 891 894 895 // cut in RF hadronness 896 TString hadRFName = "HadRF"; 897 Float_t maxhadronness = 0.23; 898 Float_t maxalpha = 20.0; 899 Float_t maxdist = 10.0; 900 901 TString fHilName = "MHillas"; 902 TString fHilNameExt = "MHillasExt"; 903 TString fHilNameSrc = "MHillasSrc"; 904 TString fImgParName = "MNewImagePar"; 905 892 906 893 907 //-------------------------------------------- 894 908 // file to be updated (either ON or MC) 895 909 896 TString typeInput = "ON";897 //TString typeInput = "MC";910 //TString typeInput = "ON"; 911 TString typeInput = "MC"; 898 912 gLog << "typeInput = " << typeInput << endl; 899 913 … … 913 927 914 928 //-------------------------------------------- 915 // files to be read for generating the look-alikeevents929 // files to be read for generating the matrices of training events 916 930 // "hadrons" : 917 931 TString filenameON = outPath; … … 932 946 933 947 //-------------------------------------------- 934 // files of look-alikeevents948 // files of training events 935 949 936 950 TString outNameGammas = outPath; … … 951 965 matrixg.EnableGraphicalOutput(); 952 966 967 matrixg.AddColumn("cos(MMcEvt.fTelescopeTheta)"); 968 matrixg.AddColumn("MSigmabar.fSigmabar"); 969 matrixg.AddColumn("log10(MHillas.fSize)"); 970 matrixg.AddColumn("MHillasSrc.fDist"); 971 matrixg.AddColumn("MHillas.fWidth"); 972 matrixg.AddColumn("MHillas.fLength"); 973 matrixg.AddColumn("log10(MHillas.fSize/(MHillas.fWidth*MHillas.fLength))"); 974 matrixg.AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)"); 975 matrixg.AddColumn("MNewImagePar.fConc"); 976 matrixg.AddColumn("MNewImagePar.fLeakage1"); 977 953 978 MHMatrix matrixh("MatrixHadrons"); 954 979 matrixh.EnableGraphicalOutput(); 955 980 981 matrixh.AddColumns(matrixg.GetColumns()); 982 956 983 //-------------------------------------------- 957 984 // file of trees of the random forest … … 962 989 963 990 //************************************************************************* 964 // read in matrices of look-alikeevents965 if (R LookRF)991 // read in matrices of training events 992 if (RTrainRF) 966 993 { 967 994 const char* mtxName = "MatrixGammas"; … … 1005 1032 1006 1033 //************************************************************************* 1007 // create matrices of look-alikeevents1008 if ( !RLookRF)1034 // create matrices of training events 1035 if (CTrainRF) 1009 1036 { 1010 1037 gLog << "" << endl; 1011 1038 gLog << "========================================================" << endl; 1012 gLog << " Create matrices of look-alikeevents" << endl;1039 gLog << " Create matrices of training events" << endl; 1013 1040 gLog << " Gammas :" << endl; 1014 1041 … … 1085 1112 MEvtLoop evtloopg; 1086 1113 evtloopg.SetParList(&plistg); 1087 evtloopg.ReadEnv(env, "", printEnv);1114 //evtloopg.ReadEnv(env, "", printEnv); 1088 1115 evtloopg.SetProgressBar(&matrixbar); 1089 1116 … … 1141 1168 MEvtLoop evtlooph; 1142 1169 evtlooph.SetParList(&plisth); 1143 evtlooph.ReadEnv(env, "", printEnv);1170 //evtlooph.ReadEnv(env, "", printEnv); 1144 1171 evtlooph.SetProgressBar(&matrixbar); 1145 1172 … … 1155 1182 1156 1183 1157 // write out look-alikeevents1184 // write out training events 1158 1185 1159 1186 gLog << "" << endl; 1160 1187 gLog << "========================================================" << endl; 1161 gLog << "Write out look=alikeevents" << endl;1188 gLog << "Write out training events" << endl; 1162 1189 1163 1190 … … 1171 1198 1172 1199 gLog << "" << endl; 1173 gLog << "Macro CT1Analysis : matrix of look-alikeevents for gammas written onto file "1200 gLog << "Macro CT1Analysis : matrix of training events for gammas written onto file " 1174 1201 << outNameGammas << endl; 1175 1202 … … 1183 1210 1184 1211 gLog << "" << endl; 1185 gLog << "Macro CT1Analysis : matrix of look-alikeevents for hadrons written onto file "1212 gLog << "Macro CT1Analysis : matrix of training events for hadrons written onto file " 1186 1213 << outNameHadrons << endl; 1187 1214 1188 1215 } 1189 //********** end of creating matrices of look-alikeevents ***********1216 //********** end of creating matrices of training events *********** 1190 1217 1191 1218 … … 1301 1328 1302 1329 1303 1304 1330 //----------------------------------------------------------------- 1305 1331 // Update the input files with the RF hadronness 1306 1332 // 1307 1308 1333 if (WRF) 1309 1334 { … … 1328 1353 read.DisableAutoScheme(); 1329 1354 1330 TString fHilName = "MHillas";1331 TString fHilNameExt = "MHillasExt";1332 TString fHilNameSrc = "MHillasSrc";1333 TString fImgParName = "MNewImagePar";1334 1355 1335 1356 //....................................................................... 1336 1357 // calculate hadronnes for method of RANDOM FOREST 1337 1358 1338 TString hadRFName = "HadRF"; 1359 1339 1360 MRanForestCalc rfcalc; 1340 1361 rfcalc.SetHadronnessName(hadRFName); … … 1360 1381 1361 1382 //----------------------------------------------------------------- 1362 // geometry is needed in MHHillas... classes 1363 MGeomCam *fGeom = 1364 (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam"); 1365 1366 1367 Float_t maxhadronness = 0.40; 1368 Float_t maxalpha = 20.0; 1369 Float_t maxdist = 10.0; 1383 1370 1384 1371 1385 MFCT1SelFinal selfinalgh(fHilNameSrc); … … 1482 1496 TH1 &alphaHist = absalpha->GetHist(); 1483 1497 alphaHist.SetXTitle("|alpha| [\\circ]"); 1498 alphaHist.SetName("alpha-macro"); 1484 1499 1485 1500 Double_t alphasig = 13.1; 1486 1501 Double_t alphamin = 30.0; 1487 1502 Double_t alphamax = 90.0; 1488 Int_t degree = 4;1503 Int_t degree = 2; 1489 1504 Double_t significance = -99.0; 1490 1505 Bool_t drawpoly = kTRUE; … … 1563 1578 1564 1579 TString parSCfile = outPath; 1565 parSCfile += "parSC_2 209a";1580 parSCfile += "parSC_2310a"; 1566 1581 1567 1582 gLog << "parSCfile = " << parSCfile << endl; … … 1570 1585 // file to be updated (either ON or MC) 1571 1586 1572 TString typeInput = "ON";1573 //TString typeInput = "MC";1587 //TString typeInput = "ON"; 1588 TString typeInput = "MC"; 1574 1589 gLog << "typeInput = " << typeInput << endl; 1575 1590 … … 1612 1627 1613 1628 //-------------------------------------------- 1614 // files to contain the matrices (gener tated from filenameTrain and1615 // 1629 // files to contain the matrices (generated from filenameTrain and 1630 // filenameTest) 1616 1631 // 1617 1632 // for the training … … 1642 1657 //-------------------------- 1643 1658 // create matrices and write them onto files 1644 if (!RMatrix && (WOptimize || RTest))1659 if (!RMatrix) 1645 1660 { 1646 1661 MH3 &mh3 = *(new MH3("MHillas.fSize")); … … 1911 1926 //MWriteRootFile write = new MWriteRootFile(outNameImage, "RECREATE"); 1912 1927 1913 /*1928 1914 1929 MWriteRootFile write(outNameImage, "RECREATE"); 1915 1930 … … 1927 1942 write.AddContainer("HadRF", "Events"); 1928 1943 write.AddContainer(hadSCName, "Events"); 1929 */1944 1930 1945 1931 1946 //----------------------------------------------------------------- … … 2001 2016 tliston.AddToList(&fillhadsc); 2002 2017 2003 //tliston.AddToList(&write);2018 tliston.AddToList(&write); 2004 2019 tliston.AddToList(&contfinalgh); 2005 2020 … … 2292 2307 // and definition of final selections 2293 2308 2294 //TString XX("NN"); 2295 TString XX("SC"); 2296 //TString XX("RF"); 2309 //TString XX("SC"); 2310 TString XX("RF"); 2297 2311 TString fhadronnessName("Had"); 2298 2312 fhadronnessName += XX; … … 2300 2314 2301 2315 // maximum values of the hadronness, |ALPHA| and DIST 2302 Float_t maxhadronness = 0. 30;2316 Float_t maxhadronness = 0.233; 2303 2317 Float_t maxalpha = 20.0; 2304 2318 Float_t maxdist = 10.0; … … 2355 2369 contfinalgh.SetName("ContSelFinalgh"); 2356 2370 2357 MFillH fillhadnn("hadNN[MHHadronness]", "HadNN");2358 fillhadnn.SetName("HhadNN");2359 2371 MFillH fillhadsc("hadSC[MHHadronness]", "HadSC"); 2360 2372 fillhadsc.SetName("HhadSC"); … … 2362 2374 fillhadrf.SetName("HhadRF"); 2363 2375 2376 TString mh3name = "abs(Alpha)"; 2377 MBinning binsalphaabs("Binning"+mh3name); 2378 binsalphaabs.SetEdges(50, -2.0, 98.0); 2379 2380 MH3 alphaabs("abs(MHillasSrc.fAlpha)"); 2381 alphaabs.SetName(mh3name); 2382 2383 TH1 &alphahist = alphaabs->GetHist(); 2384 2385 MFillH alpha(&alphaabs); 2386 alpha.SetName("FillAlphaAbs"); 2364 2387 2365 2388 MFillH hfill1("MHHillas", fHilName); … … 2391 2414 pliston.AddToList(&tliston); 2392 2415 InitBinnings(&pliston); 2393 2416 pliston.AddToList(&binsalphaabs); 2417 pliston.AddToList(&alphaabs); 2394 2418 2395 2419 //***************************** … … 2400 2424 tliston.AddToList(&contfinalgh); 2401 2425 2402 tliston.AddToList(&fillhadnn);2403 2426 tliston.AddToList(&fillhadsc); 2404 2427 tliston.AddToList(&fillhadrf); 2405 2428 2429 tliston.AddToList(&alpha); 2406 2430 tliston.AddToList(&hfill1); 2407 2431 tliston.AddToList(&hfill2); … … 2434 2458 // 2435 2459 2436 pliston.FindObject("hadNN", "MHHadronness")->DrawClone();2437 2460 pliston.FindObject("hadRF", "MHHadronness")->DrawClone(); 2438 2461 pliston.FindObject("hadSC", "MHHadronness")->DrawClone(); … … 2446 2469 2447 2470 //------------------------------------------- 2448 // fit alpha distribution to get the number of excess events 2449 // 2450 2451 MHHillasSrc* hillasSrc = 2452 (MHHillasSrc*)(pliston.FindObject("MHHillasSrc")); 2453 TH1F* alphaHist = (TH1F*)(hillasSrc->GetHistAlpha()); 2471 2472 // fit alpha distribution to get the number of excess events and 2473 // calculate significance of gamma signal in the alpha plot 2454 2474 2455 MHOnSubtraction onsub; 2456 onsub.Calc(alphaHist, kTRUE, 13.1); 2475 MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3")); 2476 TH1 &alphaHist = absalpha->GetHist(); 2477 alphaHist.SetXTitle("|alpha| [\\circ]"); 2478 alphaHist.SetName("alpha-JobD"); 2479 2480 Double_t alphasig = 13.1; 2481 Double_t alphamin = 30.0; 2482 Double_t alphamax = 90.0; 2483 Int_t degree = 2; 2484 Double_t significance = -99.0; 2485 Bool_t drawpoly = kTRUE; 2486 Bool_t fitgauss = kTRUE; 2487 Bool_t print = kTRUE; 2488 2489 MHFindSignificance findsig; 2490 findsig.SetRebin(kTRUE); 2491 findsig.SetReduceDegree(kFALSE); 2492 2493 findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 2494 alphasig, drawpoly, fitgauss, print); 2495 significance = findsig.GetSignificance(); 2496 Float_t alphasi = findsig.GetAlphasi(); 2497 2498 gLog << "For file '" << filenameData << "' : " << endl; 2499 gLog << "Significance of gamma signal after supercuts : " 2500 << significance << " (for |alpha| < " << alphasi << " degrees)" 2501 << endl; 2502 2503 findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print); 2504 2457 2505 //------------------------------------------- 2458 2506 … … 2488 2536 2489 2537 gLog << "" << endl; 2490 gLog << "Macro CT1Analysis : JobE_XX, WEX = "2538 gLog << "Macro CT1Analysis : JobE_XX, OEEst, WEX = " 2491 2539 << (JobE_XX ? "kTRUE" : "kFALSE") << ", " 2540 << (OEEst ? "kTRUE" : "kFALSE") << ", " 2492 2541 << (WEX ? "kTRUE" : "kFALSE") << endl; 2493 2542 … … 2507 2556 // and definition of final selections 2508 2557 2509 //TString XX("NN");2510 2558 TString XX("SC"); 2511 2559 //TString XX("RF"); … … 2515 2563 2516 2564 // maximum values of the hadronness, |ALPHA| and DIST 2517 Float_t maxhadronness = 0.4 0;2565 Float_t maxhadronness = 0.4; 2518 2566 Float_t maxalpha = 20.0; 2519 2567 Float_t maxdist = 10.0; … … 2676 2724 TString fImgParName = "MNewImagePar"; 2677 2725 2678 2679 //=========================================================== 2726 2727 if (OEEst) 2728 { 2729 //=========================================================== 2680 2730 // 2681 2731 // Optimization of energy estimator … … 2691 2741 binsE, binsTheta); 2692 2742 gLog << "Macro CT1Analysis.C : returning from CT1EEst" << endl; 2693 2694 2695 2696 2743 } 2744 2745 if (WEX) 2746 { 2697 2747 //----------------------------------------------------------- 2698 2748 // … … 2706 2756 TFile enparam(energyParName); 2707 2757 enparam.ls(); 2708 2709 //MMcEnergyEst mcest("MMcEnergyEst"); 2710 //mcest.Read("MMcEnergyEst"); 2711 MMcEnergyEst &mcest = *((MMcEnergyEst*)gROOT->FindObject("MMcEnergyEst")); 2712 2758 MMcEnergyEst mcest("MMcEnergyEst"); 2759 mcest.Read("MMcEnergyEst"); 2760 2761 //MMcEnergyEst &mcest = *((MMcEnergyEst*)gROOT->FindObject("MMcEnergyEst")); 2713 2762 gLog << "Parameters of energy estimator were read in" << endl; 2763 2764 2765 gLog << "Read in Migration matrix" << endl; 2766 2767 MHMcEnergyMigration mighiston("MHMcEnergyMigration"); 2768 mighiston.Read("MHMcEnergyMigration"); 2769 //MHMcEnergyMigration &mighiston = 2770 // *((MHMcEnergyMigration*)gROOT->FindObject("MHMcEnergyMigration")); 2771 2772 gLog << "Migration matrix was read in" << endl; 2773 2714 2774 2715 2775 TArrayD parA(mcest.GetNumCoeffA()); … … 2720 2780 parB[i] = mcest.GetCoeff( i+parA.GetSize() ); 2721 2781 2722 gLog << "Read in Migration matrix" << endl;2723 2724 //MHMcEnergyMigration mighiston("MHMcEnergyMigration");2725 //mighiston.Read("MHMcEnergyMigration");2726 MHMcEnergyMigration &mighiston =2727 *((MHMcEnergyMigration*)gROOT->FindObject("MHMcEnergyMigration"));2728 2729 gLog << "Migration matrix was read in" << endl;2730 2731 2782 //************************************************************************* 2732 2783 // … … 2758 2809 2759 2810 //MWriteRootFile &write = *(new MWriteRootFile(filenameDataout)); 2811 2760 2812 2761 2813 MWriteRootFile write(filenameDataout, "RECREATE"); … … 2916 2968 2917 2969 Int_t maxevents = -1; 2918 //Int_t maxevents = 10000;2919 2970 if ( !evtloop.Eventloop(maxevents) ) 2920 2971 return; … … 2952 3003 gLog << "before DeleteBinnings" << endl; 2953 3004 2954 //DeleteBinnings(&pliston);3005 DeleteBinnings(&pliston); 2955 3006 2956 3007 gLog << "before Robert's code" << endl; … … 3036 3087 } 3037 3088 3038 gLog << "Macro CT1Analysis : End of Job F_XX" << endl;3089 gLog << "Macro CT1Analysis : End of Job E_XX" << endl; 3039 3090 gLog << "=======================================================" << endl; 3040 3091 }
Note:
See TracChangeset
for help on using the changeset viewer.