本文整理汇总了C++中TTree::AddFriend方法的典型用法代码示例。如果您正苦于以下问题:C++ TTree::AddFriend方法的具体用法?C++ TTree::AddFriend怎么用?C++ TTree::AddFriend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTree
的用法示例。
在下文中一共展示了TTree::AddFriend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MCefficiency
void MCefficiency(TString inputmc, TString outputfile, TString tfend, TString selmcgen, TString cut, TString weight, Float_t centmin, Float_t centmax)
{
Float_t hiBinMin,hiBinMax;
hiBinMin = centmin*2;
hiBinMax = centmax*2;
selmcgen = Form("%s&&hiBin>=%f&&hiBin<%f",selmcgen.Data(),hiBinMin,hiBinMax);
cut = Form("%s&&hiBin>=%f&&hiBin<%f",cut.Data(),hiBinMin,hiBinMax);
TFile* infMC = new TFile(inputmc.Data());
TTree* ntMC = (TTree*)infMC->Get("ntDkpi");
ntMC->AddFriend("ntHi");
ntMC->AddFriend("ntSkim");
TTree* ntGen = (TTree*)infMC->Get("ntGen");
ntGen->AddFriend("ntHi");
ntGen->AddFriend("ntSkim");
TH1D* hPtMC = new TH1D("hPtMC","",nPtBins,ptBins);
TH1D* hPtGen = new TH1D("hPtGen","",nPtBins,ptBins);
ntMC->Project("hPtMC","Dpt",TCut(weight)*(TCut(cut.Data())&&"(Dgen==23333)"));
divideBinWidth(hPtMC);
ntGen->Project("hPtGen","Gpt",TCut(weight)*(TCut(selmcgen.Data())));
divideBinWidth(hPtGen);
TH1D* hEff = (TH1D*)hPtMC->Clone("hEff");
hEff->Divide(hPtGen);
TFile* fout=new TFile(Form("%s_cent_%.0f_%.0f_%s.root",outputfile.Data(),centmin,centmax,tfend.Data()),"recreate");
fout->cd();
hEff->Write();
fout->Close();
}
示例2: weightPbPbvertex
void weightPbPbvertex(){
TFile*fMC=new TFile("/data/HeavyFlavourRun2/MC2015/Dntuple/PbPb/ntD_EvtBase_20160513_DfinderMC_PbPb_20160502_dPt1tkPt0p5_D0_prompt_Dpt2Dy1p1tkPt0p7tkEta2Decay2p9Dalpha0p14Skim_pthatweight.root");
TTree *ntDkpiMC = (TTree*)fMC->Get("ntDkpi");
TTree *ntSkimMC = (TTree*)fMC->Get("ntSkim");
TTree *ntHiMC = (TTree*)fMC->Get("ntHi");
ntDkpiMC->AddFriend(ntSkimMC);
ntDkpiMC->AddFriend(ntHiMC);
TFile*fData=new TFile("/data/jisun/PbPb2015/HF2and_ncand_skim_Dntuple_crab_PbPb_HIMinimumBias1to7_ForestAOD_D0y1p1_tkpt0p7eta1p5_goldenjson_EvtPlaneCali_03182015.root");
TTree *ntDkpiData = (TTree*)fData->Get("ntDkpi");
TTree *ntSkimData = (TTree*)fData->Get("ntSkim");
TTree *ntHiData = (TTree*)fData->Get("ntHi");
TTree *ntHltData = (TTree*)fData->Get("ntHlt");
ntDkpiData->AddFriend(ntSkimData);
ntDkpiData->AddFriend(ntHiData);
ntDkpiData->AddFriend(ntHltData);
TH1F*hpzData=new TH1F("hpzData","hpzData",200,-15,15);
TH1F*hpzMC=new TH1F("hpzMC","hpzMC",200,-15,15);
TCut weighpthat="1";
TString cut="abs(PVz)<15&&pclusterCompatibilityFilter&&pprimaryVertexFilter&&phfCoincFilter3";
TString hlt="HLT_HIL1MinimumBiasHF2AND_part1_v1||HLT_HIL1MinimumBiasHF2AND_part2_v1||HLT_HIL1MinimumBiasHF2AND_part3_v1";
TCut weighttest="1";
//TCut weighttest="1.26077+PVz*(0.00887442)+PVz*PVz*(-0.00782056)+PVz*PVz*PVz*(-3.51063e-05)+PVz*PVz*PVz*PVz*(-3.51063e-05)";
ntDkpiMC->Project("hpzMC","PVz",TCut(weighpthat)*(TCut(cut.Data()*TCut(weighttest))));
ntDkpiData->Project("hpzData","PVz",(TCut(cut.Data())*TCut(hlt.Data())));
hpzMC->Scale(1./hpzMC->Integral(hpzMC->FindBin(-15.),hpzMC->FindBin(15)));
hpzData->Scale(1./hpzData->Integral(hpzMC->FindBin(-15.),hpzMC->FindBin(15)));
TCanvas*cRatioVtx=new TCanvas("cRatioVtx","cRatioVtx",500,500);
cRatioVtx->Divide(2,1);
cRatioVtx->cd(1);
hpzMC->SetLineColor(2);
hpzMC->Draw();
hpzData->Draw("same");
cRatioVtx->cd(2);
TH1D*hRatioVertex=(TH1D*)hpzData->Clone("hRatioVertex");
hRatioVertex->Divide(hpzMC);
hRatioVertex->Draw();
TF1 *myfit = new TF1("myfit","[0]+[1]*x+x*x*[2]+x*x*x*[3]+x*x*x*x*[4]", -15, 15);
hRatioVertex->Fit("myfit","","",-15,15);
double par0=myfit->GetParameter(0);
double par1=myfit->GetParameter(1);
double par2=myfit->GetParameter(2);
double par3=myfit->GetParameter(3);
double par4=myfit->GetParameter(4);
std::cout<<"weight="<<par0<<"+PVz*("<<par1<<")+PVz*PVz*("<<par2<<")+PVz*PVz*PVz*("<<par3<<")+PVz*PVz*PVz*PVz*("<<par4<<")"<<endl;
}
示例3: fitBarea
void fitBarea(TString infname="",bool doweight = 1)
{
if (doweight==0) weight="1";
if (infname=="") infname=inputdata.Data();
TFile *inf = new TFile(infname.Data());
TTree *nt = (TTree*) inf->Get("ntKp");
TFile *infMC = new TFile(inputmc.Data());
TTree *ntGen = (TTree*)infMC->Get("ntGen");
TTree *ntGen2 = (TTree*)inf->Get("ntGen");
TTree *ntMC = (TTree*)infMC->Get("ntKp");
ntGen->AddFriend(ntMC);
ntGen2->AddFriend(ntMC);
const int nBins = 1;
double ptBins[nBins+1] = {10,60};
// const int nBins = 1;
// double ptBins[nBins+1] = {10,60};
TH1D *hPt = new TH1D("hPt","",nBins,ptBins);
for (int i=0;i<nBins;i++)
{
TF1 *f = fit(nt,ntMC,ptBins[i],ptBins[i+1]);
double yield = f->Integral(5,6)/0.02;
double yieldErr = f->Integral(5,6)/0.02*f->GetParError(0)/f->GetParameter(0);
hPt->SetBinContent(i+1,yield/(ptBins[i+1]-ptBins[i]));
hPt->SetBinError(i+1,yieldErr/(ptBins[i+1]-ptBins[i]));
}
}
示例4: ConnectFriends
void ConnectFriends()
{
// Connect the friends tree as soon as available.
//
// Handle the friends first
//
if (!esdTree->FindBranch("ESDfriend.")) {
// Try to add ESDfriend. branch as friend
TString esdFriendTreeFName;
esdFriendTreeFName = (esdTree->GetCurrentFile())->GetName();
TString basename = gSystem->BaseName(esdFriendTreeFName);
Int_t index = basename.Index("#")+1;
basename.Remove(index);
basename += "AliESDfriends.root";
TString dirname = gSystem->DirName(esdFriendTreeFName);
dirname += "/";
esdFriendTreeFName = dirname + basename;
//
TTree* cTree = esdTree->GetTree();
if (!cTree) cTree = esdTree;
cTree->AddFriend("esdFriendTree", esdFriendTreeFName.Data());
cTree->SetBranchStatus("ESDfriend.", 1);
esdFr = (AliESDfriend*)(esdEv->FindListObject("AliESDfriend"));
if (esdFr) cTree->SetBranchAddress("ESDfriend.", &esdFr);
}
}
示例5: 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->Draw("x:TF.x");
}
示例6: prescaleBrilCalc
void prescaleBrilCalc(TString inputMB, Float_t unprescale, Float_t unprescaleMB, TString eventfilter, Int_t isPbPb)
{
TString tPbPb = (isPbPb>0)?"PbPb":"pp";
cout<<" -- Calculating lumi of "<<tPbPb<<endl;
Double_t prescaleMB = unprescaleMB/unprescale;
TFile* f = new TFile(inputMB);
TTree* ntDkpi = (TTree*)f->Get("ntDkpi");
ntDkpi->AddFriend("ntSkim");
ntDkpi->AddFriend("ntHlt");
ntDkpi->AddFriend("ntHi");
TH1F* hcountsMB0100 = new TH1F("hcountsMB0100","",100,-2,2);
TH1F* hcountsMB010 = new TH1F("hcountsMB010","",100,-2,2);
//0-100%
cout<<" -- Processing 0-100%"<<endl;
ntDkpi->Draw("1>>hcountsMB0100",Form("%s&&hiBin<180",eventfilter.Data()));
Double_t ncountsMB0100 = hcountsMB0100->GetEntries()*10/9;
cout<<" - Number of MB events (0-90%): "<<ncountsMB0100<<endl;
Double_t TAA0100 = 392.4/(70.*1e9);
Double_t lumiMB0100 = TAA0100*ncountsMB0100;
Double_t lumiHighpt0100 = lumiMB0100/prescaleMB;
cout<<" - Luminosity brilcalc low pt: "<<lumiMB0100<<endl;
cout<<" - Luminosity brilcalc high pt: "<<lumiHighpt0100<<endl;
//0-10%
cout<<" -- Processing 0-10%"<<endl;
ntDkpi->Draw("1>>hcountsMB010",Form("%s&&hiBin<20",eventfilter.Data()));
Double_t ncountsMB010 = hcountsMB010->GetEntries();
cout<<" - Number of MB events (0-10%): "<<ncountsMB010<<endl;
Double_t TAA010 = (23.2/1e9);
Double_t lumiMB010 = TAA010*ncountsMB010;
Double_t lumiHighpt010 = lumiMB010/prescaleMB;
cout<<" - Luminosity brilcalc low pt: "<<lumiMB010<<endl;
cout<<" - Luminosity brilcalc high pt: "<<lumiHighpt010<<endl;
}
示例7: execNonExistingFriend
// inspired by ROOT-7007
int execNonExistingFriend() {
TTree* a = new TTree("a", "a");
auto fe = a->AddFriend("asfasf", "asfasgfags.root");
if (!fe->IsZombie()){
std::cerr << "The TFriendElement instance should be a zombie but it's not!\n";
} else {
std::cout << "The TFriendElement instance is a zombie.\n";
}
return 0;
}
示例8: extract
void extract(TString trigger="HLT_HIDmesonHITrackingGlobal_Dpt40_v1",double nbins=2,double minpt=2,double maxpt=2)
{
TH1D* getYield(TTree* nt, TTree* ntMC, TString triggerpass, TString triggername, TString prescale, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="");
void plotTurnOn(TH1D* hnominator, TH1D* hdenominator, TString triggerlegend, TString triggername, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX);
TFile* infile = new TFile(infname);
TTree* root = (TTree*)infile->Get("ntDkpi");
root->AddFriend("ntHlt");
TFile* infileMC = new TFile(infnameMC);
TTree* rootMC = (TTree*)infileMC->Get("ntDkpi");
rootMC->AddFriend("ntHlt");
rootMC->AddFriend("ntGen");
if(!isPbPb)
{
TH1D* hpp_pt = getYield(root,rootMC,"","","","Dpt","pt","p_{T} (GeV/c)",nbins,minpt,maxpt);
TH1D* hpp_pt_Hlt = getYield(root,rootMC,Form("&&%s",trigger.Data()),Form("_%s",trigger.Data()),"","Dpt","pt","p_{T} (GeV/c)",nbins,minpt,maxpt);
plotTurnOn(hpp_pt_Hlt,hpp_pt,trigger,Form("_%s",trigger.Data()),"pt","p_{T} (GeV/c)",nbins,minpt,maxpt);
}
}
示例9: katieTest
void katieTest(int run) {
gSystem->Load("libAnitaEvent.so");
char eventName[100];//FILENAME_MAX];
char headerName[100];//FILENAME_MAX];
char hkName[100];//FILENAME_MAX];
char gpsName[100];//FILENAME_MAX];
sprintf(eventName,"/anitaStorage/antarctica14/root/run%d/eventFile%d.root",run,run);
sprintf(headerName,"/anitaStorage/antarctica14/root/run%d/headFile%d.root",run,run);
sprintf(hkName,"/anitaStorage/antarctica14/root/run%d/prettyHkFile%d.root",run,run);
sprintf(gpsName,"/anitaStorage/antarctica14/root/run%d/gpsFile%d.root",run,run);
TFile *fpEvent = new TFile(eventName);
TTree *eventTree = (TTree*) fpEvent->Get("eventTree");
eventTree->AddFriend("headTree",headerName);
eventTree->AddFriend("prettyHkTree",hkName);
eventTree->AddFriend("adu5PatTree",gpsName);
eventTree->Draw("pressures[1]:altitude");
}
示例10: saveHist3pMinpt
void saveHist3pMinpt()
{
real isMC=MC;
TFile* infMCData = new TFile(infnameData3p[isMC].Data());
TFile* infMCMC = new TFile(infnameMC3p[isMC].Data());
TTree* ntMCData = (TTree*)infMCData->Get("ntDD0kpipi");
TTree* ntMCMC = (TTree*)infMCMC->Get("ntDD0kpipi");
ntMCData->AddFriend("ntHlt");
if(isMC!=Data_MB||isMC!=Data) ntMCData->AddFriend("ntHi");
ntMCMC->AddFriend("ntHlt");
ntMCMC->AddFriend("ntHi");
cout<<" -- Filling histograms - MC"<<endl;
cout<<" "<<infnameData3p[isMC]<<endl;
cout<<" "<<infnameMC3p[isMC]<<endl;
for(int i=0; i<nBins; i++)
{
cout<<setiosflags(ios::left)<<" - Processing ptbin "<<setw(3)<<ptBins[i]<<endl;
TH1D* h = new TH1D("h","",BINNUM,BINMIN,BINMAX);
TH1D* hMCSignal = new TH1D("hMCSignal","",BINNUM,BINMIN,BINMAX);
TH1D* hMCSwapped = new TH1D("hMCSwapped","",BINNUM,BINMIN,BINMAX);
ntMCData->Project("h","Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightdata[isMC].Data(),seldata3p[isMC].Data(),triggerselectiondata[isMC].Data(),ptBins[i]));
ntMCMC->Project("hMCSignal","Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightmc[isMC].Data(),selmc3p[isMC].Data(),triggerselectionmc[isMC].Data(),ptBins[i]));
ntMCMC->Project("hMCSwapped","Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightmc[isMC].Data(),selswp3p[isMC].Data(),triggerselectionmc[isMC].Data(),ptBins[i]));
TFile* outf = new TFile(Form("inputfiles/fmass_pp_3p_%s_%.0f.root",texData[isMC].Data(),ptBins[i]),"recreate");
outf->cd();
h->Write();
hMCSignal->Write();
hMCSwapped->Write();
outf->Close();
delete hMCSwapped;
delete hMCSignal;
delete h;
delete outf;
}
cout<<endl;
}
示例11: runcircular
int runcircular() {
int i = 0;
int j = 1;
// int k = 2;;
TTree *master = new TTree("master","master");
master->Branch("i",&i);
TTree *slave = new TTree("slave","slave");
slave->Branch("j",&j);
for(int s=0; s<10; ++s) master->Fill();
for(int s=0; s<15; ++s) slave->Fill();
cout << "Alone\n";
cout << master->LoadTree(3) << endl;
cout << master->LoadTree(12) << endl;
cout << master->LoadTree(20) << endl;
master->AddFriend(slave);
cout << "Friend\n";
cout << master->LoadTree(3) << endl;
cout << master->LoadTree(12) << endl;
cout << master->LoadTree(20) << endl;
slave->AddFriend(master);
cout << "Indirect Circular\n";
cout << master->LoadTree(3) << endl;
cout << master->LoadTree(12) << endl;
cout << master->LoadTree(20) << endl;
master->AddFriend(master);
cout << "Direct Circular\n";
cout << master->LoadTree(3) << endl;
cout << master->LoadTree(12) << endl;
cout << master->LoadTree(20) << endl;
if (master->LoadTree(20) != -2) {
cout << "A circular TTree friendship leads to LoadTree incorrectly returning: " << master->LoadTree(20) << " when it should return -2 (out of bound entry)\n";
return 1;
}
return 0;
}
示例12: triggerturnon
void triggerturnon()
{
void plotTurnOn(TTree* inttree, TString triggerpass, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="");
void plotTurnOnNL1seed(TTree* inttree, TString triggerpass, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX);
TString infname;
if(!isPbPb) infname = Form("/export/d00/scratch/jwang/Dmeson/ntD_20151115_DfinderMC_20151115_EvtMatching_Pythia_D0pt%.0fp0_Pthat%.0f_TuneZ2_5020GeV_GENSIM_75x_1015_20151110_ppGlobaTrackingPPmenuHFlowpuv11_MBseed_twang-Pythia_755patch2_v20_MBseed_1116.root",pthat,pthat);
else infname = Form("/export/d00/scratch/jwang/Dmeson/ntD_20151110_DfinderMC_20151110_EvtMatching_Pyquen_D0tokaonpion_D0pt%.0fp0_Pthat%.0f_TuneZ2_Unquenched_5020GeV_GENSIM_75x_v2_20151110_50k_L1v4_v15_loosecuts_MBseed_1108.root",pthat,pthat);
//infname = "/export/d00/scratch/jwang/Dmeson/nt_merged_dntuple.root";
TFile* infile = new TFile(infname);
TTree* root = (TTree*)infile->Get("ntDkpi");
root->AddFriend("HltTree");
if(!isPbPb)
{
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt8_v1&&L1_SingleJet16_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt15_v1&&L1_SingleJet24_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt20_v1&&L1_SingleJet28_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt30_v1&&L1_SingleJet40_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt40_v1&&L1_SingleJet40_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt50_v1&&L1_SingleJet48_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt60_v1&&L1_SingleJet48_BptxAND","Dpt","pt","p_{T} (GeV/c)",16,0,80);
/*
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt10_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt20_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt30_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt40_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt50_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonPPTrackingGlobal_Dpt60_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt10_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt20_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt30_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt40_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt50_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonPPTrackingGlobal_Dpt60_v1",16,0,80);
*/
}
else
{
plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt20_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt30_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt40_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt50_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(root,"HLT_DmesonTrackingGlobalPt8_Dpt60_v1","Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt20_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt30_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt40_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt50_v1",16,0,80);
plotTurnOnNL1seed(root,"HLT_DmesonTrackingGlobalPt8_Dpt60_v1",16,0,80);
}
}
示例13: CreateTree
TTree* MillePedeTrees::CreateTree(const char *fileName, const TString &treeNameAdd)
{
TFile *file = TFile::Open(fileName);
if (!file) return NULL;
TString *allTreeNames[] = {&fOrgPos, &fPos, &fMisPos, &fMisPar, &fPar, &fMp};
const unsigned int nTree = sizeof(allTreeNames) / sizeof(allTreeNames[0]);
unsigned int iTree = 0;
TTree *mainTree = NULL;
do {
file->GetObject(allTreeNames[iTree]->Data(), mainTree);
if (!mainTree) {
::Error("MillePedeTrees::CreateTree",
"no tree %s in %s", allTreeNames[iTree]->Data(), fileName);
}
*(allTreeNames[iTree]) += treeNameAdd; // Yes, we really change the data members!
if (mainTree && !treeNameAdd.IsNull()) {
mainTree->SetName(*(allTreeNames[iTree]));
}
++iTree;
} while (!mainTree && iTree < nTree);
if (mainTree) {
for (unsigned int jTree = iTree; jTree < nTree; ++jTree) {
const TString newName(*(allTreeNames[jTree]) + treeNameAdd);
// either by really renaming trees:
// TTree *tree = NULL;
// file->GetObject(allTreeNames[jTree]->Data(), tree);
// if (!tree) {
// ::Error("MillePedeTrees::CreateTree",
// "no tree %s in %s", allTreeNames[jTree]->Data(), fileName);
// } else {
// tree->SetName(newName);
// mainTree->AddFriend(tree, "", true); // no alias, but warn if different lengths
// }
// or by setting an alias:
TFriendElement *fEle = mainTree->AddFriend(newName + " = " + *(allTreeNames[jTree]));
if (!fEle || !fEle->GetTree()) {
::Error("MillePedeTrees::CreateTree","no %s as friend tree",allTreeNames[jTree]->Data());
}
*(allTreeNames[jTree]) = newName; // Yes, we really change the data members!
}
mainTree->SetEstimate(mainTree->GetEntries()); // for secure use of GetV1() etc.
}
return mainTree;
}
示例14: triggerturnonFast
void triggerturnonFast(TString trigger="HLT_DmesonPPTrackingGlobal_Dpt20_v1")
{
TH1D* getYield(TTree* nt, TString triggerpass, TString triggername, TString prescale, TString variable, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX, TString addcut="");
void plotTurnOn(TH1D* hnominator, TH1D* hdenominator, TString triggerlegend, TString triggername, TString varname, TString varlatex, Int_t BIN_NUM, Double_t BIN_MIN, Double_t BIN_MAX);
TString infname;
infname = "/data/dmeson2015/Dntuple/ntD_BigMergeExpressHiForest_run262163-run262252_match.root";
//infname = "/data/dmeson2015/Dntuple/Dntuple_run262163_262165_262167_262172.root";
TFile* infile = new TFile(infname);
TTree* root = (TTree*)infile->Get("ntDkpi");
root->AddFriend("HltTree",infname);
TH1D* hpp_pt = getYield(root,"","","","Dpt","pt","p_{T} (GeV/c)",16,0,80);
TH1D* hpp_pt_Hlt = getYield(root,Form("&&%s",trigger.Data()),Form("_%s",trigger.Data()),Form("*%s_Prescl",trigger.Data()),"Dpt","pt","p_{T} (GeV/c)",16,0,80);
plotTurnOn(hpp_pt_Hlt,hpp_pt,trigger,Form("_%s",trigger.Data()),"pt","p_{T} (GeV/c)",16,0,80);
}
示例15: addDiMuMassPrimeBranchZPt
void addDiMuMassPrimeBranchZPt(DiMuPlottingSystem* dps)
{
TTree* newtree = new TTree("newtree", "new tree");
newtree->AddFriend(dps->treename, dps->infilename);
TBranch *newBranch = newtree->Branch("recoCandMassPrime",&dps->recoCandMassPrime,"recoCandMassPrime/F");
Int_t nentries = dps->tree->GetEntries();
std::cout << "nentries: " << nentries << std::endl;
for (Int_t i = 0; i < nentries; i++)
{
dps->tree->GetEntry(i);
if(dps->recoCandPt > 20 && dps->recoCandPt < 60) dps->recoCandMassPrime = dps->recoCandMass + 0.0000917686*(dps->recoCandPt*dps->recoCandPt)*TMath::Sin(-6.43015*TMath::Sqrt(dps->recoCandPt) + 0.210496);
else dps->recoCandMassPrime = dps->recoCandMass;
newBranch->Fill();
}
dps->tree = newtree;
}