// echo object at mouse position void exec1() { //example of macro called when a pad is redrawn //one must create a TExec object in the following way // TExec ex("ex",".x exec1.C"); // ex.Draw(); // this macro prints the bin number and the bin content when one clicks //on the histogram contour of any histogram in a pad //Author: Rene Brun if (!gPad) { Error("exec1", "gPad is null, you are not supposed to run this macro"); return; } int event = gPad->GetEvent(); if (event != 11) return; int px = gPad->GetEventX(); TObject *select = gPad->GetSelected(); if (!select) return; if (select->InheritsFrom(TH1::Class())) { TH1 *h = (TH1*)select; Float_t xx = gPad->AbsPixeltoX(px); Float_t x = gPad->PadtoX(xx); Int_t binx = h->GetXaxis()->FindBin(x); printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx)); } }
//______________________________________________________________________________ void HighlightFragment() { // TODO templates: what and how highlighing if (!gPad || !gr) return; // not correct TVirtualPad *ph = (TVirtualPad *)gPad->FindObject("ph"); if (!ph) { ph = new TPad("ph", "ph", 0.0, 0.2, 1.0, 1.0); ph->SetFillColor(kBlue-10); ph->Draw(); } Int_t ih = gr->GetHighlightPoint(); if (ih == -1) return; TRsnFragment *frag = group->FragmentAt(ih); if (!frag) return; TVirtualPad *save = gPad; ph->cd(); TObject *element = frag->FindElement(tagname); if (!element) ph->Clear(); else element->Draw(); save->cd(); }
// Method by name TH2F* eff2(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; TH2F* h1=0; TH2F* h2=0; TString str1 = Form("%s",name1); TString str2 = Form("%s",name2); while(obj=iter->Next()) { TString objName = obj->GetName(); if (objName == str1) h1 = (TH2F*) obj; if (objName == str2) h2 = (TH2F*) 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 TH2F* temp = eff2(h1, h2, name); return temp; }
TH1F * getHisto(TFile * file, const char * name, double fMin, double fMax, unsigned int rebin) { TObject * h = file->Get(name); if(h == 0) cout << "Can't find object " << name << "\n"; TH1F * histo = dynamic_cast<TH1F*>(h); if(histo == 0) cout << "Object " << name << " is of type " << h->ClassName() << ", not TH1\n"; TH1F * new_histo = new TH1F(name, name, (int) (fMax-fMin), fMin, fMax); int bin_num=0; for (int i = (int)fMin; i <= (int)fMax; ++i ) { bin_num= (i - (int)fMin + 1); new_histo->SetBinContent( bin_num, histo->GetBinContent(i) ); } delete histo; new_histo->Sumw2(); new_histo->Rebin(rebin); for(int i = 1; i <= new_histo->GetNbinsX(); ++i) { if(new_histo->GetBinContent(i) == 0.00) { cout<< " WARNING: histo " << name << " has 0 enter in bin number " << i << endl; } if(new_histo->GetBinContent(i) < 0.1) { new_histo->SetBinContent(i, 0.0); new_histo->SetBinError(i, 0.0); cout<< " WARNING: setting value 0.0 to histo " << name << " for bin number " << i << endl; } } return new_histo; }
void DMAHCALBooker::SetAxis(std::string type, std::string x_axis, std::string y_axis) { for(std::map<std::string, TList*>::iterator it = m_objectList.begin(); it != m_objectList.end(); it++) { if(it->first == type) { TList *pList = it->second; TIter next(pList); TObject *obj; while ((obj = next())) { if(obj->InheritsFrom("TH1")) { TH1F *h1 = static_cast<TH1F*>(obj); h1->GetXaxis()->SetTitle(x_axis.c_str()); h1->GetYaxis()->SetTitle(y_axis.c_str()); } if(obj->InheritsFrom("TH2")) { TH1F *h2 = static_cast<TH1F*>(obj); h2->GetXaxis()->SetTitle(x_axis.c_str()); h2->GetYaxis()->SetTitle(y_axis.c_str()); } } } else { emit log("ERROR", QString("Type %1 not defined").arg(QString::fromStdString(type))); return; } } }
void CopyDir(TDirectory *source) { //copy all objects and subdirs of directory source as a subdir of the current directory source->ls(); TDirectory *savdir = gDirectory; TDirectory *adir = savdir->mkdir(source->GetName()); adir->cd(); //loop on all entries of this directory TKey *key; TIter nextkey(source->GetListOfKeys()); while ((key = (TKey*)nextkey())) { const char *classname = key->GetClassName(); TClass *cl = gROOT->GetClass(classname); if (!cl) continue; if (cl->InheritsFrom(TDirectory::Class())) { source->cd(key->GetName()); TDirectory *subdir = gDirectory; adir->cd(); CopyDir(subdir); adir->cd(); } else if (cl->InheritsFrom(TTree::Class())) { TTree *T = (TTree*)source->Get(key->GetName()); adir->cd(); TTree *newT = T->CloneTree(-1,"fast"); newT->Write(); } else { source->cd(); TObject *obj = key->ReadObj(); adir->cd(); obj->Write(); delete obj; } } adir->SaveSelf(kTRUE); savdir->cd(); }
void __fastcall TVersionInfo::DoChanged(void) { TCMVersionInfoComponent NotificationMessage = { }; NotificationMessage.Msg = CM_VERSIONINFOCHANGE; NotificationMessage.Component = this; //Changed Roy: for (int i = 0; i < FUiElements->Count; ++i) { TObject* AnUiElement; // Trick: Since in our UI elements the message map as implemented // through the overridden Dispatch method is not public, // we down-cast to a descendant (TObject) where Dispatch is // public and then call Dispatch. // This technique works because Dispatch is virtual. AnUiElement = static_cast<TObject*>(FUiElements->Items[i]); assert(AnUiElement != NULL); AnUiElement->Dispatch(&NotificationMessage); } if (FOnChange != NULL) { FOnChange(this); } }
bool Entity::matches(const TObject& other) const { if (tObject_ == other) return true; bool ret = false; switch (matchLevel_) { case LevelNone: // Never matches break; case LevelAny: // Any TObject will do ret = true; break; case LevelTOType: ret = const_cast<TObjectType&>(tObject_.getType()) == other.getType(); break; case LevelTOValue: ret = tObject_ == other; break; case LevelTOName: ret = tObject_.getName() == other.getName(); break; default: break; } return ret; }
void KVHarpeeSi::SetCalibrators() { // Pulse Height Defect calibrator as well as the calibrators of // KVVAMOSDetector. KVVAMOSDetector::SetCalibrators(); // Set PHD calibrator only if the detector has an acq. parameter // with type 'E' TObject* par = GetACQParamList()->FindObjectByType("E"); if (!par) return; TString type("channel->MeV "); type.Append(par->GetName()); fCanalE = (KVFunctionCal*)GetCalibrator(type.Data()); if (!fCanalE) Error("SetCalibrators", "channel->MeV calibrator not found"); KVRecombination* c = new KVRecombination(this); type = c->GetType(); type.Append(" "); type.Append(par->GetName()); c->SetType(type.Data()); if (!AddCalibrator(c)) delete c; fPHD = (KVRecombination*)GetCalibrator(type.Data()); }
TDirectory* fileDirectory( TDirectory *target, std::string s) { TDirectory *retval = 0; // loop over all keys in this directory TIter nextkey(target->GetListOfKeys()); TKey *key, *oldkey=0; while((key = (TKey*)nextkey())) { //keep only the highest cycle number for each key if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue; // read object from file target->cd(); TObject *obj = key->ReadObj(); if(obj->IsA()->InheritsFrom(TDirectory::Class())) { // it's a subdirectory //cout << "Found subdirectory " << obj->GetName() << endl; if(strcmp(s.c_str(), obj->GetName()) == 0) return (TDirectory*)obj; if((retval = fileDirectory((TDirectory*)obj, s))) break; } else break; } return retval; }
void __fastcall TCustomVersionInfoLabel::SetVersionInfo(TVersionInfo* Value) { if (Value != FVersionInfo) { TCMVersionInfoUi NotifcationMessage = { }; TObject* Downcast; NotifcationMessage.UiElement = this; if (FVersionInfo != NULL) { NotifcationMessage.Msg = CM_VERSIONINFOUIDETACH; Downcast = FVersionInfo; Downcast->Dispatch(&NotifcationMessage); } FVersionInfo = Value; if (FVersionInfo != NULL) { NotifcationMessage.Msg = CM_VERSIONINFOUIATTACH; Downcast = FVersionInfo; Downcast->Dispatch(&NotifcationMessage); } UpdateLabelContent(); } }
TH1 *hist_extract(TPad *c) { TIter nextobj(c->GetListOfPrimitives()); for( TObject *ptr; NULL!=(ptr=nextobj.Next()); ) { printf("==========>>> %s\n",ptr->GetName()); } }
//________________________________________________________________________________ void MergeSimpleHistogramFile( const Char_t *TargetName=0, const Char_t *inputFilesPattern=0) { // This is the deprecated version. To be dleted after debugging if (TargetName && TargetName[0] && inputFilesPattern && inputFilesPattern[0] ) { TStopwatch time; Int_t fileCounter = 0; Int_t histogramCounter = 0; // Create the output file TFile *outFile = TFile::Open(TargetName,"RECREATE"); TDirIter listOfFiles(inputFilesPattern); const char *fileName = 0; while ( (fileName = listOfFiles.NextFile() ) ) { printf("."); fileCounter++; TFileIter file(fileName); TObject *obj = 0; while ( (obj = *file) ) { if ( obj->IsA()->InheritsFrom( "TH1" ) ) { // descendant of TH1 -> merge it // printf("Merging histogram: %s\n",obj->GetName() ); // std::cout << "Merging histogram " << obj->GetName() << std::endl; TH1 *h1 = (TH1*)obj; TH1 *dstHistogram = 0; // Check whether we found the new histogram if ( (dstHistogram = (TH1 *)outFile->FindObject(h1->GetName()))) { // Accumulate the histogram dstHistogram->Add(h1); delete h1; // Optional, to reduce the memory consumption printf("+"); } else { // First time - move the histogram h1->SetDirectory(outFile); printf(" The new Histogram found: %s \n", h1->GetName() ); histogramCounter++; } } else { // printf("Skipping object: %s\n",obj->GetName() ); } ++file; } } printf("\n Finishing . . . \n"); outFile->ls(); outFile->Write(); outFile->Close(); delete outFile; printf(" Total files merged: %d \n", fileCounter); printf(" Total histograms merged: %d \n", histogramCounter); time.Print("Merge"); } else { printf("\nUsage: root MergeHistogramFile.C(\"DestinationFileName\",\"InputFilesPattern\",kTRUE)\n"); printf("------ where InputFilesPattern ::= <regexp_pattern_for_the_input_files>|@indirect_file_list\n"); printf(" indirect_file_list ::= a text file with the list of the files\n"); printf(" indirect_file_list can be create by the shell command:\n"); printf(" ls -1 --color=never *.root>indirect_file_list \n\n"); } }
bool check_complete(TString fn="output_ana.root", TString fn2="ana_target.root", double minP = 0.03, int minev = 3, int maxfail=3) { bool fTest=kFALSE; TString templateFile = gSystem->Getenv("VMCWORKDIR"); templateFile += "/macro/run/"; templateFile += fn2; TFile *f=new TFile(fn,"READ"); if (!f->IsZombie()) { TFile *f2=new TFile(templateFile,"READ"); TKey *key; TIter next(f->GetListOfKeys()); int failcount = 0; while ( (key = (TKey*)next()) ) { TObject *obj = key->ReadObj(); // only check TH1Fs if (!obj->InheritsFrom("TH1F")) continue; TString name = obj->GetName(); TH1F* h = (TH1F*) obj; TH1F* h2 = (TH1F*) f2->Get(name); if ( h->GetEntries()<minev ) { cout << "Histogram (almost) empty : " << name << " \"" << h2->GetTitle() << "\": N = " << h->GetEntries() << endl; failcount++; } else { double P = h2->KolmogorovTest(h); if ( P<minP ) { cout << "Incompatible distribution: " << name << " \"" << h2->GetTitle() << "\": P = " << P << endl; failcount++; } } } if (failcount<maxfail) fTest = kTRUE; } if (fTest){ cout << " Test passed" << endl; cout << " All ok " << endl; }else{ cout << " Test Failed" << endl; cout << " Not Ok " << endl; } exit(fTest); }
void KVCanvas::ProfileX(TH2* hh) { TObject* pfx = 0; if ((pfx = FindObject(Form("%s_pfx", hh->GetName())))) pfx->Delete(); hh->ProfileX("_pfx", 1, -1, "i,d,same"); if ((pfx = FindObject(Form("%s_pfx", hh->GetName()))))((TProfile*)pfx)->SetLineColor(kBlack); Modified(); Update(); }
TH1* KVCanvas::FindHisto() { TObject* hh = 0; TIter it(GetListOfPrimitives()); while ((hh = (TObject*)it())) { if (hh->InheritsFrom("TH1")) return (TH1*) hh; } return 0; }
static void uploadScalar( TObject const & handle, typename TObject::value_type const& input, context const& ctx, bool synchronous = true) { assert ( handle.get_count() == 1 ); ctx.transfer_to_buffer(handle.get_mem(), &input, handle.value_entry_size); }
static void upload( TObject const & handle, std::vector < typename TObject::value_type > const& input, context const& ctx, bool synchronous = true) { assert ( ( input.size() / TObject::value_elements ) == handle.get_count() ); ctx.transfer_to_buffer(handle.get_mem(), &input.front(), handle.value_entry_size * handle.get_count()); }
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); }
void printJet(Jet *jet) { GenParticle *particle; Muon *muon; Track *track; Tower *tower; TObject *object; TLorentzVector momentum; momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0); //TRefArray constituentarray(jet->Constituents); TRefArray particlearray(jet->Particles); cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl; // Loop over all jet's constituents for(Int_t j = 0; j < jet->Constituents.GetEntriesFast(); ++j) { object = jet->Constituents.At(j); // Check if the constituent is accessible if(object == 0) continue; if(object->IsA() == GenParticle::Class()) { particle = (GenParticle*) object; cout << " GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl; momentum += particle->P4(); } else if(object->IsA() == Track::Class()) { track = (Track*) object; cout << " Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl; momentum += track->P4(); } else if(object->IsA() == Tower::Class()) { tower = (Tower*) object; cout << " Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl; momentum += tower->P4(); } else if(object->IsA() == Muon::Class()) { muon = (Muon*) object; cout << " Muon pt: " << muon->PT << ", eta: " << muon->Eta << ", phi: " << muon->Phi << endl; momentum += muon->P4(); } } cout << " constituent sum pt: " << momentum.Pt() <<" eta "<< momentum.Eta() <<" phi " << momentum.Phi() << std::endl; for (Int_t j =0; j<jet->Particles.GetEntries(); j++){ GenParticle *p_tmp = (GenParticle*) particlearray.At(j); printGenParticle(p_tmp); } }
//_____________________________________________________________________________ void THaHashList::PrintOpt( Option_t* opt ) const { // Print all objects in the list. Pass option 'opt' through to each object // being printed. (This is the old ROOT 2.x behavior). TIter next(this); TObject* object; while((object = next())) object->Print(opt); }
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;} } }
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); } }
void DynamicExec() { // Example of function called when a mouse event occurs in a pad. // When moving the mouse in the canvas, a second canvas shows the // projection along X of the bin corresponding to the Y position // of the mouse. The resulting histogram is fitted with a gaussian. // A "dynamic" line shows the current bin position in Y. // This more elaborated example can be used as a starting point // to develop more powerful interactive applications exploiting CINT // as a development engine. // // Author: Rene Brun TObject *select = gPad->GetSelected(); if(!select) return; if (!select->InheritsFrom("TH2")) {gPad->SetUniqueID(0); return;} TH2 *h = (TH2*)select; gPad->GetCanvas()->FeedbackMode(kTRUE); //erase old position and draw a line at current position int pyold = gPad->GetUniqueID(); int px = gPad->GetEventX(); int py = gPad->GetEventY(); float uxmin = gPad->GetUxmin(); float uxmax = gPad->GetUxmax(); int pxmin = gPad->XtoAbsPixel(uxmin); int pxmax = gPad->XtoAbsPixel(uxmax); if(pyold) gVirtualX->DrawLine(pxmin,pyold,pxmax,pyold); gVirtualX->DrawLine(pxmin,py,pxmax,py); gPad->SetUniqueID(py); Float_t upy = gPad->AbsPixeltoY(py); Float_t y = gPad->PadtoY(upy); //create or set the new canvas c2 TVirtualPad *padsav = gPad; TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c2"); if(c2) delete c2->GetPrimitive("Projection"); else c2 = new TCanvas("c2","Projection Canvas",710,10,700,500); c2->SetGrid(); c2->cd(); //draw slice corresponding to mouse position Int_t biny = h->GetYaxis()->FindBin(y); TH1D *hp = h->ProjectionX("",biny,biny); hp->SetFillColor(38); char title[80]; sprintf(title,"Projection of biny=%d",biny); hp->SetName("Projection"); hp->SetTitle(title); hp->Fit("gaus","ql"); hp->GetFunction("gaus")->SetLineColor(kRed); hp->GetFunction("gaus")->SetLineWidth(6); c2->Update(); padsav->cd(); }
//______________________________________________________________________________ void ChangeRecoParam(Int_t startRun,const char* fromURI,const char* toURI) { AliCDBManager::Instance()->SetDefaultStorage(fromURI); AliCDBManager::Instance()->SetRun(startRun); AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam"); AliMpCDB::LoadAll(); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get recoparams ? Oups" << endl; return; } if ( o->IsA() != TObjArray::Class() ) { cout << "This code only works with TObjArray recoparams. Sorry" << endl; return; } TObjArray* array = static_cast<TObjArray*>(o); for ( Int_t i = 0; i <= array->GetLast(); ++i ) { AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i)); // if (AliRecoParam::Convert(p->GetEventSpecie())==AliRecoParam::kLowMult) // { // cout << Form("array[%d]=%s %s %s",i, // p ? p->ClassName() : "", // p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"", // p ? ( p->IsDefault() ? "default" : "") : "" ) << endl; // p->Print(""); AliMUONRecoParam* rp = dynamic_cast<AliMUONRecoParam*>(p); if (!rp) { cout << "OUPS. OUPS" << endl; return; } // rp->SetHVLimit(2,1580); UInt_t mask = rp->PadGoodnessMask(); mask |= ( (1<<7) << 24 ); rp->SetPadGoodnessMask(mask); rp->Print(""); } AliCDBManager::Instance()->SetDefaultStorage(toURI); AliMUONCDB::WriteToCDB(array, "MUON/Calib/RecoParam", startRun, AliCDBRunRange::Infinity(), "reconstruction parameters for MUON, patched to take into account the bit for bus patch removed online by PAR", "L. Aphecetche"); }
KVLVEntry::~KVLVEntry() { // Dtor // disconnect fUserData object's Modified signal from our Refresh method if connected delete [] fBoolean; if (fDisconnectRefresh && fUserData) { TObject* obj = (TObject*)fUserData; if (obj && obj->TestBit(kNotDeleted)) gInterpreter->Execute(obj, obj->IsA(), "Disconnect", Form("\"Modified()\",(KVLVEntry*)%ld,\"Refresh()\"", (ULong_t)this)); } }
//________________________________________________________ void GFHistManager::DrawLegend(Int_t layer, Int_t histNo) { // histNo starting at '0' // We must already be in the correct pad, layer and histNo must exist if(fLegendArrays && layer <= fLegendArrays->GetLast() && fLegendArrays->At(layer)){ TObjArray* legends = static_cast<TObjArray*>(fLegendArrays->At(layer)); TObject* legend = (histNo <= legends->GetLast() ? legends->At(histNo) : NULL); if(legend) legend->Draw(); } }
// 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); } }
// 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(); } }
void CopyElement(char *fTempStr) { printf("Copy: %s\n", fTempStr); RootFileP->cd(); TObject *o = gROOT->FindObject(fTempStr); if (o) { RootFile2->cd(); o->Write(); } else { printf("Object %s not found.\n", fTempStr); } }