00001 #include <TFile.h>
00002 #include <TTree.h>
00003 #include <TString.h>
00004 #include "TObjString.h"
00005
00006 #include "StMuDSTMaker/COMMON/StMuDst.h"
00007 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00008 #include "StMuDSTMaker/COMMON/StMuEvent.h"
00009 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
00010
00011 #include "StGammaEventMaker.h"
00012 #include "StGammaEvent.h"
00013 #include "StGammaRawMaker.h"
00014
00015 #include "StGammaTreeMaker.h"
00016
00017 ClassImp(StGammaTreeVersion);
00018 ClassImp(StGammaTreeMaker);
00019
00020 using namespace std;
00021
00023
00025 StGammaTreeVersion::StGammaTreeVersion(const char *name, const char *title): TNamed(name, title)
00026 {}
00027
00029
00031 StGammaTreeVersion::~StGammaTreeVersion()
00032 {}
00033
00035
00037 void StGammaTreeVersion::print()
00038 {
00039
00040 cout << "-- List of makers --" << endl << endl;
00041 for(UInt_t i = 0; i < mMakerTags.size(); i++)
00042 {
00043 cout << Form("[%i]: %s", (int)i, mMakerTags[i].Data()) << endl;
00044 }
00045
00046 cout << endl;
00047 cout << "-- List of containers --" << endl << endl;
00048 for (UInt_t i = 0; i < mStorageTags.size(); i++)
00049 {
00050 cout << Form("[%i]: %s", (int)i, mStorageTags[i].Data()) << endl;
00051 }
00052
00053 }
00054
00056
00058 StGammaTreeMaker::StGammaTreeMaker(const char *name): StMaker(name)
00059 {
00060 mFilename="gamma_tree.root";
00061 mGammaFile = 0;
00062 mGammaTree = 0;
00063 mGammaEvent = 0;
00064 mSkipEmpty = true;
00065 }
00066
00068
00070 StGammaTreeMaker::~StGammaTreeMaker()
00071 {}
00072
00074
00076 Int_t StGammaTreeMaker::Init()
00077 {
00078
00079
00080 if(!mGammaFile) mGammaFile = new TFile(mFilename, "RECREATE");
00081
00082
00083 if(!mGammaTree)
00084 {
00085 TString title = "Gamma TTree $Id: StGammaTreeMaker.cxx,v 1.10 2008/12/03 15:39:18 betan Exp $ built "__DATE__" "__TIME__;
00086 mGammaTree = new TTree("gammas", title);
00087 mGammaTree->SetDirectory(mGammaFile);
00088 }
00089
00090
00091 StGammaEventMaker *mGammaEventMaker = dynamic_cast<StGammaEventMaker*>(GetMakerInheritsFrom("StGammaEventMaker"));
00092 if(!mGammaEventMaker)
00093 {
00094 LOG_DEBUG << "Make() - No StGammaEventMaker found!" << endm;
00095 return kStFatal;
00096 }
00097
00098 mGammaEvent = mGammaEventMaker->event();
00099 mGammaTree->Branch("GammaEvent", &mGammaEvent, 32000, 99);
00100 mGammaTree->BranchRef();
00101
00102
00103 mVersion.mStorageTags.push_back( TString(mGammaEvent->GetCVS()) );
00104 mVersion.mStorageTags.push_back( TString(mGammaEvent->newCandidate()->GetCVS()) );
00105 mVersion.mStorageTags.push_back( TString(mGammaEvent->newTower()->GetCVS()) );
00106 mVersion.mStorageTags.push_back( TString(mGammaEvent->newTrack()->GetCVS()) );
00107 mVersion.mStorageTags.push_back( TString(mGammaEvent->newStrip()->GetCVS()) );
00108 mVersion.mStorageTags.push_back( TString(mGammaEvent->candidate(0)->smdFit().GetCVS() ) );
00109
00110
00111 mGammaEvent->Clear();
00112
00113 assert(mGammaFile);
00114 assert(mGammaTree);
00115
00116 return StMaker::Init();
00117
00118 }
00119
00121
00123 void StGammaTreeMaker::Clear(Option_t *opts)
00124 {
00125 mGammaEvent->Clear();
00126 StMaker::Clear(opts);
00127 }
00128
00130
00132 Int_t StGammaTreeMaker::Make()
00133 {
00134
00135 if( !GetDataSet("MuDst") )
00136 {
00137 LOG_DEBUG << "Make() - MuDst not found!" << endm;
00138 return kStFatal;
00139 }
00140
00141
00142
00143
00144
00145 if(mSkipEmpty)
00146 {
00147 if(mGammaEvent->numberOfCandidates() > 0) mGammaTree->Fill();
00148 }
00149 else
00150 {
00151 mGammaTree->Fill();
00152 }
00153
00154 return kStOK;
00155
00156 }
00157
00159
00161 Int_t StGammaTreeMaker::Finish()
00162 {
00163
00164
00165
00166
00167 TString cvstag = GetCVS();
00168
00169 TIter next( GetParentChain()->GetMakeList());
00170 mVersion.mMakerTags.push_back( cvstag );
00171
00172 StMaker *maker;
00173 while(maker = (StMaker*)next())
00174 {
00175 cvstag = maker->GetCVS();
00176 mVersion.mMakerTags.push_back(cvstag);
00177 }
00178
00179 LOG_QA <<" -- StGammaMaker versioning information follows --" << endm;
00180 mVersion.print();
00181
00182
00183 mGammaFile->cd();
00184 mVersion.Write();
00185 mGammaTree->Write();
00186
00187 return kStOK;
00188
00189 }