//____________________________________________________________________
//
// Single-top Entry List Writer
// 
//  
// Author: Ruth Herrberg <mailto: ruthh@physik.hu-berlin.de>
// Update: $Id: AtlSgTopEntryListWriter.cxx,v 1.3 2011/06/07 12:03:31 herrberg Exp $
// Copyright: 2009 (C) Oliver Maria Kind
//
#ifndef SINGLETOP_AtlSgTopEntryListWriter
#include <AtlSgTopEntryListWriter.h>
#endif
#include <iostream>

using namespace std;

#ifndef __CINT__
ClassImp(AtlSgTopEntryListWriter);
#endif


const Int_t AtlSgTopEntryListWriter::fgNCuts = 2;

//____________________________________________________________________

AtlSgTopEntryListWriter::AtlSgTopEntryListWriter(const char* OutputFile) :
    AtlSelector(OutputFile) {
    //
    // Default constructor
    //
    
    // Init
    SetCutDefaults();
}

//____________________________________________________________________

AtlSgTopEntryListWriter::~AtlSgTopEntryListWriter() {
    //
    // Default destructor
    //
}

//____________________________________________________________________

void AtlSgTopEntryListWriter::SetBranchStatus() {
    //
    // Switch on/off branches in order to gain speed
    //

    // Switch off all branches by default
    fTree->SetBranchStatus("*", kFALSE);

    // Switch on only branches we are going to use
    // This will speed up the analysis process considerably
    fTree->SetBranchStatus("fEventHeader*",         kTRUE);
    fTree->SetBranchStatus("fTrigger*",             kTRUE);

}

//____________________________________________________________________

void AtlSgTopEntryListWriter::SetCutDefaults() {
    //
    // Selection cut defaults
    //
//    fWriteEntryList = kTRUE;
    
    fTriggerChoice = "EF_e20_medium";

}

//____________________________________________________________________

void AtlSgTopEntryListWriter::BookHistograms() {
    //
    // Book histograms
    //    

//     // Weighted
//     fHistCutFlow_weighted = new TH1F("h_cut_flow_kinfit_weighted", "Cut-flow KinFitter mode (weighted)",
// 				     fgNCuts, 0,
// 				     fgNCuts);
//     fHistCutFlow_weighted->SetYTitle("Number of Entries");
//     TAxis *axis = fHistCutFlow_weighted->GetXaxis();
//     axis->SetBinLabel(1, "No Cuts");
//     axis->SetBinLabel(2, Form("%s Trigger",fTriggerChoice.Data()));

    
//     // Unweighted    
//     fHistCutFlow_unweighted = new TH1F("h_cut_flow_kinfit_unweighted", "Cut-flow KinFitter mode (unweighted)",
// 				       fgNCuts, 0,
// 				       fgNCuts);
//     fHistCutFlow_unweighted->SetYTitle("Number of Entries");
//     axis = fHistCutFlow_unweighted->GetXaxis();
//     axis->SetBinLabel(1, "No Cuts");
//     axis->SetBinLabel(2, Form("%s Trigger",fTriggerChoice.Data()));

    
}

//____________________________________________________________________

Bool_t AtlSgTopEntryListWriter::ProcessCut() {
    //
    // Event selection
    //

//     // No cut (1)
//     fHistCutFlow_weighted->AddBinContent(1, fEvtWeight);
//     fHistCutFlow_unweighted->AddBinContent(1, TMath::Abs(fEvtWeight));

//     fHistCutFlow2_weighted->AddBinContent(1, fEvtWeight);
//     fHistCutFlow2_unweighted->AddBinContent(1, TMath::Abs(fEvtWeight));


    
    if ( fEvent->HasPassedHLT(fTriggerChoice) == kFALSE ) {

	return kFALSE;
    }


    cout << endl << endl
	 << " ***************************************************************" << endl
	 << " Event with number " << fEvent->EventNr()
	 << " and run number " << fEvent->RunNr()
	 << " added to entry list."
	 << " ***************************************************************" << endl
	 << endl << endl;
    
    // Trigger cut (2)
//     fHistCutFlow_weighted->AddBinContent(2, fEvtWeight);
//     fHistCutFlow_unweighted->AddBinContent(2, TMath::Abs(fEvtWeight));

//     fHistCutFlow2_weighted->AddBinContent(2, fEvtWeight);
//     fHistCutFlow2_unweighted->AddBinContent(2, TMath::Abs(fEvtWeight));
    
    return kTRUE;
}

//____________________________________________________________________


void AtlSgTopEntryListWriter::FillHistograms() {
    //
    // Fill histograms
    //
    // This method will be called only for events surviving the
    // ProcessCut() routine
    //
    
}

//____________________________________________________________________

void AtlSgTopEntryListWriter::Print() const {
    //
    // Print user analysis configuration
    //
    cout
	<< endl
	<< "========================================================" << endl
	<< "  Atlas Single-Top Entry List Writer          " << endl
	<< "========================================================" << endl
	<< "  Chosen trigger item is fTriggerChoice = " << fTriggerChoice << endl
	<< "========================================================" << endl
	<< endl;

}

//____________________________________________________________________

void AtlSgTopEntryListWriter::Terminate() {
    //
    // Terminate routine
    //

    AtlSelector::Terminate();
}

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