UInt_t GetListOfTitles( TDirectory *rfdir, TList & titles ) { // get a list of titles (i.e TDirectory) given a method dir UInt_t ni=0; if (rfdir==0) return 0; TList *keys = rfdir->GetListOfKeys(); if (keys==0) { cout << "+++ Directory '" << rfdir->GetName() << "' contains no keys" << endl; return 0; } // TIter rfnext(rfdir->GetListOfKeys()); TKey *rfkey; titles.Clear(); titles.SetOwner(kFALSE); while ((rfkey = (TKey*)rfnext())) { // make sure, that we only look at histograms TClass *cl = gROOT->GetClass(rfkey->GetClassName()); if (cl->InheritsFrom("TDirectory")) { titles.Add(rfkey); ni++; } } cout << "--- Found " << ni << " instance(s) of the method " << rfdir->GetName() << endl; return ni; }
void fullCombination(const bool electrons = false) { TString type("_muons"); if( electrons ) type = "_electrons"; std::map<TString, TList*> cathegories; // Loop over all files std::map<TString, double> fw(filesAndWeightsMap( electrons )); std::map<TString, double>::const_iterator it = fw.begin(); for( ; it != fw.end(); ++it ) { TString cathegory(getCategory(it->first)); if( cathegories[cathegory] == 0 ) cathegories[cathegory] = new TList(); std::cout << "fileName = " << std::string(it->first).substr(std::string(it->first).find_last_of("/")+1)+"weighted"+type+".root" << std::endl; cathegories[cathegory]->Add( TFile::Open(std::string(it->first).substr(std::string(it->first).find_last_of("/")+1)+"weighted"+type+".root") ); } TList * combinationsList = new TList(); std::map<TString, TList*>::const_iterator it2 = cathegories.begin(); for( ; it2 != cathegories.end(); ++it2 ) { TFile *Target = TFile::Open( it2->first+"_combined"+type+".root", "RECREATE" ); std::cout << "fileName = " << it2->first << std::endl; combinationsList->Add( Target ); mergeFiles( Target, it2->second ); } }
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(); }
int main(int argc, char *argv[]) try { // Test if sufficient number of arguments is specified. if (5 > argc) throw std::invalid_argument("usage: merge luminosity out.root in.root [more_in.root]"); std::auto_ptr<TRint> application(new TRint("histInMemory", 0, 0)); TFile *output = 0; TList *inputs = 0; try { ::luminosity = lexical_cast<double>(argv[1]); if (0 >= ::luminosity) throw std::runtime_error("Non-positive luminosity is specified"); // Create output file output = new TFile(argv[2], "RECREATE"); if (!output->IsOpen()) throw std::runtime_error("Failed to open output file"); // open specified input files to the List // inputs = new TList(); cout << "Inputs" << endl; for( int i = 3; argc > i; ++i) { cout << " [+] " << argv[i] << endl; inputs->Add(TFile::Open(argv[i])); } // Call merge MergeRootfile(output, inputs); // memory cleanup delete inputs; delete output; } catch(const std::exception &error) { // memory cleanup in case of error if (inputs) delete inputs; if (output) delete output; throw; } return 0; } catch(const std::exception &error) { cerr << error.what() << endl; return 1; }
//_______________________________________________________________________________________ void MakeFourView(TVirtualPad *pad=0) { // Creates 4 pads view of the pad (or qPad) // ------------------------------ // | | | // | | | // | | | // | Front | Top | // | view | view | // | | | // | | | // | | | // ---------------+------------- // | | | // | | | // | | | // | Side | Spacial | // | view | view | // | | | // | | | // | | | // ------------------------------ // begin_html <P ALIGN=CENTER> <IMG SRC="gif/FourStarView.gif" ></P> end_html // TVirtualPad *thisPad = pad; if (!thisPad) thisPad = qPad(); TView *view = 0; TList *thisPrimitives = 0; if (thisPad && (thisPrimitives = thisPad->GetListOfPrimitives()) && (view = thisPad->GetView()) ) { Double_t min[3],max[3]; view->GetRange(min,max); Int_t system = view->GetSystem(); TCanvas *c = new TCanvas(" 4 views", thisPad->GetTitle(),600,600); c->Divide(2,2); TIter *next= new TIter(thisPrimitives); for (int i =1; i <= 4; i++) { c->cd(i); TList *newPrimitives = qPad()->GetListOfPrimitives(); TObject *obj = 0; while (obj = next->Next()) newPrimitives->Add(obj); TView *newView = new TView(system); newView->SetRange(min,max); next->Reset(); } delete next; // set separate view; // Fron view Int_t j = 1; c->cd(j++); FrontView(); c->cd(j++); TopView(); c->cd(j++); SideView(); c->cd(j++); RotateView(-30.0,60.0,0); c->Modified(); c->Update(); } }
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
/** * Get the list of monitored objects * * @return The list of monitored objects */ virtual TList* GetMonitorObjects() { TObject* m1 = new TNamed("dNdy", ""); m1->SetUniqueID(0x8); // Scale TList* ret = new TList; ret->Add(m1); return ret; }
void compareDYTemplates(TString baseURL="~/scratch0/top-newjec/syst_plotter.root") { TString ch[]={"ee","mumu"}; TString categs[]={"eq1jets",""}; for(size_t ich=0; ich<2; ich++) { for(size_t icat=0; icat<2; icat++) { TObjArray lowMet = getDistributionFromPlotter(ch[ich]+"_"+categs[icat]+"lowmetdilarccosine",baseURL); TH1 *lowMetH = (TH1 *) ((TList *)lowMet.At(3))->At(3); formatPlot(lowMetH,1,1,1,24,0,false,false,1,1,1); lowMetH->SetTitle("E_{T}^{miss}<30 GeV/c^{2}"); lowMetH->Scale(1./lowMetH->Integral()); TObjArray highMet = getDistributionFromPlotter(ch[ich]+"_"+categs[icat]+"dilarccosine",baseURL); TH1 *highMetH = (TH1 *) ((TList *)highMet.At(3))->At(3); formatPlot(highMetH,1,1,1,20,0,false,false,1,1,1); highMetH->SetTitle("E_{T}^{miss}>30 GeV/c^{2}"); highMetH->Scale(1./highMetH->Integral()); TString channelTitle(ich==0 ? "ee" : "#mu#mu"); if(categs[icat]=="eq1jets") channelTitle += "+ 1 jet"; else channelTitle += "+ #geq 2 jets"; //draw TString plot(ch[ich]+categs[icat]+"_anglecomparison"); TCanvas *cnv = getNewCanvas(plot+"c",plot+"c",false); cnv->Clear(); cnv->SetWindowSize(600,600); cnv->cd(); TList *mc = new TList; mc->Add(lowMetH); TList *data = new TList; data->Add(highMetH); TList *spimpose = new TList; TLegend *leg=showPlotsAndMCtoDataComparison(cnv,*mc,*spimpose,*data,false); TPad *p=(TPad *)cnv->cd(1); formatForCmsPublic(p,leg,"CMS simulation, " + channelTitle, 4); cnv->SaveAs(plot+".C"); cnv->SaveAs(plot+".pdf"); cnv->SaveAs(plot+".png"); } } }
//______________________________________________________________________________ void CreateAnalysisTrain() { /// create the analysis train and configure it // analysis manager AliAnalysisManager *mgr = new AliAnalysisManager("MuonPhysicsAnalysis"); // Debug mode //mgr->SetDebugLevel(3); // AOD handler AliInputEventHandler* aodH = new AliAODInputHandler; mgr->SetInputEventHandler(aodH); // Fill the trigger list with desired trigger combinations (See on ALICE log book for denomination) //============================================================================== TList* triggers = new TList; // Create pointer for trigger list triggers->SetOwner(kTRUE); // Give rights to trigger liser if (!isMC) { // PbPb trigger triggers->Add(new TObjString("CINT7-B-NOPF-MUFAST"));//MB &0MUL triggers->Add(new TObjString("CINT7-B-NOPF-MUFAST&0MSL"));//MB &0MUL triggers->Add(new TObjString("CINT7-B-NOPF-MUFAST&0MUL"));//MB &0MUL triggers->Add(new TObjString("CMUL7-B-NOPF-MUFAST"));// MUL triggers->Add(new TObjString("CMSL7-B-NOPF-MUFAST"));// MSL triggers->Add(new TObjString("CMSL7-B-NOPF-MUFAST&0MUL"));// MSL &0MUL } // Load centrality task //============================================================================== gROOT->LoadMacro("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C"); AddTaskMultSelection(kFALSE); // user // Load task //============================================================================== TString outputname = AliAnalysisManager::GetAnalysisManager()->GetCommonFileName(); // Create output name in case of no dataset selected gROOT->LoadMacro("AddTaskMuMu.C"); AddTaskMuMu(outputname.Data(),triggers,"PbPb2015",isMC); cout <<"add task mumu done"<< endl; }
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; }
TList *QtMultiFileDialog(const char *style="") { // This is a small ROOT macro to use Qt 3.3 class :begin_html <a href="http://doc.trolltech.com/3.3/qfiledialog.html">QFileDialog</a> end_html // See: begin_html <a href="http://doc.trolltech.com/3.3/qfiledialog.html#getOpenFileNames">http://doc.trolltech.com/3.3/qfiledialog.html#getOpenFileNames</a> end_html // // To use, invoke ACLiC from the ROOT prompt: // root [] .x QtMultiFileDialog.C++ // // To use it with no ACLiC, omit the trailing "++" // root [] .x QtMultiFileDialog.C // // The QtMultiFileDialog creates TList of TObjString objects and // returns its pointer. // // The "QtFileDialog.C" macro provides the simplified version of the "QtMultiFileDialog.C" // // Option: you can change the look and feel of the Qt file dialog // ======= by providing the optional parameter "style": // The number of the available styles is defined by your local // Qt installation. // Try: "windows", "motif", "kde", "platinum" etc // // The full list of the Qt classes available from Cint is defined by // begin_html <a href="http://root.bnl.gov/QtRoot/htmldoc/src/qtclasses.h.html">by $ROOTSYS/cint/lib/qtclasses.h</a> end_html // // All Qt classes can be used from ACLiC though. #ifdef __CINT__ // Load the qt cint dictionary. // One is recommended to do that at once somewhere. // For example from one's custom rootlogon.C script gSystem->Load("$ROOTSYS/cint/cint/include/qtcint"); #endif QStyle *saveStyle = 0; if (!QString(style).isEmpty()) { saveStyle = QApplication::style(); QApplication::setStyle(style); } TList *listOfNames = new TList(); QStringList files = QFileDialog::getOpenFileNames (); QStringList::Iterator it = files.begin(); while ( it != files.end() ) { std::string flnm = (*it).toStdString(); printf ("Next file selected: %s\n", flnm.c_str() ); // Convert QString to TObjString and add it to the output listOfNames->Add(new TObjString(flnm.c_str())); ++it; } // Restore the style if (saveStyle) QApplication::setStyle(saveStyle); printf ("\nThe TList of the file names contains:"); printf ("\n-------------------------------------\n"); listOfNames->ls(); return listOfNames; }
void TxtToBmp (TStrings *List, Graphics::TBitmap *Bitmap, TFont *Font, int left, int top) { TList *newlist = new TList; for(int i=0; i<List->Count; ++i) { char str[10000]; strcpy(str, List->Strings[i].c_str()); newlist->Add(strdup(str)); } TxtToBmp(newlist, Bitmap, Font, left, top); }
TList* GetKeyList( const TString& pattern ) { TList* list = new TList(); TIter next( TMVAGui_keyContent ); TKey* key(0); while ((key = (TKey*)next())) { if (TString(key->GetName()).Contains( pattern )) { list->Add( new TObjString( key->GetName() ) ); } } return list; }
TList* KVASGroup::GetDetectorsInLayer(UInt_t lay) { //Creates and fills a list with all the detectors in the "detector layer" //lay. Detector layers are always numbered from 1 (nearest target) to //GetNumberOfDetectorLayers(). //Delete list after use. if (lay < 1) return 0; UInt_t ndl = 0; UInt_t imin = GetLayerNearestTarget(); UInt_t imax = GetLayerFurthestTarget(); for (UInt_t i = imin; i <= imax; i++) { TList* tlist = GetTelescopesInLayer(i); if (tlist) { //note we take the max number of detectors in telescopes of layer i Int_t max = 0; TIter it(tlist); KVTelescope* tel = 0; while ((tel = (KVTelescope*)it.Next())) if (max < tel->GetDetectors()->GetSize()) max = tel->GetDetectors()->GetSize(); ndl += max; // //before it was assume that all telescopes in same layer are identically constructed //ndl += ((KVTelescope *) tlist->At(0))->GetDetectors()->GetSize(); // if (ndl >= lay) { //the required detector layer is in the telescopes in the list //calculate rank of detectors in telescopes UInt_t rank = max - ndl + lay; TIter next(tlist); KVTelescope* tel; TList* list = new TList; while ((tel = (KVTelescope*) next())) { if (rank <= (UInt_t)tel->GetSize()) { KVDetector* ddd = tel->GetDetector(rank); if (ddd) list->Add(ddd); else Warning("GetDetectorsInLayer", "pb d index pour GetDetector"); } } delete tlist; return list; } delete tlist; } } return 0; }
//_____________________________________________________ void GFHistManager::AddObject(TObject* obj, Int_t layer, Int_t histoNum, Option_t* opt) { // hist and layer must already exist if(!this->CheckHistNum("AddObject", layer, histoNum)) return; TList* objList = this->MakeObjList(layer, histoNum); objList->Add(obj, opt); if(layer < fCanArrays->GetEntriesFast()) { this->Update(layer); // if canvas already drawn } }
//--------------------------------------------------------------------------- // Description: Highlights the routes with the heigher pheromone intesity // starting from the Nest. If the Food source is not reached // after a given number of tries, stop the search and draw the // result. bool __fastcall Civilization::FindMainRoads(int Ntries, TImage *ImageBox, const int RWidth, const float Scale) { // Start from the Anthill... City *CurrentCity = Nest; TList *MainRoads = new TList(); while(CurrentCity!=FoodSourceCity && Ntries>0) { int PheroLevel = -MAXINT; Route *CurrentRoad = NULL; City* NextCity; Route* thisRoad; // the following loop select the best road acording to the pheromone level for(int j=0; j<Roads->Count; j++) { thisRoad = (Route*)Roads->Items[j]; // if the road has a conection with the current city... NextCity = thisRoad->GetConection(CurrentCity); // Test the highest Pheromone level among the possible roads... // if 'thisRoad' was not used before... if(NextCity!=NULL && MainRoads->IndexOf(thisRoad)==-1) { if(thisRoad->GetPheromone() > PheroLevel) { CurrentRoad = thisRoad; PheroLevel = thisRoad->GetPheromone(); } } } // Go to next city using the selected road... if(CurrentCity!=NULL && CurrentRoad!=NULL) { CurrentCity = CurrentRoad->GetConection(CurrentCity); MainRoads->Add(CurrentRoad); } Ntries--; } // Draw the MainRoad Rebuild(ImageBox,Scale); // Draw all the roads for(int i=0; i<MainRoads->Count; i++) { ImageBox->Canvas->Pen->Width = RWidth; ((Route*)MainRoads->Items[i])->DrawRoad(ImageBox,clRed,Scale); ImageBox->Canvas->Pen->Width = 1; } return (Ntries>0)?true:false; }
//______________________________________________________________________________ AliAnalysisTask* runMuMuLoop(TString smode = "local", TString inputFileName = "Find;BasePath=/alice/data/2015/LHC15o/000244918/muon_calo_pass1/AOD/*;FileName=AliAOD.Muons.root;Mode=cache;" ) { // path for macro usefull for saf3 gROOT->LoadMacro(gSystem->ExpandPathName("$HOME/Documents/Analysis/Macro/Philippe/runTaskFacilities.C")); // --- analysis setup --- TString rootVersion = ""; TString alirootVersion = ""; TString aliphysicsVersion = "vAN-20151215-1"; TString dataDir = "/alice/cern.ch/user/p/ppillot/Data/LHC15n/reco/PbPbParam_AlignV6"; TString dataPattern = "*AliESDs.root"; TString runFormat = "%09d"; TString outDir = "Data/LHC15n/reco/PbPbParam_AlignV6/Phys/all"; TString analysisMacroName = "Physics"; Int_t ttl = 30000; Int_t maxFilesPerJob = 100; Int_t maxMergeFiles = 10; Int_t maxMergeStages = 2; TString extraLibs="PWGmuon"; TString extraIncs="include"; TString extraTasks=""; TString extraPkgs=""; // Copy file to run on the saf TList pathList=0x0; pathList.SetOwner(); // pathList.Add(new TObjString("$HOME/alicesw/aliphysics/mumu/src/PWG/muon")); TList fileList; fileList.SetOwner(); // --- prepare the analysis environment --- Int_t mode = PrepareAnalysis(smode, inputFileName, extraLibs, extraIncs, extraTasks, extraPkgs, pathList, fileList); fileList.Add(new TObjString("runMuMuLoop.C")); fileList.Add(new TObjString("AddTaskMuMu.C")); // --- run the analysis (saf3 is a special case as the analysis is launched on the server) --- // --- run the analysis (saf3 is a special case as the analysis is launched on the server) --- if (mode == kSAF3Connect) { RunAnalysisOnSAF3(fileList, aliphysicsVersion, inputFileName); } else { CreateAnalysisTrain(); RunAnalysis(smode, inputFileName, rootVersion, alirootVersion, aliphysicsVersion, extraLibs, extraIncs, extraTasks, extraPkgs, dataDir, dataPattern, outDir, analysisMacroName, runFormat, ttl, maxFilesPerJob, maxMergeFiles, maxMergeStages); } }
//--------------------------------------------------------------------------- void __fastcall TSup1004::btOKClick(TObject *Sender) { int i; if(ItensAdd->Items->Count> 0) { TList *pListAdd = new TList(); for(i=0;i<ItensAdd->Items->Count;i++) { pListAdd->Add(ItensAdd->Items->Objects[i]); } this->OnConfirmList(pListAdd); delete pListAdd; } Close(); }
void DrawSkippable(TTree* tree, const char* what, const char* where, Bool_t draw = true) { //cerr << "Doing " << what << " which is " << skip << endl; if (draw) { TString cut = what; cut.Append(">>"); cut.Append(where); tree->Draw(cut.Data(),"","goff"); TH1* h = (TH1*)gDirectory->FindObject(where); if (h) h->SetTitle(Form("histo made from T->Draw(\"%s\")",what)); } else { gSkipped.Add(new TNamed(where,where)); } };
af::TElement Scheme::AddFragment() { if(Root.IsNull()) { throw NoLabelInicialisationException("Scheme: label do not inicialised."); } TList FragmList = GetFragmentList(); Scheme SCHEME(FragmList.Add()); return SCHEME; }
void AddParticleMonitor(AliAnalysisTaskSE *task, Bool_t isMC, Int_t listID1,AliRsnCutSet *commonEventCuts=0,AliRsnCutSet *cutPair=0,TString name = "") { Bool_t valid; Int_t isRsnMini = AliAnalysisManager::GetGlobalInt("rsnUseMiniPackage",valid); Int_t useMCMon = AliAnalysisManager::GetGlobalInt("rsnUseMCMonitoring",valid); if (isRsnMini) { // Printf("Monitoring by mini is not supported now. It will be soon !!!"); // return ; AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); AliRsnMiniMonitorTask *monTask = new AliRsnMiniMonitorTask(name.Data(),useMCMon); AddMonitorOutputMini(monTask,listID1,name); // AddMonitorOutputMini(monTask,listID1,name,'+'); // AddMonitorOutputMini(monTask,listID1,name,'-'); mgr->AddTask(monTask); // connect input container according to source choice mgr->ConnectInput(monTask, 0, mgr->GetCommonInputContainer()); // create paths for the output in the common file TString commonPath = AliAnalysisManager::GetCommonFileName(); // create containers for output AliAnalysisDataContainer *output = mgr->CreateContainer(Form("RsnMonMini%s", name.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, commonPath.Data()); mgr->ConnectOutput(monTask, 1, output); } else { TList *listLoops = new TList; // monitor definition AliRsnDaughterDef *tracksAll = new AliRsnDaughterDef(AliRsnDaughter::kTrack /*'+' or '-'*/); // // AliRsnDaughterDef *tracksPos = new AliRsnDaughterDef(AliRsnDaughter::kTrack,'+'); // // AliRsnDaughterDef *tracksNeg = new AliRsnDaughterDef(AliRsnDaughter::kTrack,'-'); // AliRsnLoopDaughter *lm =0; // // loop object listLoops->Add(new AliRsnLoopDaughter(Form("ALL_%s", name.Data()), listID1, tracksAll)); // // // listLoops->Add(new AliRsnLoopDaughter(Form("%s_pos", name.Data()), listID1, tracksPos)); // // listLoops->Add(new AliRsnLoopDaughter(Form("%s_neg", name.Data()), listID1, tracksNeg)); // TIter next(listLoops); while ((lm = (AliRsnLoopDaughter *)next.Next())) { // if (commonEventCuts) lm->SetEventCuts(commonEventCuts); AddMonitorOutput(0,"mc_loop",lm); ((AliRsnAnalysisTask *)task)->AddLoop(lm); } } }
TList* GetListOfDirectories(TDirectory* dir, const char* match = 0) { TIter nextkey(dir->GetListOfKeys()); TList* sl = new TList(); TKey* key = 0; TKey* oldkey = 0; while (( key = (TKey*)nextkey() )) { TObject *obj = key->ReadObj(); if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) { TString theName = obj->GetName(); if (!match) { cout << " -> " << theName << endl; sl->Add(obj); } else if (theName.Contains(match)) { cout << " -> " << theName << endl; sl->Add(obj); } } } // End of while return sl; }
TList* extractObjectFromFile(const char* fileName, const char* name) { TList* objects = new TList(); TFile file(fileName); gROOT->cd(); TList* keyList = file.GetListOfKeys(); for (int i = 0; i < keyList->GetSize(); ++i) { TKey* key = static_cast<TKey*>(keyList->At(i)); std::cout<< key->GetName()<< std::endl; if (!strcmp(key->GetName(), name)) { objects->Add(key->ReadObj()->Clone()); } else if (!strcmp(key->GetClassName(), "TCanvas")) { TCanvas* canvas = static_cast<TCanvas*>(key->ReadObj()); if (!strcmp(canvas->GetName(), name)) objects->Add(canvas->Clone()); TList* objectsFromPad = extractObjectFromPad(canvas, name); for (int j = 0; j < objectsFromPad->GetSize(); ++j) objects->Add(objectsFromPad->At(j)); } } file.Close(); return objects; }
TList* KVGroup::GetDetectorsInLayer(UInt_t lay) { // lay=1 : create and fill list with detectors closest to target // lay=GetNumberOfDetectorLayers() : detectors furthest from target TList* dets = new TList; TIter next(GetDetectors()); KVDetector* d; while ((d = (KVDetector*)next())) { if (lay == (UInt_t)d->GetAlignedDetectors()->GetEntries()) dets->Add(d); } return dets; }
TCollection* KVRTGIDManager::GetIDTelescopesForTGID(KVTGID* tgid) { // Return TList of all ID telescopes for which fit is valid. // Returns 0 if no telescopes are defined, or if gMultiDetArray object is not defined // (we search for the telescopes using their name and gMultiDetArray->GetIDTelescope()). // WARNING: DELETE this list after use !!! if (tgid->GetIDTelescopes()=="/" || !gMultiDetArray) return 0; TList* list = new TList; tgid->GetIDTelescopes().Begin("/"); while ( !tgid->GetIDTelescopes().End() ) { list->Add( gMultiDetArray->GetIDTelescope( tgid->GetIDTelescopes().Next() ) ); } return list; }
TList* KVLVContainer::GetSelectedObjects() { // Create and fill list with all currently selected objects (derived from TObject) // USER MUST DELETE TLIST AFTER USE!!! TGFrameElement* el; TIter next(fList); TList* ret = new TList(); while ((el = (TGFrameElement*) next())) { if (el->fFrame->IsActive()) { ret->Add((TObject*)((KVLVEntry*)el->fFrame)->GetUserData()); } } return ret; }
TList* KVLVContainer::GetSelectedItems() { // Create and fill list with all currently selected items (KVLVEntry objects) // USER MUST DELETE TLIST AFTER USE!!! TGFrameElement* el; TIter next(fList); TList* ret = new TList(); while ((el = (TGFrameElement*) next())) { if (el->fFrame->IsActive()) { ret->Add(el->fFrame); } } return ret; }
af::TElement Scheme::SetEqvList() { if(Root.IsNull()) { throw NoLabelInicialisationException("Scheme: label do not inicialised."); } RemoveElementByName("EqvList"); TList B; B.SetRoot(Root); EqvList = B.Add(); EqvList.SetName ("EqvList"); return EqvList; }
TList* KVASGroup::GetTelescopesInLayer(UInt_t nlayer) { //Create and fill list of telescopes belonging to Layer number nlayer in the group. //User must delete list after use. TIter next(GetTelescopes()); KVTelescope* t; TList* list = 0; while ((t = (KVTelescope*) next())) { if (t->GetParentStructure("RING")->GetParentStructure("LAYER")->GetNumber() == nlayer) { if (!list) list = new TList; list->Add(t); } } return list; }
// Search for files matching the pattern and different from the first file TList *getFileList(TString first, TString dirname, TRegexp pattern) { void *dir = gSystem->OpenDirectory(dirname); if(!dir) return 0; const char *file = 0; TList *list = new TList(); while(file = gSystem->GetDirEntry(dir)) { TString f(file); if(!f.Contains(pattern)) continue; if(!f.CompareTo(first)) continue; cout<<"Added file: "<<f<<endl; list->Add(new TFile(dirname+"/"+f,"READ")); } gSystem->FreeDirectory(dir); cout<<endl; return list; }