//------------------------ detclass.C ---------------------------- #include "detclass.h" #include "TROOT.h" #include #include #include using std::cout; using std::endl; ClassImp(Axis) ClassImp(Event) void detwrite(const char* ofname="detclass.root", Int_t num=10) { TFile* outfile = new TFile(ofname,"recreate"); cout << "detwrite: output file " << outfile->GetName() << endl; TTree* tree = new TTree("t","dettree"); Event* evt = new Event(); tree->Bronch("evt", "Event", &evt); cout << "detwrite: start loop" << endl; for (int jentry=0; jentryclear(); Int_t nax = 0; // haven't added any yet for(int iax = 0; iax < 3; iax++){ Axis *axis = new Axis(iax, 32); cout << "\tAxis: " << iax << "\n"; for(int ich = 0; ich < 32; ich++){ axis-> chnum [ich] = ich+5; axis-> chdata[ich] = 1.02+ich*0.0625; cout << "\t\tChannel[" << axis-> chnum[ich] << "]: " << axis-> chdata[ich] << "\n"; } evt -> AddAxis(axis); delete axis; nax++; }// end axis loop evt->evt = jentry; evt->nhps = 1; evt->naxis = nax; // should be three evt->timestamp = 100000+jentry*125; tree->Fill(); }// end events loop delete evt; cout<< "detwrite: Filled events: " << tree->GetEntries() << endl; outfile = tree->GetCurrentFile(); if (outfile) { outfile->Write(); outfile->Close(); } }// end jetwrite