Changeset 2575 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
11/28/03 08:52:39 (21 years ago)
Author:
wittek
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/macros
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/CT1Analysis.C

    r2543 r2575  
    864864 }
    865865
     866
     867
    866868  //---------------------------------------------------------------------
    867869  // Job B_RF_UP
     
    885887    gLog << "Macro CT1Analysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = "
    886888         << (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;
    891893
    892894
     
    897899    Int_t NdSize   =   1;
    898900
    899     // cut in RF hadronness
     901
    900902    TString hadRFName = "HadRF";
    901903    Float_t maxhadronness =  0.23;
     
    909911
    910912
     913    TString extin  = "1.root";
     914    TString extout = "2.root";
     915
    911916    //--------------------------------------------
    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)
    913924
    914925    //TString typeInput = "ON";
    915     TString typeInput = "MC";
     926    TString typeInput = "OFF";
     927    //TString typeInput = "MC";
    916928    gLog << "typeInput = " << typeInput << endl;
    917929
    918930    // 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;
    923936
    924937    // 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;
    931941
    932942    //--------------------------------------------
    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
    934948    // "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;
    941957   
    942958
     
    944960    TString filenameMC = outPath;
    945961    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;
    950968   
    951969    //--------------------------------------------
    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    //--------------------------------------------------------------------
    9661024
    9671025
     
    10021060    gLog << "Get matrix for (gammas)" << endl;
    10031061    gLog << "matrix name        = " << mtxName << endl;
    1004     gLog << "name of root file  = " << outNameGammas << endl;
     1062    gLog << "name of root file  = " << NameGammas << endl;
    10051063    gLog << "" << endl;
    10061064
    10071065
    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);
    10111069
    10121070    matrixg.Read(mtxName);
     
    10221080    gLog << " Get matrix for (hadrons)" << endl;
    10231081    gLog << "matrix name        = " << mtxName << endl;
    1024     gLog << "name of root file  = " << outNameHadrons << endl;
     1082    gLog << "name of root file  = " << NameHadrons << endl;
    10251083    gLog << "" << endl;
    10261084
    10271085
    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);
    10311089
    10321090    matrixh.Read(mtxName);
     
    10371095   //*************************************************************************
    10381096   // create matrices of training events
     1097   // and root files of training and test events
     1098 
    10391099if (CTrainRF)
    10401100  {
    10411101    gLog << "" << endl;
    10421102    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;
    10441105    gLog << " Gammas :" << endl;
    1045 
     1106    gLog << "---------" << endl;
    10461107
    10471108    MParList  plistg;
    10481109    MTaskList tlistg;
    1049     MFilterList flistg;
    1050 
    1051     MParList  plisth;
    1052     MTaskList tlisth;
    1053     MFilterList flisth;
    10541110
    10551111    MReadMarsFile  readg("Events", filenameMC);
    10561112    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)");
    10661113
    10671114    TString mgname("costhg");
     
    10751122      gref.GetHist().SetBinContent(i, 1.0);
    10761123
    1077 
    10781124    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);
    10821136
    10831137    MFillH fillmatg("MatrixGammas");
    1084     fillmatg.SetFilter(&flistg);
     1138    fillmatg.SetFilter(&splitg);
    10851139    fillmatg.SetName("fillGammas");
    10861140
    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   
    10891179    //*****************************   fill gammas   *** 
    1090     // entries in MFilterList
    1091 
    1092     flistg.AddToList(&fgamma);
    1093     flistg.AddToList(&selectorg);
    1094 
    1095     //***************************** 
    10961180    // entries in MParList
    10971181   
     
    11051189   
    11061190    tlistg.AddToList(&readg);
    1107     tlistg.AddToList(&flistg);
     1191    tlistg.AddToList(&contg);
     1192
     1193    tlistg.AddToList(&splitg);
    11081194    tlistg.AddToList(&fillmatg);
     1195    tlistg.AddToList(&writetraing);
     1196    tlistg.AddToList(&contgtrain);
     1197
     1198    tlistg.AddToList(&writetestg);
    11091199
    11101200    //*****************************
     
    11121202    MProgressBar matrixbar;
    11131203    MEvtLoop evtloopg;
     1204    evtloopg.SetName("FillGammaMatrix");
    11141205    evtloopg.SetParList(&plistg);
    11151206    //evtloopg.ReadEnv(env, "", printEnv);
     
    11221213    tlistg.PrintStatistics(0, kTRUE);
    11231214
    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
    11251235    //*****************************   fill hadrons   *** 
    1126 
     1236    gLog << "---------------------------------------------------------------"
     1237         << endl;
    11271238    gLog << " Hadrons :" << endl;
     1239    gLog << "----------" << endl;
     1240
     1241    MParList  plisth;
     1242    MTaskList tlisth;
     1243
     1244    MReadMarsFile  readh("Events", filenameHad);
     1245    readh.DisableAutoScheme();
    11281246
    11291247    TString mhname("costhh");
     
    11311249    binh.SetEdges(10, 0., 1.0);
    11321250
    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());
    11381259
    11391260    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);
    11441271
    11451272    MFillH fillmath("MatrixHadrons");
    1146     fillmath.SetFilter(&flisth);
     1273    fillmath.SetFilter(&splith);
    11471274    fillmath.SetName("fillHadrons");
    11481275
    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
    11541311
    11551312    //***************************** 
     
    11651322   
    11661323    tlisth.AddToList(&readh);
    1167     tlisth.AddToList(&flisth);
     1324    tlisth.AddToList(&conth);
     1325
     1326    tlisth.AddToList(&splith);
    11681327    tlisth.AddToList(&fillmath);
     1328    tlisth.AddToList(&writetrainh);
     1329    tlisth.AddToList(&conthtrain);
     1330
     1331    tlisth.AddToList(&writetesth);
    11691332
    11701333    //*****************************
     
    11721335    MProgressBar matrixbar;
    11731336    MEvtLoop evtlooph;
     1337    evtlooph.SetName("FillHadronMatrix");
    11741338    evtlooph.SetParList(&plisth);
    11751339    //evtlooph.ReadEnv(env, "", printEnv);
     
    11821346    tlisth.PrintStatistics(0, kTRUE);
    11831347
     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    }
    11841367
    11851368
     
    11871370
    11881371
    1189     // write out matrices of training events
     1372    // write out matrices of training events 
    11901373
    11911374    gLog << "" << endl;
     
    11991382      matrixg.Print("SizeCols");
    12001383
    1201       TFile writeg(outNameGammas, "RECREATE", "");
     1384      TFile writeg(NameGammas, "RECREATE", "");
    12021385      matrixg.Write();
    12031386
    12041387      gLog << "" << endl;
    12051388      gLog << "Macro CT1Analysis : matrix of training events for gammas written onto file "
    1206            << outNameGammas << endl;
     1389           << NameGammas << endl;
    12071390
    12081391      //-------------------------------------------
     
    12111394      matrixh.Print("SizeCols");
    12121395
    1213       TFile writeh(outNameHadrons, "RECREATE", "");
     1396      TFile writeh(NameHadrons, "RECREATE", "");
    12141397      matrixh.Write();
    12151398
    12161399      gLog << "" << endl;
    12171400      gLog << "Macro CT1Analysis : matrix of training events for hadrons written onto file "
    1218            << outNameHadrons << endl;
     1401           << NameHadrons << endl;
    12191402
    12201403  }
     
    12541437      tlisttr.PrintStatistics(0, kTRUE);
    12551438
     1439      gLog << "ONOFFCT1Analysis : RF trees were read in from file "
     1440           << outRF << endl;
    12561441
    12571442    // get adresses of objects which are used in the next eventloop
     
    12591444    if (!fRanForest)
    12601445    {
    1261         *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
     1446        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
    12621447        return kFALSE;
    12631448    }
     
    12661451    if (!fRanTree)                                 
    12671452    {                                                                         
    1268         *fLog << err << dbginf << "MRanTree not found... aborting." << endl;   
     1453        gLog << err << dbginf << "MRanTree not found... aborting." << endl;   
    12691454        return kFALSE;
    12701455    }
     
    13091494    //
    13101495    MEvtLoop treeloop;
    1311     treeloop.SetName("GrowRFTrees"); 
     1496    treeloop.SetName("GrowRFTrees");
    13121497    treeloop.SetParList(&plist2);
    13131498
     
    13241509    if (!fRanForest)
    13251510    {
    1326         *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
     1511        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
    13271512        return kFALSE;
    13281513    }
     
    13311516    if (!fRanTree)                                 
    13321517    {                                                                         
    1333         *fLog << err << dbginf << "MRanTree not found... aborting." << endl;   
     1518        gLog << err << dbginf << "MRanTree not found... aborting." << endl;   
    13341519        return kFALSE;
    13351520    }
     
    13401525
    13411526
    1342 
    13431527    //-----------------------------------------------------------------
    1344     // Update the input files with the RF hadronness
    1345     //
     1528    // Update the root files with the RF hadronness
     1529    //
     1530
    13461531 if (WRF)
    13471532  {
     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
    13481550    gLog << "" << endl;
    13491551    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   
    13531556    MTaskList tliston;
    13541557    MParList pliston;
     
    13631566    //
    13641567
    1365     MReadMarsFile read("Events", filenameData);
     1568    MReadMarsFile read("Events", fileName);
    13661569    read.DisableAutoScheme();
    13671570
     
    13741577    rfcalc.SetHadronnessName(hadRFName);
    13751578
     1579
    13761580    //.......................................................................
    13771581
    1378       //MWriteRootFile write(outNameImage, "UPDATE");
    1379       MWriteRootFile write(outNameImage, "RECREATE");
     1582      //MWriteRootFile write(outName, "UPDATE");
     1583      MWriteRootFile write(outName, "RECREATE");
    13801584
    13811585      write.AddContainer("MRawRunHeader", "RunHeaders");
     
    13921596      write.AddContainer(hadRFName,       "Events");
    13931597
    1394 
    13951598    //-----------------------------------------------------------------
    13961599
     
    14251628    alpha.SetName("FillAlphaAbs");
    14261629
     1630
    14271631    MFillH hfill1("MHHillas",    fHilName);
    14281632    hfill1.SetName("HHillas");
     
    14511655    pliston.AddToList(&binsalphaabs);
    14521656    pliston.AddToList(&alphaabs);
     1657
    14531658
    14541659    //*****************************
     
    14801685    MProgressBar bar;
    14811686    MEvtLoop evtloop;
     1687    evtloop.SetName("UpdateRootFile");
    14821688    evtloop.SetParList(&pliston);
    14831689    evtloop.SetProgressBar(&bar);
     
    14951701    pliston.FindObject("MHRanForest")->DrawClone();
    14961702    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
     1703    pliston.FindObject("hadRF", "MHHadronness")->Print();
    14971704
    14981705    pliston.FindObject("MHHillas")->DrawClone();
     
    15011708    pliston.FindObject("MHNewImagePar")->DrawClone();
    15021709    pliston.FindObject("MHStarMap")->DrawClone();
     1710
    15031711
    15041712     //-------------------------------------------
     
    15291737    Float_t alphasi = findsig.GetAlphasi();
    15301738
    1531     gLog << "For file '" << filenameData << "' : " << endl;
     1739    gLog << "For file '" << fileName << "' : " << endl;
    15321740    gLog << "Significance of gamma signal after supercuts : "
    15331741         << significance << " (for |alpha| < " << alphasi << " degrees)"
     
    15461754 }
    15471755  //---------------------------------------------------------------------
    1548 
    1549 
    15501756
    15511757
     
    16001806
    16011807    //TString typeInput = "ON";
     1808    //TString typeInput = "OFF";
    16021809    TString typeInput = "MC";
    16031810    gLog << "typeInput = " << typeInput << endl;
     
    16671874    findsuper.SetFilenameParam(parSCfile);
    16681875    findsuper.SetHadronnessName("HadSC");
    1669 
     1876    findsuper.SetUseOrigDistribution(kTRUE);
    16701877
    16711878    //--------------------------
     
    16731880    if (CMatrix)
    16741881    {
    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
    16771892
    16781893      if (filenameTrain == filenameTest)
    16791894      {
    1680         if ( !findsuper.DefineTrainTestMatrix(filenameTrain,
    1681                               howManyTrain, mh3, howManyTest,  mh3,
     1895        if ( !findsuper.DefineTrainTestMatrix(
     1896                              filenameTrain,   mh3,
     1897                              howManyTrain,    howManyTest, 
    16821898                              fileMatrixTrain, fileMatrixTest)     )
    16831899        {
     
    16891905      else
    16901906      {
    1691         if ( !findsuper.DefineTrainMatrix(filenameTrain,
    1692                               howManyTrain, mh3, fileMatrixTrain) )
     1907        if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3,
     1908                                          howManyTrain, fileMatrixTrain) )
    16931909        {
    16941910          *fLog << "CT1Analysis.C : DefineTrainMatrix failed" << endl;
     
    16961912        }
    16971913
    1698         if ( !findsuper.DefineTestMatrix( filenameTest,
    1699                               howManyTest,  mh3, fileMatrixTest)  )
     1914        if ( !findsuper.DefineTestMatrix( filenameTest, mh3,
     1915                                          howManyTest, fileMatrixTest)  )
    17001916        {
    17011917          *fLog << "CT1Analysis.C : DefineTestMatrix failed" << endl;
     
    21162332
    21172333
     2334
    21182335  //---------------------------------------------------------------------
    21192336  // Job C 
  • trunk/MagicSoft/Mars/macros/ONOFFCT1Analysis.C

    r2543 r2575  
    215215    //     or MC2.root)
    216216
    217     Bool_t JobB_RF_UP  = kTRUE; 
    218     Bool_t CTrainRF    = kTRUE;  // create  matrices of training events
     217    Bool_t JobB_RF_UP  = kFALSE; 
     218    Bool_t CTrainRF    = kFALSE;  // create  matrices of training events
    219219                                  // and root files of training and test events
    220220    Bool_t RTrainRF    = kFALSE;  // read in matrices of training events
     
    228228    //  - update the input files with the hadroness (==>ON3.root or MC3.root)
    229229
    230     Bool_t JobB_SC_UP  = kFALSE;
    231     Bool_t CMatrix     = kFALSE;  // create training and test matrices
     230    Bool_t JobB_SC_UP  = kTRUE;
     231    Bool_t CMatrix     = kTRUE;  // create training and test matrices
    232232    Bool_t RMatrix     = kFALSE;  // read training and test matrices from file
    233233    Bool_t WOptimize   = kFALSE;  // do optimization using the training sample
     
    782782
    783783
     784    TString extin  = "1.root";
     785    TString extout = "2.root";
     786
    784787    //--------------------------------------------
     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
    785794    // file to be updated (ON, OFF or MC)
    786795
    787796    //TString typeInput = "ON";
    788     //TString typeInput = "OFF";
    789     TString typeInput = "MC";
     797    TString typeInput = "OFF";
     798    //TString typeInput = "MC";
    790799    gLog << "typeInput = " << typeInput << endl;
    791800
    792801    // 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;
    797807
    798808    // 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;
    805812
    806813    //--------------------------------------------
     
    809816    //    - and the root files of training and test events
    810817
    811     TString typeMatrixHadrons = "OFF";
    812     gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl;
    813818
    814819    // "hadrons" :
    815820    TString filenameHad = outPath;
    816821    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;
    820825    gLog << "filenameHad = "    << filenameHad << ",   howManyHadronsTrain = "
    821826         << howManyHadronsTrain << ",   howManyHadronsTest = "
     
    826831    TString filenameMC = outPath;
    827832    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;
    831836    gLog << "filenameMC = "    << filenameMC << ",   howManyGammasTrain = "
    832837         << howManyGammasTrain << ",   howManyGammasTest = "
     
    836841    // files for the matrices of training events
    837842
    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;
    847852
    848853
     
    850855    // root files for the training events
    851856
    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;
    861873
    862874
     
    864876    // root files for the test events
    865877
    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;
    875893
    876894    //--------------------------------------------------------------------
     
    913931    gLog << "Get matrix for (gammas)" << endl;
    914932    gLog << "matrix name        = " << mtxName << endl;
    915     gLog << "name of root file  = " << outNameGammas << endl;
     933    gLog << "name of root file  = " << NameGammas << endl;
    916934    gLog << "" << endl;
    917935
    918936
    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);
    922940
    923941    matrixg.Read(mtxName);
     
    933951    gLog << " Get matrix for (hadrons)" << endl;
    934952    gLog << "matrix name        = " << mtxName << endl;
    935     gLog << "name of root file  = " << outNameHadrons << endl;
     953    gLog << "name of root file  = " << NameHadrons << endl;
    936954    gLog << "" << endl;
    937955
    938956
    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);
    942960
    943961    matrixh.Read(mtxName);
     
    962980    MTaskList tlistg;
    963981
    964     MFilterList flistgtrain;
    965     flistgtrain.SetName("GammaFilterTrain");
    966     MFilterList flistgtest;
    967     flistgtest.SetName("GammaFilterTest");
    968 
    969982    MReadMarsFile  readg("Events", filenameMC);
    970983    readg.DisableAutoScheme();
    971 
    972 
    973     MFParticleId fgamma("MMcEvt", '=', kGAMMA);
    974     fgamma.SetName("gammaID");
    975984
    976985    TString mgname("costhg");
     
    987996    selectorg.SetNumMax(howManyGammasTrain+howManyGammasTest);
    988997    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);
    9971007
    9981008    MFillH fillmatg("MatrixGammas");
    999     fillmatg.SetFilter(&flistgtrain);
     1009    fillmatg.SetFilter(&splitg);
    10001010    fillmatg.SetName("fillGammas");
    10011011
     
    10041014    // for gammas
    10051015   
    1006     MWriteRootFile writetraing(outNameGammasTrain, "RECREATE");
     1016    MWriteRootFile writetraing(inNameGammasTrain, "RECREATE");
    10071017    writetraing.SetName("WriteGammasTrain");
    1008     writetraing.SetFilter(&flistgtrain);
     1018    writetraing.SetFilter(&splitg);
    10091019
    10101020      writetraing.AddContainer("MRawRunHeader", "RunHeaders");
     
    10191029      writetraing.AddContainer("MNewImagePar",  "Events");
    10201030
    1021     MContinue contg(&flistgtrain);
    1022 
    1023     MWriteRootFile writetestg(outNameGammasTest, "RECREATE");
     1031    MContinue contgtrain(&splitg);
     1032    contgtrain.SetName("ContGammaTrain");
     1033
     1034    MWriteRootFile writetestg(inNameGammasTest, "RECREATE");
    10241035    writetestg.SetName("WriteGammasTest");
    1025     writetestg.SetFilter(&flistgtest);
    10261036
    10271037      writetestg.AddContainer("MRawRunHeader", "RunHeaders");
     
    10391049   
    10401050    //*****************************   fill gammas   *** 
    1041     // entries in MFilterList
    1042 
    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     //***************************** 
    10521051    // entries in MParList
    10531052   
     
    10611060   
    10621061    tlistg.AddToList(&readg);
    1063 
    1064     tlistg.AddToList(&flistgtrain);
     1062    tlistg.AddToList(&contg);
     1063
     1064    tlistg.AddToList(&splitg);
    10651065    tlistg.AddToList(&fillmatg);
    10661066    tlistg.AddToList(&writetraing);
    1067 
    1068     tlistg.AddToList(&contg);
    1069 
    1070     tlistg.AddToList(&flistgtest);
     1067    tlistg.AddToList(&contgtrain);
     1068
    10711069    tlistg.AddToList(&writetestg);
    10721070
     
    11071105
    11081106    //*****************************   fill hadrons   *** 
    1109 
     1107    gLog << "---------------------------------------------------------------"
     1108         << endl;
    11101109    gLog << " Hadrons :" << endl;
    11111110    gLog << "----------" << endl;
     
    11141113    MTaskList tlisth;
    11151114
    1116     MFilterList flisthtrain;
    1117     flisthtrain.SetName("HadronFilterTrain");
    1118     MFilterList flisthtest;
    1119     flisthtest.SetName("HadronFilterTest");
    1120 
    11211115    MReadMarsFile  readh("Events", filenameHad);
    11221116    readh.DisableAutoScheme();
    1123 
    1124     MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
    1125     fhadrons.SetName("hadronID)");
    11261117
    11271118    TString mhname("costhh");
     
    11291120    binh.SetEdges(10, 0., 1.0);
    11301121
    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());
    11361130
    11371131    MFEventSelector2 selectorh(href);
    11381132    selectorh.SetNumMax(howManyHadronsTrain+howManyHadronsTest);
    11391133    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);
    11481142
    11491143    MFillH fillmath("MatrixHadrons");
    1150     fillmath.SetFilter(&flisthtrain);
     1144    fillmath.SetFilter(&splith);
    11511145    fillmath.SetName("fillHadrons");
    11521146
     
    11551149    // for hadrons
    11561150   
    1157     MWriteRootFile writetrainh(outNameHadronsTrain, "RECREATE");
     1151    MWriteRootFile writetrainh(inNameHadronsTrain, "RECREATE");
    11581152    writetrainh.SetName("WriteHadronsTrain");
    1159     writetrainh.SetFilter(&flisthtrain);
     1153    writetrainh.SetFilter(&splith);
    11601154
    11611155      writetrainh.AddContainer("MRawRunHeader", "RunHeaders");
     
    11701164      writetrainh.AddContainer("MNewImagePar",  "Events");
    11711165
    1172     MContinue conth(&flisthtrain);
    1173 
    1174     MWriteRootFile writetesth(outNameHadronsTest, "RECREATE");
     1166    MContinue conthtrain(&splith);
     1167
     1168    MWriteRootFile writetesth(inNameHadronsTest, "RECREATE");
    11751169    writetesth.SetName("WriteHadronsTest");
    1176     writetesth.SetFilter(&flisthtest);
    11771170
    11781171      writetesth.AddContainer("MRawRunHeader", "RunHeaders");
     
    11871180      writetesth.AddContainer("MNewImagePar",  "Events");
    11881181
    1189     //-----------------------
    1190 
    1191     // entries in MFilterList
    1192 
    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);
    12001182
    12011183    //***************************** 
     
    12111193   
    12121194    tlisth.AddToList(&readh);
    1213 
    1214     tlisth.AddToList(&flisthtrain);
     1195    tlisth.AddToList(&conth);
     1196
     1197    tlisth.AddToList(&splith);
    12151198    tlisth.AddToList(&fillmath);
    12161199    tlisth.AddToList(&writetrainh);
    1217 
    1218     tlisth.AddToList(&conth);
    1219 
    1220     tlisth.AddToList(&flisthtest);
     1200    tlisth.AddToList(&conthtrain);
     1201
    12211202    tlisth.AddToList(&writetesth);
    12221203
     
    12721253      matrixg.Print("SizeCols");
    12731254
    1274       TFile writeg(outNameGammas, "RECREATE", "");
     1255      TFile writeg(NameGammas, "RECREATE", "");
    12751256      matrixg.Write();
    12761257
    12771258      gLog << "" << endl;
    12781259      gLog << "Macro CT1Analysis : matrix of training events for gammas written onto file "
    1279            << outNameGammas << endl;
     1260           << NameGammas << endl;
    12801261
    12811262      //-------------------------------------------
     
    12841265      matrixh.Print("SizeCols");
    12851266
    1286       TFile writeh(outNameHadrons, "RECREATE", "");
     1267      TFile writeh(NameHadrons, "RECREATE", "");
    12871268      matrixh.Write();
    12881269
    12891270      gLog << "" << endl;
    12901271      gLog << "Macro CT1Analysis : matrix of training events for hadrons written onto file "
    1291            << outNameHadrons << endl;
     1272           << NameHadrons << endl;
    12921273
    12931274  }
     
    13271308      tlisttr.PrintStatistics(0, kTRUE);
    13281309
     1310      gLog << "ONOFFCT1Analysis : RF trees were read in from file "
     1311           << outRF << endl;
    13291312
    13301313    // get adresses of objects which are used in the next eventloop
     
    14141397
    14151398    //-----------------------------------------------------------------
    1416     // Update the input files with the RF hadronness
     1399    // Update the root files with the RF hadronness
    14171400    //
    14181401
    14191402 if (WRF)
    14201403  {
     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
    14211421    gLog << "" << endl;
    14221422    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   
    14261427    MTaskList tliston;
    14271428    MParList pliston;
     
    14361437    //
    14371438
    1438     MReadMarsFile read("Events", filenameData);
     1439    MReadMarsFile read("Events", fileName);
    14391440    read.DisableAutoScheme();
    14401441
     
    14501451    //.......................................................................
    14511452
    1452       //MWriteRootFile write(outNameImage, "UPDATE");
    1453       MWriteRootFile write(outNameImage, "RECREATE");
     1453      //MWriteRootFile write(outName, "UPDATE");
     1454      MWriteRootFile write(outName, "RECREATE");
    14541455
    14551456      write.AddContainer("MRawRunHeader", "RunHeaders");
     
    15711572    pliston.FindObject("MHRanForest")->DrawClone();
    15721573    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
     1574    pliston.FindObject("hadRF", "MHHadronness")->Print();
    15731575
    15741576    pliston.FindObject("MHHillas")->DrawClone();
     
    16061608    Float_t alphasi = findsig.GetAlphasi();
    16071609
    1608     gLog << "For file '" << filenameData << "' : " << endl;
     1610    gLog << "For file '" << fileName << "' : " << endl;
    16091611    gLog << "Significance of gamma signal after supercuts : "
    16101612         << significance << " (for |alpha| < " << alphasi << " degrees)"
     
    17431745    findsuper.SetFilenameParam(parSCfile);
    17441746    findsuper.SetHadronnessName("HadSC");
    1745 
     1747    findsuper.SetUseOrigDistribution(kTRUE);
    17461748
    17471749    //--------------------------
     
    17491751    if (CMatrix)
    17501752    {
    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
    17531763
    17541764      if (filenameTrain == filenameTest)
    17551765      {
    1756         if ( !findsuper.DefineTrainTestMatrix(filenameTrain,
    1757                               howManyTrain, mh3, howManyTest,  mh3,
     1766        if ( !findsuper.DefineTrainTestMatrix(
     1767                              filenameTrain,   mh3,
     1768                              howManyTrain,    howManyTest, 
    17581769                              fileMatrixTrain, fileMatrixTest)     )
    17591770        {
     
    17651776      else
    17661777      {
    1767         if ( !findsuper.DefineTrainMatrix(filenameTrain,
    1768                               howManyTrain, mh3, fileMatrixTrain) )
     1778        if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3,
     1779                                          howManyTrain, fileMatrixTrain) )
    17691780        {
    17701781          *fLog << "CT1Analysis.C : DefineTrainMatrix failed" << endl;
     
    17721783        }
    17731784
    1774         if ( !findsuper.DefineTestMatrix( filenameTest,
    1775                               howManyTest,  mh3, fileMatrixTest)  )
     1785        if ( !findsuper.DefineTestMatrix( filenameTest, mh3,
     1786                                          howManyTest, fileMatrixTest)  )
    17761787        {
    17771788          *fLog << "CT1Analysis.C : DefineTestMatrix failed" << endl;
     
    22122223
    22132224
     2225
     2226    TString ext("2.root");
     2227    TString extout("2.root");
     2228
     2229    TString typeHadrons("OFF");
     2230    TString typeGammas("MC");
     2231
     2232    //--------------------------------------------
    22142233    // 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
    22182293    gLog << "filenameData = " << filenameData << endl;
    2219 
    2220     // name of input MC file
    2221     TString filenameMC = outPath;
    2222     filenameMC += "MC";
    2223     filenameMC += "3.root";
    22242294    gLog << "filenameMC   = " << filenameMC   << endl;
    2225 
    22262295
    22272296    //-----------------------------------------------------------------
     
    22702339
    22712340
    2272     MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
    2273     fillhadsc.SetName("HhadSC");
     2341    //MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
     2342    //fillhadsc.SetName("HhadSC");
    22742343    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
    22752344    fillhadrf.SetName("HhadRF");
     
    23112380    tliston.AddToList(&read);
    23122381
    2313     tliston.AddToList(&fillhadsc);
     2382    //tliston.AddToList(&fillhadsc);
    23142383    tliston.AddToList(&fillhadrf);
    23152384   
     
    23452414    //
    23462415
    2347     pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
     2416    //pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
    23482417    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
    23492418
Note: See TracChangeset for help on using the changeset viewer.