result_type unfold ( ast::paragraph const &source , ast::unfolded::staff &target ) { staff_converter unfold(target); return std::all_of(source.begin(), source.end(), apply_visitor(unfold)); }
void JSEdit::toggleFold(int line) { if (isFolded(line)) unfold(line); else fold(line); }
result_type operator()(ast::score& score) { if (!score.time_sigs.empty()) global_time_signature = score.time_sigs.front(); { std::vector<std::future<bool>> staves; for (ast::part &part: score.parts) { if (!part.empty()) { std::size_t const staff_count{part.front().paragraphs.size()}; for (std::size_t staff_index = 0; staff_index < staff_count; ++staff_index) { staves.emplace_back ( async( std::launch::async , std::move(annotate_staff<ErrorHandler>( error_handler , report_error , global_time_signature , score.key_sig )) , staff_index, std::ref(part)) ); } } } if (!all_of( begin(staves), end(staves) , mem_fun_ref(&std::future<bool>::get))) return false; } return unfold(score); }
result_type unfold ( ast::part const &source , ast::unfolded::part &target ) { BOOST_ASSERT(!source.empty()); size_t const staves{source.front().paragraphs.size()}; BOOST_ASSERT(std::all_of(std::next(source.begin()), source.end(), [staves](ast::section const §ion) -> bool { return section.paragraphs.size() == staves; })); for (unsigned int i = 0; i < staves; ++i) target.emplace_back(); for (ast::section const §ion: source) { int i = 0; for (ast::paragraph const ¶graph: section.paragraphs) { if (!unfold(paragraph, target.at(i++))) return false; } } std::size_t staff_nr = 0; for (ast::unfolded::staff &staff: target) { doubling_decoder undouble(report_error); if (!std::all_of(staff.begin(), staff.end(), apply_visitor(undouble))) return false; staff_nr += 1; } return true; }
t_sip_message *t_parser::parse(const string &s, list<string> &parse_errors_) { t_mutex_guard guard(mtx_parser); int ret; struct yy_buffer_state *b; msg = NULL; parse_errors.clear(); string x = unfold(s); b = yy_scan_string(x.c_str()); ret = yyparse(); yy_delete_buffer(b); if (ret != 0) { if (msg) { MEMMAN_DELETE(msg); delete msg; msg = NULL; } throw ret; } parse_errors_ = parse_errors; return msg; }
result_type unfold (ast::score &score) { for (ast::part const &part: score.parts) { score.unfolded_part.emplace_back(); if (!unfold(part, score.unfolded_part.back())) return false; } return true; }
TH1D* Unfold (TH1D* data, TH1D* res) { TH2D *mat = MatBuild(res); RooUnfoldResponse R(0, 0, mat); RooUnfoldBayes unfold(&R, data); TH1D* un = (TH1D*) unfold.Hreco(); return un; }
void unfold(vector<NestedInteger> &a) { // cout << a.size() << endl; // cout << "\t" << endl; // for (int i=a.size()-1; i>=0; --i) // if (a[i].isInteger()) cout << i << " " << endl; for (int i=a.size()-1; i>=0; --i) if (a[i].isInteger()) st.push(a[i].getInteger()); else unfold(a[i].getList()); }
result_type operator() (ast::measure const &measure) { ast::unfolded::measure unfolded_measure; unfolded_measure.ending = measure.ending; bool insert = true; for (ast::voice const &voice: measure.voices) { std::size_t voice_index = unfolded_measure.voices.size(); unfolded_measure.voices.emplace_back(); ast::unfolded::voice &new_voice = unfolded_measure.voices.back(); for (ast::partial_measure const &partial_measure: voice) { std::size_t const partial_measure_index = new_voice.size(); new_voice.emplace_back(); ast::unfolded::partial_measure &new_partial_measure = new_voice.back(); for (ast::partial_voice const &partial_voice: partial_measure) { std::size_t const partial_voice_index = new_partial_measure.size(); new_partial_measure.emplace_back(); sign_converter unfold( new_partial_measure.back() , voice_index, measure.voices.size() , partial_measure_index , partial_voice_index , prev_unfolded_measure ); for (ast::partial_voice::const_iterator sign = partial_voice.begin(); sign != partial_voice.end(); ++sign) { switch (apply_visitor(unfold, *sign)) { case sign_conversion_result::failed: return false; case sign_conversion_result::full_measure_simile: if (std::next(sign) == partial_voice.end()) { prev_unfolded_measure->count += 1; insert = false; } break; case sign_conversion_result::ok: break; } } } } } if (insert) { target.emplace_back(unfolded_measure); prev_unfolded_measure = boost::get<ast::unfolded::measure>(&target.back()); } return true; }
/** * Main function, calls all necessary function for unfolding the net * \param argc * \param argv * \return the exitcode */ int main (int argc, char **argv) { if (argc == 2 || argc == 3) { char *llnet = argv[argc-1]; char *stoptr_name = NULL; net = read_pep_net(llnet); nc_static_checks(net,stoptr_name); unfold(); if (argc == 3) { if (strcmp(argv[1], "-l")==0) write_ll_net(unf, cutoff_list, UNF_FALSE); else if (strcmp(argv[1], "-L")==0) write_ll_net(unf, cutoff_list, UNF_TRUE); else if (strcmp(argv[1], "-d")==0) write_dot_output(unf, cutoff_list); } else write_dot_output(unf, cutoff_list); } else usage(argv[0]); return exitcode; }
int compareFinalCSRho_v2(int analysisIs2D=0, int stopAt=0, int saveCS=0) { if (!DYTools::setup(analysisIs2D)) return retCodeError; // ---------------------------------------- // Main part TH2D *h2UnfYield1_global=NULL; TH2D *h2UnfYield2_global=NULL; TH2D *hEffRho1_global=NULL; TH2D *hEffRho2_global=NULL; TH2D *hAcc1_global=NULL; TH2D *hAcc2_global=NULL; TMatrixD *fsrInvUnf1_global=NULL; TMatrixD *fsrInvUnf2_global=NULL; TString rhoCorrFName="../../Results-DYee/root_files_reg/constants/DY_j22_19712pb_egamma_Unregressed_energy/covRhoFileSF_nMB41_asymHLT_Unregressed_energy-allSyst_100_v2.root"; TH2D* hRho=LoadMatrixFields(rhoCorrFName,1,"scaleFactor","scaleFactorErr",1); if (!hRho) return retCodeError; // ---------------------------------------------------------- // Unfolding // ============================================ // ---------------------------------------- // load signal yield and unfold it if (1) { TString path="../../Results-DYee/root_files_reg/"; TString yieldFName="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; TString yieldField="signalYieldDDbkg"; TH2D* h2SigYield=LoadHisto2D(yieldField,path+yieldFName,"",1); if (!h2SigYield) return retCodeError; TH2D *h2SigYield2=Clone(h2SigYield,"h2SigYield_divRho"); if (!multiplyHisto(h2SigYield2,hRho,0)) return retCodeError; //h2SigYield_global= Clone(h2SigYield,"h2SigYield_ini"); //if (!h2SigYield_global) return retCodeError; TMatrixD* UnfM1= loadMatrix(path+TString("constants/DY_j22_19712pb/detResponse_unfolding_constants1D.root"),"DetResponse",41,41,1); if (!UnfM1) return retCodeError; TH2D* detResp1= createHisto2D(*UnfM1,NULL, "detResponse_DYee","detResponse_DYee", _colrange_default,1,0.); if (!detResp1) return retCodeError; TMatrixD* UnfM2= new TMatrixD(*UnfM1); if (!UnfM2) return retCodeError; TH2D* detResp2= detResp1; if (!detResp2) return retCodeError; if (stopAt==1) { // compare the response matrices // ------------- begin inset TH2D* detRespDiff=Clone(detResp1,"detRespDiff"); detRespDiff->Add(detResp2,-1); detRespDiff->SetTitle("difference"); detResp1->GetZaxis()->SetRangeUser(0,1.); detResp2->GetZaxis()->SetRangeUser(0,1.); printProfileSums(detResp1); printProfileSums(detResp2); compareProfileSums(detResp1,detResp2); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); for (int i=1; i<3; ++i) { TPad *pad=(TPad*)cdiff->GetPad(i); pad->SetLogx(); pad->SetLogy(); } AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detResp1->Draw("COLZ"); cdiff->cd(2); detResp2->Draw("COLZ"); cdiff->cd(3); //detRespDiff->GetZaxis()->SetRangeUser(-0.01,0.); detRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); return retCodeStop; // ------------- end inset } TMatrixD invUnf1(*UnfM1); TMatrixD invUnf2(*UnfM2); double det; invUnf1.Invert(&det); invUnf2.Invert(&det); if (stopAt==2) { // compare the inverted response matrices // ------------- begin inset TH2D* detInvResp1= createHisto2D(invUnf1,NULL, "detInvResponse_DYee","detInvResponse_DYee", _colrange_default,0,0.); TH2D* detInvResp2= createHisto2D(invUnf2,NULL, "detInvResponse","detInvResponse", _colrange_default,0,0.); TH2D* detInvRespDiff=Clone(detInvResp1,"detInvRespDiff"); detInvRespDiff->Add(detInvResp2,-1); detInvRespDiff->SetTitle("difference"); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); for (int i=1; i<3; ++i) { TPad *pad=(TPad*)cdiff->GetPad(i); pad->SetLogx(); pad->SetLogy(); } AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detInvResp1->Draw("COLZ"); cdiff->cd(2); detInvResp2->Draw("COLZ"); cdiff->cd(3); detInvRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); return retCodeStop; // ------------- end inset } TH2D *h2Unf1=Clone(h2SigYield,"h2Unf_DYee"); TH2D *h2Unf2=Clone(h2SigYield,"h2Unf2"); if ( !unfold(h2Unf1, invUnf1, h2SigYield) || !unfold(h2Unf2, invUnf2, h2SigYield2) ) return retCodeError; h2UnfYield1_global=Clone(h2Unf1, "h2UnfYield1"); h2UnfYield2_global=Clone(h2Unf2, "h2UnfYield2"); if (!h2UnfYield1_global || !h2UnfYield2_global) return retCodeError; if (stopAt==3) { // ------------ begin inset TString label1="DYee"; TString label2="DYee (#rho corr)"; std::vector<int> colors; colors.push_back(kRed+1); colors.push_back(kBlue); // ---------------------------------- // Plot data TString yAxisLabel="unfolded yield"; std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h2Unf1); labelV.push_back(label1); hV.push_back(h2Unf2); labelV.push_back(label2); TCanvas *cx= plotProfiles("cxUnf",hV,labelV,&colors,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TCanvas *cy= plotProfiles("cerrUnf",hErrV,labelV,&colors,1, yAxisLabel + TString(" error")); cy->Update(); // ------------------------ end inset } } // ---------------------------------------------------------- // Load corrective factors: EffRho, Acc // ============================================ if (1) { for (int iter=0; iter<2; ++iter) { TCompareCase_t theCase=(iter==0) ? _cmp_EffRho : _cmp_Acc; TH2D* h1=NULL, *h2=NULL, *h3=NULL; TH2D *h1Syst=NULL; TString fname1,field1,field1err; TString fname2,field2,field2err; TString fname3,field3,field3err; TString label1="DYee", label2="DYeeRho", label3="unknown"; TString path1="../../Results-DYee/root_files_reg/"; TString path2=path1; TString path3=path1; int loadText2=0; int is1Dhisto2=0, is1Dhisto3=0; TString yAxisLabel="y"; switch(theCase) { case _cmp_RawYield: fname1="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; field1="Input/observedYield"; //fname2="raw_yield1D_EE.txt"; //loadText2=1; yAxisLabel="raw yield"; break; case _cmp_FakeBkg: fname1="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; field1="Input/fakeBackgroundFromData"; field1err="Input/fakeBackgroundFromDataSyst"; //fname2="fakeBkg1D_EE.txt"; //loadText2=1; yAxisLabel="fake bkg"; break; case _cmp_TrueBkg: fname1="yield/DY_j22_19712pb_ApplyEscale/bg-subtracted_yield_1D__peak20140220.root"; field1="Input/true2eBackgroundFromData"; field1err="Input/true2eBackgroundFromDataSyst"; //fname2="trueBkg1D_EE.txt"; //loadText2=1; yAxisLabel="true bkg"; break; case _cmp_Eff: fname1="constants/DY_j22_19712pb/efficiency_1D.root"; field1="hEfficiency"; fname2=fname1; field2=field2; //fname2="efficiencyTotal1D_EE.txt"; //loadText2=1; //fname3="acceff.root"; //field3="eff_postFSRcorr"; //is1Dhisto3=1; //label3="Alexey (acceff.root)"; yAxisLabel="efficiency"; break; case _cmp_MCeff: fname1="constants/DY_j22_19712pb/efficiency_1D.root"; field1="hEfficiency"; //fname2="acceff.root"; //field2="eff_postFSRcorr"; //is1Dhisto2=1; //label2="Alexey (acceff.root)"; yAxisLabel="MC efficiency"; break; case _cmp_EffRho: fname1="constants/DY_j22_19712pb/efficiency_1D.root"; field1="hEfficiency"; fname2=fname1; field2=field1; //fname2="efficiencyTotal1D_EE.txt"; //loadText2=1; yAxisLabel="efficiency #times #rho"; break; case _cmp_Acc: fname1="constants/DY_j22_19712pb/acceptance_1D.root"; field1="hAcceptance"; fname2=fname1; field2=field1; //fname2="acceptance1D_EE.txt"; //loadText2=1; //fname3="acceff.root"; //field3="acc_postFSRcorr"; //is1Dhisto3=1; //label3="Alexey (acceff.root)"; yAxisLabel="acceptance"; break; default: std::cout << "Not ready for the case\n"; return retCodeError; } // ---------------------------------- // Load data h1=LoadHisto2D(field1,path1+fname1,"",1); if (!h1) return retCodeError; if (field1err.Length()) { h1Syst=LoadHisto2D(field1err,path1+fname1,"",1); if (!h1Syst) return retCodeError; h1->Add(h1Syst,1.); } if (loadText2) { h2=loadTextFile(path2+fname2,"h2"); if (!h2) return retCodeError; } else if (is1Dhisto2) h2= loadHisto1D_convert_TH2D(path2+fname2,field2); else h2=LoadHisto2D(field2,path2+fname2,"",1); if (fname3.Length()) { if (is1Dhisto3) h3= loadHisto1D_convert_TH2D(path3+fname3,field3); } // ---------------------------------- // Special adjustments if (theCase==_cmp_EffRho) { // load the scale factors int check=0; if (check) { printHisto(h1); printHisto(hRho); } if (!multiplyHisto(h1,hRho,1)) return retCodeError; if (check) printHisto(h1); if (0) { TH2D *rhoRelErr=getRelError(hRho,"rhoRelErr",0); printHisto(rhoRelErr); } } if (theCase==_cmp_EffRho) { hEffRho1_global=Clone(h1,"hEffRho_DYee"); hEffRho2_global=Clone(h2,"hEffRho_DYeeRho"); if (!hEffRho1_global || !hEffRho2_global) return retCodeError; } else if (theCase==_cmp_Acc) { hAcc1_global=Clone(h1,"hAcc_DYee"); hAcc2_global=Clone(h2,"hAcc_DYeeRho"); } if (stopAt==4) { // ---------------------------------- // Plot data std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h1); labelV.push_back(label1); hV.push_back(h2); labelV.push_back(label2); if (h3) { hV.push_back(h3); labelV.push_back(label3); } TString cxName=Form("cxCorr_%d",iter); TCanvas *cx= plotProfiles(cxName,hV,labelV,NULL,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TString cyName=Form("cyCorr_%d",iter); TCanvas *cy= plotProfiles(cyName,hErrV,labelV,NULL,1, yAxisLabel + TString(" error")); cy->Update(); } } } // load corrective factors // ---------------------------------------------------------- // FSR unfolding // ============================================ if (1) { TFsrUnfCompareCase_t theCase=_cmp_fsrGood; // ---------------------------------- // Main part TString yAxisLabel="unfolded yield"; TString path="../../Results-DYee/root_files_reg/"; TString yieldFName="../../Results-DYee/root_files_reg/xsec/DY_j22_19712pb/xSec_preFsr_1DpostFsrFullSp.root"; TString yieldField="hpPostFsrFullSp_divLumi"; TH2D* h2PostFsrCS=LoadHisto2D(yieldField,path+yieldFName,"",1); if (!h2PostFsrCS) return retCodeError; TString fName=TString("constants/DY_j22_19712pb/detResponse_unfolding_constants1D.root"); TString tag; switch(theCase) { case _cmp_fsrGood: fName.ReplaceAll("detResponse","fsrGood"); tag="good"; break; case _cmp_fsrExact: fName.ReplaceAll("detResponse","fsrExact"); tag="exact"; break; default: std::cout << "macro is not ready for this case\n"; return retCodeError; } TMatrixD* UnfM1= loadMatrix(path+fName,"DetResponse",41,41,1); if (!UnfM1) return retCodeError; TString histoName1="detFSRResponse_DYee" + tag; TH2D* detResp1= createHisto2D(*UnfM1,NULL,histoName1,histoName1, _colrange_default,1,0.); detResp1->GetZaxis()->SetRangeUser(0,1); if (!detResp1) return retCodeError; TH2D* detResp2=detResp1; TMatrixD* UnfM2=UnfM1; if (stopAt==10) { // compare the response matrices // ------------- begin inset TH2D* detRespDiff=Clone(detResp1,"detRespDiff"); detRespDiff->Add(detResp2,-1); detRespDiff->SetTitle("difference"); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detResp1->Draw("COLZ"); cdiff->cd(2); detResp2->Draw("COLZ"); cdiff->cd(3); detRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); printHisto(detRespDiff); return retCodeStop; // ------------- end inset } TMatrixD invUnf1(*UnfM1); TMatrixD invUnf2(*UnfM2); double det; invUnf1.Invert(&det); invUnf2.Invert(&det); if (stopAt==11) { // compare the inverted response matrices // ------------- begin inset TH2D* detInvResp1= createHisto2D(invUnf1,NULL, "detInvResponse_DYee","detInvResponse_DYee", _colrange_default,0,0.); TH2D* detInvResp2= createHisto2D(invUnf2,NULL, "detInvResponse","detInvResponse", _colrange_default,0,0.); TH2D* detInvRespDiff=Clone(detInvResp1,"detInvRespDiff"); detInvRespDiff->Add(detInvResp2,-1); detInvRespDiff->SetTitle("difference"); TCanvas *cdiff=new TCanvas("cdiff","cdiff",1200,400); cdiff->Divide(3,1); AdjustFor2DplotWithHeight(cdiff); cdiff->cd(1); detInvResp1->Draw("COLZ"); cdiff->cd(2); detInvResp2->Draw("COLZ"); cdiff->cd(3); detInvRespDiff->Draw("COLZ"); //UnfM->Draw("COLZ"); cdiff->Update(); return retCodeStop; // ------------- end inset } TH2D *h2Unf1=Clone(h2PostFsrCS,"h2Unf_DYee"); TH2D *h2Unf2=Clone(h2PostFsrCS,"h2Unf2"); if ( !unfold(h2Unf1, invUnf1, h2PostFsrCS) || !unfold(h2Unf2, invUnf2, h2PostFsrCS) ) return retCodeError; fsrInvUnf1_global= new TMatrixD(invUnf1); fsrInvUnf2_global= new TMatrixD(invUnf2); if (!fsrInvUnf1_global || !fsrInvUnf2_global) return retCodeError; if (0) { // plot unfolded cross section TString label1="DYee"; TString label2="DYeeRho"; // ---------------------------------- // Plot data std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h2Unf1); labelV.push_back(label1); hV.push_back(h2Unf2); labelV.push_back(label2); TCanvas *cx= plotProfiles("cxFsr",hV,labelV,NULL,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TCanvas *cy= plotProfiles("cyFsr",hErrV,labelV,NULL,1, yAxisLabel + TString(" error")); cy->Update(); } } // load FSR unfolding // ---------------------------------------------------------------- // ---------------------------------------------------------- // Final calculation // ============================================ if (1) { TH2D* h2UnfEffRhoYield1= Clone(h2UnfYield1_global,"h2UnfEffRhoYield_DYee"); TH2D* h2UnfEffRhoYield2= Clone(h2UnfYield2_global,"h2UnfEffRhoYield_DYeeRho"); int multiply=0; // 1 - multiply, 0 - divide if (!multiplyHisto(h2UnfEffRhoYield1, hEffRho1_global, multiply) || !multiplyHisto(h2UnfEffRhoYield2, hEffRho2_global, multiply)) { return retCodeError; } TH2D* h2PostFsrYield1= Clone(h2UnfEffRhoYield1, "h2PostFsrYield_DYee"); TH2D* h2PostFsrYield2= Clone(h2UnfEffRhoYield2, "h2PostFsrYield_DYeeRho"); if (!multiplyHisto(h2PostFsrYield1, hAcc1_global, multiply) || !multiplyHisto(h2PostFsrYield2, hAcc2_global, multiply)) { return retCodeError; } TH2D* h2PostFsrCS1= Clone(h2PostFsrYield1, "h2PostFsrCS_DYee"); TH2D* h2PostFsrCS2= Clone(h2PostFsrYield2, "h2PostFsrCS_DYeeRho"); h2PostFsrCS1->Scale(1/DYTools::lumiAtECMS); h2PostFsrCS2->Scale(1/DYTools::lumiAtECMS); TH2D* h2PreFsrCS1= Clone(h2PostFsrCS1, "h2PreFsrCS_DYee"); TH2D* h2PreFsrCS2= Clone(h2PostFsrCS2, "h2PreFsrCS_DYeeRho"); if ( !unfold(h2PreFsrCS1, *fsrInvUnf1_global, h2PostFsrCS1) || !unfold(h2PreFsrCS2, *fsrInvUnf2_global, h2PostFsrCS2) ) { return retCodeError; } if (saveCS) { TString fname="cmp_UnfRho-20140604.root"; TFile fout(fname,"recreate"); if (!saveHisto(fout,h2PreFsrCS1,"","") || !saveHisto(fout,h2PreFsrCS2,"","")) { return retCodeError; } writeBinningArrays(fout,"compareAlexey/compareFinalCSRho.C"); fout.Close(); std::cout << "file <" << fout.GetName() << "> created\n"; } const int plotSteps[4]= { 1, 1, 1, 1 }; for (int iCase=0; iCase<4; ++iCase) { if (!plotSteps[iCase]) continue; TH2D *h1=NULL, *h2=NULL; TString canvTitle="cx"; TString yAxisLabel="y"; switch(iCase) { case 0: h1=h2UnfEffRhoYield1; h2=h2UnfEffRhoYield2; canvTitle.Append("_unfEffRhoYield"); yAxisLabel="N_{u}/(#epsilon#rho)"; break; case 1: h1=h2PostFsrYield1; h2=h2PostFsrYield2; canvTitle.Append("_postFsrYield"); yAxisLabel="N_{u}/(A#epsilon#rho)"; break; case 2: h1=h2PostFsrCS1; h2=h2PostFsrCS2; canvTitle.Append("_postFsrCS"); yAxisLabel="#sigma_{postFsr}=N_{u}/(A#epsilon#rhoL) [pb]"; break; case 3: h1=h2PreFsrCS1; h2=h2PreFsrCS2; canvTitle.Append("_preFsrCS"); yAxisLabel="#sigma_{preFsr} [pb]"; break; default: std::cout << "not ready for iCase=" << iCase << "\n"; return retCodeError; } if (!h1 || !h2) { std::cout << "histos were not assigned\n"; return retCodeError; } TString label1="DYee"; TString label2="DYeeRho"; // ---------------------------------- // Plot data std::vector<TH2D*> hV; std::vector<TString> labelV; hV.push_back(h1); labelV.push_back(label1); hV.push_back(h2); labelV.push_back(label2); TCanvas *cx= plotProfiles(canvTitle,hV,labelV,NULL,1, yAxisLabel); cx->Update(); // ---------------------------------- // Plot error if (0) { std::vector<TH2D*> hErrV; for (unsigned int i=0; i<hV.size(); ++i) { TH2D* hErr=Clone(hV[i],hV[i]->GetName() + TString("_err")); swapContentAndError(hErr); removeError(hErr); hErrV.push_back(hErr); } TCanvas *cy= plotProfiles(canvTitle+TString("_err"),hErrV,labelV,NULL,1, yAxisLabel + TString(" error")); cy->Update(); } } } return retCodeOk; }
void DisneyMaterialLayerUI::slot_fold_unfold_layer() { m_is_folded = !m_is_folded; m_is_folded ? fold() : unfold(); }
NestedIterator(vector<NestedInteger> &nestedList) { while (!st.empty()) st.pop(); unfold(nestedList); }
void LiteEditor::createActions() { LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor"); m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this); actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo); m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this); actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y"); m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this); actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut); m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this); actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy); m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this); actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste); m_selectAllAct = new QAction(tr("Select All"),this); actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll); m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this); #ifndef QT_NO_PRINTER m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this); m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this); m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this); #endif m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this); actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+["); m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this); actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]"); m_selectBlockAct = new QAction(tr("Select Block"),this); actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U"); m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this); actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E"); m_foldAct = new QAction(tr("Fold"),this); actionContext->regAction(m_foldAct,"Fold","Ctrl+<"); m_unfoldAct = new QAction(tr("Unfold"),this); actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>"); m_foldAllAct = new QAction(tr("Fold All"),this); actionContext->regAction(m_foldAllAct,"FoldAll",""); m_unfoldAllAct = new QAction(tr("Unfold All"),this); actionContext->regAction(m_unfoldAllAct,"UnfoldAll",""); connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold())); connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold())); connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll())); connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll())); m_gotoLineAct = new QAction(tr("Go To Line"),this); actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L"); m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this); m_lockAct->setEnabled(false); m_duplicateAct = new QAction(tr("Duplicate"),this); actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+Shift+D"); connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate())); m_deleteLineAct = new QAction(tr("Delete Line"),this); actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K"); connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine())); m_copyLineAct = new QAction(tr("Copy Line"),this); actionContext->regAction(m_copyLineAct,"CopyLine","Ctrl+Ins"); connect(m_copyLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(copyLine())); m_cutLineAct = new QAction(tr("Cut Line"),this); actionContext->regAction(m_cutLineAct,"CutLine","Shift+Del"); connect(m_cutLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(cutLine())); m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this); actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return"); connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore())); m_insertLineAfterAct = new QAction(tr("Insert Line After"),this); actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return"); connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter())); m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this); actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++"); m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this); actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-"); m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this); actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0"); m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this); actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace",""); m_wordWrapAct = new QAction(tr("Word Wrap (MimeType)"),this); m_wordWrapAct->setCheckable(true); actionContext->regAction(m_wordWrapAct,"WordWrap",""); m_codeCompleteAct = new QAction(tr("Code Complete"),this); #ifdef Q_OS_MAC actionContext->regAction(m_codeCompleteAct,"CodeComplete","Meta+Space"); #else actionContext->regAction(m_codeCompleteAct,"CodeComplete","Ctrl+Space"); #endif m_commentAct = new QAction(tr("Toggle Comment"),this); actionContext->regAction(m_commentAct,"Comment","Ctrl+/"); m_blockCommentAct = new QAction(tr("Toggle Block Commnet"),this); actionContext->regAction(m_blockCommentAct,"BlockComment","Ctrl+Shift+/"); m_autoIndentAct = new QAction(tr("Auto-indent Selection"),this); actionContext->regAction(m_autoIndentAct,"AutoIndent","Ctrl+I"); m_autoIndentAct->setVisible(false); m_tabToSpacesAct = new QAction(tr("Tab To Spaces (MimeType)"),this); actionContext->regAction(m_tabToSpacesAct,"TabToSpaces",""); m_tabToSpacesAct->setCheckable(true); m_lineEndingWindowAct = new QAction(tr("Line End Windows (\\r\\n)"),this); actionContext->regAction(m_lineEndingWindowAct,"LineEndingWindow",""); m_lineEndingWindowAct->setCheckable(true); m_lineEndingUnixAct = new QAction(tr("Line End Unix (\\n)"),this); actionContext->regAction(m_lineEndingUnixAct,"LineEndingUnix",""); m_lineEndingUnixAct->setCheckable(true); m_visualizeWhitespaceAct = new QAction(tr("Visualize Whitespace (Global)"),this); actionContext->regAction(m_visualizeWhitespaceAct,"VisualizeWhitespace",""); m_visualizeWhitespaceAct->setCheckable(true); m_commentAct->setVisible(false); m_blockCommentAct->setVisible(false); m_moveLineUpAction = new QAction(tr("Move Line Up"),this); actionContext->regAction(m_moveLineUpAction,"MoveLineUp","Ctrl+Shift+Up"); m_moveLineDownAction = new QAction(tr("Move Line Down"),this); actionContext->regAction(m_moveLineDownAction,"MoveLineDown","Ctrl+Shift+Down"); m_copyLineUpAction = new QAction(tr("Copy Line Up"),this); actionContext->regAction(m_copyLineUpAction,"CopyLineUp","Ctrl+Alt+Up"); m_copyLineDownAction = new QAction(tr("Copy Line Down"),this); actionContext->regAction(m_copyLineDownAction,"CopyLineDown","Ctrl+Alt+Down"); m_joinLinesAction = new QAction(tr("Join Lines"),this); actionContext->regAction(m_joinLinesAction,"JoinLines","Ctrl+J"); connect(m_codeCompleteAct,SIGNAL(triggered()),m_editorWidget,SLOT(codeCompleter())); // m_widget->addAction(m_foldAct); // m_widget->addAction(m_unfoldAct); // m_widget->addAction(m_gotoLineAct); // m_widget->addAction(m_gotoPrevBlockAct); // m_widget->addAction(m_gotoNextBlockAct); // m_widget->addAction(m_selectBlockAct); // m_widget->addAction(m_gotoMatchBraceAct); connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool))); connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo())); connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo())); connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut())); connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy())); connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste())); connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll())); connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock())); connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml())); #ifndef QT_NO_PRINTER connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf())); connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint())); connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview())); #endif connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock())); connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock())); connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace())); connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine())); connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize())); connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize())); connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize())); connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace())); connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool))); connect(m_commentAct,SIGNAL(triggered()),this,SLOT(comment())); connect(m_blockCommentAct,SIGNAL(triggered()),this,SLOT(blockComment())); connect(m_autoIndentAct,SIGNAL(triggered()),this,SLOT(autoIndent())); connect(m_tabToSpacesAct,SIGNAL(toggled(bool)),this,SLOT(tabToSpacesToggled(bool))); connect(m_visualizeWhitespaceAct,SIGNAL(toggled(bool)),this,SLOT(toggledVisualizeWhitespace(bool))); connect(m_moveLineUpAction,SIGNAL(triggered()),m_editorWidget,SLOT(moveLineUp())); connect(m_moveLineDownAction,SIGNAL(triggered()),m_editorWidget,SLOT(moveLineDown())); connect(m_copyLineUpAction,SIGNAL(triggered()),m_editorWidget,SLOT(copyLineUp())); connect(m_copyLineDownAction,SIGNAL(triggered()),m_editorWidget,SLOT(copyLineDown())); connect(m_joinLinesAction,SIGNAL(triggered()),m_editorWidget,SLOT(joinLines())); //connect(m_lineEndingWindowAct,SIGNAL(triggered()),this,SLOT(lineEndingWindow())); //connect(m_lineEndingUnixAct,SIGNAL(triggered()),this,SLOT(lineEndingUnixAct())); QActionGroup *group = new QActionGroup(this); group->addAction(m_lineEndingWindowAct); group->addAction(m_lineEndingUnixAct); connect(group,SIGNAL(triggered(QAction*)),this,SLOT(triggeredLineEnding(QAction*))); #ifdef Q_OS_WIN QClipboard *clipboard = QApplication::clipboard(); connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged())); clipbordDataChanged(); #endif }
/***************************************************************************** * * freq2time_adapt * transform freq. domain data to time domain. * Overlap and add transform output to recreate time sequence. * Blocks composed of multiple segments (i.e. all but long) have * input spectrums interleaved. * input: see below * output: see below * local static: * timeBuff time domain data fifo * globals: none * *****************************************************************************/ void freq2time_adapt(faacDecHandle hDecoder, byte blockType, /* input: blockType 0-3 */ Wnd_Shape *wnd_shape, /* input/output */ Float *freqInPtr, /* input: interleaved spectrum */ Float *timeBuff, /* transform state needed for each channel */ Float *ftimeOutPtr) /* output: 1/2 block of new time values */ { Float *transBuff, *transBuffPtr; int i, j; Float *timeBuffPtr, *destPtr; Float *timeOutPtr; transBuff = AllocMemory(2*BLOCK_LEN_LONG*sizeof(Float)); timeOutPtr = AllocMemory(BLOCK_LEN_LONG*sizeof(Float)); if (blockType == NORM_TYPE) { unfold (freqInPtr, transBuff, BLOCK_LEN_LONG); /* Do 1 LONG transform */ ITransformBlock (hDecoder, transBuff, LONG_BLOCK, wnd_shape, timeBuff); /* ch ); */ transBuffPtr = transBuff; timeBuffPtr = timeBuff; /* [ch]; */ destPtr = timeOutPtr; /* idimkovic: reduce loop overhead by unrolling */ for (i = BLOCK_LEN_LONG/16 - 1; i >= 0; --i) { *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; } /* Save second half as old data */ timeBuffPtr = timeBuff; /* [ch]; */ for (i = BLOCK_LEN_LONG/16 - 1; i >= 0; --i) { *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; } } else if (blockType == SHORT_TYPE) { /* Do 8 SHORT transforms */ if (hDecoder->dolbyShortOffset_f2t) destPtr = timeBuff + 4 * BLOCK_LEN_SHORT; /* DBS */ else destPtr = timeBuff + (BLOCK_LEN_LONG - BLOCK_LEN_SHORT) / 2; /* 448 */ for (i = 0; i < 8; i++) { unfold (freqInPtr, transBuff, BLOCK_LEN_SHORT ); /*was freqinPtr++, 8 .. mfd */ freqInPtr += BLOCK_LEN_SHORT; /* added mfd */ ITransformBlock (hDecoder, transBuff, SHORT_BLOCK, wnd_shape, timeBuff); /* Add first half of short window and old data */ transBuffPtr = transBuff; for (j = BLOCK_LEN_SHORT/16-1; j >= 0; --j) { *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; *destPtr++ += *transBuffPtr++; } /* Save second half of short window */ for (j = BLOCK_LEN_SHORT/16-1; j >= 0; --j) { *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; } destPtr -= BLOCK_LEN_SHORT; } /* Copy data to output buffer */ destPtr = timeOutPtr; timeBuffPtr = timeBuff; /* [ch]; */ for (i = BLOCK_LEN_LONG/16 - 1; i >= 0; --i) { *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; } /* Update timeBuff fifo */ destPtr = timeBuff; /* [ch]; */ for (i = BLOCK_LEN_LONG/16 - 1; i >= 0; --i) { *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; *destPtr++ = *timeBuffPtr++; } } else if (blockType == START_TYPE) { unfold(freqInPtr, transBuff, BLOCK_LEN_LONG); ITransformBlock (hDecoder, transBuff, START_FLAT_BLOCK, wnd_shape, timeBuff); /* Add first half and old data */ transBuffPtr = transBuff; timeBuffPtr = timeBuff; destPtr = timeOutPtr; for (i = BLOCK_LEN_LONG/16 - 1; i >= 0; --i) { *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; } /* Save second half as old data */ timeBuffPtr = timeBuff; for (i = BLOCK_LEN_LONG/16 - 1; i >= 0; --i) { *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; } hDecoder->dolbyShortOffset_f2t = 0; } else if (blockType == STOP_TYPE) { unfold (freqInPtr, transBuff, BLOCK_LEN_LONG); /* Do 1 LONG transforms */ ITransformBlock (hDecoder, transBuff, STOP_FLAT_BLOCK, wnd_shape, timeBuff); /* Add first half and old data */ transBuffPtr = transBuff; timeBuffPtr = timeBuff; destPtr = timeOutPtr; for (i = (BLOCK_LEN_LONG - NFLAT)/16 - 1; i>=0; --i) { *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; *destPtr++ = *transBuffPtr++ + *timeBuffPtr++; } for ( i = NFLAT/16-1; i>=0; --i) { *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; *destPtr++ = *transBuffPtr++; } /* Save second half as old data */ timeBuffPtr = timeBuff; for (i = BLOCK_LEN_LONG/16 - 1; i >= 0; --i ) { *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; *timeBuffPtr++ = *transBuffPtr++; } } i=0; do { *(ftimeOutPtr++) = (timeOutPtr[i]); i++; *(ftimeOutPtr++) = (timeOutPtr[i]); i++; *(ftimeOutPtr++) = (timeOutPtr[i]); i++; *(ftimeOutPtr++) = (timeOutPtr[i]); i++; *(ftimeOutPtr++) = (timeOutPtr[i]); i++; *(ftimeOutPtr++) = (timeOutPtr[i]); i++; *(ftimeOutPtr++) = (timeOutPtr[i]); i++; *(ftimeOutPtr++) = (timeOutPtr[i]); i++; } while(i<BLOCK_LEN_LONG); FreeMemory(timeOutPtr); FreeMemory(transBuff); }
void Unfold() { // usa gli errori degli istogrammi TH1::SetDefaultSumw2(); int const nSmear=250; // numero di bin nella matrice di migrazione -- dati Smeared int const nGen=100; // numero di bin nella matrice di migrazione -- dati Generator (binning meno fine, v. TUnfold) double const xminSmear=-3.; double const xmaxSmear=3.; double const xminGen=-3.; double const xmaxGen=3.; // la generazione avviene tra -3 e 3, ma la "rivelazione" (smearing) tra -2.5 e 2.5 per rimuovere gli effetti del bordo // ------------------ istogrammi -------------------------- // matrice delle migrazioni TH2D* migrMatrix = new TH2D ("migrMatrix", "Matrice di migrazione; smeared; generator", nSmear, xminSmear, xmaxSmear, nGen, xminGen, xmaxGen); // dati da unfoldare TH1D* data_smeared = new TH1D ("data_smeared", "Spettro dopo lo smearing; x; N", nSmear, xminSmear, xmaxSmear); TH1D* data_smeared_clone = new TH1D ("data_smeared_clone", "Spettro dopo lo smearing; x; N", nGen, xminGen, xmaxGen); // clone del precedente ma con il binning Gen per un plot sovraimposto // dati a livello generatore --> solo per confronto; questo istogramma non รจ disponibile in una misura reale TH1D* data_generator = new TH1D ("data_generator", "Spettro prima dello smearing; x; N", nGen, xminGen, xmaxGen); // risultato dell'unfolding TH1D* data_unfolded = new TH1D ("data_unfolded", "Spettro dopo l'unfolding; x; N", nGen, xminGen, xmaxGen); // ------------------ file di dati ----------------------- std::ifstream datafile_high_stat ("dati_high_statistics.txt"); std::ifstream datafile_sample ("dati_sample.txt"); // ------------------ riempi matrice di migrazione ------------- double buf; int count = 0; while (1) { if (count % 100000 == 0) {cout << count << endl;} datafile_high_stat >> buf; if (datafile_high_stat.eof()) {break;} migrMatrix->Fill(Smear(buf), buf); // x= smeared (detector); y = generator (MC) count++; } // --------------- riempi istogramma di dati -------------------- while (1) { if (count % 100000 == 0) {cout << count << endl;} datafile_sample >> buf; if (datafile_sample.eof()) {break;} data_generator -> Fill (buf); data_smeared -> Fill (Smear(buf)); data_smeared_clone -> Fill (Smear(buf)); count++; } // --------------- setup dell'unfolding ------------------------ TUnfold unfold(migrMatrix,TUnfold::kHistMapOutputVert, TUnfold::kRegModeCurvature, TUnfold::kEConstraintArea); if(unfold.SetInput(data_smeared)>=10000) {std::cout<<"Possibili errori nei risultati dell'unfold\n";} // parametro di regolarizzazione + esecuzione dell'unfold double tau = 0.0045; double unfold_status; unfold_status = unfold.DoUnfold(tau); if (unfold_status >= 1.) // do unfold restituisce il max coeficiente di correlazione {cout << "\n\n**ATTENZIONE**\n\nErrori durante l'unfold!\nI risultati successivi non sono validi\n\n";} // ---------------- recupera i risultati dell'unfold ------------ // binMap mappa linearmente i risultati dell'unfold nei bin dell'istogramma di output, e non salva under/overflow int *binMap=new Int_t[nGen+2]; for(Int_t i=1;i<=nGen;i++) {binMap[i]=i;} binMap[0]=-1; // no underflow binMap[nGen+1]=-1; // no overflow // recupera l'istogramma unfoldato unfold.GetOutput(data_unfolded,binMap); // ----------- disegna ---------------------------------- data_generator->SetLineColor(kBlue); data_unfolded->SetLineColor(kRed); data_smeared_clone->SetLineColor(kGreen+1); data_generator->SetLineWidth(1.5); data_unfolded->SetLineWidth(1.5); data_smeared_clone->SetLineWidth(1.5); TLegend* l = new TLegend (0.63, 0.68, 0.89, 0.89); l->AddEntry(data_generator, "Pre-smearing", "l"); l->AddEntry(data_smeared_clone, "Post-smearing (#sigma = 2#Deltax)", "l"); l->AddEntry(data_unfolded, "Unfolded con #tau = 0.0045", "l"); l->SetFillColor(kWhite); l->SetLineColor(kWhite); THStack* stack = new THStack ("stack", ";x;N"); stack->Add(data_generator); stack->Add(data_smeared_clone); stack->Add(data_unfolded); stack->SetMinimum(0.); TCanvas* c1 = new TCanvas; stack->Draw("nostack H"); //stack->GetHistogram()->GetXaxis()->SetTitle("x"); stack->Draw("nostack H"); l->Draw(); // stampa aree cout << "AREE (no u/o flow) -- (con u/o flow)" << endl; cout << "Generator: " << data_generator->Integral() << " " << data_generator->Integral(0, nGen+1) << endl; cout << "Smeared: " << data_smeared->Integral() << " " << data_smeared->Integral(0, nSmear+1) << endl; cout << "Unfolded: " << data_unfolded->Integral() << " " << data_unfolded->Integral(0, nGen+1) << endl; // ------------------- residui dopo unfold ---------------- TH1F *residui = new TH1F("residui","Bias;x;Generator - Unfolded",nGen,xminGen, xmaxGen); double err1, err2, errtot; for (Int_t i=1;i<=nGen;i++) { double diff = data_generator->GetBinContent(i) - data_unfolded->GetBinContent(i); err1 = data_generator->GetBinError(i); err2 = data_unfolded->GetBinError(i); errtot = err1 + err2; residui->SetBinContent(i,diff); residui->SetBinError(i, errtot); } gStyle->SetOptStat(0); TCanvas* c2 = new TCanvas; TLine * ll = new TLine (-3, 0, 3, 0); ll->SetLineColor(kBlack); ll->SetLineStyle(2); residui->Draw("H"); ll->Draw("same"); }
void LiteEditor::createActions() { LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor"); m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this); actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo); m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this); actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y"); m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this); actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut); m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this); actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy); m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this); actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste); m_selectAllAct = new QAction(tr("Select All"),this); actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll); m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this); #ifndef QT_NO_PRINTER m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this); m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this); m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this); #endif m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this); actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+["); m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this); actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]"); m_selectBlockAct = new QAction(tr("Select Block"),this); actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U"); m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this); actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E"); m_foldAct = new QAction(tr("Fold"),this); actionContext->regAction(m_foldAct,"Fold","Ctrl+<"); m_unfoldAct = new QAction(tr("Unfold"),this); actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>"); m_foldAllAct = new QAction(tr("Fold All"),this); actionContext->regAction(m_foldAllAct,"FoldAll",""); m_unfoldAllAct = new QAction(tr("Unfold All"),this); actionContext->regAction(m_unfoldAllAct,"UnfoldAll",""); connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold())); connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold())); connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll())); connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll())); m_gotoLineAct = new QAction(tr("Go To Line"),this); actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L"); m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this); m_lockAct->setEnabled(false); m_duplicateAct = new QAction(tr("Duplicate"),this); actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+D"); connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate())); m_deleteLineAct = new QAction(tr("Delete Line"),this); actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K"); connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine())); m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this); actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return"); connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore())); m_insertLineAfterAct = new QAction(tr("Insert Line After"),this); actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return"); connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter())); m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this); actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++;Ctrl+="); m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this); actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-"); m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this); actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0"); m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this); actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace",""); m_wordWrapAct = new QAction(tr("Word Wrap"),this); m_wordWrapAct->setCheckable(true); actionContext->regAction(m_wordWrapAct,"WordWrap",""); // m_widget->addAction(m_foldAct); // m_widget->addAction(m_unfoldAct); // m_widget->addAction(m_gotoLineAct); // m_widget->addAction(m_gotoPrevBlockAct); // m_widget->addAction(m_gotoNextBlockAct); // m_widget->addAction(m_selectBlockAct); // m_widget->addAction(m_gotoMatchBraceAct); connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool))); connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo())); connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo())); connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut())); connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy())); connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste())); connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll())); connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock())); connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml())); #ifndef QT_NO_PRINTER connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf())); connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint())); connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview())); #endif connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock())); connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock())); connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace())); connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine())); connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize())); connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize())); connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize())); connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace())); connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool))); QClipboard *clipboard = QApplication::clipboard(); connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged())); clipbordDataChanged(); }