char *ucc_where(void) { static char where[1024]; if(!where[0]){ char link[1024]; ssize_t nb; if((nb = readlink(argv0, link, sizeof link)) == -1){ snprintf(where, sizeof where, "%s", argv0); }else{ char *argv_dup; link[nb] = '\0'; /* need to tag argv0's dirname onto the start */ argv_dup = ustrdup(argv0); bname(argv_dup); snprintf(where, sizeof where, "%s/%s", argv_dup, link); free(argv_dup); } /* dirname */ bname(where); } return where; }
KernelSet Kernels::findKernels(const std::string &kname, KernelSet::KernelType ktype, Pvl &pvl, const std::string &blobname) const { // Get the kernel group and load main kernels PvlGroup &kernels = pvl.FindGroup("Kernels",Pvl::Traverse); KernelSet kkey(PvlKeyword(kname), ktype); // Check for the keyword if (kernels.HasKeyword(kname)) { kkey = KernelSet(kernels[kname], ktype); // Check for keyword design < 3.1.19 and update it to current state if (kkey.inTable() && (kkey.size() == 0)) { string bname(blobname); if (bname.empty()) bname = kname; const PvlObject &blob = findTable(bname, pvl); if (blob.HasKeyword("Kernels")) { PvlKeyword bkey = blob["Kernels"]; PvlKeyword newkey = kernels[kname]; // Found the Kernels keyword in BLOB. Get the filenames for (int i = 0 ; i < bkey.Size() ; i++) { newkey.AddValue(bkey[i]); } kkey = KernelSet(newkey, ktype); } else { kkey.Missing("Image has been jigsawed and/or kernels are gone"); } } } return (kkey); }
PetscErrorCode DMLibMeshCreateDomainDecompositionDM(DM dm, PetscInt dnumber, PetscInt* dsizes, char*** dblocklists, DM* ddm) { PetscErrorCode ierr; PetscBool islibmesh; PetscFunctionBegin; PetscValidHeaderSpecific(dm,DM_CLASSID,1); ierr = PetscObjectTypeCompare((PetscObject)dm, DMLIBMESH,&islibmesh); if(!islibmesh) SETERRQ2(((PetscObject)dm)->comm, PETSC_ERR_ARG_WRONG, "Got DM oftype %s, not of type %s", ((PetscObject)dm)->type_name, DMLIBMESH); if(dnumber < 0) SETERRQ1(((PetscObject)dm)->comm, PETSC_ERR_ARG_WRONG, "Negative number %D of decomposition parts", dnumber); PetscValidPointer(ddm,5); DM_libMesh *dlm = (DM_libMesh *)(dm->data); ierr = DMCreate(((PetscObject)dm)->comm, ddm); CHKERRQ(ierr); ierr = DMSetType(*ddm, DMLIBMESH); CHKERRQ(ierr); DM_libMesh *ddlm = (DM_libMesh *)((*ddm)->data); ddlm->sys = dlm->sys; ddlm->varids = dlm->varids; ddlm->varnames = dlm->varnames; ddlm->blockids = dlm->blockids; ddlm->blocknames = dlm->blocknames; ddlm->decomposition = new(std::vector<std::set<unsigned int> >); ddlm->decomposition_type = DMLIBMESH_DOMAIN_DECOMPOSITION; if(dnumber) { for(PetscInt d = 0; d < dnumber; ++d) { if(dsizes[d] < 0) SETERRQ2(((PetscObject)dm)->comm, PETSC_ERR_ARG_WRONG, "Negative size %D of decomposition part %D", dsizes[d],d); ddlm->decomposition->push_back(std::set<unsigned int>()); for(PetscInt b = 0; b < dsizes[d]; ++b) { std::string bname(dblocklists[d][b]); std::map<std::string, unsigned int>::const_iterator bit = dlm->blockids->find(bname); if(bit == dlm->blockids->end()) SETERRQ3(((PetscObject)dm)->comm, PETSC_ERR_ARG_WRONG, "Block %D on the %D-th list with name %s is not owned by this DM", b, d, dblocklists[d][b]); unsigned int bid = bit->second; (*ddlm->decomposition)[d].insert(bid); } } } else { /* Empty splits indicate default: split all blocks with one per split. */ PetscInt d = 0; for(std::map<std::string, unsigned int>::const_iterator bit = ddlm->blockids->begin(); bit != ddlm->blockids->end(); ++bit) { ddlm->decomposition->push_back(std::set<unsigned int>()); unsigned int bid = bit->second; std::string bname = bit->first; (*ddlm->decomposition)[d].insert(bid); ++d; } } ierr = DMLibMeshSetUpName_Private(*ddm); CHKERRQ(ierr); ierr = DMSetFromOptions(*ddm); CHKERRQ(ierr); ierr = DMSetUp(*ddm); CHKERRQ(ierr); PetscFunctionReturn(0); }
void read_mRNAs(FILE* f, GList<GSeqData>& seqdata, GList<GSeqData>* ref_data, int check_for_dups, int qfidx, const char* fname, bool only_multiexon) { //>>>>> read all transcripts/features from a GTF/GFF3 file //int imrna_counter=0; #ifdef HEAPROFILE if (IsHeapProfilerRunning()) HeapProfilerDump("00"); #endif int loci_counter=0; if (ref_data==NULL) ref_data=&seqdata; bool isRefData=(&seqdata==ref_data); //(f, transcripts_only) GffReader* gffr=new GffReader(f, true); //load only transcript annotations gffr->showWarnings(gtf_tracking_verbose); // keepAttrs mergeCloseExons noExonAttrs gffr->readAll(!isRefData, true, isRefData || gtf_tracking_largeScale); //so it will read exon attributes only for low number of Cufflinks files #ifdef HEAPROFILE if (IsHeapProfilerRunning()) HeapProfilerDump("post_readAll"); #endif int d=parse_mRNAs(gffr->gflst, seqdata, isRefData, check_for_dups, qfidx,only_multiexon); #ifdef HEAPROFILE if (IsHeapProfilerRunning()) HeapProfilerDump("post_parse_mRNAs"); #endif if (gtf_tracking_verbose && d>0) { if (isRefData) GMessage(" %d duplicate reference transcripts discarded.\n",d); else GMessage(" %d redundant query transfrags discarded.\n",d); } //imrna_counter=gffr->mrnas.Count(); delete gffr; //free the extra memory and unused GffObjs #ifdef HEAPROFILE if (IsHeapProfilerRunning()) HeapProfilerDump("post_del_gffr"); #endif //for each genomic sequence, cluster transcripts int oriented_by_overlap=0; int initial_unoriented=0; int final_unoriented=0; GStr bname(fname); GStr s; if (!bname.is_empty()) { int di=bname.rindex('.'); if (di>0) bname.cut(di); int p=bname.rindex('/'); if (p<0) p=bname.rindex('\\'); if (p>=0) bname.remove(0,p); } FILE* fdis=NULL; FILE* frloci=NULL; for (int g=0;g<seqdata.Count();g++) { //find the corresponding refseqdata with the same gseq_id int gseq_id=seqdata[g]->get_gseqid(); if (!isRefData) { //query data, find corresponding ref data GSeqData* rdata=getRefData(gseq_id, *ref_data); initial_unoriented+=seqdata[g]->umrnas.Count(); if (seqdata[g]->umrnas.Count()>0) { oriented_by_overlap+=fix_umrnas(*seqdata[g], rdata, fdis); final_unoriented+=seqdata[g]->umrnas.Count(); } } //>>>>> group mRNAs into locus-clusters (based on exon overlap) cluster_mRNAs(seqdata[g]->mrnas_f, seqdata[g]->loci_f, qfidx); cluster_mRNAs(seqdata[g]->mrnas_r, seqdata[g]->loci_r, qfidx); if (!isRefData) { cluster_mRNAs(seqdata[g]->umrnas, seqdata[g]->nloci_u, qfidx); } loci_counter+=seqdata[g]->loci_f.Count(); loci_counter+=seqdata[g]->loci_r.Count(); // if (refData) { // if (frloci==NULL) { // s=bname; // s.append(".loci.lst"); // frloci=fopen(s.chars(), "w"); // } // writeLoci(frloci, seqdata[g]->loci_f); // writeLoci(frloci, seqdata[g]->loci_r); // }//write ref loci }//for each genomic sequence if (fdis!=NULL) fclose(fdis); if (frloci!=NULL) fclose(frloci); if (initial_unoriented || final_unoriented) { if (gtf_tracking_verbose) GMessage(" Found %d transfrags with undetermined strand (%d out of initial %d were fixed by overlaps)\n", final_unoriented, oriented_by_overlap, initial_unoriented); } //if (fdis!=NULL) remove(s.chars()); remove 0-length file #ifdef HEAPROFILE if (IsHeapProfilerRunning()) HeapProfilerDump("post_cluster"); #endif }
/* * * * * * * * * * * This routine tries to link the map to the proper seadif * cell. If the seadif cell which corresponds to the nelsis * cell exists, the routine will return 'written', * otherwise it will return 'not_written' * This can be set in map->nelseastatus */ static void link_map_to_sdf_cell(MAPTABLEPTR map) { IMPCELL ** imp_p; struct stat buf; char *fp, *hn, *rem_path, hostname[100], filepath[512]; #ifdef NELSIS_REL4 DM_PROJECT *remote_projectkey; DM_CELL *cell_key; char *remote_cellname; #endif imp_p = NULL; /* * can only return something if nelsis is open */ if(Nelsis_open == FALSE) return; /* * first we have to find out what the proper library name of the cell * is..... */ /* * is the nelsis cell local?? */ #ifdef NELSIS_REL4 if(exist_cell(map->cell, map->view) == LOCAL) #else /* rel3 */ if((int) dmGetMetaDesignData(EXISTCELL, projectkey, map->cell, map->view) == TRUE) #endif { /* easy: nelsis cell is local.... */ /* therefore it must be in the local seadif library (this_sdf_lib) */ map->library = this_sdf_lib; /* path to find nelsis time */ if(map->view == circuit_str) sprintf(filepath,"circuit/%s/net", map->cell); else sprintf(filepath,"layout/%s/box", map->cell); } else { /* this is harder: nelsis cell is remote... */ /* * look in list of remote cells.. */ #ifdef NELSIS_REL4 if((imp_p = projectkey->impcelllist[_dmValidView(projectkey, map->view)]) == NULL) #else if((imp_p = projectkey->impcelllist[_dmValidView(map->view)]) == NULL) #endif { /* get the pointer */ if((imp_p = (IMPCELL **) dmGetMetaDesignData(IMPORTEDCELLLIST, projectkey, map->view)) == NULL) error(FATAL_ERROR, "link_map_to_sdf_cell"); } for(; imp_p && *imp_p; imp_p++) if(strcmp(map->cell, (*imp_p)->alias) == 0) break; if(imp_p == NULL || *imp_p == NULL) return; /* nelsis cell does not exist (default) */ /* * else: it exists: get nelsis time */ if(map->view == circuit_str) sprintf(filepath,"%s/circuit/%s/net", (*imp_p)->dmpath, (*imp_p)->cellname); else sprintf(filepath,"%s/layout/%s/box", (*imp_p)->dmpath, (*imp_p)->cellname); } /* * get time (both local as well as remote...) */ #ifndef NELSIS_REL4 /* release 3 */ if(access(filepath, F_OK) != 0) { fprintf(stderr,"WARNING: access failed on '%s'\n", filepath); return; } if(stat(filepath, &buf) != 0) { fprintf(stderr,"WARNING: cannot stat file '%s'\n", filepath); return; } #else /* NELSIS REL 4 */ /* * that's not so easy.. */ /* * open the cell: key for project */ if((remote_projectkey = dmFindProjKey(imp_p == NULL ? LOCAL : IMPORTED, map->cell, projectkey, &remote_cellname, map->view)) == NULL) { /* ? */ fprintf(stderr,"ERROR: cannot find nasty project key\n"); return; } /* * open it */ if((cell_key = dmCheckOut (remote_projectkey, remote_cellname, ACTUAL, DONTCARE, map->view, READONLY)) == NULL) { /* ? */ fprintf(stderr,"ERROR: cannot open cell '%s' for stat\n", map->cell); return; } /* * stat it.. */ if(dmStat(cell_key, map->view == layout_str ? "box" : "net", &buf) != 0) { fprintf(stderr,"ERROR: Cannot dmStat cell '%s' for stat\n", map->cell); return; } /* * and close it again... */ dmCheckIn(cell_key, COMPLETE); #endif /* store time */ map->nelsis_time = buf.st_mtime; /* * the rest only works if seadif is open... */ if(Seadif_open == FALSE) return; /* * find proper seadif lib and name of remote cell.... */ if(imp_p != NULL) { /* if remote... */ /* * the string (*imp_p)->cellname contains the real cell name and * (*imp_p)->dmpath the path to the directory.... */ /* first the easy part: the proper seadif name of the cell ... */ map->function = map->circuit = cs( (*imp_p)->cellname); if(map->view == layout_str) map->layout = map->circuit; /* * now find the library name of the cell * (*imp_p)->dmpath is the local path of the library, but * the alias of the library will be its remote path in the * form: 'hostname:dir'. Therefore: convert it */ strcpy(filepath, (*imp_p)->dmpath); strcpy(hostname, ""); fp = &filepath[0]; hn = &hostname[0]; if((rem_path = LocToRemPath ( &hn, &fp)) == NULL) { fprintf(stderr,"WARNING: cannot get remote path of project '%s'\n", (*imp_p)->dmpath); rem_path = cs((*imp_p)->dmpath); } else { sprintf(filepath,"%s:%s", hn, rem_path); rem_path = cs(filepath); } if(sdfaliastoseadif(rem_path, ALIASLIB) == NIL) { /* not found: try to take basename of path... */ map->library = bname((*imp_p)->dmpath); map->library = cs(map->library); if(existslib(map->library) == FALSE) { map->library = cs(default_sdf_lib); fprintf(stderr,"WARNING: Cannot find sdf library (alias) of project '%s'.\n", (*imp_p)->dmpath); fprintf(stderr," for imported cell '%s. Tried '%s', but failed.\n", map->cell, rem_path); fprintf(stderr," Trying lib '%s', hope that's OK....\n", map->library); if(existslib(map->library) == FALSE) { fprintf(stderr," NO, it is not OK. Oh boy, what to do now??\n"); return; } } } else { /* everything OK */ map->library = thislibnam; } /* * can we access the sdf cell? * if so, set nelseastatus accordingly... */ if((map->view == circuit_str && existscir(map->circuit, map->function, map->library) == TRUE) || (map->view == layout_str && existslay(map->layout, map->circuit, map->function, map->library) == TRUE)) { map->seadif_time = 1; /* >0 marks that it exists.... */ } else { fprintf(stderr,"WARNING: Cannot access corresponding seadif cell of\n"); fprintf(stderr," imported %s-cell '%s'.\n", map->view, map->circuit); fprintf(stderr," That is: %s(%s(%s(%s))) doesn't exists\n", map->layout, map->circuit, map->function, map->library); return; } } /* * get seadif time (same for both imported as local)... */ if(map->view == circuit_str) { if(existscir(map->circuit, map->function, map->library) == TRUE) { if(sdfreadcir(SDFCIRSTAT, map->circuit, map->function, map->library) != TRUE) { fprintf(stderr,"WARNING: Cannot read sdf cirstatus of '%s'\n", map->circuit); fprintf(stderr," That is: %s(%s(%s)) doesn't have a stat\n", map->circuit, map->function, map->library); } else { map->seadif_time = thiscir->status->timestamp; map->circuitstruct = thiscir; } } } else { if(existslay(map->layout, map->circuit, map->function, map->library) == TRUE) { if(sdfreadlay(SDFLAYSTAT, map->layout, map->circuit, map->function, map->library) != TRUE) { fprintf(stderr,"WARNING: Cannot read sdf laystatus of '%s'\n", map->layout); fprintf(stderr," That is: (%s(%s(%s)))%s doesn't have a stat\n", map->layout, map->circuit, map->function, map->library); } else { map->seadif_time = thislay->status->timestamp; map->layoutstruct = thislay; } } } }
HRESULT PCIDeviceAttachment::i_loadSettings(IMachine *aParent, const settings::HostPCIDeviceAttachment &hpda) { Bstr bname(hpda.strDeviceName); return init(aParent, bname, hpda.uHostAddress, hpda.uGuestAddress, TRUE); }
void likelihoodrefs( TDirectory *lhdir ) { Bool_t newCanvas = kTRUE; const UInt_t maxCanvas = 200; TCanvas** c = new TCanvas*[maxCanvas]; Int_t width = 670; Int_t height = 380; // avoid duplicated printing std::vector<std::string> hasBeenUsed; const TString titName = lhdir->GetName(); UInt_t ic = -1; TIter next(lhdir->GetListOfKeys()); TKey *key; while ((key = TMVAGlob::NextKey(next,"TH1"))) { // loop over all TH1 TH1 *h = (TH1*)key->ReadObj(); TH1F *b( 0 ); TString hname( h->GetName() ); // avoid duplicated plotting Bool_t found = kFALSE; for (UInt_t j = 0; j < hasBeenUsed.size(); j++) { if (hasBeenUsed[j] == hname.Data()) found = kTRUE; } if (!found) { // draw original plots if (hname.EndsWith("_sig_nice")) { if (newCanvas) { char cn[20]; sprintf( cn, "cv%d_%s", ic+1, titName.Data() ); ++ic; TString n = hname; c[ic] = new TCanvas( cn, Form( "%s reference for variable: %s", titName.Data(),(n.ReplaceAll("_sig","")).Data() ), ic*50+50, ic*20, width, height ); c[ic]->Divide(2,1); newCanvas = kFALSE; } // signal Int_t color = 4; TPad * cPad = (TPad*)c[ic]->cd(1); TString plotname = hname; h->SetMaximum(h->GetMaximum()*1.3); h->SetMinimum( 0 ); h->SetMarkerColor(color); h->SetMarkerSize( 0.7 ); h->SetMarkerStyle( 24 ); h->SetLineWidth(1); h->SetLineColor(color); color++; h->Draw("e1"); Double_t hSscale = 1.0/(h->GetSumOfWeights()*h->GetBinWidth(1)); TLegend *legS= new TLegend( cPad->GetLeftMargin(), 1-cPad->GetTopMargin()-.14, cPad->GetLeftMargin()+.77, 1-cPad->GetTopMargin() ); legS->SetBorderSize(1); legS->AddEntry(h,"Input data (signal)","p"); // background TString bname( hname ); b = (TH1F*)lhdir->Get( bname.ReplaceAll("_sig","_bgd") ); cPad = (TPad*)c[ic]->cd(2); color = 2; b->SetMaximum(b->GetMaximum()*1.3); b->SetMinimum( 0 ); b->SetLineWidth(1); b->SetLineColor(color); b->SetMarkerColor(color); b->SetMarkerSize( 0.7 ); b->SetMarkerStyle( 24 ); b->Draw("e1"); Double_t hBscale = 1.0/(b->GetSumOfWeights()*b->GetBinWidth(1)); TLegend *legB= new TLegend( cPad->GetLeftMargin(), 1-cPad->GetTopMargin()-.14, cPad->GetLeftMargin()+.77, 1-cPad->GetTopMargin() ); legB->SetBorderSize(1); legB->AddEntry(b,"Input data (backgr.)","p"); // register hasBeenUsed.push_back( bname.Data() ); // the PDFs -------------- // check for splines h = 0; b = 0; TString pname = hname; pname.ReplaceAll("_nice",""); for (int i=0; i<= 5; i++) { TString hspline = pname + Form( "_smoothed_hist_from_spline%i", i ); h = (TH1F*)lhdir->Get( hspline ); if (h) { b = (TH1F*)lhdir->Get( hspline.ReplaceAll("_sig","_bgd") ); break; } } // check for KDE if (h == 0 && b == 0) { TString hspline = pname +"_smoothed_hist_from_KDE"; h = (TH1F*)lhdir->Get( hspline ); if (h) { b = (TH1F*)lhdir->Get( hspline.ReplaceAll("_sig","_bgd") ); } } // found something ? if (h == 0 || b == 0) { cout << "--- likelihoodrefs.C: did not find spline for histogram: " << pname.Data() << endl; } else { Double_t pSscale = 1.0/(h->GetSumOfWeights()*h->GetBinWidth(1)); h->Scale( pSscale/hSscale ); color = 4; c[ic]->cd(1); h->SetLineWidth(2); h->SetLineColor(color); legS->AddEntry(h,"Estimated PDF (norm. signal)","l"); h->Draw("histsame"); legS->Draw(); Double_t pBscale = 1.0/(b->GetSumOfWeights()*b->GetBinWidth(1)); b->Scale( pBscale/hBscale ); color = 2; c[ic]->cd(2); b->SetLineColor(color); b->SetLineWidth(2); legB->AddEntry(b,"Estimated PDF (norm. backgr.)","l"); b->Draw("histsame"); // draw the legends legB->Draw(); hasBeenUsed.push_back( pname.Data() ); } c[ic]->Update(); // write to file TString fname = Form( "root_mva/plots/%s_refs_c%i", titName.Data(), ic+1 ); TMVAGlob::imgconv( c[ic], fname ); // c[ic]->Update(); newCanvas = kTRUE; hasBeenUsed.push_back( hname.Data() ); } } } }
//______________________________________________________________________________ void alice_esd_split(Bool_t auto_size=kFALSE) { // Main function, initializes the application. // // 1. Load the auto-generated library holding ESD classes and ESD dictionaries. // 2. Open ESD data-files. // 3. Load cartoon geometry. // 4. Spawn simple GUI. // 5. Load first event. TFile::SetCacheFileDir("."); if (!alice_esd_loadlib(esd_file_name, "aliesd")) { Error("alice_esd", "Can not load project libraries."); return; } printf("*** Opening ESD ***\n"); esd_file = TFile::Open(esd_file_name, "CACHEREAD"); if (!esd_file) return; printf("*** Opening ESD-friends ***\n"); esd_friends_file = TFile::Open(esd_friends_file_name, "CACHEREAD"); if (!esd_friends_file) return; esd_tree = (TTree*) esd_file->Get("esdTree"); esd = (AliESDEvent*) esd_tree->GetUserInfo()->FindObject("AliESDEvent"); // Set the branch addresses. { TIter next(esd->fESDObjects); TObject *el; while ((el=(TNamed*)next())) { TString bname(el->GetName()); if(bname.CompareTo("AliESDfriend")==0) { // AliESDfriend needs some '.' magick. esd_tree->SetBranchAddress("ESDfriend.", esd->fESDObjects->GetObjectRef(el)); } else { esd_tree->SetBranchAddress(bname, esd->fESDObjects->GetObjectRef(el)); } } } TEveManager::Create(); // Adapt the main frame to the screen size... if (auto_size) { Int_t qq; UInt_t ww, hh; gVirtualX->GetWindowSize(gVirtualX->GetDefaultRootWindow(), qq, qq, ww, hh); Float_t screen_ratio = (Float_t)ww/(Float_t)hh; if (screen_ratio > 1.5) { gEve->GetBrowser()->MoveResize(100, 50, ww - 300, hh - 100); } else { gEve->GetBrowser()->Move(50, 50); } } { // Simple geometry TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD"); if (!geom) return; TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle"); gGeoShape = TEveGeoShape::ImportShapeExtract(gse, 0); geom->Close(); delete geom; gEve->AddGlobalElement(gGeoShape); } make_gui(); // import the geometry in the projection managers if (gRPhiMgr) { TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr); a->SetNdivisions(3); gEve->GetScenes()->FindChild("R-Phi Projection")->AddElement(a); gRPhiMgr->ImportElements(gGeoShape); } if (gRhoZMgr) { TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr); a->SetNdivisions(3); gEve->GetScenes()->FindChild("Rho-Z Projection")->AddElement(a); gRhoZMgr->ImportElements(gGeoShape); } load_event(); update_projections(); gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown. }
void PWOrbitalBuilder::transform2GridData(PWBasis::GIndex_t& nG, int spinIndex, PWOrbitalSet& pwFunc) { ostringstream splineTag; splineTag << "eigenstates_"<<nG[0]<<"_"<<nG[1]<<"_"<<nG[2]; herr_t status = H5Eset_auto(NULL, NULL); app_log() << " splineTag " << splineTag.str() << endl; hid_t es_grp_id; status = H5Gget_objinfo (hfileID, splineTag.str().c_str(), 0, NULL); if(status) { es_grp_id = H5Gcreate(hfileID,splineTag.str().c_str(),0); HDFAttribIO<PWBasis::GIndex_t> t(nG); t.write(es_grp_id,"grid"); } else { es_grp_id = H5Gopen(hfileID,splineTag.str().c_str()); } string tname=myParam->getTwistName(); hid_t twist_grp_id; status = H5Gget_objinfo (es_grp_id, tname.c_str(), 0, NULL); if(status) twist_grp_id = H5Gcreate(es_grp_id,tname.c_str(),0); else twist_grp_id = H5Gopen(es_grp_id,tname.c_str()); HDFAttribIO<PosType> hdfobj_twist(TwistAngle); hdfobj_twist.write(twist_grp_id,"twist_angle"); ParticleSet::ParticleLayout_t& lattice(targetPtcl.Lattice); RealType dx=1.0/static_cast<RealType>(nG[0]-1); RealType dy=1.0/static_cast<RealType>(nG[1]-1); RealType dz=1.0/static_cast<RealType>(nG[2]-1); #if defined(VERYTINYMEMORY) typedef Array<ValueType,3> StorageType; StorageType inData(nG[0],nG[1],nG[2]); int ib=0; while(ib<myParam->numBands) { string bname(myParam->getBandName(ib)); status = H5Gget_objinfo (twist_grp_id, bname.c_str(), 0, NULL); hid_t band_grp_id, spin_grp_id=-1; if(status) { band_grp_id = H5Gcreate(twist_grp_id,bname.c_str(),0); } else { band_grp_id = H5Gopen(twist_grp_id,bname.c_str()); } hid_t parent_id=band_grp_id; if(myParam->hasSpin) { bname=myParam->getSpinName(spinIndex); status = H5Gget_objinfo (band_grp_id, bname.c_str(), 0, NULL); if(status) { spin_grp_id = H5Gcreate(band_grp_id,bname.c_str(),0); } else { spin_grp_id = H5Gopen(band_grp_id,bname.c_str()); } parent_id=spin_grp_id; } for(int ig=0; ig<nG[0]; ig++) { RealType x=ig*dx; for(int jg=0; jg<nG[1]; jg++) { RealType y=jg*dy; for(int kg=0; kg<nG[2]; kg++) { inData(ig,jg,kg)= pwFunc.evaluate(ib,lattice.toCart(PosType(x,y,kg*dz))); } } } app_log() << " Add spline data " << ib << " h5path=" << tname << "/eigvector" << endl; HDFAttribIO<StorageType> t(inData); t.write(parent_id,myParam->eigvecTag.c_str()); if(spin_grp_id>=0) H5Gclose(spin_grp_id); H5Gclose(band_grp_id); ++ib; } #else typedef Array<ValueType,3> StorageType; vector<StorageType*> inData; int nb=myParam->numBands; for(int ib=0; ib<nb; ib++) inData.push_back(new StorageType(nG[0],nG[1],nG[2])); PosType tAngle=targetPtcl.Lattice.k_cart(TwistAngle); PWOrbitalSet::ValueVector_t phi(nb); for(int ig=0; ig<nG[0]; ig++) { RealType x=ig*dx; for(int jg=0; jg<nG[1]; jg++) { RealType y=jg*dy; for(int kg=0; kg<nG[2]; kg++) { targetPtcl.R[0]=lattice.toCart(PosType(x,y,kg*dz)); pwFunc.evaluate(targetPtcl,0,phi); RealType x(dot(targetPtcl.R[0],tAngle)); ValueType phase(std::cos(x),-std::sin(x)); for(int ib=0; ib<nb; ib++) (*inData[ib])(ig,jg,kg)=phase*phi[ib]; } } } for(int ib=0; ib<nb; ib++) { string bname(myParam->getBandName(ib)); status = H5Gget_objinfo (twist_grp_id, bname.c_str(), 0, NULL); hid_t band_grp_id, spin_grp_id=-1; if(status) { band_grp_id = H5Gcreate(twist_grp_id,bname.c_str(),0); } else { band_grp_id = H5Gopen(twist_grp_id,bname.c_str()); } hid_t parent_id=band_grp_id; if(myParam->hasSpin) { bname=myParam->getSpinName(spinIndex); status = H5Gget_objinfo (band_grp_id, bname.c_str(), 0, NULL); if(status) { spin_grp_id = H5Gcreate(band_grp_id,bname.c_str(),0); } else { spin_grp_id = H5Gopen(band_grp_id,bname.c_str()); } parent_id=spin_grp_id; } app_log() << " Add spline data " << ib << " h5path=" << tname << "/eigvector" << endl; HDFAttribIO<StorageType> t(*(inData[ib])); t.write(parent_id,myParam->eigvecTag.c_str()); if(spin_grp_id>=0) H5Gclose(spin_grp_id); H5Gclose(band_grp_id); } for(int ib=0; ib<nb; ib++) delete inData[ib]; #endif H5Gclose(twist_grp_id); H5Gclose(es_grp_id); }
SPOSetBase* PWOrbitalBuilder::createPW(xmlNodePtr cur, int spinIndex) { int nb=targetPtcl.last(spinIndex)-targetPtcl.first(spinIndex); vector<int> occBand(nb); for(int i=0;i<nb; i++) occBand[i]=i; typedef PWBasis::GIndex_t GIndex_t; GIndex_t nG(1); bool transform2grid=false; cur=cur->children; while(cur != NULL) { string cname((const char*)(cur->name)); if(cname == "transform") { putContent(nG,cur); transform2grid=true; } else if(cname == "occupation") { string occMode("ground"); int bandoffset(1); OhmmsAttributeSet aAttrib; aAttrib.add(spinIndex,"spindataset"); aAttrib.add(occMode,"mode"); aAttrib.add(bandoffset,"offset"); /* reserved for index offset */ aAttrib.put(cur); if(occMode == "excited") { vector<int> occ; vector<int> deleted, added; putContent(occ,cur); for(int i=0; i<occ.size(); i++) { if(occ[i]<0) deleted.push_back(-occ[i]); else added.push_back(occ[i]); } if(deleted.size() != added.size()) { app_error() << " Numbers of deleted and added bands are not identical." << endl; OHMMS::Controller->abort(); } for(int i=0; i<deleted.size(); i++) { occBand[deleted[i]-bandoffset]=added[i]-bandoffset; } app_log() << " mode=\"excited\" Occupied states: " << endl; std::copy(occBand.begin(),occBand.end(),ostream_iterator<int>(app_log()," ")); app_log() << endl; } } cur=cur->next; } string tname=myParam->getTwistName(); hid_t es_grp_id = H5Gopen(hfileID,myParam->eigTag.c_str()); hid_t twist_grp_id = H5Gopen(es_grp_id,tname.c_str()); //create a single-particle orbital set SPOSetType* psi=new SPOSetType; if(transform2grid) { nb=myParam->numBands; occBand.resize(nb); for(int i=0;i<nb; i++) occBand[i]=i; } //going to take care of occ psi->resize(myBasisSet,nb,true); if(myParam->hasComplexData(hfileID))//input is complex { app_log() << " PW coefficients are complex." << endl; typedef std::vector<complex<RealType> > TempVecType; TempVecType coefs(myBasisSet->inputmap.size()); HDFAttribIO<TempVecType> hdfobj_coefs(coefs); int ib=0; while(ib<nb) { string bname(myParam->getBandName(occBand[ib],spinIndex)); app_log() << " Reading " << myParam->eigTag << "/" << tname <<"/"<< bname << endl; hid_t band_grp_id = H5Gopen(twist_grp_id,bname.c_str()); hdfobj_coefs.read(band_grp_id,myParam->eigvecTag.c_str()); psi->addVector(coefs,ib); H5Gclose(band_grp_id); ++ib; } } else { app_log() << " PW coefficients are real." << endl; typedef std::vector<RealType> TempVecType; TempVecType coefs(myBasisSet->inputmap.size()); HDFAttribIO<TempVecType> hdfobj_coefs(coefs); int ib=0; while(ib<nb) { string bname(myParam->getBandName(occBand[ib],spinIndex)); app_log() << " Reading " << myParam->eigTag << "/" << tname <<"/"<< bname << endl; hid_t band_grp_id = H5Gopen(twist_grp_id,bname.c_str()); hdfobj_coefs.read(band_grp_id,myParam->eigvecTag.c_str()); psi->addVector(coefs,ib); H5Gclose(band_grp_id); ++ib; } } H5Gclose(twist_grp_id); H5Gclose(es_grp_id); #if defined(QMC_COMPLEX) if(transform2grid) { app_warning() << " Going to transform on grid " << endl; transform2GridData(nG,spinIndex,*psi); } #endif return psi; }
//______________________________________________________________________________ void alice_esd() { // Main function, initializes the application. // // 1. Load the auto-generated library holding ESD classes and // ESD dictionaries. // 2. Open ESD data-files. // 3. Load cartoon geometry. // 4. Spawn simple GUI. // 5. Load first event. const TString weh("alice_esd()"); if (gROOT->LoadMacro("MultiView.C+") != 0) { Error(weh, "Failed loading MultiView.C in compiled mode."); return; } TFile::SetCacheFileDir("."); if (!alice_esd_loadlib("aliesd")) { Error("alice_esd", "Can not load project libraries."); return; } printf("*** Opening ESD ***\n"); esd_file = TFile::Open(esd_file_name, "CACHEREAD"); if (!esd_file) return; esd_tree = (TTree*) esd_file->Get("esdTree"); esd = (AliESDEvent*) esd_tree->GetUserInfo()->FindObject("AliESDEvent"); esd_objs = esd->fESDObjects; if (esd_friends_file_name != 0) { printf("*** Opening ESD-friends ***\n"); esd_friends_file = TFile::Open(esd_friends_file_name, "CACHEREAD"); if (!esd_friends_file) return; esd_tree->SetBranchStatus ("ESDfriend*", 1); } // Set the branch addresses. { TIter next(esd_objs); TObject *el; while ((el = (TNamed*)next())) { TString bname(el->GetName()); if (bname == "AliESDfriend") { // AliESDfriend needs special treatment. TBranch *br = esd_tree->GetBranch("ESDfriend."); br->SetAddress(esd_objs->GetObjectRef(el)); } else { TBranch *br = esd_tree->GetBranch(bname); if (br) { br->SetAddress(esd_objs->GetObjectRef(el)); } else { br = esd_tree->GetBranch(bname + "."); if (br) { br->SetAddress(esd_objs->GetObjectRef(el)); } else { Warning("AliESDEvent::ReadFromTree() " "No Branch found with Name '%s' or '%s.'.", bname.Data(),bname.Data()); } } } } } TEveManager::Create(); { // Simple geometry TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD"); if (!geom) return; TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle"); gGeomGentle = TEveGeoShape::ImportShapeExtract(gse, 0); geom->Close(); delete geom; gEve->AddGlobalElement(gGeomGentle); } // Standard multi-view //===================== gMultiView = new MultiView; gMultiView->ImportGeomRPhi(gGeomGentle); gMultiView->ImportGeomRhoZ(gGeomGentle); // HTML summary view //=================== gROOT->LoadMacro("alice_esd_html_summary.C"); fgHtmlSummary = new HtmlSummary("Alice Event Display Summary Table"); slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); fgHtml = new TGHtml(0, 100, 100); TEveWindowFrame *wf = slot->MakeFrame(fgHtml); fgHtml->MapSubwindows(); wf->SetElementName("Summary"); // Final stuff //============= gEve->GetBrowser()->GetTabRight()->SetTab(1); make_gui(); load_event(); gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown. }