00001
00002
00003
00004
00005
00007 #include <fstream>
00008 #include <iostream>
00009 #include <sstream>
00010 #include <string>
00011 #include <cassert>
00012
00013 #include "TCanvas.h"
00014 #include "TDirectory.h"
00015
00016 #include "MessageService/MsgService.h"
00017
00018 #include "AtNuEvent/AtmosEvent.h"
00019
00020 #include "AtNuUtils/TreeOut.h"
00021
00022 ClassImp(TreeOut)
00023 CVSID("$Id: TreeOut.cxx,v 1.2 2006/07/19 22:41:29 gmieg Exp $");
00024
00025 TreeOut::TreeOut(std::string fname) {
00026 MSG("TreeOut",Msg::kVerbose) << "TreeOut::TreeOut" << endl;
00027
00028 TDirectory *tmpd = gDirectory;
00029 fFile = new TFile(fname.c_str(), "RECREATE");
00030 fTree = new TTree("ntp", "FarDet Atmos Events");
00031 fTree->SetDirectory(fFile);
00032 fEvent = 0;
00033 fTree->Branch("evt", "AtmosEvent", &fEvent);
00034 tmpd->cd();
00035 }
00036
00037 TreeOut::~TreeOut() {
00038 MSG("TreeOut",Msg::kVerbose) << "TreeOut::~TreeOut" << endl;
00039 }
00040
00041 void TreeOut::MakeHistos() {
00042 MSG("TreeOut",Msg::kVerbose) << "TreeOut::MakeHistos" << endl;
00043 }
00044
00045 void TreeOut::MakeCanvases() {
00046 MSG("TreeOut",Msg::kVerbose) << "TreeOut::MakeCanvases" << endl;
00047 }
00048
00049 bool TreeOut::FillEvent(const AtmosEvent *event) {
00050 MSG("TreeOut",Msg::kVerbose) << "TreeOut::FillEvent" << endl;
00051
00052 if (!event) {
00053 MSG("TreeOut",Msg::kWarning)<< "No Event in TreeOut::FillEvent" << endl;
00054 return false;
00055 }
00056
00057
00058 fEvent = event;
00059 if(!fEvent) return false;
00060
00061 TDirectory* tmpd = gDirectory;
00062 fFile->cd();
00063 fTree->Fill();
00064 gDirectory = tmpd;
00065
00066 return(true);
00067 }
00068
00069 void TreeOut::Reset() {
00070 MSG("TreeOut",Msg::kVerbose) << "TreeOut::Reset" << endl;
00071 }
00072
00073 void TreeOut::Finish() {
00074 MSG("TreeOut",Msg::kVerbose) << "TreeOut::Finish" << endl;
00075 TDirectory* tmpd = gDirectory;
00076 fFile->cd();
00077 fTree->SetDirectory(fFile);
00078 fTree->Write();
00079 fFile->Write();
00080 fFile->Close();
00081 gDirectory = tmpd;
00082 }