Index: /trunk/MagicSoft/Mars/mtemp/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/Changelog	(revision 6451)
+++ /trunk/MagicSoft/Mars/mtemp/Changelog	(revision 6452)
@@ -18,4 +18,5 @@
 
                                                  -*-*- END OF LINE -*-*-
+
 
 2005/02/14: Hendrik Bartko
@@ -25,8 +26,18 @@
 
 
+
+2005/02/14: Robert Wagner
+   * mtemp/mmpi/FluxCalcAndUnfold.C
+     - Example macro for calculating a flux and unfolding it using
+       MUnfoldSpectrum and MUnfold
+
+
+
+
 2005/02/11: Robert Wagner
    * mtemp/mmpi/MUnfoldSpectrum.[cc,h]
      - A wrapper class which applies the general unfolding algorithms
        of MUnfold to a gamma spectrum
+
 
 
Index: /trunk/MagicSoft/Mars/mtemp/mmpi/FluxCalcAndUnfold.C
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mmpi/FluxCalcAndUnfold.C	(revision 6452)
+++ /trunk/MagicSoft/Mars/mtemp/mmpi/FluxCalcAndUnfold.C	(revision 6452)
@@ -0,0 +1,59 @@
+void Flux6c() 
+{
+
+  TString datafile = "files/AlphaEnergyTheta.LastKeichiRF.27MC.root";
+  TString areafile = "files/area.root";
+
+  TFile* file = new TFile(datafile);
+
+  MHAlphaEnergyTheta hAlpha;
+  hAlpha.Read("MHAlphaEnergyTheta");
+  hAlpha.DrawClone();
+
+  MHEffectiveOnTime hEffTime;
+  hEffTime.Read("MHEffectiveOnTime");
+  hEffTime.DrawClone();
+
+  TFile* file3 = new TFile(areafile);
+  MHMcCollectionArea area;
+  area.Read("MHMcCollectionArea");
+  area.DrawClone();
+
+  //
+  // Read Migration Matrix
+  //
+  TFile* file4 = new TFile("files/EnergyParams.Keichi.Resized.root");
+  MHMcEnergyMigration migm;
+  migm.Read("MHMcEnergyMigration");
+  
+  // ----------------------------------------------------------------------- 
+  //
+  // Calculate # Excess events vs. Energy and Theta
+  //
+  MHExcessEnergyTheta *hex = new MHExcessEnergyTheta;
+  hex->Calc(&hAlpha);
+  hex->Draw();
+  
+  MHFlux* hFluxNUnf = new MHFlux;
+  hFluxNUnf->Calc(hex, &area, &hEffTime);
+  TH1D* fluxNUnf = hFluxNUnf->GetAverageFlux();
+
+  // ----------------------------------------------------------------------- 
+  //
+  // Unfold # Excess events vs. Energy and Theta
+  //
+  
+  TH2D* tobeunfolded = hex->GetHist();
+  TH2D* unfolded = new TH2D(*tobeunfolded);    
+  
+  MUnfoldSpectrum munfs;
+  munfs.SetDistToUnfold(tobeunfolded);
+  munfs.SetMigrationMatrix(migm->GetHist());
+  munfs.SetPriorConstant();
+  //munfs.SetPriorInput(hpr);
+  munfs.SetUnfoldingMethod(2);
+  munfs.Calc();
+  unfolded=munfs.GetUnfDist();
+
+}
+
Index: /trunk/MagicSoft/Mars/mtemp/mmpi/MUnfoldSpectrum.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mmpi/MUnfoldSpectrum.cc	(revision 6451)
+++ /trunk/MagicSoft/Mars/mtemp/mmpi/MUnfoldSpectrum.cc	(revision 6452)
@@ -26,4 +26,6 @@
 //  MUnfoldSpectrum
 //
+//  Unfolds a gamma spectrum using the algorithms given in the MUnfold class
+//
 /////////////////////////////////////////////////////////////////////////////   
 #include "MUnfoldSpectrum.h"
@@ -54,9 +56,10 @@
   //   TH3D* migration = migm->GetHist();
   
-  const Int_t energyBins = fToBeUnfolded->GetXaxis()->GetNbins();
-  const Int_t thetaBins =  fToBeUnfolded->GetYaxis()->GetNbins();
-  const TAxis* axisEnergy = fToBeUnfolded->GetXaxis();
-  const TAxis* axisTheta  = fToBeUnfolded->GetYaxis();
-  cout << "Distribution to be unfolded has " << energyBins << ", " << thetaBins << " bins" <<endl;
+  //const Int_t energyBins = fToBeUnfolded->GetXaxis()->GetNbins();
+  //const Int_t thetaBins =  fToBeUnfolded->GetYaxis()->GetNbins();
+  //const TAxis* axisEnergy = fToBeUnfolded->GetXaxis();
+  //const TAxis* axisTheta  = fToBeUnfolded->GetYaxis();
+  //cout << "Distribution to be unfolded has " << energyBins 
+  //     << ", " << thetaBins << " bins" <<endl;
   
   TAxis &taxis  = *fToBeUnfolded->GetYaxis();
@@ -140,6 +143,5 @@
     Double_t blow = baxismig.GetBinLowEdge(1);
     Double_t bup  = baxismig.GetBinLowEdge(nbmig+1);
-      
-    
+          
     // -----------------------------------------
     // dummy ideal distribution
@@ -260,5 +262,4 @@
       hb.SetBinError(a+1, sqrt(Vbcov(a, a)) );
     }
-
     
     for (Int_t k=1; k<=nb; k++) {
@@ -272,9 +273,4 @@
     }    	
   }
-  
-        
-
-
-
 }
 
Index: /trunk/MagicSoft/Mars/mtemp/mmpi/MUnfoldSpectrum.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mmpi/MUnfoldSpectrum.h	(revision 6451)
+++ /trunk/MagicSoft/Mars/mtemp/mmpi/MUnfoldSpectrum.h	(revision 6452)
@@ -13,6 +13,6 @@
 {
  public:
-    MUnfoldSpectrum();
-    ~MUnfoldSpectrum();
+  MUnfoldSpectrum();
+  ~MUnfoldSpectrum();
 
  private:
@@ -35,4 +35,5 @@
   void SetPriorInput(TH1D *hpr);
   void SetPriorPower(Double_t gamma);
+  void SetUnfoldingMethod(Short_t method) { fUnfoldingMethod = method; }
   
   ClassDef(MUnfoldSpectrum, 1)
