#ifndef MyronModeAna_h #define MyronModeAna_h #if !defined(__CINT__) || defined(__MAKECINT__) #include #include #include #include #endif class MyronModeAna { public : TTree *fTree; // pointer to the analyzed TTree or TChain Int_t fCurrent; // current Tree number in a TChain // Declaration of leaves types TMyronData* fMyronData; // List of branches (of interest) TBranch *b_MyronData; TBranch *b_Basket0; TBranch *b_Basket1; TBranch *b_Basket2; TBranch *b_Basket3; //----------------------------------------------------------------------------- // local variables //----------------------------------------------------------------------------- TH1F *fHem [48][48][2]; TProfile *fHhad[48][48][2]; //----------------------------------------------------------------------------- // methods //----------------------------------------------------------------------------- MyronModeAna(const char* filename=0); ~MyronModeAna(); Int_t Cut(Int_t entry); Int_t GetEntry(Int_t entry); Int_t LoadTree(Int_t entry); void Init(TTree *tree); void Loop1(int nevents=0); void Loop2(float ehad_min, int nevents=0); void Notify(); void Show(Int_t entry = -1); }; #endif #ifdef MyronModeAna_cxx //_____________________________________________________________________________ MyronModeAna::MyronModeAna(const char* filename) { // if parameter tree is not specified (or zero), connect the file // used to generate this class and read the Tree. TTree* tree; if (filename != 0) { TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(filename); if (!f) { f = new TFile(filename); } tree = (TTree*) f->Get("STNTUPLE"); Init(tree); } } //_____________________________________________________________________________ MyronModeAna::~MyronModeAna() { if (!fTree) return; delete fTree->GetCurrentFile(); } //_____________________________________________________________________________ Int_t MyronModeAna::GetEntry(Int_t entry) { // Read contents of entry. if (!fTree) return 0; return fTree->GetEntry(entry); } //_____________________________________________________________________________ Int_t MyronModeAna::LoadTree(Int_t entry) { // Set the environment to read one entry if (!fTree) return -5; Int_t centry = fTree->LoadTree(entry); if (centry < 0) return centry; if (fTree->IsA() != TChain::Class()) return centry; TChain *chain = (TChain*)fTree; if (chain->GetTreeNumber() != fCurrent) { fCurrent = chain->GetTreeNumber(); Notify(); } return centry; } //_____________________________________________________________________________ void MyronModeAna::Init(TTree *tree) { // Set branch addresses if (tree == 0) return; fTree = tree; fCurrent = -1; fTree->SetBranchAddress("MyronData",&fMyronData); fTree->SetBranchAddress("Basket0" ,&fMyronData->fCalData[0]); fTree->SetBranchAddress("Basket1" ,&fMyronData->fCalData[1]); fTree->SetBranchAddress("Basket2" ,&fMyronData->fCalData[2]); fTree->SetBranchAddress("Basket3" ,&fMyronData->fCalData[3]); Notify(); } //_____________________________________________________________________________ void MyronModeAna::Notify() { // called by LoadTree when loading a new file // get branch pointers b_MyronData = fTree->GetBranch("MyronData"); b_Basket0 = fTree->GetBranch("Basket0"); b_Basket1 = fTree->GetBranch("Basket1"); b_Basket2 = fTree->GetBranch("Basket2"); b_Basket3 = fTree->GetBranch("Basket3"); } void MyronModeAna::Show(Int_t entry) { // Print contents of entry. // If entry is not specified, print current entry if (!fTree) return; fTree->Show(entry); } Int_t MyronModeAna::Cut(Int_t entry) { // This function may be called from Loop. // returns 1 if entry is accepted. // returns -1 otherwise. return 1; } #endif // #ifdef MyronModeAna_cxx