ROOT logo
#include "hparticlegeant.h"
#include "hparticlegeantdecay.h"
#include "hparticlecandsim.h"

#include <algorithm>
#include <iostream>
#include <iomanip>

using namespace std;


ClassImp(HParticleGeant)

//_HADES_CLASS_DESCRIPTION
////////////////////////////////////////////////////////////////////////////////
//
//
// HParticleGeant
//
// Simulation object keeping HGeant pointers and pointers to decays and
// reconstructed HParticleCand objects for this geant track.
// For documentation of use case see the documentation of
// HParticleGeantEvent.
////////////////////////////////////////////////////////////////////////////////

HParticleGeant::HParticleGeant()
{
    clear();
}
HParticleGeant::~HParticleGeant()
{
    ;
}

void  HParticleGeant::setParticle(HGeantKine* part)
{
    // sets kine pointer of particle
    // the vertex and the acceptance flag
    fparticle = part;
    part->getVertex(fdecayVertex);
    fInAcceptance = part->isInAcceptance();
}
Float_t HParticleGeant::getDistFromVertex(HGeomVector* primVer)
{
    if(!primVer) return fdecayVertex.length();
    else {
	HGeomVector diff = *primVer + fdecayVertex;
        return diff.length();
    }
}

void HParticleGeant::addRecoCand(HParticleCandSim* c)
{
    // adds a candidate to the list of recontructed
    // candidates if it is not already in the list
    if(find(vReco.begin(),vReco.end(),c)==vReco.end()) vReco.push_back(c);
}

UInt_t  HParticleGeant::getNRecoCand()
{
    return vReco.size();
}

UInt_t  HParticleGeant::getNRecoUsedCand()
{

    // return the number of reconstructed candidates matching
    // this geant object which are flagged kIsUsed
    Int_t ct = 0 ;
    for(UInt_t i =0; i < vReco.size(); i++){
	if(!vReco[i]->isFlagBit(kIsUsed)) continue;    // only count used particles
	ct++;
    }
    return ct;
}

UInt_t  HParticleGeant::getNGhosts(Bool_t isUsed)
{
    // return the number of reconstructed candidates matching
    // this geant object which are flagged kIsUsed (if isUsed=kTRUE, default=kFALSE)
    // and are marked as Ghosts
    Int_t ct = 0 ;
    for(UInt_t i =0; i < vReco.size(); i++){
	if(isUsed && !vReco[i]->isFlagBit(kIsUsed)) continue;    // only count used particles
	if(vReco[i]->isGhostTrack()) ct++;
    }
    return ct;
}

UInt_t HParticleGeant::getNTrueReco(Bool_t isUsed,UInt_t detbits)
{
    // return the number of reconstructed candidates matching
    // this geant object which are flagged kIsUsed (if isUsed=kTRUE, default=kTRUE)
    // and are not marked as Ghosts and fullfill the detector bits
    // (default == kIsInInnerMDC|kIsInOuterMDC|kIsInMETA, = 0 will ignore)
    Int_t ct = 0 ;
    for(UInt_t i =0; i < vReco.size(); i++){
	if(isUsed && !vReco[i]->isFlagBit(kIsUsed)) continue;    // only count used particles
	if( (detbits==0 || vReco[i]->isInDetectors(detbits)) && !vReco[i]->isGhostTrack()) ct++;
    }
    return ct;
}

void HParticleGeant::print()
{
    // prints some basic infos about this particle
    cout<<"HParticleGeant: generation "<< setw(3)<<fgeneration<< " ##################################"<<endl;
    if(fparticle) fparticle->print();
    if(fmotherDecay)  cout<<"mother ID  "<< setw(3)<<fmotherDecay->getMotherID() ;
    cout<<"n reco     "<< setw(3)<<vReco.size()<<"n reco used "<<setw(3)<<getNRecoUsedCand()<<" n true "<<setw(3)<<getNTrueReco()<<" n ghost "<<setw(3)<<getNGhosts()<<endl;
}

void HParticleGeant::clear()
{
    // resets all internal varibales
    fparticle   = 0;
    fmother     = 0;
    fgeneration = 0;
    fmotherDecay= 0;
    fdecayVertex.setXYZ(-1000,-1000,-1000);
    vReco.clear();
    fInAcceptance = kFALSE;

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