本文整理汇总了C++中TList::FindObject方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::FindObject方法的具体用法?C++ TList::FindObject怎么用?C++ TList::FindObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::FindObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QAcentrality
void QAcentrality(const Char_t *fdata)
{
style();
TFile *fin = TFile::Open(fdata);
TList *lin = (TList *)fin->Get("clist");
lin->ls();
TH1 *hin = (TH1 *)lin->FindObject("EvCentrDist");
Float_t sum = 1.2 * hin->Integral(hin->FindBin(0.1), hin->FindBin(79.9));
hin->Scale(1. / sum);
SetHistoStyle(hin, 20, kRed+1);
TCanvas *c = new TCanvas("cQAcentrality", "cQAcentrality", 800, 800);
TH1 * hfr = c->DrawFrame(0., 0.005, 100., 0.015);
hfr->SetTitle(";centrality percentile;events");
hin->Draw("same");
c->SaveAs(canvasPrefix+"centrality.pdf");
TH2 *hinv0 = (TH2 *)lin->FindObject("V0");
TCanvas *cv0 = new TCanvas("cQAcentralityV0", "cQAcentralityV0", 800, 800);
cv0->SetLogx();
cv0->SetLogz();
// TH1 * hfrv0 = cv0->DrawFrame(100., -0.5, 50000., 10.5);
// DrawBinLabelsY(hfrv0, kTRUE);
// hfrv0->SetTitle(";V0 signal;");
//hinv0->Draw("same,col");
hinv0->Draw("col");
cv0->SaveAs(canvasPrefix+"centralityV0.pdf");
}
示例2: AnaCombineEvH
void AnaCombineEvH()
{
TFile *file = TFile::Open("AnalysisResults_EmcalEvH.root", "READ");
TList *list = (TList*)file->Get("listEmcalEvH");
file->Close();
//=============================================================================
TH2D *hist2 = 0;
TH2D *hCentMtCh = 0;
TH2D *hMtChMtEm = 0;
for (Int_t i=0; i<4; i++) {
hist2 = (TH2D*)list->FindObject(Form("hCentMtCh_%d",i));
if (i==0) { hCentMtCh = (TH2D*)hist2->Clone("hCentMtCh"); hCentMtCh->Reset(); } hCentMtCh->Add(hist2); hist2 = 0;
hist2 = (TH2D*)list->FindObject(Form("hMtChMtEm_%d",i));
if (i==0) { hMtChMtEm = (TH2D*)hist2->Clone("hMtChMtEm"); hMtChMtEm->Reset(); } hMtChMtEm->Add(hist2); hist2 = 0;
}
//=============================================================================
/*file = TFile::Open("AnalysisResults_EmcalEvH.root", "UPDATE");
hCentMtCh->Write();
hMtChMtEm->Write();
file->Close();*/
//=============================================================================
return;
}
示例3: closeEvent
void ApplicationWindow::closeEvent( QCloseEvent* ce )
{
int testvar = QMessageBox::information( 0, "Qt Application Example",
"Do you want to close QtRoot? "
"", "Save", "Cancel", "Close",
0, 1 );
switch (testvar) {
case 0: // here we should save
// data
save();
ce->accept();
break;
case 1:
default: // just for sanity
ce->ignore();
break;
case 2: // Here i close all windows
// do now an explicit release of Histogram's
// child windows
TList *lc = (TList*)gROOT->GetListOfCanvases();
TObject *fitpanel = lc->FindObject("R__fitpanel");
TObject *drawpanel = lc->FindObject("R__drawpanelhist");
if (fitpanel) {
qDebug("detecting fitpanel %x \n",fitpanel);
delete fitpanel;
}
if (drawpanel) {
qDebug("detecting drawpanel %x \n",drawpanel);
delete drawpanel;
}
ce->accept();
break;
}
}
示例4: countEntries
int countEntries(TH1D* inComing, double ptMin, double ptMax, int fileNum)
{
if(fileNum < 0 || fileNum > 4)
{
cout << "number not in the cut range" << endl;
return;
}
TFile *myFile = TFile::Open("GammaCalo_MC_LHC15g2_60.root");
TList *myL = (TList*)myFile->Get("GammaCalo;1");
TString cutString[5];
cutString[0] = "00000113_1111121063032220000_0163103100000050";
cutString[1] = "00000013_1111121063032220000_0163103100000050";
cutString[2] = "00052013_1111121063032220000_0163103100000050";
cutString[3] = "00083013_1111121063032220000_0163103100000050";
cutString[4] = "00085013_1111121063032220000_0163103100000050";
//cout << "Cut selection: " << cutString[fileNum] << endl;
TString folderString = "Cut Number " + cutString[fileNum];
TList* cut_folder = (TList*)myL->FindObject(folderString);
TString esdString = cutString[fileNum] + " ESD histograms";
TList* esdHists = (TList*)cut_folder->FindObject(esdString);
TH2F* hist = (TH2F*)esdHists->FindObject("ESD_Mother_InvMass_Pt");
TH1D* pi0WBg = hist->ProjectionX("pi0WBg",ptBinMin,ptBinMax,"");
int entries = pi0WBg->GetEntries();
cout << "Num entries: " << entries << endl;
return entries;
}
示例5: PlotMinEtFromSim
void PlotMinEtFromSim(Bool_t isPhos = kFALSE){
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
gStyle->SetOptFit(0);
Float_t min = 0;
float max = 1;
TString filename, detname;
if(isPhos){
min = 0.655;
max = 0.785;
detname = "PHOS";
filename = "rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.PHOS.LHC11a10a_bis.Run139465.root";
}
else{
min = 0.58;
max = 0.725;
filename = "rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.EMCal.LHC11a10a_bis.Run139465.root";
detname = "EMCal";
}
TFile *f = TFile::Open(filename, "READ");
TList *l = dynamic_cast<TList*>(f->Get("out1"));
TH1F *fHistSimulatedGammaEnergyAboveThreshold = l->FindObject("fHistSimulatedGammaEnergyAboveThreshold");
TH1F *fHistSimulatedGammaEnergy = l->FindObject("fHistSimulatedGammaEnergy");
SetStyles(fHistSimulatedGammaEnergyAboveThreshold,20,TColor::kRed);
fHistSimulatedGammaEnergyAboveThreshold->Divide(fHistSimulatedGammaEnergy);
TCanvas *c1 = new TCanvas("c1","Simulation",600,400);
c1->SetTopMargin(0.02);
c1->SetRightMargin(0.03);
c1->SetLeftMargin(0.11745);
c1->SetBottomMargin(0.11745);
c1->SetBorderSize(0);
c1->SetFillColor(0);
c1->SetFillColor(0);
c1->SetBorderMode(0);
c1->SetFrameFillColor(0);
c1->SetFrameBorderMode(0);
fHistSimulatedGammaEnergyAboveThreshold->SetMaximum(max +0.1);
fHistSimulatedGammaEnergyAboveThreshold->SetMinimum(min-0.1);
fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetTitle("Centrality bin");
fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetTitle("f_{minEt}");
fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetLabelSize(0.06);
fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetLabelSize(0.06);
fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetTitleSize(0.06);
fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetTitleSize(0.06);
fHistSimulatedGammaEnergyAboveThreshold->Draw();
TLine *lineMin = new TLine(-0.5,min,19.5,min);
lineMin->Draw();
TLine *lineMax = new TLine(-0.5,max,19.5,max);
lineMax->Draw();
lineMin->SetLineColor(TColor::kBlue);
lineMax->SetLineColor(TColor::kBlue);
lineMin->SetLineStyle(2);
lineMax->SetLineStyle(2);
TString outfile = "/tmp/MinEtFromSim"+detname+".png";
c1->SaveAs(outfile.Data());
}
示例6: QAvertex
void QAvertex(const Char_t *fdata, const Char_t *fmc)
{
style();
TFile *fdtin = TFile::Open(fdata);
TList *ldtin = (TList *)fdtin->Get("clist");
TH2 *hdtin = (TH2 *)ldtin->FindObject("zv");
TH1 *hdt = (TH1 *)ldtin->FindObject("zvNoSel");
SetHistoStyle(hdt, 20, kRed+1);
hdt->Scale(1. / hdt->Integral());
TH1 *hdt0010 = hdtin->ProjectionX("hdt0010", 1, 4);
SetHistoStyle(hdt0010, 20, kRed+1);
hdt0010->Scale(1. / hdt0010->Integral());
TH1 *hdt7080 = hdtin->ProjectionX("hdt7080", 11, 11);
SetHistoStyle(hdt7080, 25, kAzure-3);
hdt7080->Scale(1. / hdt7080->Integral());
TFile *fmcin = TFile::Open(fmc);
TList *lmcin = (TList *)fmcin->Get("clist");
TH1 *hmc = (TH1 *)lmcin->FindObject("zvNoSel");
SetHistoStyle(hmc, 25, kAzure-3);
hmc->Scale(1. / hmc->Integral());
TCanvas *c = new TCanvas("cVertex", "cVertex", 800, 800);
TH1 * hfr = c->DrawFrame(-20., 0., 20., 0.1);
hfr->SetTitle(";#it{z}_{vtx};");
hdt0010->Draw("same");
hdt7080->Draw("same");
TLegend *legend = new TLegend(0.20, 0.18+0.60, 0.50, 0.30+0.60);
legend->SetFillColor(0);
legend->SetBorderSize(0);
legend->SetTextFont(42);
legend->SetTextSize(0.04);
legend->AddEntry(hdt0010, "0-10%", "p");
legend->AddEntry(hdt7080, "70-80%", "p");
legend->Draw("same");
c->SaveAs(canvasPrefix+"vertex.pdf");
TCanvas *c1 = new TCanvas("cVertexDataMC", "cVertexDataMC", 800, 800);
hfr = c1->DrawFrame(-20., 0., 20., 0.1);
hfr->SetTitle(";#it{z}_{vtx};");
hdt->Draw("same");
hmc->Draw("same");
legend = new TLegend(0.20, 0.18+0.60, 0.50, 0.30+0.60);
legend->SetFillColor(0);
legend->SetBorderSize(0);
legend->SetTextFont(42);
legend->SetTextSize(0.04);
legend->AddEntry(hdt, "data", "p");
legend->AddEntry(hmc, "Monte Carlo", "p");
legend->Draw("same");
c1->SaveAs(canvasPrefix+"vertexDataMC.pdf");
//return 0;
}
示例7: QAoccupancy
void QAoccupancy(const Char_t *fdata, const Char_t *fmc)
{
style();
TFile *fdtin = TFile::Open(fdata);
TList *ldtin = (TList *)fdtin->Get("clist");
TH2 *hdtin = (TH2 *)ldtin->FindObject("NClustersSPD2");
TProfile *pdtin = hdtin->ProfileY("pdtin_clusters");
pdtin->SetMarkerStyle(20);
pdtin->SetMarkerSize(2);
pdtin->SetMarkerColor(kAzure-3);
TFile *fmcin = TFile::Open(fmc);
TList *lmcin = (TList *)fmcin->Get("clist");
TH2 *hmcin = (TH2 *)lmcin->FindObject("NClustersSPD2");
TProfile *pmcin = hmcin->ProfileY("pmcin_clusters");
pmcin->SetMarkerStyle(25);
pmcin->SetMarkerSize(2);
pmcin->SetMarkerColor(kRed+1);
TCanvas *c = new TCanvas("cOccupancy", "cOccupancy", 800, 800);
c->SetLogy();
TH1 * hfr = c->DrawFrame(-0.5, 2., 10.5, 500.);
DrawBinLabelsX(hfr, kTRUE);
hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT");
pdtin->DrawCopy("same");
pmcin->DrawCopy("same");
TLegend *legend = new TLegend(0.20, 0.18, 0.50, 0.30);
legend->SetFillColor(0);
legend->SetBorderSize(0);
legend->SetTextFont(42);
legend->SetTextSize(0.04);
legend->AddEntry(pdtin, "data", "pl");
legend->AddEntry(pmcin, "Monte Carlo", "pl");
legend->Draw("same");
c->SaveAs(canvasPrefix+"occupancy.pdf");
return;
TCanvas *cr = new TCanvas("cOccupancyr", "cOccupancyr", 800, 800);
// hfr = cr->DrawFrame(-0.5, 0.75, 10.5, 1.25);
// DrawBinLabelsX(hfr, kTRUE);
// hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT ratio");
pdtin->SetLineColor(kAzure-3);
pdtin->SetLineWidth(3);
pdtin->Divide(pmcin);
pdtin->Draw("same,histo");
legend = new TLegend(0.505025, 0.760673, 0.805276, 0.930142);
legend->SetFillColor(0);
legend->SetBorderSize(0);
legend->SetTextFont(42);
legend->SetTextSize(0.04);
legend->AddEntry(pdtin, "data / Monte Carlo", "l");
legend->Draw("same");
cr->SaveAs(canvasPrefix+"occupancyr.pdf");
}
示例8: MakeHistsForSlides
Double_t MakeHistsForSlides(TString goodFile, TString badFile, TString rootFile)
{
//Extracting the histogram
TFile* f = TFile::Open(rootFile);
TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal"));
TList* list = (TList*)(dirFile->Get("histogram"));
TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude"));
//Getting a Good Cell
TH1D* goodC = new TH1D();
ifstream myFile(goodFile);
TString title = "";
const int num = 500;
if(myFile.is_open())
{
string line = "";
std::getline(myFile,line);
int index = 0;
double chi2 = 0.0;
while(myFile >> index >> chi2 && index < num)
{
//cout << index << "\t" << chi2 << endl;
title = Form("Energy distribution of Cell %d",index);
TH1D* goodCell = cellVAmplitude->ProjectionY("goodCell", index+1,index+1);
goodC = (TH1D*)goodCell->Clone();
}
}
示例9: AddGrid
//_______________________________________________________________________________________
static void AddGrid()
{
TVirtualPad *thisPad = qPad();
if (thisPad) {
TView *view = thisPad->GetView();
if (!view) return;
Double_t min[3],max[3];
view->GetRange(min,max);
TList *list = thisPad->GetListOfPrimitives();
TString histName = thisPad->GetName();
TH2F *m_DummyHist = 0;
const Char_t *dummyName = "Axis3D";
histName += dummyName;
m_DummyHist = list->FindObject(histName.Data());
if (!m_DummyHist) {
m_DummyHist = new TH2F(histName.Data(),"",1,min[0],max[0],1,min[1],max[1]);
m_DummyHist->SetDirectory(0);
m_DummyHist->Draw("surf,same");
}
m_DummyHist->GetXaxis()->SetLimits(min[0],max[0]);
m_DummyHist->GetYaxis()->SetLimits(min[1],max[1]);
m_DummyHist->GetZaxis()->SetLimits(min[2],max[2]);
thisPad->Modified();
thisPad->Update();
}
}
示例10:
TH2* Get2DHistogramfromList(TList *pidqalist, const char* listname, const char* histoname)
{
TList *histolist = (TList *)pidqalist->FindObject(listname);
if (!histolist) {printf(" list not found \n"); return 0x0; }
TH2* histo = (TH2*)histolist->FindObject(histoname);
// if (!histo) {printf(" histogram not found \n"); return 0x0; }
return histo;
}
示例11: trackMatchingEff
int trackMatchingEff(TString file = "Et.ESD.simPbPb.PHOS.root")
{
TFile *f = TFile::Open(file, "READ");
if(!f)
{
std::cout << "Could not open file: " << file << " !" << std::endl;
return -1;
}
TList *l = (TList*)(f->Get("out1"));
if(!l)
{
std::cout << "Could not find list!" << std::endl;
return -1;
}
TTree *primTree = (TTree*)(l->FindObject("fPrimaryTreePhosMC"));
if(!primTree)
{
std::cout << "Could not find tree!" << std::endl;
return -1;
}
TString emSelect = "(fPrimaryCode==22||fPrimaryCode==221||TMath::Abs(fPrimaryCode)==11)";
TString chargeSelect = "(fPrimaryCharge!=0 && TMath::Abs(fPrimaryCode)!=11)";
TString neutralSelect = "(!"+emSelect+")&&fPrimaryCharge==0&&(!fSecondary)";
TString secondarySelect = "(fSecondary)";
emSelect += "&&(!fSecondary)";
chargeSelect += "&&(!fSecondary)";
TString matchedSelect = "fPrimaryMatched==1&&";
TString notMatchedSelect = "fPrimaryMatched==0&&";
int n = primTree->Draw("fDepositedEt", notMatchedSelect+ emSelect);
int nRemoved = primTree->Draw("fDepositedEt", matchedSelect + emSelect);
std::cout << "EM: " << float(n)/(n+nRemoved) << std::endl;
n = primTree->Draw("fDepositedEt", notMatchedSelect+ chargeSelect);
nRemoved = primTree->Draw("fDepositedEt", matchedSelect + chargeSelect);
std::cout << "Charged: " << float(n)/(n+nRemoved) << std::endl;
n = primTree->Draw("fDepositedEt", notMatchedSelect+ neutralSelect);
nRemoved = primTree->Draw("fDepositedEt", matchedSelect + neutralSelect);
std::cout << "Neutral: " << float(n)/(n+nRemoved) << std::endl;
n = primTree->Draw("fDepositedEt", notMatchedSelect+ secondarySelect);
nRemoved = primTree->Draw("fDepositedEt", matchedSelect + secondarySelect);
if(n+nRemoved) std::cout << "Secondary: " << float(n)/(n+nRemoved) << std::endl;
else std::cout << "No secondaries" << std::endl;
return 0;
}
示例12: DirectoryContains
Bool_t KVDMS::DirectoryContains(const Char_t* name, const Char_t* directory)
{
// Returns true if the current directory (default) or the given directory
// contains a file or a container with given name.
TList* list = GetListing(directory);
if (!list)
return kFALSE;
Bool_t ok = list->FindObject(name);
delete list;
return ok;
}
示例13:
TH1D *
GetITSsaSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE, Bool_t addSystematicError = kTRUE)
{
/* pt limits for combined spectra */
Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0.1, 0.2, 0.3};
Double_t ptMax[AliPID::kSPECIES] = {0., 0., 0.6, 0.5, 0.6};
TList *list = (TList *)file->Get("output");
TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSsaPartName[part], ITSsaChargeName[charge], cent));
if (!hin) return NULL;
/* get systematics */
TFile *fsys = TFile::Open("SPECTRASYS_ITSsa.root");
TH1 *hsys = fsys->Get(Form("hSystTot%s%s", ITSsaChargeName[charge], ITSsaPartName[part]));
TH1D *h = new TH1D(Form("hITSsa_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSsa", NptBins, ptBin);
Double_t pt, width, value, error, sys;
Int_t bin;
for (Int_t ipt = 0; ipt < NptBins; ipt++) {
/* get input bin */
pt = h->GetBinCenter(ipt + 1);
width = h->GetBinWidth(ipt + 1);
bin = hin->FindBin(pt);
/* sanity check */
if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 ||
TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001)
continue;
/* check pt limits */
if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue;
/* copy bin */
value = hin->GetBinContent(bin);
error = hin->GetBinError(bin);
/*** TEMP ADD SYS ***/
if (addSystematicError) {
sys = hsys->GetBinContent(bin) * value;
error = TMath::Sqrt(error * error + sys * sys);
}
h->SetBinContent(ipt + 1, value);
h->SetBinError(ipt + 1, error);
}
h->SetTitle("ITSsa");
h->SetLineWidth(1);
h->SetLineColor(1);
h->SetMarkerStyle(20);
h->SetMarkerColor(1);
h->SetFillStyle(0);
h->SetFillColor(0);
return h;
}
示例14: GetHistogram
//______________________________________________________________________________
TObject* GetHistogram(TFile* file,
const Char_t* cutClass,
const Char_t* histList,
const Char_t* histName) {
//
// get a histogram from the J/psi output
//
TKey* qaKey = (TKey*)file->GetListOfKeys()->At(0);
TList* qaList = (TList*)qaKey->ReadObj();
THashList* qaCutClass = (THashList*)qaList->FindObject(cutClass);
THashList* qaHistList = (THashList*)qaCutClass->FindObject(histList);
return qaHistList->FindObject(histName);
}
示例15: plotQApid
void plotQApid(Int_t ic,Float_t pt,Int_t addbin){
char name[100];
char stringa[200];
LoadLib();
snprintf(name,100,"AnalysisResults.root");
if(!fo) fo = new TFile(name);
snprintf(name,100,"contVZEROv2");
TList *cont = (TList *) fo->Get(name);
AliFlowVZEROResults *pidqa = cont->FindObject("qaPID");
Float_t xval[2] = {2.,pt+0.00001};
Float_t xval2[2] = {2.+addbin,pt+0.00001};
TProfile *proTPCpi = pidqa->GetV2(0,xval,xval2);
TProfile *proTOFpi = pidqa->GetV2(1,xval,xval2);
TProfile *proTPCka = pidqa->GetV2(2,xval,xval2);
TProfile *proTOFka = pidqa->GetV2(3,xval,xval2);
TProfile *proTPCpr = pidqa->GetV2(4,xval,xval2);
TProfile *proTOFpr = pidqa->GetV2(5,xval,xval2);
proTPCpi->SetName("hPiTPC");
proTOFpi->SetName("hPiTOF");
proTPCka->SetName("hKaTPC");
proTOFka->SetName("hKaTOF");
proTPCpr->SetName("hPrTPC");
proTOFpr->SetName("hPrTOF");
proTPCpi->GetXaxis()->SetTitle("dE/dx - dE/dx_{calc}^{#pi} (a.u)");
proTOFpi->GetXaxis()->SetTitle("t_{tof} - t_{calc}^{#pi} (ps)");
proTPCka->GetXaxis()->SetTitle("dE/dx - dE/dx_{calc}^{K} (a.u)");
proTOFka->GetXaxis()->SetTitle("t_{tof} - t_{calc}^{K} (ps)");
proTPCpr->GetXaxis()->SetTitle("dE/dx - dE/dx_{calc}^{p} (a.u)");
proTOFpr->GetXaxis()->SetTitle("t_{tof} - t_{calc}^{p} (ps)");
TCanvas *c = new TCanvas("cVproj","cVproj");
c->Divide(2,3);
c->cd(1);
proTPCpi->Draw();
c->cd(2);
proTOFpi->Draw();
c->cd(3);
proTPCka->Draw();
c->cd(4);
proTOFka->Draw();
c->cd(5);
proTPCpr->Draw();
c->cd(6);
proTOFpr->Draw();
}