//____________________________________________________________________
//
// HEP vertex used in Monte Carlo simulations
// 

//  
// Author: Oliver Maria Kind <mailto: kind@mail.desy.de>
// Update: $Id: HepMCVertex.cxx,v 1.2 2010/12/23 15:14:32 herrberg Exp $
// Copyright: 2008 (C) Oliver Maria Kind
//
#ifndef HEP_HepMCVertex
#include <HepMCVertex.h>
#endif
#include <iostream>

using namespace std;

#ifndef __CINT__
ClassImp(HepMCVertex);
#endif

//____________________________________________________________________

HepMCVertex::HepMCVertex() {
    //
    // Default constructor
    //
    fDaughters = new TRefArray;
    fMother = new TRef;
}

//____________________________________________________________________

HepMCVertex::HepMCVertex(Int_t Id, Float_t x, Float_t y, Float_t z) :
    fId(Id) {
    //
    // Normal constructor
    //
    fPos.SetXYZ(x, y, z);
    fDaughters = new TRefArray;
    fMother = new TRef;
}

//____________________________________________________________________

HepMCVertex::~HepMCVertex() {
    //
    // Default destructor
    //
    delete fMother; fMother = 0;
    delete fDaughters; fDaughters = 0;
}

//____________________________________________________________________

void HepMCVertex::Clear(Option_t *option) {
    //
    // Clear this object
    //
    fId = 0;
    fPos.SetXYZ(0, 0, 1);
    fDaughters->Clear();
    delete fDaughters; fDaughters = 0;
    delete fMother; fMother = 0;
}

//____________________________________________________________________

void HepMCVertex::AddDaughter(HepMCParticle *Daughter) {
    //
    // Add outgoing particle
    //
    fDaughters->Add((TObject*)Daughter);
}

//____________________________________________________________________

void HepMCVertex::Print(Option_t *option) const {
    //
    // Print object information
    //
    // Options available:
    //   "nohead" - No header containing the variable names is
    //              displayed. Useful when printing a whole table
    //              for a list of vertices
    //
    TString opt = option;
    opt.ToLower();

    // Print header
    if ( !opt.Contains("nohead") ) PrintHeader();

    // Print
    cout.setf(ios::showpoint | ios::fixed, ios::floatfield);
    cout.precision(3);
    cout.width(4);  cout << fId;
    cout.width(12); cout << X();
    cout.width(12); cout << Y();
    cout.width(12); cout << Z();
    cout << endl;

    // Print footer
    if ( !opt.Contains("nohead") ) PrintFooter();
}

//____________________________________________________________________

void HepMCVertex::PrintHeader() {
    //
    // Print information header
    //
    cout << "------------------------------------" << endl
         << " Id  X           Y           Z      " << endl
         << "------------------------------------" << endl;
}

//____________________________________________________________________

void HepMCVertex::PrintFooter() {
    //
    // Print footer
    //
    cout << "-------------------------------------" << endl;
}
 HepMCVertex.cxx:1
 HepMCVertex.cxx:2
 HepMCVertex.cxx:3
 HepMCVertex.cxx:4
 HepMCVertex.cxx:5
 HepMCVertex.cxx:6
 HepMCVertex.cxx:7
 HepMCVertex.cxx:8
 HepMCVertex.cxx:9
 HepMCVertex.cxx:10
 HepMCVertex.cxx:11
 HepMCVertex.cxx:12
 HepMCVertex.cxx:13
 HepMCVertex.cxx:14
 HepMCVertex.cxx:15
 HepMCVertex.cxx:16
 HepMCVertex.cxx:17
 HepMCVertex.cxx:18
 HepMCVertex.cxx:19
 HepMCVertex.cxx:20
 HepMCVertex.cxx:21
 HepMCVertex.cxx:22
 HepMCVertex.cxx:23
 HepMCVertex.cxx:24
 HepMCVertex.cxx:25
 HepMCVertex.cxx:26
 HepMCVertex.cxx:27
 HepMCVertex.cxx:28
 HepMCVertex.cxx:29
 HepMCVertex.cxx:30
 HepMCVertex.cxx:31
 HepMCVertex.cxx:32
 HepMCVertex.cxx:33
 HepMCVertex.cxx:34
 HepMCVertex.cxx:35
 HepMCVertex.cxx:36
 HepMCVertex.cxx:37
 HepMCVertex.cxx:38
 HepMCVertex.cxx:39
 HepMCVertex.cxx:40
 HepMCVertex.cxx:41
 HepMCVertex.cxx:42
 HepMCVertex.cxx:43
 HepMCVertex.cxx:44
 HepMCVertex.cxx:45
 HepMCVertex.cxx:46
 HepMCVertex.cxx:47
 HepMCVertex.cxx:48
 HepMCVertex.cxx:49
 HepMCVertex.cxx:50
 HepMCVertex.cxx:51
 HepMCVertex.cxx:52
 HepMCVertex.cxx:53
 HepMCVertex.cxx:54
 HepMCVertex.cxx:55
 HepMCVertex.cxx:56
 HepMCVertex.cxx:57
 HepMCVertex.cxx:58
 HepMCVertex.cxx:59
 HepMCVertex.cxx:60
 HepMCVertex.cxx:61
 HepMCVertex.cxx:62
 HepMCVertex.cxx:63
 HepMCVertex.cxx:64
 HepMCVertex.cxx:65
 HepMCVertex.cxx:66
 HepMCVertex.cxx:67
 HepMCVertex.cxx:68
 HepMCVertex.cxx:69
 HepMCVertex.cxx:70
 HepMCVertex.cxx:71
 HepMCVertex.cxx:72
 HepMCVertex.cxx:73
 HepMCVertex.cxx:74
 HepMCVertex.cxx:75
 HepMCVertex.cxx:76
 HepMCVertex.cxx:77
 HepMCVertex.cxx:78
 HepMCVertex.cxx:79
 HepMCVertex.cxx:80
 HepMCVertex.cxx:81
 HepMCVertex.cxx:82
 HepMCVertex.cxx:83
 HepMCVertex.cxx:84
 HepMCVertex.cxx:85
 HepMCVertex.cxx:86
 HepMCVertex.cxx:87
 HepMCVertex.cxx:88
 HepMCVertex.cxx:89
 HepMCVertex.cxx:90
 HepMCVertex.cxx:91
 HepMCVertex.cxx:92
 HepMCVertex.cxx:93
 HepMCVertex.cxx:94
 HepMCVertex.cxx:95
 HepMCVertex.cxx:96
 HepMCVertex.cxx:97
 HepMCVertex.cxx:98
 HepMCVertex.cxx:99
 HepMCVertex.cxx:100
 HepMCVertex.cxx:101
 HepMCVertex.cxx:102
 HepMCVertex.cxx:103
 HepMCVertex.cxx:104
 HepMCVertex.cxx:105
 HepMCVertex.cxx:106
 HepMCVertex.cxx:107
 HepMCVertex.cxx:108
 HepMCVertex.cxx:109
 HepMCVertex.cxx:110
 HepMCVertex.cxx:111
 HepMCVertex.cxx:112
 HepMCVertex.cxx:113
 HepMCVertex.cxx:114
 HepMCVertex.cxx:115
 HepMCVertex.cxx:116
 HepMCVertex.cxx:117
 HepMCVertex.cxx:118
 HepMCVertex.cxx:119
 HepMCVertex.cxx:120
 HepMCVertex.cxx:121
 HepMCVertex.cxx:122
 HepMCVertex.cxx:123
 HepMCVertex.cxx:124