Scale many histos at the same time

Hi,

I have many histos to scale with the same factor. I’m thought I could scale them all with something like : TIter next (gDirectory->GetListOfKeys()); TKey *key; while((key=(TKey*)next())) if(strstr(key->GetClassName(),"TH1F"))((TH1F*)(gDirectory->Get(key->GetName())))->Scale(N);
or TIter next (gDirectory->GetListOfKeys()); TKey *key; while((key=(TKey*)next())) if(strstr(key->GetClassName(),"TH1F"))((TH1F*)(gDirectory->FindObjectAny(key->GetName())))->Scale(N);
but unfortunatly the scale seems to apply only on a temporarly histo (I guess) and not on the stored ones…

Is there any simpler way to do this or do I really have to write all my histos names in the program ?

Thanks.

If your directory is correctly set , both forms should work

Rene

[quote=“brun”]If your directory is correctly set[/quote]Of course… :blush:

Thanks.

Is there any way to do the same thing for objects which do not belong to any directory ? I mean, after a SetDirectory(0) ?

Thanks.

Well, in this case it is your responsability to put these objects in some collection and iterate over this collection.
The TDirectory is doing that for you.

Rene