Re: tree -> Project doesn't work!

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Mon, 9 May 2011 11:58:50 -0500


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 Mon May 09 2011 - 18:58:59 CEST

This archive was generated by hypermail 2.2.0 : Sun May 22 2011 - 05:50:01 CEST