Extract data from root tree

Dear Experts,
I am a beginner in root . I wrote a program to extract data from my output root file to a txt file. however, while running, it gives the following error message. can anyone help me ? here I give my script.

#include <iostream>
#include "TFile.h"
#include "TTree.h"
#include <fstream>
#include <vector>
using namespace std;

void tpc_postionedHits(const char* file_name){
  TFile *f=TFile::Open(file_name); // opens the root file
  TTree *events=(TTree*)f->Get("events"); // creates the TTree object
  events->Scan(); // prints the content on the screen

  float *tpc_positionedHits; // create variables of the same type as the branches you want to access

  events->SetBranchAddress("tpc_positionedHits",&tpc_positionedHits); // for all the TTree branches you need this
//  tr->SetBranchAddress("ns",&b);
//  tr->SetBranchAddress("nserr",&c);

  ofstream myfile;
  myfile.open ("tpc_positionedHits.txt");
  myfile << "tpc_positionedHits\n";

  for (int i=0;i<events->GetEntries();i++){
    // loop over the tree
   // cout << a << " " << endl; //print to the screen
   // myfile << a << "\n"; //write to file

it gives the error,

**Error in <TTree::SetBranchAddress>: The pointer type given "Float_t" (5) does not correspond to the type needed "vector<fcc::PositionedTrackHitData>" by the branch: tpc_positionedHits**

_ROOT Version: 6.13
_Platform: Ubuntu 16.04
Compiler: Not Provided

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.