void GenerateMergeConfigs(){ // // Generate configurations for merging // (MergeViaJDL and Terminate) // // Write config for MergeViaJDL std::ofstream outMerge("configMerge.txt"); outMerge << "aliroot " << g_aliroot_version.Data() << std::endl; outMerge << "root " << g_root_version.Data() << std::endl; outMerge << "sample " << g_sample.Data() << std::endl; outMerge << "mode MergeViaJDL\n"; outMerge << "traindir " << g_train_dir.Data() << std::endl; outMerge << "runlist "; for(int irun = 0; irun < g_runlist.GetSize()-1; irun++) outMerge << g_runlist[irun] << ","; outMerge << g_runlist[g_runlist.GetSize()-1] << std::endl; outMerge.close(); // Write config for Terminate std::ofstream outTerminate("configTerminate.txt"); outTerminate << "aliroot " << g_aliroot_version.Data() << std::endl; outTerminate << "root " << g_root_version.Data() << std::endl; outTerminate << "sample " << g_sample.Data() << std::endl; outTerminate << "mode Terminate\n"; outTerminate << "traindir " << g_train_dir.Data() << std::endl; outTerminate << "runlist "; for(int irun = 0; irun < g_runlist.GetSize()-1; irun++) outTerminate << g_runlist[irun] << ","; outTerminate << g_runlist[g_runlist.GetSize()-1] << std::endl; outTerminate.close(); printf("Configurations for MergeViaJDL and terminate generated\n"); }
bool testReading(TArrayI &arr, TString &json) { TArrayI *arr2 = nullptr; TBufferJSON::FromJSON(arr2, json); if (!arr2) { cout << "Fail to read array from JSON" << endl; return false; } if (arr2->GetSize() != arr.GetSize()) { cout << "Array sizes mismatch " << arr.GetSize() << " != " << arr2->GetSize() << endl; delete arr2; return false; } for (int n=0;n<arr.GetSize();++n) if (arr.At(n) != arr2->At(n)) { cout << "Array content mismatch indx=" << n << " " << arr.At(n) << " != " << arr2->At(n) << endl; delete arr2; return false; } delete arr2; return true; }
/// \brief Cache MC production trees, store summary information in formated text files -> root trees /// \param dataType - /// \param fileList void CacheTestMCProductions(TString dataType, const char *fileList=NULL){ AliExternalInfo info; info.fLoadMetadata=kFALSE; TObjArray* periodList = NULL; TArrayI nRuns; if (fileList!=NULL) { periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n"); nRuns.Set(periodList->GetEntries()); }else{ TTree * tree = info.GetTree("MonALISA.ProductionMC","",""); Int_t nProd=tree->GetEntries(); periodList = new TObjArray(nProd); nRuns.Set(nProd); TLeaf *leaf = tree->GetLeaf("Tag"); TLeaf *leafRuns = tree->GetLeaf("Number_of_runs"); for (Int_t iProd=0; iProd<nProd; iProd++){ tree->GetEntry(iProd); TString prodName=((char*)leaf->GetValuePointer()); if (prodName.Contains("LHC")==0) continue; periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd); nRuns[iProd]=leafRuns->GetValue(); } delete tree; } for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){ TObjString * pName= (TObjString*)periodList->At(iPeriod); if (pName==NULL) continue; TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC"); if (tree){ Int_t entries=tree->Draw("run","1","goff"); TString sInfo=periodList->At(iPeriod)->GetName(); sInfo+="\t"; sInfo+=dataType; sInfo+="\t"; sInfo+=TString::Format("%d\t",entries); sInfo+=TString::Format("%d\t",nRuns[iPeriod]); for (Int_t j=0; j<entries; j++) { sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]); ::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]); } sInfo+="0"; ::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data()); delete tree; }else{ ::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]); } } }
//___________________________________________________________________________________________ TArrayI* KVIntegerList::CreateTArrayI() { //Cree un objet TArrayI de dimension fMult ( KVIntegerList::GetNbre() ) et rempli par ordre decroissant toutes les valeurs de la partition //L'objet cree doit etre effacé après utilisation par l'utilisateur TArrayI* tab = new TArrayI(GetNbre()); Int_t mm = 0; for (Int_t ii = fLimiteRegle; ii >= 0; ii -= 1) { Int_t contenu = fRegle->At(ii); for (Int_t cc = 0; cc < contenu; cc += 1) tab->AddAt(ii, mm++); } return tab; }
//___________________________________________________________ void DecodeDataString(const TString &datastring, TString &sample, TArrayI &listofruns){ TObjArray *toks = datastring.Tokenize(":"); sample = (dynamic_cast<TObjString *>(toks->At(0)))->String(); TString &listrunstring = (dynamic_cast<TObjString *>(toks->At(1)))->String(); TObjArray *runstrings = listrunstring.Tokenize(","); TIter runiter(runstrings); listofruns.Set(runstrings->GetEntriesFast()); TObjString *myrunstring = NULL; Int_t counter = 0; while((myrunstring = dynamic_cast<TObjString *>(runiter()))) listofruns[counter++] = myrunstring->String().Atoi(); // Print summary: printf("Selected sample: %s\n", sample.Data()); printf("========================================\n"); for(Int_t irun = 0; irun < listofruns.GetSize(); irun++){ printf("\trun %d\n", listofruns[irun]); } printf("\n"); delete toks; delete runstrings; }
void GetFinalDecayProducts(Int_t ind, IlcStack & stack , TArrayI & ar){ // Recursive algorithm to get the final decay products of a particle // // ind is the index of the particle in the IlcStack // stack is the particle stack from the generator // ar contains the indexes of the final decay products // ar[0] is the number of final decay products if (ind<0 || ind>stack.GetNtrack()) { cerr << "Invalid index of the particle " << ind << endl; return; } if (ar.GetSize()==0) { ar.Set(10); ar[0] = 0; } TParticle * part = stack.Particle(ind); Int_t iFirstDaughter = part->GetFirstDaughter(); if( iFirstDaughter<0) { // This particle is a final decay product, add its index to the array ar[0]++; if (ar.GetSize() <= ar[0]) ar.Set(ar.GetSize()+10); // resize if needed ar[ar[0]] = ind; return; } Int_t iLastDaughter = part->GetLastDaughter(); for (Int_t id=iFirstDaughter; id<=iLastDaughter;id++) { // Now search for final decay products of the daughters GetFinalDecayProducts(id,stack,ar); } }
void DecodeRunlist(const TString &val){ // // Tokenize run list // TObjArray *runstrings = val.Tokenize(","); TObjString *os; TString runstr; TIter runIter(runstrings); g_runlist.Set(runstrings->GetEntries()); int nruns(0); while((os = dynamic_cast<TObjString *>(runIter()))){ runstr = os->String(); g_runlist[nruns++] = runstr.Atoi(); } delete runstrings; }
Bool_t TZigZag::NearestPoints(Double_t x, TArrayI &I, TArrayD &W) const { // One-dimensional case. Gives the 2 nearest points from point x in zigzag numbering. //W are weights for the points, calculated according to the inverse of their distances //from x const Double_t un = 1.0; const Double_t eps = 1.0e-12; Int_t k; Double_t xl,xr,x1,x2,dx,dxs2,w0,w1,wt; I.Set(2); W.Set(2); dx = (fXmax-fXmin)/fNx; dxs2 = dx/2; xl = dxs2; xr = dxs2 + (fNx-1)*dx; if (x<xl) { I[0] = 0; I[1] = 1; x1 = dxs2; x2 = dxs2 + dx; } else { if (x>xr) { I[0] = fNx - 1; I[1] = fNx - 2; x1 = dxs2 + (fNx-1)*dx; x2 = x1 - dx; } else { k = Int_t((x-dxs2)/dx); I[0] = k; I[1] = k+1; x1 = dxs2 + k*dx; x2 = x1 + dx; } } w0 = TMath::Abs(x1-x); if (w0<eps) w0 = eps; w0 = un/w0; w1 = TMath::Abs(x2-x); if (w1<eps) w1 = eps; w1 = un/w1; wt = w0 + w1; W[0] = w0/wt; W[1] = w1/wt; return kTRUE; }
//___________________________________________________________ void AddInput(AliAnalysisAlien *alienhandler, TString sample, TArrayI &listofruns, Bool_t MC){ Int_t year = GetYear(sample); TString specialpattern, datapattern; if(!MC){ // handle Data datapattern = "ESDs/pass2/*ESDs.root"; specialpattern = Form("data/%d", year); //alienhandler->SetRunPrefix("%09d"); } else { // handle MC datapattern = "*ESDs.root"; specialpattern = "sim"; } alienhandler->SetGridDataDir(Form("/alice/%s/%s", specialpattern.Data(), sample.Data())); alienhandler->SetDataPattern(datapattern.Data()); for(Int_t ien = 0; ien < listofruns.GetSize(); ien++){ if(!MC) alienhandler->AddRunNumber(Form("%09d", listofruns[ien])); else alienhandler->AddRunNumber(listofruns[ien]); } alienhandler->SetGridOutputDir(sample.Data()); alienhandler->SetOutputToRunNo(); }
bool MakeSample(AliAnalysisAlien *plugin, TMap &lookup){ // // Fill Sample information (Data dir, pattern, run list) to the Alien plugin // TObjArray infos; bool found = FindDataSample(lookup, infos); if(!found){ printf("sample %s not found\n", g_sample.Data()); return false; } TString datadir, pattern, type; GetData(infos, datadir, 0); GetData(infos, pattern, 1); GetData(infos, type, 2); plugin->SetGridDataDir(datadir.Data()); plugin->SetDataPattern(pattern.Data()); if(!IsMC(type)) plugin->SetRunPrefix("000"); // Add runs to the sample for(int irun = 0; irun < g_runlist.GetSize(); irun++){ plugin->AddRunNumber(g_runlist[irun]); } return true; }
Bool_t TZigZag::NearestPoints(Double_t x, Double_t y, Double_t z, TArrayI &I, TArrayD &W) const { // 3-dimensional case. Gives the 8 nearest points from point x in zigzag numbering. //W are weights for the points, calculated according to the inverse of their distances //from x. If point (x,y) not inside [fXmin,fXmax],[fYmin,fYmax],[fZmin,fZmax], make a //projection towards center and stops at point just after entry and gives the 8 points //for it. const Double_t un = 1.0; const Double_t aeps = 1.0e-6; Bool_t ok; Int_t i; Int_t kx=0; Int_t ky=0; Int_t kz=0; Double_t mx,my,mz,eps; Double_t xc,xl,xr,dx,dxs2; Double_t yc,yl,yr,dy,dys2; Double_t zc,zl,zr,dz,dzs2; Double_t xi,yi,zi,ti,xp,yp,zp; Double_t xle,xre,yle,yre,zle,zre; Double_t w0,w1,w2,w3,w4,w5,w6,w7,wt; I.Set(8); W.Set(8); for (i=0;i<8;i++) { I[i] = -1; W[i] = -un; } dx = (fXmax-fXmin)/fNx; dxs2 = dx/2; dy = (fYmax-fYmin)/fNy; dys2 = dy/2; dz = (fZmax-fZmin)/fNy; dzs2 = dz/2; xl = dxs2; xr = dxs2 + (fNx-1)*dx; yl = dys2; yr = dys2 + (fNy-1)*dy; zl = dzs2; zr = dzs2 + (fNz-1)*dz; w0 = xr - xl; w1 = yr - yl; w2 = zr - zl; w0 = TMath::Max(w0,w1); w0 = TMath::Max(w0,w2); eps = aeps*w0; if ((x>=xl) && (x<=xr) && (y>=yl) && (y<=yr) && (z>=zl) && (z<=zr)) { xi = x; yi = y; zi = z; kx = Int_t((xi-dxs2)/dx) + 1; ky = Int_t((yi-dys2)/dy) + 1; kz = Int_t((zi-dzs2)/dz) + 1; ok = kTRUE; }//end if ((x>xl) && (x<xr) && (y>yl) && (y<yr) && (z>zl) && (z<zr)) else { xc = (fXmax-fXmin)/2; yc = (fYmax-fYmin)/2; zc = (fZmax-fZmin)/2; xle = xl + eps; xre = xr - eps; yle = yl + eps; yre = yr - eps; zle = zl + eps; zre = zr - eps; mx = x - xc; my = y - yc; mz = z - zc; //intercept with xle xi = xle; ti = (xi-xc)/mx; yi = yc + my*ti; zi = zc + mz*ti; ok = IsInside(xi,yi,zi,x,y,z,xc,yc,zc,xl,xr,yl,yr,zl,zr); if (!ok) { //intercept with xre xi = xre; ti = (xi-xc)/mx; yi = yc + my*ti; zi = zc + mz*ti; ok = IsInside(xi,yi,zi,x,y,z,xc,yc,zc,xl,xr,yl,yr,zl,zr); if (!ok) { //intercept with yle yi = yle; ti = (yi-yc)/my; xi = xc + mx*ti; zi = zc + mz*ti; ok = IsInside(xi,yi,zi,x,y,z,xc,yc,zc,xl,xr,yl,yr,zl,zr); if (!ok) { //intercept with yre yi = yre; ti = (yi-yc)/my; xi = xc + mx*ti; zi = zc + mz*ti; ok = IsInside(xi,yi,zi,x,y,z,xc,yc,zc,xl,xr,yl,yr,zl,zr); if (!ok) { //intercept with zle zi = zle; ti = (zi-zc)/mz; xi = xc + mx*ti; yi = yc + my*ti; ok = IsInside(xi,yi,zi,x,y,z,xc,yc,zc,xl,xr,yl,yr,zl,zr); if (!ok) { //intercept with zre zi = zre; ti = (zi-zc)/mz; xi = xc + mx*ti; yi = yc + my*ti; ok = IsInside(xi,yi,zi,x,y,z,xc,yc,zc,xl,xr,yl,yr,zl,zr); }//end if (!ok) intercept with zre }//end if (!ok) intercept with zle }//end if (!ok) intercept with yre }//end if (!ok) intercept with yle }//end if (!ok) intercept with xre if (ok) { kx = Int_t((xi-dxs2)/dx) + 1; ky = Int_t((yi-dys2)/dy) + 1; kz = Int_t((zi-dzs2)/dz) + 1; } else { cout << "TZigZag::NearestPoints : ERROR point inside not found" << endl; } }//end else if ((x>xl) && (x<xr) && (y>yl) && (y<yr) && (z>zl) && (z<zr)) if (ok) { Double_t fx,fy,fz; //Point kx,ky,kz xp = dxs2 + (kx-1)*dx; yp = dys2 + (ky-1)*dy; zp = dzs2 + (kz-1)*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx,ky,kz); I[0] = i; w0 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w0 = un/w0; //Point kx+1,ky,kz xp = dxs2 + kx*dx; yp = dys2 + (ky-1)*dy; zp = dzs2 + (kz-1)*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx+1,ky,kz); I[1] = i; w1 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w1 = un/w1; //Point kx,ky+1,kz xp = dxs2 + (kx-1)*dx; yp = dys2 + ky*dy; zp = dzs2 + (kz-1)*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx,ky+1,kz); I[2] = i; w2 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w2 = un/w2; //Point kx+1,ky+1,kz xp = dxs2 + kx*dx; yp = dys2 + ky*dy; zp = dzs2 + (kz-1)*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx+1,ky+1,kz); I[3] = i; w3 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w3 = un/w3; //Point kx,ky,kz+1 xp = dxs2 + (kx-1)*dx; yp = dys2 + (ky-1)*dy; zp = dzs2 + kz*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx,ky,kz+1); I[4] = i; w4 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w4 = un/w4; //Point kx+1,ky,kz+1 xp = dxs2 + kx*dx; yp = dys2 + (ky-1)*dy; zp = dzs2 + kz*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx+1,ky,kz+1); I[5] = i; w5 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w5 = un/w5; //Point kx,ky+1,kz+1 xp = dxs2 + (kx-1)*dx; yp = dys2 + ky*dy; zp = dzs2 + kz*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx,ky+1,kz+1); I[6] = i; w6 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w6 = un/w6; //Point kx+1,ky+1,kz+1 xp = dxs2 + kx*dx; yp = dys2 + ky*dy; zp = dzs2 + kz*dz; fx = x - xp; fy = y - yp; fz = z - zp; i = NToZZ(kx+1,ky+1,kz+1); I[7] = i; w7 = TMath::Sqrt(fx*fx + fy*fy + fz*fz) + eps; w7 = un/w7; // wt = w0 + w1 + w2 + w3 + w4 + w5 + w6 + w7; W[0] = w0/wt; W[1] = w1/wt; W[2] = w2/wt; W[3] = w3/wt; W[4] = w4/wt; W[5] = w5/wt; W[6] = w6/wt; W[7] = w7/wt; } return ok; }