Re: MakeClass()

From: Monika Sharma <monika_at_rcf.rhic.bnl.gov>
Date: Tue, 06 Feb 2007 14:09:45 +0530

Hi Rene,

Thank you very much for your answer. Yes I had Long64_t nentries = fChain->GetEntriesFast(); in my macro, PMD.C. But when I replaced this line with
Long64_t nentries = fChain->GetEntries(); It does return the correct number of entries.

Thanks & regards
Monika

Rene Brun wrote:

> Hi Monika,
>
> In your PMD.C file, you should have a statement:
> Long64_t nentries = fChain->GetEntriesFast();
> In case of a TChain, nentries will be the large number 1234567890.
> At this point, ROOT does not know the total number of entries in all
> files.
> This is to avoid opening each file twice.
> When executing the loop, the loop will terminate correctly when all
> events will be processed.
> You can also replace GetEntriesFast by GetEntries. It will return the
> right number of entries
> but it will be slower.
>
> Rene Brun
>
>
> Monika Sharma wrote:
>
>>
>> Hi Rene,
>>
>> Thank you for quick answer. I tried it but I am facing a strange
>> problem.
>>
>> Following is what I did recently :
>> void Pmd_cucu_analysis()
>> {
>>
>> TChain chain("PmdNano");
>> chain.Add("PMD_Nanodst_feb4_540Kevts.root");
>> chain.Add("PMD_Nanodst_feb4_540Kevts_1.root");
>> chain.MakeClass("PMD");
>>
>> }
>>
>> It does generate PMD.C and PMD.h. However when I try to read the
>> number of events in PMD.C, it gives me a very large number of events.
>> Which are not actually present intotality in the above two mentioned
>> rootfiles.
>>
>> For example :
>> Following is the output I get when I execute PMD.C
>> root.exe [1] .L PMD.C
>> root.exe [2] PMD t
>> root.exe [3] t.Loop()
>> Total events = 1234567890
>> Warning in <TClass::TClass>: no dictionary for class PmdEvent is
>> available
>> Warning in <TClass::TClass>: no dictionary for class PmdCluster is
>> available
>> Warning in <TClass::TClass>: no dictionary for class PmdHit is available
>> Warning in <TClass::TClass>: no dictionary for class PmdTrack is
>> available
>> root.exe [4] .q
>>
>> But when I try to see the number of events indiviually from the
>> rootfiles,
>> this is what I get :
>>
>>
>> root.exe [0]
>> Attaching file PMD_Nanodst_feb4_540Kevts.root as _file0...
>> Warning in <TClass::TClass>: no dictionary for class PmdEvent is
>> available
>> Warning in <TClass::TClass>: no dictionary for class PmdCluster is
>> available
>> Warning in <TClass::TClass>: no dictionary for class PmdHit is available
>> Warning in <TClass::TClass>: no dictionary for class PmdTrack is
>> available
>> root.exe [1] PmdNano->GetEntries()
>> (const Long64_t)367860
>> root.exe [2] .q
>>
>> And :
>> root.exe [0]
>> Attaching file PMD_Nanodst_feb4_540Kevts_1.root as _file0...
>> Warning in <TClass::TClass>: no dictionary for class PmdEvent is
>> available
>> Warning in <TClass::TClass>: no dictionary for class PmdCluster is
>> available
>> Warning in <TClass::TClass>: no dictionary for class PmdHit is available
>> Warning in <TClass::TClass>: no dictionary for class PmdTrack is
>> available
>> root.exe [1] PmdNano->GetEntries()
>> (const Long64_t)406344
>> root.exe [2] .q
>>
>> So I expect a total of 774204 events from PMD.C (Because this is the
>> actual number
>> of events present in the rootfiles). Is there any obvious mistake
>> that I am making.
>>
>> Thanks in advance.
>> Regards
>> Monika
>>
>>
>> Rene Brun wrote:
>>
>>> Hi Monika,
>>>
>>> You should use a TChain to process a collection of files
>>>
>>> TChain chain("VW");
>>> chain.Add("filename_*.root");
>>> chain.MakeClass("something");
>>>
>>> Rene Brun
>>>
>>> Monika Sharma wrote:
>>>
>>>>
>>>> Hi Rooters,
>>>>
>>>> I am trying to use MakeClass function to read a .root file.
>>>> Following is a typical example of what I am doing :
>>>>
>>>> ========================================
>>>> void analysis()
>>>> {
>>>>
>>>> TFile *f = new TFile("Event_transport.root");
>>>> TTree *v = (TTree*)f->Get("VW");
>>>> f->ls();
>>>>
>>>> v->MakeClass("something");
>>>> }
>>>> =========================================
>>>>
>>>> This generates a .C and a .h file, which works fine for me.
>>>> But now my aim is to increase statistics. Therefore I have two
>>>> rootfiles
>>>> each of ~2 GB size, as a result I cannot merge them any further.
>>>>
>>>> I wanted to ask is there anyway that I can still use MakeClass
>>>> function
>>>> to read these rootfiles together which would generate one .C and .h
>>>> file
>>>> so that I have double the statistics.
>>>>
>>>> I tried doing
>>>> =============================================
>>>> void analysis()
>>>> {
>>>>
>>>> for(Int_t nFiles=0; nFiles<2; nFiles++)
>>>> {
>>>> char fname[150];
>>>> sprintf(fname,"filename_%d.root",nFiles);
>>>> cout<<endl;
>>>> printf(fname,"filename_%d.root",nFiles);
>>>> TFile *file = new TFile(fname,"r");
>>>> TTree *P = (TTree*)file->Get("VW");
>>>> file->ls();
>>>> }
>>>> P->MakeClass("something");
>>>> }
>>>> =====================================================
>>>>
>>>> But the above method generates .C and .h files taking the last
>>>> rootfile as
>>>> the input.
>>>>
>>>> Thanks in advance.
>>>> Monika
>>>
>>>
Received on Tue Feb 06 2007 - 09:40:20 CET

This archive was generated by hypermail 2.2.0 : Tue Feb 06 2007 - 11:50:00 CET