本文整理汇总了C++中TTree::GetTreeNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ TTree::GetTreeNumber方法的具体用法?C++ TTree::GetTreeNumber怎么用?C++ TTree::GetTreeNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTree
的用法示例。
在下文中一共展示了TTree::GetTreeNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadTree
Long64_t CalibTree::LoadTree(Long64_t entry) {
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (fChain->GetTreeNumber() != fCurrent) {
fCurrent = fChain->GetTreeNumber();
Notify();
}
return centry;
}
示例2: GrowTree
//.........这里部分代码省略.........
assert(inputExpressionsReg1.size() == nvars);
/// Load TMVA weights
TString weightdir = "weights/";
TString weightfile = weightdir + "TMVARegression_" + regMethod + ".testweights.xml";
reader->BookMVA(regMethod + " method", weightfile);
TStopwatch sw;
sw.Start();
/// Create TTreeFormulas
TTreeFormula *ttf = 0;
std::vector < TTreeFormula * >::const_iterator formIt, formItEnd;
std::vector < TTreeFormula * > inputFormulasReg0;
std::vector < TTreeFormula * > inputFormulasReg1;
std::vector < TTreeFormula * > inputFormulasFJReg0;
std::vector < TTreeFormula * > inputFormulasFJReg1;
std::vector < TTreeFormula * > inputFormulasFJReg2;
for (UInt_t iexpr = 0; iexpr < nvars; iexpr++) {
ttf = new TTreeFormula(Form("ttfreg%i_0", iexpr), inputExpressionsReg0.at(iexpr).c_str(), inTree);
ttf->SetQuickLoad(1);
inputFormulasReg0.push_back(ttf);
ttf = new TTreeFormula(Form("ttfreg%i_1", iexpr), inputExpressionsReg1.at(iexpr).c_str(), inTree);
ttf->SetQuickLoad(1);
inputFormulasReg1.push_back(ttf);
}
///-- Loop over events -----------------------------------------------------
Int_t curTree = inTree->GetTreeNumber();
const Long64_t nentries = inTree->GetEntries();
if (endEntry < 0) endEntry = nentries;
Long64_t ievt = 0;
for (ievt=TMath::Max(ievt, beginEntry); ievt<TMath::Min(nentries, endEntry); ievt++) {
if (ievt % 2000 == 0)
std::cout << "--- ... Processing event: " << ievt << std::endl;
const Long64_t local_entry = inTree->LoadTree(ievt); // faster, but only for TTreeFormula
if (local_entry < 0) break;
inTree->GetEntry(ievt); // same event as received by LoadTree()
if (inTree->GetTreeNumber() != curTree) {
curTree = inTree->GetTreeNumber();
for (formIt=inputFormulasReg0.begin(), formItEnd=inputFormulasReg0.end(); formIt!=formItEnd; formIt++)
(*formIt)->UpdateFormulaLeaves(); // if using TChain
for (formIt=inputFormulasReg1.begin(), formItEnd=inputFormulasReg1.end(); formIt!=formItEnd; formIt++)
(*formIt)->UpdateFormulaLeaves(); // if using TChain
for (formIt=inputFormulasFJReg0.begin(), formItEnd=inputFormulasFJReg0.end(); formIt!=formItEnd; formIt++)
(*formIt)->UpdateFormulaLeaves(); // if using TChain
for (formIt=inputFormulasFJReg1.begin(), formItEnd=inputFormulasFJReg1.end(); formIt!=formItEnd; formIt++)
(*formIt)->UpdateFormulaLeaves(); // if using TChain
for (formIt=inputFormulasFJReg2.begin(), formItEnd=inputFormulasFJReg2.end(); formIt!=formItEnd; formIt++)
(*formIt)->UpdateFormulaLeaves(); // if using TChain
ttf_lheweight->UpdateFormulaLeaves();
}
/// These need to be called when arrays of variable size are used in TTree.
for (formIt=inputFormulasReg0.begin(), formItEnd=inputFormulasReg0.end(); formIt!=formItEnd; formIt++)
示例3: SkimClassification
void SkimClassification(TString process="ZnnH125")
{
gROOT->LoadMacro("HelperFunctions.h" ); // make functions visible to TTreeFormula
gROOT->SetBatch(1);
//TChain * chain = new TChain("tree");
//TString fname = "";
//TString dijet = "DiJetPt_";
//TString dirMC = "dcache:/pnfs/cms/WAX/resilient/jiafu/ZnunuHbb/" + tagMC + "/";
//TString dirData = "dcache:/pnfs/cms/WAX/resilient/jiafu/ZnunuHbb/" + tagData + "/";
TString indir = "/afs/cern.ch/work/d/degrutto/public/MiniAOD/ZnnHbb_Spring15_PU20bx25/skimV12_v2/step3/";
TString outdir = "/afs/cern.ch/work/d/degrutto/public/MiniAOD/ZnnHbb_Spring15_PU20bx25/skimV12_v2/step3/skim_ZnnH_classification/";
TString prefix = "Step3_";
TString suffix = ".root";
TFile *input = TFile::Open(indir + prefix + process + suffix);
if (!input) {
std::cout << "ERROR: Could not open input file." << std::endl;
exit(1);
}
TTree *tree = (TTree *) input->Get("tree");
Long64_t entries = tree->GetEntriesFast();
// Make output directory if it doesn't exist
if (gSystem->AccessPathName(outdir))
gSystem->mkdir(outdir);
TString outname = outdir + prefix + Form("%s.root", process.Data());
TFile* output = TFile::Open(outname, "RECREATE");
// Get selections
const std::vector < std::string > & selExpressions = GetSelExpressions("ZnunuHighPt") ;
// const UInt_t nsels = 3; // ZnunuHighPt, ZnunuLowPt, ZnunuLowCSV
const UInt_t nsels = 1; // just one now... ZnunuHighPt, ZnunuLowPt, ZnunuLowCSV
// assert(nsels == selExpressions.size()); <-- fixME
// even-number events for training, odd-number events for testing
TCut evenselection = "evt %2 == 0";
TCut oddselection = "evt %2 == 1";
TTreeFormula *ttf = 0;
std::vector < TTreeFormula * >::const_iterator formIt, formItEnd;
// Loop over selections
std::vector<Long64_t> ventries;
for (unsigned int i = 0; i < nsels; i++) {
TString selname = "ZnunuHighPt";
if (i == 1) {
selname = "ZnunuMedPt";
// selExpressions = GetSelExpressions("ZnunuMedPt") ;
} else if (i == 2) {
selname = "ZnunuLowPt";
// selExpressions = GetSelExpressions("ZnunuLowPt") ;
}
TTree *t1 = (TTree*) tree->CloneTree(0);
TTree *t2 = (TTree*) tree->CloneTree(0);
t1->SetName(TString::Format("%s_%s_train", tree->GetName(), selname.Data()));
t2->SetName(TString::Format("%s_%s", tree->GetName(), selname.Data()));
// The clones should not delete any shared i/o buffers.
ResetDeleteBranches(t1);
ResetDeleteBranches(t2);
ttf = new TTreeFormula(Form("ttfsel%i", i), selExpressions.at(i).c_str(), tree);
ttf->SetQuickLoad(1);
TTreeFormula *ttf1 = new TTreeFormula(Form("ttfeven%i", i), evenselection, tree);
ttf1->SetQuickLoad(1);
TTreeFormula *ttf2 = new TTreeFormula(Form("ttfodd%i", i), oddselection, tree);
ttf2->SetQuickLoad(1);
if (!ttf || !ttf->GetNdim()) {
std::cerr << "ERROR: Failed to find any TTree variable from the selection: " << selExpressions.at(i) << std::endl;
return;
}
/// Loop over events
Int_t curTree = tree->GetTreeNumber();
const Long64_t nentries = tree->GetEntries();
for (Long64_t ievt = 0; ievt < nentries; ievt++) {
Long64_t entryNumber = tree->GetEntryNumber(ievt);
if (entryNumber < 0) break;
Long64_t localEntry = tree->LoadTree(entryNumber);
if (localEntry < 0) break;
if (tree->GetTreeNumber() != curTree) {
curTree = tree->GetTreeNumber();
ttf ->UpdateFormulaLeaves(); // if using TChain
ttf1->UpdateFormulaLeaves(); // if using TChain
ttf2->UpdateFormulaLeaves(); // if using TChain
}
const Int_t ndata = ttf->GetNdata();
Bool_t keep = kFALSE;
for(Int_t current = 0; current<ndata && !keep; current++) {
keep |= (bool(ttf->EvalInstance(current)) != 0);
}
if (!keep) continue;
//.........这里部分代码省略.........