void MergeFlowd() { TGrid *alien = TGrid::Connect("alien"); if (alien->IsZombie()) { delete alien; cout << "Fatal: Alien is a zombie!" << endl; return; } Int_t runlist[] = { // Counter /*170309, 170308, 170306, 170270, 170269, 170268, 170230, 170228,*/ 170204, 170203, // 10 170193, 170163, 170159, 170155, 170081, 170027, 169859, 169858, 169855, 169846, // 20 169838, 169837, 169835, 169417, 169415, 169411, 169238, 169167, 169160, 169156, // 30 169148, 169145, 169144, 169138, 169094, 169091, 169035, 168992, 168988, 168826, // 40 168777, 168514, 168512, 168511, 168467, 168464, 168460, 168458, 168362, 168361, // 50 168342, 168341, 168325, 168322, 168311, 168310, 167988, 167987 // 58 }; TFileMerger merger; TString dataBaseDir = "/alice/cern.ch/user/m/mpuccio/Flowd_PbPb2011/output/000"; merger.OutputFile("FileMerger.root"); for (int iRun = 0; iRun < 1; ++iRun) { TString runDir = Form("%s%i",dataBaseDir.Data(),runlist[iRun]); TGridResult *res = alien->Command(Form("find %s */mpuccio_Flowd.root",runDir.Data())); TIter iter(res); TMap *map; while ((map = (TMap*)iter())) { TObjString *obj = dynamic_cast<TObjString*>(map->GetValue("turl")); if (!obj || !obj->String().Length()) { delete res; break; } TFile *f = TFile::Open(obj->String().Data()); if (!f->IsOpen()) { cout << "File " << obj->String().Data() << " has some problems..." << endl; continue; } merger.AddFile(f); merger.PartialMerge(); f->Close(); } } merger.Merge(); merger.Write(); }
TDirection TAntNeuralAI::Evaluate(TGrid status,uint randomseed) { if (!load_ok) return DIR_NORTH; // error std::vector<float> input; uint height = status.GetHeight(); uint width = status.GetWidth(); for (uint h = 0; h < height; h++) for (uint w = 0; w < width; w++) input.push_back(status[h][w]); std::vector<float> output = net.Evaluate(input); if (output.size() != MAX_DIR) return DIR_NORTH; // error!! // find max uint maxi = 0; for (uint i = 1; i < MAX_DIR; i++) if (output[maxi] < output[i]) maxi = i; float tot = 0.0; std::vector<float> diff(4,0.0); for (uint i = 0; i < MAX_DIR; i++) if (output[maxi] - output[i] < SIMILARITY_LIMIT) { diff[i] = SIMILARITY_LIMIT - (output[maxi] - output[i]); tot += diff[i]; } std::vector<float> prob(4,0.0); for (uint i = 0; i < MAX_DIR; i++) prob[i] = diff[i] / tot; float random = float(randomseed % 100) / 99.0; for (uint i = 0; i < MAX_DIR; i++) { if (prob[i] >= random) return TDirection(i); random -= prob[i]; } return TDirection(maxi); }
void eval_radial_function(const TGrid &grid_2d, Value_type<TGrid> x, Value_type<TGrid> y, TVector &V) { using X = Value_type<TGrid>; X r_max = x_max(); X fr_max = (*this)(r_max); for(auto ix = 0; ix < grid_2d.nx; ix++) { for(auto iy = 0; iy < grid_2d.ny; iy++) { X r = grid_2d.R2(ix, iy, x, y); int ixy = grid_2d.ind_col(ix, iy); V[ixy] = (r < r_max)?(*this)(r):fr_max; } } }
void alien() { TString testdir = "root-test3"; int nfiles = 10; // connect to AliEn TGrid *alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "", "-domain=cern.ch"); if (alien->IsZombie()) { delete alien; return; } // get info on AliEn version printf("Using AliEn version %s\n", alien->GetInfo()); // print current working directory printf("Current directory is %s\n", alien->Pwd()); // check if directory exists Long_t size, flags, modtime; if (alien->GetPathInfo(testdir, &size, &flags, &modtime) == 0) { // delete existing directory alien->Rmdir(testdir); } // create a directory alien->Mkdir(testdir); // change directory alien->Cd(testdir); printf("Current directory is %s\n", alien->Pwd()); // insert nfiles into the catalog Int_t i; char lfn[32], pfn[256]; for (i = 0; i < nfiles; i++) { sprintf(lfn, "test-%d.root", i); sprintf(pfn, "rfio:/castor/cern.ch/user/r/rdm/mytest-%d.root", i); alien->AddFile(lfn, pfn, 1000000000); } // list the contents of a directory alien->ls("", "l"); // get physical file name from lfn for (i = 0; i < nfiles; i++) { sprintf(lfn, "test-%d.root", i); char *pf = alien->GetPhysicalFileName(lfn); if (i == nfiles-1) printf("last pfn retrieved is: %s\n", pf); delete [] pf; } delete alien; }