void CDlgLianHaoLanQiu::OnBnClickedButton5() { m_FormulaInfoList=CFormulaCenter::GetInstance()->GetFormulaInfoByType(m_FormulaType); m_CurrentIndex=0; FillData(m_FormulaInfoList); UpdateBtnStatus(); }
CDlgSmsPhone::CDlgSmsPhone(QWidget *parent) : QDialog(parent), ui(new Ui::CDlgSmsPhone) { ui->setupUi(this); CCommonFunction::ControlSysMenu( *this ); FillData( ); }
ViewSwitchingWindow() :GuiWindow(GetCurrentTheme()->CreateWindowStyle()) { this->SetText(L"Controls.ListView.ViewSwitching"); GuiTableComposition* table=new GuiTableComposition; table->SetCellPadding(4); table->SetAlignmentToParent(Margin(0, 0, 0, 0)); table->SetRowsAndColumns(2, 1); table->SetRowOption(0, GuiCellOption::MinSizeOption()); table->SetRowOption(1, GuiCellOption::PercentageOption(1.0)); table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0)); { GuiCellComposition* cell=new GuiCellComposition; table->AddChild(cell); cell->SetSite(0, 0, 1, 1); GuiTextList* comboSource=g::NewTextList(); comboSource->GetItems().Add(new list::TextItem(L"Big Icon")); comboSource->GetItems().Add(new list::TextItem(L"Small Icon")); comboSource->GetItems().Add(new list::TextItem(L"List")); comboSource->GetItems().Add(new list::TextItem(L"Detail")); comboSource->GetItems().Add(new list::TextItem(L"Tile")); comboSource->GetItems().Add(new list::TextItem(L"Information")); comboSource->SetHorizontalAlwaysVisible(false); comboView=g::NewComboBox(comboSource); comboView->SetSelectedIndex(0); comboView->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, -1, 0)); comboView->GetBoundsComposition()->SetPreferredMinSize(Size(160, 0)); comboView->SelectedIndexChanged.AttachMethod(this, &ViewSwitchingWindow::comboView_SelectedIndexChanged); cell->AddChild(comboView->GetBoundsComposition()); } { GuiCellComposition* cell=new GuiCellComposition; table->AddChild(cell); cell->SetSite(1, 0, 1, 1); listView=g::NewListViewBigIcon(); listView->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0)); listView->SetHorizontalAlwaysVisible(false); listView->SetVerticalAlwaysVisible(false); listView->SetMultiSelect(true); cell->AddChild(listView->GetBoundsComposition()); } this->GetBoundsComposition()->AddChild(table); FillData(listView); // set the preferred minimum client size this->GetBoundsComposition()->SetPreferredMinSize(Size(640, 480)); // call this to calculate the size immediately if any indirect content in the table changes // so that the window can calcaulte its correct size before calling the MoveToScreenCenter() this->ForceCalculateSizeImmediately(); // move to the screen center this->MoveToScreenCenter(); }
void CDlgLianHaoLanQiu::OnBnClickedSearchBtn() { int Cursel=m_ComboBox.GetCurSel(); int Data=-1; int Data1=-1; CString Text; GetDlgItemText(IDC_EDIT1,Text); if(!Text.IsEmpty()) Data = atoi(Text.GetBuffer()); Text.Empty(); GetDlgItemText(IDC_EDIT6,Text); if(!Text.IsEmpty()) Data1=atoi(Text.GetBuffer()); m_CurrentIndex=0; m_FormulaInfoList=CFormulaCenter::GetInstance()->SearchFormulaInfoByType(m_FormulaType,eSearchVType(Cursel),Data,Data1); FillData(m_FormulaInfoList); UpdateBtnStatus(); }
Model* FBXFactory::CreateModel(FbxModelData* someModelData, Effect* aEffect) { Model* tempModel = new Model(); tempModel->myEffect = aEffect; if (someModelData->myData) { FillData(someModelData->myData, tempModel, aEffect); tempModel->myOrientation = someModelData->myOrientation; } for (int i = 0; i < someModelData->myChilds.Size(); ++i) { auto currentChild = someModelData->myChilds[i]; tempModel->AddChild(CreateModel(currentChild, aEffect)); } return tempModel; }
void CCreateNewDatabase::CreateItem(std::string& filename, std::string& sDBFileName, std::string& sDBFileCreated) { std::string sDBType = ""; std::string sDBAlbum = ""; std::string sDBArtist = ""; std::string sDBBand = ""; std::string sDBTitle = ""; std::string sDBYear = ""; std::string sDBGenre = ""; std::string sDBTrack = ""; std::string sDBAlbumArtist = ""; FillData(filename, sDBType, sDBAlbum, sDBArtist, sDBBand, sDBTitle, sDBYear, sDBGenre, sDBTrack, sDBAlbumArtist); m_strQueryCreateItem.append("INSERT INTO media ('Filename', 'Album', 'Artist', 'Band', 'Title', 'Year', 'Genre', 'Track', 'Type', 'DeleteFlag', 'Rating', 'PlayTime', 'Cover', 'DBAddDate', 'FileCreateDate', 'LastPlayDate', 'AlbumArtist') "); m_strQueryCreateItem.append("VALUES('"); m_strQueryCreateItem.append(sDBFileName); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBAlbum); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBArtist); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBBand); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBTitle); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBYear); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBGenre); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBTrack); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBType); m_strQueryCreateItem.append("',0,0,0,0,'"); m_strQueryCreateItem.append(m_strCreateDate); m_strQueryCreateItem.append("','"); m_strQueryCreateItem.append(sDBFileCreated); m_strQueryCreateItem.append("', '','"); m_strQueryCreateItem.append(sDBAlbumArtist); m_strQueryCreateItem.append("');"); m_iCreateItem++; }
void CCreateNewDatabase::UpdateItem(std::string& filename, std::string& sDBFileName, std::string& sDBFileCreated) { std::string sDBType = ""; std::string sDBAlbum = ""; std::string sDBArtist = ""; std::string sDBBand = ""; std::string sDBTitle = ""; std::string sDBYear = ""; std::string sDBGenre = ""; std::string sDBTrack = ""; std::string sDBAlbumArtist = ""; FillData(filename, sDBType, sDBAlbum, sDBArtist, sDBBand, sDBTitle, sDBYear, sDBGenre, sDBTrack, sDBAlbumArtist); m_strQueryUpdateItem.append("UPDATE media SET DeleteFlag = 0, Album = '"); m_strQueryUpdateItem.append(sDBAlbum); m_strQueryUpdateItem.append("', Artist = '"); m_strQueryUpdateItem.append(sDBArtist); m_strQueryUpdateItem.append("', Band ='"); m_strQueryUpdateItem.append(sDBBand); m_strQueryUpdateItem.append("', Title ='"); m_strQueryUpdateItem.append(sDBTitle); m_strQueryUpdateItem.append("', Year = '"); m_strQueryUpdateItem.append(sDBYear); m_strQueryUpdateItem.append("', Genre = '"); m_strQueryUpdateItem.append(sDBGenre); m_strQueryUpdateItem.append("', Track = '"); m_strQueryUpdateItem.append(sDBTrack); m_strQueryUpdateItem.append("', Type = '"); m_strQueryUpdateItem.append(sDBType); m_strQueryUpdateItem.append("', DBAddDate = '"); m_strQueryUpdateItem.append(m_strCreateDate); m_strQueryUpdateItem.append("', FileCreateDate = '"); m_strQueryUpdateItem.append(sDBFileCreated); m_strQueryUpdateItem.append("', AlbumArtist = '"); m_strQueryUpdateItem.append(sDBAlbumArtist); m_strQueryUpdateItem.append("' WHERE UPPER(Filename) = UPPER('"); m_strQueryUpdateItem.append(sDBFileName); m_strQueryUpdateItem.append("');"); m_iUpdateItem++; }
void CDlgLianHaoLanQiu::OnBnClickedNextBtn() { if(m_FormulaInfoList.empty()) return; m_CurrentIndex+=PAGE_COUNT; if(m_CurrentIndex >= m_FormulaInfoList.size()) m_CurrentIndex=m_FormulaInfoList.size()-1; int Count = m_CurrentIndex+PAGE_COUNT; if(Count >= m_FormulaInfoList.size()-1) Count=m_FormulaInfoList.size()-1; vector<sFormulaInfo>::iterator it = m_FormulaInfoList.begin(); vector<sFormulaInfo> Temp; Temp.insert(Temp.begin(),it+m_CurrentIndex,it+Count); FillData(Temp); UpdateBtnStatus(); }
Sample2D_Face::Sample2D_Face (const TopoDS_Shape& theFace) :AIS_InteractiveObject() { myshape = theFace; myFORWARDColor = Quantity_NOC_BLUE1; myREVERSEDColor = Quantity_NOC_YELLOW; myINTERNALColor = Quantity_NOC_RED1; myEXTERNALColor = Quantity_NOC_MAGENTA1; myWidthIndex = 1; myTypeIndex = 1; myForwardNum=0; myReversedNum=0; myInternalNum=0; myExternalNum=0; SetAutoHilight(Standard_False); FillData(Standard_True); }
void CDlgLianHaoLanQiu::OnBnClickedJingxuanBtn() { CMarkup Xml; CString FormulaName=GetAppCurrentPath()+"FormulaNameList.xml"; Xml.Load(FormulaName.GetBuffer()); FormulaName.ReleaseBuffer(); vector<CString> NameList; while(Xml.FindChildElem("FormulaInfo")) { Xml.IntoElem(); Xml.FindChildElem("FormulaName"); CString Name=Xml.GetChildData().c_str(); Xml.FindChildElem("FormulaType"); CString StrType=Xml.GetChildData().c_str(); int Type = atoi(StrType.GetBuffer()); StrType.ReleaseBuffer(); if(Type == m_FormulaType && !Name.IsEmpty()) NameList.push_back(Name); Xml.OutOfElem(); } if(NameList.empty()) { m_FormulaInfoList=CFormulaCenter::GetInstance()->GetFormulaInfoByType(m_FormulaType); } else m_FormulaInfoList=CFormulaCenter::GetInstance()->GetFormulaInfoByName(m_FormulaType,NameList); m_CurrentIndex=0; FillData(m_FormulaInfoList); UpdateBtnStatus(); }
void VariableSettingsDlg::OnOkClick(wxCommandEvent& event) { wxLogMessage("Click VariableSettingsDlg::OnOkClick:"); if (no_weights_found_fail) { event.Skip(); EndDialog(wxID_CANCEL); return; } if ((style & ALLOW_EMPTY_IN_FIRST) && (style & ALLOW_EMPTY_IN_SECOND)) { if (lb1->GetSelection() == 0 && lb2->GetSelection() == 0) { wxString msg(_("No field chosen for first and second variable.")); wxMessageDialog dlg (this, msg, _("Error"), wxOK | wxICON_ERROR); dlg.ShowModal(); return; } } if (map_theme_ch) { m_theme = map_theme_ch->GetSelection(); } if (lb1->GetSelection() == wxNOT_FOUND) { wxString msg(_("No field chosen for first variable.")); wxMessageDialog dlg (this, msg, _("Error"), wxOK | wxICON_ERROR); dlg.ShowModal(); return; } int sel_idx = lb1->GetSelection(); v1_col_id = col_id_map[sel1_idx_map[sel_idx]]; v1_name = table_int->GetColName(v1_col_id); project->SetDefaultVarName(0, v1_name); if (is_time) { v1_time = time_lb1->GetSelection(); project->SetDefaultVarTime(0, v1_time); if (!table_int->IsColTimeVariant(v1_col_id)) v1_time = 0; } wxLogMessage(v1_name); if (num_var >= 2) { if (lb2->GetSelection() == wxNOT_FOUND) { wxString msg(_("No field chosen for second variable.")); wxMessageDialog dlg (this, msg, _("Error"), wxOK | wxICON_ERROR); dlg.ShowModal(); return; } int sel_idx = lb2->GetSelection(); v2_col_id = col_id_map[sel2_idx_map[sel_idx]]; v2_name = table_int->GetColName(v2_col_id); project->SetDefaultVarName(1, v2_name); if (is_time) { v2_time = time_lb2->GetSelection(); project->SetDefaultVarTime(1, v2_time); if (!table_int->IsColTimeVariant(v2_col_id)) v2_time = 0; } wxLogMessage(v2_name); } if (num_var >= 3) { if (lb3->GetSelection() == wxNOT_FOUND) { wxString msg(_("No field chosen for third variable.")); wxMessageDialog dlg (this, msg, _("Error"), wxOK | wxICON_ERROR); dlg.ShowModal(); return; } v3_col_id = col_id_map[sel3_idx_map[lb3->GetSelection()]]; v3_name = table_int->GetColName(v3_col_id); project->SetDefaultVarName(2, v3_name); if (is_time) { v3_time = time_lb3->GetSelection(); project->SetDefaultVarTime(2, v3_time); if (!table_int->IsColTimeVariant(v3_col_id)) v3_time = 0; } wxLogMessage(v3_name); } if (num_var >= 4) { if (lb4->GetSelection() == wxNOT_FOUND) { wxString msg(_("No field chosen for fourth variable.")); wxMessageDialog dlg (this, msg, _("Error"), wxOK | wxICON_ERROR); dlg.ShowModal(); return; } v4_col_id = col_id_map[sel4_idx_map[lb4->GetSelection()]]; v4_name = table_int->GetColName(v4_col_id); project->SetDefaultVarName(3, v4_name); if (is_time) { v4_time = time_lb4->GetSelection(); project->SetDefaultVarTime(3, v4_time); if (!table_int->IsColTimeVariant(v4_col_id)) v4_time = 0; } wxLogMessage(v4_name); } wxString emptyVar = FillData(); if (emptyVar.empty()== false) { wxString msg = wxString::Format(_("The selected variable %s is not valid. If it's a grouped variable, please modify it in Time->Time Editor. Or please select another variable."), emptyVar); wxMessageDialog dlg (this, msg.mb_str(), _("Invalid Variable"), wxOK | wxICON_ERROR); dlg.ShowModal(); } else { if (show_weights) { project->GetWManInt()->MakeDefault(GetWeightsId()); } if (GetDistanceMetric() != WeightsMetaInfo::DM_unspecified) { project->SetDefaultDistMetric(GetDistanceMetric()); } if (GetDistanceUnits() != WeightsMetaInfo::DU_unspecified) { project->SetDefaultDistUnits(GetDistanceUnits()); } bool check_group_var = true; try { for (int i=0; i<col_ids.size(); i++) { project->GetTableInt()->GetColTypes(col_ids[i]); } } catch(GdaException& ex) { // place holder found wxString msg = wxString::Format(_("The selected group variable should contains %d items. Please modify the group variable in Time->Time Editor, or select another variable."), project->GetTableInt()->GetTimeSteps()); wxMessageDialog dlg (this, msg.mb_str(), _("Incomplete Group Variable"), wxOK | wxICON_ERROR); dlg.ShowModal(); check_group_var = false; } if (check_group_var == true) EndDialog(wxID_OK); } }
void SortArray::FillData(unsigned int schema, size_t arraysize) { if (arraysize == 0) arraysize = 1; ResetArray(arraysize); if (schema == 0) // Shuffle of [1,n] { for (size_t i = 0; i < m_array.size(); ++i) m_array[i] = ArrayItem(i+1); std::random_shuffle(m_array.begin(), m_array.end()); } else if (schema == 1) // Ascending [1,n] { for (size_t i = 0; i < m_array.size(); ++i) m_array[i] = ArrayItem(i+1); } else if (schema == 2) // Descending [1,n] { for (size_t i = 0; i < m_array.size(); ++i) m_array[i] = ArrayItem(m_array.size() - i); } else if (schema == 3) // Cubic skew of [1,n] { for (size_t i = 0; i < m_array.size(); ++i) { // normalize to [-1,+1] double x = (2.0 * (double)i / m_array.size()) - 1.0; // calculate x^3 double v = x * x * x; // normalize to array size double w = (v + 1.0) / 2.0 * arraysize + 1; // decrease resolution for more equal values w /= 3.0; m_array[i] = ArrayItem(w + 1); } std::random_shuffle(m_array.begin(), m_array.end()); } else if (schema == 4) // Quintic skew of [1,n] { for (size_t i = 0; i < m_array.size(); ++i) { // normalize to [-1,+1] double x = (2.0 * (double)i / m_array.size()) - 1.0; // calculate x^5 double v = x * x * x * x * x; // normalize to array size double w = (v + 1.0) / 2.0 * arraysize + 1; // decrease resolution for more equal values w /= 3.0; m_array[i] = ArrayItem(w + 1); } std::random_shuffle(m_array.begin(), m_array.end()); } else if (schema == 5) // shuffled n-2 equal values in [1,n] { m_array[0] = ArrayItem(1); for (size_t i = 1; i < m_array.size()-1; ++i) { m_array[i] = ArrayItem( arraysize / 2 + 1 ); } m_array[m_array.size()-1] = ArrayItem(arraysize); std::random_shuffle(m_array.begin(), m_array.end()); } else // fallback { return FillData(0, arraysize); } FinishFill(); }
/** * 1. Data sample : pp200 W->e nu with pile-up corresponding to 1 MHz min. bias * events, 50 K event y2011, 10 K event y2012. * * 2. Proof of principal: no pile-up for both PPV and KFV * * a. Reconstructed primary track multiplicity versus corresponding MC * "reconstructable" (i.e. in n STAR acceptance,no. TPC MC hits >= 15) tracks * multiplicity. * * b. Corrected reconstructed primary track multiplicity (i.e. multiplied by * QA/100.) versus corresponding MC "reconstructable" (i.e. in n STAR * acceptance,no. TPC MC hits >= 15) tracks multiplicity. * * c. Efficiency primary vertex reconstruction versus MC "reconstructable" * tracks multiplicity. * * 3. With pileup. repeat above (a-c) with old ranking scheme for * * I. Any reconstructed primary vertex which is matched with MC trigger * vertex (MC = 1) * * II. The best (in sense of ranking) reconstructed primary vertex which is * matched with MC trigger vertex (MC = 1) * * III. The best (in sense of ranking) reconstructed primary vertex which is * not matched with MC trigger vertex (MC != 1) * * 4. With pileup. repeat above (a-c) with new ranking scheme for cases I-III */ void MuMcPrVKFV2012(Long64_t nevent, const char *file, const std::string& outFile, bool fillNtuple) { #ifdef __TMVA__ boost::replace_last(outFile, ".root", ""); outFile += ".TMVArank.root"; // create a set of variables and declare them to the reader // - the variable names must corresponds in name and type to // those given in the weight file(s) that you use TString separator(":"); TString Vnames(vnames); TObjArray *array = Vnames.Tokenize(separator); std::vector<std::string> inputVars; TIter next(array); TObjString *objs; while ((objs = (TObjString *) next())) { std::cout << objs->GetString() << std::endl; } inputVars.push_back("beam"); inputVars.push_back("postx"); inputVars.push_back("prompt"); inputVars.push_back("cross"); inputVars.push_back("tof"); inputVars.push_back("notof"); inputVars.push_back("EEMC"); inputVars.push_back("noEEMC"); inputVars.push_back("chi2"); std::vector<double> *inputVec = new std::vector<double>( inputVars.size() ); IClassifierReader *classReader = new ReadBDT( inputVars ); #endif /* __TMVA__ */ TFile *fOut = TFile::Open(outFile.c_str(), "recreate"); data_t data; // Book histograms const int nMcRecMult = 75; TArrayD xMult(nMcRecMult + 1); xMult[0] = -0.5; for (int i = 1; i <= nMcRecMult; i++) { if (xMult[i - 1] < 50) xMult[i] = xMult[i - 1] + 1; // 1 - 50 else if (xMult[i - 1] < 100) xMult[i] = xMult[i - 1] + 2; // 51 - 75 else if (xMult[i - 1] < 200) xMult[i] = xMult[i - 1] + 10; // 76 - 85 else xMult[i] = xMult[i - 1] + 100; // 86 -100 } TH1D *McRecMulT = new TH1D("McRecMulT", "Reconstructable multiplicity for trigger Mc Vertex", nMcRecMult, xMult.GetArray()); struct Name_t { const Char_t *Name; const Char_t *Title; }; const Name_t HCases[3] = { {"Any", "Any vertex matched with MC == 1"}, {"Good", "The best rank vertex with MC == 1"}, {"Bad", "The best rank vertex with MC != 1"} }; const Name_t Plots[4] = { {"Mult" , "the reconstructed (uncorrected) track multiplicity versus Reconstructable multiplicity"}, {"MultQA" , "the reconstructed (corrected for QA) track multiplicity versus Reconstructable multiplicity"}, {"McRecMul", "Reconstructable multiplicity"}, {"YvsX" , "Bad versus Good value"} }; /* h p */ TH1 *hists[3][4]; for (int h = 0; h < 3; h++) { for (int p = 0; p < 4; p++) { TString Name(Plots[p].Name); Name += HCases[h].Name; TString Title(Plots[p].Title); Title += " for "; Title += HCases[h].Title; Title += " vertex"; if (p < 2) hists[h][p] = new TH2D(Name, Title, nMcRecMult, xMult.GetArray(), nMcRecMult, xMult.GetArray()); else if (p == 2) hists[h][p] = new TH1D(Name, Title, nMcRecMult, xMult.GetArray()); } } TNtuple *VertexG = new TNtuple("VertexG", "good vertex & global params info", vnames); TNtuple *VertexB = new TNtuple("VertexB", "bad vertex & global params info", vnames); // ---------------------------------------------- StMuDstMaker *maker = new StMuDstMaker(0, 0, "", file, "st:MuDst.root", 1e9); // set up maker in read mode // 0,0 this mean read mode // dir read all files in this directory // file bla.lis real all file in this list, if (file!="") dir is ignored // filter apply filter to filenames, multiple filters are separated by ':' // 10 maximum number of file to read maker->SetStatus("*", 0); std::vector<std::string> activeBranchNames = { "MuEvent", "PrimaryVertices", "StStMuMcVertex", "StStMuMcTrack" }; // Set Active braches for (const auto& branchName : activeBranchNames) maker->SetStatus(branchName.c_str(), 1); TChain *tree = maker->chain(); Long64_t nentries = tree->GetEntries(); nevent = TMath::Min(nevent, nentries); std::cout << nentries << " events in chain " << nevent << " will be read." << std::endl; tree->SetCacheSize(-1); //by setting the read cache to -1 we set it to the AutoFlush value when writing tree->SetCacheLearnEntries(1); //one entry is sufficient to learn tree->SetCacheEntryRange(0, nevent); for (Long64_t ev = 0; ev < nevent; ev++) { if (maker->Make()) break; StMuDst *muDst = maker->muDst(); // get a pointer to the StMuDst class, the class that points to all the data StMuEvent *muEvent = muDst->event(); // get a pointer to the class holding event-wise information int referenceMultiplicity = muEvent->refMult(); // get the reference multiplicity TClonesArray *PrimaryVertices = muDst->primaryVertices(); int nPrimaryVertices = PrimaryVertices->GetEntriesFast(); TClonesArray *MuMcVertices = muDst->mcArray(0); int nMuMcVertices = MuMcVertices->GetEntriesFast(); TClonesArray *MuMcTracks = muDst->mcArray(1); int nMuMcTracks = MuMcTracks->GetEntriesFast(); if ( nevent >= 10 && ev % int(nevent*0.1) == 0 ) { std::cout << "Event #" << ev << "\tRun\t" << muEvent->runId() << "\tId: " << muEvent->eventId() << " refMult= " << referenceMultiplicity << "\tPrimaryVertices " << nPrimaryVertices << "\t" << " " << nMuMcVertices << "\t" << " " << nMuMcTracks << std::endl; } // const Double_t field = muEvent->magneticField()*kilogauss; if (! nMuMcVertices || ! nMuMcTracks || nPrimaryVertices <= 0) { std::cout << "Ev. " << ev << " has no MC information ==> skip it" << std::endl; std::cout << "OR no reconstructed verticies found" << std::endl; continue; } // Count number of MC tracks at a vertex with TPC reconstructable tracks std::multimap<int, int> Mc2McHitTracks; for (int m = 0; m < nMuMcTracks; m++) { StMuMcTrack *McTrack = (StMuMcTrack *) MuMcTracks->UncheckedAt(m); if (McTrack->No_tpc_hit() < 15) continue; Mc2McHitTracks.insert(std::pair<int, int>(McTrack->IdVx(), McTrack->Id())); } // This is the "reconstructable" track multiplicity int nMcTracksWithHits = Mc2McHitTracks.count(1); // Let's skip events in which we do not expect to reconstruct any tracks // (and thus vertex) from the primary vertex if (nMcTracksWithHits <= 0) continue; // This is our denominator histogram for efficiencies McRecMulT->Fill(nMcTracksWithHits); // ============= Build map between Rc and Mc vertices std::map<StMuPrimaryVertex *, StMuMcVertex *> reco2McVertices; TArrayF vertexRanks(nPrimaryVertices); int mcMatchedVertexIndex = -1; // any vertex with MC==1 and highest reconstrated multiplicity. int vertexMaxMultiplicity = -1; // First loop over all verticies in this event. There is at least one // must be available for (int recoVertexIndex = 0; recoVertexIndex < nPrimaryVertices; recoVertexIndex++) { vertexRanks[recoVertexIndex] = -1e10; StMuPrimaryVertex *recoVertex = (StMuPrimaryVertex *) PrimaryVertices->UncheckedAt(recoVertexIndex); if ( !AcceptVX(recoVertex) ) continue; // Check Mc if (recoVertex->idTruth() < 0 || recoVertex->idTruth() > nMuMcVertices) { std::cout << "ERROR: Illegal idTruth " << recoVertex->idTruth() << " The track is ignored" << std::endl; continue; } StMuMcVertex *mcVertex = (StMuMcVertex *) MuMcVertices->UncheckedAt(recoVertex->idTruth() - 1); if (mcVertex->Id() != recoVertex->idTruth()) { std::cout << "ERROR: Mismatched idTruth " << recoVertex->idTruth() << " and mcVertex Id " << mcVertex->Id() << " The vertex is ignored" << std::endl; continue; } reco2McVertices[recoVertex] = mcVertex; vertexRanks[recoVertexIndex] = recoVertex->ranking(); if (recoVertex->idTruth() == 1 && recoVertex->noTracks() > vertexMaxMultiplicity) { mcMatchedVertexIndex = recoVertexIndex; vertexMaxMultiplicity = recoVertex->noTracks(); } FillData(data, recoVertex); #ifdef __TMVA__ Float_t *dataArray = &data.beam; for (size_t j = 0; j < inputVec->size(); j++) (*inputVec)[j] = dataArray[j]; vertexRanks[recoVertexIndex] = classReader->GetMvaValue( *inputVec ); #endif } // If we reconstructed a vertex which matches the MC one we fill the // numerator of the "Any" efficiency histogram if (mcMatchedVertexIndex != -1) { StMuPrimaryVertex *recoVertexMatchedMc = (StMuPrimaryVertex*) PrimaryVertices->UncheckedAt(mcMatchedVertexIndex); double nTracks = recoVertexMatchedMc->noTracks(); double nTracksQA = nTracks * recoVertexMatchedMc->qaTruth() / 100.; hists[0][0]->Fill(nMcTracksWithHits, nTracks); hists[0][1]->Fill(nMcTracksWithHits, nTracksQA); hists[0][2]->Fill(nMcTracksWithHits); } // Now deal with the highest rank vertex int maxRankVertexIndex = TMath::LocMax(nPrimaryVertices, vertexRanks.GetArray()); StMuPrimaryVertex *recoVertexMaxRank = (StMuPrimaryVertex*) PrimaryVertices->UncheckedAt(maxRankVertexIndex); StMuMcVertex *mcVertex = reco2McVertices[recoVertexMaxRank]; double nTracks = recoVertexMaxRank->noTracks(); double nTracksQA = nTracks * recoVertexMaxRank->qaTruth() / 100.; // Fill numerator for "good" and "bad" efficiencies int h = ( mcVertex && mcVertex->Id() == 1) ? 1 : 2; hists[h][0]->Fill(nMcTracksWithHits, nTracks); hists[h][1]->Fill(nMcTracksWithHits, nTracksQA); hists[h][2]->Fill(nMcTracksWithHits); // Proceed with filling ntuple only if requested by the user if ( !fillNtuple ) continue; // Second loop over all verticies in this event for (int recoVertexIndex = 0; recoVertexIndex < nPrimaryVertices; recoVertexIndex++) { StMuPrimaryVertex *recoVertex = (StMuPrimaryVertex *) PrimaryVertices->UncheckedAt(recoVertexIndex); if ( !AcceptVX(recoVertex) ) continue; StMuMcVertex *mcVertex = reco2McVertices[recoVertex]; if ( !mcVertex ) { std::cout << "No Match from RC to MC" << std::endl; continue; } if (vtxeval::gDebugFlag) { std::cout << Form("Vx[%3i]", recoVertexIndex) << *recoVertex << " " << *mcVertex; int nMcTracksWithHitsatL = Mc2McHitTracks.count(recoVertex->idTruth()); std::cout << Form("Number of McTkHit %4i rank %8.3f", nMcTracksWithHitsatL, vertexRanks[recoVertexIndex]); } int IdPar = mcVertex->IdParTrk(); if (IdPar > 0 && IdPar <= nMuMcTracks) { StMuMcTrack *mcTrack = (StMuMcTrack *) MuMcTracks->UncheckedAt(IdPar - 1); if (mcTrack && vtxeval::gDebugFlag) std::cout << " " << mcTrack->GeName(); } FillData(data, recoVertex); double nTracks = recoVertex->noTracks(); if (mcVertex->Id() == 1 && nTracks == vertexMaxMultiplicity) {// good VertexG->Fill(&data.beam); } else { // bad VertexB->Fill(&data.beam); } } if ( !gROOT->IsBatch() ) { if (vtxeval::ask_user()) return; } else { vtxeval::gDebugFlag = false; } } fOut->Write(); }
LRESULT HexView::OnKeyDown(UINT nVirtualKey, UINT nRepeatCount, UINT nFlags) { BOOL fForceUpdate = FALSE; bool fCtrlDown = IsKeyDown(VK_CONTROL); bool fShiftDown = IsKeyDown(VK_SHIFT); size_w oldoffset = m_nCursorOffset; fForceUpdate = !IsKeyDown(VK_SHIFT); if(nVirtualKey == VK_CONTROL || nVirtualKey == VK_SHIFT || nVirtualKey == VK_MENU) return 0; switch(nVirtualKey) { case VK_ESCAPE: fForceUpdate = TRUE; break; case VK_INSERT: if(fCtrlDown) { OnCopy(); } else if(fShiftDown) { OnPaste(); } else { if(m_nEditMode == HVMODE_INSERT) m_nEditMode = HVMODE_OVERWRITE; else if(m_nEditMode == HVMODE_OVERWRITE) m_nEditMode = HVMODE_INSERT; NotifyParent(HVN_EDITMODE_CHANGE); } return 0; case 'z': case 'Z': m_nSubItem = 0; if(fCtrlDown) Undo(); return 0; // CTRL+Y redo case 'y': case 'Y': m_nSubItem = 0; if(fCtrlDown) Redo(); return 0; case VK_DELETE: // can only erase when in Insert mode if(m_nEditMode == HVMODE_INSERT || CheckStyle(HVS_ALWAYSDELETE) && (m_nEditMode == HVMODE_INSERT || m_nEditMode == HVMODE_OVERWRITE) && SelectionSize() == 0) { ForwardDelete(); } else if(m_nEditMode != HVMODE_READONLY) { BYTE b[] = { 0 }; FillData(b, 1, SelectionSize()); } return 0; case VK_BACK: // can only erase when in Insert mode if(m_nEditMode == HVMODE_INSERT || CheckStyle(HVS_ALWAYSDELETE) && (m_nEditMode == HVMODE_INSERT || m_nEditMode == HVMODE_OVERWRITE)) { BackDelete(); } else { //PostMessage(m_hWnd, WM_KEYDOWN, INPUT inp = { INPUT_KEYBOARD }; inp.ki.wVk = VK_LEFT; SendInput(1, &inp, sizeof(inp)); } return 0; case VK_LEFT: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_HSCROLL, SB_LINEUP, 0L); return 0; } if(m_nCursorOffset > 0) m_nCursorOffset--; m_fCursorAdjustment = FALSE; break; case VK_RIGHT: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_HSCROLL, SB_LINEDOWN, 0L); return 0; } if(m_nCursorOffset < m_pDataSeq->size()) { m_nCursorOffset++; if(m_nCursorOffset == m_pDataSeq->size() && m_pDataSeq->size() % m_nBytesPerLine == 0) m_fCursorAdjustment = TRUE; else m_fCursorAdjustment = FALSE; } break; case VK_UP: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_VSCROLL, SB_LINEUP, 0L); return 0; } if(m_nCursorOffset > (unsigned)m_nBytesPerLine) m_nCursorOffset -= m_nBytesPerLine; break; case VK_DOWN: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_VSCROLL, SB_LINEDOWN, 0L); return 0; } m_nCursorOffset += min((size_w)m_nBytesPerLine, m_pDataSeq->size() - m_nCursorOffset); // if in the last partial line, don't go to end of file, rather // stay at "bottom" of file/window if(m_nCursorOffset >= m_pDataSeq->size() && !m_fCursorAdjustment) { // test if in a partial line if( oldoffset % m_nBytesPerLine < m_pDataSeq->size() % m_nBytesPerLine || m_pDataSeq->size() % m_nBytesPerLine == 0) { m_nCursorOffset = oldoffset; fForceUpdate = TRUE; } } break; case VK_HOME: //if ctrl held down, then scroll the viewport around! if(fCtrlDown) { m_nCursorOffset = 0; PostMessage(m_hWnd, WM_VSCROLL, SB_TOP, 0L); } else { if(m_fCursorAdjustment && m_nCursorOffset > 0) m_nCursorOffset--; m_nCursorOffset -= m_nCursorOffset % m_nBytesPerLine; } m_fCursorAdjustment = FALSE; break; case VK_END: if(IsKeyDown(VK_CONTROL)) { m_nCursorOffset = m_pDataSeq->size(); if(m_nCursorOffset % m_nBytesPerLine == 0) m_fCursorAdjustment = TRUE; PostMessage(m_hWnd, WM_VSCROLL, SB_BOTTOM, 0L); } else { // if not already at very end of line if(m_fCursorAdjustment == FALSE) { if(m_pDataSeq->size() - m_nBytesPerLine >= m_nCursorOffset && m_pDataSeq->size() >= m_nBytesPerLine) { m_nCursorOffset += m_nBytesPerLine - (m_nCursorOffset % m_nBytesPerLine); m_fCursorAdjustment = TRUE; } else { m_nCursorOffset += m_pDataSeq->size()-m_nCursorOffset; } } if(m_nCursorOffset >= m_pDataSeq->size() && m_pDataSeq->size() % m_nBytesPerLine == 0) m_fCursorAdjustment = TRUE; } break; case VK_PRIOR: // pageup m_nCursorOffset -= min(m_nCursorOffset, (size_w)m_nBytesPerLine * m_nWindowLines); break; case VK_NEXT: // pagedown m_nCursorOffset += min(m_pDataSeq->size() - m_nCursorOffset, (size_w)m_nBytesPerLine * m_nWindowLines); if(m_nCursorOffset >= m_pDataSeq->size() && m_pDataSeq->size() % m_nBytesPerLine == 0) { m_fCursorAdjustment = TRUE; } break; case VK_TAB: m_nWhichPane ^= 1; fForceUpdate = TRUE; if(m_ColourList[HVC_SELECTION] != m_ColourList[HVC_SELECTION2]) { InvalidateRange(m_nSelectionStart, m_nSelectionEnd); } break; default: // don't know what this key is, so exit return 0; } m_nSubItem = 0; if(m_nCursorOffset != oldoffset || fForceUpdate) { // SHIFT key being held down? if(IsKeyDown(VK_SHIFT)) { // extend the selection m_nSelectionEnd = m_nCursorOffset; InvalidateRange(oldoffset, m_nSelectionEnd); } else if(nVirtualKey != VK_TAB) { // clear any selection if(m_nSelectionEnd != m_nSelectionStart) InvalidateRange(m_nSelectionEnd, m_nSelectionStart); m_nSelectionEnd = m_nCursorOffset; m_nSelectionStart = m_nCursorOffset; } ScrollToCaret(); NotifyParent(HVN_CURSOR_CHANGE); if(nVirtualKey == VK_NEXT || nVirtualKey == VK_PRIOR) { RefreshWindow(); } } return 0; }
void LoadNodeRecursive(FbxModelData* aModel,AnimationData& aAnimation,FbxNode* aNode,FbxAMatrix& aParentOrientation, FbxPose* aPose, FbxAnimLayer* aCurrentAnimLayer, int parentBone) { parentBone; FbxAMatrix lGlobalPosition = GetGlobalPosition(aNode, static_cast<FbxTime>(0.0f), aPose, &aParentOrientation); FbxNodeAttribute* lNodeAttribute = aNode->GetNodeAttribute(); if (lNodeAttribute && lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eSkeleton) { return; } CU::Matrix44f fixMatrix; fixMatrix = CU::Matrix44<float>::CreateReflectionMatrixAboutAxis(CU::Vector3f(1, 0, 0)); FbxAMatrix lGeometryOffset = GetGeometry(aNode); FbxAMatrix lGlobalOffPosition = lGlobalPosition * lGeometryOffset; FbxAMatrix lRotationOffset = GetRotaionPivot(aNode); aModel->myRotationPivot = fixMatrix * CreateMatrix(lRotationOffset) * fixMatrix; aModel->myOrientation = fixMatrix * CreateMatrix(lGlobalOffPosition) * fixMatrix; int boneId = -1; if (lNodeAttribute) { if(lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eMesh) { aModel->myData = new ModelData(); aModel->myData->myLayout.Init(8); // Geometry offset. // it is not inherited by the children. FillData(aModel->myData, aNode, &aAnimation); } else if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eLight) { FBXLight* newLight = new FBXLight(); FbxLight* light = aNode->GetLight(); newLight->myIntensity = static_cast<float>(light->Intensity); auto color = light->Color.Get(); newLight->myColor = CU::Vector3<float>(static_cast<float>(color.mData[0]), static_cast<float>(color.mData[1]), static_cast<float>(color.mData[2])); auto type = light->LightType.Get(); if (type == FbxLight::eDirectional) { newLight->myType = EDirectionalLight; } else if (type == FbxLight::ePoint) { newLight->myType = EPointLight; } else if (type == FbxLight::eSpot) { newLight->myInnerAngle = static_cast<float>(light->InnerAngle); newLight->myOuterAngle = static_cast<float>(light->OuterAngle); } aModel->myLight = newLight; } else if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eCamera) { aModel->myCamera = new Camera(); auto orgCamera = aNode->GetCamera(); aModel->myCamera->myFov = static_cast<float>(orgCamera->FieldOfViewY); } FbxTimeSpan animationInterval; if (aNode->GetAnimationInterval(animationInterval)) { aModel->myAnimationCurves = new AnimationCurves(); aModel->myAnimationCurves->myRotationCurve[0] = aNode->LclRotation.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_X); aModel->myAnimationCurves->myRotationCurve[1] = aNode->LclRotation.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y); aModel->myAnimationCurves->myRotationCurve[2] = aNode->LclRotation.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z); aModel->myAnimationCurves->myRotationCurve[3] = aNode->LclRotation.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_ROTATION); aModel->myAnimationCurves->myScalingCurve[0] = aNode->LclScaling.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_X); aModel->myAnimationCurves->myScalingCurve[1] = aNode->LclScaling.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y); aModel->myAnimationCurves->myScalingCurve[2] = aNode->LclScaling.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z); aModel->myAnimationCurves->myTtranslationCurve[0] = aNode->LclTranslation.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_X); aModel->myAnimationCurves->myTtranslationCurve[1] = aNode->LclTranslation.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y); aModel->myAnimationCurves->myTtranslationCurve[2] = aNode->LclTranslation.GetCurve(aCurrentAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z); int nrOfKeys = 0; nrOfKeys; float startTime = (float)animationInterval.GetStart().GetSecondDouble(); float endTime = (float)animationInterval.GetStop().GetSecondDouble(); aModel->myAnimatedOrientation.Init((int)((endTime - startTime) / (1.0f / 24.0f))); for (float currentTime = startTime; currentTime < endTime; currentTime += 1.0f / 24.0f) { FbxTime time; time.SetSecondDouble(currentTime); KeyFrame animationFrame; animationFrame.myTime = currentTime; animationFrame.myMatrix = fixMatrix * CreateMatrix(aNode->EvaluateLocalTransform(time)) * fixMatrix; aModel->myAnimatedOrientation.Add(animationFrame); } } } const int lChildCount = aNode->GetChildCount(); if(lChildCount > 0) { aModel->myChilds.Init(lChildCount); for (int lChildIndex = 0; lChildIndex < lChildCount; ++lChildIndex) { aModel->myChilds.Add(new FbxModelData()); LoadNodeRecursive(aModel->myChilds.GetLast(), aAnimation, aNode->GetChild(lChildIndex), lGlobalPosition , aPose, aCurrentAnimLayer, boneId); } } }
void IncrementalSelectListBase::OnSearch(cb_unused wxCommandEvent& event) { FillData(); }
ERROR_CODE ProcessCommand(void) { ERROR_CODE ErrorCode = NO_ERR; //return error code COMMAND_STRUCT CmdStruct; // switch on the command and fill command structure. switch ( AFP_Command ) { // erase all case ERASE_ALL: CmdStruct.SEraseAll.ulFlashStartAddr = FLASH_START_ADDR; //FlashStartAddress ErrorCode = (ERROR_CODE) ADIM29W64DEntryPoint.adi_pdd_Control(NULL, CNTRL_ERASE_ALL, &CmdStruct ); break; // erase sector case ERASE_SECT: CmdStruct.SEraseSect.nSectorNum = AFP_Sector; // Sector Number to erase CmdStruct.SEraseSect.ulFlashStartAddr = FLASH_START_ADDR; // FlashStartAddress ErrorCode = (ERROR_CODE) ADIM29W64DEntryPoint.adi_pdd_Control(NULL, CNTRL_ERASE_SECT, &CmdStruct); break; // fill case FILL: ErrorCode = FillData( AFP_Offset, AFP_Count, AFP_Stride, AFP_Buffer ); break; // get manufacturer and device codes case GET_CODES: CmdStruct.SGetCodes.pManCode = (unsigned long *)&AFP_ManCode; // Manufacturer Code CmdStruct.SGetCodes.pDevCode = (unsigned long *)&AFP_DevCode; // Device Code CmdStruct.SGetCodes.ulFlashStartAddr = FLASH_START_ADDR; ErrorCode = (ERROR_CODE) ADIM29W64DEntryPoint.adi_pdd_Control(NULL, CNTRL_GET_CODES, &CmdStruct); break; // get sector number based on address case GET_SECTNUM: CmdStruct.SGetSectNum.ulOffset = AFP_Offset; // offset from the base address CmdStruct.SGetSectNum.pSectorNum = (unsigned long *)&AFP_Sector; //Sector Number ErrorCode = (ERROR_CODE) ADIM29W64DEntryPoint.adi_pdd_Control(NULL, CNTRL_GET_SECTNUM, &CmdStruct); break; // get sector number start and end offset case GET_SECSTARTEND: CmdStruct.SSectStartEnd.nSectorNum = AFP_Sector; // Sector Number CmdStruct.SSectStartEnd.pStartOffset = &AFP_StartOff;// sector start address CmdStruct.SSectStartEnd.pEndOffset = &AFP_EndOff; // sector end address ErrorCode = (ERROR_CODE) ADIM29W64DEntryPoint.adi_pdd_Control(NULL, CNTRL_GET_SECSTARTEND, &CmdStruct ); break; // read case READ: ErrorCode = ReadData( AFP_Offset, AFP_Count, AFP_Stride, AFP_Buffer ); break; // reset case RESET: CmdStruct.SReset.ulFlashStartAddr = FLASH_START_ADDR; //Flash start address ErrorCode = (ERROR_CODE) ADIM29W64DEntryPoint.adi_pdd_Control(NULL, CNTRL_RESET, &CmdStruct); break; // write case WRITE: ErrorCode = WriteData( AFP_Offset, AFP_Count, AFP_Stride, AFP_Buffer ); break; // no command or unknown command do nothing case NO_COMMAND: default: // set our error ErrorCode = UNKNOWN_COMMAND; break; } // clear the command AFP_Command = NO_COMMAND; return(ErrorCode); }
void WSortView::FillData(unsigned int schema, size_t arraysize) { if (arraysize == 0) arraysize = 1; ResetArray(arraysize); if (schema == 0) // Shuffle of [1,n] { for (size_t i = 0; i < m_array.size(); ++i) m_array[i] = ArrayItem(i+1); std::random_shuffle(m_array.begin(), m_array.end()); } else if (schema == 1) // Ascending [1,n] { for (size_t i = 0; i < m_array.size(); ++i) m_array[i] = ArrayItem(i+1); } else if (schema == 2) // Descending [1,n] { for (size_t i = 0; i < m_array.size(); ++i) m_array[i] = ArrayItem(m_array.size() - i); } else if (schema == 3) // Cubic skew of [1,n] { for (size_t i = 0; i < m_array.size(); ++i) { // normalize to [-1,+1] double x = (2.0 * (double)i / m_array.size()) - 1.0; // calculate x^3 double v = x * x * x; // normalize to array size double w = (v + 1.0) / 2.0 * arraysize + 1; // decrease resolution for more equal values w /= 3.0; m_array[i] = ArrayItem(w + 1); } std::random_shuffle(m_array.begin(), m_array.end()); } else if (schema == 4) // Quintic skew of [1,n] { for (size_t i = 0; i < m_array.size(); ++i) { // normalize to [-1,+1] double x = (2.0 * (double)i / m_array.size()) - 1.0; // calculate x^5 double v = x * x * x * x * x; // normalize to array size double w = (v + 1.0) / 2.0 * arraysize + 1; // decrease resolution for more equal values w /= 3.0; m_array[i] = ArrayItem(w + 1); } std::random_shuffle(m_array.begin(), m_array.end()); } else if (schema == 5) // shuffled n-2 equal values in [1,n] { m_array[0] = ArrayItem(1); for (size_t i = 1; i < m_array.size()-1; ++i) { m_array[i] = ArrayItem( arraysize / 2 + 1 ); } m_array[m_array.size()-1] = ArrayItem(arraysize); std::random_shuffle(m_array.begin(), m_array.end()); } else if (schema == 6) // almost sorted values in [1,n] { for (size_t i = 0; i < m_array.size(); ++i) m_array[i] = ArrayItem(i+1); auto arraysize = m_array.size(); std::uniform_int_distribution<std::size_t> dist{0, arraysize}; std::random_device gen; std::size_t permutations = arraysize / 30; // magic numbers ftw! for(std::size_t i=0; i < permutations; ++i) std::swap(m_array[dist(gen)], m_array[dist(gen)]); } else // fallback { return FillData(0, arraysize); } FinishFill(); }