ROOT logo
#include <iostream>
#include <fstream>
#include "TMath.h"

using namespace std;

char myjunk[200];

void SetStyles(TH1 *histo, char *ytitle, char *xtitle, int color, int marker);
void SetCanvasStyle(TCanvas *c);
TLegend *GetLegend(float x1, float y1, float x2, float y2);
Bool_t doLevy = kFALSE;//for debugging
Bool_t doBlast = kTRUE;//for debugging
void Draw(TH1 *data, TF1 *fLevy, TF1 *fBlast,int centbin,char *pid,char *name);
void PrintLatex(int etCutNum, char *det,Bool_t effCorr);
void PrintArrays();

// Centrality dependent factors
int nbins = 10;  // number of centrality bins
Double_t etk0[2][10] = {{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
Double_t etBlastk0[2][10] = {{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
Double_t etBlastk02D[2][10] = {{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
//et cuts for kaon energies
//0.00, 0.050, 0.100, 0.150, 0.200
//0.250,0.300, 0.350, 0.400, 0.450
//0.500
//counting is integer and starts are 1
//                        1     2      3      4      5       6PHOS 7EMCal 8      9      10      11Alt
Double_t etCutOffs[11] = {0.00, 0.050, 0.100, 0.150, 0.200,  0.250,0.300, 0.350, 0.400, 0.450,  0.500};

Double_t kaonDeposits[2][10] = {{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};

//note:  Not at all sensitive to which Jacobian is used, which also means the pT used doesn't really matter
void SecondaryK0SJacSys(char *inputfilename = "../workingdir/rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.EMCal.LHC11a10a_bis.Run139465.root", char *det = "EMCal", int whichjacobian = 1, int etCutNum = 7, Bool_t longRun = kFALSE, Bool_t effCorr = kFALSE){//Kaon collection: 0=K0S, -1=K-, +1=K+
  Int_t kaonSelection = 1;
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetOptFit(0);
  gStyle->SetLineWidth(3);
  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
  gROOT->ProcessLine(".L AliBWFunc.cxx+g");
  gROOT->ProcessLine(".L AliBWTools.cxx+g");
  gSystem->Load("libTree.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libMinuit.so");
  gSystem->Load("libSTEERBase.so");
  gSystem->Load("libESD.so");
  gSystem->Load("libAOD.so");
  gSystem->Load("libANALYSIS.so");
  gSystem->Load("libANALYSISalice.so");
  gSystem->Load("libCORRFW.so");
  gSystem->Load("libPWGLFspectra.so");
  gSystem->Load("libPWGTools.so");
  gROOT->LoadMacro("macros/FitParticle.C+");
  gROOT->LoadMacro("macros/GetLevidEtdptTimesPt.C");
  //inputting kaon errors from http://arxiv.org/abs/1303.0737
  //using average of K+ and K-
  Float_t kaonYield[10] = {109,90.5,68,46,30,18.2,10.2,5.1,2.3,0.855};
  Float_t kaonStatErr[10] = {0.3,0.2,0.1,0.1,0.1, 0.06,0.04,0.03,0.02,0.01};
  Float_t kaonSysErr[10] = {9,7,5,4,2, 1.5,0.8,0.4,0.2,0.09};
  Float_t kaonTotErr[10] = {0,0,0,0,0, 0,0,0,0,0};
  Float_t kaonFracErr[10] = {0,0,0,0,0, 0,0,0,0,0};
  for(int i=0;i<10;i++){
    kaonTotErr[i] = TMath::Sqrt(kaonSysErr[i]*kaonSysErr[i]+kaonStatErr[i]*kaonStatErr[i]);
    kaonFracErr[i] = kaonTotErr[i]/kaonYield[i];
    //cout<<"bin "<<i<<" err "<<kaonFracErr[i]<<endl;
  }

  //centrality bin #  (want to loop over 5 bins)
  int centbin = 0;  // can change later
  TString detector = det;
  float etarange = 0.7;
  if(detector.Contains("EMC")){
    etarange = 0.7;
  }
  else{etarange = 0.1;}

  //==================READ IN DATA==========================

  TFile *chargedkaonfile = new TFile("rootFiles/SPECTRA_COMB_20120709.root");
  gROOT->LoadMacro("macros/k0sFinal.C");                // load data spectra
  TClonesArray histosk0 = GetK0S();                     // get K0S histogram
  
  TCanvas *cChK = new TCanvas("cChK","ChargedKaons",700,500);
  //cChK->Divide(4,3);
  TH1D *histoskch[] = {NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL, NULL,NULL};
  if(kaonSelection==1){
    for(int i=0;i<=9;i++){
      TH1D *histoTemp = (TH1D*) chargedkaonfile->Get(Form("cent%i_kaon_plus",i));
      histoskch[i] = (TH1D*)histoTemp->Clone("cent%i_kaon_plus_clone");
      if(i==0){
	((TH1D*)histoskch[i])->Draw();
      }
      else{
	((TH1D*)histoskch[i])->Draw("same");
      }
      //}
    }
  }
  else{
    for(int i=0;i<=9;i++){
      TH1D *histoTemp = (TH1D*) chargedkaonfile->Get(Form("cent%i_kaon_minus",i));
      histoskch[i] = (TH1D*)histoTemp->Clone("cent%i_kaon_minus_clone");
      if(i==0){
	((TH1D*)histoskch[i])->Draw();
      }
      else{
	((TH1D*)histoskch[i])->Draw("same");
      }
      //}
    }
  }
  TCanvas *cEmpty = new TCanvas("cEmpty","Empty",700,500);

  TString particleName = "K0";
  TString particleLatex = "K^{0}_S";
  if(kaonSelection==1){
    particleName = "K+";
    particleLatex = "K^{+}";
  }
  if(kaonSelection==-1){
    particleName = "K-";
    particleLatex = "K^{-}";
  }

  //==================FIT DATA==========================
  TF1 *funck0[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};          
  TF1 *funcBlastk0[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};     // Blastwave fit to K0 pT?
  TF1 *funcetk0[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};         
  TF1 *funcetBlastk0[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};   // Blastwave fit to K0 et
  TF1 *funcetBlastk02D[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};
  TF1 *funcBlastk0Jac[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL}; 
 
  TH1 *histoSysUp[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};  //K0S Clone histogram
  TF1 *funcBlastk0Up[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL}; 
  TH1 *histoSysLow[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};  //K0S Clone histogram
  TF1 *funcBlastk0Low[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL}; 
  
  TH1 *histoSys[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};  //K0S Clone histogram
  
  
  Float_t TInit = 0.1326;    // initialize T parameter of Blastwave fit
  Float_t nInit = 6.6857;    // initialize n parameter of Blastwave fit
  Float_t normInit = 20;     // set normalization parameter of Blastwave fit
  AliBWTools *tools = new AliBWTools();
  Double_t yield;            // yield
  Double_t yieldError;       // yield error
  Double_t partialYields[] = {0,0,0};
  Double_t partialYieldErrors[] = {0,0,0};
  Double_t Ameson = 0;
  Double_t Abaryon = -1;
  Double_t Aantibaryon = 1;
  
  //Systematic erros
  
  TF1 *funcBlastk0Par1[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};
  TF1 *funcBlastk0Par2[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};
  Double_t Par[10] = {0,0,0,0,0, 0,0,0,0,0};
  Double_t ErrPar[10] = {0,0,0,0,0, 0,0,0,0,0};
 
  // Genarate y
   
  TRandom* randy = new TRandom();  
  
  // integral of fit to data
  float fitINTEGRALdata[10] = {NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL};

  if(kaonSelection!=0){//charged kaons
    nbins = 10;
  }

  // loop over centrality bins 0->5 and genarate histos shift up and down to Systematic errors
  for(int i=0;i<nbins;i++){
    //for(int i=centbin;i<centbin+1;i++){
    if(kaonSelection==0){
      histoSys[i] = (TH1F*)histosk0[i]->Clone(Form("Sys%i",i));
      histoSysLow[i] = (TH1F*)histosk0[i]->Clone(Form("SysLow%i",i));
      histoSysUp[i] = (TH1F*)histosk0[i]->Clone(Form("SysUp%i",i));
    }
    else{
      histoSys[i] = (TH1D*)histoskch[i]->Clone(Form("Sys%i",i));
      histoSysLow[i] = (TH1D*)histoskch[i]->Clone(Form("SysLow%i",i));
      histoSysUp[i] = (TH1D*)histoskch[i]->Clone(Form("SysUp%i",i));
    }
    float NbinsSys =  histoSysUp[i]->GetXaxis()->GetNbins();
    
    for(int x = 1; x<=NbinsSys; x++){
		
      float BinContent = histoSysUp[i]->GetBinContent(x);
      float BinError =  histoSysUp[i]->GetBinError(x);
      histoSysUp[i]->SetBinContent(x, BinContent+BinError);
      histoSysLow[i]->SetBinContent(x, BinContent-BinError);
    }

    funcBlastk0Up[i] = FitParticle((TH1*)histoSysUp[i],particleName.Data(),-1,-1,-1,0,0,3,-1,kFitBlastWave);
    funcBlastk0Low[i] = FitParticle((TH1*)histoSysLow[i],particleName.Data(),-1,-1,-1,0,0,3,-1,kFitBlastWave);
    funcBlastk0[i] = FitParticle((TH1*)histoSys[i],particleName.Data(),-1,-1,-1,0,0,3,-1,kFitBlastWave);

    if(kaonSelection==0){
      funck0[i] = FitParticle((TH1F*)histosk0[i],particleName.Data(),TInit,normInit,nInit);
      if(!histosk0[i]) cerr<<"histosk0[i] does not exist!"<<endl;
      if(!funck0[i]) cerr<<"funck0[i] does not exist!"<<endl;
      Draw((TH1F*)histosk0[i],funck0[i],funcBlastk0[i],i,particleLatex.Data(),particleName.Data());
    }
    else{
      if(!histoskch[i]) cerr<<"Warning!  Histogram does not exist!"<<endl;
      funck0[i] = FitParticle((TH1D*)histoskch[i],particleName.Data());
      cerr<<"174"<<endl;
      Draw(histoskch[i],funck0[i],funcBlastk0[i],i,particleLatex.Data(),particleName.Data());
    }
  }

 
  //==================THROWING RANDOM SPECTRA========================== 
  // number of particles to put in histogram (will change later)
  int nParticles = 1e3; // for quick runs
  if(longRun) nParticles = 1e8;   //for statistics

  // set parameters of setstyles
  int marker1 = 21; int marker2 = 24;
  int color1 = 2; int color2 = 4;
  int mixmarker = 22; int mixcolor = 3;
  
  TFile *f = TFile::Open(inputfilename, "READ");
  TList *l = (TList*)f->Get("out1");
  TH3F *fHistK0EDepositsVsPtInAcceptance;
  TH3F *fHistK0EDepositsVsPtOutOfAcceptance;
  if(effCorr){
    fHistK0EDepositsVsPtInAcceptance =(TH3F*) l->FindObject("fHistK0EDepositsVsPtInAcceptance");
    fHistK0EDepositsVsPtOutOfAcceptance =(TH3F*) l->FindObject("fHistK0EDepositsVsPtOutOfAcceptance");
  }
  else{
    fHistK0EDepositsVsPtInAcceptance =(TH3F*) l->FindObject("fHistK0EGammaVsPtInAcceptance");
    fHistK0EDepositsVsPtOutOfAcceptance =(TH3F*) l->FindObject("fHistK0EGammaVsPtOutOfAcceptance");
  }
  if(!fHistK0EDepositsVsPtOutOfAcceptance) cerr<<"Warning!  did not find fHistK0EDepositsVsPtOutOfAcceptance"<<endl;
  if(!fHistK0EDepositsVsPtInAcceptance) cerr<<"Warning!  did not find fHistK0EDepositsVsPtInAcceptance"<<endl;
  fHistK0EDepositsVsPtInAcceptance->GetZaxis()->SetRange(etCutNum,etCutNum);
  TH2D *my2DhistoK0S = (TH2D*) fHistK0EDepositsVsPtInAcceptance->Project3D("yx");
  fHistK0EDepositsVsPtOutOfAcceptance->GetZaxis()->SetRange(etCutNum,etCutNum);
  TH2D *my2DhistoK0SOutOfAcceptance = (TH2D*) fHistK0EDepositsVsPtOutOfAcceptance->Project3D("yx");
  TH1F *fHistSimKaonsInAcceptance = l->FindObject("fHistSimKaonsInAcceptance");
  TH1F *fHistSimKaonsOutOfAcceptance = l->FindObject("fHistSimKaonsOutOfAcceptance");
  TH1F *hRatioOutOfAccOverInAcc = fHistSimKaonsOutOfAcceptance->Clone("hRatioOutOfAccOverInAcc");
  hRatioOutOfAccOverInAcc->Divide(fHistSimKaonsInAcceptance);

  //find number of bins of Caio's histogram
  int bincount = 0;
  bincount = my2DhistoK0S->GetXaxis()->GetNbins();
  cout<<"Number of bins in histo: "<<bincount<<endl;
  
  // create array to hold histograms
  TClonesArray histoarrayK0S("TH1D",bincount);  //(nbins);
  TClonesArray histoarrayK0SOutOfAcceptance("TH1D",bincount);  //(nbins);

  //==================PROJECTIONS FOR INPUT ET DEPOSITS==========================
  //loop over bins in x to define projections  (nbins)
  for(int i=0; i<bincount; i++){

    // make projections of 2D histogram my2DhistoK0S
    histoarrayK0S[i] = (TH1D*)my2DhistoK0S->ProjectionY(Form("tmpK0S%i", i+1), i+1, i+1);
    histoarrayK0SOutOfAcceptance[i] = (TH1D*)my2DhistoK0SOutOfAcceptance->ProjectionY(Form("tmpK0SOutOfAcc%i", i+1), i+1, i+1);
  }


  for(int j=0;j<nbins;j++){
    centbin = j;  
    cout<<"Working on centrality bin "<<centbin<<endl;


    // creates histogram of spectra from thrown K0S
    TH1F *histoSpectrumK0S = new TH1F("histoSpectrumK0S","p_{T} spectrum of K^{0}_{S}",100,0.0,5.0);
    SetStyles(histoSpectrumK0S,"dN/dp_{T}","p_{T} (GeV)", color1, marker1);
    TH1F *histoETspectrumK0S = new TH1F("histoETspectrumK0S","transverse energy scaled of K^{0}_{S}",100,0.0,5.0);
    SetStyles(histoETspectrumK0S,"dN/dE_{T} calculated","E_{T} (GeV)", color2, marker2);
    TH1F *histoETCspectrumK0S = new TH1F("histoETCspectrumK0S","transverse energy scaled from data of K^{0}_{S}",100,0.0,5.0);
    SetStyles(histoETCspectrumK0S,"dN/dE_{T} from data","E_{T} (GeV)", mixcolor, mixmarker);

    // initialize totals
    float totET = 0;               // total ET of K0S's calculated
    float totetcK0S = 0;           // total ET of K0S's from data
    float testTOT = 0;
    float testTOTpt = 0;
    float pK0S = 0;  

    // declare edges of first and last bin
    int mybin100 = my2DhistoK0S->GetXaxis()->FindBin(0.1001);
    int mybin0 = my2DhistoK0S->GetXaxis()->FindBin(0.0001);
  
    //Jacobian correction
  
    TH1F *histoSpectrumK0SJac;
    histoSpectrumK0SJac = (TH1F*)histoSys[centbin]->Clone("Jac");
    SetStyles(histoSpectrumK0SJac,"dN/dp_{T}","p_{T} (GeV)", color1, marker1);

    TH1F *histoSpectrumK0SDivide = (TH1F*)histoSys[centbin]->Clone("JacDiv");

  
//     TH1F *histoeta = new TH1F("histoeta","",100,-1,1);
//     SetStyles(histoeta,"N","#eta", color1, marker1);
  
    //Jacobian Correction 
  
    float NbinsJac = histoSys[centbin]->GetXaxis()->GetNbins(); 
    double mK0SJac = 0.497614;            // mass of K0S (GeV)  
    double nK0s = 1000;
    double deltay =0;
    double deltaeta = 0;
  
  
    TF1 *jacobian = new TF1("jacobian","[0]/TMath::Sqrt([1]*[1]*TMath::Power(TMath::CosH(x),2)+[0]*[0])",-etarange,etarange);
    jacobian->SetParameter(1,0.493);
    //here we're going to come up with a simple model that looks at a non-flat eta dependence.
    //if I assume that the pseudorapidity distribution has the shape y = m|x|+b, I have to normalize by the integral of that function after I take the jacobian so I can get the right weighting.  That integral works out to be
    float m = +0.15;
    float b = 1;
    float renormalization = (m*etarange*etarange)/2+b*etarange;
    TF1 *jacobianReweighted = new TF1("jacobianReweighted","([2]*x+[3])*[4]*[0]/TMath::Sqrt([1]*[1]*TMath::Power(TMath::CosH(x),2)+[0]*[0])",-etarange,etarange);
    jacobianReweighted->SetParameter(1,0.493);
    jacobianReweighted->SetParameter(2,m);
    jacobianReweighted->SetParameter(3,b);
    jacobianReweighted->SetParameter(4,renormalization);
    //==================CAIO'S TOY MODEL FOR JACOBIAN==========================
    float overallAverageJac[5] = {0,0,0,0,0};
    int totK0S = 0;
    for(int a = 1; a<NbinsJac; a ++){
		  
      int count = 0;
      double binContent = histoSys[centbin]->GetBinContent(a);
      double binError = histoSys[centbin]->GetBinError(a);
      jacobian->SetParameter(0,histoSys[centbin]->GetXaxis()->GetBinCenter(a));
      float averageJac = jacobian->Integral(-etarange,etarange) / (2*etarange);
      jacobian->SetParameter(0,histoSys[centbin]->GetXaxis()->GetBinLowEdge(a));
      float lowJac = jacobian->Integral(-etarange,etarange) / (2*etarange);
      jacobian->SetParameter(0,histoSys[centbin]->GetXaxis()->GetBinLowEdge(a+1));
      float highJac = jacobian->Integral(-etarange,etarange) / (2*etarange);
      float eta0Jac = jacobian->Eval(0.0);
      jacobianReweighted->SetParameter(0,histoSys[centbin]->GetXaxis()->GetBinCenter(a));
      float altJac = jacobianReweighted->Integral(-etarange,etarange);
      double correc =1;
		
      double mult = (binContent*correc)*deltay*deltaeta;
      float scale = averageJac;
      switch(whichjacobian){
      case 1:
	scale = averageJac;
      case 2:
	scale = lowJac;
      case 3:
	scale = highJac;
      case 4:
	scale = eta0Jac;
      case 5:
	scale = altJac;
      }
      histoSpectrumK0SJac->SetBinContent(a,scale*binContent);
      histoSpectrumK0SJac->SetBinError(a,scale*binError);
      totK0S += binContent;
      overallAverageJac[0] += averageJac*binContent;
      overallAverageJac[1] += lowJac*binContent;
      overallAverageJac[2] += highJac*binContent;
      overallAverageJac[3] += eta0Jac*binContent;
      overallAverageJac[4] += altJac*binContent;
		
    }
    cEmpty->cd();
    histoSys[centbin]->Draw();
    histoSpectrumK0SJac->Draw("same");
    cEmpty->SaveAs(Form("/tmp/KaonCut%i%s.png",etCutNum,det));
    float minJacobian = overallAverageJac[0]/totK0S;
    float maxJacobian = overallAverageJac[0]/totK0S;
    cout<<"Average jacobians: ";
    for(int i=0;i<=3;i++){
      cout<<" "<< overallAverageJac[i]/totK0S;
      if(minJacobian>overallAverageJac[i]/totK0S) minJacobian = overallAverageJac[i]/totK0S;
      if(maxJacobian<overallAverageJac[i]/totK0S) maxJacobian = overallAverageJac[i]/totK0S;
    }
    cout<<endl;
    float errJacobian = (maxJacobian-minJacobian)/2.0;
    float meanJacobian = (maxJacobian+minJacobian)/2.0;
    cout<<"Jacobian with error "<<meanJacobian<<" +/- "<<errJacobian<<endl;
    cEmpty->cd();
    funcBlastk0Jac[centbin] = FitParticle(histoSpectrumK0SJac,"K0",-1,-1,-1,0,0,3,-1,kFitBlastWave);
    funcBlastk0[centbin]->Draw("same");	  
	
    // gets integral in input K0S histograms for different centrality bins   
    fitINTEGRALdata[centbin] = histoSpectrumK0SJac->Integral("width");

    cout<<"integral of fit for centrality bin "<<centbin<<": "<<fitINTEGRALdata[centbin]<<endl;
    cout<<funcBlastk0Jac[centbin]->Integral(0.0,100.0)<<endl;
    
    //==================END CAIO'S TOY MODEL FOR JACOBIAN==========================
     
    //==================THROWING RANDOM K0S==========================
    float totetcK0SOutOfAcc = 0;
    float totetcK0SOutOfAccCorr = 0;
    float avgCorrOutOfAcc = 0;
  
    //THROW random K0S particle 
    for(int i=0; i<nParticles; i++){
      float mK0S = 0.497614;            // mass of K0S (GeV)
      //You can change funBlastk0 to funBlastk0up or funBlastk0low for systematica error analysis 
      float ptK0S = funcBlastk0Jac[centbin]->GetRandom(); // array? centbin =1
      histoSpectrumK0S->Fill(ptK0S);     
      
      // *******************************************
      float etK0S = sqrt(ptK0S*ptK0S + mK0S*mK0S);          // calculate transverse energy of K0S
      histoETspectrumK0S->Fill(etK0S);
      totET += etK0S;

      int mybinK0S = my2DhistoK0S->GetXaxis()->FindBin(ptK0S);  
      int xbins = my2DhistoK0S->GetNbinsX();

      float scaleForOutOfAcc = hRatioOutOfAccOverInAcc->GetBinContent(hRatioOutOfAccOverInAcc->FindBin(ptK0S));
      //cout<<"Scale for out of acc "<<scaleForOutOfAcc<<endl;
      
      float etcK0S = 0;
      float etcK0SOutOfAcc = 0;
      // get ET projection of K0S and sum
      if(mybinK0S>0 && mybinK0S<=bincount){  //nbins  // then this is in our range
	etcK0S = ((TH1D*)histoarrayK0S.At(mybinK0S-1))->GetRandom();
	etcK0SOutOfAcc = ((TH1D*)histoarrayK0SOutOfAcceptance.At(mybinK0S-1))->GetRandom();
	histoETCspectrumK0S->Fill(etcK0S);
	//here we deal with a problem.  The get random function gets confused for zeros.  It gives a small but non-zero value.  But we can never have a deposit less than the minimum energy!
	//this doesn't mess up the kaons in the 
	if(etCutNum>0 && etK0S<etCutOffs[etCutNum-1]){etK0S = 0.0;}
	if(etCutNum>0 && etcK0SOutOfAcc<etCutOffs[etCutNum-1]){etcK0SOutOfAcc = 0.0;}

	//if(etcK0SOutOfAcc>0){cout<<"et dep "<<etcK0SOutOfAcc<<" scale "<<scaleForOutOfAcc<<" pT "<<ptK0S<<endl;}
	//else{cout<<"No energy deposited"<<endl;}
	//else{cout<<"deposit is not small "<<etcK0SOutOfAcc<<endl;}
      }
      else{cerr<<"Did not find pt bin!"<<endl;}    // this should never be reached
      totetcK0S += etcK0S;
      totetcK0SOutOfAccCorr += etcK0SOutOfAcc*scaleForOutOfAcc; 
      //if(etcK0SOutOfAcc>1e-3) cout<<"Deposit is not small "<<etcK0SOutOfAcc<<" corr "<<scaleForOutOfAcc<<" product "<<totetcK0SOutOfAccCorr<<" total "<<endl;
      totetcK0SOutOfAcc +=etcK0SOutOfAcc;
      avgCorrOutOfAcc += scaleForOutOfAcc;
    }         		  

    // print Calculated and Data projection values of scaled Et for K0S
    cout<<"Total ET observed (before renormalization): "<<(totetcK0S)<<endl;//Total ET observed
    cout<<"Total possible  energy (before renormalization):  "<<totET<<endl;
    cout<<"Average ET observed (simple): "<<(totetcK0S)/nParticles<<endl;
    //cout<<"Average ET observed out of acceptance (simple): "<<(totetcK0SOutOfAcc)/nParticles<<endl;
    //cout<<"Average corr for out of acc (simple): "<<(avgCorrOutOfAcc)/nParticles<<endl;
    //cout<<"ET observed out of acceptance corr (simple): "<<(totetcK0SOutOfAccCorr)<<endl;
    cout<<"Average ET observed out of acceptance corr (simple): "<<(totetcK0SOutOfAccCorr)/nParticles<<endl;

    //Estimating the difference between the number of particles in |eta|<0.5 and our eta range
    //assume the distribution of particles is approximately N=m*|eta|+b
    //if N(eta=0) = 1, b=1
    //The percentage drop/increase in eta over one unit is m
    //The integral from 0-0.5 is
    m = 0.15;
    b = 1;
    float etaspectrameas = 0.5;
    float integralSpectraMeas = m*etaspectrameas*etaspectrameas/2+b*etaspectrameas;
    //and the integral over our range is:
    float integralMeasHigh = m*etarange*etarange/2+b*etarange;
    m = -0.15;
    float integralMeasLow = m*etarange*etarange/2+b*etarange;
    float etaRangeWeightMean = (integralMeasHigh/integralSpectraMeas+integralMeasLow/integralSpectraMeas)/2.0;
    float etaRangeWeightErr = (integralMeasHigh/integralSpectraMeas-integralMeasLow/integralSpectraMeas)/2.0;
    //cout<<" range high "<< integralMeasHigh/integralSpectraMeas<< " range low "<< integralMeasLow/integralSpectraMeas<<endl;
  
    //cout<<"Eta range scale: "<<etaRangeWeightMean<<" +/- "<<etaRangeWeightErr<<endl;

    //getting the final ET:
    //multiply by the dN/dy from the spectra paper (with error)
    //scale by Jacobian with the error on the Jacobian (with error)
    //multiply by the 4 kaon species
    //add an error for the fact that we need to extrapolate to our eta range
    float scale = 4*kaonYield[centbin]*meanJacobian*etaRangeWeightMean;
    float meanETperkaon = (totetcK0S+totetcK0SOutOfAccCorr)/nParticles;
    float meanETperkaonInAcc = (totetcK0S)/nParticles;
    float meanETperkaonOutOfAcc = (totetcK0SOutOfAccCorr)/nParticles;
    //now we're going to allow the ratio of kaons in and out of acceptance to vary by another 20%
    float fracerrFromInOutVariance = 0.2*meanETperkaonOutOfAcc/(meanETperkaonInAcc+meanETperkaonOutOfAcc);
    float fracerr = TMath::Sqrt(TMath::Power(kaonFracErr[centbin],2)+TMath::Power(errJacobian/meanJacobian,2)+TMath::Power(etaRangeWeightErr/etaRangeWeightMean,2));
    float fracerrTotal = TMath::Sqrt(TMath::Power(kaonFracErr[centbin],2)+TMath::Power(errJacobian/meanJacobian,2)+TMath::Power(etaRangeWeightErr/etaRangeWeightMean,2)+TMath::Power(fracerrFromInOutVariance,2));
    cout<<"Errors : Yield: "<<kaonFracErr[centbin]<<" Jacobian "<<errJacobian/meanJacobian<<" eta range "<<etaRangeWeightErr/etaRangeWeightMean<<" InOutVariance "<<fracerrFromInOutVariance<<endl;
    cout<<"Total ET deposited in acc: "<<meanETperkaonInAcc*scale<<" +/- "<<meanETperkaonInAcc*fracerr*scale<<endl;
    cout<<"Total ET deposited out of acc: "<<meanETperkaonOutOfAcc*scale<<" +/- "<<meanETperkaonOutOfAcc*fracerr*scale<<endl;
    cout<<"Total ET deposited: "<<meanETperkaon*scale<<" +/- "<<meanETperkaon*fracerrTotal*scale<<endl;

    kaonDeposits[0][centbin] = meanETperkaon*scale;
    kaonDeposits[1][centbin] = meanETperkaon*scale*fracerrTotal;

    delete histoSpectrumK0S;
    delete histoETspectrumK0S;
    delete histoETCspectrumK0S;
    delete histoSpectrumK0SJac;
    delete histoSpectrumK0SDivide;
    delete jacobian;
    delete jacobianReweighted;
  }


  PrintLatex(etCutNum,det,effCorr); 
}


// function to define canvas characteristics globally
void SetCanvasStyle(TCanvas *c){
  c->SetBorderSize(0);
  c->SetFillColor(0);
  c->SetBorderMode(0);
  c->SetFrameFillColor(0);
  c->SetFrameBorderMode(0);
  c->SetTopMargin(0.0254237);    // 0.04
  c->SetRightMargin(0.0322581);  // 0.04
  c->SetLeftMargin(0.129032);    // 0.181452
  c->SetBottomMargin(0.134409);  
}

// function to define characteristics globally of plots
void SetStyles(TH1 *histo, char *ytitle, char *xtitle, int color, int marker){
  histo->Sumw2();
  histo->GetYaxis()->SetTitle(ytitle);
  histo->GetXaxis()->SetTitle(xtitle);
  histo->SetMarkerColor(color);
  histo->SetLineColor(color);
  histo->SetMarkerStyle(marker);
}


TLegend *GetLegend(float x1, float y1, float x2, float y2){
  TLegend *leg = new TLegend(x1,y1,x2,y2);
  leg->SetBorderSize(0);
  leg->SetTextFont(62);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
  leg->SetTextSize(0.0381356);
  return leg;
}

void Draw(TH1 *data, TF1 *fLevy, TF1 *fBlast, int centbin,char *pid,char *name){
  TCanvas *canvas = new TCanvas("canvas","canvas",500,500);
  SetCanvasStyle(canvas);
  //canvas->SetLogy();
  data->SetTitle("p_{T} spectra of K$^{0}_{S}$ centbin=%i");
  data->GetYaxis()->SetTitle("1/2#pi p_{T} d^2N/dp_{T}dy");
  data->GetXaxis()->SetTitle("p_{T} (GeV)");
  data->GetXaxis()->SetTitleSize(0.05);
  data->GetYaxis()->SetTitleSize(0.05);
  data->GetXaxis()->SetRange(1,data->FindBin(3.5));
  //data->SetMarkerStyle(20);
  data->Draw();
  fLevy->Draw("same");
  fBlast->Draw("same");
  fLevy->SetLineColor(2);
  fBlast->SetLineColor(4);
  TLegend *legend = GetLegend(0.118952,0.120763,0.368952,0.271186);
  legend->AddEntry(data,Form("%s centrality bin %i",pid,centbin),"l");
  legend->AddEntry(fLevy,"Levy Fit");
  legend->AddEntry(fBlast,"BlastWave Fit");
  legend->Draw();
  canvas->SaveAs(Form("pics/%s%i.png",name,centbin));
  delete canvas;
}

void PrintLatex(int etCutNum, char *det,Bool_t effCorr){
  TString cutNumString = Form("%i",etCutNum);
  ofstream myfile;
  TString tag = "";
  if(!effCorr){tag = "NoEffCorr";}
  TString tmpName = Form("datatablesKaonCut%i%s.tex",etCutNum,det);
  myfile.open(tmpName);
  cout<<"Creating "<<tmpName<<endl;

  myfile<<Form("%3.2f",etCutOffs[etCutNum-1]);
  myfile<<"& ";
  //myfile<<"K$^{0}_{S}$  ";
  for(int j=0;j<nbins;j++){
    myfile<<Form("%3.1f $\\pm$ %3.1f",kaonDeposits[0][j],kaonDeposits[1][j]);
    if(j!=nbins-1) myfile<<"& ";
  }
  //myfile<<" & ";
  myfile<<"\\\\%data"<<endl;
  myfile<<endl<<endl;

  myfile.close();
  cout<<"kaonCorr["<<nbins<<"] = {";
  for(int j=0;j<nbins;j++){
    cout<<kaonDeposits[0][j];
    if(j!=nbins-1) cout<<",";
  }
  cout<<"};"<<endl;
  cout<<"kaonError["<<nbins<<"] = {";
  for(int j=0;j<nbins;j++){
    cout<<kaonDeposits[1][j];
    if(j!=nbins-1) cout<<",";
  }
  cout<<"};"<<endl;
  cerr<<"I got here 587"<<endl;
  ofstream myfile2;
  cerr<<"I got here 589"<<endl;
  cerr<<"cut num "<<etCutNum<<" string "<<cutNumString<<endl;
  TString textfilename2 = Form("KaonCut%i%s%s.dat",etCutNum,det,tag.Data());
  //TString textfilename2 = "Kaons"+det+Form("%i",etCutNum)+".dat";
  cerr<<"I got here 590"<<endl;
  cout<<"Creating "<<textfilename2<<endl;
  myfile2.open (textfilename2.Data());
  for(int j=0;j<nbins;j++){
    myfile2<<Form("%2.3f %2.3f",kaonDeposits[0][j],kaonDeposits[1][j])<<endl;
  }
  myfile2.close();
//   ofstream myfile3;
//   TString textfilename2 = Form("KaonCut%i%sShort.dat",etCutNum,det);
//   //TString textfilename = "Kaons"+det+Form("CutNum%i",etCutNum)+"Short.dat";
//   cout<<"Creating "<<textfilename<<endl;
//   myfile3.open (textfilename.Data());
//   int startbin = 0;
//   for(int j=0;j<10;j++){
//     float mean = 0;
//     float err = 0;
//     if(j>1){ 
//       startbin+=2;
//       mean = (kaonDeposits[0][startbin]+kaonDeposits[0][startbin+1])/2.0;
//       err = (kaonDeposits[1][startbin]+kaonDeposits[1][startbin+1])/2.0;
//     }
//     else{
//       mean = kaonDeposits[0][startbin];
//       err = kaonDeposits[1][startbin];
//       startbin++;
//     }
//     myfile3<<Form("%2.3f %2.3f",kaonDeposits[0][j],kaonDeposits[1][j])<<endl;
//   }
//   myfile3.close();

}

void PrintArrays(){
  ofstream myfile;
  myfile.open("arraysv0.dat");

  myfile<<"etk0[2][10] = {";
  for(int i=0;i<2;i++){
    myfile<<"{";
    for(int j=0;j<nbins;j++){
      myfile<<etk0[i][j];
      if(j<nbins-1) myfile<<",";
    }
    myfile<<"}";
    if(i<1) myfile<<",";
  }
  myfile<<"};"<<endl;
  myfile<<endl<<endl; 

  myfile<<"etBlastk0[2][10] = {";
  for(int i=0;i<2;i++){
    myfile<<"{";
    for(int j=0;j<nbins;j++){
      myfile<<etBlastk0[i][j];
      if(j<nbins-1) myfile<<",";
    }
    myfile<<"}";
    if(i<1) myfile<<",";
  }
  myfile<<"};"<<endl;
  myfile<<endl<<endl; 

  myfile<<"etBlastk02D[2][10] = {";
  for(int i=0;i<2;i++){
    myfile<<"{";
    for(int j=0;j<nbins;j++){
      myfile<<etBlastk02D[i][j];
      if(j<nbins-1) myfile<<",";
    }
    myfile<<"}";
    if(i<1) myfile<<",";
  }
  myfile<<"};"<<endl;

  myfile.close();
}



 
	  
	   

 SecondaryK0SJacSys.C:1
 SecondaryK0SJacSys.C:2
 SecondaryK0SJacSys.C:3
 SecondaryK0SJacSys.C:4
 SecondaryK0SJacSys.C:5
 SecondaryK0SJacSys.C:6
 SecondaryK0SJacSys.C:7
 SecondaryK0SJacSys.C:8
 SecondaryK0SJacSys.C:9
 SecondaryK0SJacSys.C:10
 SecondaryK0SJacSys.C:11
 SecondaryK0SJacSys.C:12
 SecondaryK0SJacSys.C:13
 SecondaryK0SJacSys.C:14
 SecondaryK0SJacSys.C:15
 SecondaryK0SJacSys.C:16
 SecondaryK0SJacSys.C:17
 SecondaryK0SJacSys.C:18
 SecondaryK0SJacSys.C:19
 SecondaryK0SJacSys.C:20
 SecondaryK0SJacSys.C:21
 SecondaryK0SJacSys.C:22
 SecondaryK0SJacSys.C:23
 SecondaryK0SJacSys.C:24
 SecondaryK0SJacSys.C:25
 SecondaryK0SJacSys.C:26
 SecondaryK0SJacSys.C:27
 SecondaryK0SJacSys.C:28
 SecondaryK0SJacSys.C:29
 SecondaryK0SJacSys.C:30
 SecondaryK0SJacSys.C:31
 SecondaryK0SJacSys.C:32
 SecondaryK0SJacSys.C:33
 SecondaryK0SJacSys.C:34
 SecondaryK0SJacSys.C:35
 SecondaryK0SJacSys.C:36
 SecondaryK0SJacSys.C:37
 SecondaryK0SJacSys.C:38
 SecondaryK0SJacSys.C:39
 SecondaryK0SJacSys.C:40
 SecondaryK0SJacSys.C:41
 SecondaryK0SJacSys.C:42
 SecondaryK0SJacSys.C:43
 SecondaryK0SJacSys.C:44
 SecondaryK0SJacSys.C:45
 SecondaryK0SJacSys.C:46
 SecondaryK0SJacSys.C:47
 SecondaryK0SJacSys.C:48
 SecondaryK0SJacSys.C:49
 SecondaryK0SJacSys.C:50
 SecondaryK0SJacSys.C:51
 SecondaryK0SJacSys.C:52
 SecondaryK0SJacSys.C:53
 SecondaryK0SJacSys.C:54
 SecondaryK0SJacSys.C:55
 SecondaryK0SJacSys.C:56
 SecondaryK0SJacSys.C:57
 SecondaryK0SJacSys.C:58
 SecondaryK0SJacSys.C:59
 SecondaryK0SJacSys.C:60
 SecondaryK0SJacSys.C:61
 SecondaryK0SJacSys.C:62
 SecondaryK0SJacSys.C:63
 SecondaryK0SJacSys.C:64
 SecondaryK0SJacSys.C:65
 SecondaryK0SJacSys.C:66
 SecondaryK0SJacSys.C:67
 SecondaryK0SJacSys.C:68
 SecondaryK0SJacSys.C:69
 SecondaryK0SJacSys.C:70
 SecondaryK0SJacSys.C:71
 SecondaryK0SJacSys.C:72
 SecondaryK0SJacSys.C:73
 SecondaryK0SJacSys.C:74
 SecondaryK0SJacSys.C:75
 SecondaryK0SJacSys.C:76
 SecondaryK0SJacSys.C:77
 SecondaryK0SJacSys.C:78
 SecondaryK0SJacSys.C:79
 SecondaryK0SJacSys.C:80
 SecondaryK0SJacSys.C:81
 SecondaryK0SJacSys.C:82
 SecondaryK0SJacSys.C:83
 SecondaryK0SJacSys.C:84
 SecondaryK0SJacSys.C:85
 SecondaryK0SJacSys.C:86
 SecondaryK0SJacSys.C:87
 SecondaryK0SJacSys.C:88
 SecondaryK0SJacSys.C:89
 SecondaryK0SJacSys.C:90
 SecondaryK0SJacSys.C:91
 SecondaryK0SJacSys.C:92
 SecondaryK0SJacSys.C:93
 SecondaryK0SJacSys.C:94
 SecondaryK0SJacSys.C:95
 SecondaryK0SJacSys.C:96
 SecondaryK0SJacSys.C:97
 SecondaryK0SJacSys.C:98
 SecondaryK0SJacSys.C:99
 SecondaryK0SJacSys.C:100
 SecondaryK0SJacSys.C:101
 SecondaryK0SJacSys.C:102
 SecondaryK0SJacSys.C:103
 SecondaryK0SJacSys.C:104
 SecondaryK0SJacSys.C:105
 SecondaryK0SJacSys.C:106
 SecondaryK0SJacSys.C:107
 SecondaryK0SJacSys.C:108
 SecondaryK0SJacSys.C:109
 SecondaryK0SJacSys.C:110
 SecondaryK0SJacSys.C:111
 SecondaryK0SJacSys.C:112
 SecondaryK0SJacSys.C:113
 SecondaryK0SJacSys.C:114
 SecondaryK0SJacSys.C:115
 SecondaryK0SJacSys.C:116
 SecondaryK0SJacSys.C:117
 SecondaryK0SJacSys.C:118
 SecondaryK0SJacSys.C:119
 SecondaryK0SJacSys.C:120
 SecondaryK0SJacSys.C:121
 SecondaryK0SJacSys.C:122
 SecondaryK0SJacSys.C:123
 SecondaryK0SJacSys.C:124
 SecondaryK0SJacSys.C:125
 SecondaryK0SJacSys.C:126
 SecondaryK0SJacSys.C:127
 SecondaryK0SJacSys.C:128
 SecondaryK0SJacSys.C:129
 SecondaryK0SJacSys.C:130
 SecondaryK0SJacSys.C:131
 SecondaryK0SJacSys.C:132
 SecondaryK0SJacSys.C:133
 SecondaryK0SJacSys.C:134
 SecondaryK0SJacSys.C:135
 SecondaryK0SJacSys.C:136
 SecondaryK0SJacSys.C:137
 SecondaryK0SJacSys.C:138
 SecondaryK0SJacSys.C:139
 SecondaryK0SJacSys.C:140
 SecondaryK0SJacSys.C:141
 SecondaryK0SJacSys.C:142
 SecondaryK0SJacSys.C:143
 SecondaryK0SJacSys.C:144
 SecondaryK0SJacSys.C:145
 SecondaryK0SJacSys.C:146
 SecondaryK0SJacSys.C:147
 SecondaryK0SJacSys.C:148
 SecondaryK0SJacSys.C:149
 SecondaryK0SJacSys.C:150
 SecondaryK0SJacSys.C:151
 SecondaryK0SJacSys.C:152
 SecondaryK0SJacSys.C:153
 SecondaryK0SJacSys.C:154
 SecondaryK0SJacSys.C:155
 SecondaryK0SJacSys.C:156
 SecondaryK0SJacSys.C:157
 SecondaryK0SJacSys.C:158
 SecondaryK0SJacSys.C:159
 SecondaryK0SJacSys.C:160
 SecondaryK0SJacSys.C:161
 SecondaryK0SJacSys.C:162
 SecondaryK0SJacSys.C:163
 SecondaryK0SJacSys.C:164
 SecondaryK0SJacSys.C:165
 SecondaryK0SJacSys.C:166
 SecondaryK0SJacSys.C:167
 SecondaryK0SJacSys.C:168
 SecondaryK0SJacSys.C:169
 SecondaryK0SJacSys.C:170
 SecondaryK0SJacSys.C:171
 SecondaryK0SJacSys.C:172
 SecondaryK0SJacSys.C:173
 SecondaryK0SJacSys.C:174
 SecondaryK0SJacSys.C:175
 SecondaryK0SJacSys.C:176
 SecondaryK0SJacSys.C:177
 SecondaryK0SJacSys.C:178
 SecondaryK0SJacSys.C:179
 SecondaryK0SJacSys.C:180
 SecondaryK0SJacSys.C:181
 SecondaryK0SJacSys.C:182
 SecondaryK0SJacSys.C:183
 SecondaryK0SJacSys.C:184
 SecondaryK0SJacSys.C:185
 SecondaryK0SJacSys.C:186
 SecondaryK0SJacSys.C:187
 SecondaryK0SJacSys.C:188
 SecondaryK0SJacSys.C:189
 SecondaryK0SJacSys.C:190
 SecondaryK0SJacSys.C:191
 SecondaryK0SJacSys.C:192
 SecondaryK0SJacSys.C:193
 SecondaryK0SJacSys.C:194
 SecondaryK0SJacSys.C:195
 SecondaryK0SJacSys.C:196
 SecondaryK0SJacSys.C:197
 SecondaryK0SJacSys.C:198
 SecondaryK0SJacSys.C:199
 SecondaryK0SJacSys.C:200
 SecondaryK0SJacSys.C:201
 SecondaryK0SJacSys.C:202
 SecondaryK0SJacSys.C:203
 SecondaryK0SJacSys.C:204
 SecondaryK0SJacSys.C:205
 SecondaryK0SJacSys.C:206
 SecondaryK0SJacSys.C:207
 SecondaryK0SJacSys.C:208
 SecondaryK0SJacSys.C:209
 SecondaryK0SJacSys.C:210
 SecondaryK0SJacSys.C:211
 SecondaryK0SJacSys.C:212
 SecondaryK0SJacSys.C:213
 SecondaryK0SJacSys.C:214
 SecondaryK0SJacSys.C:215
 SecondaryK0SJacSys.C:216
 SecondaryK0SJacSys.C:217
 SecondaryK0SJacSys.C:218
 SecondaryK0SJacSys.C:219
 SecondaryK0SJacSys.C:220
 SecondaryK0SJacSys.C:221
 SecondaryK0SJacSys.C:222
 SecondaryK0SJacSys.C:223
 SecondaryK0SJacSys.C:224
 SecondaryK0SJacSys.C:225
 SecondaryK0SJacSys.C:226
 SecondaryK0SJacSys.C:227
 SecondaryK0SJacSys.C:228
 SecondaryK0SJacSys.C:229
 SecondaryK0SJacSys.C:230
 SecondaryK0SJacSys.C:231
 SecondaryK0SJacSys.C:232
 SecondaryK0SJacSys.C:233
 SecondaryK0SJacSys.C:234
 SecondaryK0SJacSys.C:235
 SecondaryK0SJacSys.C:236
 SecondaryK0SJacSys.C:237
 SecondaryK0SJacSys.C:238
 SecondaryK0SJacSys.C:239
 SecondaryK0SJacSys.C:240
 SecondaryK0SJacSys.C:241
 SecondaryK0SJacSys.C:242
 SecondaryK0SJacSys.C:243
 SecondaryK0SJacSys.C:244
 SecondaryK0SJacSys.C:245
 SecondaryK0SJacSys.C:246
 SecondaryK0SJacSys.C:247
 SecondaryK0SJacSys.C:248
 SecondaryK0SJacSys.C:249
 SecondaryK0SJacSys.C:250
 SecondaryK0SJacSys.C:251
 SecondaryK0SJacSys.C:252
 SecondaryK0SJacSys.C:253
 SecondaryK0SJacSys.C:254
 SecondaryK0SJacSys.C:255
 SecondaryK0SJacSys.C:256
 SecondaryK0SJacSys.C:257
 SecondaryK0SJacSys.C:258
 SecondaryK0SJacSys.C:259
 SecondaryK0SJacSys.C:260
 SecondaryK0SJacSys.C:261
 SecondaryK0SJacSys.C:262
 SecondaryK0SJacSys.C:263
 SecondaryK0SJacSys.C:264
 SecondaryK0SJacSys.C:265
 SecondaryK0SJacSys.C:266
 SecondaryK0SJacSys.C:267
 SecondaryK0SJacSys.C:268
 SecondaryK0SJacSys.C:269
 SecondaryK0SJacSys.C:270
 SecondaryK0SJacSys.C:271
 SecondaryK0SJacSys.C:272
 SecondaryK0SJacSys.C:273
 SecondaryK0SJacSys.C:274
 SecondaryK0SJacSys.C:275
 SecondaryK0SJacSys.C:276
 SecondaryK0SJacSys.C:277
 SecondaryK0SJacSys.C:278
 SecondaryK0SJacSys.C:279
 SecondaryK0SJacSys.C:280
 SecondaryK0SJacSys.C:281
 SecondaryK0SJacSys.C:282
 SecondaryK0SJacSys.C:283
 SecondaryK0SJacSys.C:284
 SecondaryK0SJacSys.C:285
 SecondaryK0SJacSys.C:286
 SecondaryK0SJacSys.C:287
 SecondaryK0SJacSys.C:288
 SecondaryK0SJacSys.C:289
 SecondaryK0SJacSys.C:290
 SecondaryK0SJacSys.C:291
 SecondaryK0SJacSys.C:292
 SecondaryK0SJacSys.C:293
 SecondaryK0SJacSys.C:294
 SecondaryK0SJacSys.C:295
 SecondaryK0SJacSys.C:296
 SecondaryK0SJacSys.C:297
 SecondaryK0SJacSys.C:298
 SecondaryK0SJacSys.C:299
 SecondaryK0SJacSys.C:300
 SecondaryK0SJacSys.C:301
 SecondaryK0SJacSys.C:302
 SecondaryK0SJacSys.C:303
 SecondaryK0SJacSys.C:304
 SecondaryK0SJacSys.C:305
 SecondaryK0SJacSys.C:306
 SecondaryK0SJacSys.C:307
 SecondaryK0SJacSys.C:308
 SecondaryK0SJacSys.C:309
 SecondaryK0SJacSys.C:310
 SecondaryK0SJacSys.C:311
 SecondaryK0SJacSys.C:312
 SecondaryK0SJacSys.C:313
 SecondaryK0SJacSys.C:314
 SecondaryK0SJacSys.C:315
 SecondaryK0SJacSys.C:316
 SecondaryK0SJacSys.C:317
 SecondaryK0SJacSys.C:318
 SecondaryK0SJacSys.C:319
 SecondaryK0SJacSys.C:320
 SecondaryK0SJacSys.C:321
 SecondaryK0SJacSys.C:322
 SecondaryK0SJacSys.C:323
 SecondaryK0SJacSys.C:324
 SecondaryK0SJacSys.C:325
 SecondaryK0SJacSys.C:326
 SecondaryK0SJacSys.C:327
 SecondaryK0SJacSys.C:328
 SecondaryK0SJacSys.C:329
 SecondaryK0SJacSys.C:330
 SecondaryK0SJacSys.C:331
 SecondaryK0SJacSys.C:332
 SecondaryK0SJacSys.C:333
 SecondaryK0SJacSys.C:334
 SecondaryK0SJacSys.C:335
 SecondaryK0SJacSys.C:336
 SecondaryK0SJacSys.C:337
 SecondaryK0SJacSys.C:338
 SecondaryK0SJacSys.C:339
 SecondaryK0SJacSys.C:340
 SecondaryK0SJacSys.C:341
 SecondaryK0SJacSys.C:342
 SecondaryK0SJacSys.C:343
 SecondaryK0SJacSys.C:344
 SecondaryK0SJacSys.C:345
 SecondaryK0SJacSys.C:346
 SecondaryK0SJacSys.C:347
 SecondaryK0SJacSys.C:348
 SecondaryK0SJacSys.C:349
 SecondaryK0SJacSys.C:350
 SecondaryK0SJacSys.C:351
 SecondaryK0SJacSys.C:352
 SecondaryK0SJacSys.C:353
 SecondaryK0SJacSys.C:354
 SecondaryK0SJacSys.C:355
 SecondaryK0SJacSys.C:356
 SecondaryK0SJacSys.C:357
 SecondaryK0SJacSys.C:358
 SecondaryK0SJacSys.C:359
 SecondaryK0SJacSys.C:360
 SecondaryK0SJacSys.C:361
 SecondaryK0SJacSys.C:362
 SecondaryK0SJacSys.C:363
 SecondaryK0SJacSys.C:364
 SecondaryK0SJacSys.C:365
 SecondaryK0SJacSys.C:366
 SecondaryK0SJacSys.C:367
 SecondaryK0SJacSys.C:368
 SecondaryK0SJacSys.C:369
 SecondaryK0SJacSys.C:370
 SecondaryK0SJacSys.C:371
 SecondaryK0SJacSys.C:372
 SecondaryK0SJacSys.C:373
 SecondaryK0SJacSys.C:374
 SecondaryK0SJacSys.C:375
 SecondaryK0SJacSys.C:376
 SecondaryK0SJacSys.C:377
 SecondaryK0SJacSys.C:378
 SecondaryK0SJacSys.C:379
 SecondaryK0SJacSys.C:380
 SecondaryK0SJacSys.C:381
 SecondaryK0SJacSys.C:382
 SecondaryK0SJacSys.C:383
 SecondaryK0SJacSys.C:384
 SecondaryK0SJacSys.C:385
 SecondaryK0SJacSys.C:386
 SecondaryK0SJacSys.C:387
 SecondaryK0SJacSys.C:388
 SecondaryK0SJacSys.C:389
 SecondaryK0SJacSys.C:390
 SecondaryK0SJacSys.C:391
 SecondaryK0SJacSys.C:392
 SecondaryK0SJacSys.C:393
 SecondaryK0SJacSys.C:394
 SecondaryK0SJacSys.C:395
 SecondaryK0SJacSys.C:396
 SecondaryK0SJacSys.C:397
 SecondaryK0SJacSys.C:398
 SecondaryK0SJacSys.C:399
 SecondaryK0SJacSys.C:400
 SecondaryK0SJacSys.C:401
 SecondaryK0SJacSys.C:402
 SecondaryK0SJacSys.C:403
 SecondaryK0SJacSys.C:404
 SecondaryK0SJacSys.C:405
 SecondaryK0SJacSys.C:406
 SecondaryK0SJacSys.C:407
 SecondaryK0SJacSys.C:408
 SecondaryK0SJacSys.C:409
 SecondaryK0SJacSys.C:410
 SecondaryK0SJacSys.C:411
 SecondaryK0SJacSys.C:412
 SecondaryK0SJacSys.C:413
 SecondaryK0SJacSys.C:414
 SecondaryK0SJacSys.C:415
 SecondaryK0SJacSys.C:416
 SecondaryK0SJacSys.C:417
 SecondaryK0SJacSys.C:418
 SecondaryK0SJacSys.C:419
 SecondaryK0SJacSys.C:420
 SecondaryK0SJacSys.C:421
 SecondaryK0SJacSys.C:422
 SecondaryK0SJacSys.C:423
 SecondaryK0SJacSys.C:424
 SecondaryK0SJacSys.C:425
 SecondaryK0SJacSys.C:426
 SecondaryK0SJacSys.C:427
 SecondaryK0SJacSys.C:428
 SecondaryK0SJacSys.C:429
 SecondaryK0SJacSys.C:430
 SecondaryK0SJacSys.C:431
 SecondaryK0SJacSys.C:432
 SecondaryK0SJacSys.C:433
 SecondaryK0SJacSys.C:434
 SecondaryK0SJacSys.C:435
 SecondaryK0SJacSys.C:436
 SecondaryK0SJacSys.C:437
 SecondaryK0SJacSys.C:438
 SecondaryK0SJacSys.C:439
 SecondaryK0SJacSys.C:440
 SecondaryK0SJacSys.C:441
 SecondaryK0SJacSys.C:442
 SecondaryK0SJacSys.C:443
 SecondaryK0SJacSys.C:444
 SecondaryK0SJacSys.C:445
 SecondaryK0SJacSys.C:446
 SecondaryK0SJacSys.C:447
 SecondaryK0SJacSys.C:448
 SecondaryK0SJacSys.C:449
 SecondaryK0SJacSys.C:450
 SecondaryK0SJacSys.C:451
 SecondaryK0SJacSys.C:452
 SecondaryK0SJacSys.C:453
 SecondaryK0SJacSys.C:454
 SecondaryK0SJacSys.C:455
 SecondaryK0SJacSys.C:456
 SecondaryK0SJacSys.C:457
 SecondaryK0SJacSys.C:458
 SecondaryK0SJacSys.C:459
 SecondaryK0SJacSys.C:460
 SecondaryK0SJacSys.C:461
 SecondaryK0SJacSys.C:462
 SecondaryK0SJacSys.C:463
 SecondaryK0SJacSys.C:464
 SecondaryK0SJacSys.C:465
 SecondaryK0SJacSys.C:466
 SecondaryK0SJacSys.C:467
 SecondaryK0SJacSys.C:468
 SecondaryK0SJacSys.C:469
 SecondaryK0SJacSys.C:470
 SecondaryK0SJacSys.C:471
 SecondaryK0SJacSys.C:472
 SecondaryK0SJacSys.C:473
 SecondaryK0SJacSys.C:474
 SecondaryK0SJacSys.C:475
 SecondaryK0SJacSys.C:476
 SecondaryK0SJacSys.C:477
 SecondaryK0SJacSys.C:478
 SecondaryK0SJacSys.C:479
 SecondaryK0SJacSys.C:480
 SecondaryK0SJacSys.C:481
 SecondaryK0SJacSys.C:482
 SecondaryK0SJacSys.C:483
 SecondaryK0SJacSys.C:484
 SecondaryK0SJacSys.C:485
 SecondaryK0SJacSys.C:486
 SecondaryK0SJacSys.C:487
 SecondaryK0SJacSys.C:488
 SecondaryK0SJacSys.C:489
 SecondaryK0SJacSys.C:490
 SecondaryK0SJacSys.C:491
 SecondaryK0SJacSys.C:492
 SecondaryK0SJacSys.C:493
 SecondaryK0SJacSys.C:494
 SecondaryK0SJacSys.C:495
 SecondaryK0SJacSys.C:496
 SecondaryK0SJacSys.C:497
 SecondaryK0SJacSys.C:498
 SecondaryK0SJacSys.C:499
 SecondaryK0SJacSys.C:500
 SecondaryK0SJacSys.C:501
 SecondaryK0SJacSys.C:502
 SecondaryK0SJacSys.C:503
 SecondaryK0SJacSys.C:504
 SecondaryK0SJacSys.C:505
 SecondaryK0SJacSys.C:506
 SecondaryK0SJacSys.C:507
 SecondaryK0SJacSys.C:508
 SecondaryK0SJacSys.C:509
 SecondaryK0SJacSys.C:510
 SecondaryK0SJacSys.C:511
 SecondaryK0SJacSys.C:512
 SecondaryK0SJacSys.C:513
 SecondaryK0SJacSys.C:514
 SecondaryK0SJacSys.C:515
 SecondaryK0SJacSys.C:516
 SecondaryK0SJacSys.C:517
 SecondaryK0SJacSys.C:518
 SecondaryK0SJacSys.C:519
 SecondaryK0SJacSys.C:520
 SecondaryK0SJacSys.C:521
 SecondaryK0SJacSys.C:522
 SecondaryK0SJacSys.C:523
 SecondaryK0SJacSys.C:524
 SecondaryK0SJacSys.C:525
 SecondaryK0SJacSys.C:526
 SecondaryK0SJacSys.C:527
 SecondaryK0SJacSys.C:528
 SecondaryK0SJacSys.C:529
 SecondaryK0SJacSys.C:530
 SecondaryK0SJacSys.C:531
 SecondaryK0SJacSys.C:532
 SecondaryK0SJacSys.C:533
 SecondaryK0SJacSys.C:534
 SecondaryK0SJacSys.C:535
 SecondaryK0SJacSys.C:536
 SecondaryK0SJacSys.C:537
 SecondaryK0SJacSys.C:538
 SecondaryK0SJacSys.C:539
 SecondaryK0SJacSys.C:540
 SecondaryK0SJacSys.C:541
 SecondaryK0SJacSys.C:542
 SecondaryK0SJacSys.C:543
 SecondaryK0SJacSys.C:544
 SecondaryK0SJacSys.C:545
 SecondaryK0SJacSys.C:546
 SecondaryK0SJacSys.C:547
 SecondaryK0SJacSys.C:548
 SecondaryK0SJacSys.C:549
 SecondaryK0SJacSys.C:550
 SecondaryK0SJacSys.C:551
 SecondaryK0SJacSys.C:552
 SecondaryK0SJacSys.C:553
 SecondaryK0SJacSys.C:554
 SecondaryK0SJacSys.C:555
 SecondaryK0SJacSys.C:556
 SecondaryK0SJacSys.C:557
 SecondaryK0SJacSys.C:558
 SecondaryK0SJacSys.C:559
 SecondaryK0SJacSys.C:560
 SecondaryK0SJacSys.C:561
 SecondaryK0SJacSys.C:562
 SecondaryK0SJacSys.C:563
 SecondaryK0SJacSys.C:564
 SecondaryK0SJacSys.C:565
 SecondaryK0SJacSys.C:566
 SecondaryK0SJacSys.C:567
 SecondaryK0SJacSys.C:568
 SecondaryK0SJacSys.C:569
 SecondaryK0SJacSys.C:570
 SecondaryK0SJacSys.C:571
 SecondaryK0SJacSys.C:572
 SecondaryK0SJacSys.C:573
 SecondaryK0SJacSys.C:574
 SecondaryK0SJacSys.C:575
 SecondaryK0SJacSys.C:576
 SecondaryK0SJacSys.C:577
 SecondaryK0SJacSys.C:578
 SecondaryK0SJacSys.C:579
 SecondaryK0SJacSys.C:580
 SecondaryK0SJacSys.C:581
 SecondaryK0SJacSys.C:582
 SecondaryK0SJacSys.C:583
 SecondaryK0SJacSys.C:584
 SecondaryK0SJacSys.C:585
 SecondaryK0SJacSys.C:586
 SecondaryK0SJacSys.C:587
 SecondaryK0SJacSys.C:588
 SecondaryK0SJacSys.C:589
 SecondaryK0SJacSys.C:590
 SecondaryK0SJacSys.C:591
 SecondaryK0SJacSys.C:592
 SecondaryK0SJacSys.C:593
 SecondaryK0SJacSys.C:594
 SecondaryK0SJacSys.C:595
 SecondaryK0SJacSys.C:596
 SecondaryK0SJacSys.C:597
 SecondaryK0SJacSys.C:598
 SecondaryK0SJacSys.C:599
 SecondaryK0SJacSys.C:600
 SecondaryK0SJacSys.C:601
 SecondaryK0SJacSys.C:602
 SecondaryK0SJacSys.C:603
 SecondaryK0SJacSys.C:604
 SecondaryK0SJacSys.C:605
 SecondaryK0SJacSys.C:606
 SecondaryK0SJacSys.C:607
 SecondaryK0SJacSys.C:608
 SecondaryK0SJacSys.C:609
 SecondaryK0SJacSys.C:610
 SecondaryK0SJacSys.C:611
 SecondaryK0SJacSys.C:612
 SecondaryK0SJacSys.C:613
 SecondaryK0SJacSys.C:614
 SecondaryK0SJacSys.C:615
 SecondaryK0SJacSys.C:616
 SecondaryK0SJacSys.C:617
 SecondaryK0SJacSys.C:618
 SecondaryK0SJacSys.C:619
 SecondaryK0SJacSys.C:620
 SecondaryK0SJacSys.C:621
 SecondaryK0SJacSys.C:622
 SecondaryK0SJacSys.C:623
 SecondaryK0SJacSys.C:624
 SecondaryK0SJacSys.C:625
 SecondaryK0SJacSys.C:626
 SecondaryK0SJacSys.C:627
 SecondaryK0SJacSys.C:628
 SecondaryK0SJacSys.C:629
 SecondaryK0SJacSys.C:630
 SecondaryK0SJacSys.C:631
 SecondaryK0SJacSys.C:632
 SecondaryK0SJacSys.C:633
 SecondaryK0SJacSys.C:634
 SecondaryK0SJacSys.C:635
 SecondaryK0SJacSys.C:636
 SecondaryK0SJacSys.C:637
 SecondaryK0SJacSys.C:638
 SecondaryK0SJacSys.C:639
 SecondaryK0SJacSys.C:640
 SecondaryK0SJacSys.C:641
 SecondaryK0SJacSys.C:642
 SecondaryK0SJacSys.C:643
 SecondaryK0SJacSys.C:644
 SecondaryK0SJacSys.C:645
 SecondaryK0SJacSys.C:646
 SecondaryK0SJacSys.C:647
 SecondaryK0SJacSys.C:648
 SecondaryK0SJacSys.C:649
 SecondaryK0SJacSys.C:650
 SecondaryK0SJacSys.C:651
 SecondaryK0SJacSys.C:652
 SecondaryK0SJacSys.C:653
 SecondaryK0SJacSys.C:654
 SecondaryK0SJacSys.C:655
 SecondaryK0SJacSys.C:656
 SecondaryK0SJacSys.C:657
 SecondaryK0SJacSys.C:658
 SecondaryK0SJacSys.C:659
 SecondaryK0SJacSys.C:660
 SecondaryK0SJacSys.C:661
 SecondaryK0SJacSys.C:662
 SecondaryK0SJacSys.C:663
 SecondaryK0SJacSys.C:664
 SecondaryK0SJacSys.C:665
 SecondaryK0SJacSys.C:666
 SecondaryK0SJacSys.C:667
 SecondaryK0SJacSys.C:668
 SecondaryK0SJacSys.C:669
 SecondaryK0SJacSys.C:670
 SecondaryK0SJacSys.C:671
 SecondaryK0SJacSys.C:672
 SecondaryK0SJacSys.C:673
 SecondaryK0SJacSys.C:674
 SecondaryK0SJacSys.C:675
 SecondaryK0SJacSys.C:676
 SecondaryK0SJacSys.C:677
 SecondaryK0SJacSys.C:678
 SecondaryK0SJacSys.C:679
 SecondaryK0SJacSys.C:680
 SecondaryK0SJacSys.C:681
 SecondaryK0SJacSys.C:682
 SecondaryK0SJacSys.C:683
 SecondaryK0SJacSys.C:684
 SecondaryK0SJacSys.C:685
 SecondaryK0SJacSys.C:686
 SecondaryK0SJacSys.C:687
 SecondaryK0SJacSys.C:688