#ifndef SINGLETOPDPDMAKER_PDFTREEMAKER_H
#define SINGLETOPDPDMAKER_PDFTREEMAKER_H

/********************************************************************

NAME:     PdfTreeMaker.h
PACKAGE:  offline/PhysicsAnalysis/TopPhys/SingleTopDPDMaker/

AUTHOR:   Clemens Lange <clemens.lange@SPAMNOTdesy.de>
CREATED:  October 2009

EDITED :  --

PURPOSE:  SingleTopDPDMaker Tool that inserts PdfInfo using two 
          different methods for mc08 and mc09.
          mc09: uses genEvt->pdf_info()
          mc08: as pdf_info not available, fall-back method fills
                first two partons (usually barcode 3 & 4) from 
                TruthParticleContainer

********************************************************************/

#include <string>

#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ITHistSvc.h"
#include "StoreGate/StoreGate.h"

#include "McParticleEvent/TruthParticleContainer.h"
#include "McParticleEvent/TruthParticle.h"
// #include "McParticleEvent/TruthParticleParamDefs.h"

#include "GeneratorObjects/McEventCollection.h"
#include "HepMC/GenEvent.h"
// #include "HepMC/WeightContainer.h"

#include "TTree.h"

class PdfTreeMaker : public Algorithm
{

public:

  PdfTreeMaker(const std::string& name, ISvcLocator* pSvcLocator);
  virtual ~PdfTreeMaker();
  
  StatusCode initialize();
  StatusCode finalize();
  StatusCode execute();
    
  void SetBranches();
  void ClearBranches();
  void FillBranches();
  void DeleteBranches();
    
private:

  StoreGateSvc * m_StoreGateSvc;
  ITHistSvc    * m_THistSvc;
  TTree        * m_Tree;
  
  int m_InputEventNumber;
          
  // jobOptions
  std::string m_TreeName;
  std::string m_McEventContainerName;
  std::string m_TruthParticleContainerName;
  std::string m_PdfMethod;
  std::vector<double> m_Mc08_barcode;
  std::vector<double> m_Mc08_pdgId;
                    
  // containers
  const McEventCollection * m_McEventContainer;
  const TruthParticleContainer * m_TruthParticleContainer;
  
  // internal sets, because declareProperty doesn't know sets
  std::set<double> m_set_Mc08_barcode;
  std::set<double> m_set_Mc08_pdgId;
  
  // genEvent pdfInfo variables (mc09)
  int m_id1;        // flavour code of first parton
  int m_id2;        // flavour code of second parton 
  double m_x1;      // fraction of beam momentum carried by first parton ("beam side") 
  double m_x2;      // fraction of beam momentum carried by second parton ("target side") 
  double m_scalePDF;  //  Q-scale used in evaluation of PDF's   (in GeV) 
   
  // fall-back method for mc08 samples
  std::vector<double>* m_InitialParton_px;
  std::vector<double>* m_InitialParton_py;
  std::vector<double>* m_InitialParton_pz;
  std::vector<double>* m_InitialParton_pt;
  std::vector<double>* m_InitialParton_e;
  std::vector<double>* m_InitialParton_pdgId;
  std::vector<double>* m_InitialParton_barcode;
  int m_InitialParton_N;
  
              
};

#endif







