// Main display loop void display () { cam.moveToPos ( glide.x, 0, 0 ); glide.x *= 0.8; PERF_PUSH ( "frame" ); // Clear framebuffers. OpenGL glClearColor( 0.1, 0.1, 0.1, 0.0 ); glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); drawOverlay (); drawGui (); draw2D (); #ifdef USE_DX // DirectX - Swap buffers checkHR ( g_pSwapChain->Present ( 0, 0 ) ); #else // OpenGL - Swap buffers SwapBuffers ( g_hDC ); #endif PERF_POP (); frame++; }
// Main display loop void display () { PERF_PUSH ( "frame" ); // instrument code (does CPU and GPU perf) glClearColor( 0.5, 0.5, 0.5, 1.0 ); glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Draw 2D funcs similar to immediate mode, but uses VBO buffers internally // Draw order maintained. Transparency allowed. // start2D() does dynamic redraw every frame. // static2D() will redraw automatically, can be infrequently updated. // Commands: // start2D, static2D, end2D, setview2D // drawLine, drawRect, drawFill, drawText, setText // drawCircle, drawCircleFill, drawCircleDash // Future goals (partially implemented): // - Ability to change model/view matrix per start2D/end2D sets // - Add/remove static2D sets start2D(); int x1, y1, x2, y2; float r, g, b; for (int n=0; n < numRects; n++ ) { x1 = n % 40; y1 = n / 40; drawFill ( x1*30+30-14, y1*30+200-14, x1*30+30+14, y1*30+200+14, 0, float(y1)/40.0, float(x1)/40.0, 1 ); } for (int n=0; n < numCircles; n++ ) { x1 = n % 40; y1 = n / 40; drawCircleFill ( x1*30+30, y1*30+200, 14, float(x1)/40.0, float(y1)/40.0, 1, 1 ); drawCircleDash ( x1*30+30, y1*30+200, 14, 1, 1, 1, 1 ); } srand ( 3142 ); for (int n=0; n < numLines; n++ ) { x1 = (rand()*window_width)/RAND_MAX; y1 = (rand()*window_height)/RAND_MAX; x2 = (rand()*window_width)/RAND_MAX; y2 = (rand()*window_height)/RAND_MAX; r = float(rand())/RAND_MAX; g = float(rand())/RAND_MAX; b = float(rand())/RAND_MAX; drawLine ( x1, y1+200, x2, y2+200, r, g, b, 1 ); } end2D (); // multiple start/end blocks allowed per frame start2D (); char msg[128]; for (int n=0; n < numText; n++ ) { x1 = n % 40; y1 = n / 40; sprintf ( msg, "%d,%d", x1, y1 ); drawText ( x1*30+30-12, y1*30+200, msg, 1, 1, 1, 1); } end2D(); // DrawGui - required to draw GUI drawGui (); // Draw2D - required to draw nv2D draw2D (); frameTime = PERF_POP (); // frame SwapBuffers( g_hDC ); }
void GLWidget::createTRPObject(void) { if (!pObj->GetX().Size()) return; if (isBuild) glDeleteLists(xList, 1); xList = glGenLists(1); glNewList (xList, GL_COMPILE); switch (pObj->GetType()) { case FE1D_2: draw1D(); break; case FE2D_3: case FE2D_6: case FE2D_4: draw2D(); break; case FE3D_4: case FE3D_10: case FE3D_8: draw3D(); break; default: break; } glEndList(); isBuild = true; }
void dibPunto::procesFile(Document_Interface *doc) { QString sep; QMessageBox::information(this, "Info", "dibpunto procesFile"); currDoc = doc; //Warning, can change adding or reordering "formatedit" QString::SplitBehavior skip = QString::KeepEmptyParts; switch (formatedit->currentIndex()) { case 0: sep = " "; break; case 3: sep = " "; skip = QString::SkipEmptyParts; break; case 2: sep = ","; break; default: sep = "\t"; } if (!QFile::exists(fileedit->text()) ) { QMessageBox::critical ( this, "DibPunto", QString(tr("The file %1 not exist")).arg(fileedit->text()) ); return; } QFile infile(fileedit->text()); if (!infile.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::critical ( this, "DibPunto", QString(tr("Can't open the file %1")).arg(fileedit->text()) ); return; } //Warning, can change adding or reordering "formatedit" if (formatedit->currentIndex() == 4) procesfileODB(&infile, sep); else procesfileNormal(&infile, sep, skip); infile.close (); QString currlay = currDoc->getCurrentLayer(); if (pt2d->checkOn() == true) draw2D(); if (pt3d->checkOn() == true) draw3D(); if (ptelev->checkOn() == true) drawElev(); if (ptnumber->checkOn() == true) drawNumber(); if (ptcode->checkOn() == true) drawCode(); currDoc->setLayer(currlay); /* draw lines in current layer */ if ( connectPoints->isChecked() ) drawLine(); currDoc = NULL; }
int c_draw2D(lua_State* l) { nebu_Rect rect = { 0, 0, 0, 0 }; scripting_GetFloatResult(&rect.height); scripting_GetFloatResult(&rect.width); draw2D(&rect); return 0; }
/* Calls the 3d and 2d drawing functions */ void Engine::draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw3D(); draw2D(); SDL_GL_SwapBuffers(); }
void display () { mint::Time start, stop; // iso = sin(frame*0.01f ); // Do simulation! if ( !bPause ) psys.Run (); frame++; measureFPS (); glEnable ( GL_DEPTH_TEST ); // Render depth map shadows start.SetSystemTime ( ACC_NSEC ); disableShadows (); #ifdef USE_SHADOWS if ( iShade==1 ) { renderDepthMap_FrameBuffer ( 0, window_width, window_height ); } else { renderDepthMap_Clear ( window_width, window_height ); } #endif // Clear frame buffer if ( iShade<=1 ) glClearColor( 0.29, 0.29, 0.29, 1.0 ); else glClearColor ( 0, 0, 0, 0 ); glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glDisable ( GL_CULL_FACE ); glShadeModel ( GL_SMOOTH ); // Compute camera view computeFromPositions (); computeProjection (); computeView (); // Draw Shadows (if on) #ifdef USE_SHADOWS if ( iShade==1 ) renderShadows ( view_matrix ); #endif // Draw 3D start.SetSystemTime ( ACC_NSEC ); glEnable ( GL_LIGHTING ); glLoadMatrixf ( view_matrix ); drawScene ( view_matrix, true ); if ( bTiming) { stop.SetSystemTime ( ACC_NSEC ); stop = stop - start; printf ( "SCENE: %s\n", stop.GetReadableTime().c_str() ); } // Draw 2D overlay draw2D (); // Swap buffers glutSwapBuffers(); glutPostRedisplay(); }
//================================================ void DeltaZVsPt(const Int_t save = 0) { THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); TH2F *hTrkDzVsPt = (TH2F*)hn->Projection(1,0); c = draw2D(hTrkDzVsPt,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.png",run_type,trigName[kTrigType])); } Double_t pt_cut = 1; hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cut+0.1,100); TH1F *hMthDz = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDzVsPt_%s_proj",trigName[kTrigType])); hMthDz->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (p_{T}>%1.1f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cut)); TH1F *hClone = (TH1F*)hMthDz->Clone(Form("%s_clone",hMthDz->GetName())); c = draw1D(hClone,"",kFALSE,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.png",run_type,trigName[kTrigType])); } Double_t range = 50; TF1 *func = new TF1("func","gaus(0)+gaus(3)",-1*range,range); func->SetParameters(10000,0,10,1000,0,40); c = FitDeltaZ(hMthDz,func,range,20.); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.pdf",run_type,pt_cut,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.png",run_type,pt_cut,trigName[kTrigType])); } // pt dependence Double_t pt_cuts[5] = {1,2,3,5,20}; for(Int_t i=0; i<4; i++) { hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cuts[i]+0.1,pt_cuts[i+1]-0.1); TH1F *htmp = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDz_pt%1.0f-%1.0f_%s",pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); htmp->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (%1.0f < p_{T} < %1.0f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cuts[i],pt_cuts[i+1])); TF1 *func = new TF1(Form("func_pt%1.0f-%1.0f",pt_cuts[i],pt_cuts[i+1]),"gaus(0)+gaus(3)",-1*range,range); if(i==0) func->SetParameters(100,0,100,1000,0,10); if(i==1) func->SetParameters(1000,0,15,1000,0,60); if(i==2) func->SetParameters(1000,0,15,1000,0,60); if(i==3) func->SetParameters(1000,0,60,1000,0,15); c = FitDeltaZ(htmp,func,range,20.); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.pdf",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.png",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); } } }
//================================================ void DeltaY(const Int_t save = 0) { THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); TH2F *hTrkDyVsPt = (TH2F*)hn->Projection(2,0); c = draw2D(hTrkDyVsPt,Form("%s: #Deltay of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_vs_pt_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_vs_pt_%s.png",run_type,trigName[kTrigType])); } c = new TCanvas("hDy_TrkPtBin","hDy_TrkPtBin",1200,650); c->Divide(2,2); Double_t pt_cuts[5] = {1,2,4,10,20}; TH1F *hDy[4][2]; for(Int_t i=0; i<4; i++) { for(Int_t j=0; j<2; j++) { hn->GetAxis(5)->SetRange(1+j*2,1+j*2); hn->GetAxis(0)->SetRangeUser(pt_cuts[i]+0.1,pt_cuts[i+1]-0.1); hDy[i][j] = (TH1F*)hn->Projection(2); hDy[i][j]->SetName(Form("hTrkDy_pt%1.0f_%1.0f_%d",pt_cuts[i],pt_cuts[i+1],j)); hDy[i][j]->SetLineColor(color[j]); hDy[i][j]->SetMaximum(1.3*hDy[i][j]->GetMaximum()); hDy[i][j]->SetTitle(""); } c->cd(i+1); hDy[i][0]->Draw(); hDy[i][1]->Draw("sames"); TPaveText *t1 = GetTitleText(Form("%s: #Deltay of matched track-hit pairs",trigName[kTrigType]),0.06); t1->Draw(); t1 = GetPaveText(0.15,0.35,0.7,0.75,0.06); t1->AddText(Form("%1.0f < p_{T} < %1.0f GeV/c",pt_cuts[i],pt_cuts[i+1])); t1->SetTextColor(4); t1->Draw(); } c->cd(1); TLegend *leg = new TLegend(0.6,0.63,0.8,0.83); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.05); leg->AddEntry(hDy[0][0],"Negative","L"); leg->AddEntry(hDy[0][1],"Positive","L"); leg->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_InPtBin_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_InPtBin_%s.png",run_type,trigName[kTrigType])); } }
void View::draw(uint /*msMultiplier*/) const { if (!pVisible) return; // Clear depth buffer ::glClear(GL_DEPTH_BUFFER_BIT); ::glPushAttrib(GL_VIEWPORT_BIT); // Reset The Current Viewport ::glViewport((int)pX, (int)pY, (uint)pWidth, (uint)pHeight); draw2D(); ::glPopAttrib(); }
Vector2 GFont::draw3D (RenderDevice* renderDevice, const String& s, const CoordinateFrame& pos3D, float size, const Color4& color, const Color4& border, XAlign xalign, YAlign yalign, Spacing spacing) const { debugAssert(renderDevice != NULL); Vector2 bounds; renderDevice->pushState(); { CoordinateFrame flipY; flipY.rotation[1][1] = -1; renderDevice->setObjectToWorldMatrix(pos3D * flipY); bounds = draw2D(renderDevice, s, Vector2(0, 0), size, color, border, xalign, yalign, spacing); } renderDevice->popState(); return bounds; }
Stack* Stack::draw(){ if( can == NULL ) can = new TCanvas(("can_"+name).c_str(), name.c_str()); int N = vec.size(); int Ngraph = vecGraph.size(); if(N == 0 && Ngraph == 0) return this; bool plotLegend = checkIfDrawLegend(); if( N == 0 ) draw1D(); else if( vec[0] -> InheritsFrom("TH2") ) draw2D(); else draw1D(); if( _displayLegend && leg -> GetListOfPrimitives() -> GetSize() > 0 && plotLegend ) leg -> Draw("same"); if( labelSizeX != 0 ) frame -> GetXaxis() -> SetLabelSize( labelSizeX ); if( labelSizeY != 0 ) frame -> GetYaxis() -> SetLabelSize( labelSizeY ); frame -> GetXaxis() -> SetNdivisions(507,true); frame -> GetYaxis() -> SetNdivisions(507,true); frame -> GetXaxis() -> SetLabelSize(0.07); frame -> GetYaxis() -> SetLabelSize(0.07); if( titleX != "" ){ frame -> GetXaxis() -> SetTitleSize(0.08); // frame -> GetXaxis() -> SetTitleOffset(1.4); gPad -> SetBottomMargin(0.2); } if( titleY != "" ){ frame -> GetYaxis() -> SetTitleSize(0.08); gPad -> SetLeftMargin(0.2); } gPad -> SetGridx(); gPad -> SetGridy(); // gPad->RedrawAxis(); return this; }
//================================================ void acceptance(TString fileName, const Int_t save = 0) { TFile *fin = TFile::Open(Form("Rootfiles/%s",fileName.Data()),"read"); Double_t pt_cuts_1[2] = {1.0,1.5}; Double_t pt_cuts_2[2] = {1.0,1.0}; TList *list = new TList; // charge dependence TString legName[2] = {"Like-sign: ++","Like-sign: --"}; const char *title[2] = {"positive","negative"}; TH2F *hLSpair[2][2]; for(int i=0; i<2; i++) { hLSpair[0][i] = (TH2F*)fin->Get(Form("LSpos_pt_vs_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt_cuts_1[i],pt_cuts_2[i],trigName[kTrigType])); hLSpair[1][i] = (TH2F*)fin->Get(Form("LSneg_pt_vs_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt_cuts_1[i],pt_cuts_2[i],trigName[kTrigType])); for(int j=0; j<2; j++) { hLSpair[j][i]->GetXaxis()->SetRangeUser(0,8); c = draw2D(hLSpair[j][i],Form("Mixed event: %s like-sign pairs (p_{T,1}>%1.1f, p_{T,2}>%1.1f GeV/c)",title[j],pt_cuts_1[i],pt_cuts_2[i])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_vs_pt_LS_%s_pt1_%1.0f_pt2_%1.0f.pdf",run_type,run_cfg_name.Data(),title[j],pt_cuts_1[i]*10,pt_cuts_2[i]*10)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_vs_pt_LS_%s_pt1_%1.0f_pt2_%1.0f.png",run_type,run_cfg_name.Data(),title[j],pt_cuts_1[i]*10,pt_cuts_2[i]*10)); } } list->Clear(); for(int j=0; j<2; j++) { hLSpair[j][i]->GetXaxis()->SetRangeUser(0,8); TH1F *h1 = (TH1F*)hLSpair[j][i]->ProjectionX(Form("%s_prox",hLSpair[j][i]->GetName())); h1->Rebin(2); list->Add(h1); } c = sysCompare(list,Form("Charge_pt1_%1.1f_pt2_%1.1f",pt_cuts_1[i],pt_cuts_2[i]),Form("Mixed event: di-muon pairs"),"Charge dependece;M_{#mu#mu} (GeV/c^{2});--/++",kFALSE,0,15,kFALSE,0.1,10,kTRUE,0.7,1.3,kTRUE,kTRUE,legName,kTRUE,"Mixed events",0.25,0.4,0.35,0.55,kFALSE); c->cd(1); TPaveText *t1 = GetPaveText(0.7,0.8,0.7,0.85,0.04,62); t1->AddText(Form("p_{T,1}>%1.1f GeV/c",pt_cuts_1[i])); t1->AddText(Form("p_{T,2}>%1.1f GeV/c",pt_cuts_2[i])); t1->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_LS_ChargeDep_pt1_%1.0f_pt2_%1.0f.pdf",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_LS_ChargeDep_pt1_%1.0f_pt2_%1.0f.png",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); } } // acceptance TString legName1[2] = {"Unlike-sign","Like-sign: (--)+(++)"}; TH2F *hLS[2], *hUL[2]; for(int i=0; i<2; i++) { hUL[i] = (TH2F*)fin->Get(Form("US_pt_vs_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt_cuts_1[i],pt_cuts_2[i],trigName[kTrigType])); hUL[i]->Sumw2(); hUL[i]->GetXaxis()->SetRangeUser(0,8); c = draw2D(hUL[i],Form("Mixed event: unlike-sign pairs (p_{T,1}>%1.1f, p_{T,2}>%1.1f GeV/c)",pt_cuts_1[i],pt_cuts_2[i])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_vs_pt_UL_pt1_%1.0f_pt2_%1.0f.pdf",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_vs_pt_UL_pt1_%1.0f_pt2_%1.0f.png",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); } hLS[i] = (TH2F*)fin->Get(Form("LS_pt_vs_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt_cuts_1[i],pt_cuts_2[i],trigName[kTrigType])); hLS[i]->Sumw2(); hLS[i]->GetXaxis()->SetRangeUser(0,8); c = draw2D(hLS[i],Form("Mixed event: like-sign pairs (--)+(++) (p_{T,1}>%1.1f, p_{T,2}>%1.1f GeV/c)",pt_cuts_1[i],pt_cuts_2[i])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_vs_pt_LS_pt1_%1.0f_pt2_%1.0f.pdf",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_vs_pt_LS_pt1_%1.0f_pt2_%1.0f.png",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); } list->Clear(); h1 = (TH1F*)hUL[i]->ProjectionX(Form("%s_prox",hUL[i]->GetName())); h1->Rebin(2); list->Add(h1); h1 = (TH1F*)hLS[i]->ProjectionX(Form("%s_prox",hLS[i]->GetName())); h1->Rebin(2); list->Add(h1); c = sysCompare(list,Form("Acceptance_pt1_%1.1f_pt2_%1.1f",pt_cuts_1[i],pt_cuts_2[i]),Form("Mixed event: di-muon pairs"),"Acceptance effect;M_{#mu#mu} (GeV/c^{2});LS/UL",kFALSE,0,15,kFALSE,0.1,10,kTRUE,0.7,1.3,kTRUE,kTRUE,legName1,kTRUE,"Mixed events",0.25,0.4,0.35,0.55,kFALSE); c->cd(1); TPaveText *t1 = GetPaveText(0.7,0.8,0.7,0.85,0.04,62); t1->AddText(Form("p_{T,1}>%1.1f GeV/c",pt_cuts_1[i])); t1->AddText(Form("p_{T,2}>%1.1f GeV/c",pt_cuts_2[i])); t1->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_Acceptance_pt1_%1.0f_pt2_%1.0f.pdf",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_Acceptance_pt1_%1.0f_pt2_%1.0f.png",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); } c = sysCompare(list,Form("Acceptance_pt1_%1.1f_pt2_%1.1f_zoom",pt_cuts_1[i],pt_cuts_2[i]),Form("Mixed event: di-muon pairs"),"Acceptance effect;M_{#mu#mu} (GeV/c^{2});LS/UL",kTRUE,0,4,kFALSE,0.1,10,kTRUE,0.7,1.3,kFALSE,kTRUE,legName1,kTRUE,"Mixed events",0.25,0.4,0.25,0.45,kFALSE); c->cd(1); TPaveText *t1 = GetPaveText(0.3,0.4,0.7,0.85,0.04,62); t1->AddText(Form("p_{T,1}>%1.1f GeV/c",pt_cuts_1[i])); t1->AddText(Form("p_{T,2}>%1.1f GeV/c",pt_cuts_2[i])); t1->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_Acceptance_pt1_%1.0f_pt2_%1.0f_zoomin.pdf",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_Acceptance_pt1_%1.0f_pt2_%1.0f_zoomin.png",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); } } // Geometry mean TString legName2[2] = {"N_{++}+N_{--}", "2#sqrt{N_{++}*N_{--}}"}; TH2F *hLSGeom[2]; for(int i=0; i<2; i++) { hLSGeom[i] = (TH2F*)fin->Get(Form("LS_Geom_pt_vs_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt_cuts_1[i],pt_cuts_2[i],trigName[kTrigType])); list->Clear(); TH1F *htmp = (TH1F*)hLS[i]->ProjectionX(Form("%s_prox2",hLS[i]->GetName())); TH1F *h1 = (TH1F*)htmp->Rebin(nSpecMBins,Form("htmp_rebin",htmp->GetName()),specM); scaleHisto(h1, 1, 1,kTRUE,kFALSE, kTRUE); list->Add(h1); TH1F *h1 = (TH1F*)hLSGeom[i]->ProjectionX(Form("%s_prox",hLSGeom[i]->GetName())); scaleHisto(h1, 1, 1,kTRUE,kFALSE, kTRUE); list->Add(h1); c = sysCompare(list,Form("GeometricalMean_pt1_%1.1f_pt2_%1.1f",pt_cuts_1[i],pt_cuts_2[i]),Form("Mixed event: like-sign di-muon pairs (p_{T,1}>%1.1f, p_{T,2}>%1.1f GeV/c)",pt_cuts_1[i],pt_cuts_2[i]),"Geometric/Arithmetic;M_{#mu#mu} (GeV/c^{2});",kTRUE,0,4,kFALSE,0.1,10,kTRUE,0.99,1.01,kFALSE,kTRUE,legName2,kTRUE,"Like-sign",0.25,0.4,0.25,0.45,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_Geom_pt1_%1.0f_pt2_%1.0f.pdf",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sInvMass_Geom_pt1_%1.0f_pt2_%1.0f.png",run_type,run_cfg_name.Data(),pt_cuts_1[i]*10,pt_cuts_2[i]*10)); } } }
//================================================ void eventBinning(const Int_t save = 0) { TH1F *hVtxZ = (TH1F*)f->Get(Form("mhVertexZ_%s",trigName[kTrigType])); c = draw1D(hVtxZ,"",kFALSE,kFALSE); for(int i=0; i<19; i++) { double value = -100 + i*10 + 10; double height = hVtxZ->GetBinContent(hVtxZ->FindFixBin(value)); TLine *line = GetLine(value,0,value,height,2,1,1); line->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.png",run_type,run_cfg_name.Data())); } TH1F *hgRefMultCorr = (TH1F*)f->Get(Form("mhgRefMultCorr_%s",trigName[kTrigType])); c = draw1D(hgRefMultCorr,"",kTRUE,kFALSE); //double bounds[9] = {472,401,283,193,126,77,44,23,11}; double bounds[16] = {11,16,23,32,44,59,77,99,126,157,193,235,283,338,401,472}; for(int i=0; i<16; i++) { double value = bounds[i]; double height = hgRefMultCorr->GetBinContent(hgRefMultCorr->FindFixBin(value)); TLine *line = GetLine(value,0,value,height,2,1,1); line->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.png",run_type,run_cfg_name.Data())); } // centrality TH1F *hgRefMult = (TH1F*)f->Get(Form("mhgRefMult_%s",trigName[kTrigType])); hgRefMult->SetLineColor(2); c = draw1D(hgRefMult,"",kTRUE,kFALSE); hgRefMultCorr->Draw("sames HIST"); TLegend *leg = new TLegend(0.15,0.3,0.4,0.5); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->AddEntry(hgRefMult,"Raw gRefMult","L"); leg->AddEntry(hgRefMultCorr,"Corrected gRefMult","L"); leg->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.png",run_type,run_cfg_name.Data())); } TH1F *hCentrality = (TH1F*)f->Get(Form("mhCentrality_%s",trigName[kTrigType])); c = draw1D(hCentrality,"",kTRUE,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.png",run_type,run_cfg_name.Data())); } // event plane TH2F *hExcVsIncRawEP = (TH2F*)f->Get(Form("mhExcVsIncRawEP_%s",trigName[kTrigType])); c = draw2D(hExcVsIncRawEP); TH1F *hEventPlane = (TH1F*)f->Get(Form("mhEventPlane_%s",trigName[kTrigType])); c = draw1D(hEventPlane,"",kFALSE,kFALSE); }
void EnsancheModelBuildingAdv::draw(int drawMode, bool bDrawWOffset) { if( drawMode == MODEL_DRAW_MODE_3D ) draw3D( bDrawWOffset ); else draw2D( bDrawWOffset ); }
/* * Main game loop. */ void Game::loop(){ running = true; // Fade in fade(0,2.f); sf::Mouse::SetPosition(sf::Vector2i(SCREEN_WIDTH/2,SCREEN_HEIGHT/2),app); while(running){ float time = clock.GetElapsedTime()/1000.f; clock.Reset(); while(app.PollEvent(event)){ if(event.Type == sf::Event::Closed){ running = false; } else if(event.Type == sf::Event::KeyPressed){ if(event.Key.Code == sf::Keyboard::P){ paused = !paused; } } else if(event.Type == sf::Event::GainedFocus){ hasFocus = true; } else if(event.Type == sf::Event::LostFocus){ hasFocus = false; } } if(!paused){ // Update player pl.update(time, map, app, hasFocus, sndmgr); if(pl.collideDots(dots,sndmgr) == 1){ for(git = ghosts.begin(); git < ghosts.end(); ++git){ git->setScared(); } } // Update ghosts for(git = ghosts.begin(); git < ghosts.end(); ++git) { if(git->alive){ git->update(time,map); } else{ particles.push_back(Particle(git->x,0,git->z,particleKillGhost)); git->respawn(); } } // Update particles for(pit = particles.begin(); pit < particles.end(); ++pit) { if(pit->alive){ pit->update(time); } else{ particles.erase(pit); } } pl.collideGhosts(ghosts,sndmgr); // Update lamp blinking if(lampTime < 0){ if(lampOn) lampTime = (float)(rand() % 10 + 5)/100.f; else lampTime = (float)(rand() % 50 + 10)/100.f; lampOn = !lampOn; } lampTime -= time; } // Clear screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw objects draw(); // Draw 2D effects draw2D(); // redraw screen app.Display(); } // fade out fade(1,1.f); }
//================================================ void embed(int save = 0) { char *run_config = "Embed.fix."; TString fileName; if(year==2013) fileName = Form("Run13.pp500.jpsi.%sroot",run_config); f = TFile::Open(Form("./output/%s",fileName.Data()),"read"); THnSparseF *hnDtof = (THnSparseF*)f->Get("mhMcTofQA_di_mu"); // dtof vs pt TH2F *hTofVsPt = (TH2F*)hnDtof->Projection(0,3); hTofVsPt->SetName("Embed_dTof_vs_pt"); hTofVsPt->SetTitle("Embedding: tof_{mc} - tof_{exp} vs p_{T}"); hTofVsPt->GetXaxis()->SetRangeUser(0,12); hTofVsPt->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsPt); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_pt.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_pt.png",run_type,run_config)); } // dtof vs mctof TH2F *hTofVsMcTof = (TH2F*)hnDtof->Projection(0,1); hTofVsMcTof->SetName("Embed_dTof_vs_mc_tof"); hTofVsMcTof->SetTitle("Embedding: tof_{mc} - tof_{exp} vs tof_{mc}"); hTofVsMcTof->GetXaxis()->SetRangeUser(13,17); hTofVsMcTof->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsMcTof); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_mctof.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_mctof.png",run_type,run_config)); } // dtof vs exptof TH2F *hTofVsExpTof = (TH2F*)hnDtof->Projection(0,2); hTofVsExpTof->SetName("Embed_dTof_vs_exp_tof"); hTofVsExpTof->SetTitle("Embedding: tof_{mc} - tof_{exp} vs tof_{exp}"); hTofVsExpTof->GetXaxis()->SetRangeUser(13,17); hTofVsExpTof->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsExpTof); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_exptof.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_exptof.png",run_type,run_config)); } // dtof vs module TH2F *hTofVsMod = (TH2F*)hnDtof->Projection(0,4); hTofVsMod->SetName("Embed_dTof_vs_module"); hTofVsMod->SetTitle("Embedding: tof_{mc} - tof_{exp} vs backleg"); hTofVsMod->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsMod); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_backleg.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_backleg.png",run_type,run_config)); } // dtof intervals TList *list = new TList; TString legName[3]; TH1F *histo[3][3]; double low_bounds[3] = {-5, 0.15, -0.16}; double up_bounds[3] = {5, 0.16, -0.15}; char *name[3] = {"mc_tof","exp_tof","pt"}; double scale[3] = {2,2.5,1.5}; double min[3] = {12,12,0}; double max[3]= {18,18,12}; for(int i=0; i<3; i++) { list->Clear(); for(int j=0; j<3; j++) { hnDtof->GetAxis(0)->SetRangeUser(low_bounds[j]+0.001,up_bounds[j]-0.001); histo[i][j] = (TH1F*)hnDtof->Projection(i+1); histo[i][j]->SetName(Form("%s_dTofBin%d",name[i],j)); histo[i][j]->Scale(1./histo[i][j]->Integral()); histo[i][j]->SetLineWidth(2); histo[i][j]->SetMaximum(scale[i]*histo[i][j]->GetMaximum()); legName[j] = Form("%2.2f #leq #Deltatof #leq %2.2f ns",low_bounds[j],up_bounds[j]); list->Add(histo[i][j]); } c = drawHistos(list,name[i],Form("Embedding: %s distributions",name[i]),kTRUE,min[i],max[i],kFALSE,0.1,10,kFALSE,kTRUE,legName,kTRUE,"",0.5,0.7,0.6,0.85,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%s%s_in_dTofBin.pdf",run_type,run_config,name[i])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%s%s_in_dTofBin.png",run_type,run_config,name[i])); } } hnDtof->GetAxis(0)->SetRange(0,-1); // dtof in module TH1F *hTofInMod[5]; TH2F *hTofVsProjMod[5]; for(int i=0; i<5; i++) { hnDtof->GetAxis(5)->SetRange(i+1,i+1); hTofInMod[i] = (TH1F*)hnDtof->Projection(0); hTofInMod[i]->SetName(Form("hTof_Mod%d",i+1)); hTofVsProjMod[i] = (TH2F*)hnDtof->Projection(0,6); hTofVsProjMod[i]->SetName(Form("hTofVsProjMod_Mod%d",i+1)); } hnDtof->GetAxis(5)->SetRange(0,-1); TCanvas *c = new TCanvas("hTof_in_mod","hTof_in_mod",1100,750); c->Divide(3,2); for(int i=0; i<5; i++) { c->cd(i+1); gPad->SetLogy(); hTofInMod[i]->Draw(); hTofInMod[i]->SetTitle(""); hTofInMod[i]->GetXaxis()->SetRangeUser(-1,2); TPaveText *t1 = GetTitleText(Form("Module %d",i+1),0.05); t1->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_in_module.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_in_module.png",run_type,run_config)); } TCanvas *c = new TCanvas("hTofVsProjMod_in_mod","hTofVsProjMod_in_mod",1100,750); c->Divide(3,2); for(int i=0; i<5; i++) { c->cd(i+1); gPad->SetLogz(); hTofVsProjMod[i]->SetTitle(";track module"); hTofVsProjMod[i]->GetYaxis()->SetRangeUser(-0.5,0.5); hTofVsProjMod[i]->Draw("colz"); TPaveText *t1 = GetTitleText(Form("Hit in module %d",i+1),0.05); t1->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTofVsProjMod_in_module.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTofVsProjMod_in_module.png",run_type,run_config)); } }
//================================================ void fitDzInMod(const int save = 0) { TFile *fin = TFile::Open(Form("Rootfiles/%s%s.TrkMthResidual.root",run_cfg_name.Data(),run_type)); TH2F *hDzVsModBL = (TH2F*)fin->Get(Form("hTrkDzVsModBL_%s",trigName[kTrigType])); c = draw2D(hDzVsModBL,Form("%s: #Deltaz of matched track-hit pairs;module;#Deltaz (cm)",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_ModInBL_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_ModInBL_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } TCanvas *canvas[3]; for(int i=0; i<3; i++) { canvas[i] = new TCanvas(Form("canvas_%d",i),Form("canvas_%d",i),1100,800); canvas[i]->Divide(5,5); } Int_t counter=0; TH1F *hDz[30][5]; TH1F *hDzMean[5]; TH1F *hDzSigma[5]; for(int j=0; j<5; j++) { hDzMean[j] = new TH1F(Form("hTrkDzMean_Mod%d_%s",j+1,trigName[kTrigType]),Form("%s: mean of #Deltaz from fit;module;<#Deltaz> (cm)",trigName[kTrigType]),150,0,150); hDzSigma[j] = new TH1F(Form("hDzSigma_Mod%d_%s",j+1,trigName[kTrigType]),Form("%s: sigma of #Deltaz from fit;module;#sigma(#Deltaz) (cm)",trigName[kTrigType]),150,0,150); } for(int i=0; i<30; i++) { for(int j=0; j<5; j++) { hDz[i][j] = (TH1F*)fin->Get(Form("hTrkDz_BL%d_Mod%d_%s",i+1,j+1,trigName[kTrigType])); if(i==6 && j==4) counter++; if(hDz[i][j]->GetEntries()<=0) continue; canvas[counter/25]->cd(counter%25+1); hDz[i][j]->GetXaxis()->SetRangeUser(-60,100); hDz[i][j]->SetTitle(""); hDz[i][j]->SetLineColor(1); hDz[i][j]->SetLineWidth(2); hDz[i][j]->Draw(); TF1 *func = new TF1(Form("Fit_%s",hDz[i][j]->GetName()),"gaus",-20,25); hDz[i][j]->Fit(func,"IRQ0"); func->SetLineColor(2); func->SetLineStyle(2); func->Draw("sames"); TPaveText *t1 = GetPaveText(0.15,0.35,0.6,0.8,0.1); t1->AddText(Form("BL %d",i+1)); t1->AddText(Form("Mod %d",j+1)); t1->Draw(); counter++; hDzMean[j]->SetBinContent(i*5+j+1,func->GetParameter(1)); hDzMean[j]->SetBinError(i*5+j+1,func->GetParError(1)); hDzSigma[j]->SetBinContent(i*5+j+1,func->GetParameter(2)); hDzSigma[j]->SetBinError(i*5+j+1,func->GetParError(2)); } } if(save) { for(int i=0; i<3; i++) { canvas[i]->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sFitDz_vs_Mod_%d_%s.pdf",run_type,run_cfg_name.Data(),i,trigName[kTrigType])); canvas[i]->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sFitDz_vs_Mod_%d_%s.png",run_type,run_cfg_name.Data(),i,trigName[kTrigType])); } } TList *list = new TList; list->Clear(); TString legName[5]; for(Int_t j=0; j<5; j++) { legName[j] = Form("Module %d",j+1); list->Add(hDzMean[j]); } c = drawHistos(list,"TrkDzMean","",kTRUE,0,150,kTRUE,-4,14,kFALSE,kTRUE,legName,kTRUE,"",0.45,0.6,0.6,0.88,kTRUE); TLine *line = GetLine(0,0,150,0,1); line->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sFitDzMean_vs_Mod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sFitDzMean_vs_Mod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } list->Clear(); for(Int_t j=0; j<5; j++) { list->Add(hDzSigma[j]); } c = drawHistos(list,"TrkDzSigma","",kTRUE,0,150,kTRUE,6,19,kFALSE,kTRUE,legName,kTRUE,"",0.2,0.35,0.18,0.42,kTRUE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sFitDzSigma_vs_Mod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sFitDzSigma_vs_Mod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } }
void ana_Run11_eff() { const int rebin = 1; TFile *f = TFile::Open("Rootfiles/Run11_eff.root","read"); // Run with weigth TH2F *hMcPtVsEta = (TH2F*)f->Get("mcJpsiPtY"); TH2F *hRcPtVsEta = (TH2F*)f->Get("hHt2JpsiPE"); draw2D(hMcPtVsEta); draw2D(hRcPtVsEta); hMcPtVsEta->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6); TH1F *hMcPt = (TH1F*)hMcPtVsEta->ProjectionY("hMcPt"); hMcPt->Rebin(rebin); hMcPt->SetMarkerStyle(20); draw1D(hMcPt,"",kTRUE); hRcPtVsEta->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6); TH1F *hRcPt = (TH1F*)hRcPtVsEta->ProjectionY("hRcPt"); hRcPt->Rebin(rebin); hRcPt->SetMarkerStyle(21); hRcPt->SetMarkerColor(2); hRcPt->SetLineColor(2); hRcPt->Draw("sames P"); TH1F *hRatio = (TH1F*)hRcPt->Clone("hRatio_fromRunning"); hRatio->Rebin(100); hMcPt->Rebin(100); hRatio->Divide(hMcPt); cEff = draw1D(hRatio,""); // Run without weight TH2F *hMcPtVsEtaNoWeight = (TH2F*)f->Get("mcJpsiPtY_Or"); draw2D(hMcPtVsEtaNoWeight); TH2F *hMcPtVsRcNoWeight = (TH2F*)f->Get("hJpsiRcvsMC_Cut1"); hMcPtVsRcNoWeight->RebinX(rebin); hMcPtVsRcNoWeight->RebinY(rebin); draw2D(hMcPtVsRcNoWeight); hMcPtVsEtaNoWeight->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6); TH1F *hMcPtNoWeight = (TH1F*)hMcPtVsEtaNoWeight->ProjectionY("hMcPtNoWeight"); hMcPtNoWeight->Rebin(rebin); hMcPtNoWeight->SetMarkerStyle(20); hMcPtNoWeight->SetMinimum(1); draw1D(hMcPtNoWeight,"",kTRUE); TH1F *hRcPtNoWeight = (TH1F*)hMcPtVsRcNoWeight->ProjectionX("hRcPtNoWeight"); hRcPtNoWeight->SetMarkerStyle(21); hRcPtNoWeight->SetMarkerColor(2); hRcPtNoWeight->SetLineColor(2); hRcPtNoWeight->Draw("sames P"); TH1F *hRatioNoWeight = (TH1F*)hRcPtNoWeight->Clone("hRatioNoWeight"); hRatioNoWeight->Divide(hMcPtNoWeight); cEff->cd(); hRatioNoWeight->SetMarkerColor(4); hRatioNoWeight->Draw("samesP"); // weight with input histogram TH1F *hMcPtWeight = (TH1F*)hMcPtNoWeight->Clone("hMcPtWeight"); TH2F *hMcPtVsRcWeight = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcWeight"); for(int ibin=1; ibin<=hMcPtVsRcNoWeight->GetNbinsX(); ibin++) { double scale = hMcPt->GetBinContent(ibin); hMcPtWeight->SetBinContent(ibin,hMcPtWeight->GetBinContent(ibin)*scale); hMcPtWeight->SetBinError(ibin,hMcPtWeight->GetBinError(ibin)*scale); for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++) { hMcPtVsRcWeight->SetBinContent(ibin,jbin,hMcPtVsRcWeight->GetBinContent(ibin,jbin)*scale); hMcPtVsRcWeight->SetBinError(ibin,jbin,hMcPtVsRcWeight->GetBinError(ibin,jbin)*scale); } } TH1F *hRcPtWeight = (TH1F*)hMcPtVsRcWeight->ProjectionY("hRcPtWeight"); hRcPtWeight->SetMarkerStyle(21); hRcPtWeight->SetMarkerColor(2); hRcPtWeight->SetLineColor(2); draw2D(hMcPtVsRcWeight); draw1D(hMcPtWeight,"",kTRUE); hRcPtWeight->Draw("sames P"); TH1F *hRatioWeight = (TH1F*)hRcPtWeight->Clone("hRatioWeight"); hRatioWeight->Divide(hMcPtWeight); cEff->cd(); hRatioWeight->SetMarkerColor(6); hRatioWeight->Draw("samesP"); TH1F *hCheck = (TH1F*)hRatioWeight->Clone("check"); hCheck->Divide(hRatio); draw1D(hCheck); // weight with fitted function TCanvas *c = new TCanvas("Fit","Fit",800,600); SetPadMargin(gPad,0.15,0.15); gPad->SetLogy(); TH1F *h = new TH1F("histogram",";;;",7,0,30); h->GetYaxis()->SetRangeUser(1e-7,100); h->Draw(); TFile *fdata = TFile::Open("Rootfiles/Spectrum_in_bin.root","read"); TGraphErrors *gr = (TGraphErrors*)fdata->Get("gall"); gr->SetMarkerColor(1); gr->SetLineColor(1); gr->GetXaxis()->SetRangeUser(0,30); gr->Draw("sames PE"); TF1 *func = new TF1("func",InvPt,0,30,4); func->SetParameters(0.4,-0.4796,4.229,-7.54); gr->Fit(func,"RL"); TH1F *hMcPtFunc = (TH1F*)hMcPtNoWeight->Clone("hMcPtFunc"); TH2F *hMcPtVsRcFunc = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcFunc"); for(int ibin=1; ibin<=hMcPtVsRcFunc->GetNbinsX(); ibin++) { double scale = func->Eval(hMcPtFunc->GetBinCenter(ibin)); hMcPtFunc->SetBinContent(ibin,hMcPtFunc->GetBinContent(ibin)*scale); hMcPtFunc->SetBinError(ibin,hMcPtFunc->GetBinError(ibin)*scale); for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++) { hMcPtVsRcFunc->SetBinContent(ibin,jbin,hMcPtVsRcFunc->GetBinContent(ibin,jbin)*scale); hMcPtVsRcFunc->SetBinError(ibin,jbin,hMcPtVsRcFunc->GetBinError(ibin,jbin)*scale); } } TH1F *hRcPtFunc = (TH1F*)hMcPtVsRcFunc->ProjectionY("hRcPtFunc"); hRcPtFunc->SetMarkerStyle(21); hRcPtFunc->SetMarkerColor(2); hRcPtFunc->SetLineColor(2); hMcPtVsRcFunc->GetZaxis()->SetRangeUser(1e-4,1e2); draw2D(hMcPtVsRcFunc); hMcPtFunc->GetYaxis()->SetRangeUser(1e-4,5e4); draw1D(hMcPtFunc,"",kTRUE); hRcPtFunc->Draw("sames P"); TH1F *hRatioFunc = (TH1F*)hRcPtFunc->Clone("hRatioFunc"); hRatioFunc->Rebin(100); hMcPtFunc->Rebin(100); hRatioFunc->Divide(hMcPtFunc); cEff->cd(); hRatioFunc->SetMarkerColor(5); hRatioFunc->Draw("samesP"); TH1F *hCheck2 = (TH1F*)hRatioFunc->Clone("check2"); hCheck2->Divide(hRatio); draw1D(hCheck2); }
//================================================ void DeltaZVsPos(const Int_t save = 0) { THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); TList *list = new TList; // dz vs BL TH2F *hTrkDzVsBL = (TH2F*)hn->Projection(1,3); c = draw2D(hTrkDzVsBL,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_BL_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_BL_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } list->Clear(); TString legName[30]; TH1F *hTrkDzInBL[30]; Int_t counter = 0; for(Int_t i=0; i<30; i++) { hTrkDzInBL[i] = (TH1F*)hTrkDzVsBL->ProjectionY(Form("hDeltaZ_BL%d",i+1),i+1,i+1); if(hTrkDzInBL[i]->GetEntries()>0) { legName[counter] = Form("Module %d",i+1); hTrkDzInBL[i]->SetLineColor(color[counter]); list->Add(hTrkDzInBL[i]); counter ++; } } c = drawHistos(list,"TrkDzInBL",Form("%s: #Deltaz of matched track-hit pairs in backleg;#Deltaz (cm)",trigName[kTrigType]),kTRUE,-100,100,kTRUE,0,1.2*hTrkDzInBL[1]->GetMaximum(),kFALSE,kTRUE,legName,kTRUE,"",0.15,0.25,0.2,0.88,kFALSE,0.04,0.04,kFALSE,1,kTRUE,kFALSE); TLine *line = GetLine(0,0,0,1.1*hTrkDzInBL[1]->GetMaximum(),1); line->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_BL_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_BL_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } // dz vs Mod TH2F *hTrkDzVsMod = (TH2F*)hn->Projection(1,4); c = draw2D(hTrkDzVsMod,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_Mod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_Mod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } TH1F *hMthMod = (TH1F*)hTrkDzVsMod->ProjectionX("hMthMod"); hMthMod->Sumw2(); hMthMod->Scale(1./hMthMod->Integral()); TH2F *hMtdHitMap = (TH2F*)f->Get(Form("mhMtdHitMap_%s",trigName[kTrigType])); TH1F *htmp = (TH1F*)hMtdHitMap->ProjectionY("hHitMod_finebin"); htmp->Rebin(12); TH1F *hMtdHitMod = new TH1F(Form("hMtdHitMod_%s",trigName[kTrigType]),"# of MTD hits per module;module",5,1,6); for(int i=0; i<hMtdHitMod->GetNbinsX(); i++) { hMtdHitMod->SetBinContent(i+1,htmp->GetBinContent(i+1)); hMtdHitMod->SetBinError(i+1,htmp->GetBinError(i+1)); } hMtdHitMod->Scale(1./hMtdHitMod->Integral()); list->Clear(); list->Add(hMthMod); list->Add(hMtdHitMod); TString legName3[2] = {"Matched good hits","All good hits"}; c = drawHistos(list,"MtdHitMod",Form("%s: MTD hits per module;module;probability",trigName[kTrigType]),kFALSE,0,5,kTRUE,0,0.5,kFALSE,kTRUE,legName3,kTRUE,"",0.15,0.25,0.6,0.88,kTRUE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sCompMtdHitMod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sCompMtdHitMod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } list->Clear(); TString legName2[5]; TH1F *hTrkDzInMod[5]; for(Int_t i=0; i<5; i++) { hTrkDzInMod[i] = (TH1F*)hTrkDzVsMod->ProjectionY(Form("hDeltaZ_Mod%d",i+1),i+1,i+1); legName2[i] = Form("Module %d",i+1); list->Add(hTrkDzInMod[i]); } c = drawHistos(list,"TrkDzInMod",Form("%s: #Deltaz of matched track-hit pairs in module;#Deltaz (cm)",trigName[kTrigType]),kTRUE,-100,100,kTRUE,0,1.2*hTrkDzInMod[3]->GetMaximum(),kFALSE,kTRUE,legName2,kTRUE,"",0.15,0.25,0.6,0.88,kTRUE); TLine *line = GetLine(0,0,0,hTrkDzInMod[3]->GetMaximum()*1.05,1); line->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_Mod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_Mod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } }
void draw() { GLfloat position[4] = {1, 1, 1, 0}; // Clearing glClearColor(0, 0, 0.0f, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Setting camera glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // Draw crosshair before lookat glLineWidth(1); glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); draw2D(); glPopMatrix(); glPopAttrib(); glMatrixMode(GL_MODELVIEW); gluLookAt( camPosition[0], camPosition[1], camPosition[2], camPosition[0] - camOrientation[2], camPosition[1] - camOrientation[5], camPosition[2] - camOrientation[8], camOrientation[1], camOrientation[4], camOrientation[7] ); // Setting light position glLightfv(GL_LIGHT0, GL_POSITION, position); // Drawing /* glBegin(GL_LINES); { double *nearest = COL_queryLatestNearest(); // double *lastImpulse = DYN_getLastImpulse(); double *lastCollisionPoint = DYN_getLastCollisionPoint(); glColor3f(1, 0, 0); glVertex3f(nearest[0], nearest[1], nearest[2]); glColor3f(0, 1, 0); glVertex3f(nearest[3], nearest[4], nearest[5]); glColor3f(1, 1, 0); glVertex3f(lastCollisionPoint[0], lastCollisionPoint[1], lastCollisionPoint[2]); glColor3f(1, 1, 0); glVertex3f( lastCollisionPoint[0] + lastCollisionPoint[0] * 20, lastCollisionPoint[1] + lastCollisionPoint[1] * 20, lastCollisionPoint[2] + lastCollisionPoint[2] * 20 ); } glEnd();*/ drawAxes(); drawGrid(); drawBodies(); }