problems retrieving <vector> object in ROOT

From: Fabrizio Salvatore <p.salvatore_at_rhul.ac.uk>
Date: Fri, 17 Mar 2006 12:50:54 +0000


Hi,

I'm running on some ROOT-tuples that have been produced using some non-native ROOT classes. I've loaded the appropriate library in ROOT where all those classes are defined and I've used the MakeSelector to create my macro.

First, I noticed that all objects of type vector<Type*> have been automatically commented out in the header file (macro.h):

//vector<float> fPFlow_PID_parameters[kMaxfPFlow];

Double_t        fMCpart_NumberofDaughters[kMaxfMCpart];  //[fMCpart_]
Double_t        fMCpart_NumberofParents[kMaxfMCpart];   //[fMCpart_]
UChar_t         fMCpart_InteractCal[kMaxfMCpart];   //[fMCpart_]
UChar_t         fMCpart_InteractTrk[kMaxfMCpart];   //[fMCpart_]

//vector<MCpart*> fMCpart_Parents[kMaxfMCpart];
//vector<MCpart*> fMCpart_Daughters[kMaxfMCpart];

What is the reason for this ?

I now need to access the info of objects of type MCpart* stored in the ROOT-tuple as vectors of MCpart objects and so I've commented out the above lines, and define for these types the branch, branch address, branch pointers:

    TBranch *b_fMCpart_Parents; //!     ...

    fChain->SetBranchAddress("fMCpart.Parents",fMCpart_Parents);     ....

    b_fMCpart_Parents = fChain->GetBranch("fMCpart.Parents");     .....

However, when in my macro I do the following command:

for(Int_t j=0; j<fNMCpart; j++) {

	MCpart* mcp = fMCpart_Parents[j];
	.....

}

my program crashes with the following error:

Error: Incorrect assignment to mcp, wrong type 'vector<MCpart*>' FILE:muSel.C LINE:289

What am I doing wrong ?

As far as I can see, ROOT does know about the vector<MCpart*> type, since if, from the ROOT prompt, I do:

root[0]vector<MCpart*> test;
root[1]test
(vector<MCpart*>)192369456

so the object of that type is defined. Or am I mis-interpreting everything ?

Thanks for any help !

                                Fab

-- 
#############################################################
Dr P-Fabrizio Salvatore            | Department of Physics
Phone: +44 (0)1784 44 3479         | Royal Holloway College
Fax: +44 (0)1784 47 2794           | University of London
e-mail: P.Salvatore_at_rhul.ac.uk     | Egham, Surrey, TW20 0EX
http://www.pp.rhul.ac.uk/~salvator | United Kingdom (UK)
#############################################################
Received on Fri Mar 17 2006 - 13:51:30 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET