Re: performance : TTree::Project vs Loop() from MakeClass() with a Fill() instruction

From: Marc Escalier <escalier_at_lal.in2p3.fr>
Date: Fri, 21 May 2010 09:23:48 +0200


dear all,

here is for those interested, the feedback/answer to my question, thanks to the help of Rene :

using C+ instead of C didn't improve the speed

the reason of the slow code when i do Loop() would be : -the access via the pointer via a fChain one can improve by using :
mybranch->GetEntry(j)
instead of
fChain->GetEntry(jentry);

-the model of the data : due to many vectors in the ntuples

regards



Rene Brun a écrit :
> Instead of
> time -q -x -b TheMacro.C
> could you do
> time -q -x -b TheMacro.C+
>
> Rene Brun
>
> Marc Escalier wrote:
>> Dear rooters,
>>
>> i compared performance of filling an histograms in two ways from a
>> TChain list of files
>>
>> 1) using a direct filling using the TTree::Project() method
>> 2) using a MakeClass created from a TChain () and filling the
>> histogram in a loop on the events
>> (of course i deactivated the branchs that are not useful to speed up
>> the Loop() )
>>
>> but from performance (time -q -x -b TheMacro.C)
>> i see that the Project() is much faster than the Loop() method of a
>> class generated from a MakeClass() instruction
>>
>> ==>would you know why and how to make the Loop() as fast as the
>> Project() method
>>
>> i see that if i do many Project(), at a given threshold of number of
>> histograms to fill, the Loop() method becomes more faster,
>> because in the Project() method, one loop each time on the whole
>> events while in the Loop() method from MakeClass() filling the
>> histograms on the fly, whereas in the Project() method,
>> it loops each time again on the events. So my goal would be to
>> understand the fact that individual Project() method is so fast, in
>> order to improve the Loop() method that is automaticaly generated
>> from the MakeClass() instruction (sorry for redundance of the
>> observed behaviour, it is to explains the phenomena)
>>
>> thank you
>>
>> here is a minimal example :
>> {
>> #include "PAUReco.C"
>>
>> TChain *mychain_data_7000=new TChain("PAUReco");
>> gROOT->ProcessLine(".x menu_ChooseDatasets.C");
>>
>> TH1F *hist1=new TH1F("hist1","hist1",1,0,2000);
>>
>> //first method :
>> mychain_data_7000->Project("hist1","ph_pt/1000");
>>
>> //second method : (i comment the first or the second method to
>> compare performances)
>> PAUReco myPAUReco(mychain_data_7000);
>> myPAUReco.Loop();
>> }
>>
>>
>> mychain_data_7000->Add("/sps/atlas/l/lal-photon/Trash/PAU-00-01-73/data_cutPt9/L1Calo/Run152166/*root*");
>>
>>
>> -------------------------------------
>> PAUReco.C :
>>
>> void PAUReco::Loop()
>> {
>> if (fChain == 0) return;
>>
>> fChain->SetBranchStatus("*",0);
>> fChain->SetBranchStatus("ph_pt",1);
>>
>> Long64_t nentries = fChain->GetEntries();
>>
>> for (Long64_t jentry=0; jentry<nentries;jentry++) {
>> Long64_t ientry = LoadTree(jentry);
>>
>> if (ientry < 0) break;
>> fChain->GetEntry(jentry); // nbytes += nb;
>> int mysize=ph_pt->size();
>> for (int i_photon=0;i_photon<mysize;i_photon++) {
>> float myph_pt=ph_pt->at(i_photon)/1000.;
>>
>> hist1->Fill(myph_pt); }
>> } //end loop en entries
>> }
>>
>
Received on Fri May 21 2010 - 09:28:37 CEST

This archive was generated by hypermail 2.2.0 : Sat May 22 2010 - 23:50:01 CEST