Re: tree -> Project doesn't work!

From: Genie Jhang <geniejhang_at_majimak.com>
Date: Sun, 22 May 2011 11:21:37 +0900


Thanks!

It's second time for you to save my life!

On May 10, 2011, at 1:58 AM, Philippe Canal wrote:

> Hi Genie,
> 
> The problem is that in pT_y.C when you do:
> 
>        TH2D *hist = new TH2D("hist", "p_{T}/m vs. y", selectXBins, selectMinX, selectMaxX, selectYBins, selectMinY, selectMaxY);
> 
>        TFile *openFile = new TFile(dataName[selectData].c_str());
>        TTree *particleTree = (TTree *) openFile -> Get(particleName[selectParticle].c_str());
> 
>        particleTree -> Project("hist", "pT/mass:rapidity", dataOption.c_str(), "", 10);
> 
>        hist -> GetXaxis() -> SetTitle("y");
> 
> The 'hist' that is filled by Project is different from the 'hist' that you manipulate
> and later Draw (you end up draw an empty histogram) because the 'hist' you
> created is not in the current directory when you executed Project.
> 
> This code solves the problem:
> 
>       TDirectory *where = gDirectory;
>        TH2D *hist = new TH2D("hist", "p_{T}/m vs. y", selectXBins, selectMinX, selectMaxX, selectYBins, selectMinY, selectMaxY);
> 
>        TFile *openFile = new TFile(dataName[selectData].c_str());
>        TTree *particleTree = (TTree *) openFile -> Get(particleName[selectParticle].c_str());
> 
>        where->cd();
>        particleTree -> Project("hist", "pT/mass:rapidity", dataOption.c_str(), "", 10);
> 
> Cheers,
> Philippe.
> 
> On 5/6/11 7:57 PM, Genie Jhang wrote:

>> Hi.
>>
>> I found something mysterious!!!!
>>
>> Here's the thing.
>>
>> particleTree -> Project("hist", "pT/mass:rapidity", dataOption.c_str());
>>
>> This line doesn't work when I'm using it in the macro file!!!!
>>
>> In command line, it works good. But with macro file, it doesn't give me anything!!!!
>>
>> Is there anyone who is curious about this matter?
>>
>>
>> Here's the full macro code and one of the root files.
>>
>> http://www.majimak.com/pT_y.C
>> http://www.majimak.com/IQMD_AuAu_150_MeV_Hard_Model_1000.root
>>
>> To run the code, you type in command line mode, for example,
>>
>> .L pT_y.C
>> pT_y(0, 1, 15, -0.5, 1, 70, 0, 0.7, 1, 1)
>>
>> Thanks in advance!!!!
>>
>>
>> Genie.
Received on Sun May 22 2011 - 04:22:01 CEST

This archive was generated by hypermail 2.2.0 : Sun May 22 2011 - 17:50:02 CEST