/// \file /// \ingroup tutorial_proofntuple /// /// Selector to fill a simple ntuple /// /// \macro_code /// /// \author Gerardo Ganis (gerardo.ganis@cern.ch) #ifndef SelGetSplitData_h #define SelGetSplitData_h #include #include #include #include #include #include #include #include #include class SelGetSplitData : public TSelector { public : TTree *fChain; //!pointer to the analyzed TTree or TChain // Specific members TTree *fOutTree ; //!SetMakeClass(1); // Set the branch addresses now TString token, subtoken_branch, subtoken_type ; Ssiz_t from = 0 ; Int_t iF = 0, iD = 0, iI = 0, ii = 0, iS = 0, is = 0 ; Int_t fCurrentBranch = 0 ; TObjArray *str_arr ; TObjString *objStr1, *objStr2 ; while ( fDataLeavesString.Tokenize(token,from,":") ) { str_arr = token.Tokenize("/") ; if(!str_arr) { Error("InitMembers","Bad Leaf decsriptor \"%s\"\n",token.Data()) ; Abort("") ; } else { objStr1 = (TObjString*)(str_arr->At(0)) ; objStr2 = (TObjString*)(str_arr->At(1)) ; if(!objStr1 || !objStr2) { Error("InitMembers","Bad Leaf decsriptor \"%s\"\n",token.Data()) ; Abort("") ; } else { subtoken_branch = objStr1 -> GetString() ; subtoken_type = objStr2 -> GetString() ; if(subtoken_type.CompareTo("D")) { fChain -> SetBranchAddress(subtoken_branch.Data(),&fDoubleVars[iD],&fBranches[fCurrentBranch]) ; ++iD ; } else if(subtoken_type.CompareTo("F")) { fChain -> SetBranchAddress(subtoken_branch.Data(),&fFloatVars[iF],&fBranches[fCurrentBranch]) ; ++iF ; } else if(subtoken_type.CompareTo("I")) { fChain -> SetBranchAddress(subtoken_branch.Data(),&fIntVars[iI],&fBranches[fCurrentBranch]) ; ++iI ; } else if(subtoken_type.CompareTo("i")) { fChain -> SetBranchAddress(subtoken_branch.Data(),&fUIntVars[ii],&fBranches[fCurrentBranch]) ; ++ii ; } else if(subtoken_type.CompareTo("S")) { fChain -> SetBranchAddress(subtoken_branch.Data(),&fShortVars[iS],&fBranches[fCurrentBranch]) ; ++iS ; } else if(subtoken_type.CompareTo("s")) { fChain -> SetBranchAddress(subtoken_branch.Data(),&fUShortVars[is],&fBranches[fCurrentBranch]) ; ++is ; } else { Error("InitMembers","Invalid branch type '%s'\n",subtoken_type.Data()) ; Abort("") ; } ++fCurrentBranch ; } } } } Bool_t SelGetSplitData::Notify() { // The Notify() function is called when a new file is opened. This // can be either for a new TTree in a TChain or when when a new TTree // is started when using PROOF. It is normally not necessary to make changes // to the generated code, but the routine can be extended by the // user if needed. The return value is currently not used. return kTRUE; } #endif