//____________________________________________________________________
//
// Atlas Top Pair Item
//

// Author: Felix Thomas <mailto: Felix.Thomas@mailbox.tu-dresden.de>
// Update: $Id: AtlTopPair.cxx,v 1.3 2011/12/16 10:37:59 fthomas Exp $
// Copyright: 2011 (C) Felix Thomas
//
//  This class records the top decays that belong to a given reconstructed
//  top pair.
//
//
//
//

#ifndef ATLAS_AtlTopPair
#include <AtlTopPair.h>
#endif
#include <iostream>
#include <TMath.h>

using namespace std;

#ifndef __CINT__
ClassImp(AtlTopPair);
#endif


//____________________________________________________________________

AtlTopPair::AtlTopPair() {
    //
    // Default constructor
    //

    fTop1 = new TRef;   
    fTop2 = new TRef;   
    fId       = 0;
    fChi2     = 0;
    fNdof     = 0;     
    fChi2Prob = 0; 
    fType     = AtlTopPair::kInvalid;
    
    InitPulls();
    
}

//____________________________________________________________________

AtlTopPair::AtlTopPair(Int_t Id, HepTopDecay* top1, HepTopDecay* top2, 
                                  Double_t chi2, Int_t ndof, AtlTopPair::EType type){
    //
    // Custom constructor
    //

  fTop1 = new TRef;
  fTop2 = new TRef;
  *fTop1 = (TObject*)top1;
  *fTop2 = (TObject*)top2;
  fId   = Id;
  fChi2 = chi2;
  fNdof = ndof;
  fChi2Prob =  TMath::Prob(chi2, ndof);  
  fType = type;

  InitPulls();

}

//____________________________________________________________________

void AtlTopPair::InitPulls(){
  
  fChargedLeptonPull.ResizeTo(3,1);
  fNeutrinoPull.ResizeTo(3,1);
  fLepBJetPull.ResizeTo(3,1);
  fHadJet1Pull.ResizeTo(3,1);
  fHadJet2Pull.ResizeTo(3,1);
  fHadBJetPull.ResizeTo(3,1);
    
  fChargedLeptonPull.Zero();
  fNeutrinoPull.Zero();
  fLepBJetPull.Zero();
  fHadJet1Pull.Zero();
  fHadJet2Pull.Zero();
  fHadBJetPull.Zero();
  
}

//____________________________________________________________________

AtlTopPair::~AtlTopPair() {
    //
    // Default destructor
    //

  delete fTop1; fTop1 = 0;
  delete fTop2; fTop2 = 0;  

}

//____________________________________________________________________

void AtlTopPair::Clear(Option_t *option) {
    //
    // Clear this object
    //


    delete fTop1; fTop1 = 0;
    delete fTop2; fTop2 = 0;  
    fId       = 0;
    fChi2     = 0;
    fNdof     = 0;     
    fChi2Prob = 0; 
    fType     = kInvalid;

}


//____________________________________________________________________

HepTopDecay* AtlTopPair::GetLeptonicTop() const {
    //
    // retrieving the leptonic top
    //
  
  if (((HepTopDecay*)fTop1->GetObject())->IsSemiLeptonicDecay() == kTRUE) return (HepTopDecay*)fTop1->GetObject();
  if (((HepTopDecay*)fTop2->GetObject())->IsSemiLeptonicDecay() == kTRUE) return (HepTopDecay*)fTop2->GetObject();  

  return 0;
}

//____________________________________________________________________

HepTopDecay* AtlTopPair::GetHadronicTop() const {
    //
    // retrieving the hadronic top
    //
  
  if (((HepTopDecay*)fTop1->GetObject())->IsHadronicDecay() == kTRUE) return (HepTopDecay*)fTop1->GetObject();
  if (((HepTopDecay*)fTop2->GetObject())->IsHadronicDecay() == kTRUE) return (HepTopDecay*)fTop2->GetObject();  

  return 0;
}
//____________________________________________________________________

void AtlTopPair::SetPullMatrices(TMatrixD leptonpull, TMatrixD neutrinopull, TMatrixD lepbjetpull,
                                 TMatrixD hadjet1pull, TMatrixD hadjet2pull, TMatrixD hadbjetpull){
                                     
  fChargedLeptonPull = leptonpull;
  fNeutrinoPull = neutrinopull;
  fLepBJetPull = lepbjetpull;
  fHadJet1Pull = hadjet1pull;
  fHadJet2Pull = hadjet2pull;
  fHadBJetPull = hadbjetpull;                            
  
}


//____________________________________________________________________

void AtlTopPair::Print(Option_t *option) const {
    //
    // Print object information
    //

    ((HepTopDecay*)fTop1->GetObject())->Print();
    ((HepTopDecay*)fTop2->GetObject())->Print();

}
 AtlTopPair.cxx:1
 AtlTopPair.cxx:2
 AtlTopPair.cxx:3
 AtlTopPair.cxx:4
 AtlTopPair.cxx:5
 AtlTopPair.cxx:6
 AtlTopPair.cxx:7
 AtlTopPair.cxx:8
 AtlTopPair.cxx:9
 AtlTopPair.cxx:10
 AtlTopPair.cxx:11
 AtlTopPair.cxx:12
 AtlTopPair.cxx:13
 AtlTopPair.cxx:14
 AtlTopPair.cxx:15
 AtlTopPair.cxx:16
 AtlTopPair.cxx:17
 AtlTopPair.cxx:18
 AtlTopPair.cxx:19
 AtlTopPair.cxx:20
 AtlTopPair.cxx:21
 AtlTopPair.cxx:22
 AtlTopPair.cxx:23
 AtlTopPair.cxx:24
 AtlTopPair.cxx:25
 AtlTopPair.cxx:26
 AtlTopPair.cxx:27
 AtlTopPair.cxx:28
 AtlTopPair.cxx:29
 AtlTopPair.cxx:30
 AtlTopPair.cxx:31
 AtlTopPair.cxx:32
 AtlTopPair.cxx:33
 AtlTopPair.cxx:34
 AtlTopPair.cxx:35
 AtlTopPair.cxx:36
 AtlTopPair.cxx:37
 AtlTopPair.cxx:38
 AtlTopPair.cxx:39
 AtlTopPair.cxx:40
 AtlTopPair.cxx:41
 AtlTopPair.cxx:42
 AtlTopPair.cxx:43
 AtlTopPair.cxx:44
 AtlTopPair.cxx:45
 AtlTopPair.cxx:46
 AtlTopPair.cxx:47
 AtlTopPair.cxx:48
 AtlTopPair.cxx:49
 AtlTopPair.cxx:50
 AtlTopPair.cxx:51
 AtlTopPair.cxx:52
 AtlTopPair.cxx:53
 AtlTopPair.cxx:54
 AtlTopPair.cxx:55
 AtlTopPair.cxx:56
 AtlTopPair.cxx:57
 AtlTopPair.cxx:58
 AtlTopPair.cxx:59
 AtlTopPair.cxx:60
 AtlTopPair.cxx:61
 AtlTopPair.cxx:62
 AtlTopPair.cxx:63
 AtlTopPair.cxx:64
 AtlTopPair.cxx:65
 AtlTopPair.cxx:66
 AtlTopPair.cxx:67
 AtlTopPair.cxx:68
 AtlTopPair.cxx:69
 AtlTopPair.cxx:70
 AtlTopPair.cxx:71
 AtlTopPair.cxx:72
 AtlTopPair.cxx:73
 AtlTopPair.cxx:74
 AtlTopPair.cxx:75
 AtlTopPair.cxx:76
 AtlTopPair.cxx:77
 AtlTopPair.cxx:78
 AtlTopPair.cxx:79
 AtlTopPair.cxx:80
 AtlTopPair.cxx:81
 AtlTopPair.cxx:82
 AtlTopPair.cxx:83
 AtlTopPair.cxx:84
 AtlTopPair.cxx:85
 AtlTopPair.cxx:86
 AtlTopPair.cxx:87
 AtlTopPair.cxx:88
 AtlTopPair.cxx:89
 AtlTopPair.cxx:90
 AtlTopPair.cxx:91
 AtlTopPair.cxx:92
 AtlTopPair.cxx:93
 AtlTopPair.cxx:94
 AtlTopPair.cxx:95
 AtlTopPair.cxx:96
 AtlTopPair.cxx:97
 AtlTopPair.cxx:98
 AtlTopPair.cxx:99
 AtlTopPair.cxx:100
 AtlTopPair.cxx:101
 AtlTopPair.cxx:102
 AtlTopPair.cxx:103
 AtlTopPair.cxx:104
 AtlTopPair.cxx:105
 AtlTopPair.cxx:106
 AtlTopPair.cxx:107
 AtlTopPair.cxx:108
 AtlTopPair.cxx:109
 AtlTopPair.cxx:110
 AtlTopPair.cxx:111
 AtlTopPair.cxx:112
 AtlTopPair.cxx:113
 AtlTopPair.cxx:114
 AtlTopPair.cxx:115
 AtlTopPair.cxx:116
 AtlTopPair.cxx:117
 AtlTopPair.cxx:118
 AtlTopPair.cxx:119
 AtlTopPair.cxx:120
 AtlTopPair.cxx:121
 AtlTopPair.cxx:122
 AtlTopPair.cxx:123
 AtlTopPair.cxx:124
 AtlTopPair.cxx:125
 AtlTopPair.cxx:126
 AtlTopPair.cxx:127
 AtlTopPair.cxx:128
 AtlTopPair.cxx:129
 AtlTopPair.cxx:130
 AtlTopPair.cxx:131
 AtlTopPair.cxx:132
 AtlTopPair.cxx:133
 AtlTopPair.cxx:134
 AtlTopPair.cxx:135
 AtlTopPair.cxx:136
 AtlTopPair.cxx:137
 AtlTopPair.cxx:138
 AtlTopPair.cxx:139
 AtlTopPair.cxx:140
 AtlTopPair.cxx:141
 AtlTopPair.cxx:142
 AtlTopPair.cxx:143
 AtlTopPair.cxx:144
 AtlTopPair.cxx:145
 AtlTopPair.cxx:146
 AtlTopPair.cxx:147
 AtlTopPair.cxx:148
 AtlTopPair.cxx:149
 AtlTopPair.cxx:150
 AtlTopPair.cxx:151
 AtlTopPair.cxx:152
 AtlTopPair.cxx:153
 AtlTopPair.cxx:154
 AtlTopPair.cxx:155
 AtlTopPair.cxx:156
 AtlTopPair.cxx:157
 AtlTopPair.cxx:158
 AtlTopPair.cxx:159
 AtlTopPair.cxx:160
 AtlTopPair.cxx:161
 AtlTopPair.cxx:162
 AtlTopPair.cxx:163
 AtlTopPair.cxx:164
 AtlTopPair.cxx:165
 AtlTopPair.cxx:166
 AtlTopPair.cxx:167
 AtlTopPair.cxx:168
 AtlTopPair.cxx:169
 AtlTopPair.cxx:170
 AtlTopPair.cxx:171
 AtlTopPair.cxx:172