bool RenameFile(const wxString& src, const wxString& dst) { wxFileName fname1(Manager::Get()->GetMacrosManager()->ReplaceMacros(src)); wxFileName fname2(Manager::Get()->GetMacrosManager()->ReplaceMacros(dst)); NormalizePath(fname1, wxEmptyString); NormalizePath(fname2, wxEmptyString); if (!SecurityAllows(_T("RenameFile"), wxString::Format(_T("%s -> %s"), fname1.GetFullPath().c_str(), fname2.GetFullPath().c_str()))) return false; if (!wxFileExists(fname1.GetFullPath())) return false; return wxRenameFile(fname1.GetFullPath(), fname2.GetFullPath()); }
/* -------------------------------- Main ---------------------------------- */ int main() { std::string fname1("screenwriter:fontone.dat"); std::string fname2("screenwriter:fonttwo.dat"); std::string fname3("imageloader:imageone.dat"); std::string fname4("imageloader:imagetwo.dat"); std::string fname5("imageloader:imagethree.dat"); MenuResourceManager mrm; std::shared_ptr<MenuResourceBase> p1 = mrm.requestResource(fname1); std::shared_ptr<MenuResourceBase> p2 = mrm.requestResource(fname1); std::shared_ptr<MenuResourceBase> p3 = mrm.requestResource(fname2); std::shared_ptr<MenuResourceBase> p4 = mrm.requestResource(fname3); std::shared_ptr<MenuResourceBase> p5 = mrm.requestResource(fname4); std::shared_ptr<MenuResourceBase> p6 = mrm.requestResource(fname5); unsigned int n( std::thread::hardware_concurrency() ); std::cout << n << " concurrent threads are supported.\n"; unsigned N(0); while (true) { // Simulate a graphix engine loop mrm.manageResources(); std::cout << "Hi, I'm the main thread, waiting for my children threads to finish!\n"; std::cout << "COUNT: " << N << "\n"; std::this_thread::sleep_for( std::chrono::milliseconds(100) ); mrm.printLoad(); if ( p1 && p1.get()->is_loaded() ) p1.reset(); if ( p2 && p2.get()->is_loaded() ) p2.reset(); ++N; } std::cout << "Hi, I'm Main after the threads finished loading!\n"; }
void MakeSkimQAPlots(TString dataset = "") { gStyle->SetMarkerStyle(20); gStyle->SetLineWidth(3); gStyle->SetPadColor(10); gStyle->SetCanvasColor(10); gStyle->SetTitleFont(42, "XYZ"); gStyle->SetTitleSize(0.06, "XYZ"); gStyle->SetTitleXOffset(0.7); gStyle->SetTitleYOffset(1.05); TString fname1("mumu.recolevel." + dataset + ".root"); TString fname2("ee.recolevel." + dataset + ".root"); // TFile *f1 = new TFile(fname1); // TFile *f2 = new TFile(fname2); // TTree *t1 = f1->Get("ntp1"); // TTree *t2 = f2->Get("ntp1"); TChain *t1 = new TChain("ntp1"); t1->Add("crab_0_071121_090253/res/mumu.recolevel_*.root"); TChain *t2 = new TChain("ntp1"); t2->Add("crab_0_071121_102409/res/ee.recolevel_*.root"); TH1F *hpsim = new TH1F("hpsim","hpsim",50,2.5,4.5); TH1F *hpsie = new TH1F("hpsie","hpsie",50,2.5,4.5); TH1F *hupsm = new TH1F("hupsm","hupsm",50,8,12); TH1F *hupse = new TH1F("hupse","hupse",50,8,12); TH1F *hzm = new TH1F("hzm","hzm",50,60,120); TH1F *hze = new TH1F("hze","hze",50,60,120); TCanvas *c1 = new TCanvas("c1","#mu^{+}#mu^{-}",1400,800); c1->Divide(3,3); c1->cd(1); hpsim->SetXTitle("#psi mass"); t1->Draw("MuMu_mass >> hpsim"); c1->cd(2); hupsm->SetXTitle("#Upsilon mass"); t1->Draw("MuMu_mass >> hupsm"); c1->cd(3); hzm->SetXTitle("Z mass"); t1->Draw("MuMu_mass >> hzm"); c1->cd(4); t1->Draw("MuonCand_pt"); htemp->SetXTitle("p_{T} (#mu)"); htemp->Draw(); c1->cd(5); t1->Draw("MuonCand_pt[0]-MuonCand_pt[1]"); htemp->SetXTitle("#Delta p_{T}"); htemp->Draw(); c1->cd(6); t1->Draw("MuMu_dphi"); htemp->SetXTitle("#Delta #phi"); htemp->Draw(); c1->cd(7); t1->Draw("CaloTower_eta"); htemp->SetXTitle("#eta (towers)"); htemp->Draw(); c1->cd(8); c1->SetLogy(); t1->Draw("CaloTower_e"); htemp->SetXTitle("E (towers)"); htemp->Draw(); c1->SetLogy(0); c1->cd(9); t1->Draw("nExtraCaloTowersE5"); htemp->SetXTitle("Extra towers (E > 5 GeV)"); htemp->Draw(); TString muname = "dimuons.skimqa." + dataset + ".png"; c1->SaveAs(muname); TCanvas *c2 = new TCanvas("c2","e^{+}e^{-}",1400,800); c2->Divide(3,3); c2->cd(1); hpsie->SetXTitle("#psi mass"); t2->Draw("ElEl_mass >> hpsie"); c2->cd(2); hupse->SetXTitle("#Upsilon mass"); t2->Draw("ElEl_mass >> hupse"); c2->cd(3); hze->SetXTitle("Z mass"); t2->Draw("ElEl_mass >> hze"); c2->cd(4); t2->Draw("EleCand_et"); htemp->SetXTitle("E_{T} (e)"); htemp->Draw(); c2->cd(5); t2->Draw("EleCand_et[0]-EleCand_et[1]"); htemp->SetXTitle("#Delta E_{T}"); htemp->Draw(); c2->cd(6); t2->Draw("ElEl_dphi"); htemp->SetXTitle("#Delta #phi"); htemp->Draw(); c2->cd(7); t2->Draw("CaloTower_eta"); htemp->SetXTitle("#eta (towers)"); htemp->Draw(); c2->cd(8); c2->SetLogy(); t2->Draw("CaloTower_e"); htemp->SetXTitle("E (towers)"); htemp->Draw(); c2->SetLogy(0); c2->cd(9); t2->Draw("nExtraCaloTowersE5"); htemp->SetXTitle("Extra towers (E > 5 GeV)"); htemp->Draw(); TString elname = "dielectrons.skimqa." + dataset + ".png"; c2->SaveAs(elname); }
/****************************** * Cross-correlation analysis * ******************************/ void CalcCrossCorrelation (char * filename1 = "test.flu",char * filename2 = "test2.flu") { FILE * fp_params = fopen ("params.txt","rt"); if (fp_params == NULL) {LOG("!Could not find parameters file!"); return;} std::string fname1 (filename1); std::string fname2 (filename2); std::string out_name ("Xcorr"); if (fname1 != "test.flu" || fname2 != "test2.flu") //in case of custom filename, change the output name too out_name += fname1.substr(8,100) += fname2.substr(8,100); out_name += ".dat"; LOG ("*Output correlation to %s",out_name.c_str()); int num_steps = -1; double dT = -1.0, TAU_MAX = -1.0; int STEPS_PER_BIN = -1; if (fscanf (fp_params,"NUM_FRAMES %d\ndT %lf\nTAU_MAX %lf\nBIN_SIZE %d\n",&num_steps, &dT, &TAU_MAX, &STEPS_PER_BIN) != 4) { LOG ("!Error reading parameters file (params.txt)."); exit (2); } LOG ("*Calculating correlation for %s & %s.\nNUM_FRAMES %d, dT %f, TAU_MAX %f, BIN_SIZE %d\n",filename1,filename2,num_steps, dT, TAU_MAX, STEPS_PER_BIN); FILE * fp; fp = fopen (out_name.c_str(),"wt"); LOG ("Calculating cross correlation (Logarithmic)."); fprintf (fp, "@title \"G(tau), dT = %f\"\n",dT); int counter = 0; //counter=1; if (STEPS_PER_BIN <= 0) { //STEPS_PER_BIN undefined = varying bin size STEPS_PER_BIN = 1; //start form bin size = frame size, then increase double time = STEPS_PER_BIN*dT; Correlator * corr1; while (time <= TAU_MAX) { corr1 = new CrossCorrelator (filename1, filename2, dT, num_steps, STEPS_PER_BIN); printf ("STEPS_PER_BIN=%d.\n",STEPS_PER_BIN); double result = corr1->Calculate_correlation (time); fprintf (fp,"%5.9le %5.9le\n",time/1e12, result); printf ("g(%5.9le)=%5.9le\n", time/1e12, result); delete corr1; counter++; if (counter >= 4) {counter=0; STEPS_PER_BIN*=2;} //every 4 iterations, the bin size (and time change) is doubled time += STEPS_PER_BIN*dT; } } else { //STEPS_PER_BIN constant, as defined in params.txt LOG ("Calculating CROSS-correlation for BIN_SIZE = %d.",STEPS_PER_BIN); double time = STEPS_PER_BIN*dT; double TIME_STEP = STEPS_PER_BIN; Correlator * corr1 = new CrossCorrelator (filename1, filename2, dT, num_steps, STEPS_PER_BIN); printf ("STEPS_PER_BIN=%d.\n",STEPS_PER_BIN); while (time <= TAU_MAX) { double result = corr1->Calculate_correlation (time); fprintf (fp,"%5.9le %5.9le\n",time/1e12, result); printf ("g(%5.9le)=%5.9le\n", time/1e12, result); counter++; if (counter >= 4) {counter=0; TIME_STEP*=2;} //every 4 iterations, the correlation time increase is doubled time += TIME_STEP*dT; } delete corr1; } fclose (fp); LOG ("Finished calculating cross-correlation."); }