13 #include "StJetMuEvent.h"
14 #include "StJetFilter.h"
19 : mIoType(type), mEventCounter(0), mFile(0), mTree(0), mEvent(new
StJetMuEvent)
21 cout <<
"StJetFilter::StJetFilter()"<<endl;
24 cout <<
"\tOpen file in write mode"<<endl;
25 mFile =
new TFile(file,
"RECREATE");
26 mFile->SetCompressionLevel(9);
29 mTree =
new TTree(
"mTree",
"StUpsilon Tree");
30 mTree->SetBranchStyle(0);
32 Int_t bufsize = 20000;
35 mTree->Branch(
"StJetMuEvent",
"StJetMuEvent",&mEvent,bufsize,split);
37 else if (type==kRead) {
38 cout <<
"\tOpen file in read mode"<<endl;
39 mFile =
new TFile(file,
"READ");
42 TTree* temp =
dynamic_cast<TTree*
>(mFile->Get(
"mTree"));
44 cout <<
"Could not recover TTree from file:\t"<<file<<
" Prepare to crash"<<endl;
47 mTree->SetBranchAddress(
"StJetMuEvent",&mEvent);
51 cout <<
"StJetFilter::StJetFilter(). ERROR:\t"
52 <<
"Undefined ioType. Abort"<<endl;
56 StJetFilter::~StJetFilter()
58 cout <<
"StJetFilter::~StJetFilter()"<<endl;
60 if (mIoType==kWrite) {
75 int StJetFilter::nEvents()
const
77 return (mTree) ?
static_cast<int>(mTree->GetEntries()) : 0;
80 void StJetFilter::setCuts(
const AnaCuts& c)
88 if (mIoType==kWrite) {
89 if (mEvent->fill(maker)) {
90 cout <<
"Event Accepted. Fill TTree"<<endl;
94 cout <<
"Event Rejected, write log"<<endl;
97 else if (mIoType==kRead) {
99 if (mEventCounter<mTree->GetEntries()) {
100 mTree->GetEntry(mEventCounter++);
103 cout <<
"StJetFilter::fill(StMuDstMaker*). Error:\t"
104 <<
"No more entries to get. No action taken"<<endl;
108 cout <<
"StJetFilter::fill(StMuDstMaker*). ERROR:\t"
109 <<
"Undefined ioType. No action taken"<<endl;