本文整理汇总了C++中TList::MakeIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::MakeIterator方法的具体用法?C++ TList::MakeIterator怎么用?C++ TList::MakeIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::MakeIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: yaxis
void yaxis(const char* patORpfx, const char* title) {
TRegexp reg(patORpfx, kFALSE);
TList* list = gDirectory->GetList() ;
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
while (obj = iter->Next()) {
if (! (obj->InheritsFrom(TH1::Class()) || obj->InheritsFrom(THStack::Class()))) continue;
TString name = obj->GetName();
if (TString(patORpfx).MaybeRegexp()) {
if (TString(obj->GetName()).Index(reg) < 0 ) continue;
} else if (! name.BeginsWith(patORpfx)) continue;
if (obj->InheritsFrom(TH1::Class()))
((TH1*)obj)->GetYaxis()->SetTitle(title);
if (obj->InheritsFrom(THStack::Class())) {
((THStack*)obj)->Draw();
((THStack*)obj)->GetYaxis()->SetTitle(title);
}
}
}
示例2: scalebins
void scalebins(const char* patORpfx, Double_t scale) {
TRegexp reg(patORpfx, kFALSE);
TList* list = gDirectory->GetList() ;
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
TString name = obj->GetName();
if (TString(patORpfx).MaybeRegexp()) {
if (TString(obj->GetName()).Index(reg) < 0 ) continue;
} else if (! name.BeginsWith(patORpfx)) continue;
Double_t binWidth, binContent, binError, newBinContent, newBinError;
for (Int_t i = 1; i <= ((TH1*)obj)->GetNbinsX(); ++i) {
binWidth = ((TH1*)obj)->GetBinWidth(i);
binContent = ((TH1*)obj)->GetBinContent(i);
binError = ((TH1*)obj)->GetBinError(i);
newBinContent = (binContent*scale)/binWidth;
newBinError = (binError*scale)/binWidth;
((TH1*)obj)->SetBinContent(i, newBinContent);
((TH1*)obj)->SetBinError(i, newBinContent);
// Rename y axis with scale
}
}
}
示例3: normalize
void normalize(const char* patORpfx) {
TRegexp reg(patORpfx, kFALSE);
TList* list = gDirectory->GetList() ;
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
TString name = obj->GetName();
if (TString(patORpfx).MaybeRegexp()) {
if (TString(obj->GetName()).Index(reg) < 0 ) continue;
} else if (! name.BeginsWith(patORpfx)) continue;
Double_t integral = 0;
if (obj->InheritsFrom(TH2::Class()))
integral = ((TH2*)obj)->Integral();
else
integral = ((TH1*)obj)->Integral();
if (integral) {
((TH1*)obj)->Sumw2();
((TH1*)obj)->Scale(1./integral);
}
}
}
示例4: legend
TLegend* legend(THStack* stack, Option_t* option = "lp", Bool_t addColor = kFALSE, Int_t token = -1,
Float_t xmin = 0.50, Float_t ymin = 0.51, Float_t xmax = 0.85, Float_t ymax = 0.92) {
if(! stack) return 0;
TLegend* leg = new TLegend(xmin, ymin, xmax, ymax);
TList* list = stack->GetHists();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
//Hist color iterator
Int_t colorIt = 1;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
if (addColor) {
hist::color(obj->GetName(), colorIt);
++colorIt;
}
if (token == -1)
leg->AddEntry(obj, obj->GetTitle(), option);
else {
TString name(obj->GetName());
TObjArray* a = name.Tokenize("_");
if (a->GetEntries() <= token)
leg->AddEntry(obj, obj->GetName(), option);
else
leg->AddEntry(obj, a->At(token)->GetName(), option);
}
}
return leg;
}
示例5: colors
void colors(TCanvas* canvas, Color_t color = 1) {
if(! canvas) return 0;
TList* list = canvas->GetListOfPrimitives();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
//Hist color iterator
Int_t colorIt = color;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
//yellow
if (colorIt == 5)
++colorIt;
hist::color(obj->GetName(), colorIt);
if (colorIt == 40)
colorIt = 1;
else
++colorIt;
}
}
示例6: eff
// Method by name
TH1F* eff(const char* name1, const char* name2, const char* name="eff"){
// Get a list of object and their iterator
TList* list = gDirectory->GetList() ;
TIterator* iter = list->MakeIterator();
// Loop over objects, set the pointers
TObject* obj;
TH1F* h1=0;
TH1F* h2=0;
TString str1 = Form("%s",name1);
TString str2 = Form("%s",name2);
while(obj=iter->Next()) {
TString objName = obj->GetName();
if (objName == str1) h1 = (TH1F*) obj;
if (objName == str2) h2 = (TH1F*) obj;
}
// quit if not found
if (h1 == 0) {
cout << "Histogram " << name1 << " not found" << endl;
return 0;
}
if (h2 == 0) {
cout << "Histogram " << name2 << " not found" << endl;
return 0;
}
// Call the method by pointer
TH1F* temp = eff(h1, h2, name);
return temp;
}
示例7: scaleToRate
void scaleToRate(const char* collectionName, double rateFactor) {
TRegexp reg(collectionName, kTRUE);
// gDirectory->ls();
TList* list = gDirectory->GetList() ;
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) {
// cout << "bugger" << endl;
continue;
}
TString name = obj->GetName();
cout << "Testing name: " << name << " against " << collectionName << endl;
if (TString(collectionName).MaybeRegexp()) {
cout << "we have a possible match" << endl;
cout << "Trying to match to " << TString(obj->GetName()) << endl;
if (TString(obj->GetName()).Index(reg) < 0 ) {
cout << "failure here. Argument returns " << TString(obj->GetName()).Index(reg) << endl;
continue;
}
}
else if (! name.BeginsWith(collectionName)) continue;
cout << "We're trying to scale" << name << endl;
((TH1*)obj)->Scale(rateFactor);
}
}
示例8: drawsame
void drawsame(const char* canvasName, const char* patORpfx,Option_t* drawOption = "") {
// cout << "testing this method" << endl;
TRegexp reg(patORpfx, kFALSE);
TList* list = gDirectory->GetList() ;
// cout << "this bleeping directory has " << gDirectory->GetNkeys() << "things in it" << endl;
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
TObject* canvas = 0;
Bool_t makeCanvas = false;
canvas = gROOT->GetListOfCanvases()->FindObject(canvasName);
//If canvas does not exist, remember to create it
// cout << "found our canvas" << endl;
if (! canvas) makeCanvas = true;
while (obj = iter->Next()) {
// cout << "We have an object" << endl;
if (! obj->InheritsFrom(TH1::Class())) continue;
TString name = obj->GetName();
// cout << "Testing object of name " << name << endl;
// if (TString(patORpfx).MaybeRegexp()) { THIS BASICALLY ADDS IT IF IT HAS A BLEEPING PULSE
if (TString(name).Contains(patORpfx)) {
// cout << "possible match" << endl;
if (TString(obj->GetName()).Index(reg) < 0 ) {
// cout << "not a match here" << endl;
continue;
}
else if (! name.BeginsWith(patORpfx)) {
// cout << "mismatched beginning" << endl;
continue;
}
if (makeCanvas) {
canvas = new TCanvas(canvasName, canvasName);
makeCanvas = false;
}
((TH1*)obj)->UseCurrentStyle();
((TCanvas*)canvas)->cd();
if (!((TCanvas*)canvas)->GetListOfPrimitives()->GetEntries()) {
// cout << "Drawing with non-same option" << endl;
((TH1*)obj)->Draw(Form("%s", drawOption));
}
else {
// cout << "Drawing with the same option" << endl;
((TH1*)obj)->Draw(Form("SAME%s", drawOption));
}
}
}
hist::colors((TCanvas*)canvas);
}
示例9: deleteHistos
void deleteHistos() {
// Delete all existing histograms in memory
TObject* obj;
TList* list = gDirectory->GetList() ;
TIterator* iter = list->MakeIterator();
while (obj=iter->Next()) {
if (obj->IsA()->InheritsFrom(TH1::Class()) ||
obj->IsA()->InheritsFrom(TH2::Class()) ) {delete obj;}
}
}
示例10: normalize_all_by_single_SF
// Multiply everything by a scale factor
void normalize_all_by_single_SF(double factor) {
TList* list = gDirectory->GetList();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
((TH1F*)obj)->Scale(factor);
}
}
示例11: while
// Sumw2 all your bleep if you're a muppet (like Tom) and forgot to do it in
// your analysis code
void sumw2Everything() {
TList* list = gDirectory->GetList();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
((TH1F*)obj)->Sumw2();
}
}
示例12: normalizeAllToUnity
// normalize all your bleep to 1
void normalizeAllToUnity() {
TList* list = gDirectory->GetList();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
int nBins = ((TH1F*)obj)->GetNbinsX();
Float_t integral = ((TH1F*)obj)->Integral(1, nBins+1);
if (integral > 0) ((TH1F*)obj)->Scale(1/integral);
}
}
示例13: styles
void styles(TCanvas* canvas, Style_t style = 20) {
if(! canvas) return 0;
TList* list = canvas->GetListOfPrimitives();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
//Hist style iterator
Int_t styleIt = style;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
((TH1*)obj)->SetMarkerStyle(styleIt);
++styleIt;
}
}
示例14: stack
void stack(const char* stackHistName, const char* patORpfx, Bool_t addColor = kFALSE, Option_t* drawOption = "") {
// cout << "bleep1" << endl;
TRegexp reg(patORpfx, kFALSE);
TList* list = gDirectory->GetList() ;
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
TObject* stack = 0;
Bool_t makeStackHist = false;
stack = gDirectory->Get(stackHistName);
//If stack hist does not exist, remember to create it
if (! stack) makeStackHist = true;
//Hist color iterator
Int_t colorIt = 1;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
TString name = obj->GetName();
if (TString(patORpfx).MaybeRegexp()) {
if (TString(obj->GetName()).Index(reg) < 0 ) continue;
} else if (! name.BeginsWith(patORpfx)) continue;
if (makeStackHist) {
stack = new THStack(stackHistName, stackHistName);
makeStackHist = false;
}
if (addColor) {
cout << "calling the color method" << endl;
hist::color(obj->GetName(), colorIt);
++colorIt;
}
((THStack*)stack)->Add((TH1*)obj, drawOption);
}
// Currently breaks .ls
gDirectory->Append(stack);
}
示例15: setrangey
void setrangey(TCanvas* canvas, Double_t maxy = -999999, Double_t miny = 999999) {
if(! canvas) return 0;
TList* list = canvas->GetListOfPrimitives();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
TObject* top = 0;
while (obj = iter->Next()) {
// cout << "iterating over objects, should be 2 in this case" << endl;
if (! obj->InheritsFrom(TH1::Class())) {
// cout << "bleep, stacks present a problem" << endl;
continue;
}
if (! top) top = obj;
// cout << "Make sure we are looking at different objects\n";
// cout << "max for this object: " << ((TH1*)obj)->GetMaximum() << endl;
if (((TH1*)obj)->GetMaximum() > maxy) maxy = ((TH1*)obj)->GetMaximum();
// JAKE Set to log scale if max/min > 10
if (canvas->GetLogy()) {
//protect against user supplied argument
if (miny == 0) miny = 999999;
for(Int_t bin = 1; bin <= ((TH1*)obj)->GetNbinsX(); ++bin) {
Double_t binContent = ((TH1*)obj)->GetBinContent(bin);
if (binContent != 0 && binContent < miny)
miny = binContent;
}
} else if (((TH1*)obj)->GetMinimum() < miny) miny = ((TH1*)obj)->GetMinimum();
}
cout << "miny, maxy = " << miny <<" "<<maxy << endl;
((TH1*)top)->SetMaximum(maxy*1.3);
((TH1*)top)->SetMinimum(miny*0.7);
}