vector<TH1F*>

Hi,

I am trying to do the following from the root command line. However, it keeps throwing out an error:

root [1] std::vector<TH1F*> fTelInfo;
root [2] fTelInfo.resize(2);
root [3] fTelInfo.at(0)=new TH1F("wid","width",100,0,5);

The first line goes through fine. But then I get:

Error: Can't call vector<TH1F*,allocator<TH1F*> >::resize(2) in current scope (tmpfile):1:
Possible candidates are...
(in vector<TH1F*,allocator<TH1F*> >)
*** Interpreter error recovered ***

What could be causing this? I thought the current version of CINT supports STL! The reason I ask is b/c I would like to be able to use vector<TH1F*> in my script without having to compile it.

Erdos

G5PPC OX 10.4.8
gcc 4.0.1
ROOT 5.14/00d

I’m sure that the powers that be will give a more complete response. With Root 4.02, you can do (more or less) what you want, you just need to '#include '. I use stl::vectors in uncompiled root scripts often (although I do not use the ‘resize’ function).

Cheers,
Charles

root [0] #include< vector >          
root [1] std::vector< TH1F* > histVec
root [2] histVec.push_back( new TH1F ("bla", "bla", 100, 0, 5) )
root [3] histVec[0].Draw()
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [4] .q

Hello Charles,

I tried to reproduce your code but to no avail. I get the same error message. Unfortunately, my collaboration uses root 5.12f and above. Therefore, I am stuck with the latest version!!

However, I am surprised that you could actually loose functionality as you upgrade. Or may be the feature is just hidden away in some other corner.

Thanks anyways

Cheers
Erdos

root [0] #include< vector >          
root [1] std::vector< TH1F* > histVec
root [2] histVec.push_back( new TH1F ("bla", "bla", 100, 0, 5) )
Error: Can't call vector<TH1F*,allocator<TH1F*> >::push_back(new TH1F("bla","bla",100,0,5)) in current scope (tmpfile):1:
Possible candidates are...
(in vector<TH1F*,allocator<TH1F*> >)
*** Interpreter error recovered ***

Hi Erdos,
I hope to be able to check tomorrow why this fails. I agree that it should just work…
Cheers, Axel.

Hi Erdos,

this is an annoying problem with STL of class pointers. You should create a dictionary for it, see e.g. root.cern.ch/phpBB2/viewtopic.php?t=2294 We will solve this properly once we have Reflex available in CINT.

Cheers, Axel.

Hi,
I still have the same problem with ROOT Version 5.34/30

[quote=“Axel”]Hi Erdos,
this is an annoying problem with STL of class pointers. You should create a dictionary for it, see e.g. root.cern.ch/phpBB2/viewtopic.php?t=2294 We will solve this properly once we have Reflex available in CINT.
Cheers, Axel.[/quote]
The link is not working.

Is there any workaround?

Thank you,
Leonardo

Hi,

Did you generate a dictionary for the STL collection in question? (See for example TInterpreter::GenerateDictionary). Alternatively, you should consider using ROOT v6 which does not have this problem.

Cheers,
Philippe.