Index: trunk/MagicSoft/Mars/macros/ONOFFAnalysis.C
===================================================================
--- trunk/MagicSoft/Mars/macros/ONOFFAnalysis.C	(revision 2797)
+++ trunk/MagicSoft/Mars/macros/ONOFFAnalysis.C	(revision 2798)
@@ -197,5 +197,5 @@
 
     // Job A : 
-    //  - produce MHSigmaTheta plots for ON and OFF data
+    //  - produce MHSigmaTheta plots for ON, OFF and MC data
     //  - write out (or read in) these MHSigmaTheta plots
     //  - read ON (or OFF or MC) data
@@ -289,14 +289,10 @@
   // Job A
   //=========
-    // read ON data file 
-
-    //  - produce the 2D-histogram "sigmabar versus Theta" 
-    //    (SigmaTheta_ON.root) for ON data
-    //    (to be used for the padding of the MC gamma data)
-
-    //  - write a file of ON events (ON1.root) 
+
+    //  - produce the histograms "sigmabar versus Theta", etc. 
+    //    for ON, OFF and MC data (to be used for the padding)
+    //
+    //  - write root file of padded ON (OFF, MC) events (ON1.root, ...) 
     //    (after the standard cuts, before the g/h separation)
-    //    (to be used together with the corresponding MC gamma file (MC1.root)
-    //     for the optimization of the g/h separation)
 
 
@@ -304,7 +300,7 @@
  {
     gLog << "=====================================================" << endl;
-    gLog << "Macro MagicAnalysis : Start of Job A" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job A" << endl;
     gLog << "" << endl;
-    gLog << "Macro MagicAnalysis : JobA, WPad, RPad, Wout = " 
+    gLog << "Macro ONOFFAnalysis : JobA, WPad, RPad, Wout = " 
          << (JobA ? "kTRUE" : "kFALSE")  << ",  " 
          << (WPad ? "kTRUE" : "kFALSE")  << ",  " 
@@ -318,5 +314,7 @@
     TString fileON  = onfile;
     TString fileOFF = offfile;
-    gLog << "fileON, fileOFF = " << fileON << ",  " << fileOFF << endl;
+    TString fileMC  = mcfile;
+    gLog << "fileON, fileOFF, fileMC = " << fileON << ",  " 
+         << fileOFF << ",  " << fileMC   << endl;
 
     // name of file to conatin the histograms for the padding
@@ -353,5 +351,5 @@
     // generate histograms to be used in the padding
     // 
-    // read ON and OFF data files
+    // read ON, OFF and MC data files
     // generate (or read in) the padding histograms for ON and OFF data
     //                       and merge these histograms
@@ -526,4 +524,84 @@
 
       //-----------------------------------------
+      // MC events
+
+      gLog << "------------" << endl;
+      gLog << "MC events :" << endl;
+      gLog << "------------" << endl;
+
+      MTaskList tlistmc;
+      MParList plistmc;
+
+    MReadMarsFile  readMC("Events", fileMC);
+    read.DisableAutoScheme();
+    //      MCT1ReadPreProc readMC(fileMC);
+
+      MFSelBasic selthetamc;
+      selthetamc.SetCuts(-100.0, 29.5, 35.5);
+      MContinue contthetamc(&selthetamc);
+
+      MBlindPixelCalc blindmc;
+      blindmc.SetUseBlindPixels();
+
+      MFSelBasic selbasicmc;
+      MContinue contbasicmc(&selbasicmc);
+
+      MHBlindPixels blindMC("BlindPixelsMC");
+      MFillH fillblindMC("BlindPixelsMC[MHBlindPixels]", "MBlindPixels");
+      fillblindMC.SetName("FillBlindMC");
+
+      MSigmabarCalc sigbarcalcmc;
+
+      MHSigmaTheta sigthMC("SigmaThetaMC");
+      MFillH fillsigthetaMC ("SigmaThetaMC[MHSigmaTheta]", "MMcEvt");
+      fillsigthetaMC.SetName("FillSigThetaMC");     
+
+      //*****************************
+      // entries in MParList
+    
+      plistmc.AddToList(&tlistmc);
+      InitBinnings(&plistmc);
+      plistmc.AddToList(&blindMC);
+      plistmc.AddToList(&sigthMC);
+
+
+      //*****************************
+      // entries in MTaskList
+    
+      tlistmc.AddToList(&readMC);
+      //tlistmc.AddToList(&contthetamc);
+
+      tlistmc.AddToList(&blindmc);
+
+      tlistmc.AddToList(&contbasicmc);
+      tlistmc.AddToList(&fillblindMC);
+      tlistmc.AddToList(&sigbarcalcmc);
+      tlistmc.AddToList(&fillsigthetaMC);
+
+      MProgressBar barmc;
+      MEvtLoop evtloopmc;
+      evtloopmc.SetParList(&plistmc);
+      evtloopmc.SetProgressBar(&barmc);
+
+      Int_t maxeventsmc = -1;
+      //Int_t maxeventsmc = 20000;
+      if ( !evtloopmc.Eventloop(maxeventsmc) )
+          return;
+
+      tlistmc.PrintStatistics(0, kTRUE);
+
+      blindMC.DrawClone();
+      sigthMC.DrawClone();
+
+      // save the histograms for the padding
+      TH2D *sigthmc     = sigthMC.GetSigmaTheta();
+      TH3D *sigpixthmc  = sigthMC.GetSigmaPixTheta();
+      TH3D *diffpixthmc = sigthMC.GetDiffPixTheta();
+
+      TH2D *blindidthmc = blindMC.GetBlindId();
+      TH2D *blindnthmc  = blindMC.GetBlindN();
+
+
+      //-----------------------------------------
 
       gLog << "End of generating the padding histograms" << endl;
@@ -762,5 +840,5 @@
 
 
-    gLog << "Macro MagicAnalysis : End of Job A" << endl;
+    gLog << "Macro ONOFFAnalysis : End of Job A" << endl;
     gLog << "===================================================" << endl;
  }
@@ -786,8 +864,8 @@
  {
     gLog << "=====================================================" << endl;
-    gLog << "Macro MagicAnalysis : Start of Job B_RF_UP" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job B_RF_UP" << endl;
 
     gLog << "" << endl;
-    gLog << "Macro MagicAnalysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = "
+    gLog << "Macro ONOFFAnalysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = "
          << (JobB_RF_UP ? "kTRUE" : "kFALSE")  << ",  " 
          << (RTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
@@ -1290,5 +1368,5 @@
 
       gLog << "" << endl;
-      gLog << "Macro MagicAnalysis : matrix of training events for gammas written onto file "
+      gLog << "Macro ONOFFAnalysis : matrix of training events for gammas written onto file "
            << NameGammas << endl;
 
@@ -1302,5 +1380,5 @@
 
       gLog << "" << endl;
-      gLog << "Macro MagicAnalysis : matrix of training events for hadrons written onto file "
+      gLog << "Macro ONOFFAnalysis : matrix of training events for hadrons written onto file "
            << NameHadrons << endl;
 
@@ -1369,5 +1447,5 @@
     gLog << "" << endl;
     gLog << "========================================================" << endl;
-    gLog << "Macro MagicAnalysis : start growing trees" << endl;
+    gLog << "Macro ONOFFAnalysis : start growing trees" << endl;
 
     MTaskList tlist2;
@@ -1654,5 +1732,5 @@
   }
 
-    gLog << "Macro MagicAnalysis : End of Job B_RF_UP" << endl;
+    gLog << "Macro ONOFFAnalysis : End of Job B_RF_UP" << endl;
     gLog << "=======================================================" << endl;
  }
@@ -1674,8 +1752,8 @@
  {
     gLog << "=====================================================" << endl;
-    gLog << "Macro MagicAnalysis : Start of Job B_SC_UP" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job B_SC_UP" << endl;
 
     gLog << "" << endl;
-    gLog << "Macro MagicAnalysis : JobB_SC_UP, CMatrix, RMatrix, WOptimize, RTest, WSC = "
+    gLog << "Macro ONOFFAnalysis : JobB_SC_UP, CMatrix, RMatrix, WOptimize, RTest, WSC = "
          << (JobB_SC_UP ? "kTRUE" : "kFALSE")  << ",  " 
          << (CMatrix    ? "kTRUE" : "kFALSE")  << ",  "
@@ -2230,5 +2308,5 @@
 
 
-    gLog << "Macro MagicAnalysis : End of Job B_SC_UP" << endl;
+    gLog << "Macro ONOFFAnalysis : End of Job B_SC_UP" << endl;
     gLog << "=======================================================" << endl;
  }
@@ -2249,8 +2327,8 @@
  {
     gLog << "=====================================================" << endl;
-    gLog << "Macro MagicAnalysis : Start of Job C" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job C" << endl;
 
     gLog << "" << endl;
-    gLog << "Macro MagicAnalysis : JobC = " 
+    gLog << "Macro ONOFFAnalysis : JobC = " 
          << (JobC ? "kTRUE" : "kFALSE")  << endl;
 
@@ -2458,5 +2536,5 @@
     DeleteBinnings(&pliston);
 
-    gLog << "Macro MagicAnalysis : End of Job C" << endl;
+    gLog << "Macro ONOFFAnalysis : End of Job C" << endl;
     gLog << "===================================================" << endl;
  }
@@ -2477,8 +2555,8 @@
  {
     gLog << "=====================================================" << endl;
-    gLog << "Macro MagicAnalysis : Start of Job D" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job D" << endl;
 
     gLog << "" << endl;
-    gLog << "Macro MagicAnalysis : JobD = " 
+    gLog << "Macro ONOFFAnalysis : JobD = " 
          << (JobD        ? "kTRUE" : "kFALSE")  << endl;
 
@@ -2698,5 +2776,5 @@
     DeleteBinnings(&pliston);
 
-    gLog << "Macro MagicAnalysis : End of Job D" << endl;
+    gLog << "Macro ONOFFAnalysis : End of Job D" << endl;
     gLog << "=======================================================" << endl;
  }
@@ -2723,8 +2801,8 @@
  {
     gLog << "=====================================================" << endl;
-    gLog << "Macro MagicAnalysis : Start of Job E_XX" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job E_XX" << endl;
 
     gLog << "" << endl;
-    gLog << "Macro MagicAnalysis : JobE_XX, CCollArea, OEEst, WEX = " 
+    gLog << "Macro ONOFFAnalysis : JobE_XX, CCollArea, OEEst, WEX = " 
          << (JobE_XX ? "kTRUE" : "kFALSE")  << ",  " 
          << (CCollArea?"kTRUE" : "kFALSE")  << ",  " 
@@ -2951,5 +3029,5 @@
     // Optimization of energy estimator
     //
-    gLog << "Macro MagicAnalysis.C : calling MagicEEst" << endl;
+    gLog << "Macro ONOFFAnalysis.C : calling MagicEEst" << endl;
 
     TString inpath("");
@@ -2960,5 +3038,5 @@
             howMany,  maxhadronness, maxalpha, maxdist,
             binsE, binsTheta);
-    gLog << "Macro MagicAnalysis.C : returning from MagicEEst" << endl;
+    gLog << "Macro ONOFFAnalysis.C : returning from MagicEEst" << endl;
  }
 
@@ -2972,5 +3050,5 @@
     gLog << "================================================================"
          << endl;
-    gLog << "Macro MagicAnalysis.C : read parameters of energy estimator and migration matrix from file '"
+    gLog << "Macro ONOFFAnalysis.C : read parameters of energy estimator and migration matrix from file '"
          << energyParName << "'" << endl;
     TFile enparam(energyParName);
@@ -3307,5 +3385,5 @@
   }
 
-    gLog << "Macro Analysis : End of Job E_XX" << endl;
+    gLog << "Macro ONOFFAnalysis : End of Job E_XX" << endl;
     gLog << "=======================================================" << endl;
  }
