Changeset 2575 for trunk/MagicSoft/Mars
- Timestamp:
- 11/28/03 08:52:39 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/macros
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/macros/CT1Analysis.C
r2543 r2575 864 864 } 865 865 866 867 866 868 //--------------------------------------------------------------------- 867 869 // Job B_RF_UP … … 885 887 gLog << "Macro CT1Analysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = " 886 888 << (JobB_RF_UP ? "kTRUE" : "kFALSE") << ", " 887 << (RTrainRF ? "kTRUE" : "kFALSE") << ", "888 << (CTrainRF ? "kTRUE" : "kFALSE") << ", "889 << (RTree ?"kTRUE" : "kFALSE") << ", "890 << (WRF ?"kTRUE" : "kFALSE") << endl;889 << (RTrainRF ? "kTRUE" : "kFALSE") << ", " 890 << (CTrainRF ? "kTRUE" : "kFALSE") << ", " 891 << (RTree ? "kTRUE" : "kFALSE") << ", " 892 << (WRF ? "kTRUE" : "kFALSE") << endl; 891 893 892 894 … … 897 899 Int_t NdSize = 1; 898 900 899 // cut in RF hadronness 901 900 902 TString hadRFName = "HadRF"; 901 903 Float_t maxhadronness = 0.23; … … 909 911 910 912 913 TString extin = "1.root"; 914 TString extout = "2.root"; 915 911 916 //-------------------------------------------- 912 // file to be updated (either ON or MC) 917 // for the analysis using ON data only set typeMatrixHadrons = "ON" 918 // ON and OFF data = "OFF" 919 TString typeMatrixHadrons = "ON"; 920 gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl; 921 922 923 // file to be updated (ON, OFF or MC) 913 924 914 925 //TString typeInput = "ON"; 915 TString typeInput = "MC"; 926 TString typeInput = "OFF"; 927 //TString typeInput = "MC"; 916 928 gLog << "typeInput = " << typeInput << endl; 917 929 918 930 // name of input root file 919 TString filenameData = outPath; 920 filenameData += typeInput; 921 filenameData += "1.root"; 922 gLog << "filenameData = " << filenameData << endl; 931 TString NameData = outPath; 932 NameData += typeInput; 933 TString inNameData(NameData); 934 inNameData += extin; 935 gLog << "inNameData = " << inNameData << endl; 923 936 924 937 // name of output root file 925 TString outNameImage = outPath; 926 outNameImage += typeInput; 927 outNameImage += "2.root"; 928 //TString outNameImage = filenameData; 929 930 gLog << "outNameImage = " << outNameImage << endl; 938 TString outNameData(NameData); 939 outNameData += extout; 940 gLog << "outNameData = " << outNameData << endl; 931 941 932 942 //-------------------------------------------- 933 // files to be read for generating the matrices of training events 943 // files to be read for generating 944 // - the matrices of training events 945 // - and the root files of training and test events 946 947 934 948 // "hadrons" : 935 TString filenameON = outPath; 936 filenameON += "ON"; 937 filenameON += "1.root"; 938 Int_t howManyHadrons = 35000; 939 gLog << "filenameON = " << filenameON << ", howManyHadrons = " 940 << howManyHadrons << endl; 949 TString filenameHad = outPath; 950 filenameHad += typeMatrixHadrons; 951 filenameHad += extin; 952 Int_t howManyHadronsTrain = 12000; 953 Int_t howManyHadronsTest = 12000; 954 gLog << "filenameHad = " << filenameHad << ", howManyHadronsTrain = " 955 << howManyHadronsTrain << ", howManyHadronsTest = " 956 << howManyHadronsTest << endl; 941 957 942 958 … … 944 960 TString filenameMC = outPath; 945 961 filenameMC += "MC"; 946 filenameMC += "1.root"; 947 Int_t howManyGammas = 35000; 948 gLog << "filenameMC = " << filenameMC << ", howManyGammas = " 949 << howManyGammas << endl; 962 filenameMC += extin; 963 Int_t howManyGammasTrain = 12000; 964 Int_t howManyGammasTest = 12000; 965 gLog << "filenameMC = " << filenameMC << ", howManyGammasTrain = " 966 << howManyGammasTrain << ", howManyGammasTest = " 967 << howManyGammasTest << endl; 950 968 951 969 //-------------------------------------------- 952 // files of training events 953 954 TString outNameGammas = outPath; 955 outNameGammas += "RFmatrix_gammas_"; 956 outNameGammas += "MC"; 957 outNameGammas += ".root"; 958 959 TString typeMatrixHadrons = "ON"; 960 gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl; 961 962 TString outNameHadrons = outPath; 963 outNameHadrons += "RFmatrix_hadrons_"; 964 outNameHadrons += typeMatrixHadrons; 965 outNameHadrons += ".root"; 970 // files for the matrices of training events 971 972 TString NameGammas = outPath; 973 NameGammas += "RFmatrix_gammas_Train_"; 974 NameGammas += "MC"; 975 NameGammas += extin; 976 977 TString NameHadrons = outPath; 978 NameHadrons += "RFmatrix_hadrons_Train_"; 979 NameHadrons += typeMatrixHadrons; 980 NameHadrons += extin; 981 982 983 //-------------------------------------------- 984 // root files for the training events 985 986 TString NameGammasTrain = outPath; 987 NameGammasTrain += "RF_gammas_Train_"; 988 NameGammasTrain += "MC"; 989 TString inNameGammasTrain(NameGammasTrain); 990 inNameGammasTrain += extin; 991 TString outNameGammasTrain(NameGammasTrain); 992 outNameGammasTrain += extout; 993 994 995 TString NameHadronsTrain = outPath; 996 NameHadronsTrain += "RF_hadrons_Train_"; 997 NameHadronsTrain += typeMatrixHadrons; 998 TString inNameHadronsTrain(NameHadronsTrain); 999 inNameHadronsTrain += extin; 1000 TString outNameHadronsTrain(NameHadronsTrain); 1001 outNameHadronsTrain += extout; 1002 1003 1004 //-------------------------------------------- 1005 // root files for the test events 1006 1007 TString NameGammasTest = outPath; 1008 NameGammasTest += "RF_gammas_Test_"; 1009 NameGammasTest += "MC"; 1010 TString inNameGammasTest(NameGammasTest); 1011 inNameGammasTest += extin; 1012 TString outNameGammasTest(NameGammasTest); 1013 outNameGammasTest += extout; 1014 1015 TString NameHadronsTest = outPath; 1016 NameHadronsTest += "RF_hadrons_Test_"; 1017 NameHadronsTest += typeMatrixHadrons; 1018 TString inNameHadronsTest(NameHadronsTest); 1019 inNameHadronsTest += extin; 1020 TString outNameHadronsTest(NameHadronsTest); 1021 outNameHadronsTest += extout; 1022 1023 //-------------------------------------------------------------------- 966 1024 967 1025 … … 1002 1060 gLog << "Get matrix for (gammas)" << endl; 1003 1061 gLog << "matrix name = " << mtxName << endl; 1004 gLog << "name of root file = " << outNameGammas << endl;1062 gLog << "name of root file = " << NameGammas << endl; 1005 1063 gLog << "" << endl; 1006 1064 1007 1065 1008 // read in the object with the name 'mtxName' from file ' outNameGammas'1009 // 1010 TFile fileg( outNameGammas);1066 // read in the object with the name 'mtxName' from file 'NameGammas' 1067 // 1068 TFile fileg(NameGammas); 1011 1069 1012 1070 matrixg.Read(mtxName); … … 1022 1080 gLog << " Get matrix for (hadrons)" << endl; 1023 1081 gLog << "matrix name = " << mtxName << endl; 1024 gLog << "name of root file = " << outNameHadrons << endl;1082 gLog << "name of root file = " << NameHadrons << endl; 1025 1083 gLog << "" << endl; 1026 1084 1027 1085 1028 // read in the object with the name 'mtxName' from file ' outNameHadrons'1029 // 1030 TFile fileh( outNameHadrons);1086 // read in the object with the name 'mtxName' from file 'NameHadrons' 1087 // 1088 TFile fileh(NameHadrons); 1031 1089 1032 1090 matrixh.Read(mtxName); … … 1037 1095 //************************************************************************* 1038 1096 // create matrices of training events 1097 // and root files of training and test events 1098 1039 1099 if (CTrainRF) 1040 1100 { 1041 1101 gLog << "" << endl; 1042 1102 gLog << "========================================================" << endl; 1043 gLog << " Create matrices of training events" << endl; 1103 gLog << " Create matrices of training events and root files of training and test events" 1104 << endl; 1044 1105 gLog << " Gammas :" << endl; 1045 1106 gLog << "---------" << endl; 1046 1107 1047 1108 MParList plistg; 1048 1109 MTaskList tlistg; 1049 MFilterList flistg;1050 1051 MParList plisth;1052 MTaskList tlisth;1053 MFilterList flisth;1054 1110 1055 1111 MReadMarsFile readg("Events", filenameMC); 1056 1112 readg.DisableAutoScheme(); 1057 1058 MReadMarsFile readh("Events", filenameON);1059 readh.DisableAutoScheme();1060 1061 MFParticleId fgamma("MMcEvt", '=', kGAMMA);1062 fgamma.SetName("gammaID");1063 1064 MFParticleId fhadrons("MMcEvt", '!', kGAMMA);1065 fhadrons.SetName("hadronID)");1066 1113 1067 1114 TString mgname("costhg"); … … 1075 1122 gref.GetHist().SetBinContent(i, 1.0); 1076 1123 1077 1078 1124 MFEventSelector2 selectorg(gref); 1079 selectorg.SetNumMax(howManyGammas); 1080 selectorg.SetName("selectGammas"); 1081 1125 selectorg.SetNumMax(howManyGammasTrain+howManyGammasTest); 1126 selectorg.SetName("selectGammasTrainTest"); 1127 selectorg.SetInverted(); 1128 selectorg.SetUseOrigDistribution(kTRUE); 1129 1130 MContinue contg(&selectorg); 1131 contg.SetName("ContGammas"); 1132 1133 Double_t probg = ( (Double_t) howManyGammasTrain ) 1134 / ( (Double_t)(howManyGammasTrain+howManyGammasTest) ); 1135 MFRandomSplit splitg(probg); 1082 1136 1083 1137 MFillH fillmatg("MatrixGammas"); 1084 fillmatg.SetFilter(& flistg);1138 fillmatg.SetFilter(&splitg); 1085 1139 fillmatg.SetName("fillGammas"); 1086 1140 1087 1088 1141 //----------------------- 1142 // for writing the root files of training and test events 1143 // for gammas 1144 1145 MWriteRootFile writetraing(inNameGammasTrain, "RECREATE"); 1146 writetraing.SetName("WriteGammasTrain"); 1147 writetraing.SetFilter(&splitg); 1148 1149 writetraing.AddContainer("MRawRunHeader", "RunHeaders"); 1150 writetraing.AddContainer("MTime", "Events"); 1151 writetraing.AddContainer("MMcEvt", "Events"); 1152 writetraing.AddContainer("ThetaOrig", "Events"); 1153 writetraing.AddContainer("MSrcPosCam", "Events"); 1154 writetraing.AddContainer("MSigmabar", "Events"); 1155 writetraing.AddContainer("MHillas", "Events"); 1156 writetraing.AddContainer("MHillasExt", "Events"); 1157 writetraing.AddContainer("MHillasSrc", "Events"); 1158 writetraing.AddContainer("MNewImagePar", "Events"); 1159 1160 MContinue contgtrain(&splitg); 1161 contgtrain.SetName("ContGammaTrain"); 1162 1163 MWriteRootFile writetestg(inNameGammasTest, "RECREATE"); 1164 writetestg.SetName("WriteGammasTest"); 1165 1166 writetestg.AddContainer("MRawRunHeader", "RunHeaders"); 1167 writetestg.AddContainer("MTime", "Events"); 1168 writetestg.AddContainer("MMcEvt", "Events"); 1169 writetestg.AddContainer("ThetaOrig", "Events"); 1170 writetestg.AddContainer("MSrcPosCam", "Events"); 1171 writetestg.AddContainer("MSigmabar", "Events"); 1172 writetestg.AddContainer("MHillas", "Events"); 1173 writetestg.AddContainer("MHillasExt", "Events"); 1174 writetestg.AddContainer("MHillasSrc", "Events"); 1175 writetestg.AddContainer("MNewImagePar", "Events"); 1176 1177 //----------------------- 1178 1089 1179 //***************************** fill gammas *** 1090 // entries in MFilterList1091 1092 flistg.AddToList(&fgamma);1093 flistg.AddToList(&selectorg);1094 1095 //*****************************1096 1180 // entries in MParList 1097 1181 … … 1105 1189 1106 1190 tlistg.AddToList(&readg); 1107 tlistg.AddToList(&flistg); 1191 tlistg.AddToList(&contg); 1192 1193 tlistg.AddToList(&splitg); 1108 1194 tlistg.AddToList(&fillmatg); 1195 tlistg.AddToList(&writetraing); 1196 tlistg.AddToList(&contgtrain); 1197 1198 tlistg.AddToList(&writetestg); 1109 1199 1110 1200 //***************************** … … 1112 1202 MProgressBar matrixbar; 1113 1203 MEvtLoop evtloopg; 1204 evtloopg.SetName("FillGammaMatrix"); 1114 1205 evtloopg.SetParList(&plistg); 1115 1206 //evtloopg.ReadEnv(env, "", printEnv); … … 1122 1213 tlistg.PrintStatistics(0, kTRUE); 1123 1214 1124 1215 matrixg.Print("SizeCols"); 1216 Int_t generatedgTrain = matrixg.GetM().GetNrows(); 1217 if ( fabs(generatedgTrain-howManyGammasTrain) > 1218 3.0*sqrt(howManyGammasTrain) ) 1219 { 1220 gLog << "ONOFFCT1Analysis.C : no.of generated gamma training events (" 1221 << generatedgTrain << ") is incompatible with the no.of requested events (" 1222 << howManyGammasTrain << ")" << endl; 1223 } 1224 1225 1226 Int_t generatedgTest = writetestg.GetNumExecutions(); 1227 if ( fabs(generatedgTest-howManyGammasTest) > 1228 3.0*sqrt(howManyGammasTest) ) 1229 { 1230 gLog << "ONOFFCT1Analysis.C : no.of generated gamma test events (" 1231 << generatedgTest << ") is incompatible with the no.of requested events (" 1232 << howManyGammasTest << ")" << endl; 1233 } 1234 1125 1235 //***************************** fill hadrons *** 1126 1236 gLog << "---------------------------------------------------------------" 1237 << endl; 1127 1238 gLog << " Hadrons :" << endl; 1239 gLog << "----------" << endl; 1240 1241 MParList plisth; 1242 MTaskList tlisth; 1243 1244 MReadMarsFile readh("Events", filenameHad); 1245 readh.DisableAutoScheme(); 1128 1246 1129 1247 TString mhname("costhh"); … … 1131 1249 binh.SetEdges(10, 0., 1.0); 1132 1250 1133 MH3 href("cos(MMcEvt.fTelescopeTheta)"); 1134 href.SetName(mhname); 1135 MH::SetBinning(&href.GetHist(), &binh); 1136 for (Int_t i=1; i<=href.GetNbins(); i++) 1137 href.GetHist().SetBinContent(i, 1.0); 1251 //MH3 href("cos(MMcEvt.fTelescopeTheta)"); 1252 //href.SetName(mhname); 1253 //MH::SetBinning(&href.GetHist(), &binh); 1254 //for (Int_t i=1; i<=href.GetNbins(); i++) 1255 // href.GetHist().SetBinContent(i, 1.0); 1256 1257 //use the original distribution from the gammas 1258 MH3 &href = *(selectorg.GetHistOrig()); 1138 1259 1139 1260 MFEventSelector2 selectorh(href); 1140 //selectorh.SetNumMax(howManyHadrons); 1141 // select as many hadrons as gammas 1142 selectorh.SetNumMax(matrixg.GetM().GetNrows()); 1143 selectorh.SetName("selectHadrons"); 1261 selectorh.SetNumMax(howManyHadronsTrain+howManyHadronsTest); 1262 selectorh.SetName("selectHadronsTrainTest"); 1263 selectorh.SetInverted(); 1264 1265 MContinue conth(&selectorh); 1266 conth.SetName("ContHadrons"); 1267 1268 Double_t probh = ( (Double_t) howManyHadronsTrain ) 1269 / ( (Double_t)(howManyHadronsTrain+howManyHadronsTest) ); 1270 MFRandomSplit splith(probh); 1144 1271 1145 1272 MFillH fillmath("MatrixHadrons"); 1146 fillmath.SetFilter(& flisth);1273 fillmath.SetFilter(&splith); 1147 1274 fillmath.SetName("fillHadrons"); 1148 1275 1149 1150 // entries in MFilterList 1151 1152 flisth.AddToList(&fhadrons); 1153 flisth.AddToList(&selectorh); 1276 //----------------------- 1277 // for writing the root files of training and test events 1278 // for hadrons 1279 1280 MWriteRootFile writetrainh(inNameHadronsTrain, "RECREATE"); 1281 writetrainh.SetName("WriteHadronsTrain"); 1282 writetrainh.SetFilter(&splith); 1283 1284 writetrainh.AddContainer("MRawRunHeader", "RunHeaders"); 1285 writetrainh.AddContainer("MTime", "Events"); 1286 writetrainh.AddContainer("MMcEvt", "Events"); 1287 writetrainh.AddContainer("ThetaOrig", "Events"); 1288 writetrainh.AddContainer("MSrcPosCam", "Events"); 1289 writetrainh.AddContainer("MSigmabar", "Events"); 1290 writetrainh.AddContainer("MHillas", "Events"); 1291 writetrainh.AddContainer("MHillasExt", "Events"); 1292 writetrainh.AddContainer("MHillasSrc", "Events"); 1293 writetrainh.AddContainer("MNewImagePar", "Events"); 1294 1295 MContinue conthtrain(&splith); 1296 1297 MWriteRootFile writetesth(inNameHadronsTest, "RECREATE"); 1298 writetesth.SetName("WriteHadronsTest"); 1299 1300 writetesth.AddContainer("MRawRunHeader", "RunHeaders"); 1301 writetesth.AddContainer("MTime", "Events"); 1302 writetesth.AddContainer("MMcEvt", "Events"); 1303 writetesth.AddContainer("ThetaOrig", "Events"); 1304 writetesth.AddContainer("MSrcPosCam", "Events"); 1305 writetesth.AddContainer("MSigmabar", "Events"); 1306 writetesth.AddContainer("MHillas", "Events"); 1307 writetesth.AddContainer("MHillasExt", "Events"); 1308 writetesth.AddContainer("MHillasSrc", "Events"); 1309 writetesth.AddContainer("MNewImagePar", "Events"); 1310 1154 1311 1155 1312 //***************************** … … 1165 1322 1166 1323 tlisth.AddToList(&readh); 1167 tlisth.AddToList(&flisth); 1324 tlisth.AddToList(&conth); 1325 1326 tlisth.AddToList(&splith); 1168 1327 tlisth.AddToList(&fillmath); 1328 tlisth.AddToList(&writetrainh); 1329 tlisth.AddToList(&conthtrain); 1330 1331 tlisth.AddToList(&writetesth); 1169 1332 1170 1333 //***************************** … … 1172 1335 MProgressBar matrixbar; 1173 1336 MEvtLoop evtlooph; 1337 evtlooph.SetName("FillHadronMatrix"); 1174 1338 evtlooph.SetParList(&plisth); 1175 1339 //evtlooph.ReadEnv(env, "", printEnv); … … 1182 1346 tlisth.PrintStatistics(0, kTRUE); 1183 1347 1348 matrixh.Print("SizeCols"); 1349 Int_t generatedhTrain = matrixh.GetM().GetNrows(); 1350 if ( fabs(generatedhTrain-howManyHadronsTrain) > 1351 3.0*sqrt(howManyHadronsTrain) ) 1352 { 1353 gLog << "ONOFFCT1Analysis.C : no.of generated hadron training events (" 1354 << generatedhTrain << ") is incompatible with the no.of requested events (" 1355 << howManyHadronsTrain << ")" << endl; 1356 } 1357 1358 1359 Int_t generatedhTest = writetesth.GetNumExecutions(); 1360 if ( fabs(generatedhTest-howManyHadronsTest) > 1361 3.0*sqrt(howManyHadronsTest) ) 1362 { 1363 gLog << "ONOFFCT1Analysis.C : no.of generated gamma test events (" 1364 << generatedhTest << ") is incompatible with the no.of requested events (" 1365 << howManyHadronsTest << ")" << endl; 1366 } 1184 1367 1185 1368 … … 1187 1370 1188 1371 1189 // write out matrices of training events 1372 // write out matrices of training events 1190 1373 1191 1374 gLog << "" << endl; … … 1199 1382 matrixg.Print("SizeCols"); 1200 1383 1201 TFile writeg( outNameGammas, "RECREATE", "");1384 TFile writeg(NameGammas, "RECREATE", ""); 1202 1385 matrixg.Write(); 1203 1386 1204 1387 gLog << "" << endl; 1205 1388 gLog << "Macro CT1Analysis : matrix of training events for gammas written onto file " 1206 << outNameGammas << endl;1389 << NameGammas << endl; 1207 1390 1208 1391 //------------------------------------------- … … 1211 1394 matrixh.Print("SizeCols"); 1212 1395 1213 TFile writeh( outNameHadrons, "RECREATE", "");1396 TFile writeh(NameHadrons, "RECREATE", ""); 1214 1397 matrixh.Write(); 1215 1398 1216 1399 gLog << "" << endl; 1217 1400 gLog << "Macro CT1Analysis : matrix of training events for hadrons written onto file " 1218 << outNameHadrons << endl;1401 << NameHadrons << endl; 1219 1402 1220 1403 } … … 1254 1437 tlisttr.PrintStatistics(0, kTRUE); 1255 1438 1439 gLog << "ONOFFCT1Analysis : RF trees were read in from file " 1440 << outRF << endl; 1256 1441 1257 1442 // get adresses of objects which are used in the next eventloop … … 1259 1444 if (!fRanForest) 1260 1445 { 1261 *fLog << err << dbginf << "MRanForest not found... aborting." << endl;1446 gLog << err << dbginf << "MRanForest not found... aborting." << endl; 1262 1447 return kFALSE; 1263 1448 } … … 1266 1451 if (!fRanTree) 1267 1452 { 1268 *fLog << err << dbginf << "MRanTree not found... aborting." << endl;1453 gLog << err << dbginf << "MRanTree not found... aborting." << endl; 1269 1454 return kFALSE; 1270 1455 } … … 1309 1494 // 1310 1495 MEvtLoop treeloop; 1311 treeloop.SetName("GrowRFTrees"); 1496 treeloop.SetName("GrowRFTrees"); 1312 1497 treeloop.SetParList(&plist2); 1313 1498 … … 1324 1509 if (!fRanForest) 1325 1510 { 1326 *fLog << err << dbginf << "MRanForest not found... aborting." << endl;1511 gLog << err << dbginf << "MRanForest not found... aborting." << endl; 1327 1512 return kFALSE; 1328 1513 } … … 1331 1516 if (!fRanTree) 1332 1517 { 1333 *fLog << err << dbginf << "MRanTree not found... aborting." << endl;1518 gLog << err << dbginf << "MRanTree not found... aborting." << endl; 1334 1519 return kFALSE; 1335 1520 } … … 1340 1525 1341 1526 1342 1343 1527 //----------------------------------------------------------------- 1344 // Update the input files with the RF hadronness 1345 // 1528 // Update the root files with the RF hadronness 1529 // 1530 1346 1531 if (WRF) 1347 1532 { 1533 //TString fileName(inNameHadronsTrain); 1534 //TString outName(outNameHadronsTrain); 1535 1536 //TString fileName(inNameHadronsTest); 1537 //TString outName(outNameHadronsTest); 1538 1539 //TString fileName(inNameGammasTrain); 1540 //TString outName(outNameGammasTrain); 1541 1542 //TString fileName(inNameGammasTest); 1543 //TString outName(outNameGammasTest); 1544 1545 TString fileName(inNameData); 1546 TString outName(outNameData); 1547 1548 1549 1348 1550 gLog << "" << endl; 1349 1551 gLog << "========================================================" << endl; 1350 gLog << "Update input file '" << filenameData 1351 << "' with the RF hadronness" << endl; 1352 1552 gLog << "Update root file '" << fileName 1553 << "' with the RF hadronness; ==> " << outName << endl; 1554 1555 1353 1556 MTaskList tliston; 1354 1557 MParList pliston; … … 1363 1566 // 1364 1567 1365 MReadMarsFile read("Events", file nameData);1568 MReadMarsFile read("Events", fileName); 1366 1569 read.DisableAutoScheme(); 1367 1570 … … 1374 1577 rfcalc.SetHadronnessName(hadRFName); 1375 1578 1579 1376 1580 //....................................................................... 1377 1581 1378 //MWriteRootFile write(outName Image, "UPDATE");1379 MWriteRootFile write(outName Image, "RECREATE");1582 //MWriteRootFile write(outName, "UPDATE"); 1583 MWriteRootFile write(outName, "RECREATE"); 1380 1584 1381 1585 write.AddContainer("MRawRunHeader", "RunHeaders"); … … 1392 1596 write.AddContainer(hadRFName, "Events"); 1393 1597 1394 1395 1598 //----------------------------------------------------------------- 1396 1599 … … 1425 1628 alpha.SetName("FillAlphaAbs"); 1426 1629 1630 1427 1631 MFillH hfill1("MHHillas", fHilName); 1428 1632 hfill1.SetName("HHillas"); … … 1451 1655 pliston.AddToList(&binsalphaabs); 1452 1656 pliston.AddToList(&alphaabs); 1657 1453 1658 1454 1659 //***************************** … … 1480 1685 MProgressBar bar; 1481 1686 MEvtLoop evtloop; 1687 evtloop.SetName("UpdateRootFile"); 1482 1688 evtloop.SetParList(&pliston); 1483 1689 evtloop.SetProgressBar(&bar); … … 1495 1701 pliston.FindObject("MHRanForest")->DrawClone(); 1496 1702 pliston.FindObject("hadRF", "MHHadronness")->DrawClone(); 1703 pliston.FindObject("hadRF", "MHHadronness")->Print(); 1497 1704 1498 1705 pliston.FindObject("MHHillas")->DrawClone(); … … 1501 1708 pliston.FindObject("MHNewImagePar")->DrawClone(); 1502 1709 pliston.FindObject("MHStarMap")->DrawClone(); 1710 1503 1711 1504 1712 //------------------------------------------- … … 1529 1737 Float_t alphasi = findsig.GetAlphasi(); 1530 1738 1531 gLog << "For file '" << file nameData<< "' : " << endl;1739 gLog << "For file '" << fileName << "' : " << endl; 1532 1740 gLog << "Significance of gamma signal after supercuts : " 1533 1741 << significance << " (for |alpha| < " << alphasi << " degrees)" … … 1546 1754 } 1547 1755 //--------------------------------------------------------------------- 1548 1549 1550 1756 1551 1757 … … 1600 1806 1601 1807 //TString typeInput = "ON"; 1808 //TString typeInput = "OFF"; 1602 1809 TString typeInput = "MC"; 1603 1810 gLog << "typeInput = " << typeInput << endl; … … 1667 1874 findsuper.SetFilenameParam(parSCfile); 1668 1875 findsuper.SetHadronnessName("HadSC"); 1669 1876 findsuper.SetUseOrigDistribution(kTRUE); 1670 1877 1671 1878 //-------------------------- … … 1673 1880 if (CMatrix) 1674 1881 { 1675 MH3 &mh3 = *(new MH3("MHillas.fSize")); 1676 mh3.SetName("Target distribution for SIZE"); 1882 TString mname("costheta"); 1883 MBinning bin("Binning"+mname); 1884 bin.SetEdges(10, 0., 1.0); 1885 1886 MH3 mh3("cos(MMcEvt.fTelescopeTheta)"); 1887 mh3.SetName(mname); 1888 MH::SetBinning(&mh3.GetHist(), &bin); 1889 for (Int_t i=1; i<=mh3.GetNbins(); i++) 1890 mh3.GetHist().SetBinContent(i, 1.0); 1891 1677 1892 1678 1893 if (filenameTrain == filenameTest) 1679 1894 { 1680 if ( !findsuper.DefineTrainTestMatrix(filenameTrain, 1681 howManyTrain, mh3, howManyTest, mh3, 1895 if ( !findsuper.DefineTrainTestMatrix( 1896 filenameTrain, mh3, 1897 howManyTrain, howManyTest, 1682 1898 fileMatrixTrain, fileMatrixTest) ) 1683 1899 { … … 1689 1905 else 1690 1906 { 1691 if ( !findsuper.DefineTrainMatrix(filenameTrain, 1692 howManyTrain, mh3,fileMatrixTrain) )1907 if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3, 1908 howManyTrain, fileMatrixTrain) ) 1693 1909 { 1694 1910 *fLog << "CT1Analysis.C : DefineTrainMatrix failed" << endl; … … 1696 1912 } 1697 1913 1698 if ( !findsuper.DefineTestMatrix( filenameTest, 1699 howManyTest, mh3,fileMatrixTest) )1914 if ( !findsuper.DefineTestMatrix( filenameTest, mh3, 1915 howManyTest, fileMatrixTest) ) 1700 1916 { 1701 1917 *fLog << "CT1Analysis.C : DefineTestMatrix failed" << endl; … … 2116 2332 2117 2333 2334 2118 2335 //--------------------------------------------------------------------- 2119 2336 // Job C -
trunk/MagicSoft/Mars/macros/ONOFFCT1Analysis.C
r2543 r2575 215 215 // or MC2.root) 216 216 217 Bool_t JobB_RF_UP = k TRUE;218 Bool_t CTrainRF = k TRUE; // create matrices of training events217 Bool_t JobB_RF_UP = kFALSE; 218 Bool_t CTrainRF = kFALSE; // create matrices of training events 219 219 // and root files of training and test events 220 220 Bool_t RTrainRF = kFALSE; // read in matrices of training events … … 228 228 // - update the input files with the hadroness (==>ON3.root or MC3.root) 229 229 230 Bool_t JobB_SC_UP = k FALSE;231 Bool_t CMatrix = k FALSE; // create training and test matrices230 Bool_t JobB_SC_UP = kTRUE; 231 Bool_t CMatrix = kTRUE; // create training and test matrices 232 232 Bool_t RMatrix = kFALSE; // read training and test matrices from file 233 233 Bool_t WOptimize = kFALSE; // do optimization using the training sample … … 782 782 783 783 784 TString extin = "1.root"; 785 TString extout = "2.root"; 786 784 787 //-------------------------------------------- 788 // for the analysis using ON data only set typeMatrixHadrons = "ON" 789 // ON and OFF data = "OFF" 790 TString typeMatrixHadrons = "OFF"; 791 gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl; 792 793 785 794 // file to be updated (ON, OFF or MC) 786 795 787 796 //TString typeInput = "ON"; 788 //TString typeInput = "OFF";789 TString typeInput = "MC";797 TString typeInput = "OFF"; 798 //TString typeInput = "MC"; 790 799 gLog << "typeInput = " << typeInput << endl; 791 800 792 801 // name of input root file 793 TString filenameData = outPath; 794 filenameData += typeInput; 795 filenameData += "1.root"; 796 gLog << "filenameData = " << filenameData << endl; 802 TString NameData = outPath; 803 NameData += typeInput; 804 TString inNameData(NameData); 805 inNameData += extin; 806 gLog << "inNameData = " << inNameData << endl; 797 807 798 808 // name of output root file 799 TString outNameImage = outPath; 800 outNameImage += typeInput; 801 outNameImage += "2.root"; 802 //TString outNameImage = filenameData; 803 804 gLog << "outNameImage = " << outNameImage << endl; 809 TString outNameData(NameData); 810 outNameData += extout; 811 gLog << "outNameData = " << outNameData << endl; 805 812 806 813 //-------------------------------------------- … … 809 816 // - and the root files of training and test events 810 817 811 TString typeMatrixHadrons = "OFF";812 gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl;813 818 814 819 // "hadrons" : 815 820 TString filenameHad = outPath; 816 821 filenameHad += typeMatrixHadrons; 817 filenameHad += "1.root";818 Int_t howManyHadronsTrain = 8000;819 Int_t howManyHadronsTest = 8000;822 filenameHad += extin; 823 Int_t howManyHadronsTrain = 12000; 824 Int_t howManyHadronsTest = 12000; 820 825 gLog << "filenameHad = " << filenameHad << ", howManyHadronsTrain = " 821 826 << howManyHadronsTrain << ", howManyHadronsTest = " … … 826 831 TString filenameMC = outPath; 827 832 filenameMC += "MC"; 828 filenameMC += "1.root";829 Int_t howManyGammasTrain = 8000;830 Int_t howManyGammasTest = 8000;833 filenameMC += extin; 834 Int_t howManyGammasTrain = 12000; 835 Int_t howManyGammasTest = 12000; 831 836 gLog << "filenameMC = " << filenameMC << ", howManyGammasTrain = " 832 837 << howManyGammasTrain << ", howManyGammasTest = " … … 836 841 // files for the matrices of training events 837 842 838 TString outNameGammas = outPath;839 outNameGammas += "RFmatrix_gammas_Train_";840 outNameGammas += "MC";841 outNameGammas += ".root";842 843 TString outNameHadrons = outPath;844 outNameHadrons += "RFmatrix_hadrons_Train_";845 outNameHadrons += typeMatrixHadrons;846 outNameHadrons += ".root";843 TString NameGammas = outPath; 844 NameGammas += "RFmatrix_gammas_Train_"; 845 NameGammas += "MC"; 846 NameGammas += extin; 847 848 TString NameHadrons = outPath; 849 NameHadrons += "RFmatrix_hadrons_Train_"; 850 NameHadrons += typeMatrixHadrons; 851 NameHadrons += extin; 847 852 848 853 … … 850 855 // root files for the training events 851 856 852 TString outNameGammasTrain = outPath; 853 outNameGammasTrain += "RF_gammas_Train_"; 854 outNameGammasTrain += "MC"; 855 outNameGammasTrain += ".root"; 856 857 TString outNameHadronsTrain = outPath; 858 outNameHadronsTrain += "RF_hadrons_Train_"; 859 outNameHadronsTrain += typeMatrixHadrons; 860 outNameHadronsTrain += ".root"; 857 TString NameGammasTrain = outPath; 858 NameGammasTrain += "RF_gammas_Train_"; 859 NameGammasTrain += "MC"; 860 TString inNameGammasTrain(NameGammasTrain); 861 inNameGammasTrain += extin; 862 TString outNameGammasTrain(NameGammasTrain); 863 outNameGammasTrain += extout; 864 865 866 TString NameHadronsTrain = outPath; 867 NameHadronsTrain += "RF_hadrons_Train_"; 868 NameHadronsTrain += typeMatrixHadrons; 869 TString inNameHadronsTrain(NameHadronsTrain); 870 inNameHadronsTrain += extin; 871 TString outNameHadronsTrain(NameHadronsTrain); 872 outNameHadronsTrain += extout; 861 873 862 874 … … 864 876 // root files for the test events 865 877 866 TString outNameGammasTest = outPath; 867 outNameGammasTest += "RF_gammas_Test_"; 868 outNameGammasTest += "MC"; 869 outNameGammasTest += ".root"; 870 871 TString outNameHadronsTest = outPath; 872 outNameHadronsTest += "RF_hadrons_Test_"; 873 outNameHadronsTest += typeMatrixHadrons; 874 outNameHadronsTest += ".root"; 878 TString NameGammasTest = outPath; 879 NameGammasTest += "RF_gammas_Test_"; 880 NameGammasTest += "MC"; 881 TString inNameGammasTest(NameGammasTest); 882 inNameGammasTest += extin; 883 TString outNameGammasTest(NameGammasTest); 884 outNameGammasTest += extout; 885 886 TString NameHadronsTest = outPath; 887 NameHadronsTest += "RF_hadrons_Test_"; 888 NameHadronsTest += typeMatrixHadrons; 889 TString inNameHadronsTest(NameHadronsTest); 890 inNameHadronsTest += extin; 891 TString outNameHadronsTest(NameHadronsTest); 892 outNameHadronsTest += extout; 875 893 876 894 //-------------------------------------------------------------------- … … 913 931 gLog << "Get matrix for (gammas)" << endl; 914 932 gLog << "matrix name = " << mtxName << endl; 915 gLog << "name of root file = " << outNameGammas << endl;933 gLog << "name of root file = " << NameGammas << endl; 916 934 gLog << "" << endl; 917 935 918 936 919 // read in the object with the name 'mtxName' from file ' outNameGammas'920 // 921 TFile fileg( outNameGammas);937 // read in the object with the name 'mtxName' from file 'NameGammas' 938 // 939 TFile fileg(NameGammas); 922 940 923 941 matrixg.Read(mtxName); … … 933 951 gLog << " Get matrix for (hadrons)" << endl; 934 952 gLog << "matrix name = " << mtxName << endl; 935 gLog << "name of root file = " << outNameHadrons << endl;953 gLog << "name of root file = " << NameHadrons << endl; 936 954 gLog << "" << endl; 937 955 938 956 939 // read in the object with the name 'mtxName' from file ' outNameHadrons'940 // 941 TFile fileh( outNameHadrons);957 // read in the object with the name 'mtxName' from file 'NameHadrons' 958 // 959 TFile fileh(NameHadrons); 942 960 943 961 matrixh.Read(mtxName); … … 962 980 MTaskList tlistg; 963 981 964 MFilterList flistgtrain;965 flistgtrain.SetName("GammaFilterTrain");966 MFilterList flistgtest;967 flistgtest.SetName("GammaFilterTest");968 969 982 MReadMarsFile readg("Events", filenameMC); 970 983 readg.DisableAutoScheme(); 971 972 973 MFParticleId fgamma("MMcEvt", '=', kGAMMA);974 fgamma.SetName("gammaID");975 984 976 985 TString mgname("costhg"); … … 987 996 selectorg.SetNumMax(howManyGammasTrain+howManyGammasTest); 988 997 selectorg.SetName("selectGammasTrainTest"); 989 990 TString strgtrain = "gRandom->Rndm()*("; 991 strgtrain += howManyGammasTrain; 992 strgtrain += "+"; 993 strgtrain += howManyGammasTest; 994 strgtrain += ")<"; 995 strgtrain += howManyGammasTrain; 996 MF selsplitg(strgtrain); 998 selectorg.SetInverted(); 999 selectorg.SetUseOrigDistribution(kTRUE); 1000 1001 MContinue contg(&selectorg); 1002 contg.SetName("ContGammas"); 1003 1004 Double_t probg = ( (Double_t) howManyGammasTrain ) 1005 / ( (Double_t)(howManyGammasTrain+howManyGammasTest) ); 1006 MFRandomSplit splitg(probg); 997 1007 998 1008 MFillH fillmatg("MatrixGammas"); 999 fillmatg.SetFilter(& flistgtrain);1009 fillmatg.SetFilter(&splitg); 1000 1010 fillmatg.SetName("fillGammas"); 1001 1011 … … 1004 1014 // for gammas 1005 1015 1006 MWriteRootFile writetraing( outNameGammasTrain, "RECREATE");1016 MWriteRootFile writetraing(inNameGammasTrain, "RECREATE"); 1007 1017 writetraing.SetName("WriteGammasTrain"); 1008 writetraing.SetFilter(& flistgtrain);1018 writetraing.SetFilter(&splitg); 1009 1019 1010 1020 writetraing.AddContainer("MRawRunHeader", "RunHeaders"); … … 1019 1029 writetraing.AddContainer("MNewImagePar", "Events"); 1020 1030 1021 MContinue contg(&flistgtrain); 1022 1023 MWriteRootFile writetestg(outNameGammasTest, "RECREATE"); 1031 MContinue contgtrain(&splitg); 1032 contgtrain.SetName("ContGammaTrain"); 1033 1034 MWriteRootFile writetestg(inNameGammasTest, "RECREATE"); 1024 1035 writetestg.SetName("WriteGammasTest"); 1025 writetestg.SetFilter(&flistgtest);1026 1036 1027 1037 writetestg.AddContainer("MRawRunHeader", "RunHeaders"); … … 1039 1049 1040 1050 //***************************** fill gammas *** 1041 // entries in MFilterList1042 1043 flistgtrain.AddToList(&fgamma);1044 flistgtrain.AddToList(&selectorg);1045 flistgtrain.AddToList(&selsplitg);1046 1047 flistgtest.AddToList(&fgamma);1048 flistgtest.AddToList(&selectorg);1049 flistgtest.AddToList(&selsplitg);1050 1051 //*****************************1052 1051 // entries in MParList 1053 1052 … … 1061 1060 1062 1061 tlistg.AddToList(&readg); 1063 1064 tlistg.AddToList(&flistgtrain); 1062 tlistg.AddToList(&contg); 1063 1064 tlistg.AddToList(&splitg); 1065 1065 tlistg.AddToList(&fillmatg); 1066 1066 tlistg.AddToList(&writetraing); 1067 1068 tlistg.AddToList(&contg); 1069 1070 tlistg.AddToList(&flistgtest); 1067 tlistg.AddToList(&contgtrain); 1068 1071 1069 tlistg.AddToList(&writetestg); 1072 1070 … … 1107 1105 1108 1106 //***************************** fill hadrons *** 1109 1107 gLog << "---------------------------------------------------------------" 1108 << endl; 1110 1109 gLog << " Hadrons :" << endl; 1111 1110 gLog << "----------" << endl; … … 1114 1113 MTaskList tlisth; 1115 1114 1116 MFilterList flisthtrain;1117 flisthtrain.SetName("HadronFilterTrain");1118 MFilterList flisthtest;1119 flisthtest.SetName("HadronFilterTest");1120 1121 1115 MReadMarsFile readh("Events", filenameHad); 1122 1116 readh.DisableAutoScheme(); 1123 1124 MFParticleId fhadrons("MMcEvt", '!', kGAMMA);1125 fhadrons.SetName("hadronID)");1126 1117 1127 1118 TString mhname("costhh"); … … 1129 1120 binh.SetEdges(10, 0., 1.0); 1130 1121 1131 MH3 href("cos(MMcEvt.fTelescopeTheta)"); 1132 href.SetName(mhname); 1133 MH::SetBinning(&href.GetHist(), &binh); 1134 for (Int_t i=1; i<=href.GetNbins(); i++) 1135 href.GetHist().SetBinContent(i, 1.0); 1122 //MH3 href("cos(MMcEvt.fTelescopeTheta)"); 1123 //href.SetName(mhname); 1124 //MH::SetBinning(&href.GetHist(), &binh); 1125 //for (Int_t i=1; i<=href.GetNbins(); i++) 1126 // href.GetHist().SetBinContent(i, 1.0); 1127 1128 //use the original distribution from the gammas 1129 MH3 &href = *(selectorg.GetHistOrig()); 1136 1130 1137 1131 MFEventSelector2 selectorh(href); 1138 1132 selectorh.SetNumMax(howManyHadronsTrain+howManyHadronsTest); 1139 1133 selectorh.SetName("selectHadronsTrainTest"); 1140 1141 TString strhtrain = "gRandom->Rndm()*("; 1142 strhtrain += howManyHadronsTrain;1143 strhtrain += "+";1144 strhtrain += howManyHadronsTest; 1145 strhtrain += ")<";1146 strhtrain += howManyHadronsTrain;1147 MF selsplith(strhtrain);1134 selectorh.SetInverted(); 1135 1136 MContinue conth(&selectorh); 1137 conth.SetName("ContHadrons"); 1138 1139 Double_t probh = ( (Double_t) howManyHadronsTrain ) 1140 / ( (Double_t)(howManyHadronsTrain+howManyHadronsTest) ); 1141 MFRandomSplit splith(probh); 1148 1142 1149 1143 MFillH fillmath("MatrixHadrons"); 1150 fillmath.SetFilter(& flisthtrain);1144 fillmath.SetFilter(&splith); 1151 1145 fillmath.SetName("fillHadrons"); 1152 1146 … … 1155 1149 // for hadrons 1156 1150 1157 MWriteRootFile writetrainh( outNameHadronsTrain, "RECREATE");1151 MWriteRootFile writetrainh(inNameHadronsTrain, "RECREATE"); 1158 1152 writetrainh.SetName("WriteHadronsTrain"); 1159 writetrainh.SetFilter(& flisthtrain);1153 writetrainh.SetFilter(&splith); 1160 1154 1161 1155 writetrainh.AddContainer("MRawRunHeader", "RunHeaders"); … … 1170 1164 writetrainh.AddContainer("MNewImagePar", "Events"); 1171 1165 1172 MContinue conth (&flisthtrain);1173 1174 MWriteRootFile writetesth( outNameHadronsTest, "RECREATE");1166 MContinue conthtrain(&splith); 1167 1168 MWriteRootFile writetesth(inNameHadronsTest, "RECREATE"); 1175 1169 writetesth.SetName("WriteHadronsTest"); 1176 writetesth.SetFilter(&flisthtest);1177 1170 1178 1171 writetesth.AddContainer("MRawRunHeader", "RunHeaders"); … … 1187 1180 writetesth.AddContainer("MNewImagePar", "Events"); 1188 1181 1189 //-----------------------1190 1191 // entries in MFilterList1192 1193 flisthtrain.AddToList(&fhadrons);1194 flisthtrain.AddToList(&selectorh);1195 flisthtrain.AddToList(&selsplith);1196 1197 flisthtest.AddToList(&fhadrons);1198 flisthtest.AddToList(&selectorh);1199 flisthtest.AddToList(&selsplith);1200 1182 1201 1183 //***************************** … … 1211 1193 1212 1194 tlisth.AddToList(&readh); 1213 1214 tlisth.AddToList(&flisthtrain); 1195 tlisth.AddToList(&conth); 1196 1197 tlisth.AddToList(&splith); 1215 1198 tlisth.AddToList(&fillmath); 1216 1199 tlisth.AddToList(&writetrainh); 1217 1218 tlisth.AddToList(&conth); 1219 1220 tlisth.AddToList(&flisthtest); 1200 tlisth.AddToList(&conthtrain); 1201 1221 1202 tlisth.AddToList(&writetesth); 1222 1203 … … 1272 1253 matrixg.Print("SizeCols"); 1273 1254 1274 TFile writeg( outNameGammas, "RECREATE", "");1255 TFile writeg(NameGammas, "RECREATE", ""); 1275 1256 matrixg.Write(); 1276 1257 1277 1258 gLog << "" << endl; 1278 1259 gLog << "Macro CT1Analysis : matrix of training events for gammas written onto file " 1279 << outNameGammas << endl;1260 << NameGammas << endl; 1280 1261 1281 1262 //------------------------------------------- … … 1284 1265 matrixh.Print("SizeCols"); 1285 1266 1286 TFile writeh( outNameHadrons, "RECREATE", "");1267 TFile writeh(NameHadrons, "RECREATE", ""); 1287 1268 matrixh.Write(); 1288 1269 1289 1270 gLog << "" << endl; 1290 1271 gLog << "Macro CT1Analysis : matrix of training events for hadrons written onto file " 1291 << outNameHadrons << endl;1272 << NameHadrons << endl; 1292 1273 1293 1274 } … … 1327 1308 tlisttr.PrintStatistics(0, kTRUE); 1328 1309 1310 gLog << "ONOFFCT1Analysis : RF trees were read in from file " 1311 << outRF << endl; 1329 1312 1330 1313 // get adresses of objects which are used in the next eventloop … … 1414 1397 1415 1398 //----------------------------------------------------------------- 1416 // Update the input files with the RF hadronness1399 // Update the root files with the RF hadronness 1417 1400 // 1418 1401 1419 1402 if (WRF) 1420 1403 { 1404 //TString fileName(inNameHadronsTrain); 1405 //TString outName(outNameHadronsTrain); 1406 1407 //TString fileName(inNameHadronsTest); 1408 //TString outName(outNameHadronsTest); 1409 1410 //TString fileName(inNameGammasTrain); 1411 //TString outName(outNameGammasTrain); 1412 1413 //TString fileName(inNameGammasTest); 1414 //TString outName(outNameGammasTest); 1415 1416 TString fileName(inNameData); 1417 TString outName(outNameData); 1418 1419 1420 1421 1421 gLog << "" << endl; 1422 1422 gLog << "========================================================" << endl; 1423 gLog << "Update input file '" << filenameData 1424 << "' with the RF hadronness" << endl; 1425 1423 gLog << "Update root file '" << fileName 1424 << "' with the RF hadronness; ==> " << outName << endl; 1425 1426 1426 1427 MTaskList tliston; 1427 1428 MParList pliston; … … 1436 1437 // 1437 1438 1438 MReadMarsFile read("Events", file nameData);1439 MReadMarsFile read("Events", fileName); 1439 1440 read.DisableAutoScheme(); 1440 1441 … … 1450 1451 //....................................................................... 1451 1452 1452 //MWriteRootFile write(outName Image, "UPDATE");1453 MWriteRootFile write(outName Image, "RECREATE");1453 //MWriteRootFile write(outName, "UPDATE"); 1454 MWriteRootFile write(outName, "RECREATE"); 1454 1455 1455 1456 write.AddContainer("MRawRunHeader", "RunHeaders"); … … 1571 1572 pliston.FindObject("MHRanForest")->DrawClone(); 1572 1573 pliston.FindObject("hadRF", "MHHadronness")->DrawClone(); 1574 pliston.FindObject("hadRF", "MHHadronness")->Print(); 1573 1575 1574 1576 pliston.FindObject("MHHillas")->DrawClone(); … … 1606 1608 Float_t alphasi = findsig.GetAlphasi(); 1607 1609 1608 gLog << "For file '" << file nameData<< "' : " << endl;1610 gLog << "For file '" << fileName << "' : " << endl; 1609 1611 gLog << "Significance of gamma signal after supercuts : " 1610 1612 << significance << " (for |alpha| < " << alphasi << " degrees)" … … 1743 1745 findsuper.SetFilenameParam(parSCfile); 1744 1746 findsuper.SetHadronnessName("HadSC"); 1745 1747 findsuper.SetUseOrigDistribution(kTRUE); 1746 1748 1747 1749 //-------------------------- … … 1749 1751 if (CMatrix) 1750 1752 { 1751 MH3 &mh3 = *(new MH3("MHillas.fSize")); 1752 mh3.SetName("Target distribution for SIZE"); 1753 TString mname("costheta"); 1754 MBinning bin("Binning"+mname); 1755 bin.SetEdges(10, 0., 1.0); 1756 1757 MH3 mh3("cos(MMcEvt.fTelescopeTheta)"); 1758 mh3.SetName(mname); 1759 MH::SetBinning(&mh3.GetHist(), &bin); 1760 for (Int_t i=1; i<=mh3.GetNbins(); i++) 1761 mh3.GetHist().SetBinContent(i, 1.0); 1762 1753 1763 1754 1764 if (filenameTrain == filenameTest) 1755 1765 { 1756 if ( !findsuper.DefineTrainTestMatrix(filenameTrain, 1757 howManyTrain, mh3, howManyTest, mh3, 1766 if ( !findsuper.DefineTrainTestMatrix( 1767 filenameTrain, mh3, 1768 howManyTrain, howManyTest, 1758 1769 fileMatrixTrain, fileMatrixTest) ) 1759 1770 { … … 1765 1776 else 1766 1777 { 1767 if ( !findsuper.DefineTrainMatrix(filenameTrain, 1768 howManyTrain, mh3,fileMatrixTrain) )1778 if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3, 1779 howManyTrain, fileMatrixTrain) ) 1769 1780 { 1770 1781 *fLog << "CT1Analysis.C : DefineTrainMatrix failed" << endl; … … 1772 1783 } 1773 1784 1774 if ( !findsuper.DefineTestMatrix( filenameTest, 1775 howManyTest, mh3,fileMatrixTest) )1785 if ( !findsuper.DefineTestMatrix( filenameTest, mh3, 1786 howManyTest, fileMatrixTest) ) 1776 1787 { 1777 1788 *fLog << "CT1Analysis.C : DefineTestMatrix failed" << endl; … … 2212 2223 2213 2224 2225 2226 TString ext("2.root"); 2227 TString extout("2.root"); 2228 2229 TString typeHadrons("OFF"); 2230 TString typeGammas("MC"); 2231 2232 //-------------------------------------------- 2214 2233 // name of input data file 2215 TString filenameData = outPath; 2216 filenameData += "OFF"; 2217 filenameData += "3.root"; 2234 TString NameData = outPath; 2235 NameData += typeHadrons; 2236 TString inNameData(NameData); 2237 inNameData += ext; 2238 gLog << "inNameData = " << inNameData << endl; 2239 2240 // name of input MC file 2241 TString NameMC = outPath; 2242 NameMC += typeGammas; 2243 TString inNameMC(NameMC); 2244 inNameMC += ext; 2245 gLog << "inNameMC = " << inNameMC << endl; 2246 2247 2248 //-------------------------------------------- 2249 // root files for the training events 2250 2251 2252 2253 TString NameGammasTrain = outPath; 2254 NameGammasTrain += "RF_gammas_Train_"; 2255 NameGammasTrain += typeGammas; 2256 TString outNameGammasTrain(NameGammasTrain); 2257 outNameGammasTrain += extout; 2258 2259 2260 TString NameHadronsTrain = outPath; 2261 NameHadronsTrain += "RF_hadrons_Train_"; 2262 NameHadronsTrain += typeHadrons; 2263 TString outNameHadronsTrain(NameHadronsTrain); 2264 outNameHadronsTrain += extout; 2265 2266 2267 //-------------------------------------------- 2268 // root files for the test events 2269 2270 TString NameGammasTest = outPath; 2271 NameGammasTest += "RF_gammas_Test_"; 2272 NameGammasTest += typeGammas; 2273 TString outNameGammasTest(NameGammasTest); 2274 outNameGammasTest += extout; 2275 2276 TString NameHadronsTest = outPath; 2277 NameHadronsTest += "RF_hadrons_Test_"; 2278 NameHadronsTest += typeHadrons; 2279 TString outNameHadronsTest(NameHadronsTest); 2280 outNameHadronsTest += extout; 2281 2282 //-------------------------------------------------------------------- 2283 2284 //TString filenameData(inNameData); 2285 //TString filenameMC(inNameMC); 2286 2287 //TString filenameData(outNameHadronsTrain); 2288 //TString filenameMC(outNameGammasTrain); 2289 2290 TString filenameData(outNameHadronsTest); 2291 TString filenameMC(outNameGammasTest); 2292 2218 2293 gLog << "filenameData = " << filenameData << endl; 2219 2220 // name of input MC file2221 TString filenameMC = outPath;2222 filenameMC += "MC";2223 filenameMC += "3.root";2224 2294 gLog << "filenameMC = " << filenameMC << endl; 2225 2226 2295 2227 2296 //----------------------------------------------------------------- … … 2270 2339 2271 2340 2272 MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);2273 fillhadsc.SetName("HhadSC");2341 //MFillH fillhadsc("hadSC[MHHadronness]", hadSCName); 2342 //fillhadsc.SetName("HhadSC"); 2274 2343 MFillH fillhadrf("hadRF[MHHadronness]", hadRFName); 2275 2344 fillhadrf.SetName("HhadRF"); … … 2311 2380 tliston.AddToList(&read); 2312 2381 2313 tliston.AddToList(&fillhadsc);2382 //tliston.AddToList(&fillhadsc); 2314 2383 tliston.AddToList(&fillhadrf); 2315 2384 … … 2345 2414 // 2346 2415 2347 pliston.FindObject("hadSC", "MHHadronness")->DrawClone();2416 //pliston.FindObject("hadSC", "MHHadronness")->DrawClone(); 2348 2417 pliston.FindObject("hadRF", "MHHadronness")->DrawClone(); 2349 2418
Note:
See TracChangeset
for help on using the changeset viewer.