Exemplo n.º 1
0
void extractTree(const char *file, int event_num) {
    TFile *f = new TFile(file);
    TTree *tree = (TTree*) f->Get("T");
    
    RAT::DS::Root *rds = new RAT::DS::Root();
    tree->SetBranchAddress("ds", &rds);
    
    tree->GetEntry(event_num);
    RAT::DS::MC *mc = rds->GetMC();

    int nTracks = mc->GetMCTrackCount();
    Particle *trackmap = new Particle[nTracks+1];
    for (int j = 0; j < nTracks; j++) {
        RAT::DS::MCTrack *track = mc->GetMCTrack(j);
        int tid = track->GetID();
        int pid = track->GetParentID();
        
        Particle *cur = &trackmap[tid];
        trackmap[pid].addChild(cur);

        RAT::DS::MCTrackStep *first = track->GetMCTrackStep(0);
        RAT::DS::MCTrackStep *last = track->GetLastMCTrackStep();
        
        int nSteps = track->GetMCTrackStepCount();
        TVector3 *steps = new TVector3[nSteps];
        for (int k = 0; k < nSteps; k++) {
            steps[k] = track->GetMCTrackStep(k)->GetEndpoint();
        }

        cur->setProperties(track->GetParticleName(),first->GetProcess(),last->GetProcess(),steps,nSteps);
    }
    
    trackmap[1].dumpList(cout);
}