/* Clone an object. The new object is owned by the cloning player */ static dbref clone_object(dbref player, dbref thing, const char *newname, int preserve) { dbref clone; clone = new_object(); Owner(clone) = Owner(player); Name(clone) = NULL; if (newname && *newname) set_name(clone, newname); else set_name(clone, Name(thing)); s_Pennies(clone, Pennies(thing)); AttrCount(clone) = 0; List(clone) = NULL; Locks(clone) = NULL; clone_locks(player, thing, clone); Zone(clone) = Zone(thing); Parent(clone) = Parent(thing); Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); if (!preserve) { clear_flag_internal(clone, "WIZARD"); clear_flag_internal(clone, "ROYALTY"); Warnings(clone) = 0; /* zap warnings */ Powers(clone) = new_flag_bitmask("POWER"); /* zap powers */ } else { Powers(clone) = clone_flag_bitmask("POWER", Powers(thing)); Warnings(clone) = Warnings(thing); if (Wizard(clone) || Royalty(clone) || Warnings(clone) || !null_flagmask("POWER", Powers(clone))) notify(player, T ("Warning: @CLONE/PRESERVE on an object with WIZ, ROY, @powers, or @warnings.")); } /* We give the clone the same modification time that its * other clone has, but update the creation time */ ModTime(clone) = ModTime(thing); CreTime(clone) = mudtime; Type(clone) = Type(thing); Contents(clone) = Location(clone) = Next(clone) = NOTHING; if (IsRoom(thing)) Exits(clone) = NOTHING; else Home(clone) = Home(thing); atr_cpy(clone, thing); queue_event(player, "OBJECT`CREATE", "%s,%s", unparse_objid(clone), unparse_objid(thing)); return clone; }
RooFitResult * fitTo(RooAbsPdf * pdf, RooDataSet * data, RooArgSet * cons = NULL, string opt = "" ) { //freopen ("tmp.txt","w",stdout); RooFitResult * res = NULL; if(cons!=NULL) res = pdf->fitTo(*data,PrintLevel(-1),Save(),NumCPU(2), ExternalConstraints(*cons),Warnings(false), Verbose(kFALSE), Minos(true)); else res = pdf->fitTo(*data,PrintLevel(-1),Save(),Warnings(false),NumCPU(2), Minos(true)); //freopen ("/dev/tty", "a", stdout); return res; }
static void check_topology_on(dbref player, dbref i) { warn_type flags; /* Skip it if it's NOWARN or the player checking is the owner and * is NOWARN. Also skip GOING objects. */ if (Going(i) || NoWarn(i)) return; /* If the owner is checking, use the flags on the object, and fall back * on the owner's flags as default. If it's not the owner checking * (therefore, an admin), ignore the object flags, use the admin's flags */ if (Owner(player) == Owner(i)) { if (!(flags = Warnings(i))) flags = Warnings(player); } else flags = Warnings(player); ct_generic(player, i, flags); switch (Typeof(i)) { case TYPE_ROOM: ct_room(player, i, flags); break; case TYPE_THING: ct_thing(player, i, flags); break; case TYPE_EXIT: ct_exit(player, i, flags); break; case TYPE_PLAYER: ct_player(player, i, flags); break; } return; }
/** Set warnings on an object. * \verbatim * This implements @warnings obj=warning list * \endverbatim * \param player the enactor. * \param name name of object to set warnings on. * \param warns list of warnings to set, space-separated. */ void do_warnings(dbref player, const char *name, const char *warns) { dbref thing; warn_type w, old; switch (thing = match_result(player, name, NOTYPE, MAT_EVERYTHING)) { case NOTHING: notify(player, T("I don't see that object.")); return; case AMBIGUOUS: notify(player, T("I don't know which one you mean.")); return; default: if (!controls(player, thing)) { notify(player, T("Permission denied.")); return; } if (IsGarbage(thing)) { notify(player, T("Why would you want to be warned about garbage?")); return; } break; } old = Warnings(thing); w = parse_warnings(player, warns); if (w != old) { Warnings(thing) = w; if (Warnings(thing)) notify_format(player, T("@warnings set to: %s"), unparse_warnings(Warnings(thing))); else notify(player, T("@warnings cleared.")); } else { notify(player, T("@warnings not changed.")); } }
/** Set up the default warnings on an object. * \param player object to set warnings on. */ void set_initial_warnings(dbref player) { Warnings(player) = W_NORMAL; return; }
/** Clone an object. * \verbatim * This is the top-level function for @clone, which creates a duplicate * of a (non-player) object. * \endverbatim * \param player the enactor. * \param name the name of the object to clone. * \param newname the name to give the duplicate. * \param preserve if 1, preserve ownership and privileges on duplicate. * \paran newdbref the (unparsed) dbref to give the object, or NULL to use the next free * \return dbref of the duplicate, or NOTHING. */ dbref do_clone(dbref player, char *name, char *newname, int preserve, char *newdbref) { dbref clone, thing; char dbnum[BUFFER_LEN]; thing = noisy_match_result(player, name, NOTYPE, MAT_EVERYTHING); if ((thing == NOTHING)) return NOTHING; if (newname && *newname && !ok_name(newname, IsExit(thing))) { notify(player, T("That is not a reasonable name.")); return NOTHING; } if (!controls(player, thing) || IsPlayer(thing) || (IsRoom(thing) && !command_check_byname(player, "@dig")) || (IsExit(thing) && !command_check_byname(player, "@open")) || (IsThing(thing) && !command_check_byname(player, "@create"))) { notify(player, T("Permission denied.")); return NOTHING; } /* don't allow cloning of destructed things */ if (IsGarbage(thing)) { notify(player, T("There's nothing left of it to clone!")); return NOTHING; } if (preserve && !Wizard(player)) { notify(player, T("You cannot @CLONE/PRESERVE. Use normal @CLONE instead.")); return NOTHING; } if (!make_first_free_wrapper(player, newdbref)) { return NOTHING; } /* make sure owner can afford it */ switch (Typeof(thing)) { case TYPE_THING: if (can_pay_fees(player, Pennies(thing))) { clone = clone_object(player, thing, newname, preserve); notify_format(player, T("Cloned: Object %s."), unparse_dbref(clone)); if (IsRoom(player)) moveto(clone, player, player, "cloned"); else moveto(clone, Location(player), player, "cloned"); current_state.things++; local_data_clone(clone, thing); real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING, global_eval_context.wenv, 0); return clone; } return NOTHING; break; case TYPE_ROOM: if (can_pay_fees(player, ROOM_COST)) { clone = clone_object(player, thing, newname, preserve); Exits(clone) = NOTHING; notify_format(player, T("Cloned: Room #%d."), clone); current_state.rooms++; local_data_clone(clone, thing); real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING, global_eval_context.wenv, 0); return clone; } return NOTHING; break; case TYPE_EXIT: /* For exits, we don't want people to be able to link it to a location they can't with @open. So, all this stuff. */ switch (Location(thing)) { case NOTHING: strcpy(dbnum, "#-1"); break; case HOME: strcpy(dbnum, "home"); break; case AMBIGUOUS: strcpy(dbnum, "variable"); break; default: strcpy(dbnum, unparse_dbref(Location(thing))); } if (newname && *newname) clone = do_real_open(player, newname, dbnum, NOTHING); else clone = do_real_open(player, Name(thing), dbnum, NOTHING); if (!GoodObject(clone)) { return NOTHING; } else { atr_cpy(clone, thing); clone_locks(player, thing, clone); Zone(clone) = Zone(thing); Parent(clone) = Parent(thing); Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); if (!preserve) { clear_flag_internal(clone, "WIZARD"); clear_flag_internal(clone, "ROYALTY"); Warnings(clone) = 0; /* zap warnings */ Powers(clone) = new_flag_bitmask("POWER"); /* zap powers */ } else { Warnings(clone) = Warnings(thing); Powers(clone) = clone_flag_bitmask("POWER", Powers(thing)); } if (Wizard(clone) || Royalty(clone) || Warnings(clone) || !null_flagmask("POWER", Powers(clone))) notify(player, T ("Warning: @CLONE/PRESERVE on an object with WIZ, ROY, @powers, or @warnings.")); notify_format(player, T("Cloned: Exit #%d."), clone); local_data_clone(clone, thing); return clone; } } return NOTHING; }
void Emissions::Read_HPMS_Map (void) { int count, type, subtype; char *record, *str_ptr; Type_Map map_rec, *map_ptr; Data_Group *data_ptr; Speed_Bin_File *file; //---- read the vehicle type map file ---- count = 0; record = hpms_map_file.Record (); while (hpms_map_file.Read ()) { str_ptr = Get_Integer (record, &type); if (type == 0 || str_ptr == NULL) continue; map_rec.Type (type); str_ptr = Get_Integer (str_ptr, &type); if (str_ptr == NULL) continue; map_rec.SubType (type); Get_Integer (str_ptr, &type); if (type == 0) continue; map_rec.Map (type); if (!hpms_type_map.Add (&map_rec)) { Error ("Adding Vehicle Type"); } count++; } hpms_map_file.Close (); //---- report the map data ---- Print (2, "Number of HPMS Type Maps = %d", count); Print (2, "Type SubType Map Label"); for (map_ptr = hpms_type_map.First (); map_ptr; map_ptr = hpms_type_map.Next ()) { Print (1, " %2d %2d %2d", map_ptr->Type (), map_ptr->SubType (), map_ptr->Map ()); } //---- check hpms types in speed bin files ---- for (data_ptr = data_group.First (); data_ptr; data_ptr = data_group.Next ()) { file = data_ptr->Speed_File (); //---- check the vehicle type ---- type = file->Vehicle_Type (); subtype = file->Veh_SubType (); if (hpms_type_map.Map (type, subtype) == 0) { Warning ("Group %d HPMS Type %d-%d is Not in the Type Map", data_ptr->Group (), type, subtype); } } if (Warnings () > 0) Show_Message (1); }
void fitEfficiency(float thres, float mLow=45, float mHigh=70, TString cutdef="pt_HLT>=20", TString cut_choice="HLT", TString dirIn="/data_CMS/cms/ndaci/ndaci_2012/HTauTau/TriggerStudy/SingleMu/MuMu/Run2012A_PRV1/Pairs/", TString dirResults="/home//llr/cms/ndaci/SKWork/macro/HTauTau/results/TriggerStudies/MuMu/Run2012A_PRV1/", TString lumi="200 pb", int nCPU=4, int color1=kBlack, int style1=kFullCircle, int color2=kRed, int style2=kOpenSquare, TString fileIn="*.root", TString image="eff_HLT_MuTau") { // STYLE // gROOT->Reset(); loadPresentationStyle(); gROOT->ForceStyle(); // OUTPUT // TString name_image = dirResults+"/"+image; ofstream fichier(name_image+".txt", ios::out); // BINNING // const int nbinsEB = 14; Double_t binsEB[nbinsEB] = {10., 14., 18., 20., 22., 26., 30., 40., 50., 60., 70., 80, 90, 100}; RooBinning binningEB = RooBinning(nbinsEB-1, binsEB, "binningEB"); const int nbinsEE = 14; Double_t binsEE[nbinsEE] = {10., 14., 18., 20., 22., 26., 30., 40., 50., 60., 70., 80, 90, 100}; RooBinning binningEE = RooBinning(nbinsEE-1, binsEE, "binningEE"); // EB/EE eta cuts // TString etacutEB="eta>-1.479 && eta<1.479", etacutEE="eta<=-1.479 || eta>=1.479"; TString cutdefEB, cutdefEE; if(cutdef=="") { cutdefEB=etacutEB; cutdefEE=etacutEE; } else { cutdefEB=cutdef+" && "+etacutEB ; cutdefEB=cutdef+" && "+etacutEE ; } // INPUT DATA // TChain* treeTnP = new TChain("treeTnP"); treeTnP->Add(dirIn+"/"+fileIn); RooRealVar xaxis("pt","P_{T} [GeV]",0,150) ; RooRealVar mass("mass","mass",mLow,mHigh) ;// consider only this mass range when importing data RooRealVar eta("eta","eta",-3., 3) ; RooRealVar weight("weight","weight",-1,1000) ; RooRealVar pt_HLT_tag("pt_HLT_tag","P_{T} [GeV]",0,150) ; RooRealVar pt_HLT_tag_sanity("pt_HLT_tag_sanity","P_{T} [GeV]",0,150) ; RooRealVar pt_L3("pt_L3","P_{T} [GeV]",0,150) ; RooRealVar pt_L25("pt_L25","P_{T} [GeV]",0,150) ; RooRealVar pt_L2("pt_L2","P_{T} [GeV]",0,150) ; RooRealVar et_L1jet("et_L1_jet","P_{T} [GeV]",0,150) ; RooRealVar et_L1tau("et_L1_tau","P_{T} [GeV]",0,150) ; // DEFINE EFFICIENCY CUT // RooCategory cutHLT("match","") ; cutHLT.defineType("accept",1) ; cutHLT.defineType("reject",0) ; RooCategory cutL1("L1match","") ; cutL1.defineType("accept",1) ; cutL1.defineType("reject",0) ; RooCategory cutL1L2("L1L2match","") ; cutL1L2.defineType("accept",1) ; cutL1L2.defineType("reject",0) ; RooCategory cutL1L2L25("L1L2L25match","") ; cutL1L2L25.defineType("accept",1) ; cutL1L2L25.defineType("reject",0) ; RooCategory cutL1L2L25L3("L1L2L25L3match","") ; cutL1L2L25L3.defineType("accept",1) ; cutL1L2L25L3.defineType("reject",0) ; RooCategory *cut; if(cut_choice=="HLT") cut = &cutHLT; if(cut_choice=="L1") cut = &cutL1; if(cut_choice=="L1L2") cut = &cutL1L2; if(cut_choice=="L1L2L25") cut = &cutL1L2L25; if(cut_choice=="L1L2L25L3") cut = &cutL1L2L25L3; RooDataSet dataSetEB("data","data from tree", RooArgSet(xaxis, *cut, pt_HLT_tag, pt_L3, pt_L25, pt_L2, mass, weight, eta), WeightVar(weight), Import(*treeTnP), Cut(cutdefEB) ); RooDataSet dataSetEE("data","data from tree", RooArgSet(xaxis, *cut, pt_HLT_tag, pt_L3, pt_L25, pt_L2, mass, weight, eta), WeightVar(weight), Import(*treeTnP), Cut(cutdefEE) ); dataSetEB.Print(); dataSetEE.Print(); // PLOT // RooPlot* frame = xaxis.frame(Bins(18000),Title("Fitted efficiency")) ; dataSetEB.plotOn(frame, Binning(binningEB), Efficiency(*cut), MarkerColor(color1), LineColor(color1), MarkerStyle(style1) ); dataSetEE.plotOn(frame, Binning(binningEE), Efficiency(*cut), MarkerColor(color2), LineColor(color2), MarkerStyle(style2) ); // PARAMETRES ROOFIT CRYSTAL BALL // RooRealVar norm("norm","N",0.95,0.6,1); RooRealVar alpha("alpha","#alpha",0.2,0.01,8); RooRealVar n("n","n",2,1.1,35); RooRealVar mean("mean","mean",10,5,30); mean.setVal(thres); RooRealVar sigma("sigma","#sigma",0.23,0.01,5); RooRealVar pedestal("pedestal","pedestal",0.01,0,0.4); FuncCB cb_EB("cb_EB","Fit function EB (cb)",xaxis,mean,sigma,alpha,n,norm) ; FuncCB cb_EE("cb_EE","Fit function EE (cb)",xaxis,mean,sigma,alpha,n,norm) ; RooEfficiency eff_EB("eff_EB","efficiency EB", cb_EB, *cut, "accept"); RooEfficiency eff_EE("eff_EE","efficiency EE", cb_EE, *cut, "accept"); // FIT // double fit_cuts_min = thres-1.5 ; double fit_cuts_max = 150; xaxis.setRange("interesting",fit_cuts_min,fit_cuts_max); fichier << "Fit characteristics :" << endl << "Threshold : " << thres << endl << "Fit Range : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl << endl << endl; RooFitResult* roofitres_EB = new RooFitResult("roofitres_EB","roofitres_EB"); RooFitResult* roofitres_EE = new RooFitResult("roofitres_EE","roofitres_EE"); // Fit #1 // roofitres_EB = eff_EB.fitTo(dataSetEB,ConditionalObservables(xaxis),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE),SumW2Error(kTRUE)); cb_EB.plotOn(frame,LineColor(color1),LineWidth(2)); fichier << "<----------------- EB ----------------->" << endl << "double res_mean=" << mean.getVal() << "; " << "double res_sigma=" << sigma.getVal() << "; " << "double res_alpha=" << alpha.getVal() << "; " << "double res_n=" << n.getVal() << "; " << "double res_norm=" << norm.getVal() << "; " << endl << "double err_mean=" << mean.getError() << "; " << "double err_sigma=" << sigma.getError() << "; " << "double err_alpha=" << alpha.getError() << "; " << "double err_n=" << n.getError() << "; " << "double err_norm=" << norm.getErrorLo()<< "; " << endl; // Fit #2 // roofitres_EE = eff_EE.fitTo(dataSetEE,ConditionalObservables(xaxis),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE),SumW2Error(kTRUE)); cb_EE.plotOn(frame,LineColor(color2),LineWidth(2)); fichier << "<----------------- EE ----------------->" << endl << "double res_mean=" << mean.getVal() << "; " << "double res_sigma=" << sigma.getVal() << "; " << "double res_alpha=" << alpha.getVal() << "; " << "double res_n=" << n.getVal() << "; " << "double res_norm=" << norm.getVal() << "; " << endl << "double err_mean=" << mean.getError() << "; " << "double err_sigma=" << sigma.getError() << "; " << "double err_alpha=" << alpha.getError() << "; " << "double err_n=" << n.getError() << "; " << "double err_norm=" << norm.getErrorLo()<< "; " << endl; //////////////////////////// DRAWING PLOTS AND LEGENDS ///////////////////////////////// TCanvas* ca = new TCanvas("ca","Trigger Efficiency") ; ca->SetGridx(); ca->SetGridy(); ca->cd(); //gPad->SetLogx(); gPad->SetObjectStat(1); frame->GetYaxis()->SetRangeUser(0,1.05); frame->GetXaxis()->SetRangeUser(1,150.); frame->GetYaxis()->SetTitle("Efficiency"); frame->GetXaxis()->SetTitle("E_{T} [GeV]"); frame->Draw() ; TH1F *SCeta_EB = new TH1F("SCeta_EB","SCeta_EB",50,-2.5,2.5); TH1F *SCeta_EE = new TH1F("SCeta_EE","SCeta_EE",50,-2.5,2.5); SCeta_EB->SetLineColor(color1) ; SCeta_EB->SetMarkerColor(color1); SCeta_EB->SetMarkerStyle(style1); SCeta_EE->SetLineColor(color2) ; SCeta_EE->SetMarkerColor(color2); SCeta_EE->SetMarkerStyle(style2); TLegend *leg = new TLegend(0.40, 0.14, 0.63, 0.34, NULL, "brNDC"); leg->SetLineColor(1); leg->SetTextColor(1); leg->SetTextFont(42); leg->SetTextSize(0.0244755); leg->SetShadowColor(kWhite); leg->SetFillColor(kWhite); leg->AddEntry("NULL","e #tau electrons efficiency","h"); // entry->SetLineColor(1); // entry->SetLineStyle(1); // entry->SetLineWidth(1); // entry->SetMarkerColor(1); // entry->SetMarkerStyle(21); // entry->SetMarkerSize(1); // entry->SetTextFont(62); leg->AddEntry(SCeta_EB,"Barrel","p"); leg->AddEntry(SCeta_EE,"Endcaps","p"); leg->Draw(); ostringstream ossi(""); ossi << thres; TString tossi = ossi.str(); leg = new TLegend(0.40, 0.30, 0.50, 0.50, NULL, "brNDC"); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetTextSize(0.0297203); leg->SetLineColor(0); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); leg->AddEntry("NULL","CMS Preliminary 2012 pp #sqrt{s}=8 TeV","h"); leg->AddEntry("NULL","#int L dt = "+lumi+"^{-1}","h"); leg->AddEntry("NULL","Threshold : "+tossi+" GeV","h"); leg->Draw(); ca->Print(name_image+".C","C"); ca->Print(name_image+".cxx","cxx"); ca->Print(name_image+".png","png"); ca->Print(name_image+".gif","gif"); ca->Print(name_image+".pdf","pdf"); ca->Print(name_image+".ps","ps"); ///////////////////////////// // SAVE THE ROO FIT RESULT // ///////////////////////////// RooWorkspace *w = new RooWorkspace("workspace","workspace") ; w->import(dataSetEB); w->import(dataSetEE); w->import(*roofitres_EB,"roofitres_EB"); w->import(*roofitres_EE,"roofitres_EE"); cout << "CREATES WORKSPACE : " << endl; w->Print(); w->writeToFile(name_image+"_fitres.root") ; //gDirectory->Add(w) ; // DELETE POINTERS // int a=0; // cin >> a; // delete treeTnP; delete cut; delete frame; delete roofitres_EB; delete roofitres_EE; delete ca; delete SCeta_EB; delete SCeta_EE; delete leg; delete w; }