Cloned TH1D not showing up in TFile

Hello,

I’m running code to have ROOT put event data into a histogram, and I would like a copy of each individual event’s histogram. This is my code for cloning the histogram:

TString newName_hi = "nh_"; newName_hi += evtCount; TH1 *h = (TH1 *)evis_rms_hcin->Clone(newName_hi);

As far as I know, given that evis_rms_hcin is the histogram I want to clone in the current event (numbered with an integer evtCount), this should work fine. It compiles without complaint and ROOT seems happy to work with it. Any help is appreciated.

Hi,

In the case of Clone you need to explicitly attach the histogram to the output file, so do:TString newName_hi = "nh_"; newName_hi += evtCount; TH1 *h = (TH1 *)evis_rms_hcin->Clone(newName_hi); h->SetDirectory( output_file_pointer );

Cheers,
Philippe.

Hi,

Thanks for the help, that worked!

Thanks,
Derek