void ColorRect::syncStatus(){ if (_body) { setPositionX(_body->GetPosition().x*getRatio()); setPositionY(_body->GetPosition().y*getRatio()); setRotation(-_body->GetAngle()/M_PI*180); } }
int main(void) { double v; int n; printf("Enter a no.\n"); scanf("%lf", &v); printf("press 1> for sin 2> for cos\n"); scanf("%d", &n); if (n == 1) printf("sin(%lf) = %lf\n", v, getRatio(sin, v)); else printf("cos(%lf) = %lf\n", v, getRatio(cos, v)); return 0; }
void HybridHashing::putCouple(size_t hash, Couple couple) { getHybridDirectory(hash).putCouple(hash, couple); numberItems++; if (getRatio() > SPLIT_RATIO) { split(); } }
//----------------------------------------// // Make ratio plot //----------------------------------------// void plotRatio(TProfile* p0, TProfile* p1, TLegend* leg, TCanvas* c, string title, TString append) { // Make TPad object TPad* p_top; TPad* p_bot; makePads(c,p_top,p_bot); // Plot stuff on top c->cd(); p_top->Draw(); p_top->cd(); p_top->SetLogy(); // Set Some attributes p1->SetLabelSize(0.0,"X"); p1->SetLabelSize(0.06, "Y"); p1->GetYaxis()->SetTitleSize(0.06); p1->GetYaxis()->SetTitleOffset(0.85); // Draw Top p1->Draw(); p0->Draw("same"); leg->Draw("same"); p_top->Update(); // Get Bottom objects TH1D* ratio = getRatio(p0,p1,title); float xmax = ratio->GetXaxis()->GetXmax(); TLine* mid = makeLine(0,xmax,1.0,1.0); TLine* u50 = makeLine(0,xmax,1.5,1.5,kBlack,2); TLine* d50 = makeLine(0,xmax,0.5,0.5,kBlack,2); // Draw bottom c->cd(); p_bot->Draw(); p_bot->cd(); // Draw bottom objects ratio->Draw("ep"); mid->Draw("same"); u50->Draw("same"); d50->Draw("same"); ratio->Draw("sameep"); p_bot->Update(); //c->SaveAs(savedir+append+".png"); }
float SoView2DLiftChart::mapWorldToChart(const float* world) { float tempX, tempY, tempZ; mapWorldToVoxel(world, tempX, tempY, tempZ); int value = _height - (tempZ * getRatio()) - 1; if (value < 0 ) value = 0; if (value > _height) value = _height; return value; }
void REllipseEntity::print(QDebug dbg) const { dbg.nospace() << "REllipseEntity("; REntity::print(dbg); dbg.nospace() << ", center: " << getCenter(); dbg.nospace() << ", majorPoint: " << getMajorPoint(); dbg.nospace() << ", ratio: " << getRatio(); dbg.nospace() << ", startAngle: " << getStartAngle(); dbg.nospace() << ", endAngle: " << getEndAngle(); dbg.nospace() << ", reversed: " << isReversed() << ")"; }
Resampler::Resampler (int srcSR, int tgtSR) : m_sourceSR (srcSR), m_targetSR (tgtSR), m_scratchBuffer (std::max (srcSR, tgtSR)), m_srcPositionFracFP (0), m_srcIncrementFP (0), m_srcPositionInt (0) { m_srcIncrementFP = (1 << FP_POST) * 1 / getRatio (); }
void createTheoryDataRatios(bool extrapolate=true, bool hadron=false, int verbose=0){ // ============================ // Set Root Style // ============================ // TStyle myStyle("HHStyle2","HHStyle2"); // setHHStyle(myStyle); // TGaxis::SetMaxDigits(2); // myStyle.cd(); // gROOT->SetStyle("HHStyle2"); gStyle->SetEndErrorSize(8); // list all variables you want to create a ratio for std::vector<TString> xSecVariables_; // a) top and ttbar quantities if(!hadron){ xSecVariables_.insert(xSecVariables_.end(), xSecVariablesKinFit, xSecVariablesKinFit + sizeof(xSecVariablesKinFit)/sizeof(TString)); } // b) lepton and b-jet quantities if(hadron||!extrapolate){ xSecVariables_.insert(xSecVariables_.end(), xSecVariablesFinalState , xSecVariablesFinalState + sizeof(xSecVariablesFinalState )/sizeof(TString)); } // get correct names TString PS = extrapolate ? "" : "PhaseSpace"; TString LV="Parton"; if(!extrapolate&&hadron) LV="Hadron"; TString outputFolder="./diffXSecFromSignal/plots/combined/2012/xSec/"; TString outputFile="diffXSecTopSemiLep"+LV+PS+".root"; // loop variables for(unsigned int i=0; i<xSecVariables_.size(); ++i){ TString variable=xSecVariables_[i]; // create ratio canvas int verbose2=verbose; TCanvas*canv=getRatio(variable, verbose2, outputFile); // save ratio plots if(canv){ int initialIgnoreLevel=gErrorIgnoreLevel; if(verbose==0) gErrorIgnoreLevel=kWarning; canv->Print(outputFolder+"ratioFinalXSec"+variable+"NormCombined"+LV+PS+".eps"); canv->Print(outputFolder+"ratioFinalXSec"+variable+"NormCombined"+LV+PS+".png"); if(i==0) canv->Print(outputFolder+"ratioFinalXSecNormCombined"+LV+PS+".pdf("); else if(i==(xSecVariables_.size()-1))canv->Print(outputFolder+"ratioFinalXSecNormCombined"+LV+PS+".pdf)"); else canv->Print(outputFolder+"ratioFinalXSecNormCombined"+LV+PS+".pdf"); gErrorIgnoreLevel=initialIgnoreLevel; saveToRootFile(outputFile, canv, true, verbose,"ratio/"+variable); } // delete ratio canvas delete canv; } }
int isPair(squares_t *square1, squares_t *square2, float area_ratio_threshold){//set thresh around .5 //compare areas float ratio; int diff; if((square1->area)<(square2->area)) ratio = getRatio((int)square1->area, (int)square2->area); else if((square1->area)>(square2->area)) ratio = getRatio((int)square2->area, (int)square1->area); else ratio = 1; diff = get_diff_in_y(square1, square2); if(ratio > area_ratio_threshold && diff < 25) if(abs((square1->center.x) - (square2->center.x))>=50)//if they're not in the same place ie: the same square return 1; else return 0; else return 0; }
RawSourceRange FrSkyChannelData::getRange() const { RawSourceRange result; float ratio = getRatio(); if (type==0 || type==1 || type==2) result.decimals = 2; else result.decimals = 0; result.step = ratio / 255; result.min = offset * result.step; result.max = ratio + result.min; result.unit = QObject::tr("V"); return result; }
void REllipse::print(QDebug dbg) const { dbg.nospace() << "REllipse("; RShape::print(dbg); dbg.nospace() << ", startPoint: " << getStartPoint() << ", endPoint: " << getEndPoint() << ", center: " << getCenter() << ", majorPoint: " << getMajorPoint() << ", majorRadius: " << getMajorRadius() << ", minorRadius: " << getMinorRadius() << ", ratio: " << getRatio() << ", startAngle: " << RMath::rad2deg(getStartParam()) << ", endAngle: " << RMath::rad2deg(getEndParam()) << ", full: " << isFullEllipse() << ", clockwise: " << isReversed() << ")"; }
bool CImage_VI_Slope::On_Execute(void){ double dRed, dNIR; CSG_Grid* pNIR = Parameters("NIR")->asGrid(); CSG_Grid* pRed = Parameters("RED")->asGrid(); CSG_Grid* pNDVI = Parameters("NDVI")->asGrid(); CSG_Grid* pRatio = Parameters("RATIO")->asGrid(); CSG_Grid* pTVI = Parameters("TVI")->asGrid(); CSG_Grid* pTTVI = Parameters("TTVI")->asGrid(); CSG_Grid* pCTVI = Parameters("CTVI")->asGrid(); CSG_Grid* pNRatio = Parameters("NRATIO")->asGrid(); for(int y=0; y<Get_NY() && Set_Progress(y); y++){ for(int x=0; x<Get_NX(); x++){ dNIR = pNIR->asDouble(x,y); dRed = pRed->asDouble(x,y); pNDVI->Set_Value(x,y,getNDVI(dRed, dNIR)); if (pRatio){ if (dRed!=0){ pRatio->Set_Value(x,y,getRatio(dRed,dNIR)); }//if else{ pRatio->Set_Value(x,y,pRatio->Get_NoData_Value()); }//else }//if if (pTVI){ pTVI->Set_Value(x,y,getTVI(dRed,dNIR,pTVI)); }//if if (pCTVI){ pCTVI->Set_Value(x,y,getCTVI(dRed,dNIR)); }//if if (pTTVI){ pTTVI->Set_Value(x,y,getTTVI(dRed,dNIR)); }//if if (pNRatio){ pNRatio->Set_Value(x,y,getNRatio(dRed,dNIR)); }//if }// for }// for return true; }//method
RS_Vector RS_Ellipse::getNearestOrthTan(const RS_Vector& coord, const RS_Line& normal, bool onEntity ) { if ( !coord.valid ) { return RS_Vector(false); } RS_Vector direction=normal.getEndpoint() - normal.getStartpoint(); if (RS_Vector::dotP(direction,direction)< RS_TOLERANCE*RS_TOLERANCE) { //undefined direction return RS_Vector(false); } //scale to ellipse angle direction.rotate(-getAngle()); double angle=direction.scale(RS_Vector(1.,getRatio())).angle(); direction.set(getMajorRadius()*cos(angle),getMinorRadius()*sin(angle));//relative to center QList<RS_Vector> sol; for(int i=0; i<2; i++) { if(!onEntity || RS_Math::isAngleBetween(angle,getAngle1(),getAngle2(),isReversed())) { if(i) { sol.append(- direction); } else { sol.append(direction); } } angle=RS_Math::correctAngle(angle+M_PI); } RS_Vector vp; switch(sol.count()) { case 0: return RS_Vector(false); case 2: if( RS_Vector::dotP(sol[1]-getCenter(),coord-getCenter())>0.) { vp=sol[1]; break; } default: vp=sol[0]; } return getCenter() + vp.rotate(getAngle()); }
int main() { DEBUGLOG->setAutoPrint(true); ////////////////////////////////////////////////////////////////////////////// /////////////////////// INIT ////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // create window and opengl context auto window = generateWindow(800,800); ////////////////////////////////////////////////////////////////////////////// /////////////////////////////// RENDERING /////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ///////////////////// Scene / View Settings ////////////////////////// glm::mat4 model = glm::mat4(1.0f); glm::vec4 eye(0.0f, 0.0f, 3.0f, 1.0f); glm::vec4 center(0.0f,0.0f,0.0f,1.0f); glm::mat4 view = glm::lookAt(glm::vec3(eye), glm::vec3(center), glm::vec3(0,1,0)); // glm::mat4 perspective = glm::ortho(-2.0f, 2.0f, -2.0f, 2.0f, -1.0f, 6.0f); /// perspective projection is experimental; yields weird warping effects due to vertex interpolation of uv-coordinates glm::mat4 perspective = glm::perspective(glm::radians(65.f), getRatio(window), 0.1f, 10.f); // create object // Sphere grid; Grid grid(10,10,0.1f,0.1f,true); // Volume grid; // load grass texture s_texHandle = TextureTools::loadTexture(RESOURCES_PATH + std::string( "/grass.png")); glBindTexture(GL_TEXTURE_2D, s_texHandle); /////////////////////// Renderpass /////////////////////////// DEBUGLOG->log("Shader Compilation: volume uvw coords"); DEBUGLOG->indent(); ShaderProgram shaderProgram("/modelSpace/GBuffer.vert", "/modelSpace/GBuffer.frag"); DEBUGLOG->outdent(); shaderProgram.update("model", model); shaderProgram.update("view", view); shaderProgram.update("projection", perspective); shaderProgram.update("color", glm::vec4(1.0f,0.0f,0.0f,1.0f)); DEBUGLOG->log("FrameBufferObject Creation: volume uvw coords"); DEBUGLOG->indent(); FrameBufferObject fbo(getResolution(window).x, getResolution(window).y); FrameBufferObject::s_internalFormat = GL_RGBA32F; // to allow arbitrary values in G-Buffer fbo.addColorAttachments(4); DEBUGLOG->outdent(); // G-Buffer FrameBufferObject::s_internalFormat = GL_RGBA; // restore default RenderPass renderPass(&shaderProgram, &fbo); renderPass.addEnable(GL_DEPTH_TEST); renderPass.addClearBit(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); renderPass.addRenderable(&grid); ShaderProgram compShader("/screenSpace/fullscreen.vert", "/screenSpace/finalCompositing.frag"); // ShaderProgram compShader("/screenSpace/fullscreen.vert", "/screenSpace/simpleAlphaTexture.frag"); Quad quad; RenderPass compositing(&compShader, 0); compositing.addClearBit(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); compositing.addRenderable(&quad); // Geometry test shader ShaderProgram geomShader("/modelSpace/geometry.vert", "/modelSpace/simpleLighting.frag", "/geometry/simpleGeom.geom"); RenderPass geom(&geomShader, 0); geom.addClearBit(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); geom.addRenderable(&grid); geom.addEnable(GL_DEPTH_TEST); geom.addEnable(GL_ALPHA_TEST); geom.addEnable(GL_BLEND); glAlphaFunc(GL_GREATER, 0); geomShader.update("projection", perspective); ////////////////////////////////////////////////////////////////////////////// /////////////////////// GUI / USER INPUT //////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // Setup ImGui binding ImGui_ImplGlfwGL3_Init(window, true); Turntable turntable; double old_x; double old_y; glfwGetCursorPos(window, &old_x, &old_y); auto cursorPosCB = [&](double x, double y) { ImGuiIO& io = ImGui::GetIO(); if ( io.WantCaptureMouse ) { return; } // ImGUI is handling this double d_x = x - old_x; double d_y = y - old_y; if ( turntable.getDragActive() ) { turntable.dragBy(d_x, d_y, view); } old_x = x; old_y = y; }; auto mouseButtonCB = [&](int b, int a, int m) { if (b == GLFW_MOUSE_BUTTON_LEFT && a == GLFW_PRESS) { turntable.setDragActive(true); } if (b == GLFW_MOUSE_BUTTON_LEFT && a == GLFW_RELEASE) { turntable.setDragActive(false); } ImGui_ImplGlfwGL3_MouseButtonCallback(window, b, a, m); }; auto keyboardCB = [&](int k, int s, int a, int m) { if (a == GLFW_RELEASE) {return;} switch (k) { case GLFW_KEY_W: eye += glm::inverse(view) * glm::vec4(0.0f,0.0f,-0.1f,0.0f); center += glm::inverse(view) * glm::vec4(0.0f,0.0f,-0.1f,0.0f); break; case GLFW_KEY_A: eye += glm::inverse(view) * glm::vec4(-0.1f,0.0f,0.0f,0.0f); center += glm::inverse(view) * glm::vec4(-0.1f,0.0f,0.0f,0.0f); break; case GLFW_KEY_S: eye += glm::inverse(view) * glm::vec4(0.0f,0.0f,0.1f,0.0f); center += glm::inverse(view) * glm::vec4(0.0f,0.0f,0.1f,0.0f); break; case GLFW_KEY_D: eye += glm::inverse(view) * glm::vec4(0.1f,0.0f,0.0f,0.0f); center += glm::inverse(view) * glm::vec4(0.1f,0.0f,0.0f,0.0f); break; default: break; } ImGui_ImplGlfwGL3_KeyCallback(window,k,s,a,m); }; setCursorPosCallback(window, cursorPosCB); setMouseButtonCallback(window, mouseButtonCB); setKeyCallback(window, keyboardCB); ////////////////////////////////////////////////////////////////////////////// //////////////////////////////// RENDER LOOP ///////////////////////////////// ////////////////////////////////////////////////////////////////////////////// double elapsedTime = 0.0; render(window, [&](double dt) { elapsedTime += dt; std::string window_header = "Volume Renderer - " + std::to_string( 1.0 / dt ) + " FPS"; glfwSetWindowTitle(window, window_header.c_str() ); //////////////////////////////// GUI //////////////////////////////// ImGuiIO& io = ImGui::GetIO(); ImGui_ImplGlfwGL3_NewFrame(); // tell ImGui a new frame is being rendered ImGui::PushItemWidth(-100); if (ImGui::CollapsingHeader("Geometry Shader Settings")) { ImGui::ColorEdit4( "color", glm::value_ptr( s_color)); // color mixed at max distance ImGui::SliderFloat("strength", &s_strength, 0.0f, 2.0f); // influence of color shift } ImGui::Checkbox("auto-rotate", &s_isRotating); // enable/disable rotating volume ImGui::PopItemWidth(); ////////////////////////////////////////////////////////////////////////////// ///////////////////////////// MATRIX UPDATING /////////////////////////////// if (s_isRotating) // update view matrix { model = glm::rotate(glm::mat4(1.0f), (float) dt, glm::vec3(0.0f, 1.0f, 0.0f) ) * model; } view = glm::lookAt(glm::vec3(eye), glm::vec3(center), glm::vec3(0.0f, 1.0f, 0.0f)); ////////////////////////////////////////////////////////////////////////////// //////////////////////// SHADER / UNIFORM UPDATING ////////////////////////// // update view related uniforms shaderProgram.update( "view", view); shaderProgram.update( "model", turntable.getRotationMatrix() * model); geomShader.update( "view", view); geomShader.update( "model", turntable.getRotationMatrix() * model); compShader.update( "vLightPos", view * turntable.getRotationMatrix() * s_lightPos); updateVectorTexture(elapsedTime); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, s_vectorTexture); // glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // this is altered by ImGui::Render(), so reset it every frame glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, s_texHandle); geomShader.update("tex", 1); geomShader.update("blendColor", 2.0); geomShader.update("color", s_color); geomShader.update("strength", s_strength); ////////////////////////////////////////////////////////////////////////////// //////////////////////////////// RENDERING //// ///////////////////////////// // glActiveTexture(GL_TEXTURE0); // glBindTexture(GL_TEXTURE_2D, fbo.getColorAttachmentTextureHandle(GL_COLOR_ATTACHMENT0)); // color // glActiveTexture(GL_TEXTURE1); // glBindTexture(GL_TEXTURE_2D, fbo.getColorAttachmeHntTextureHandle(GL_COLOR_ATTACHMENT1)); // normal // glActiveTexture(GL_TEXTURE2); // glBindTexture(GL_TEXTURE_2D, fbo.getColorAttachmentTextureHandle(GL_COLOR_ATTACHMENT2)); // position // glActiveTexture(GL_TEXTURE0); // compShader.update("colorMap", 0); // compShader.update("normalMap", 1); // compShader.update("positionMap", 2); // renderPass.render(); // compositing.render(); geom.render(); ImGui::Render(); glDisable(GL_BLEND); glBlendFunc(GL_ONE, GL_ZERO); // this is altered by ImGui::Render(), so reset it every frame ////////////////////////////////////////////////////////////////////////////// }); destroyWindow(window); return 0; }
void FlowContext::calculateRatio(void) { emit contextRatioChanged(getRatio()); }
void registerExtensions (Extensions& extensions) { static const char *attributes[numberOfAttributes] = { "strength", "intelligence", "willpower", "agility", "speed", "endurance", "personality", "luck" }; static const char *dynamics[numberOfDynamics] = { "health", "magicka", "fatigue" }; static const char *skills[numberOfSkills] = { "block", "armorer", "mediumarmor", "heavyarmor", "bluntweapon", "longblade", "axe", "spear", "athletics", "enchant", "destruction", "alteration", "illusion", "conjuration", "mysticism", "restoration", "alchemy", "unarmored", "security", "sneak", "acrobatics", "lightarmor", "shortblade", "marksman", "mercantile", "speechcraft", "handtohand" }; std::string get ("get"); std::string set ("set"); std::string mod ("mod"); std::string modCurrent ("modcurrent"); std::string getRatio ("getratio"); for (int i=0; i<numberOfAttributes; ++i) { extensions.registerFunction (get + attributes[i], 'l', "", opcodeGetAttribute+i, opcodeGetAttributeExplicit+i); extensions.registerInstruction (set + attributes[i], "l", opcodeSetAttribute+i, opcodeSetAttributeExplicit+i); extensions.registerInstruction (mod + attributes[i], "l", opcodeModAttribute+i, opcodeModAttributeExplicit+i); } for (int i=0; i<numberOfDynamics; ++i) { extensions.registerFunction (get + dynamics[i], 'f', "", opcodeGetDynamic+i, opcodeGetDynamicExplicit+i); extensions.registerInstruction (set + dynamics[i], "f", opcodeSetDynamic+i, opcodeSetDynamicExplicit+i); extensions.registerInstruction (mod + dynamics[i], "f", opcodeModDynamic+i, opcodeModDynamicExplicit+i); extensions.registerInstruction (modCurrent + dynamics[i], "f", opcodeModCurrentDynamic+i, opcodeModCurrentDynamicExplicit+i); extensions.registerFunction (get + dynamics[i] + getRatio, 'f', "", opcodeGetDynamicGetRatio+i, opcodeGetDynamicGetRatioExplicit+i); } for (int i=0; i<numberOfSkills; ++i) { extensions.registerFunction (get + skills[i], 'l', "", opcodeGetSkill+i, opcodeGetSkillExplicit+i); extensions.registerInstruction (set + skills[i], "l", opcodeSetSkill+i, opcodeSetSkillExplicit+i); extensions.registerInstruction (mod + skills[i], "l", opcodeModSkill+i, opcodeModSkillExplicit+i); } extensions.registerFunction ("getpccrimelevel", 'f', "", opcodeGetPCCrimeLevel); extensions.registerInstruction ("setpccrimelevel", "f", opcodeSetPCCrimeLevel); extensions.registerInstruction ("modpccrimelevel", "f", opcodeModPCCrimeLevel); extensions.registerInstruction ("addspell", "cz", opcodeAddSpell, opcodeAddSpellExplicit); extensions.registerInstruction ("removespell", "c", opcodeRemoveSpell, opcodeRemoveSpellExplicit); extensions.registerInstruction ("removespelleffects", "c", opcodeRemoveSpellEffects, opcodeRemoveSpellEffectsExplicit); extensions.registerInstruction ("removeeffects", "l", opcodeRemoveEffects, opcodeRemoveEffectsExplicit); extensions.registerInstruction ("resurrect", "", opcodeResurrect, opcodeResurrectExplicit); extensions.registerFunction ("getspell", 'l', "c", opcodeGetSpell, opcodeGetSpellExplicit); extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank, opcodePCRaiseRankExplicit); extensions.registerInstruction("pclowerrank","/S",opcodePCLowerRank, opcodePCLowerRankExplicit); extensions.registerInstruction("pcjoinfaction","/S",opcodePCJoinFaction, opcodePCJoinFactionExplicit); extensions.registerInstruction ("moddisposition","l",opcodeModDisposition, opcodeModDispositionExplicit); extensions.registerInstruction ("setdisposition","l",opcodeSetDisposition, opcodeSetDispositionExplicit); extensions.registerFunction ("getdisposition",'l', "",opcodeGetDisposition, opcodeGetDispositionExplicit); extensions.registerFunction("getpcrank",'l',"/S",opcodeGetPCRank,opcodeGetPCRankExplicit); extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit); extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit); extensions.registerFunction("getstat", 'l', "c", opcodeGetStat, opcodeGetStatExplicit); extensions.registerFunction ("getdeadcount", 'l', "c", opcodeGetDeadCount); extensions.registerFunction ("getpcfacrep", 'l', "/c", opcodeGetPCFacRep, opcodeGetPCFacRepExplicit); extensions.registerInstruction ("setpcfacrep", "l/c", opcodeSetPCFacRep, opcodeSetPCFacRepExplicit); extensions.registerInstruction ("modpcfacrep", "l/c", opcodeModPCFacRep, opcodeModPCFacRepExplicit); extensions.registerFunction ("getcommondisease", 'l', "", opcodeGetCommonDisease, opcodeGetCommonDiseaseExplicit); extensions.registerFunction ("getblightdisease", 'l', "", opcodeGetBlightDisease, opcodeGetBlightDiseaseExplicit); extensions.registerFunction ("getrace", 'l', "c", opcodeGetRace, opcodeGetRaceExplicit); extensions.registerFunction ("getwerewolfkills", 'l', "", opcodeGetWerewolfKills); extensions.registerFunction ("pcexpelled", 'l', "/S", opcodePcExpelled, opcodePcExpelledExplicit); extensions.registerInstruction ("pcexpell", "/S", opcodePcExpell, opcodePcExpellExplicit); extensions.registerInstruction ("pcclearexpelled", "/S", opcodePcClearExpelled, opcodePcClearExpelledExplicit); extensions.registerInstruction ("raiserank", "", opcodeRaiseRank, opcodeRaiseRankExplicit); extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit); extensions.registerFunction ("ondeath", 'l', "", opcodeOnDeath, opcodeOnDeathExplicit); extensions.registerFunction ("onmurder", 'l', "", opcodeOnMurder, opcodeOnMurderExplicit); extensions.registerFunction ("onknockout", 'l', "", opcodeOnKnockout, opcodeOnKnockoutExplicit); extensions.registerFunction ("iswerewolf", 'l', "", opcodeIsWerewolf, opcodeIsWerewolfExplicit); extensions.registerInstruction("becomewerewolf", "", opcodeBecomeWerewolf, opcodeBecomeWerewolfExplicit); extensions.registerInstruction("undowerewolf", "", opcodeUndoWerewolf, opcodeUndoWerewolfExplicit); extensions.registerInstruction("setwerewolfacrobatics", "", opcodeSetWerewolfAcrobatics, opcodeSetWerewolfAcrobaticsExplicit); }
void registerExtensions (Compiler::Extensions& extensions) { static const char *attributes[numberOfAttributes] = { "strength", "intelligence", "willpower", "agility", "speed", "endurance", "personality", "luck" }; static const char *dynamics[numberOfDynamics] = { "health", "magicka", "fatigue" }; static const char *skills[numberOfSkills] = { "block", "armorer", "mediumarmor", "heavyarmor", "bluntweapon", "longblade", "axe", "spear", "athletics", "enchant", "destruction", "alteration", "illusion", "conjuration", "mysticism", "restoration", "alchemy", "unarmored", "security", "sneak", "acrobatics", "lightarmor", "shortblade", "marksman", "merchantile", "speechcraft", "handtohand" }; std::string get ("get"); std::string set ("set"); std::string mod ("mod"); std::string modCurrent ("modcurrent"); std::string getRatio ("getratio"); for (int i=0; i<numberOfAttributes; ++i) { extensions.registerFunction (get + attributes[i], 'l', "", opcodeGetAttribute+i, opcodeGetAttributeExplicit+i); extensions.registerInstruction (set + attributes[i], "l", opcodeSetAttribute+i, opcodeSetAttributeExplicit+i); extensions.registerInstruction (mod + attributes[i], "l", opcodeModAttribute+i, opcodeModAttributeExplicit+i); } for (int i=0; i<numberOfDynamics; ++i) { extensions.registerFunction (get + dynamics[i], 'l', "", opcodeGetDynamic+i, opcodeGetDynamicExplicit+i); extensions.registerInstruction (set + dynamics[i], "l", opcodeSetDynamic+i, opcodeSetDynamicExplicit+i); extensions.registerInstruction (mod + dynamics[i], "l", opcodeModDynamic+i, opcodeModDynamicExplicit+i); extensions.registerInstruction (modCurrent + dynamics[i], "l", opcodeModCurrentDynamic+i, opcodeModCurrentDynamicExplicit+i); extensions.registerFunction (get + dynamics[i] + getRatio, 'f', "", opcodeGetDynamicGetRatio+i, opcodeGetDynamicGetRatioExplicit+i); } for (int i=0; i<numberOfSkills; ++i) { extensions.registerFunction (get + skills[i], 'l', "", opcodeGetSkill+i, opcodeGetSkillExplicit+i); extensions.registerInstruction (set + skills[i], "l", opcodeSetSkill+i, opcodeSetSkillExplicit+i); extensions.registerInstruction (mod + skills[i], "l", opcodeModSkill+i, opcodeModSkillExplicit+i); } extensions.registerInstruction ("addspell", "c", opcodeAddSpell, opcodeAddSpellExplicit); extensions.registerInstruction ("removespell", "c", opcodeRemoveSpell, opcodeRemoveSpellExplicit); extensions.registerFunction ("getspell", 'l', "c", opcodeGetSpell, opcodeGetSpellExplicit); extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank); extensions.registerInstruction("pclowerrank","/S",opcodePCLowerRank); extensions.registerInstruction("pcjoinfaction","/S",opcodePCJoinFaction); extensions.registerInstruction("moddisposition","l",opcodeModDisposition, opcodeModDispositionExplicit); extensions.registerFunction("getpcrank",'l',"/S",opcodeGetPCRank,opcodeGetPCRankExplicit); }
RS_VectorSolutions LC_Hyperbola::getFoci() const { RS_Vector vp(getMajorP()*sqrt(1.-getRatio()*getRatio())); return RS_VectorSolutions({getCenter()+vp, getCenter()-vp}); }
QList<RVector> REllipse::getFoci() const { RVector vp(getMajorPoint() * sqrt(1.0 - getRatio()*getRatio())); return QList<RVector>() << getCenter()+vp << getCenter()-vp; }
/** * Make a root plot of the experimental ratio and the * calculated values */ void ratio::PlotFit() { #ifdef root TCanvas *canvas = new TCanvas("fit"); canvas->SetLogx(); TH2S * frame = new TH2S("frame","",10,5,300,10,-.02,.15); frame->GetXaxis()->SetTitle("E_{lab}"); frame->GetYaxis()-> SetTitle("(#sigma_{2}-#sigma_{1})/(#sigma_{2}+#sigma_{1})"); frame->SetStats(kFALSE); frame->Draw(); ofstream xFile("ratiox.dat"); xFile << Ndata << endl; if (Ndata > 0) { double xExp[Ndata]; double yExp[Ndata]; double xErrorExp[Ndata]; double yErrorExp[Ndata]; for (int i=0;i<Ndata;i++) { xExp[i] = Rdata[i].energyLab; yExp[i] = Rdata[i].x; xErrorExp[i] = 0.; yErrorExp[i] = Rdata[i].sigma; xFile << xExp[i] << " " << yExp[i] << " " << yErrorExp[i] << endl; } TGraphErrors * graphExp = new TGraphErrors(Ndata,xExp,yExp,xErrorExp, yErrorExp); graphExp->SetMarkerStyle(21); graphExp->Draw("P"); } xFile.close(); ofstream ofFile("ratio.dat"); int const Npoints = 100; double xFit[Npoints]; double yFit[Npoints]; double xStart = log(5.); double xStop = log(300); for (int i=0;i<Npoints;i++) { double xx = (xStop-xStart)/((double)Npoints)*(double)i + xStart; double Elab = exp(xx); xFit[i] = Elab; yFit[i] = getRatio(Elab); ofFile << xFit[i] << " " << yFit[i] << endl; } TGraph * graph = new TGraph(Npoints,xFit,yFit); graph->Draw("L"); canvas->Write(); ofFile.close(); ofFile.clear(); #endif }
layout->add(button2); REQUIRE(button1->getFullSize() == sf::Vector2f(1000, 400)); REQUIRE(button2->getFullSize() == sf::Vector2f(1000, 400)); layout->setRatio(button2, 3); REQUIRE(button1->getFullSize() == sf::Vector2f(1000, 200)); REQUIRE(button2->getFullSize() == sf::Vector2f(1000, 600)); layout->insertSpace(1, 1.5); layout->setRatio(0, 3.5); REQUIRE(button1->getFullSize() == sf::Vector2f(1000, 350)); REQUIRE(button2->getFullSize() == sf::Vector2f(1000, 300)); auto button3 = std::make_shared<tgui::Button>(); layout->add(button3); REQUIRE(layout->getRatio(button1) == 3.5); REQUIRE(layout->getRatio(button2) == 3); REQUIRE(layout->getRatio(button3) == 1); REQUIRE(layout->getRatio(nullptr) == 0); REQUIRE(layout->getRatio(std::make_shared<tgui::Button>()) == 0); REQUIRE(layout->getRatio(0) == 3.5); REQUIRE(layout->getRatio(1) == 1.5); REQUIRE(layout->getRatio(2) == 3); REQUIRE(layout->getRatio(3) == 1); REQUIRE(layout->getRatio(4) == 0); // TODO: Add fixed size tests }
/** * \return True if minor radius and major radius are equal, i.e. ratio is 1.0. */ bool REllipse::isCircular() const { return getRatio()>(1.0-RS::PointTolerance); }
void Slater::updateInverse() { ratio = getRatio(); if (UP) // only updating the UP matrix { int i = currentParticle; SUP.zeros(); // updating all but the ith column of the inverse slater matrix for (int j = 0; j < N; j++) // loop over columns j != i { if (j == i) continue; // not for column i for (int l = 0; l < N; l++) // loop over elements in column j { SUP(j) += slaterUPnew(i,l)*slaterUPinvOld(l,j); } } for (int j = 0; j < N; j++) // loop over columns in the inverse slater matrix { if (j == i) continue; // not updating column i for (int k = 0; k < N; k++) // loop over elements in column j { // maybe we should recalculate the ratio first to be sure?? slaterUPinvNew(k,j) = slaterUPinvOld(k,j) - SUP(j)*slaterUPinvOld(k,i)/ratioUP; } } // updating column i of the inverse slater matrix for (int k = 0; k < N; k++) // loop over elements in i'th column { slaterUPinvNew(k,i) = slaterUPinvOld(k,i)/ratioUP; } } else // only updating the DOWN matrix { int i = currentParticle - N; SDOWN.zeros(); // updating all but the ith column of the inverse slater matrix for (int j = 0; j < N; j++) // loop over columns j != i { if (j == i) continue; // not for column i for (int l = 0; l < N; l++) // loop over elements in column j { SDOWN(j) += slaterDOWNnew(i,l)*slaterDOWNinvOld(l,j); } } for (int j = 0; j < N; j++) // loop over columns in the inverse slater matrix { if (j == i) continue; // not updating column i for (int k = 0; k < N; k++) // loop over elements in column j { // maybe we should recalculate the ratio first to be sure?? slaterDOWNinvNew(k,j) = slaterDOWNinvOld(k,j) - SDOWN(j)*slaterDOWNinvOld(k,i)/ratioDOWN; } } // updating column i of the inverse slater matrix for (int k = 0; k < N; k++) // loop over elements in i'th column { slaterDOWNinvNew(k,i) = slaterDOWNinvOld(k,i)/ratioDOWN; } } }
void VisibilityExtractionDemo::init() { window = generateWindow(); // load a file std::vector<std::string> paths; //paths.push_back("/home/nlichtenberg/1crn.pdb"); paths.push_back("/home/nlichtenberg/1vis.pdb"); //paths.push_back("/home/nlichtenberg/Develop/Mol_Sandbox/resources/TrajectoryFiles/1aon.pdb"); MdTrajWrapper mdwrap; std::auto_ptr<Protein> prot = mdwrap.load(paths); impSph = new ImpostorSpheres(!useAtomicCounters, false); impSph->setProteinData(prot.get()); impSph->init(); num_balls = impSph->num_balls; if(perspectiveProj) projection = perspective(45.0f, getRatio(window), 0.1f, 100.0f); else projection = ortho(-30.0f, 30.0f, -30.0f, 30.0f, 0.0f, 100.0f); if (useAtomicCounters) { spRenderImpostor = ShaderProgram("/VisibleAtomsDetection/Impostor/impostorSpheres_InstancedUA.vert", "/VisibleAtomsDetection/Detection/solidColorInstanceCount.frag"); spRenderDiscs = ShaderProgram("/VisibleAtomsDetection//Impostor/impostorSpheres_InstancedUA.vert", "/VisibleAtomsDetection//Impostor/impostorSpheres_discardFragments_Instanced.frag"); if(perspectiveProj) spRenderBalls = ShaderProgram("/VisibleAtomsDetection/Base/modelViewProjectionInstancedUA.vert", "/VisibleAtomsDetection/Impostor/Impostor3DSphere.frag"); else spRenderBalls = ShaderProgram("/VisibleAtomsDetection/Base/modelViewProjectionInstancedUA.vert", "/VisibleAtomsDetection/Impostor/Impostor3DSphere_Ortho.frag"); } else { spRenderImpostor = ShaderProgram("/VisibleAtomsDetection/Impostor/impostorSpheres_Instanced.vert", "/VisibleAtomsDetection/Detection/solidColorInstanceCount.frag"); spRenderDiscs = ShaderProgram("/VisibleAtomsDetection/Impostor/impostorSpheres_Instanced.vert", "/VisibleAtomsDetection/Impostor/impostorSpheres_discardFragments_Instanced.frag"); spRenderBalls = ShaderProgram("/VisibleAtomsDetection/Impostor/impostorSpheres_Instanced.vert", "/VisibleAtomsDetection/Impostor/Impostor3DSphere.frag"); } /// Renderpass to render impostors/fake geometry renderBalls = new RenderPass( impSph, &spRenderBalls, getWidth(window), getHeight(window)); renderBalls->update("projection", projection); // define projection matrix for other shader programs renderBalls->setShaderProgram(&spRenderDiscs); renderBalls->update("projection", projection); renderBalls->setShaderProgram(&spRenderImpostor); renderBalls->update("projection", projection); /// Renderpass to detect the visible instances collectSurfaceIDs = new RenderPass( new Quad(), new ShaderProgram("/VisibleAtomsDetection/Base/fullscreen.vert", "/VisibleAtomsDetection/Detection/DetectVisibleInstanceIDs.frag"), getWidth(window), getHeight(window)); // prepare 1D buffer for entries tex_collectedIDsBuffer = new Texture(GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_INT); tex_collectedIDsBuffer->genUimageBuffer(num_balls); collectSurfaceIDs->texture("collectedIDsBuffer", tex_collectedIDsBuffer); collectSurfaceIDs->texture("tex", renderBalls->get("InstanceID")); /// renderpass to display result frame result = new RenderPass( new Quad(), new ShaderProgram("/VisibleAtomsDetection/Base/fullscreen.vert", "/VisibleAtomsDetection/Detection/toneMapperLinearInstanceCount.frag")); result->texture("tex", renderBalls->get("fragColor")); /// compute shader to process a list of visible IDs (with the actual instanceID of the first general draw) computeSortedIDs = new ComputeProgram(new ShaderProgram("/VisibleAtomsDetection/Detection/CreateVisibleIDList.comp")); // 1D buffer for visible IDs tex_sortedVisibleIDsBuffer = new Texture(GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT); tex_sortedVisibleIDsBuffer->genUimageBuffer(num_balls); computeSortedIDs->texture("collectedIDsBuffer", tex_collectedIDsBuffer); computeSortedIDs->texture("sortedVisibleIDsBuffer", tex_sortedVisibleIDsBuffer); // atomic counter buffer for consecutive index access in compute shader glGenBuffers(1, &atomBuff); glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomBuff); glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 3, atomBuff); glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), NULL, GL_DYNAMIC_DRAW); glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0); positions_size = sizeof(glm::vec4) * impSph->instance_positions_s.instance_positions.size(); colors_size = sizeof(glm::vec4) * impSph->instance_colors_s.instance_colors.size(); // SSBO setup glGenBuffers(2, SSBO); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[0]); glBufferData(GL_SHADER_STORAGE_BUFFER, positions_size, &impSph->instance_positions_s.instance_positions[0], GL_DYNAMIC_COPY); glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 0, SSBO[0], 0, positions_size); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[1]); glBufferData(GL_SHADER_STORAGE_BUFFER, colors_size, &impSph->instance_colors_s.instance_colors[0], GL_DYNAMIC_COPY); glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 1, SSBO[1], 0, colors_size); glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); // SSBO copy data glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[0]); GLvoid* p_ = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY); memcpy(p_, &impSph->instance_positions_s.instance_positions[0], positions_size); glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[1]); p_ = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY); memcpy(p_, &impSph->instance_colors_s.instance_colors[0], colors_size); glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); // SSBO bind to shaders glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[0]); GLuint block_index = 0; block_index = glGetProgramResourceIndex(spRenderBalls.getProgramHandle(), GL_SHADER_STORAGE_BLOCK, "instance_positions_t"); glShaderStorageBlockBinding(spRenderBalls.getProgramHandle(), block_index, 0); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[1]); block_index = glGetProgramResourceIndex(spRenderBalls.getProgramHandle(), GL_SHADER_STORAGE_BLOCK, "instance_colors_t"); glShaderStorageBlockBinding(spRenderBalls.getProgramHandle(), block_index, 1); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[0]); block_index = glGetProgramResourceIndex(spRenderDiscs.getProgramHandle(), GL_SHADER_STORAGE_BLOCK, "instance_positions_t"); glShaderStorageBlockBinding(spRenderBalls.getProgramHandle(), block_index, 0); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[1]); block_index = glGetProgramResourceIndex(spRenderDiscs.getProgramHandle(), GL_SHADER_STORAGE_BLOCK, "instance_colors_t"); glShaderStorageBlockBinding(spRenderBalls.getProgramHandle(), block_index, 1); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[0]); block_index = glGetProgramResourceIndex(spRenderImpostor.getProgramHandle(), GL_SHADER_STORAGE_BLOCK, "instance_positions_t"); glShaderStorageBlockBinding(spRenderBalls.getProgramHandle(), block_index, 0); glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO[1]); block_index = glGetProgramResourceIndex(spRenderImpostor.getProgramHandle(), GL_SHADER_STORAGE_BLOCK, "instance_colors_t"); glShaderStorageBlockBinding(spRenderBalls.getProgramHandle(), block_index, 1); // prepare data to reset the buffer that holds the visible instance IDs int byteCount = sizeof(unsigned int)* num_balls; zeros = new unsigned char[byteCount]; unsigned int f = 0; unsigned char const * p = reinterpret_cast<unsigned char const *>(&f); for (int i = 0; i < byteCount; i+=4) { zeros[i] = p[0]; zeros[i+1] = p[1]; zeros[i+2] = p[2]; zeros[i+3] = p[3]; } // prepare buffer with index = value // used to draw all istances identityInstancesMap.clear(); for (GLuint i = 0; i < num_balls; i++) identityInstancesMap.push_back(i); glBindTexture(GL_TEXTURE_1D, tex_sortedVisibleIDsBuffer->getHandle()); glTexImage1D(GL_TEXTURE_1D, 0, GL_R32UI, num_balls, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, &identityInstancesMap[0]); // map to set all instances visible mapAllVisible.resize(num_balls); std::fill(mapAllVisible.begin(), mapAllVisible.end(), 1); // time query GLuint timeQuery; glGenQueries(1, &timeQuery); glEnable(GL_DEPTH_TEST); }
void getSpectrumPP05(const char *pid) { gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetErrorX(0); bool subtractNEUTRONS=kTRUE; //neutron data: //hadron data for Levy function, nucl-ex/0601033: //--> d^2N/(2*pi*pT*N*dpT*dy) = B/((1+((mT - m0)/nT))^n) // {p-dAu; pbar-dAu; p-pp; pbar-pp} and m0 = m_neutron = 1.0 GeV. double B[]={0.3,0.23,0.072,0.061};//->[0] //double eB[]={0.01,0.01,0.005,0.005}; double T[]={0.205,0.215,0.179,0.173};//->[1] //double eT[]={0.004,0.005,0.006,0.006}; double n[]={11.00,12.55,10.87,10.49};//->[2] //double en[]={0.29,0.41,0.43,0.40}; double BR=35.8/63.9;//->p + pi- (63.9%) : ->n + pi0 (35.8%) double c_feeddown=0.8+0.2*BR; double CPVloss=0.98;//for minbias TF1 *f_nbar=new TF1("f_nbar","[3]*[4]*[0]/pow((1.+(sqrt(x*x+1.) - 1.)/([1]*[2])),[2])",0.,15.); f_nbar->SetParameters(B[3],T[3],n[3],c_feeddown,CPVloss); //get direct gammas pQCD: ifstream pQCDphotons("./datapoints/pQCD_Werner/rhic_cteq6_gamma_inv_sc1.dat"); float ppx[100]; float ppy[100]; Int_t iii=0; cout<<"pqcd photons:"<<endl; while(iii<28){ if(!pQCDphotons.good()) break; float dummy=0.; pQCDphotons>>ppx[iii]>>dummy>>dummy>>ppy[iii]; ppy[iii]*=1.e-09;//convert to mb iii++; } TGraph *g_dirgamma=new TGraph(iii,ppx,ppy); //get direct gammas pQCD: scale 0.5*pT ifstream pQCDphotons05("./datapoints/pQCD_Werner/rhic_cteq6_gamma_inv_sc05.dat"); float ppx05[100]; float ppy05[100]; Int_t iii05=0; while(iii05<28){ if(!pQCDphotons05.good()) break; float dummy=0.; pQCDphotons05>>ppx05[iii05]>>dummy>>dummy>>ppy05[iii05]; ppy05[iii05]*=1.e-09;//convert to mb iii05++; } TGraph *g_dirgamma05=new TGraph(iii05,ppx05,ppy05); //get direct gammas pQCD: scale 2*pT ifstream pQCDphotons2("./datapoints/pQCD_Werner/rhic_cteq6_gamma_inv_sc2.dat"); float ppx2[100]; float ppy2[100]; Int_t iii2=0; while(iii2<28){ if(!pQCDphotons2.good()) break; float dummy=0.; pQCDphotons2>>ppx2[iii2]>>dummy>>dummy>>ppy2[iii2]; ppy2[iii2]*=1.e-09;//convert to mb iii2++; } TGraph *g_dirgamma2=new TGraph(iii2,ppx2,ppy2); //get phenix pions in pp ifstream phenix("./datapoints/phenix_xsec_pp.dat"); float phex[100]; float phey[100]; Int_t iphe=0; while(iphe<16){ if(!phenix.good()) break; phenix>>phex[iphe]>>phey[iphe]; //is in mb already!! iphe++; } TGraphErrors *phenix_pp=new TGraphErrors(iphe,phex,phey); phenix_pp->SetMarkerStyle(24); phenix_pp->SetLineWidth(6); phenix_pp->SetName("phenix_pp"); //frank's spin2006 pions: ifstream frank("./datapoints/frank_pp05_new.dat"); float frx[100]; float fry[100]; float frex[100]; float frey[100]; Int_t ifr=0; while(ifr<12){ if(!frank.good()) break; frank>>frx[ifr]>>fry[ifr]>>frey[ifr]; frex[ifr]=0.; ifr++; } TGraphErrors *frank_pp=new TGraphErrors(ifr,frx,fry,frex,frey); frank_pp->SetMarkerStyle(25); frank_pp->SetMarkerColor(4); frank_pp->SetName("frank_pp"); //sasha's pions: float x_pp2005_sasha[]={1.20358,1.70592,2.21238,2.71916,3.4032,4.4224,5.43571,6.44468,7.45056,8.83794,10.8659,12.8831,15.2692 }; float xe_pp2005_sasha[]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; float y_pp2005_sasha[]={0.212971,0.0337464,0.00811345,0.00248195,0.000467495,6.37683e-05,1.4487e-05,3.67539e-06,1.26723e-06,3.3676e-07,8.01941e-08,1.93813e-08,5.56059e-09}; float ye_pp2005_sasha[]={0.00463771,0.000949529,0.000323778,0.000139023,3.68181e-05,7.61527e-07,2.28359e-07,9.19064e-08,4.93116e-08,8.16844e-09,3.66273e-09,1.75057e-09,7.36722e-10}; TGraphErrors *sasha_pp05=new TGraphErrors(13,x_pp2005_sasha,y_pp2005_sasha,xe_pp2005_sasha,ye_pp2005_sasha); sasha_pp05->SetMarkerStyle(8); sasha_pp05->SetMarkerColor(TColor::GetColor(8,80,8)); sasha_pp05->SetName("sasha_pp05"); //get pions KKP scale pT ifstream pQCDpions("./datapoints/pQCD_Werner/klaus_pi0inv_200_kkp_1.dat"); float pionx[100]; float piony[100]; Int_t ipion=0; while(ipion<28){ if(!pQCDpions.good()) break; pQCDpions>>pionx[ipion]>>piony[ipion]; piony[ipion]*=1.e-09;//convert to mb ipion++; } TGraphErrors *kkp=new TGraphErrors(ipion,pionx,piony); kkp->SetLineColor(54); kkp->SetName("kkp"); //get pions KKP scale 0.5*pT ifstream pQCDpions05("./datapoints/pQCD_Werner/klaus_pi0inv_200_kkp_05.dat"); float pionx05[100]; float piony05[100]; Int_t ipion05=0; while(ipion05<28){ if(!pQCDpions05.good()) break; pQCDpions05>>pionx05[ipion05]>>piony05[ipion05]; piony05[ipion05]*=1.e-09;//convert to mb ipion05++; } TGraphErrors *kkp05=new TGraphErrors(ipion05,pionx05,piony05); kkp05->SetLineStyle(2); kkp05->SetLineColor(54); kkp05->SetName("kkp05"); //get pions KKP scale 2*pT ifstream pQCDpions2("./datapoints/pQCD_Werner/klaus_pi0inv_200_kkp_2.dat"); float pionx2[100]; float piony2[100]; Int_t ipion2=0; while(ipion2<28){ if(!pQCDpions2.good()) break; pQCDpions2>>pionx2[ipion2]>>piony2[ipion2]; piony2[ipion2]*=1.e-09;//convert to mb ipion2++; } TGraphErrors *kkp2=new TGraphErrors(ipion2,pionx2,piony2); kkp2->SetLineStyle(2); kkp2->SetLineColor(54); kkp2->SetName("kkp2"); TFile *f_decaybg=new TFile("~/MyDecay/gammaDecayPPSum.root","OPEN"); TH1F *h_decaybg=(TH1F*)f_decaybg->Get("gamma"); TH1F *h_decaypion=(TH1F*)f_decaybg->Get("gamma_pion"); TF1 *fit_decay=new TF1("fit_decay","[0]/pow(x,[1])+[2]",.3,15.); TF1 *fit_piondecay=new TF1(*fit_decay); fit_decay->SetParameters(1.,1.,.5); fit_piondecay->SetParameters(1.,1.,.5); h_decaybg->Fit(fit_decay,"R0Q"); h_decaypion->Fit(fit_piondecay,"R0Q"); //take ratio gamma_direct/pion and divide by gamma/pi and then +1: for(Int_t i=0;i<iii;i++){ ppy[i]=ppy[i]/piony[i]; ppy[i]=ppy[i]/fit_decay->Eval(ppx[i]); ppy[i]+=1.; ppy05[i]=ppy05[i]/piony05[i]; ppy05[i]=ppy05[i]/fit_decay->Eval(ppx05[i]); ppy05[i]+=1.; ppy2[i]=ppy2[i]/piony2[i]; ppy2[i]=ppy2[i]/fit_decay->Eval(ppx2[i]); ppy2[i]+=1.; } TGraphErrors *g_photonpqcd=new TGraphErrors(iii,ppx,ppy); g_photonpqcd->SetName("g_photonpqcd"); TGraphErrors *g_photonpqcd05=new TGraphErrors(iii05,ppx05,ppy05); g_photonpqcd05->SetName("g_photonpqcd05"); TGraphErrors *g_photonpqcd2=new TGraphErrors(iii2,ppx2,ppy2); g_photonpqcd2->SetName("g_photonpqcd2"); //set outputfiles TString dir("/star/u/russcher/gamma/analysis/output/pp05/"); dir.Append(pid); dir.Append("/"); dir.Append(pid); TString psout=dir; TString psout_eta=dir; TString psout2=dir; TString psout3=dir; TString eFile=dir; TString eFileGamma=dir; TString pi0File=dir; TString nbarFile=dir; TString nbarOut=dir; eFile.Append("pion_eff.root"); eFileGamma.Append("gamma_eff.root"); pi0File.Append("pi0_pp05.root"); nbarFile.Append("antineutron_eff.root"); nbarOut.Append("nbar_contam.ps"); psout2.Append("correctedspec.ps"); psout_eta.Append("/dev/null"); psout.Append("invmassplots.ps"); //load *.so gSystem->Load("$HOME/MyEvent/MyEvent"); gSystem->Load("$HOME/gamma/analysis/lib/AnaCuts"); gSystem->Load("$HOME/gamma/analysis/lib/EventMixer"); gSystem->Load("$HOME/gamma/analysis/lib/Pi0Analysis"); AnaCuts *cuts=new AnaCuts("pp05"); //get inv mass hists TFile f(pi0File.Data(),"OPEN"); TH2F *h_mb=new TH2F(*h_minvMB); TH2F *h_ht1=new TH2F(*h_minvHT1); TH2F *h_ht2=new TH2F(*h_minvHT2); TH1F *h_ev=new TH1F(*h_events); //get anti-neutron TFile *file_nbar=new TFile(nbarFile,"OPEN"); TH1F *h_nbarEffMB=new TH1F(*h_effMB); h_nbarEffMB->Sumw2(); TH1F *h_nbarEffHT1=new TH1F(*h_effHT1); h_nbarEffHT1->Sumw2(); TH1F *h_nbarEffHT2=new TH1F(*h_effHT2); h_nbarEffHT2->Sumw2(); //get prescales int trigger=0; Int_t numberOfMB=0; Int_t numberOfHT1=0; Int_t numberOfHT2=0; for(Int_t i=1;i<=h_ev->GetNbinsX();i++) { trigger=(Int_t)h_ev->GetBinCenter(i); if(trigger&1) numberOfMB+=(Int_t)h_ev->GetBinContent(i); if(trigger&2) numberOfHT1+=(Int_t)h_ev->GetBinContent(i); if(trigger&4) numberOfHT2+=(Int_t)h_ev->GetBinContent(i); } cout<<"number of mb: "<<numberOfMB<<endl; //numberOfMB/=0.63; //cout<<"nmb after 62% vertex eff.: "<<numberOfMB<<endl; float psMB=32742; float psHT1=3.89; float psHT2=1.; //mb events for hightower: float nMBwithHT=328871; //get efficiencies+acceptance TFile g(eFile.Data(),"OPEN"); TH1F *h_emb=new TH1F(*h_effMB); TH1F *h_eht1=new TH1F(*h_effHT1); TH1F *h_eht2=new TH1F(*h_effHT2); //bin corrections TFile binf("~/BinWidth/bincorrectionsPP.root","OPEN"); TH1F *h_binmb=new TH1F(*h4mb); TH1F *h_binht1=new TH1F(*h4ht1); TH1F *h_binht2=new TH1F(*h4ht2); h_binmb->Sumw2(); h_binht1->Sumw2(); h_binht2->Sumw2(); for(Int_t i=1;i<=h_binmb->GetNbinsX();i++) h_binmb->SetBinError(i,0); for(Int_t i=1;i<=h_binht1->GetNbinsX();i++) h_binht1->SetBinError(i,0); for(Int_t i=1;i<=h_binht2->GetNbinsX();i++) h_binht2->SetBinError(i,0); //corrections, all multiplicative, in case of //pions: TF1 *pion_cpv_corrMB=new TF1("pion_cpv_corrMB","1./(1.-0.01*(0.3+0.0*x))",0.,15.); TF1 *pion_cpv_corrHT1=new TF1("pion_cpv_corrHT1","1./(1.-0.01*(-0.1+0.16*x))",0.,15.); TF1 *pion_cpv_corrHT2=new TF1("pion_cpv_corrHT2","1./(1.-0.01*(-0.2+0.18*x))",0.,15.); //photons: TF1 *gamma_cpv_corrMB=new TF1("gamma_cpv_corrMB","1./(1.-0.01*(2.8+0.0*x))",0.,15.); TF1 *gamma_cpv_corrHT1=new TF1("gamma_cpv_corrHT1","1./(1.-0.01*(0.2+1.1*x))",0.,15.); TF1 *gamma_cpv_corrHT2=new TF1("gamma_cpv_corrHT2","1./(1.-0.01*(0.4+1.1*x))",0.,15.); TF1 *gamma_cont_corrMB=new TF1("gamma_cont_corrMB","0.985",0.,15.); TF1 *gamma_cont_corrHT1=new TF1("gamma_cont_corrHT1","0.98",0.,15.); TF1 *gamma_cont_corrHT2=new TF1("gamma_cont_corrHT2","0.96",0.,15.); //missing material //pions: TF1 *pion_conv_corrMB=new TF1("pion_conv_corrMB","1.1",0.,15.); TF1 *pion_conv_corrHT1=new TF1("pion_conv_corrHT1","1.1",0.,15.); TF1 *pion_conv_corrHT2=new TF1("pion_conv_corrHT2","1.1",0.,15.); //photons: TF1 *gamma_conv_corrMB=new TF1("gamma_conv_corrMB","1.05",0.,15.); TF1 *gamma_conv_corrHT1=new TF1("gamma_conv_corrHT1","1.05",0.,15.); TF1 *gamma_conv_corrHT2=new TF1("gamma_conv_corrHT2","1.05",0.,15.); //get yield Pi0Analysis *pi0=new Pi0Analysis(psout.Data(),psout_eta.Data(),"pp05"); pi0->init("/dev/null"); TH1F *pionYieldMB=new TH1F(*pi0->getYield(h_mb,"mb")); TH1F *pionYieldHT1=new TH1F(*pi0->getYield(h_ht1,"ht1")); TH1F *pionYieldHT2=new TH1F(*pi0->getYield(h_ht2,"ht2")); pi0->storeCanvases((dir+"canvases.root").Data()); cout<<"***************************************"<<endl; cout<<"got yield, dividing by rapidity bite!!!"<<endl; float dy_gamma=cuts->rapidityMaxCUT - cuts->rapidityMinCUT; float dy_pion=cuts->rapPionMaxCUT - cuts->rapPionMinCUT; cout<<"***************************************"<<endl; cout<<endl; cout<<" pion bite is "<<dy_pion<<endl; cout<<" gamma bite is "<<dy_gamma<<endl; cout<<endl; cout<<"***************************************"<<endl; pionYieldMB->Scale(1./dy_pion); pionYieldHT1->Scale(1./dy_pion); pionYieldHT2->Scale(1./dy_pion); //set yield to zero /* for(Int_t i=0;i<pionYieldHT2->GetNbinsX();i++) { if(i<1) { pionYieldMB->SetBinContent(i+1,0); pionYieldMB->SetBinError(i+1,0); } if(i<4) { pionYieldHT1->SetBinContent(i+1,0); pionYieldHT1->SetBinError(i+1,0); } if(i>12) { pionYieldHT1->SetBinContent(i+1,0); pionYieldHT1->SetBinError(i+1,0); } if(i<6) { pionYieldHT2->SetBinContent(i+1,0); pionYieldHT2->SetBinError(i+1,0); } } */ //set colors: pionYieldMB->SetMarkerStyle(8); pionYieldMB->SetMarkerSize(1.0); pionYieldHT1->SetMarkerStyle(8); pionYieldHT1->SetMarkerSize(1.0); pionYieldHT1->SetMarkerColor(4); pionYieldHT2->SetMarkerStyle(8); pionYieldHT2->SetMarkerSize(1.0); pionYieldHT2->SetMarkerColor(2); TF1 *scale=new TF1("scale","x",0.,15.); pionYieldMB->SetNameTitle("pionYieldMB","corrected yield MB"); pionYieldMB->Divide(h_emb); pionYieldMB->Scale(psMB/(psMB*numberOfMB*2.*TMath::Pi())); pionYieldMB->Divide(scale); pionYieldMB->Multiply(h_binmb); pionYieldMB->Multiply(pion_cpv_corrMB); pionYieldMB->Multiply(pion_conv_corrMB); pionYieldHT1->SetNameTitle("pionYieldHT1","corrected yield HT1"); pionYieldHT1->Divide(h_eht1); pionYieldHT1->Scale(psHT1/(psMB*nMBwithHT*2.*TMath::Pi())); pionYieldHT1->Divide(scale); pionYieldHT1->Multiply(h_binht1); pionYieldHT1->Multiply(pion_cpv_corrHT1); pionYieldHT1->Multiply(pion_conv_corrHT1); pionYieldHT2->SetNameTitle("pionYieldHT2","corrected yield HT2"); pionYieldHT2->Divide(h_eht2); pionYieldHT2->Scale(psHT2/(psMB*nMBwithHT*2.*TMath::Pi())); pionYieldHT2->Divide(scale); pionYieldHT2->Multiply(h_binht2); pionYieldHT2->Multiply(pion_cpv_corrHT2); pionYieldHT2->Multiply(pion_conv_corrHT2); //create pion yield for double ratio: TH1F *pionYieldMBratio=new TH1F(*pionYieldMB); TH1F *pionYieldHT1ratio=new TH1F(*pionYieldHT1); TH1F *pionYieldHT2ratio=new TH1F(*pionYieldHT2); TH1F *pionXsMB=new TH1F(*pionYieldMB); TH1F *pionXsHT1=new TH1F(*pionYieldHT1); TH1F *pionXsHT2=new TH1F(*pionYieldHT2); pionXsMB->Scale((26.1/0.85));//times xs_bbc/bbc_eff pionXsHT1->Scale((26.1/0.85)); pionXsHT2->Scale((26.1/0.85)); TH1F *pionXsMBnoErr=new TH1F(*pionXsMB); TH1F *pionXsHT1noErr=new TH1F(*pionXsHT1); TH1F *pionXsHT2noErr=new TH1F(*pionXsHT2); for(int i=1;i<=pionXsMBnoErr->GetNbinsX();i++){ pionXsMBnoErr->SetBinError(i,0.); } for(int i=1;i<=pionXsHT1noErr->GetNbinsX();i++){ pionXsHT1noErr->SetBinError(i,0.); } for(int i=1;i<=pionXsHT2noErr->GetNbinsX();i++){ pionXsHT2noErr->SetBinError(i,0.); } TGraphErrors *g_pionXsMB=new TGraphErrors(pionXsMB); g_pionXsMB->SetName("g_pionXsMB"); removeThesePoints(g_pionXsMB,1); TGraphErrors *g_pionXsHT1=new TGraphErrors(pionXsHT1); g_pionXsHT1->SetName("g_pionXsHT1"); removeThesePoints(g_pionXsHT1,2); TGraphErrors *g_pionXsHT2=new TGraphErrors(pionXsHT2); g_pionXsHT2->SetName("g_pionXsHT2"); removeThesePoints(g_pionXsHT2,3); if(0){ cout<<endl<<"xsec: x y ex ey"<<endl; cout<<"minbias"<<endl; printPoints(g_pionXsMB); cout<<endl<<"hightower-1"<<endl; printPoints(g_pionXsHT1); cout<<endl<<"hightower-2"<<endl; printPoints(g_pionXsHT2); cout<<endl; } TMultiGraph *m_pions_fit=new TMultiGraph(); m_pions_fit->SetName("m_pions_fit"); m_pions_fit->SetMinimum(5.0e-9); m_pions_fit->SetMaximum(0.99); m_pions_fit->Add(g_pionXsMB); m_pions_fit->Add(g_pionXsHT1); m_pions_fit->Add(g_pionXsHT2); TF1 *fitQCD=new TF1("fitQCD",sumpqcd,1.,15.,6); fitQCD->SetParameters(600.,-8.2,4.,-8.5,2.,2.); fitQCD->FixParameter(4,2.); m_pions_fit->Fit(fitQCD,"R"); bool inclPhenix=false; bool inclFrank=false; bool inclSasha=false; bool inclPqcd=false; TCanvas *compare=new TCanvas("compare","compare;p_{T}:xsec (mb)",600,750); compare->cd(); TPad *padt=new TPad("padt","",0.0,0.3,1.,1.0); padt->SetBottomMargin(0.001); padt->SetLeftMargin(0.15); TPad *padb=new TPad("padb","",0.0,0.0,1.,0.3); padb->SetTopMargin(0.001); padb->SetBottomMargin(0.25); padb->SetLeftMargin(0.15); padt->Draw(); padt->cd(); gPad->SetLogy(); TMultiGraph *m_pions=new TMultiGraph(); m_pions->SetName("m_pions"); if(inclPqcd){ m_pions->Add(kkp,"c"); m_pions->Add(kkp05,"c"); m_pions->Add(kkp2,"c"); } if(inclSasha){ m_pions->Add(sasha_pp05); } if(inclFrank){ m_pions->Add(frank_pp); } if(inclPhenix){ m_pions->Add(phenix_pp); } //g_pionXsMB->Print(); //cout<<endl<<endl; //g_pionXsHT1->Print(); //cout<<endl<<endl; //g_pionXsHT2->Print(); //cout<<endl; m_pions->Add(g_pionXsMB); m_pions->Add(g_pionXsHT1); m_pions->Add(g_pionXsHT2); m_pions->SetMinimum(1.0e-9); m_pions->SetMaximum(1.); m_pions->Draw("ap"); //fitQCD->Draw("same"); m_pions->GetXaxis()->SetLabelSize(0.); m_pions->GetYaxis()->SetTitle("Ed^{3}#sigma/dp^{3} (mb GeV^{-2}c^{2})"); TLegend *leg=new TLegend(.5,.5,.85,.85); if(inclPhenix) leg->AddEntry(phenix_pp,"PHENIX p+p","p"); if(inclFrank) leg->AddEntry(frank_pp,"STAR preliminary (upd.)","p"); if(inclSasha) leg->AddEntry(sasha_pp05,"O.Grebenyuk p+p","p"); leg->AddEntry(g_pionXsMB,"p+p minimum bias","p"); leg->AddEntry(g_pionXsHT1,"hightower 1","p"); leg->AddEntry(g_pionXsHT2,"hightower 2","p"); if(inclPqcd){ leg->AddEntry(kkp,"kkp + CTEQ6m, #mu=p_{T}","l"); leg->AddEntry(kkp2,"#mu=2p_{T},p_{T}/2","l"); leg->Draw("same"); } leg->SetFillColor(0); leg->Draw(); compare->cd(); padb->Draw(); padb->cd(); TGraphErrors *sasha_pp05_overPqcd=new TGraphErrors(*sasha_pp05); divideGraphWithGraph(sasha_pp05_overPqcd,kkp); TGraphErrors *phenix_pp05_overPqcd=new TGraphErrors(*phenix_pp); divideGraphWithGraph(phenix_pp05_overPqcd,kkp); TGraphErrors *g_pionXsMB_overPqcd=new TGraphErrors(*g_pionXsMB); divideGraphWithGraph(g_pionXsMB_overPqcd,kkp); TGraphErrors *g_pionXsHT1_overPqcd=new TGraphErrors(*g_pionXsHT1); divideGraphWithGraph(g_pionXsHT1_overPqcd,kkp); TGraphErrors *g_pionXsHT2_overPqcd=new TGraphErrors(*g_pionXsHT2); divideGraphWithGraph(g_pionXsHT2_overPqcd,kkp); TGraphErrors *frank_pp05_overPqcd=new TGraphErrors(*frank_pp); divideGraphWithGraph(frank_pp05_overPqcd,kkp); TGraphErrors *kkp05_ratio=new TGraphErrors(*kkp05); divideGraphWithGraph(kkp05_ratio,kkp); TGraphErrors *kkp_ratio=new TGraphErrors(*kkp); divideGraphWithGraph(kkp_ratio,kkp); TGraphErrors *kkp2_ratio=new TGraphErrors(*kkp2); divideGraphWithGraph(kkp2_ratio,kkp); //systematic errors: TGraphErrors *g_pionXsMB_sys=new TGraphErrors(*g_pionXsMB_overPqcd); set_sys_pp_pion(g_pionXsMB_sys); TGraphErrors *g_pionXsHT1_sys=new TGraphErrors(*g_pionXsHT1_overPqcd); set_sys_pp_pion(g_pionXsHT1_sys); TGraphErrors *g_pionXsHT2_sys=new TGraphErrors(*g_pionXsHT2_overPqcd); set_sys_pp_pion(g_pionXsHT2_sys); TMultiGraph *m_pions_over_pqcd=new TMultiGraph(); m_pions_over_pqcd->SetMinimum(0.0); m_pions_over_pqcd->SetMaximum(2.5); if(inclPqcd){ m_pions_over_pqcd->Add(kkp05_ratio,"c"); m_pions_over_pqcd->Add(kkp_ratio,"c"); m_pions_over_pqcd->Add(kkp2_ratio,"c"); } m_pions_over_pqcd->Add(g_pionXsMB_overPqcd); m_pions_over_pqcd->Add(g_pionXsHT1_overPqcd); m_pions_over_pqcd->Add(g_pionXsHT2_overPqcd); //m_pions_over_pqcd->Add(g_pionXsMB_sys,"c"); //m_pions_over_pqcd->Add(g_pionXsHT1_sys,"c"); //m_pions_over_pqcd->Add(g_pionXsHT2_sys,"c"); if(inclPhenix) m_pions_over_pqcd->Add(phenix_pp05_overPqcd); if(inclFrank) m_pions_over_pqcd->Add(frank_pp05_overPqcd); if(inclSasha) m_pions_over_pqcd->Add(sasha_pp05_overPqcd); //m_pions_over_pqcd->Draw("ap"); //m_pions_over_pqcd->GetXaxis()->SetTitle("p_{T} (GeV/c)"); compare->SaveAs((dir+"pionxsec_pp.eps").Data()); compare->SaveAs((dir+"pionxsec_pp.root").Data()); TMultiGraph *m_pions_over_fit=new TMultiGraph(); m_pions_over_fit->SetMinimum(0.01); m_pions_over_fit->SetMaximum(1.99); TGraphErrors *g_pionXsMB_overFit=new TGraphErrors(*g_pionXsMB); divideGraphWithFunction(g_pionXsMB_overFit,fitQCD); TGraphErrors *g_pionXsHT1_overFit=new TGraphErrors(*g_pionXsHT1); divideGraphWithFunction(g_pionXsHT1_overFit,fitQCD); TGraphErrors *g_pionXsHT2_overFit=new TGraphErrors(*g_pionXsHT2); divideGraphWithFunction(g_pionXsHT2_overFit,fitQCD); m_pions_over_fit->Add(g_pionXsMB_overFit); m_pions_over_fit->Add(g_pionXsHT1_overFit); m_pions_over_fit->Add(g_pionXsHT2_overFit); m_pions_over_fit->Draw("ap"); compare->SaveAs((dir+"pionxsec_pp_overfit.eps").Data()); compare->SaveAs((dir+"pionxsec_pp_overfit.root").Data()); TCanvas *compare2=new TCanvas("compare2","compare2;p_{T};yield divided by fit",600,300); compare2->cd(); //divide by fit: TGraphErrors *frank_pp2=new TGraphErrors(*frank_pp); divideGraphWithFunction(frank_pp2,fitQCD); TGraphErrors *sasha_pp2=new TGraphErrors(*sasha_pp05); divideGraphWithFunction(sasha_pp2,fitQCD); TGraphErrors *phenix_pp2=new TGraphErrors(*phenix_pp); divideGraphWithFunction(phenix_pp2,fitQCD); TGraphErrors *g_pionXsMBcopy=new TGraphErrors(*g_pionXsMB); divideGraphWithFunction(g_pionXsMBcopy,fitQCD); TGraphErrors *g_pionXsHT1copy=new TGraphErrors(*g_pionXsHT1); divideGraphWithFunction(g_pionXsHT1copy,fitQCD); TGraphErrors *g_pionXsHT2copy=new TGraphErrors(*g_pionXsHT2); divideGraphWithFunction(g_pionXsHT2copy,fitQCD); inclPhenix=true; inclFrank=false; inclSasha=false; inclPqcd=false; TMultiGraph *m_pions2=new TMultiGraph(); m_pions2->SetName("m_pions2"); if(inclSasha) m_pions2->Add(sasha_pp2); if(inclFrank) m_pions2->Add(frank_pp2); if(inclPhenix) m_pions2->Add(phenix_pp2); m_pions2->Add(g_pionXsMBcopy); m_pions2->Add(g_pionXsHT1copy); m_pions2->Add(g_pionXsHT2copy); m_pions2->SetMinimum(0.000001); m_pions2->SetMaximum(3.); m_pions2->Draw("ap"); TLegend *legg=new TLegend(.25,.55,.65,.85); legg->AddEntry(g_pionXsMBcopy,"minimum bias","p"); legg->AddEntry(g_pionXsHT1copy,"hightower 1","p"); legg->AddEntry(g_pionXsHT2copy,"hightower 2","p"); if(inclFrank) legg->AddEntry(frank_pp2,"Frank's p+p (upd.)","p"); if(inclSasha) legg->AddEntry(sasha_pp2,"Sasha's p+p","p"); if(inclPhenix) legg->AddEntry(phenix_pp,"PHENIX p+p","p"); legg->Draw("same"); legg->SetFillColor(0); compare2->cd(0); compare2->SaveAs((dir+"pionxsec_pp_ratio.eps").Data()); compare2->SaveAs((dir+"pionxsec_pp_ratio.root").Data()); //******************************************** // Get double ratio: //******************************************** //pion decay photon eff: TFile gg(eFile.Data(),"OPEN"); TH1F *effGammaMB=new TH1F(*h_effDaughtersMB); TH1F *effGammaHT1=new TH1F(*h_effDaughtersHT1); TH1F *effGammaHT2=new TH1F(*h_effDaughtersHT2); //single photon eff: TFile gg_single(eFileGamma.Data(),"OPEN"); TH1F *effGammaSingleMB=new TH1F(*h_effMB); TH1F *effGammaSingleHT1=new TH1F(*h_effHT1); TH1F *effGammaSingleHT2=new TH1F(*h_effHT2); //raw neutral clusters: TFile ff(pi0File.Data(),"OPEN"); TH1F *gammaYieldMB=new TH1F(*h_gammaMB); TH1F *gammaYieldHT1=new TH1F(*h_gammaHT1); TH1F *gammaYieldHT2=new TH1F(*h_gammaHT2); //divide rap. bite: gammaYieldMB->Scale(1./dy_gamma); gammaYieldHT1->Scale(1./dy_gamma); gammaYieldHT2->Scale(1./dy_gamma); for(Int_t i=1;i<=gammaYieldMB->GetNbinsX();i++){ gammaYieldMB->SetBinContent(i,gammaYieldMB->GetBinContent(i)/gammaYieldMB->GetXaxis()->GetBinWidth(i)); gammaYieldMB->SetBinError(i,gammaYieldMB->GetBinError(i)/gammaYieldMB->GetXaxis()->GetBinWidth(i)); } gammaYieldMB->Scale(psMB/(psMB*numberOfMB*2.*TMath::Pi())); gammaYieldMB->Divide(scale);// ../pT gammaYieldMB->Multiply(h_binmb); gammaYieldMB->Divide(effGammaMB); gammaYieldMB->Multiply(gamma_cpv_corrMB); gammaYieldMB->Multiply(gamma_cont_corrMB); gammaYieldMB->Multiply(gamma_conv_corrMB); gammaYieldMB->SetMarkerStyle(8); gammaYieldMB->SetMarkerSize(1.); TGraphErrors *g_inclPhotonsMB=new TGraphErrors(gammaYieldMB); for(Int_t i=1;i<=gammaYieldHT1->GetNbinsX();i++){ gammaYieldHT1->SetBinContent(i,gammaYieldHT1->GetBinContent(i)/gammaYieldHT1->GetXaxis()->GetBinWidth(i)); gammaYieldHT1->SetBinError(i,gammaYieldHT1->GetBinError(i)/gammaYieldHT1->GetXaxis()->GetBinWidth(i)); } gammaYieldHT1->Scale(psHT1/(psMB*nMBwithHT*2.*TMath::Pi())); gammaYieldHT1->Divide(scale);// ../pT gammaYieldHT1->Multiply(h_binht1); gammaYieldHT1->Divide(effGammaHT1); gammaYieldHT1->Multiply(gamma_cpv_corrHT1); gammaYieldHT1->Multiply(gamma_cont_corrHT1); gammaYieldHT1->Multiply(gamma_conv_corrHT1); gammaYieldHT1->SetMarkerStyle(8); gammaYieldHT1->SetMarkerSize(1.); gammaYieldHT1->SetMarkerColor(4); TGraphErrors *g_inclPhotonsHT1=new TGraphErrors(gammaYieldHT1); for(Int_t i=1;i<=gammaYieldHT2->GetNbinsX();i++){ gammaYieldHT2->SetBinContent(i,gammaYieldHT2->GetBinContent(i)/gammaYieldHT2->GetXaxis()->GetBinWidth(i)); gammaYieldHT2->SetBinError(i,gammaYieldHT2->GetBinError(i)/gammaYieldHT2->GetXaxis()->GetBinWidth(i)); } gammaYieldHT2->Scale(psHT2/(psMB*nMBwithHT*2.*TMath::Pi())); gammaYieldHT2->Divide(scale);// ../pT gammaYieldHT2->Multiply(h_binht2); gammaYieldHT2->Divide(effGammaHT2); gammaYieldHT2->Multiply(gamma_cpv_corrHT2); gammaYieldHT2->Multiply(gamma_cont_corrHT2); gammaYieldHT2->Multiply(gamma_conv_corrHT2); gammaYieldHT2->SetMarkerStyle(8); gammaYieldHT2->SetMarkerSize(1.); gammaYieldHT2->SetMarkerColor(2); TGraphErrors *g_inclPhotonsHT2=new TGraphErrors(gammaYieldHT2); removeThesePoints(g_inclPhotonsMB,1); removeThesePoints(g_inclPhotonsHT1,2); removeThesePoints(g_inclPhotonsHT2,2); TMultiGraph *m_incl=new TMultiGraph(); m_incl->SetName("m_incl"); m_incl->SetTitle("inclusive photon invariant yield 0<y<1;p_{T} (GeV/c);#frac{1}{2#piNp_{T}} #frac{d^{2}N}{dydp_{T}}"); m_incl->Add(g_inclPhotonsMB); m_incl->Add(g_inclPhotonsHT1); m_incl->Add(g_inclPhotonsHT2); m_incl->Fit(fitQCD,"R0"); m_incl->SetMinimum(1.e-11); m_incl->SetMaximum(10.); TCanvas *c_incl=new TCanvas("c_incl","c_incl",600,400); gPad->SetLogy(); m_incl->Draw("ap"); c_incl->SaveAs((dir+"inclPhotonYield.eps").Data()); c_incl->SaveAs((dir+"inclPhotonYield.root").Data()); //get ratio: TH1F *gammaYieldMBratio=new TH1F(*gammaYieldMB); gammaYieldMBratio->SetName("gammaYieldMBratio"); TH1F *gammaYieldHT1ratio=new TH1F(*gammaYieldHT1); gammaYieldHT1ratio->SetName("gammaYieldHT1ratio"); TH1F *gammaYieldHT2ratio=new TH1F(*gammaYieldHT2); gammaYieldHT2ratio->SetName("gammaYieldHT2ratio"); gammaYieldMBratio->Divide(pionYieldMBratio); gammaYieldHT1ratio->Divide(pionYieldHT1ratio); gammaYieldHT2ratio->Divide(pionYieldHT2ratio); //correct gamma over pion ratio, using two efficiencies: getRatio(gammaYieldMBratio,effGammaMB,effGammaSingleMB,fit_piondecay); getRatio(gammaYieldHT1ratio,effGammaHT1,effGammaSingleHT1,fit_piondecay); getRatio(gammaYieldHT2ratio,effGammaHT2,effGammaSingleHT2,fit_piondecay); TH1F *gammaYieldMBratio_incl=new TH1F(*gammaYieldMBratio); TH1F *gammaYieldHT1ratio_incl=new TH1F(*gammaYieldHT1ratio); TH1F *gammaYieldHT2ratio_incl=new TH1F(*gammaYieldHT2ratio); TH1F *gammaYieldMBratioNoErr=new TH1F(*gammaYieldMBratio); TH1F *gammaYieldHT1ratioNoErr=new TH1F(*gammaYieldHT1ratio); TH1F *gammaYieldHT2ratioNoErr=new TH1F(*gammaYieldHT2ratio); for(int i=1;i<=gammaYieldMBratioNoErr->GetNbinsX();i++){ gammaYieldMBratioNoErr->SetBinError(i,0.); } for(int i=1;i<=gammaYieldHT1ratioNoErr->GetNbinsX();i++){ gammaYieldHT1ratioNoErr->SetBinError(i,0.); } for(int i=1;i<=gammaYieldHT2ratioNoErr->GetNbinsX();i++){ gammaYieldHT2ratioNoErr->SetBinError(i,0.); } TGraphErrors *g_ratioMB=new TGraphErrors(gammaYieldMBratio); g_ratioMB->SetName("g_ratioMB"); TGraphErrors *g_ratioHT1=new TGraphErrors(gammaYieldHT1ratio); g_ratioHT1->SetName("g_ratioHT1"); TGraphErrors *g_ratioHT2=new TGraphErrors(gammaYieldHT2ratio); g_ratioHT2->SetName("g_ratioHT2"); removeThesePoints(g_ratioMB,1); removeThesePoints(g_ratioHT1,2); removeThesePoints(g_ratioHT2,3); TCanvas *c_ratio=new TCanvas("c_ratio","c_ratio",400,200); TMultiGraph *m_ratio=new TMultiGraph("m_ratio","p+p 2005;p_{T};#gamma/#pi^{0}"); m_ratio->Add(g_ratioMB); m_ratio->Add(g_ratioHT1); m_ratio->Add(g_ratioHT2); m_ratio->Draw("ap"); m_ratio->SetMinimum(.001); m_ratio->SetMaximum(1.5); TLegend *leg3=new TLegend(.35,.65,.65,.85); leg3->AddEntry(g_ratioMB,"minimum bias","p"); leg3->AddEntry(g_ratioHT1,"hightower 1","p"); leg3->AddEntry(g_ratioHT2,"hightower 2","p"); leg3->AddEntry(fit_decay,"decay background (total)","l"); leg3->AddEntry(fit_piondecay,"decay background (#pi^{0})","l"); leg3->SetFillColor(0); leg3->Draw("same"); fit_decay->SetLineColor(13); fit_decay->SetLineWidth(1); fit_decay->SetLineColor(1); fit_decay->Draw("same"); fit_piondecay->SetLineColor(13); fit_piondecay->SetLineWidth(1); fit_piondecay->SetLineStyle(2); fit_piondecay->SetLineColor(1); fit_piondecay->Draw("same"); c_ratio->SaveAs((dir+"gammaOverPion.eps").Data()); c_ratio->SaveAs((dir+"gammaOverPion.root").Data()); //create fully corrected incl. photons: gammaYieldMBratio_incl->Multiply(pionYieldMBratio); gammaYieldHT1ratio_incl->Multiply(pionYieldHT1ratio); gammaYieldHT2ratio_incl->Multiply(pionYieldHT2ratio); //gammaYieldMBratio_incl->Scale(7.5); //gammaYieldHT1ratio_incl->Scale(7.5); //gammaYieldHT2ratio_incl->Scale(7.5); TGraphErrors *g_incl_corrMB=new TGraphErrors(gammaYieldMBratio_incl); TGraphErrors *g_incl_corrHT1=new TGraphErrors(gammaYieldHT1ratio_incl); TGraphErrors *g_incl_corrHT2=new TGraphErrors(gammaYieldHT2ratio_incl); TCanvas *c_incl_corr=new TCanvas("c_incl_corr","c_incl_corr",400,300); gPad->SetLogy(); TMultiGraph *m_incl_corr=new TMultiGraph(); m_incl_corr->Add(g_incl_corrMB); m_incl_corr->Add(g_incl_corrHT1); m_incl_corr->Add(g_incl_corrHT2); m_incl_corr->SetMinimum(1.e-11); m_incl_corr->SetMaximum(1.); m_incl_corr->Draw("apX"); c_incl_corr->SaveAs((dir+"inclPhotonYieldCorr.eps").Data()); c_incl_corr->SaveAs((dir+"inclPhotonYieldCorr.root").Data()); TCanvas *c_doubleratio=new TCanvas("c_doubleratio","c_doubleratio",400,300); gStyle->SetOptStat(0); c_doubleratio->cd(1); TH1F *gammaYieldMBdoubleratio=new TH1F(*gammaYieldMBratio); TH1F *gammaYieldHT1doubleratio=new TH1F(*gammaYieldHT1ratio); TH1F *gammaYieldHT2doubleratio=new TH1F(*gammaYieldHT2ratio); gammaYieldMBdoubleratio->Divide(fit_decay); gammaYieldHT1doubleratio->Divide(fit_decay); gammaYieldHT2doubleratio->Divide(fit_decay); TGraphErrors *g_doubleRatioMB=new TGraphErrors(gammaYieldMBdoubleratio); g_doubleRatioMB->SetName("g_doubleRatioMB"); g_doubleRatioMB->SetMarkerStyle(8); TGraphErrors *g_doubleRatioHT1=new TGraphErrors(gammaYieldHT1doubleratio); g_doubleRatioHT1->SetName("g_doubleRatioHT1"); g_doubleRatioHT1->SetMarkerStyle(8); TGraphErrors *g_doubleRatioHT2=new TGraphErrors(gammaYieldHT2doubleratio); g_doubleRatioHT2->SetName("g_doubleRatioHT2"); g_doubleRatioHT2->SetMarkerStyle(8); removeThesePoints(g_doubleRatioMB,1); removeThesePoints(g_doubleRatioHT1,2); removeThesePoints(g_doubleRatioHT2,3); TMultiGraph *m_doubleratio=new TMultiGraph(); m_doubleratio->SetName("m_doubleratio"); m_doubleratio->SetMinimum(.5); m_doubleratio->SetMaximum(2.75); cout<<endl; g_doubleRatioHT1->Print(); cout<<endl<<endl; g_doubleRatioHT2->Print(); cout<<endl; //m_doubleratio->Add(g_doubleRatioMB,"p"); m_doubleratio->Add(g_doubleRatioHT1,"p"); m_doubleratio->Add(g_doubleRatioHT2,"p"); g_photonpqcd->SetLineWidth(2); g_photonpqcd->SetLineColor(2); g_photonpqcd05->SetLineWidth(2); g_photonpqcd05->SetLineColor(2); g_photonpqcd05->SetLineStyle(2); g_photonpqcd2->SetLineWidth(2); g_photonpqcd2->SetLineColor(2); g_photonpqcd2->SetLineStyle(2); m_doubleratio->Add(g_photonpqcd,"c"); m_doubleratio->Add(g_photonpqcd05,"c"); m_doubleratio->Add(g_photonpqcd2,"c"); //appropriate fit to photon pqcd result TF1 *fitGamma2=new TF1("fitGamma2","1.+[0]*pow(x,[1])",2.,15.); g_photonpqcd->Fit(fitGamma2,"R0"); m_doubleratio->Draw("a"); m_doubleratio->GetXaxis()->SetTitle("p_{T} (GeV/c)"); m_doubleratio->GetYaxis()->SetTitle("1 + #gamma_{dir}/#gamma_{incl}"); m_doubleratio->GetXaxis()->SetRangeUser(2.,16.); TLegend *leg5=new TLegend(.15,.6,.6,.8); leg5->AddEntry(g_doubleRatioHT1,"hightower-1","p"); leg5->AddEntry(g_doubleRatioHT2,"hightower-2","p"); leg5->AddEntry(g_photonpqcd,"NLO (CTEQ6+KKP) #mu=p_{T}","l"); leg5->AddEntry(g_photonpqcd05,"#mu=2p_{T}, #mu=p_{T}/2","l"); leg5->SetFillColor(0); leg5->Draw("same"); c_doubleratio->cd(0); c_doubleratio->SaveAs((dir+"gammaDoubleRatio.eps").Data()); c_doubleratio->SaveAs((dir+"gammaDoubleRatio.root").Data()); TCanvas *c_dirphoton=new TCanvas("c_dirphoton","c_dirphoton",400,300); gStyle->SetOptStat(0); c_dirphoton->cd(1); TH1F *dirphotonYieldMB=new TH1F(*gammaYieldMBdoubleratio); TH1F *dirphotonYieldHT1=new TH1F(*gammaYieldHT1doubleratio); TH1F *dirphotonYieldHT2=new TH1F(*gammaYieldHT2doubleratio); TH1F *dirphotonYieldMBnoErr=new TH1F(*dirphotonYieldMB); for(int i=1;i<=dirphotonYieldMBnoErr->GetNbinsX();i++){ dirphotonYieldMBnoErr->SetBinError(i,0.); } TH1F *dirphotonYieldHT1noErr=new TH1F(*dirphotonYieldHT1); for(int i=1;i<=dirphotonYieldHT1noErr->GetNbinsX();i++){ dirphotonYieldHT1noErr->SetBinError(i,0.); } TH1F *dirphotonYieldHT2noErr=new TH1F(*dirphotonYieldHT2); for(int i=1;i<=dirphotonYieldHT1noErr->GetNbinsX();i++){ dirphotonYieldHT2noErr->SetBinError(i,0.); } TF1 *f_unity=new TF1("f_unity","1.",0.,15.); dirphotonYieldMB->Add(f_unity,-1.); dirphotonYieldHT1->Add(f_unity,-1.); dirphotonYieldHT2->Add(f_unity,-1.); dirphotonYieldMB->Divide(dirphotonYieldMBnoErr); dirphotonYieldHT1->Divide(dirphotonYieldHT1noErr); dirphotonYieldHT2->Divide(dirphotonYieldHT2noErr); dirphotonYieldMB->Multiply(gammaYieldMBratioNoErr); dirphotonYieldHT1->Multiply(gammaYieldHT1ratioNoErr); dirphotonYieldHT2->Multiply(gammaYieldHT2ratioNoErr); dirphotonYieldMB->Multiply(pionXsMBnoErr); dirphotonYieldHT1->Multiply(pionXsHT1noErr); dirphotonYieldHT2->Multiply(pionXsHT2noErr); TGraphErrors *g_dirphotonMB=new TGraphErrors(dirphotonYieldMB); g_dirphotonMB->SetName("g_dirphotonMB"); g_dirphotonMB->SetMarkerStyle(8); TGraphErrors *g_dirphotonHT1=new TGraphErrors(dirphotonYieldHT1); g_dirphotonHT1->SetName("g_dirphotonHT1"); g_dirphotonHT1->SetMarkerStyle(8); TGraphErrors *g_dirphotonHT2=new TGraphErrors(dirphotonYieldHT2); g_dirphotonHT2->SetName("g_dirphotonHT2"); g_dirphotonHT2->SetMarkerStyle(8); removeThesePoints(g_dirphotonMB,1); removeThesePoints(g_dirphotonHT1,2); removeThesePoints(g_dirphotonHT2,3); gPad->SetLogy(); TMultiGraph *m_dirphoton=new TMultiGraph(); m_dirphoton->SetName("m_dirphoton"); m_dirphoton->SetMinimum(1.0e-11); m_dirphoton->SetMaximum(0.1); m_dirphoton->Add(g_dirgamma,"c"); m_dirphoton->Add(g_dirgamma05,"c"); m_dirphoton->Add(g_dirgamma2,"c"); cout<<"direct photons:"<<endl; g_dirphotonHT1->Print(); cout<<endl; g_dirphotonHT2->Print(); cout<<endl; m_dirphoton->Add(g_dirphotonHT1,"p"); m_dirphoton->Add(g_dirphotonHT2,"p"); m_dirphoton->Draw("a"); m_dirphoton->GetXaxis()->SetTitle("p_{T} (GeV/c)"); m_dirphoton->GetYaxis()->SetTitle("1 - R^{-1}"); m_dirphoton->GetXaxis()->SetRangeUser(2.,16.); TLegend *leg5=new TLegend(.15,.6,.6,.8); leg5->AddEntry(g_dirphotonHT1,"hightower-1","p"); leg5->AddEntry(g_dirphotonHT2,"hightower-2","p"); leg5->SetFillColor(0); leg5->Draw("same"); c_dirphoton->cd(0); c_dirphoton->SaveAs((dir+"gammaDirPhoton.eps").Data()); c_dirphoton->SaveAs((dir+"gammaDirPhoton.root").Data()); return; }