本文整理汇总了C++中TTree::Scan方法的典型用法代码示例。如果您正苦于以下问题:C++ TTree::Scan方法的具体用法?C++ TTree::Scan怎么用?C++ TTree::Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTree
的用法示例。
在下文中一共展示了TTree::Scan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_SyntBranch
void read_SyntBranch() {
gSystem->Load("libCintex");
Cintex::Enable();
gSystem->Load("libPoolTestsPoolTreeTests");
TFile f("T1.root");
TTree * t = (TTree*)f.Get("Syn");
t->Show(7);
t->Scan("m_2:m_3","id<10");
t->Scan("","id<5");
}
示例2: Enum
void Enum() {
TTree *t = new TTree;
WithEnum *e = new WithEnum;
t->Branch("test",&e);
t->Fill();
t->Fill();
#ifdef ClingWorkAroundCallfuncAndInline2
t->Scan("test.val");
#else
t->Scan("test.val:test.GetVal()");
#endif
}
示例3: rundeepClass
int rundeepClass()
#endif
{
TFile OriginalFile("ver_40200.root");
TFile CopyFile("CopyTree.root");
TTree* OriginalTree = (TTree*) OriginalFile.Get("NtpSt");
TTree* CopyTree = (TTree*) CopyFile.Get("NtpSt");
OriginalTree->Scan("fHeader.fVldContext.fDetector:fHeader.fVldContext.fSimFlag:fHeader.fVldContext.fTimeStamp.fSec","","colsize=20",10);
CopyTree->Scan("fHeader.fVldContext.fDetector:fHeader.fVldContext.fSimFlag:fHeader.fVldContext.fTimeStamp.fSec","","colsize=20",10);
return 0;
}
示例4: dumpSome
void dumpSome(string infile, string field, string obj = "lb", string addCut = "")
{
TFile* tfIn = TFile::Open(infile.c_str(), "READ");
if (tfIn == 0)
{
cout << "Problem opening infile \"" << infile << "\" - exting";
return;
}
TTree* intree = (TTree*) tfIn->Get("events");
// cut selection
Cuts cut;
if (obj == "lb") cut.selectCut("acc03","lb07");
if (obj == "B0") cut.selectCut("acc03B0","B001");
//if (obj == "B0") cut.selectCut("acc03B0","B001exp");
if (addCut.size() > 0)
intree->Draw(">>lst", (cut.getCut()+"&&"+addCut).c_str());
else
intree->Draw(">>lst", cut.getCut().c_str());
TEventList *lst = (TEventList*)gDirectory->Get("lst");
intree->SetEventList(lst);
intree->SetScanField(-1);
intree->Scan(field.c_str());
}
示例5: tscan
void tscan(const char *input) {
TFile* tf = new TFile(input);
TTree* tree = (TTree*)tf->Get("tree");
tree->Draw("aa[][]");
tree->SetScanField(0);
tree->Scan("aa");
}
示例6: runstring
void runstring() {
TString *sone = new TString("topsone");
string *stwo = new string("topstwo");
vector<TString> *sthree = new vector<TString>;
vector<string> *sfour = new vector<string>;
vector<bool> sfive;
vector<int> ssix;
sthree->push_back("sthree_1");
sthree->push_back("sthree_2");
sfour->push_back("sfour_1");
sfour->push_back("sfour_2");
sfive.push_back(false);
sfive.push_back(true);
sfive.push_back(false);
ssix.push_back(33);
myclass *m = new myclass(1);
TFile *f = new TFile("string.root","RECREATE");
TTree *t = new TTree("T","T");
t->Branch("sone",&sone,32000,0);
t->Branch("stwo",&stwo,32000,0);
t->Branch("sthree",&sthree,32000,0);
t->Branch("sfour",&sfour,32000,0);
t->Branch("obj.",&m);
t->Branch("sfive",&sfive);
t->Branch("ssix",&ssix);
t->Fill();
f->Write();
t->Show(0);
t->Scan("*");
t->Scan("sone");
t->Scan("stwo");
t->Scan("sthree.Data()");
t->Scan("sfour.c_str()");
}
示例7: DrawFriend
void DrawFriend() {
// Draw a scatter plot of variable x in the parent TTree versus
// the same variable in the subtree.
// This should produce points along a straight line.
TFile *f = TFile::Open("treeparent.root");
TTree *T = (TTree*)f->Get("T");
T->AddFriend("TF","treefriend.root");
T->SetScanField(0);
T->Scan("x:TF.x","","",20);
}
示例8: modulo
TTree* modulo() {
TTree *tree = new TTree("T","T");
UInt_t i = 1<<31;
Int_t k = 1<<20;
tree->Branch("unsignedInt",&i,"unsignedInt/i");
tree->Branch("signedInt",&k,"signedInt/I");
for(int j=0;j<2;++j) {
tree->Fill();
k = -k;
}
i = 2763;
k = 11*i;
tree->Fill();
tree->Scan("signedInt:signedInt%235");
tree->Scan("unsignedInt:unsignedInt%235","","colsize=15");
tree->Scan("(signedInt/unsignedInt):(signedInt/unsignedInt)%10");
return tree;
}
示例9: make_run_table
void make_run_table(const char * infile="rtree.root")
{
TFile * tf = new TFile(infile,"READ");
TTree * tr = (TTree*) tf->Get("rellum");
tr->SetScanField(0);
char outfile[64];
strcpy(outfile,"run_table.txt");
gSystem->RedirectOutput(outfile,"w");
tr->Scan("i:runnum:fi:fill");
gSystem->RedirectOutput(0);
printf("%s created\n",outfile);
};
示例10: runprova
int runprova()
{
TChain *chain_null = new TChain("Eventi");
chain_null->Add("prova1.root");
chain_null->Add("prova2.root");
chain_null->Draw("br.n_run");
chain_null->Merge("merge.root");
TFile *f = new TFile("merge.root");
TTree *t; f->GetObject("Eventi",t);
t->Scan("br.n_ev");
return 0;
}
示例11: runmixing
void runmixing(bool scan = false)
{
int len = 5;
std::vector<MyClass> *p = new std::vector<MyClass>;
TTree *t = new TTree("tree","bad vector");
t->Branch("checked_value", "vector<MyClass>", &p);
t->Branch("value", "vector<MyClass>", (void*)&p);
for(int i = 0; i<len; ++i) {
p->push_back( MyClass( i*12 ) );
if (scan) t->Fill();
}
t->SetBranchAddress("value",&p);
if (scan) {
//t->Print();
t->Scan("*");
}
}
示例12: runnestedind
int runnestedind() {
TTree *t = create();
t->SetScanField(0);
t->Scan("type[]:type[sonind[]]","type[]==3");
TH1I* hgood = new TH1I("hgood","works",10,0,10);
TH1I* hbad = new TH1I("hbad","used to fail",10,0,10);
TCanvas *c = new TCanvas("c1");
c->Divide(1,2);
c->cd(1);
t->Draw("type[sonind[]]>>hbad","type[]==3");
c->cd(2);
t->Draw("type[sonind[]]>>hgood","type[]==3 && sonind[]>=0");
if (hgood->GetMean()!=hbad->GetMean()) {
cout << "Drawing \"type[sonind[]]>>hbad\",\"type[]==3\" failed!\n";
return 1;
}
#ifdef ClingWorkAroundErracticValuePrinter
printf("(int)0\n");
#endif
return 0;
}
示例13: dumpTrees
void dumpTrees(TString dir = "zz4lTree", const char *cut="", int maxEvents = 200, const char *process=0) {
TTree *Events = (TTree *) gFile->Get(dir+"/probe_tree");
if (Events == 0) { std::cerr << "Didn't find " << dir << " in file " << gFile->GetName() << std::endl; return; }
Events->SetScanField(0);
if (dir.Contains("4l") || dir.Contains("4L")) {
Events->Scan("event:mass:m4l:z1mass:z2mass:l1pdgId:l1pt:l1eta:l2pt:l2eta:l3pdgId:l3pt:l3eta:l4pt:l4eta:massErr:melaLD:pho1pt:pho1eta:pho2pt:pho2eta:jet1pt:jet1eta:jet2pt:jet2eta:mjj:njets30",cut,"",maxEvents);
//} else if (dir.Contains("anyZllTree")) {
// Events->Scan("event:zmass:l1pdgId:l1pt:l1eta:l2pt:l2eta:l1pfIsoComb04EACorr/l1pt:l2pfIsoComb04EACorr/l2pt:l1sip:l2sip",cut,"",maxEvents);
} else if (dir.Contains("muonTree")) {
Events->Scan("event:pt:eta:phi:looseID:newID:prlID:mvaISO:sip:pfIsoComb04EACorr:bdtIso:mvaISO:pfIsoChHad04:pfIsoNHad04_NoEA:pfIsoPhot04_NoEA:pfIsoEAtot:rho:rhoAA",cut,"",maxEvents);
} else if (dir.Contains("electronTree")) {
Events->Scan("event:pt:eta:phi:looseID:newID:prlID:sip:pfIsoComb04EACorr:bdtIso:bdtID:mvaISO:mvaID:pfIsoChHad04:pfIsoNHad04_NoEA:pfIsoPhot04_NoEA:pfIsoEAtot:rho:rhoAA",cut,"",maxEvents);
} else if (dir.Contains("jetTree")) {
Events->Scan("event:pt:eta:phi:passID:passPUID:puJetIDMask:jetIDMVA",cut,"",maxEvents);
} else if (dir.Contains("photonTree")) {
Events->Scan("event:pt:eta:phi:deltaR:eleMatch:lepMatchNoIso:lepMatch:pfIsoChHad03pt02:pfIsoNHad03:pfIsoPhot03:pfIsoChHadPU03pt02",cut,"",maxEvents);
} else if (dir.Contains("zeetree")) {
Events->Scan("event:zmass:zmll:l1pt:l1eta:l1phi:l2pt:l2eta:l2phi:fsr:phopt:phoeta:phophi",cut,"",maxEvents);
} else if (dir.Contains("zmmtree")) {
Events->Scan("event:zmass:zmll:l1pt:l1eta:l1phi:l2pt:l2eta:l2phi:fsr:phopt:phoeta:phophi",cut,"",maxEvents);
}
}
示例14: check
bool check(int n = 2) {
TFile *file = TFile::Open(TString::Format("merged%d.root",n));
bool result = true;
TH1F *h; file->GetObject("h1",h);
if (!h) {
Error("execFileMerger","h1 is missing\n");
result = false;
}
if (h->GetBinContent(2) != n || h->GetBinContent(3) != n) {
Error("execFileMerger","h1 not added properly");
result = false;
}
THnSparseF *sparse; file->GetObject("sparse",sparse);
if (!sparse) {
Error("execFileMerger","sparse is missing\n");
result = false;
} else {
Int_t coordIdx[5] = {1, 2, 3, 4, 5};
Double_t cont = sparse->GetBinContent(coordIdx);
if (cont > n + 0.4 || cont < n - 0.4) {
Error("execFileMerger","sparse merge failed: expected bin content %g, read %g\n",
(Double_t)n, cont);
result = false;
}
Double_t entries = sparse->GetEntries();
if (entries > n + 0.4 || entries < n - 0.4) {
Error("execFileMerger","sparse merge failed: expected %g entries, read %g\n",
(Double_t)n, entries);
result = false;
}
}
THStack *stack; file->GetObject("stack",stack);
if (!stack) {
Error("execFileMerger","stack is missing\n");
result = false;
}
h = (TH1F*)stack->GetHists()->FindObject("hs_1");
if (!h) {
Error("execFileMerger","hs_1 is missing\n");
result = false;
}
if (h->GetBinContent(2) != n || h->GetBinContent(3) != n) {
Error("execFileMerger","hs_1 not added properly");
result = false;
}
h = (TH1F*)stack->GetHists()->FindObject("hs_2");
if (!h) {
Error("execFileMerger","hs_2 is missing\n");
result = false;
}
if (h->GetBinContent(4) != n || h->GetBinContent(5) != n) {
Error("execFileMerger","hs_2 not added properly");
result = false;
}
TGraph *gr; file->GetObject("exgraph",gr);
if (!gr) {
Error("execFileMerger","exgraph is missing\n");
result = false;
}
if (gr->GetN() != ( n * 3)) {
Error("execFileMerger","exgraph not added properly n=%d rather than %d",gr->GetN(),n*3);
result = false;
} else {
for(Int_t k = 0; k < gr->GetN(); ++k) {
double x,y;
gr->GetPoint(k,x,y);
if ( x != ( (k%3)+1 ) || y != ( (k%3)+1 ) ) {
Error("execFileMerger","exgraph not added properly");
result = false;
}
}
}
TTree *tree; file->GetObject("tree",tree);
if (!tree) {
Error("execFileMerger","tree is missing\n");
result = false;
}
if (tree->GetEntries() != n*2) {
Error("execFileMerger","tree does not have the expected number of entries: %lld rather than %d",tree->GetEntries(),n*2);
result = false;
} else {
if ( tree->GetEntries("data==1") != n ) {
Error("execFileMerger","tree does not have the expected data. We got %lld entries with 'data==1' rather than %d",tree->GetEntries("data==1"),n);
tree->Scan();
result = false;
}
}
return result;
}
示例15: abs
forSync_ee() {
ofstream fout;
TString decay="ElEl";
// TString sample="ZJets";
TString sample="TTbarTuneZ2";
fout.open(decay+"_"+sample+".txt");
// fout.open(decay+"_"+sample+"_ALL.txt");
TFile* f = TFile::Open("./"+decay+"/vallot_"+sample+".root");
// TFile* f = TFile::Open("./"+decay+"/vallot_"+sample+"_ALL.root");
TTree* tree = (TTree*)f->Get("ElEl/tree");
bool scan=true;
double step0, step1, step2, step3, step4, step5;
TCut cut0 = "";
TCut cut1 = "ZMass > 12 && relIso1 < 0.17 && relIso2 < 0.17 && PairSign < 0 && pt1 > 20 && pt2 > 20";
TCut cut2 = cut1 && "abs(ZMass - 91.2) > 15";
TCut cut3 = cut2 && "@jetspt30.size() >= 2";
TCut cut4 = cut3 && "MET > 30";
TCut cut5 = cut4 && "nbjets_CSVL >= 1";
/* step0=tree->GetEntries();
step1=tree->GetEntries("ZMass > 12 && relIso1 < 0.2 && relIso2 < 0.2 && PairSign < 0 && pt1 > 20 && pt2 > 20");
step2=tree->GetEntries("ZMass > 12 && relIso1 < 0.2 && relIso2 < 0.2 && PairSign < 0 && pt1 > 20 && pt2 > 20 && abs(ZMass - 91.2) > 15");
step3=tree->GetEntries("ZMass > 12 && relIso1 < 0.2 && relIso2 < 0.2 && PairSign < 0 && pt1 > 20 && pt2 > 20 && abs(ZMass - 91.2) > 15 && @jetspt30.size() >= 2");
step4=tree->GetEntries("ZMass > 12 && relIso1 < 0.2 && relIso2 < 0.2 && PairSign < 0 && pt1 > 20 && pt2 > 20 && abs(ZMass - 91.2) > 15 && @jetspt30.size() >= 2 && MET > 30");
step5=tree->GetEntries("ZMass > 12 && relIso1 < 0.2 && relIso2 < 0.2 && PairSign < 0 && pt1 > 20 && pt2 > 20 && abs(ZMass - 91.2) > 15 && @jetspt30.size() >= 2 && MET > 30 && nbjets_CSVL >= 1");
*/
step0=tree->GetEntries();
step1=tree->GetEntries(cut1);
step2=tree->GetEntries(cut2);
step3=tree->GetEntries(cut3);
step4=tree->GetEntries(cut4);
step5=tree->GetEntries(cut5);
cout << "===================================================================================" << endl;
cout << "Synchronization Exercise with MC (Decay channel = "+decay+", Sample = "+sample+") " << endl;
cout << "===================================================================================" << endl;
cout << "Cut at step1 ; " << "ZMass > 12 && relIso1 < 0.17 && relIso2 < 0.17 && PairSign < 0 && pt1 > 20 && pt2 > 20" << endl;
cout << "Cut at step2 ; " << "Cut at step1 + && abs(ZMass - 91.2) > 15" << endl;
cout << "Cut at step3 ; " << "Cut at step2 + && @jetspt30.size() >= 2 " << endl;
cout << "Cut at step4 ; " << "Cut at step3 + && MET > 30" << endl;
cout << "Cut at step5 ; " << "Cut at step4 + && nbjets_CSVL >= 1" << endl;
cout << "===================================================================================" << endl;
cout << "Step0 = " << step0 << endl;
cout << "Step1 = " << step1 << endl;
cout << "Step2 = " << step2 << endl;
cout << "Step3 = " << step3 << endl;
cout << "Step4 = " << step4 << endl;
cout << "Step5 = " << step5 << endl;
cout << "===================================================================================" << endl;
if (scan==true) {
cout << tree->Scan("RUN:LUMI:EVENT:ZMass:@jetspt30.size():MET:nbjets_CSVL",cut4) << endl;
}
fout << "===================================================================================" << endl;
fout << "Synchronization Exercise with MC (Decay channel = "+decay+", Sample = "+sample+") " << endl;
fout << "===================================================================================" << endl;
fout << "Cut at step1 ; " << "ZMass > 12 && relIso1 < 0.17 && relIso2 < 0.17 && PairSign < 0 && pt1 > 20 && pt2 > 20" << endl;
fout << "Cut at step2 ; " << "Cut at step1 + && abs(ZMass - 91.2) > 15" << endl;
fout << "Cut at step3 ; " << "Cut at step2 + && @jetspt30.size() >= 2 " << endl;
fout << "Cut at step4 ; " << "Cut at step3 + && MET > 30" << endl;
fout << "Cut at step5 ; " << "Cut at step4 + && nbjets_CSVL >= 1" << endl;
fout << "===================================================================================" << endl;
fout << "Step0 = " << step0 << endl;
fout << "Step1 = " << step1 << endl;
fout << "Step2 = " << step2 << endl;
fout << "Step3 = " << step3 << endl;
fout << "Step4 = " << step4 << endl;
fout << "Step5 = " << step5 << endl;
fout << "===================================================================================" << endl;
fout << "" << endl;
fout << "" << endl;
if (scan==true) {
const string tmpFileName = decay+"_"+sample+"_tmp.txt";
((TTreePlayer*)(tree->GetPlayer()))->SetScanRedirect(true);
((TTreePlayer*)(tree->GetPlayer()))->SetScanFileName(tmpFileName.c_str());
tree->Scan("RUN:LUMI:EVENT:ZMass:@jetspt30.size():MET:pt1:pt2",cut1);
((TTreePlayer*)(tree->GetPlayer()))->SetScanRedirect(false);
}
fout.close();
}