Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/computeCoeff.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/computeCoeff.C	(revision 6368)
+++ trunk/MagicSoft/Mars/mtemp/mifae/macros/computeCoeff.C	(revision 6465)
@@ -4,27 +4,6 @@
 {    
   MEffAreaAndCoeffCalc calc;
+  calc.AddFile("/data/star_gamma_test.root");
 
-  // initial MC files
-  calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_0_7_1000to1009_w0.root");
-  calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_0_7_1130to1139_w0.root");
-  calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_0_7_1520to1529_w0.root");
-  calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_90_7_1260to1269_w0.root");
-  calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_90_7_1390to1399_w0.root");
-  calc.AddFileToInitialMC("/data/camera_NCL/Gamma_zbin0_90_7_1650to1659_w0.root");
-  
-
-  // files with remaining events after cuts (or where to apply cuts) see warning above
-  calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_0_7_1000to1009_w0_cleaned4035.root");
-  calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_0_7_1130to1139_w0_cleaned4035.root");
-  calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_0_7_1520to1529_w0_cleaned4035.root");
-  calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_90_7_1260to1269_w0_cleaned4035.root");
-  calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_90_7_1390to1399_w0_cleaned4035.root");
-  calc.AddFileToFinalMC("/data/camera_CL/Gamma_zbin0_90_7_1650to1659_w0_cleaned4035.root");
-
-
-  // define the funtion of the desired spectrum
-  calc.SetFunction("4.e9*pow(x,-2.6+1)",10.,10000.);
-  calc.ComputeAllFactors();
-  
   /************************************************/
   /* Build spectrum                               */
@@ -32,57 +11,40 @@
   /************************************************/
   const Int_t ebins = 10;              // number of bins to build spectrum
-  const Int_t esubbins = 20;           // number of subbins per big bin
   const Double_t emin=10;
-  const Double_t emax=1000;
+  const Double_t emax=600;
   const Double_t logemin = TMath::Log10(emin);
   const Double_t logemax = TMath::Log10(emax);
-  const Double_t de = (logemax-logemin)/ebins; // bin size (in log)
-  const Double_t desub = de/esubbins; // subbin size (in log)
-  const Int_t esbins = ebins*esubbins; // total number of subbins
+  calc.SetEbins(ebins);
+  //  calc.SetEsubbins(1);
 
-  // remaining events after cuts
-  const UInt_t ncutfiles=6;
-  Char_t* cutName[ncutfiles]={
-    "/data/camera_CL/Gamma_zbin0_0_7_1000to1009_w0_cleaned4035.root",
-    "/data/camera_CL/Gamma_zbin0_0_7_1130to1139_w0_cleaned4035.root",
-    "/data/camera_CL/Gamma_zbin0_0_7_1520to1529_w0_cleaned4035.root",
-    "/data/camera_CL/Gamma_zbin0_90_7_1260to1269_w0_cleaned4035.root",
-    "/data/camera_CL/Gamma_zbin0_90_7_1390to1399_w0_cleaned4035.root",
-    "/data/camera_CL/Gamma_zbin0_90_7_1650to1659_w0_cleaned4035.root"
-  };
+  // define the funtion of the desired spectrum
+  calc.SetFunction("4.e9*pow(x,-2.6+1)",emin,emax);
+  calc.ComputeAllFactors();
+  
+  const UInt_t ncutfiles=1;
+  Char_t* cutName[ncutfiles]={"/data/star_gamma_test.root"};
 
   TChain* ccut = new TChain("Events");
   for(Int_t i = 0; i < ncutfiles; i++)
     ccut->Add(cutName[i]);
-  ccut->SetAlias("logestenergy","log10(MHillas.fSize/15.)");
-  const Int_t nentries = Int_t(ccut->GetEntries());
-
-  MHillas*  hillas;
-  MMcEvt*   mcevt;
-  ccut->SetBranchStatus("*",0);
-  ccut->SetBranchStatus("MHillas.*",1);
-  ccut->SetBranchStatus("MMcEvt.*",1);
-  ccut->SetBranchAddress("MHillas.",&hillas);
-  ccut->SetBranchAddress("MMcEvt.",&mcevt);
+  ccut->SetAlias("logestenergy","log10(MHillas.fSize/0.18/15.)");
+  ccut->SetAlias("theta","MMcEvt.fTelescopeTheta*180./3.14159");
 
   TH1D* hspec = new TH1D("hspec","Spectrum",ebins,logemin,logemax);
   hspec->Sumw2();
+  ccut->Draw("logestenergy>>hspec","theta<10","goff");
 
-  for(Int_t i=0;i<nentries;i++)
+  for(Int_t i=0;i<ebins;i++)
     {
-      ccut->GetEntry(i);  
-      
-      // OJO!! Estimated energy will be taken directly from some input container
-      Float_t estim  = hillas->GetSize()/15.;
-
-      UInt_t effabin = UInt_t((TMath::Log10(estim)-logemin)/desub);
-      UInt_t coefbin = UInt_t((TMath::Log10(estim)-logemin)/de);
-      
-      Float_t effa  =  calc.GetEffectiveAreaHisto()->GetBinContent(effabin+1,1);
-      Float_t unfold = calc.GetCoefficientHisto()->GetBinContent(coefbin+1,1);
-      
+      const Float_t uncorrval = hspec->GetBinContent(i+1);
+      const Float_t effa  =  calc.GetEffectiveAreaHisto()->GetBinContent(i+1,1);
+      const Float_t unfold = calc.GetCoefficientHisto()->GetBinContent(i+1,1);
+      Float_t corrval;
       if(effa)
-	hspec->Fill(TMath::Log10(estim),unfold/effa*1e9);
-    }      
+	corrval = uncorrval*unfold/effa;
+      else
+	corrval = 0;
+      hspec->SetBinContent(i+1,corrval);
+    }
 
   // SAVE RESULTS
