//  
// Author:  <mailto: kind@mail.desy.de>
// Update: $Id: AtlBDecayGenTool.h,v 1.9 2017/09/28 14:23:11 mergelm Exp $
// Copyright: 2017 (C) 
//
#ifndef ATLAS_AtlBDecayGenTool
#define ATLAS_AtlBDecayGenTool
#ifndef ATLAS_AtlAnalysisTool
#include <AtlAnalysisTool.h>
#endif
#ifndef ATLAS_AtlSelector
#include <AtlSelector.h>
#endif
#ifndef HEP_HepParticle
#include <HepParticle.h>
#endif

class TH2D;
class TRandom;
class TList;

class AtlBDecayGenTool : public AtlAnalysisTool {

  public:
    static const Int_t fgNDSIDsMax = 256;
    enum EBJetMode {
	kRandom, // Pick parent b-jets randomly
	kLowPt,  // Pick b-jet with lowest Pt as parent jet
	kHighPt, // Pick b-jet with highest Pt as parent jet
	kHalfRandom, // Randomly fluctuate between kLowPt and kRandom
	kNBJetModes
    };
    
  public:
    const char* fValidDSIDs;       // Comma separated list of valid DSID numbers for which the tool will be enabled; for all other samples the won't run
    Bool_t      fDoOverlapRemoval; // Perform overlap removal of accompanying b-jet (default=true)
    Bool_t      fRequireOverlapRemoval; // Reject event if overlap removal fails
    Float_t     fORdeltaR_max;     // Maximum deltaR used for the overlap removal (default=0.4)
    EBJetMode   fBJetMode;         // Define how to pick the parent b-jet in case of more than one b-jets (default=random)
    
  private:
    Int_t     fNDSIDs;            // Number of given valid DSIDs
    UInt_t    fDSID[fgNDSIDsMax]; // Array of valid DSID numbers
    Bool_t    fFirstEvt;          // First event ?
    TH2D     *fHistGen;           // Histogram for decay angle / energy generation
    TRandom  *fRandom;            // Random generator
    TList    *fJets;              // List of jets
    TList    *fBJets;             // List of b-jets
    TList    *fElectrons;         // List of electrons
    TList    *fMuons;             // List of muons
    TList    *fLeptons;           // List of leptons
    TH1F     *fHistDeltaR;        // Histogram of deltaR between the generated lepton and its parent jet
    TH1F     *fHistAlphaLoc;      // Histogram of alpha, local
    TH1F     *fHistPhiLoc;        // Histogram of phi, local
    TH1F     *fHistPzLoc;         // Histogram of Pz, local
    TH1F     *fHistPtLoc;         // Histogram of Pt, local
    TH1F     *fHistPmagLoc;       // Histogram of P magnitude, local
    TH1F     *fHistAlphaLab;      // Histogram of alpha, lab frame
    TH1F     *fHistEtaLab;        // Histogram of eta, lab frame
    TH1F     *fHistPhiLab;        // Histogram of phi, lab frame
    TH1F     *fHistPzLab;         // Histogram of Pz, lab frame
    TH1F     *fHistPtLab;         // Histogram of Pt, lab frame
    TH1F     *fHistPmagLab;       // Histogram of P magnitude, lab frame
    
  public:
    AtlBDecayGenTool(const char* name, const char* title);
    virtual ~AtlBDecayGenTool();

    const char* GetBJetModeName(AtlBDecayGenTool::EBJetMode BJetMode) const;
    
protected:
    virtual Bool_t AnalyzeEvent();
    virtual void   Init();
    virtual void   BookHistograms();
    virtual void   FillHistograms() {;}
    virtual void   SetBranchStatus();
    virtual void   SetCutDefaults();
    virtual void   Print() const;
    virtual void   Terminate();    
    
private:
    void SetDSIDArray();
    void CreateHistGen();
    HepParticle* GenerateBDecay(TLorentzVector p_mother, HepParticle *lep);
    Bool_t AddLeptons();
    
    ClassDef(AtlBDecayGenTool,0) // Tool for semileptonic B-meson decay generation
};
#endif

 AtlBDecayGenTool.h:1
 AtlBDecayGenTool.h:2
 AtlBDecayGenTool.h:3
 AtlBDecayGenTool.h:4
 AtlBDecayGenTool.h:5
 AtlBDecayGenTool.h:6
 AtlBDecayGenTool.h:7
 AtlBDecayGenTool.h:8
 AtlBDecayGenTool.h:9
 AtlBDecayGenTool.h:10
 AtlBDecayGenTool.h:11
 AtlBDecayGenTool.h:12
 AtlBDecayGenTool.h:13
 AtlBDecayGenTool.h:14
 AtlBDecayGenTool.h:15
 AtlBDecayGenTool.h:16
 AtlBDecayGenTool.h:17
 AtlBDecayGenTool.h:18
 AtlBDecayGenTool.h:19
 AtlBDecayGenTool.h:20
 AtlBDecayGenTool.h:21
 AtlBDecayGenTool.h:22
 AtlBDecayGenTool.h:23
 AtlBDecayGenTool.h:24
 AtlBDecayGenTool.h:25
 AtlBDecayGenTool.h:26
 AtlBDecayGenTool.h:27
 AtlBDecayGenTool.h:28
 AtlBDecayGenTool.h:29
 AtlBDecayGenTool.h:30
 AtlBDecayGenTool.h:31
 AtlBDecayGenTool.h:32
 AtlBDecayGenTool.h:33
 AtlBDecayGenTool.h:34
 AtlBDecayGenTool.h:35
 AtlBDecayGenTool.h:36
 AtlBDecayGenTool.h:37
 AtlBDecayGenTool.h:38
 AtlBDecayGenTool.h:39
 AtlBDecayGenTool.h:40
 AtlBDecayGenTool.h:41
 AtlBDecayGenTool.h:42
 AtlBDecayGenTool.h:43
 AtlBDecayGenTool.h:44
 AtlBDecayGenTool.h:45
 AtlBDecayGenTool.h:46
 AtlBDecayGenTool.h:47
 AtlBDecayGenTool.h:48
 AtlBDecayGenTool.h:49
 AtlBDecayGenTool.h:50
 AtlBDecayGenTool.h:51
 AtlBDecayGenTool.h:52
 AtlBDecayGenTool.h:53
 AtlBDecayGenTool.h:54
 AtlBDecayGenTool.h:55
 AtlBDecayGenTool.h:56
 AtlBDecayGenTool.h:57
 AtlBDecayGenTool.h:58
 AtlBDecayGenTool.h:59
 AtlBDecayGenTool.h:60
 AtlBDecayGenTool.h:61
 AtlBDecayGenTool.h:62
 AtlBDecayGenTool.h:63
 AtlBDecayGenTool.h:64
 AtlBDecayGenTool.h:65
 AtlBDecayGenTool.h:66
 AtlBDecayGenTool.h:67
 AtlBDecayGenTool.h:68
 AtlBDecayGenTool.h:69
 AtlBDecayGenTool.h:70
 AtlBDecayGenTool.h:71
 AtlBDecayGenTool.h:72
 AtlBDecayGenTool.h:73
 AtlBDecayGenTool.h:74
 AtlBDecayGenTool.h:75
 AtlBDecayGenTool.h:76
 AtlBDecayGenTool.h:77
 AtlBDecayGenTool.h:78
 AtlBDecayGenTool.h:79
 AtlBDecayGenTool.h:80
 AtlBDecayGenTool.h:81
 AtlBDecayGenTool.h:82
 AtlBDecayGenTool.h:83
 AtlBDecayGenTool.h:84
 AtlBDecayGenTool.h:85
 AtlBDecayGenTool.h:86
 AtlBDecayGenTool.h:87
 AtlBDecayGenTool.h:88
 AtlBDecayGenTool.h:89
 AtlBDecayGenTool.h:90