00001 #include "StMaker.h"
00002
00003
00004 #include <StMuDSTMaker/COMMON/StMuDstMaker.h>
00005 #include <StMuDSTMaker/COMMON/StMuDst.h>
00006 #include <StMuDSTMaker/COMMON/StMuEvent.h>
00007
00008 #include <TChain.h>
00009 #include <TDirectory.h>
00010
00011 #include <libgen.h>
00012
00013 #include <string>
00014 #include <cstring>
00015
00016 using namespace std;
00017
00018 class StjMuDstFileNameMaker : public StMaker {
00019
00020 public:
00021
00022 StjMuDstFileNameMaker(const Char_t *name, TDirectory* file, StMuDstMaker* uDstMaker)
00023 : StMaker(name), _file(file), _uDstMaker(uDstMaker)
00024 { }
00025
00026 virtual ~StjMuDstFileNameMaker() { }
00027
00028 const char* GetCVS() const
00029 {static const char cvs[]="Tag $Name: $ $Id: StjMuDstFileNameMaker.C,v 1.1 2008/11/10 22:17:25 tai Exp $ built "__DATE__" "__TIME__; return cvs;}
00030
00031 private:
00032
00033 TDirectory* _file;
00034 TTree* _tree;
00035
00036 StMuDstMaker* _uDstMaker;
00037
00038 Int_t _runNumber;
00039 Int_t _eventId;
00040 Double_t _vertexZ;
00041 Char_t _mudstName[256];
00042
00043 string getMuDstFileName()
00044 {
00045 string filepath(_uDstMaker->chain()->GetFile()->GetName());
00046 char *chFilepath = new char[filepath.size() + 1];
00047 sprintf(chFilepath, "%s", filepath.c_str());
00048 string filename = basename(chFilepath);
00049 delete[] chFilepath;
00050 return filename;
00051 }
00052
00053 public:
00054
00055 Int_t Init()
00056 {
00057 _file->cd();
00058 _tree = new TTree("mudstName", "mudstName");
00059 _tree->Branch("runNumber" , &_runNumber , "runNumber/I" );
00060 _tree->Branch("eventId" , &_eventId , "eventId/I" );
00061 _tree->Branch("vertexZ" , &_vertexZ , "vertexZ/D" );
00062 _tree->Branch("mudstName" , &_mudstName , "mudstName[256]/C" );
00063 return kStOk;
00064 }
00065
00066 Int_t Make()
00067 {
00068 string finlename = getMuDstFileName();
00069 _runNumber = _uDstMaker->muDst()->event()->runId();
00070 _eventId = _uDstMaker->muDst()->event()->eventId();
00071 _vertexZ = _uDstMaker->muDst()->event()->primaryVertexPosition().z();
00072
00073 strcpy(_mudstName, finlename.c_str());
00074 _tree->Fill();
00075 return kStOk;
00076 }
00077
00078 Int_t Finish()
00079 {
00080 _tree->BuildIndex("runNumber", "eventId");
00081 return kStOk;
00082 }
00083 ClassDef(StjMuDstFileNameMaker, 0)
00084 };