本文整理汇总了C++中TList::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::GetSize方法的具体用法?C++ TList::GetSize怎么用?C++ TList::GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::GetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractObjectFromPad
TList* extractObjectFromPad(TPad* pad, const char* name)
{
TList* objects = new TList();
TList* primitivesList = pad->GetListOfPrimitives();
assert(primitivesList);
for (int i = 0; i < primitivesList->GetSize(); ++i) {
TObject* object = primitivesList->At(i);
std::cout << object->ClassName() << ' ' << object->GetName() << std::endl;
if (object->InheritsFrom("TPad")) {
TList* objectsFromPad = extractObjectFromPad(static_cast<TPad*>(object), name);
for (int j = 0; j < objectsFromPad->GetSize(); ++j)
objects->Add(objectsFromPad->At(j));
} else if (object->InheritsFrom("THStack")) {
TList* hList = (static_cast<THStack*>(object))->GetHists();
for (int j = 0; j < hList->GetSize(); ++j)
if (!strcmp(hList->At(j)->GetName(), name)) {
objects->Add(hList->At(j));
}
} else if (!strcmp(object->GetName(), name)) {
std::cout << "--->" << name << std::endl;
objects->Add(object);
}
}
return objects;
}
示例2: getContourFilledX
TGraph* getContourFilledX(TH2D* inputHisto, TCanvas* goodCanvas, int Width, int Style, int FillStyle, double X){
TCanvas* c1 = new TCanvas("temp", "temp",600,600);
TH2D* histo = (TH2D*)inputHisto->Clone("temp");
double levels[] = {X};
histo->SetContour(1, levels);
histo->Draw("CONT LIST");
c1->Update();
TObjArray* contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
Int_t ncontours = contours->GetSize();
TList *list = (TList*)contours->At(0);
delete c1;
goodCanvas->cd();
printf("list size = %i\n", (int)list->GetSize());
if(list->GetSize()<=0)return new TGraph(0);
for(unsigned int i=0;i<list->GetSize();i++){
TGraph* EXCLUSION = (TGraph*)(list->At(i)->Clone("copy"));
EXCLUSION->SetLineColor(1);
EXCLUSION->SetLineWidth(Width);
EXCLUSION->SetLineStyle(Style);
EXCLUSION->SetFillColor(kBlack);
EXCLUSION->SetFillStyle(FillStyle);
//EXCLUSION->Draw("CL F same");
}
return EXCLUSION;
}
示例3: printf
TList* contourFromTH2(TH2 *h2in, double threshold) {
std::cout << "Getting contour at threshold " << threshold << " from " << h2in->GetName() << std::endl;
//http://root.cern.ch/root/html/tutorials/hist/ContourList.C.html
Double_t contours[1];
contours[0] = threshold;
TH2D *h2 = frameTH2D((TH2D*)h2in);
h2->SetContour(1, contours);
// Draw contours as filled regions, and Save points
h2->Draw("CONT Z LIST");
gPad->Update(); // Needed to force the plotting and retrieve the contours in TGraphs
// Get Contours
TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
TList* contLevel = NULL;
if (conts == NULL || conts->GetSize() == 0){
printf("*** No Contours Were Extracted!\n");
return 0;
}
TList *ret = new TList();
for(int i = 0; i < conts->GetSize(); i++){
contLevel = (TList*)conts->At(i);
printf("Contour %d has %d Graphs\n", i, contLevel->GetSize());
for (int j = 0, n = contLevel->GetSize(); j < n; ++j) {
TGraph *gr1 = (TGraph*) contLevel->At(j)->Clone();
ret->Add(gr1);
}
}
return ret;
}
示例4: 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
示例5: GetListOfBranches
TList* GetListOfBranches(const char* dataType, TFile* file) {
if (TString(dataType) == "HLT") {
file->cd("DQMData/Run 1/HLT/Run summary/Muon/MuonTrack");
}
else if (TString(dataType) == "RECO") {
file->cd("DQMData/Run 1/Muons/Run summary/RecoMuonV/MuonTrack");
}
else {
cout << "ERROR: Data type " << dataType << " not allowed: only RECO and HLT are considered" << endl;
cerr << "ERROR: Data type " << dataType << " not allowed: only RECO and HLT are considered" << endl;
return 0;
}
TDirectory * dir=gDirectory;
TList* sl = GetListOfDirectories(dir);
if (sl->GetSize() == 0) {
cout << "ERROR: No DQM muon reco histos found in NEW file " << endl;
cerr << "ERROR: No DQM muon reco histos found in NEW file " << endl;
delete sl;
return 0;
}
return sl;
}
示例6: testContour
void testContour()
{
TFile *file = new TFile("T2tt___sigma_UL_bestexpected.root");
TH2F *h = (TH2F*)file->Get("T2tt__expected_strength_UL");
TGraph2D *tg2d = new TGraph2D(h); //Crea TGraph2D da TH2
Double_t contours[1]; // Crea array con i valori dei contour che vuoi
contours[0] = 1.0;
tg2d->GetHistogram()->SetContour(1,contours); //SetContour(numero contour,array contour)
//tg2d->Draw("cont list"); //Dummy plotting, serve solo per creare la lista di contour
TList *contLevel = tg2d->GetContourList(1.); // Prendi quello che ti interessa
if(contLevel->GetSize()>0) doContour = true;
cout<< doContour << endl;
TCanvas *cSmoothed = new TCanvas("test","test",800,600); // Crea canvas
cSmoothed->cd();
//TH1F* hrl = cSmoothed->DrawFrame(0.1,0.,1.,0.5); // Commando fondamentale: ti setta il range del Pad, formato (x1,y1,x2,y2) dove (x1,y1) e (x2,y2) sono le coordinate estreme del tuo TH2
h->Draw("colz same"); //prima fa il Draw() del TH2 (o TGraph2D)
if (doContour){
TIter next(contLevel);
TObject *contour = 0;
while (contour = next()){
((TGraph2D*)contour)->SetLineWidth(3);
((TGraph2D*)contour)->SetLineStyle(2);
((TGraph2D*)contour)->Draw("L"); // poi fa del TGraph del contour, ma senza l'opzione "A"
}
}
//ROOT::gPad::RedrawAxis();
cSmoothed->Update();
cSmoothed->SaveAs(".root");
}
示例7: NtupleChecker
void NtupleChecker(){
TString path = "/uscms_data/d2/uplegger/CMSSW/CMSSW_3_8_0_pre7/src/RecoVertex/BeamSpotProducer/test/scripts/Ntuples/";
TSystemDirectory sourceDir("fileDir",path);
TList* fileList = sourceDir.GetListOfFiles();
TIter next(fileList);
TSystemFile* fileName;
int fileNumber = 1;
int maxFiles = 1000;
BeamSpotTreeData aData;
while ((fileName = (TSystemFile*)next()) && fileNumber <= maxFiles){
if(TString(fileName->GetName()) == "." || TString(fileName->GetName()) == ".." ){
continue;
}
TTree* aTree = 0;
TFile file(path+fileName->GetName(),"READ");//STARTUP
cout << "Opening file: " << path+fileName->GetName() << endl;
file.cd();
// aTree = (TTree*)file.Get("PrimaryVertices");
aTree = (TTree*)file.Get("BeamSpotTree");
cout << (100*fileNumber)/(fileList->GetSize()-2) << "% of files done." << endl;
++fileNumber;
if(aTree == 0){
cout << "Can't find the tree" << endl;
continue;
}
aData.setBranchAddress(aTree);
for(unsigned int entry=0; entry<aTree->GetEntries(); entry++){
aTree->GetEntry(entry);
cout << aData.getRun() << endl;
}
}
}
示例8: dominik
void dominik()
{
TH1* matHistogramRoman = static_cast<TH1*>(extractObjectFromFile("lyRoman.root", "lightYieldProjectionY")->At(0));
TList* objects = extractObjectFromFile("c.root", "chargeBins");
TH1* matHistogramDominik = new TH1D("matHistogramDominik", ";channel;light yield / pixels", 512, -0.5, 512-0.5);
int sipmIt = 0;
for (int i = 0; i < objects->GetSize(); ++i) {
TH1* h = static_cast<TH1*>(objects->At(i));
if (h->GetLineColor() == 8) {
for (int bin = 1; bin <= 128; ++bin) {
matHistogramDominik->SetBinContent(512 - (sipmIt * 128 + bin - 1), h->GetBinContent(bin));
if (h->GetBinError(bin) > 0)
matHistogramDominik->SetBinError(512 - (sipmIt * 128 + bin - 1), h->GetBinError(bin));
}
++sipmIt;
}
}
TCanvas* c = new TCanvas;
c->Divide(1, 2);
c->cd(1);
matHistogramDominik->Draw();
matHistogramRoman->Draw("SAME");
c->cd(2);
TH1* h = static_cast<TH1*>(matHistogramDominik->Clone());
h->Add(matHistogramRoman, -1);
h->Draw();
}
示例9: make_histos_syst_rawyield
void make_histos_syst_rawyield(TString file_syst, TString file_default, TString out_tag){
TFile *f1 = new TFile(file_syst.Data(),"read");
TFile *f2 = new TFile(file_default.Data(),"read");
TDirectoryFile *dir1 = (TDirectoryFile*)(f1->Get("effunf"));
TDirectoryFile *dir2 = (TDirectoryFile*)(f2->Get("effunf"));
TList *list = dir1->GetListOfKeys();
TFile *f = new TFile(Form("plots/ratiosyst_%s.root",out_tag.Data()),"recreate");
for (int i=0; i<list->GetSize(); i++){
TString name = dir1->GetListOfKeys()->At(i)->GetName();
if (!(name.Contains("hreco_"))) continue;
TObject *obj1 = dir1->Get(name.Data());
assert(obj1);
TObject *obj2 = dir2->Get(name.Data());
assert(obj2);
TString newname = name;
newname.Append("_ratiosyst");
if (name.EndsWith("_0")) newname.ReplaceAll("_0_","_EBEB_");
if (name.EndsWith("_1")) newname.ReplaceAll("_1_","_EBEE_");
if (name.EndsWith("_2")) newname.ReplaceAll("_2_","_EEEE_");
TH1F *h = (TH1F*)(((TH1F*)obj1)->Clone(newname.Data()));
h->SetTitle(h->GetName());
h->Divide((TH1F*)obj2);
for (int j=0; j<h->GetNbinsX(); j++) h->SetBinError(j+1,0);
for (int j=0; j<h->GetNbinsX(); j++) h->SetBinContent(j+1,1+fabs(1-h->GetBinContent(j+1)));
f->cd();
h->Write();
}
}
示例10: GetListOfJobs
UInt_t GetListOfJobs( TFile* file, TList& jobdirs)
{
// get a list of all jobs in all method directories
// based on ideas by Peter and Joerg found in macro deviations.C
TIter next(file->GetListOfKeys());
TKey *key(0);
while ((key = (TKey*)next())) {
if (TString(key->GetName()).BeginsWith("Method_")) {
if (gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory")) {
TDirectory* mDir = (TDirectory*)key->ReadObj();
TIter keyIt(mDir->GetListOfKeys());
TKey *jobkey;
while ((jobkey = (TKey*)keyIt())) {
if (!gROOT->GetClass(jobkey->GetClassName())->InheritsFrom("TDirectory")) continue;
TDirectory *jobDir = (TDirectory *)jobkey->ReadObj();
cout << "jobdir name " << jobDir->GetName() << endl;
jobdirs.Add(jobDir);
}
}
}
}
return jobdirs.GetSize();
}
示例11: SaveOutput
// Save to .root file
void SaveOutput(TString name,TList &list)
{
TFile *out = new TFile(name,"RECREATE");
TDirectory *pwd = gDirectory;
for(int i=0;i<list.GetSize();i++)
{
TDecayMode *dm = list.At(i);
TDirectory *subdir = out->mkdir(dm->GetName());
subdir->cd();
subdir->Append(dm);
subdir->Append(dm->histograms);
pwd->cd();
}
if(!genDesc) cout<<"WARNING! No Generator description in files!"<<endl;
else out->Append(genDesc);
if(userHisto)
{
TDecayMode *uh = (TDecayMode*) userHisto;
cout<<"INFO: Appending user histograms"<<endl;
TDirectoryFile *histos = out->mkdir("USER_HISTOGRAMS");
TIter nexthist(uh->histograms);
TKey *key_hist=0;
TH1D *h;
while(h=(TH1D*)nexthist()) histos->Append(h);
}
out->Write();
out->Close();
delete out;
}
示例12:
void TTree_UnfriendAll(TTree *tree)
{
TList *friends = tree->GetListOfFriends();
while(friends->GetSize() != 0)
{
friends->RemoveLast();
}
}
示例13: HandleButton
Bool_t KVLVContainer::HandleButton(Event_t* event)
{
// Override TGContainer method in order to set fControlClick flag
fControlClick = kFALSE;
if (event->fCode == kButton1 && (event->fState & kKeyControlMask)) fControlClick = kTRUE;
if (event->fCode == kButton3) {
TList* list = GetSelectedItems();
if (list->GetSize() == 0) {
fContextMenu->Popup(event->fXRoot, event->fYRoot, this);
delete list;
return kTRUE;
} else if (list->GetSize() == 1) {
return TGLVContainer::HandleButton(event);
}
delete list;
}
return TGLVContainer::HandleButton(event);
}
示例14: GetContour
TGraph* GetContour(TGraph2D *g, TString name){
TGraph *gnew;
//cout << g->GetName() << " " << g->GetN() << endl;
TH2D *temp = (TH2D*)g->GetHistogram();//need this for list to work?
//g->Draw("alp");//need this for list to work?
TList *glist = (TList*)g->GetContourList(1.0);
if(glist == nullptr) return gnew;
int max_points = -1;
int nn = glist->GetSize();
//cout << "number of entries in list " << nn << endl;
for(int i = 0; i<glist->GetSize(); ++i){
TGraph *gtemp = (TGraph*)glist->At(i);
int Npoints = gtemp->GetN();
if(Npoints>max_points){
gnew = (TGraph*)gtemp->Clone(name);
max_points = Npoints;
}
}
return gnew;
}
示例15: GetStatPad
TPaveStats* GetStatPad(TH1* hst)
{
TList *lst = hst->GetListOfFunctions();
if (!lst) return 0;
int nf = lst->GetSize();
for (int i=0;i<nf;i++) {
TPaveStats *fnc = (TPaveStats*) lst->At(i);
if (fnc->InheritsFrom("TPaveStats")) return fnc;
}
return 0;
//
}