#define MAXPARAMETER 28

TNtuple *makeBhwNtuple(const Char_t *fileName,bool oldFile=0) {

  cout << "makeBhwNtuple from: " << fileName << endl;
  if (oldFile){
    Int_t   iParameters = 17;
    TString fileStructure = TString("e:se:sp:be:bp:isr:tot:px1:py1:pz1:e1:px2:py2:pz2:e2:nzpos:nzneg");

  }
  else {
    Int_t   iParameters = 21;
    TString fileStructure = TString("e:se:sp:be:bp:isr:tot:px1:py1:pz1:e1:px2:py2:pz2:e2:nzpos:nzneg:gx:gy:gz:ge");
  }

  //| e | beamspread e- | beamspread e+
  //| beamstrahlung e-| beamstrahlung e+
  //| isr | total
  //| px e-| py e- | pz e- | energy e- 
  //| px e+| py e+ | pz e+ | energy e+
  //| n gamma +z | n gamma -z|
  //| px gammas | py gammas | pz gammas y | energy gammas |

  TString ntupleName = TString("bhwide");
  TString ntupleTitle = TString("bhwide");

  ifstream ifstr(fileName,ios::in);

  if(!ifstr) {
    cout << "makeBhwNtuple> Could not open file" << endl;
  }

  // ntuple instance
  TNtuple *nt = new TNtuple(ntupleName.Data(),ntupleTitle.Data(),fileStructure.Data());

  // reset input values
  Float_t dInputValues[MAXPARAMETER];
  for(Int_t i=0;i<MAXPARAMETER;i++) {
    dInputValues[i] = 0;
  }

  ifstream ifstr(fileName,ios::in);
  Int_t iEntry = 0;
  while(ifstr) {
    for(Int_t i=0;i<iParameters;i++) {
      ifstr >> dInputValues[i];
    }
    nt->Fill(dInputValues);
    iEntry++;
  }

  return nt;
}