Hi Jan-Erik,
I had a very fast first look through your files and have
an immediate reaction.
Your two nested loops to find the same events:
- must run very very slow. You destroy the Root Tree cache
completly.
- When running with a subset of the branches only, the pointers
to the branches used in the first loop are overwritten
in the second loop when you go to a new file.
There are several solutions to this simple problem.
I would recommend the following.
Create arrays for the variables "platform","partition",etc
Make one single pass on the TChain to fill these 4 or 5 arrays.
Then make two loops like you do now, but instead of calling GetEntry,
you use directly the arrays.
Rene
Jan Erik Sundermann wrote:
>
> Hi Rene,
>
> the problem should be reproduceable using the two data files as input for
> the class "brecontp_doubleevents":
>
> root [0] .L brecontp_doubleevents.C
> root [1] TChain* ch = new TChain("CompBRecoNtpDump/ntp1")
> root [2] ch->Add("./*.root")
> (Int_t)2
> root [3] brecontp_doubleevents t(ch)
> root [4] t.Loop()
>
> The variables which should contain the data from the tree are not filled
> the right way.
>
>
> If I try the same with just one file like
>
> root [0] .L brecontp_doubleevents.C
> root [1] TFile f("2000_on_br-a12-v02_B0ToDLightReduced-phys13-1.root")
> root [2] f.cd("CompBRecoNtpDump")
> (Bool_t)1
> root [3] brecontp_doubleevents t(ntp1)
> root [4] t.Loop()
>
> everything seems to work. I tried the same with the development version
> 3.03/05 from yesterday but the problems remained.
>
>
>
> Best regard,
>
>
> Jan Erik.
>
> On Thu, 2 May 2002, Rene Brun wrote:
>
> > Jan Erik,
> >
> > I cannot reproduce this problem. Could you tell me where I can take
> > the strict minimum to reproduce the problem:
> > - two small data files making your TChain
> > - your code generated by MakeClass
> >
> > Rene Brun
> >
> > Jan Erik Sundermann wrote:
> > >
> > > Hi Rene,
> > >
> > > I checked the version of my root installation and tried again with the
> > > CVS version from 01 May. But unfortunately the problems I had with
> > > disabled branches did not vanish.
> > >
> > > Best regards,
> > >
> > > Jan Erik.
> > >
> > > On Tue, 30 Apr 2002, Rene Brun wrote:
> > >
> > > > Hi Jan Erik,
> > > >
> > > > Are you really using the version from CVS ?
> > > >
> > > > On April 21st I fixed a problem in TChain::SetBranchStatus
> > > > appearing when
> > > > -all branches were disabled
> > > > -then some branches activated but not the top level branch.
> > > > (seems to be your case)
> > > >
> > > > Could you check and let me know?
> > > >
> > > > Rene Brun
> > > >
> > > > Jan Erik Sundermann wrote:
> > > > >
> > > > > Hello rooters,
> > > > >
> > > > > the advised recipe in TChain->MakeClass() to disable braches for reading
> > > > > always fails in my code. I was trying both
> > > > >
> > > > > fChain->SetBranchStatus("*", 0);
> > > > > fChain->SetBranchStatus("event", 1);
> > > > > fChain->SetBranchStatus("platform", 1);
> > > > > (...)
> > > > >
> > > > > and alternatively
> > > > >
> > > > > b_event->GetEntry(entry);
> > > > > b_platform->GetEntry(entry);
> > > > > (...)
> > > > > In the first case all enabled branches allways return 0. In the second
> > > > > case everythings works fine until the loop reaches entry 1353 (maybe the
> > > > > begin of a new file in the chain). Then the entries remain constant.
> > > > > I use the by TChain::MakeClass() generated code skeleton and the current
> > > > > version from CVS. Attached below are the important parts of the code i
> > > > > use.
> > > > >
> > > > > What am i doing wrong?
> > > > >
> > > > > Bye,
> > > > >
> > > > > Jan Erik.
> > > > >
> > > > > --------------------------------------------
> > > > >
> > > > > void
> > > > > brecontp_doubleevents::Loop() {
> > > > >
> > > > > fChain->SetBranchStatus("*", 0);
> > > > > fChain->SetBranchStatus("platform", 1);
> > > > > fChain->SetBranchStatus("partition", 1);
> > > > > fChain->SetBranchStatus("upperID", 1);
> > > > > fChain->SetBranchStatus("lowerID", 1);
> > > > > fChain->SetBranchStatus("runNumber", 1);
> > > > > fChain->SetBranchStatus("nB0", 1);
> > > > > fChain->SetBranchStatus("nChB", 1);
> > > > >
> > > > > if (fChain == 0) return;
> > > > > Int_t nentries = Int_t(fChain->GetEntriesFast());
> > > > >
> > > > >
> > > > > for (Int_t entry1=0; entry1 < nentries; entry1++) {
> > > > >
> > > > > Int_t ientry = LoadTree(entry1);
> > > > > if (ientry < 0) break;
> > > > >
> > > > > fChain->GetEntry(entry1);
> > > > >
> > > > > // or alternatively ...
> > > > >
> > > > > // b_event->GetEntry(entry1);
> > > > > // b_platform->GetEntry(entry1);
> > > > > // b_partition->GetEntry(entry1);
> > > > > // b_upperID->GetEntry(entry1);
> > > > > // b_lowerID->GetEntry(entry1);
> > > > > // b_runNumber->GetEntry(entry1);
> > > > > // b_nB0->GetEntry(entry1);
> > > > > // b_nChB->GetEntry(entry1);
> > > > >
> > > > > long platform1 = platform;
> > > > > long partition1 = partition;
> > > > > long upperID1 = upperID;
> > > > > long lowerID1 = lowerID;
> > > > > long event1 = event;
> > > > > long runnumber1 = runNumber;
> > > > > long nB01 = nB0;
> > > > > long nChB1 = nChB;
> > > > >
> > > > > for (Int_t entry2 = entry1+1; entry2 < nentries; entry2++) {
> > > > >
> > > > > Int_t jentry = LoadTree(entry2);
> > > > > if (jentry < 0) break;
> > > > > fChain->GetEntry(entry2);
> > > > >
> > > > > // or alternatively ...
> > > > >
> > > > > // b_event->GetEntry(entry2);
> > > > > // b_platform->GetEntry(entry2);
> > > > > // b_partition->GetEntry(entry2);
> > > > > // b_upperID->GetEntry(entry2);
> > > > > // b_lowerID->GetEntry(entry2);
> > > > > // b_runNumber->GetEntry(entry2);
> > > > > // b_nB0->GetEntry(entry2);
> > > > > // b_nChB->GetEntry(entry2);
> > > > >
> > > > > }
> > > > > }
> > > > >
> > > > > fChain->SetBranchStatus("*", 1);
> > > > >
> > > > > }
> > > >
> >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET