//I STRONGLY RECOMMEND TO USE Trunk Rather than a new unneeded class //maybe just a class Wood? void Tree::generateBranches(Trunk* wrap) { vec loc = wrap->location(); int32_t posx = loc.x(); uint8_t posy = loc.y(); int32_t posz = loc.z(); uint8_t schanse = BRANCHING_CHANCE / (posy - _y); //Not much point to loop here //or make a function for the inside of the if. if(rand() % schanse == 0){ Branch(posx+1,posy,posz); } if(rand() % schanse == 0){ Branch(posx-1,posy,posz); } if(rand() % schanse == 0){ Branch(posx,posy,posz+1); } if(rand() % schanse == 0 ){ Branch(posx,posy,posz-1); } if(rand() % schanse == 0 ){ Branch(posx,posy+1,posz) } }
void CMA_MIPSIV::Template_BranchEq(bool condition, bool likely) { if(m_regSize == MIPS_REGSIZE_32) { m_codeGen->PushRel(offsetof(CMIPS, m_State.nGPR[m_nRS].nV[0])); m_codeGen->PushRel(offsetof(CMIPS, m_State.nGPR[m_nRT].nV[0])); } else if(m_regSize == MIPS_REGSIZE_64) { m_codeGen->PushRel64(offsetof(CMIPS, m_State.nGPR[m_nRS].nV[0])); m_codeGen->PushRel64(offsetof(CMIPS, m_State.nGPR[m_nRT].nV[0])); m_codeGen->Cmp64(Jitter::CONDITION_NE); m_codeGen->PushCst(0); } Jitter::CONDITION branchCondition = condition ? Jitter::CONDITION_EQ : Jitter::CONDITION_NE; if(likely) { BranchLikely(branchCondition); } else { Branch(branchCondition); } }
void CMA_MIPSIV::Template_BranchGez(bool condition, bool likely) { if(m_regSize == MIPS_REGSIZE_32) { m_codeGen->PushRel(offsetof(CMIPS, m_State.nGPR[m_nRS].nV[0])); } else { m_codeGen->PushRel(offsetof(CMIPS, m_State.nGPR[m_nRS].nV[1])); } m_codeGen->PushCst(0x80000000); m_codeGen->And(); m_codeGen->PushCst(0); Jitter::CONDITION branchCondition = condition ? Jitter::CONDITION_EQ : Jitter::CONDITION_NE; if(likely) { BranchLikely(branchCondition); } else { Branch(branchCondition); } }
void CMA_MIPSIV::Template_BranchLez(bool condition, bool likely) { Jitter::CONDITION branchCondition; if(m_regSize == MIPS_REGSIZE_32) { m_codeGen->PushRel(offsetof(CMIPS, m_State.nGPR[m_nRS].nV[0])); m_codeGen->PushCst(0); branchCondition = condition ? Jitter::CONDITION_LE : Jitter::CONDITION_GT; } else { m_codeGen->PushRel64(offsetof(CMIPS, m_State.nGPR[m_nRS].nV[0])); m_codeGen->PushCst64(0); m_codeGen->Cmp64(condition ? Jitter::CONDITION_LE : Jitter::CONDITION_GT); m_codeGen->PushCst(0); branchCondition = Jitter::CONDITION_NE; } if(likely) { BranchLikely(branchCondition); } else { Branch(branchCondition); } }
void CTreepadView::OnFileOpen() { BOOL isOpen = TRUE; CString defaultDir = L"D:\\Treepad\\Iteration"; CString filter = L"Treepad File (*.tpf)||"; CString fileName = L"file1.tpf"; CFileDialog openFileDlg(isOpen, L"tpf", fileName, OFN_HIDEREADONLY | OFN_READONLY, filter, NULL); INT_PTR result = openFileDlg.DoModal(); if (result == IDOK) { CClientDC dc(this); CBranch_Ser b(0,0,0,0); CString filePath = openFileDlg.GetPathName(); CFile myFile(filePath, CFile::modeRead); myFile.SeekToBegin(); CArchive arLoad(&myFile, CArchive::load); CBranch_Ser* t = (CBranch_Ser*)arLoad.ReadObject(RUNTIME_CLASS(CBranch_Ser)); tree = Trunk(CPoint(t->x1, t->y1), CPoint(t->x2, t->y2)); for (int i = 0; i < t->num; ++i) { CBranch_Ser* p = (CBranch_Ser*)arLoad.ReadObject(RUNTIME_CLASS(CBranch_Ser)); str.Format(L"x=%d y=%d", p->x1, p->y1); tree.addBranch(Branch(CPoint(p->x1, p->y1), CPoint(p->x2, p->y2))); } arLoad.Close(); statu = MOVE_STATU; InvalidateRect(NULL); } // TODO: 在此添加命令处理程序代码 }
void updateweight(TString filename) { auto f = new TFile(filename,"update"); auto nt = (TTree *)f->Get("nt"); float prew, weight; TBranch *bw; bw = nt->Branch("weight",&weight); nt->SetBranchAddress("prew",&prew); int n = nt->GetEntries(); int onep = n/100; for (int i=0;i<n;i++) { if (i%onep==0) cout<<i/onep<<endl; nt->GetEntry(i); weight = prew; bw->Fill(); } nt->Write(); f->Close(); }
void CTreepadView::draw_branch(vector<Branch> b,int k) { k--; if (!k) { return; } double angle; double lenth; double rat1; //分支点位置与主干长度的比例 double rat2; //分支长度与主干长度的比例 CClientDC dc(this); CPen pen(PS_SOLID, (int)(dam*pow(dec,iter-k)), color); dc.SelectObject(&pen); for (UINT i = 0; i < b.size(); ++i) { vector<Branch> sub; for (UINT j = 0; j < b.size(); ++j) { rat1 = getLen(tree.getStart(), tree[j].getStart()) / tree.lenth; CPoint *p=new CPoint(b[i].getStart().x + (int)(rat1*b[i].lenth*cos(b[i].angle)), b[i].getStart().y + (int)(rat1*b[i].lenth*sin(b[i].angle))); angle = b[i].angle + tree[j].angle - tree.angle; rat2 = tree[j].lenth / (double)tree.lenth; lenth = b[i].lenth*rat2; dc.MoveTo(*p); dc.LineTo(int(p->x + lenth*cos(angle)), int(p->y + lenth*sin(angle))); sub.push_back(Branch(*p, angle, lenth)); } draw_branch(sub, k); } ReleaseDC(&dc); }
RunInformation::RunInformation() : TTree("runs", "Information on the run"), fIPCollection(0) { fIPCollection = new IncomingParticlesRef; Clear(""); Branch("fIPCollection", fIPCollection); }
void TauOptimization::Init(){ cout<<"[TauOptimization]::[Init]::[INFO] Booking Histo "<<endl; for ( string& l : AllLabel() ) { Book2D("TauOpt/Iso_Rho_" + l , "tau Iso delta Beta corrections",1000,0,200,1000,0,20); Book2D("TauOpt/Iso2_Rho_" + l , "tau Iso2 delta Beta corrections",1000,0,200,1000,0,20); Book("TauOpt/Iso_Match_"+l,"tau Iso",1000,0.,20.); Book("TauOpt/Iso_Lead_"+l,"tau Iso",1000,0.,20.); Book("TauOpt/IsLeadMatched_"+l,"Leading Matched",10,-4.5,5.5); Book("TauOpt/Pt_Match_"+l,"tau Pt",1000,0.,1000.); Book("TauOpt/Pt_Lead_"+l,"tau Pt",1000,0.,1000.); Book("TauOpt/Iso2_Match_"+l,"tau Iso Delta Beta",1500,-10,20.); Book("TauOpt/Iso2_Lead_"+l,"tau Iso Delta Beta",1500,-10,20.); } string treename = "TauOptTree"; InitTree(treename); Branch(treename, "tau1Pt" ,'F'); Branch(treename, "tau2Pt" ,'F'); Branch(treename, "tau1Eta" ,'F'); Branch(treename, "tau2Eta" ,'F'); Branch(treename, "tau1Iso" ,'F'); Branch(treename, "tau2Iso" ,'F'); Branch(treename, "ttM" ,'F'); }
void circular() { auto T = new TTree("T","test circular buffers"); TRandom r; Float_t px,py,pz; Double_t randomNum; UShort_t i; T->Branch("px",&px,"px/F"); T->Branch("py",&py,"px/F"); T->Branch("pz",&pz,"px/F"); T->Branch("random",&randomNum,"random/D"); T->Branch("i",&i,"i/s"); T->SetCircular(20000); //keep a maximum of 20000 entries in memory for (i = 0; i < 65000; i++) { r.Rannor(px,py); pz = px*px + py*py; randomNum = r.Rndm(); T->Fill(); } T->Print(); }
bool MakeBranch ( CLxLoc_EvaluationStack &branch) { LXtObjectID obj; if (LXx_FAIL (Branch (&obj))) return false; return branch.take (obj); }
void Interpret( void ) { INSTRUCTION current; int addr, nextaddr; current = Pmem[PC]; nextaddr = PC+1; switch ( current.opcode ) { case HALT: WriteOut( "!! HALT encountered\n\n" ); Running = 0; break; case ADD: BinaryOp( ADD ); break; case SUB: BinaryOp( SUB ); break; case MULT: BinaryOp( MULT ); break; case DIV: BinaryOp( DIV ); break; case NEG: Dmem[SP] = -Dmem[SP]; break; case BR: nextaddr = Branch( BR ); break; case BGZ: nextaddr = Branch( BGZ ); break; case BG: nextaddr = Branch( BG ); break; case BLZ: nextaddr = Branch( BLZ ); break; case BL: nextaddr = Branch( BL ); break; case BZ: nextaddr = Branch( BZ ); break; case BNZ: nextaddr = Branch( BNZ ); break; case CALL: Push( nextaddr ); nextaddr = CodeAddr( current.offset ); break; case RET: nextaddr = CodeAddr( Pop() ); break; case BSF: BuildStackFrame(); break; case RSF: RemoveStackFrame(); break; case LDP: LoadDisplayPointer(); break; case RDP: RestoreDisplayPointer(); break; case INC: SP = DataAddr( SP + current.offset ); break; case DEC: SP = Decrement( SP, current.offset ); break; case PUSHFP: Push( FP ); break; case LOADI: Push( current.offset ); break; case LOADA: addr = DataAddr( current.offset ); Push( Dmem[addr] ); break; case LOADFP: addr = DataAddr( FP + current.offset ); Push( Dmem[addr] ); break; case LOADSP: addr = DataAddr( Dmem[SP] + current.offset ); Dmem[SP] = Dmem[addr]; break; case STOREA: addr = DataAddr( current.offset ); Dmem[addr] = Pop(); break; case STOREFP: addr = DataAddr( FP + current.offset ); Dmem[addr] = Pop(); break; case STORESP: addr = DataAddr( Pop() ); addr = DataAddr( addr + current.offset ); Dmem[addr] = Pop(); break; case READ: ReadInteger(); break; case WRITE: WriteInteger(); break; default: DisplayError( !FATAL, "Error, unknown opcode encountered\n" ); DisplayError( FATAL, "PC = %d, SP = %d, FP = %d, opcode = %d\n", PC, SP, FP, current.opcode ); break; } PC = nextaddr; }
void colWiseWrite_4() { auto file = TFile::Open("file_colWiseWrite_4.root", "RECREATE"); auto tree = new TTree("mytree", "mytree"); MetaArrayHolder a_metaholder; tree->Branch("mybranch", &a_metaholder); for (int i=0;i<10;++i) { a_metaholder.Set(i,i+1,i+2); tree->Fill(); } file->Write(); file->Close(); }
void DoWhile() { char L1[100]; char L2[100]; strcpy(L1, NewLabel()); strcpy(L2, NewLabel()); PostLabel(L1); BoolExpression(); BranchFalse(L2); Block(); MatchString("ENDWHILE"); Branch(L1); PostLabel(L2); }
void DoWhile() { Next(); char L1[MAX_BUF]; char L2[MAX_BUF]; sprintf(L1, NewLabel()); sprintf(L2, NewLabel()); PostLabel(L1); BoolExpression(); BranchFalse(L2); Block(); MatchString("ENDWHILE"); Branch(L1); PostLabel(L2); }
void DoIf() { char L1[100]; char L2[100]; BoolExpression(); strcpy(L1, NewLabel()); strcpy(L2, L1); BranchFalse(L1); Block(); if(Token == 'l') { Match('l'); strcpy(L2, NewLabel()); Branch(L2); PostLabel(L1); Block(); } PostLabel(L2); MatchString("ENDIF"); }
/* Recognize and Translate an IF construct */ void DoIf() { Next(); char L1[MAX_BUF]; char L2[MAX_BUF]; sprintf(L1, NewLabel()); sprintf(L2, L1); BoolExpression(); BranchFalse(L1); Block(); if (Token == 'l') { Next(); sprintf(L2, NewLabel()); Branch(L2); PostLabel(L1); Block(); } PostLabel(L2); MatchString("ENDIF"); }
void CTreepadView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if ((statu == TRUNK_STATU|| statu == BRANCH_STATU)&&p1 != point) { CClientDC dc(this); CPen pen(PS_SOLID, dam, color); dc.SelectObject(&pen); dc.MoveTo(p1); dc.LineTo(f3?CPoint(p1.x,point.y):point); if (statu == TRUNK_STATU) { tree=Trunk(p1, f3 ? CPoint(p1.x, point.y) : point); f2 = false; } else { tree.addBranch(Branch(p1, point)); } f6 = true; f7 = false; statu = MOVE_STATU; } CView::OnLButtonUp(nFlags, point); }
void updatePbPbBtriggerweight(TString filename, vector<float> w) { auto f = new TFile(filename,"update"); auto nt = (TTree *)f->Get("nt"); float csv60, csv80; float triggermatched; float weight; TBranch *bw; bw = nt->Branch("weight",&weight); nt->SetBranchAddress("hltCSV60",&csv60); nt->SetBranchAddress("hltCSV80",&csv80); nt->SetBranchAddress("triggermatched",&triggermatched); int n = nt->GetEntries(); int onep = n/100; for (int i=0;i<n;i++) { if (i%onep==0) cout<<i/onep<<endl; nt->GetEntry(i); weight = 0; if (triggermatched && csv80) weight = w[1]; if (triggermatched && csv60 && !csv80) weight = w[0]; bw->Fill(); } nt->Write(); f->Close(); }
void Traverse(wxInt32 id, wxInt32 avoidID1, wxInt32 avoidID2) { SegmentHash::iterator it = mSegmentHash.find(id); // If there's no side object here, or it has already been visited, // do nothing. if( (mSegmentHash.end() == it) || (true == it->second.counted)) { return; } // Mark this segment as being traversed so we don't hit it again. Segment &segment = it->second; segment.counted = true; // In addition, mark the other side as being visited. wxInt32 thisTile, thisSide; boost::tie(thisTile, thisSide) = Utility::decodeSel(id); wxInt32 otherTile = tile<IntArray>(shSides, thisTile)[thisSide]; wxInt32 otherID = Utility::encodeSel(otherTile, (thisSide + 3) % 6); wxASSERT(mSegmentHash.end() != mSegmentHash.find(otherID)); mSegmentHash[otherID].counted = true; // Since there is a side object here, do two things. 1) Look to see // if we hit one of the potential move corners, and 2) Continue to // look for more side objects to traverse. // Branch direction 1. wxInt32 branch1ID = Utility::encodeSel(thisTile, (thisSide + 1) % 6); wxInt32 branch2ID = Utility::encodeSel(otherTile, (thisSide + 2) % 6); wxInt32 cornerID = branch1ID; if( (avoidID1 != branch1ID) && (avoidID1 != branch2ID) && (avoidID2 != branch1ID) && (avoidID2 != branch2ID) ) { // See if we found a corner. if(mPossiblePlacements.end() != mPossiblePlacements.find(cornerID)) { wxInt32 foundTile, foundCorner; boost::tie(foundTile, foundCorner) = Utility::decodeSel(cornerID); mAvailablePlacements.insert( TileCorner(foundTile, foundCorner)); } // No dead end, so we are free to check the branches. if(mDeadEndCorners.end() == mDeadEndCorners.find(cornerID)) { Branch(id, otherID, branch1ID, segment, cornerID); Branch(id, otherID, branch2ID, segment, cornerID); } } // Branch direction 2. wxInt32 curSide = (thisSide + 5) % 6; branch1ID = Utility::encodeSel(thisTile, curSide); otherTile = tile<IntArray>(shSides, thisTile)[curSide]; branch2ID = Utility::encodeSel(otherTile, (thisSide + 1) % 6); cornerID = id; if( (avoidID1 != branch1ID) && (avoidID1 != branch2ID) && (avoidID2 != branch1ID) && (avoidID2 != branch2ID) ) { // See if we found a corner. if(mPossiblePlacements.end() != mPossiblePlacements.find(cornerID)) { wxInt32 foundTile, foundCorner; boost::tie(foundTile, foundCorner) = Utility::decodeSel(cornerID); mAvailablePlacements.insert( TileCorner(foundTile, foundCorner)); } // No dead end, so we are free to check the branches. if(mDeadEndCorners.end() == mDeadEndCorners.find(cornerID)) { Branch(id, otherID, branch1ID, segment, cornerID); Branch(id, otherID, branch2ID, segment, cornerID); } } // We're off the segment so it can be counted in another chain. segment.counted = false; mSegmentHash[otherID].counted = false; }
void Branch::move(const std::string& branchName, bool force) { git_reference *out; Exception::git2_assert(git_branch_move(&out, data(), branchName.c_str(), force?1:0)); *this = Branch(out); }
Branch Branch::upstream() const { git_reference *out; Exception::git2_assert(git_branch_upstream(&out, data())); return Branch(out); }