int parse( char *d, int i, char *c ) { int k, k2, k3, k4; #ifdef CHECKALL if( i > numstr(d) ) return -1; #endif /* ifdef CHECKALL */ k3 = -1; for(k=1; k<=i; k++) { k2 = wspace( d, k3+1 ); /* find start of substring */ if( k2 == -1 ) return -1; k3 = find( d, " \t", k2 ); /* find end of substring */ } if( k3 == -1 ) { k3 = strlen( d ); } else --k3; scopy( c, d, k2, k3-k2 ); // c[k4] = '\0'; return 0; }
int ft_printf(char *format, ...) { char *tmp; va_list arg; int i; int u; u = 0; i = -1; va_start(arg, format); while (format[++i]) { if (format[i] == '%') { tmp = ft_strsub(format, (i + 1), (ft_strlen(format) - i)); if (check_flag(format[i + 1]) != -1) u = u + (wflag(format[i + 1], arg, &i)); else if (check_space(tmp) != -1) u = u + (wspace(tmp, &i, format, arg)); else i = i + (check_nbr(tmp, &u, arg)); } else u = u + (wformat(format[i])); } va_end(arg); return (u); }
/* * Name: numstr - Returns number of substrings in a string * Input : d - a pointer to the string to search through * Output: returns number of substrings in string d * Example: numstr( "bob and Figment are THE Bombz " ) returns 6 */ int numstr( char *d ) { int k2, k3; int cnt = 0; k3 = -1; /* new version */ do { k2 = wspace( d, k3+1 ); /* find start of substring */ if( k2 == -1 ) /* if there is no start, we return */ return cnt; k3 = find( d, " \t", k2 ); /* find end of substring */ if( k3 == -1 ) return ++cnt; ++cnt; /* increase counter if there is a start & a finish */ } while( k3 != -1 ); return -1; }
void createWorkspace(){ gSystem->Load("libHiggsAnalysisCombinedLimit.so"); TFile *outfile = new TFile("workspace.root","RECREATE"); RooWorkspace wspace("w","w"); RooRealVar met("met","E_{T}^{miss}",200,1000); RooArgList vars(met); // Templates TFile* templatesfile = new TFile("templates.root"); // ---------------------------- SIGNAL REGION -------------------------------------------------------------------// // Data addTemplate("data_obs_SR", vars, wspace, (TH1F*)templatesfile->Get("datahist")); // Signal shape addTemplate("DM_SR", vars, wspace, (TH1F*)templatesfile->Get("sig1hist")); // Znunu background TH1F* znn_SR_hist = (TH1F*)templatesfile->Get("zinvhist"); RooArgList znn_SR_bins; makeBinList("Znunu_SR", met, wspace, znn_SR_hist, znn_SR_bins); // WJets background TH1F* wln_SR_hist = (TH1F*)templatesfile->Get("wjethist"); RooArgList wln_SR_bins; vector<pair<RooRealVar*, TH1*> > wln_SR_syst; RooRealVar* wln_SR_re1 = new RooRealVar("WJets_SR_RenScale1" , "", 0., -5., 5.); RooRealVar* wln_SR_fa1 = new RooRealVar("WJets_SR_FactScale1", "", 0., -5., 5.); RooRealVar* wln_SR_re2 = new RooRealVar("WJets_SR_RenScale2" , "", 0., -5., 5.); RooRealVar* wln_SR_fa2 = new RooRealVar("WJets_SR_FactScale2", "", 0., -5., 5.); RooRealVar* wln_SR_pdf = new RooRealVar("WJets_SR_PDF" , "", 0., -5., 5.); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(NULL , (TH1F*)templatesfile->Get("ZW_EWK"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_re1, (TH1F*)templatesfile->Get("ZW_RenScale1"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_fa1, (TH1F*)templatesfile->Get("ZW_FactScale1"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_re2, (TH1F*)templatesfile->Get("ZW_RenScale2"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_fa2, (TH1F*)templatesfile->Get("ZW_FactScale2"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_pdf, (TH1F*)templatesfile->Get("ZW_PDF"))); if (!connectWZ) makeBinList("WJets_SR", met, wspace, wln_SR_hist, wln_SR_bins); else makeConnectedBinList("WJets_SR", met, wspace, (TH1F*)templatesfile->Get("zwjcorewkhist"), wln_SR_syst, znn_SR_bins, &wln_SR_bins); TH1F* qcdhist = (TH1F*)templatesfile->Get("qbkghist"); qcdhist->Scale(2.0); // Other MC backgrounds addTemplate("ZJets_SR" , vars, wspace, (TH1F*)templatesfile->Get("zjethist")); addTemplate("Top_SR" , vars, wspace, (TH1F*)templatesfile->Get("tbkghist")); //addTemplate("QCD_SR" , vars, wspace, (TH1F*)templatesfile->Get("qbkghist")); addTemplate("QCD_SR" , vars, wspace, qcdhist); addTemplate("Dibosons_SR" , vars, wspace, (TH1F*)templatesfile->Get("dbkghist")); // ---------------------------- CONTROL REGION (Dimuon) -----------------------------------------------------------------// addTemplate("data_obs_ZM", vars, wspace, (TH1F*)templatesfile->Get("datahistzmm")); vector<pair<RooRealVar*, TH1*> > znn_ZM_syst; makeConnectedBinList("Znunu_ZM", met, wspace, (TH1F*)templatesfile->Get("zmmcorhist"), znn_ZM_syst, znn_SR_bins); // Other MC backgrounds in dimuon control region addTemplate("WJets_ZM" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistzmm")); addTemplate("Top_ZM" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistzmm")); addTemplate("QCD_ZM" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistzmm")); addTemplate("Dibosons_ZM" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistzmm")); // ---------------------------- CONTROL REGION (Dielectron) -----------------------------------------------------------------// addTemplate("data_obs_ZE" , vars, wspace, (TH1F*)templatesfile->Get("datahistzee")); vector<pair<RooRealVar*, TH1*> > znn_ZE_syst; makeConnectedBinList("Znunu_ZE", met, wspace, (TH1F*)templatesfile->Get("zeecorhist"), znn_ZE_syst, znn_SR_bins); // Other MC backgrounds in dielectron control region addTemplate("WJets_ZE" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistzee")); addTemplate("Top_ZE" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistzee")); addTemplate("QCD_ZE" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistzee")); addTemplate("Dibosons_ZE" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistzee")); // ---------------------------- CONTROL REGION (Photon+Jets) -----------------------------------------------------------------// addTemplate("data_obs_GJ" , vars, wspace, (TH1F*)templatesfile->Get("datahistgam")); vector<pair<RooRealVar*, TH1*> > znn_GJ_syst; RooRealVar* znn_GJ_re1 = new RooRealVar("Znunu_GJ_RenScale1" , "", 0., -5., 5.); RooRealVar* znn_GJ_fa1 = new RooRealVar("Znunu_GJ_FactScale1", "", 0., -5., 5.); RooRealVar* znn_GJ_re2 = new RooRealVar("Znunu_GJ_RenScale2" , "", 0., -5., 5.); RooRealVar* znn_GJ_fa2 = new RooRealVar("Znunu_GJ_FactScale2", "", 0., -5., 5.); RooRealVar* znn_GJ_pdf = new RooRealVar("Znunu_GJ_PDF" , "", 0., -5., 5.); RooRealVar* znn_GJ_fpc = new RooRealVar("Znunu_GJ_Footprint" , "", 0., -5., 5.); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(NULL , (TH1F*)templatesfile->Get("ZG_EWK"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_re1, (TH1F*)templatesfile->Get("ZG_RenScale1"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fa1, (TH1F*)templatesfile->Get("ZG_FactScale1"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_re2, (TH1F*)templatesfile->Get("ZG_RenScale2"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fa2, (TH1F*)templatesfile->Get("ZG_FactScale2"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_pdf, (TH1F*)templatesfile->Get("ZG_PDF"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fpc, (TH1F*)templatesfile->Get("ZG_Footprint"))); makeConnectedBinList("Znunu_GJ", met, wspace, (TH1F*)templatesfile->Get("gamcorewkhist"), znn_GJ_syst, znn_SR_bins); // Other MC backgrounds photon+jets control region addTemplate("QCD_GJ" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistgam")); // ---------------------------- CONTROL REGION (Single muon) -----------------------------------------------------------------// addTemplate("data_obs_WM" , vars, wspace, (TH1F*)templatesfile->Get("datahistwmn")); vector<pair<RooRealVar*, TH1*> > wln_WM_syst; makeConnectedBinList("WJets_WM", met, wspace, (TH1F*)templatesfile->Get("wmncorhist"), wln_WM_syst, wln_SR_bins); // Other MC backgrounds in single muon control region addTemplate("ZJets_WM" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistwmn")); addTemplate("Top_WM" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistwmn")); addTemplate("QCD_WM" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistwmn")); addTemplate("Dibosons_WM" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistwmn")); // ---------------------------- CONTROL REGION (Single electron) -----------------------------------------------------------------// addTemplate("data_obs_WE" , vars, wspace, (TH1F*)templatesfile->Get("datahistwen")); vector<pair<RooRealVar*, TH1*> > wln_WE_syst; makeConnectedBinList("WJets_WE", met, wspace, (TH1F*)templatesfile->Get("wencorhist"), wln_WE_syst, wln_SR_bins); // Other MC backgrounds in single electron control region addTemplate("ZJets_WE" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistwen")); addTemplate("Top_WE" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistwen")); addTemplate("QCD_WE" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistwen")); addTemplate("Dibosons_WE" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistwen")); // ---------------------------- Write out the workspace -----------------------------------------------------------------// outfile->cd(); wspace.Write(); outfile->Close(); }
void update(MMSP::grid<2,MMSP::vector<double> >& grid, int steps) { int rank=0; #ifdef MPI_VERSION rank = MPI::COMM_WORLD.Get_rank(); #endif for (int d=0; d<2; d++) { dx(grid,d) = deltaX; if (MMSP::x0(grid,d)==MMSP::g0(grid,d)) MMSP::b0(grid,d) = Neumann; // enumerated in MMSP.utility.hpp else if (MMSP::x1(grid,d)==MMSP::g1(grid,d)) MMSP::b1(grid,d) = Neumann; // enumerated in MMSP.utility.hpp } ghostswap(grid); MMSP::grid<2,MMSP::vector<double> > update(grid); for (int d=0; d<2; d++) { dx(update,d) = deltaX; if (MMSP::x0(update,d)==MMSP::g0(update,d)) MMSP::b0(update,d) = Neumann; // enumerated in MMSP.utility.hpp else if (MMSP::x1(update,d)==MMSP::g1(update,d)) MMSP::b1(update,d) = Neumann; // enumerated in MMSP.utility.hpp } MMSP::grid<2,double> wspace(grid,1); for (int d=0; d<2; d++) { dx(wspace,d) = deltaX; if (MMSP::x0(wspace,d)==MMSP::g0(wspace,d)) MMSP::b0(wspace,d) = Neumann; // enumerated in MMSP.utility.hpp else if (MMSP::x1(wspace,d)==MMSP::g1(wspace,d)) MMSP::b1(wspace,d) = Neumann; // enumerated in MMSP.utility.hpp } for (int step=0; step<steps; step++) { for (int n=0; n<nodes(grid); n++) { MMSP::vector<int> x=position(grid,n); double sum = 0.0; for (int i=1; i<fields(grid); i++) sum += std::pow(grid(x)[i],2); double C = grid(x)[0]; double lap = onelap(grid, x, 0); wspace(x) = -A*(C-Cm) + B*std::pow(C-Cm,3) + Da*std::pow(C-Ca,3) + Db*std::pow(C-Cb,3) - g*(C-Ca)*sum - kappa*lap; } ghostswap(wspace); double energy = 0.0; double mass = 0.0; for (int n=0; n<nodes(grid); n++) { MMSP::vector<int> x=position(grid,n); double lap = laplacian(wspace, x); double C = grid(x)[0]; update(x)[0] = C + dt*D*lap; double sum = 0.0; for (int i=1; i<fields(grid); i++) sum += std::pow(grid(x)[i],2); for (int i=1; i<fields(grid); i++) { double phase = grid(x)[i]; lap = onelap(grid, x, i); update(x)[i] = phase - dt*L*(df2deta(C,phase) + df3deta(phase,sum) - kappa*lap); } mass += dx(grid)*dy(grid)*update(x)[0]; energy += dx(grid)*dy(grid)*energydensity(update(x)); } #ifdef MPI_VERSION double myEnergy=energy; double myMass=mass; MPI::COMM_WORLD.Reduce(&myEnergy,&energy,1,MPI_DOUBLE,MPI_SUM,0); MPI::COMM_WORLD.Reduce(&myMass,&mass,1,MPI_DOUBLE,MPI_SUM,0); #endif #ifndef DEBUG if (rank==0) std::cout<<energy<<'\t'<<mass<<'\n'; #endif swap(grid,update); ghostswap(grid); } #ifndef DEBUG if (rank==0) std::cout<<std::flush; #endif }
static IPTR mNew(struct IClass *cl, Object *obj, struct opSet *msg) { struct data temp; memset(&temp,0,sizeof(temp)); if((obj = (Object *)DoSuperNew(cl,obj, MUIA_HelpNode, "WIN", MUIA_Window_ID, MAKE_ID('M', 'W', 'I', 'N'), MUIA_Window_Title, getString(MSG_Win_WinTitle), MUIA_Window_ScreenTitle, getString(MSG_App_ScreenTitle), WindowContents, VGroup, Child, temp.reg = RegisterObject, MUIA_Background, MUII_RegisterBack, MUIA_CycleChain, TRUE, MUIA_Register_Titles, tabs, /* Browsers */ Child, temp.browsers = appListObject, MUIA_AppList_Type, MUIV_AppList_Type_Browser, End, /* Mailers */ Child, temp.mailers = appListObject, MUIA_AppList_Type, MUIV_AppList_Type_Mailer, End, /* FTPs */ Child, temp.FTPs = appListObject, MUIA_AppList_Type, MUIV_AppList_Type_FTP, End, /* Miscellaneous */ Child, temp.misc = VGroup, MUIA_HelpNode, "MISCS", /* Defaults */ Child, VGroup, GroupFrameT(getString(MSG_Misc_Defaults)), Child, HGroup, Child, ColGroup(2), Child, temp.show = ocheckmark(MSG_Misc_Show,MSG_Misc_Show_Help), Child, ollabel1(MSG_Misc_Show), Child, temp.toFront = ocheckmark(MSG_Misc_Bring,MSG_Misc_Bring_Help), Child, ollabel1(MSG_Misc_Bring), Child, temp.newWin = ocheckmark(MSG_Misc_Open,MSG_Misc_Open_Help), Child, ollabel1(MSG_Misc_Open), Child, temp.launch = ocheckmark(MSG_Misc_Launch,MSG_Misc_Launch_Help), Child, ollabel1(MSG_Misc_Launch), End, Child, HSpace(0), End, Child, VSpace(0), End, /* Options */ Child, VGroup, GroupFrameT(getString(MSG_Misc_Options)), Child, HGroup, Child, ColGroup(2), Child, temp.prepend = ocheckmark(MSG_Misc_Prepend,MSG_Misc_Prepend_Help), Child, ollabel1(MSG_Misc_Prepend), Child, temp.mailto = ocheckmark(MSG_Misc_UseMailer,MSG_Misc_UseMailer_Help), Child, ollabel1(MSG_Misc_UseMailer), Child, temp.useFTP = ocheckmark(MSG_Misc_UseFTP,MSG_Misc_UseFTP_Help), Child, ollabel1(MSG_Misc_UseFTP), End, Child, HSpace(0), End, Child, VSpace(0), End, End, End, /* Buttons */ Child, HGroup, Child, temp.save = obutton(MSG_Win_Save,MSG_Win_Save_Help), Child, wspace(16), Child, temp.use = obutton(MSG_Win_Use,MSG_Win_Use_Help), Child, wspace(16), Child, temp.apply = obutton(MSG_Win_Apply,MSG_Win_Apply_Help), Child, wspace(16), Child, temp.cancel = obutton(MSG_Win_Cancel,MSG_Win_Cancel_Help), End, End, TAG_MORE, msg->ops_AttrList)) != NULL) { struct data *data = INST_DATA(cl,obj); /* init instance data */ CopyMem(&temp,data,sizeof(*data)); data->browserList = (Object *)xget(data->browsers, MUIA_AppList_ListObj); data->mailerList = (Object *)xget(data->mailers, MUIA_AppList_ListObj); data->FTPList = (Object *)xget(data->FTPs, MUIA_AppList_ListObj); /* buttons */ set(obj,MUIA_Window_DefaultObject,data->browserList); /* window notifies */ DoMethod(obj,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2, MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit); /* buttons notifies */ DoMethod(data->save,MUIM_Notify,MUIA_Pressed,FALSE,(IPTR)obj,2,MUIM_Win_StorePrefs,MUIV_Win_StorePrefs_Save); DoMethod(data->use,MUIM_Notify,MUIA_Pressed,FALSE,(IPTR)obj,2,MUIM_Win_StorePrefs,MUIV_Win_StorePrefs_Use); DoMethod(data->apply,MUIM_Notify,MUIA_Pressed,FALSE,(IPTR)obj,2,MUIM_Win_StorePrefs,MUIV_Win_StorePrefs_Apply); DoMethod(data->cancel,MUIM_Notify,MUIA_Pressed,FALSE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit); } return (IPTR)obj; }