本文整理汇总了C++中TList::After方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::After方法的具体用法?C++ TList::After怎么用?C++ TList::After使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::After方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectContours
void collectContours(map<string,TGraph2D *>& m_graphs,
const vector<string>& keys,
map<string,double>& m_contourlevels,
map<string,TList *>& m_contours)
{
cout << "CollectContours" << endl;
TCanvas *canv = new TCanvas("dummy","dummy",100,100);
//canv->Divide(3,2);
std::cout << "keys.size() = " << keys.size() << std::endl;
//process TGraph2Ds into contours at levels m_contourlevels
for (size_t i=0; i<keys.size(); i++) {
double clev = m_contourlevels[keys[i]];
TGraph2D *gr2d = m_graphs[keys[i]];
std::cout << "gr2d = " << gr2d << std::endl;
std::cout << "gr2d->GetN() = " << gr2d->GetN() << std::endl;
if (gr2d && (gr2d->GetN() > 0)) {
gr2d->GetHistogram()->SetContour(1, &clev);
//canv->cd(i+1);
cout << "drawing... " << endl;
gr2d->Draw("CONT LIST"); // it's stupid, but only "CONT" will generate the list
gPad->Update();
TObjArray *contours = (TObjArray *)gROOT->GetListOfSpecials()->FindObject("contours");
assert(contours);
TList *newlist = 0;
for (int ci=0; ci<contours->GetEntriesFast(); ci++) {
TList *contLevel = (TList*)contours->At(ci);
printf("%s: Contour %d has %d Graphs\n", keys[i].c_str(), ci, contLevel->GetSize());
if (contLevel->GetSize()) {
assert(contLevel->First());
if (!newlist) newlist = new TList();
TGraph *curv = (TGraph*)(contLevel->First());
for (int j=0; j<contLevel->GetSize(); j++) {
newlist->Add((TGraph *)(curv->Clone()));
curv=(TGraph *)(contLevel->After(curv));
}
}
} // contour loop
cout << "Inserting contour list for "<< keys[i] << " newlist="<<newlist<<endl;
m_contours[keys[i]] = newlist;
} // if (gr2d)
} // key loop
//delete canv;
} // collectContours
示例2: compareHistos
void compareHistos( char *Current, char *Reference=0 ) {
TText* te = new TText();
te->SetTextSize(0.1);
TFile * curfile = new TFile( TString(Current)+".root" );
TFile * reffile = curfile;
if (Reference) reffile = new TFile(TString(Reference)+".root");
char * prefix="DQMData/MixingV/Mixing";
//1-Dimension Histogram
TDirectory * refDir=reffile->GetDirectory(prefix);
TDirectory * curDir=curfile->GetDirectory(prefix);
TList* list = refDir->GetListOfKeys();
TObject* object = list->First();
int iHisto = 0;
char title[50];
while (object) {
// find histo objects
std::cout << " object :" << object->GetName() << std::endl;
TProfile * h1 = dynamic_cast<TProfile*>( refDir->Get(object->GetName()));
TProfile * h2 = dynamic_cast<TProfile*>( curDir->Get(object->GetName()));
bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TProfile");
std::cout << " isHisto = " << isHisto << std::endl;
if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
iHisto++;
char title[50];
// draw and compare
std::cout << " Start draw and compare" << std::endl;
TCanvas c1;
TProfile htemp2;
h2->Copy(htemp2);// to keep 2 distinct histos
h1->SetLineColor(2);
htemp2.SetLineColor(3);
h1->SetLineStyle(3);
h1->SetMarkerColor(3);
htemp2.SetLineStyle(5);
htemp2.SetMarkerColor(5);
TLegend leg(0.1, 0.15, 0.2, 0.25);
leg.AddEntry(h1, "Reference", "l");
leg.AddEntry(&htemp2, "New ", "l");
h1->Draw();
htemp2.Draw("Same");
leg.Draw();
sprintf(title,"%s%s", object->GetName(),".gif");
c1.Print(title);
}
// go to next object
object = list->After(object);
}
}
示例3: getTreeList
TList PlotAlignmentValidation::getTreeList()
{
TList treeList = new TList();
TFile *first_source = (TFile*)sourcelist->First();
std::cout<<first_source->GetName()<<std::endl;
TDirectoryFile *d=(TDirectoryFile*)first_source->Get( treeBaseDir.c_str() );
treeList.Add( (TTree*)(*d).Get("TkOffVal") );
if( moreThanOneSource ==true ){
TFile *nextsource = (TFile*)sourcelist->After( first_source );
while ( nextsource ) {
std::cout<<nextsource->GetName()<<std::endl;
d=(TDirectoryFile*)nextsource->Get("TrackerOfflineValidation");
treeList.Add((TTree*)(*d).Get("TkOffVal"));
nextsource = (TFile*)sourcelist->After( nextsource );
}
}return treeList;
}
示例4: DoCompare
void DoCompare( char *Current, char *Reference=0 ){
TText* te = new TText();
te->SetTextSize(0.1);
gROOT->ProcessLine(".x HistoCompare.C");
HistoCompare * myPV = new HistoCompare();
TFile * curfile = new TFile( TString(Current)+".root" );
TFile * reffile = curfile;
if (Reference) reffile = new TFile(TString(Reference)+".root");
char * prefix="DQMData/MixingV/";
//1-Dimension Histogram
TDirectory * refDir=reffile->GetDirectory(prefix);
TDirectory * curDir=curfile->GetDirectory(prefix);
TList* list = refDir->GetListOfKeys();
TObject* object = list->First();
int iHisto = 0; char title[50];
while (object) {
// find histo objects
TH1F * h1 = dynamic_cast<TH1F*>( refDir->Get(object->GetName()));
TH1F * h2 = dynamic_cast<TH1F*>( curDir->Get(object->GetName()));
bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TH1F");
if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
iHisto++;
char title[50];
// draw and compare
TCanvas c1;
TH1F htemp2;
h2->Copy(htemp2);// to keep 2 distinct histos
h1->SetLineColor(2);
htemp2.SetLineColor(3);
h1->SetLineStyle(3);
htemp2.SetLineStyle(5);
TLegend leg(0.1, 0.15, 0.2, 0.25);
leg.AddEntry(h1, "Reference", "l");
leg.AddEntry(&htemp2, "New ", "l");
h1->Draw();
htemp2.Draw("Same");
leg.Draw();
myPV->PVCompute(h1,&htemp2, te);
sprintf(title,"%s%s", object->GetName(),".eps");
c1.Print(title);
}
// go to next object
object = list->After(object);
}
}
示例5: getContours
TList* getContours(const TH2* hist,double contourLevel,const TString filename)
{
TH2* h = (TH2*)hist->Clone("_clone");
double limitValue[1] = {contourLevel};
h->SetContour(1,limitValue);
TCanvas* c = new TCanvas("contour_canvas","Contour List",0,0,600,600);
h->Draw("CONT LIST");
c->Update();
TList* contours = (TList*)((TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"))->At(0);
TGraph* contour = (TGraph*)contours->First();
if(filename!="")
{
for(unsigned int j = 0; j < contours->GetSize(); j++)
{
TString newFilename = filename+"_";
newFilename+=j;
contour->SaveAs(newFilename+".C");
contour = (TGraph*)contours->After(contour); // Get Next graph
}
}
delete h;
delete c;
return contours;
}
示例6: plotMSSM
//.........这里部分代码省略.........
//return;
// Get Contours
TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
TList* contLevel = NULL;
TGraph* curv = NULL;
TGraph* gc = NULL;
Int_t nGraphs = 0;
Int_t TotalConts = 0;
if (conts == NULL){
printf("*** No Contours Were Extracted!\n");
TotalConts = 0;
return;
} else {
TotalConts = conts->GetSize();
}
printf("TotalConts = %d\n", TotalConts);
for(i = 0; i < TotalConts; i++){
contLevel = (TList*)conts->At(i);
printf("Contour %d has %d Graphs\n", i, contLevel->GetSize());
nGraphs += contLevel->GetSize();
}
nGraphs = 0;
TH2F *hr = new TH2F("hr", ";m_{A};tan#beta", 2, 225, 600, 2, 0.1, 100);
hr->GetXaxis()->SetTitleOffset(1.1);
hr->GetXaxis()->SetRangeUser(200,650);
hr->GetYaxis()->SetTitleOffset(1.2);
hr->GetYaxis()->SetNdivisions(110,kFALSE);
hr->GetXaxis()->SetNdivisions(20205,kFALSE);
hr->Draw();
Double_t x0, y0, z0;
TLatex l;
l.SetTextSize(0.03);
l.SetTextAlign(32);
char val[20];
for(i = 0; i < TotalConts; i++){
contLevel = (TList*)conts->At(i);
z0 = level[i];
printf("Z-Level Passed in as: Z = %f\n", z0);
// Get first graph from list on curves on this level
curv = (TGraph*)contLevel->First();
for(j = 0; j < contLevel->GetSize(); j++){
// last point
//curv->GetPoint(curv->GetN()-1, x0, y0);
// first point
curv->GetPoint(2, x0, y0);
// if (z0<0) curv->SetLineColor(kRed);
// if (z0>0) curv->SetLineColor(kBlue);
nGraphs ++;
printf("\tGraph: %d -- %d Elements\n", nGraphs,curv->GetN());
// Draw clones of the graphs to avoid deletions in case the 1st
// pad is redrawn.
gc = (TGraph*)curv->Clone();
gc->Draw("C");
if (z0>=.01) sprintf(val,"%0.2f",z0);
if (z0>=.1) sprintf(val,"%0.2f",z0);
if (z0>=1) sprintf(val,"%0.0f",z0);
l.DrawLatex(x0*0.99,y0,val);
curv = (TGraph*)contLevel->After(curv); // Get Next graph
}
}
gPad->SetLogy();
gPad->SetGridx();
gPad->SetGridy();
gPad->SetRightMargin(0.05);
gPad->SetTopMargin(0.10);
c2->Update();
printf("\n\n\tExtracted %d Contours and %d Graphs \n", TotalConts, nGraphs );
tl.SetTextAlign(31);
tl.DrawLatex(0.8,0.85,goodName);
tl.SetTextAlign(31);
tl.DrawLatex(0.8,0.77,goodType);
pCan(c2,cname+"_BW");
c1->cd(1);
gPad->SetLogy();
gPad->SetLogz();
c1->cd(2);
gPad->SetLogy();
c1->Update();
pCan(c1,cname);
}
示例7: ttreesToHistograms
//.........这里部分代码省略.........
}
cout << endl << endl;
// Open the files & set their scales
cout << endl << "Histograms will be scaled to " << invLuminosityToScaleTo << "pb-1 " << endl;
cout << "Looking for TTree named \"" << treeName << "\" in files..." << endl;
vector<float> fileScale;
TList *fileList = new TList();
for (int i=0; i < fileName.size(); i++) {
TFile* currentFile = TFile::Open(fileName[i]);
fileList->Add(currentFile);
float currentScale = crossSection[i]*invLuminosityToScaleTo*filterEffeciency[i]/eventsAnalyzied[i];
fileScale.push_back( currentScale );
// Display entries in that file's TTree
TTree* tree;
currentFile->GetObject(treeName, tree);
cout << "file" << i <<": " << fileName[i] << " contains " << tree->GetEntries(allCuts) << " entries, and will be scaled by " <<
currentScale << endl;
}
cout << endl << endl;
//Create output file
TFile *outputFile = TFile::Open( outputFileName, "RECREATE" );
//************************************************************
// Core of the Script //
// Loop over locations
for (int l=0; l<locationName.size(); l++) {
TString currentLocation = locationName[l];
TCut currentCuts = allCuts;
currentCuts += locationCut[l];
cout << "Creating plots for " << currentLocation << ", " << locationCut[l] << endl;
// Loop over variables to plot
for (int i=0; i<variableToPlot.size(); i++) {
// should we plot this variable for this location?
if (i<locationVariablesToPlot[l][0] || i>locationVariablesToPlot[l][1]) continue;
TString currentHistType = histogram[i]->IsA()->GetName();
TString currentHistName = TString(histogram[i]->GetName()) + "_" + currentLocation;
TString currentHistTitle = TString(histogram[i]->GetTitle()) + "(" + currentLocation + ")";
cout << " " << variableToPlot[i] << " >> " << currentHistName;
TString currentHistDrawOpt;
if (currentHistType=="TH2F") {
currentHistDrawOpt="goffbox";
} else {
currentHistDrawOpt="egoff";
}
TH1* currentHist = (TH1*)histogram[i]->Clone(currentHistName); // Creates clone with name currentHistName
currentHist->Sumw2(); // store errors
currentHist->SetTitle(currentHistTitle);
//cout << " from file";
// Plot from the first file
int f = 0;
//cout << f;
TTree *tree;
TFile *current_file = (TFile*)fileList->First();
current_file->cd();
current_file->GetObject(treeName, tree);
tree->Draw(variableToPlot[i]+">>"+currentHistName,currentCuts+TCut(fileCuts[f]),currentHistDrawOpt);
currentHist->Scale(fileScale[f]);
f++;
// Loop over files
current_file = (TFile*)fileList->After( current_file );
while ( current_file ) {
current_file->cd();
//cout << ", file" << f;
current_file->GetObject(treeName, tree);
TString tempHistName = currentHistName+"Temp";
TH1* tempHist = (TH1*)currentHist->Clone(tempHistName);
tree->Draw(variableToPlot[i]+">>"+tempHistName,currentCuts+TCut(fileCuts[f]),currentHistDrawOpt);
tempHist->Scale(fileScale[f]);
currentHist->Add(tempHist);
tempHist->Delete();
current_file = (TFile*)fileList->After( current_file );
f++;
} // End of loop over files
outputFile->cd();
currentHist->Write();
cout << endl;
} // End of loop over variabls to plot
} // End of loop over locations
// END of Core of Script //
//************************************************************
cout << endl;
cout << "Wrote file " << outputFileName << endl;
cout << endl;
outputFile->Close();
}
示例8: TCanvas
void
draw2DLimitContours(map<string,TList *>& m_contours,
const TString& par1,
const TString& par2,
const TString& plotprefix,
TLegend *legend)
{
//from here we build the two-dimensional aTGC limit
TCanvas *finalPlot = new TCanvas("final","limits",500,500);
finalPlot->cd();
cout << "Drawing expected 68%" << endl;
TList *contLevel = m_contours["exp68"];
TGraph *curv;
std::cout << "m_contours.size() = " << m_contours.size() << std::endl;
for (map<string,TList *>::const_iterator iter = m_contours.begin(); iter != m_contours.end(); iter++ ){
std::cout << "iter->first = " << iter->first << std::endl;
std::cout << "iter->second = " << iter->second << std::endl;
}
std::cout << "contLevel = " << contLevel << std::endl;
assert(contLevel);
curv = (TGraph*)(contLevel->First());
curv->GetXaxis()->SetLimits(parmin(par1),parmax(par1));
curv->GetYaxis()->SetRangeUser(parmin(par2),parmax(par2));
curv->SetTitle();
curv->GetXaxis()->SetTitle(par2latex(par1));
curv->GetXaxis()->SetTitleFont(42);
curv->GetYaxis()->SetTitle(par2latex(par2));
curv->GetYaxis()->SetTitleFont(42);
curv->GetYaxis()->SetTitleOffset(1.20);
for (int i=0; i<contLevel->GetSize(); i++) {
assert(curv);
curv->SetLineColor(kBlue);
curv->SetLineWidth(2);
curv->SetLineStyle(9);
if (!i) {
curv->Draw("AC");
legend->AddEntry(curv,"Expected 68% C.L.","L");
} else
curv->Draw("SAME C");
curv=(TGraph *)(contLevel->After(curv));
}
cout << "Drawing expected 95%" << endl;
contLevel = m_contours["exp95"];
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->SetLineColor(kGreen);
curv->SetLineWidth(2);
curv->SetLineStyle(9);
curv->Draw("SAME C");
if (!i) legend->AddEntry(curv,"Expected 95% C.L.","L");
curv=(TGraph *)(contLevel->After(curv));
}
cout << "Drawing expected 99%" << endl;
contLevel = m_contours["exp99"];
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->SetLineColor(kRed);
curv->SetLineWidth(2);
curv->SetLineStyle(9);
curv->Draw("SAME C");
if (!i) legend->AddEntry(curv,"Expected 99% C.L.","L");
curv=(TGraph *)(contLevel->After(curv));
}
contLevel = m_contours["obs95"];
if (contLevel) {
cout << "Drawing obs95" << endl;
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->Draw("SAME C");
curv->SetLineWidth(2);
if (!i) legend->AddEntry(curv,"Observed 95% C.L.","L");
curv=(TGraph *)(contLevel->After(curv));
}
}
TGraph *SMpoint = new TGraph(1);
//.........这里部分代码省略.........
示例9: z
//.........这里部分代码省略.........
TH2D *HistStreamFn = new TH2D("HstreamFn",
"#splitline{Histogram with negative and positive contents. Six contours are defined.}{It is plotted with options CONT LIST to retrieve the contours points in TGraphs}",
nZsamples, z[0], z[nZsamples-1], nPhiSamples, phi[0], phi[nPhiSamples-1]);
// Load Histogram Data
for (Int_t i = 0; i < nZsamples; i++) {
for(Int_t j = 0; j < nPhiSamples; j++){
HistStreamFn->SetBinContent(i,j, HofZ[i]*FofPhi[j]);
}
}
gStyle->SetPalette(1);
gStyle->SetOptStat(0);
gStyle->SetTitleW(0.99);
gStyle->SetTitleH(0.08);
Double_t contours[6];
contours[0] = -0.7;
contours[1] = -0.5;
contours[2] = -0.1;
contours[3] = 0.1;
contours[4] = 0.4;
contours[5] = 0.8;
HistStreamFn->SetContour(6, contours);
// Draw contours as filled regions, and Save points
HistStreamFn->Draw("CONT Z LIST");
c->Update(); // Needed to force the plotting and retrieve the contours in TGraphs
// Get Contours
TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
TList* contLevel = NULL;
TGraph* curv = NULL;
TGraph* gc = NULL;
Int_t nGraphs = 0;
Int_t TotalConts = 0;
if (conts == NULL){
printf("*** No Contours Were Extracted!\n");
TotalConts = 0;
return;
} else {
TotalConts = conts->GetSize();
}
printf("TotalConts = %d\n", TotalConts);
for(i = 0; i < TotalConts; i++){
contLevel = (TList*)conts->At(i);
printf("Contour %d has %d Graphs\n", i, contLevel->GetSize());
nGraphs += contLevel->GetSize();
}
nGraphs = 0;
TCanvas* c1 = new TCanvas("c1","Contour List",610,0,600,600);
c1->SetTopMargin(0.15);
TH2F *hr = new TH2F("hr",
"#splitline{Negative contours are returned first (highest to lowest). Positive contours are returned from}{lowest to highest. On this plot Negative contours are drawn in red and positive contours in blue.}",
2, -2, 2, 2, 0, 6.5);
hr->Draw();
Double_t x0, y0, z0;
TLatex l;
l.SetTextSize(0.03);
char val[20];
for(i = 0; i < TotalConts; i++){
contLevel = (TList*)conts->At(i);
if (i<3) z0 = contours[2-i];
else z0 = contours[i];
printf("Z-Level Passed in as: Z = %f\n", z0);
// Get first graph from list on curves on this level
curv = (TGraph*)contLevel->First();
for(j = 0; j < contLevel->GetSize(); j++){
curv->GetPoint(0, x0, y0);
if (z0<0) curv->SetLineColor(kRed);
if (z0>0) curv->SetLineColor(kBlue);
nGraphs ++;
printf("\tGraph: %d -- %d Elements\n", nGraphs,curv->GetN());
// Draw clones of the graphs to avoid deletions in case the 1st
// pad is redrawn.
gc = (TGraph*)curv->Clone();
gc->Draw("C");
sprintf(val,"%g",z0);
l.DrawLatex(x0,y0,val);
curv = (TGraph*)contLevel->After(curv); // Get Next graph
}
}
c1->Update();
printf("\n\n\tExtracted %d Contours and %d Graphs \n", TotalConts, nGraphs );
gStyle->SetTitleW(0.);
gStyle->SetTitleH(0.);
return c1;
}