//_____________________________________________________________________________ Int_t ProofSimple::GetHistosFromFC(TCanvas *cv) { // Check for the histograms in the files of a possible TFileCollection TIter nxo(fOutput); TFileCollection *fc = 0; Bool_t fc_found = kFALSE, hs_found = kFALSE; while ((fc = (TFileCollection *) nxo())) { if (strcmp(fc->ClassName(), "TFileCollection")) continue; fc_found = kTRUE; if (!fHist) { fHist = new TH1F*[fNhist]; for (Int_t i = 0; i < fNhist; i++) { fHist[i] = 0; } } else { for (Int_t i = 0; i < fNhist; i++) { SafeDelete(fHist[i]); } } // Go through the list of files TIter nxf(fc->GetList()); TFileInfo *fi = 0; while ((fi = (TFileInfo *) nxf())) { TFile *f = TFile::Open(fi->GetCurrentUrl()->GetUrl()); if (f) { for (Int_t i = 0; i < fNhist; i++) { TString hn = TString::Format("h%d", i); TH1F *h = (TH1F *) f->Get(hn); if (h) { hs_found = kTRUE; if (!fHist[i]) { fHist[i] = (TH1F *) h->Clone(); fHist[i]->SetDirectory(0); } else { fHist[i]->Add(h); } } else { Error("GetHistosFromFC", "histo '%s' not found in file '%s'", hn.Data(), fi->GetCurrentUrl()->GetUrl()); } } f->Close(); } else { Error("GetHistosFromFC", "file '%s' could not be open", fi->GetCurrentUrl()->GetUrl()); } } if (hs_found) break; } if (!fc_found) return -1; if (!hs_found) return -1; for (Int_t i = 0; i < fNhist; i++) { cv->cd(i+1); if (fHist[i]) { fHist[i]->DrawCopy(); } } Info("GetHistosFromFC", "histograms read from %d files in TFileCollection '%s'", fc->GetList()->GetSize(), fc->GetName()); // Done return 0; }
void runProofFwdDetsQA(const char * dataset = "/COMMON/COMMON/LHC09a4_run8101X",Long64_t nentries=100000, Long64_t firstentry=0) { gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); gSystem->AddIncludePath("-I$ALICE_ROOT/include"); // Connect to Proof gEnv->SetValue("XSec.GSI.DelegProxy","2"); TProof::Open("cheshkov:PWG0@alicecaf"); // Upload and enable packages: please use the correct version! gProof->UploadPackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-16-Release/AF-v4-16"); gProof->EnablePackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-16-Release/AF-v4-16"); // Create the analysis manager AliAnalysisManager *mgr = new AliAnalysisManager("AliAnaFwdDetsQA"); AliVEventHandler* esdH = new AliESDInputHandler(); mgr->SetInputEventHandler(esdH); // Enable MC event handler AliVEventHandler* handler = new AliMCEventHandler; mgr->SetMCtruthEventHandler(handler); // Create task gProof->Load(Form("%s/PWGPP/AliAnaFwdDetsQA.cxx++g", gSystem->Getenv("ALICE_ROOT"))); AliAnalysisTask *task = new AliAnaFwdDetsQA("AliAnaFwdDetsQA"); // Add task mgr->AddTask(task); // Create containers for input/output AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); AliAnalysisDataContainer *coutput = mgr->CreateContainer("coutput", TList::Class(), AliAnalysisManager::kOutputContainer, "FwdDetsQA.root"); // Connect input/output mgr->ConnectInput(task, 0, cinput); mgr->ConnectOutput(task, 1, coutput); // Enable debug printouts mgr->SetDebugLevel(3); if (!mgr->InitAnalysis()) return; mgr->PrintStatus(); TFileCollection *proofColl = gProof->GetDataSet(dataset); TChain *chain = new TChain("esdTree"); chain->AddFileInfoList((TCollection*)(proofColl->GetList())); mgr->StartAnalysis("proof", chain, nentries, firstentry); // mgr->StartAnalysis("proof",dataset,nentries,firstentry); }
void runLocal(TString dataset, TString treename = "", Long64_t nentries=TChain::kBigNumber, Long64_t firstentry = 0) { ProofAna* ana = new ProofAna(); //Need to provide a TList for local running TList* list = new TList(); ana->SetInputList(list); // Load dataset manager stuff, uses same local datasets as PROOF-Lite by design TString defaultdir(gSystem->HomeDirectory()); defaultdir.Append("/.proof"); TString dsetdir(gEnv->GetValue("ProofLite.Sandbox",defaultdir.Data())); dsetdir.Append("/datasets"); dsetdir.Prepend("dir:"); TDataSetManagerFile mgr(dsetdir); TString dsetfile(dataset); dsetfile.Append(".txt"); dsetfile.Prepend("../filelists/"); //Register dataset, if non-existent if(!mgr.ExistsDataSet(dataset)) { TFileCollection* dset = new TFileCollection(dataset,"",dsetfile); mgr.RegisterDataSet(dataset,dset,"V"); //This seems to return true regardless of success or failure at the moment if(treename.CompareTo("")!=0) { cout << "Setting default tree to " << treename << " (local and lite running)" << endl; TProof* lite = TProof::Open("lite://"); if(lite->SetDataSetTreeName(dataset,treename)) { cout << "Failure to set default tree to " << treename << endl; return; } delete lite; } } mgr.ShowDataSets(); // And yes, all this dataset garbage was to get the default tree name TFileCollection* dset = mgr.GetDataSet(dataset); TString defaultTree = dset->GetDefaultTreeName(); // Make TChain from TFileCollection...doesn't seem like there is a more direct way if(defaultTree.First("/")==0) defaultTree.Remove(0,1); TChain* T = new TChain(defaultTree); TList* filelist = (TList*)dset->GetList(); TIter next(filelist); TFileInfo* fileinfo = 0; while ((fileinfo = (TFileInfo*)next())) T->AddFile(fileinfo->GetCurrentUrl()->GetUrl()); // Process TChain T->Process(ana,"", nentries, firstentry); }