Root crash when reading a tree

I am trying to read the attached ntuple with a piece of code. I am on lxplus using /cvmfs/cms.cern.ch/slc6_amd64_gcc493/cms/cmssw/CMSSW_7_6_3/external/slc6_amd64_gcc493/bin/root

The code I am using is given below. When I uncomment the line with “jet_source” in it, it crashes. If however I type these lines in my hand at the root prompt, instead of calling it doing .x SCEprint.C, it does not crash. Any help would be appreciated.

void SCEprint(){
// read the Tree generated by tree1w and fill two histograms
// note that we use “new” to create the TFile and TTree objects,
// to keep them alive after leaving this function.
TFile *f = new TFile(“ntuple.root”);
TTree tt = (TTree)f->Get(“emJetAnalyzer/emJetTree”);

Int_t nVtx, event;
Float_t met_pt, met_phi;
vector *jet_index,*jet_source;
vector *jet_pt;

tt->SetBranchAddress(“nVtx”,&nVtx);
tt->SetBranchAddress(“event”,&event);
tt->SetBranchAddress(“met_pt”,&met_pt);
tt->SetBranchAddress(“met_phi”,&met_phi);
tt->SetBranchAddress(“jet_index”,&jet_index);
//tt->SetBranchAddress(“jet_source”,&jet_source);

// create a histograms
TH1F *hpt = new TH1F(“hpt”,“pt distribution”,100,0.,100.);

//read all entries and fill the histograms
Int_t nentries = (Int_t)tt->GetEntries();
for (Int_t i=0; i<nentries; i++) {
tt->GetEntry(i);
cout<<"event number is “<<event<<” number of vertex is “<<nVtx<<endl;
for(Int_t j=0; j<(*jet_index).size(); j++) {
cout<<” jet "<<(*jet_index)[j]<<endl;
//hpt->Fill((*jet_pt)[j]);
}
}
// We do not close the file. We want to keep the generated
// histograms we open a browser and the TreeViewer
if (gROOT->IsBatch()) return;
TCanvas *c1 = new TCanvas(“c1”,“Vertex Plots”,200,10,700,500);
hpt->Draw();
c1->Modified();
c1->Update();
// t1->StartViewer();

//In the browser, click on “ROOT Files”, then on “tree1.root”
//You can click on the histogram icons in the right panel to draw
//them in the TreeViewer, follow the instructions in the Help.
}
ntuple.root (604 KB)

At least:
vector *jet_index = new vector;
vector *jet_source = new vector;
vector *jet_pt = new vector;
and then in the end of your routine:
tt->ResetBranchAddresses(); // detach from local variables
delete jet_index;
delete jet_source;
delete jet_pt;

Thanks! That works.