#include #include int main() { TFile* in = new TFile("~larcalib/w0/data/WorkingDirectory/00129019_00129020_00129024_Barrel-EMB-EMEC_MEDIUM_26_15.0.0_1/rootFiles/LArCaliWave_00129020_EB-EMBA_StripsXtalkCorr.root","READ"); TFile* out = new TFile ("./out.root","RECREATE"); TTree* cw = (TTree*) (in->Get("CALIWAVE")); cw->Scan ("channelId", "FT==0 && slot==2 && channel==1"); // that works fine! - 1 record is printed out TTree* tr = cw->CopyTree("FT==0 && slot==2 && channel==1"); // that throws a bad_alloc exception out->Write(); out->Close(); in->Close(); }