//============================================================================== void ColourGradient::createLookupTable (PixelARGB* const lookupTable, const int numEntries) const noexcept { JUCE_COLOURGRADIENT_CHECK_COORDS_INITIALISED // Trying to use this object without setting its coordinates? jassert (colours.size() >= 2); jassert (numEntries > 0); jassert (colours.getReference(0).position == 0); // The first colour specified has to go at position 0 PixelARGB pix1 (colours.getReference (0).colour.getPixelARGB()); int index = 0; for (int j = 1; j < colours.size(); ++j) { const ColourPoint& p = colours.getReference (j); const int numToDo = roundToInt (p.position * (numEntries - 1)) - index; const PixelARGB pix2 (p.colour.getPixelARGB()); for (int i = 0; i < numToDo; ++i) { jassert (index >= 0 && index < numEntries); lookupTable[index] = pix1; lookupTable[index].tween (pix2, (uint32) ((i << 8) / numToDo)); ++index; } pix1 = pix2; } while (index < numEntries) lookupTable [index++] = pix1; }
void ARehabMainWindow::loadGuiInitial(void) { float wGraphicsView = ui.graphicsInicial->width(); float hGraphicsView = ui.graphicsInicial->height(); ui.btHelp->setIcon(QPixmap(QString::fromUtf8(":/svg/help.svg"))); ui.btAbout->setIcon(QPixmap(QString::fromUtf8(":/svg/about.svg"))); ui.graphicsInicial->verticalScrollBar()->blockSignals(true); ui.graphicsInicial->horizontalScrollBar()->blockSignals(true); ui.graphicsInicial->setScene(new QGraphicsScene); QGraphicsScene * scene = ui.graphicsInicial->scene(); scene->setSceneRect(0, 0, ui.graphicsInicial->width(), ui.graphicsInicial->height()); QRadialGradient gradient(wGraphicsView / 2.0f, hGraphicsView / 2.0f, hGraphicsView); gradient.setColorAt(0.95, QColor(200, 200, 200)); gradient.setColorAt(0.5, QColor(255, 255, 255)); gradient.setColorAt(0, QColor(255, 255, 255)); scene->setBackgroundBrush(QBrush(gradient)); QPixmap pix1(":/images/banner.png"); this->pixmapItemInitial = scene->addPixmap(pix1); float wImage = this->pixmapItemInitial->boundingRect().width(); float hImage = this->pixmapItemInitial->boundingRect().height(); float scaleH = hGraphicsView / hImage; pixmapItemInitial->setTransformationMode(Qt::SmoothTransformation); pixmapItemInitial->setScale(scaleH); pixmapItemInitial->setPos((wGraphicsView / 2.0f) - (scaleH*wImage / 2.0f), 0); QFont btFont("Calibri", 16, QFont::Light); btNew = new QPushButton("Nuevo Ejercicio"); btNew->setMinimumSize(360, 60); btNew->setFont(btFont); proxyBtNuevo = scene->addWidget(btNew); btLoad = new QPushButton("Cargar Ejercicio"); btLoad->setMinimumSize(360, 60); btLoad->setFont(btFont); proxyBtLoad = scene->addWidget(btLoad); btLoadResults = new QPushButton("Cargar Resultados de Paciente"); btLoadResults->setMinimumSize(360, 60); btLoadResults->setFont(btFont); proxyBtLoadResults = scene->addWidget(btLoadResults); QGridLayout * layoutBottomFrame = reinterpret_cast<QGridLayout*>(ui.bottomFrame->layout()); if (layoutBottomFrame) { layoutBottomFrame->addWidget(this->guistatewidget, 0, 1); this->guistatewidget->hide(); } }
//============================================================================== int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlock <PixelARGB>& lookupTable) const { #if JUCE_DEBUG // trying to use the object without setting its co-ordinates? Have a careful read of // the comments for the constructors. jassert (point1.getX() != 987654.0f); #endif const int numEntries = jlimit (1, jmax (1, (colours.size() - 1) << 8), 3 * (int) point1.transformedBy (transform) .getDistanceFrom (point2.transformedBy (transform))); lookupTable.malloc ((size_t) numEntries); if (colours.size() >= 2) { jassert (colours.getReference(0).position == 0); // the first colour specified has to go at position 0 PixelARGB pix1 (colours.getReference (0).colour.getPixelARGB()); int index = 0; for (int j = 1; j < colours.size(); ++j) { const ColourPoint& p = colours.getReference (j); const int numToDo = roundToInt (p.position * (numEntries - 1)) - index; const PixelARGB pix2 (p.colour.getPixelARGB()); for (int i = 0; i < numToDo; ++i) { jassert (index >= 0 && index < numEntries); lookupTable[index] = pix1; lookupTable[index].tween (pix2, (uint32) (i << 8) / numToDo); ++index; } pix1 = pix2; } while (index < numEntries) lookupTable [index++] = pix1; } else { jassertfalse; // no colours specified! } return numEntries; }
int ctkThumbnailListWidgetTest1( int argc, char * argv [] ) { QApplication app(argc, argv); ctkThumbnailListWidget widget; QPixmap pix1(QSize(128, 128));; QPixmap pix2(QSize(64, 64)); QPixmap pix3(QSize(256, 256)); QPixmap pix4(QSize(256, 128)); pix1.fill(Qt::green); pix2.fill(Qt::yellow); pix3.fill(Qt::blue); pix4.fill(Qt::red); QList<QPixmap> pixList; widget.setThumbnailSize(QSize(128, 128)); if(widget.thumbnailSize() != QSize(128, 128)) { std::cerr << "ctkThumbnailListWidget::setThumbnailWidth failed." << " size: " << widget.thumbnailSize().width() << "," << widget.thumbnailSize().height() << " expected: 128" << std::endl; return EXIT_FAILURE; } pixList.append(pix1); pixList.append(pix2); pixList.append(pix3); pixList.append(pix4); widget.addThumbnails(pixList); widget.show(); if (argc <= 1 || QString(argv[1]) != "-I") { QTimer::singleShot(200, &app, SLOT(quit())); } return app.exec(); }
void Field::slot_change_icon(){ if(scene->get_count() == 1){ QPixmap pixhh(PALADIN_ICON); whose_turn_wgt->setIcon(pixhh); whose_turn_wgt->setIconSize(pixhh.size()); } else if(scene->get_count() == 2){ QPixmap pixoh(OGRE_ICON); whose_turn_wgt->setIcon(pixoh); whose_turn_wgt->setIconSize(pixoh.size()); } else if(scene->get_count() == 3){ QPixmap pix1(ARCHER_ICON); whose_turn_wgt->setIcon(pix1); whose_turn_wgt->setIconSize(pix1.size()); } else if(scene->get_count() == 4){ QPixmap pix2(TROLL_ICON); whose_turn_wgt->setIcon(pix2); whose_turn_wgt->setIconSize(pix2.size()); } else if(scene->get_count() == 5){ QPixmap pix3(FOOTMAN_ICON); whose_turn_wgt->setIcon(pix3); whose_turn_wgt->setIconSize(pix3.size()); } else if(scene->get_count() == 6){ QPixmap pix4(GRUNT_ICON); whose_turn_wgt->setIcon(pix4); whose_turn_wgt->setIconSize(pix4.size()); } else if(scene->get_count() == 7){ QPixmap pix5(BALLISTA_ICON); whose_turn_wgt->setIcon(pix5); whose_turn_wgt->setIconSize(pix5.size()); } else if(scene->get_count() == 8){ QPixmap pix6(CATAPULT_ICON); whose_turn_wgt->setIcon(pix6); whose_turn_wgt->setIconSize(pix6.size()); } }
/* See task: 41469 Problem is that the state is not properly restored if the basestate of the painter is different when the picture data was created compared to the base state of the painter when it is played back. */ void tst_QPicture::save_restore() { QPicture pic; QPainter p; p.begin(&pic); paintStuff(&p); p.end(); QPixmap pix1(300, 300); pix1.fill(Qt::white); p.begin(&pix1); p.drawPicture(50, 50, pic); p.end(); QPixmap pix2(300, 300); pix2.fill(Qt::white); p.begin(&pix2); p.translate(50, 50); paintStuff(&p); p.end(); QVERIFY( pix1.toImage() == pix2.toImage() ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); r1 = NULL; gr = NULL; gr1 = NULL; gr2 = NULL; gr3 = NULL; gr4 = NULL; gr5 = NULL; ui->lineEdit->setText("0.0"); ui->lineEdit_2->setText("0"); ui->lineEdit_3->setText("0"); ui->lineEdit_4->setText("2"); ui->lineEdit_5->setText("2"); ui->lineEdit_6->setText("100"); ui->lineEdit_7->setText("100"); ui->lineEdit_8->setText("5"); ui->lineEdit_9->setText("5"); QPixmap pix("pic1.png"); QPixmap pix1("pic2.png"); QPalette pal; pal.setBrush(QPalette::Window,QBrush(pix1)); //pix.scaled(100,100,Qt::IgnoreAspectRatio,Qt::FastTransformation); ui->label_11->setPixmap(pix); ui->label_11->setScaledContents(true); //ui->pushButton_2->setEnabled(false); }
int main_alt() { in_head.Register("/egomap/i:head"); in_img.Register("/egomap/i:img"); out_img.Register("/egomap/o:img"); out_cmd.Register("/egomap/o:cmd"); in_voice.Register("/egomap/i:cmd"); while (1) { JointPos joints; in_img.Read(); state_mutex.Wait(); joints = state_joint; CogGaze gaze; gaze.Apply(joints); double roll = gaze.roll_right; double theta = gaze.theta_right; double phi = gaze.phi_right; //printf("DIR %g %g %g\n", theta, phi, roll); global_theta = theta; global_phi = phi; global_roll = roll; state_mutex.Post(); double z_x = gaze.z_right[0]; double z_y = gaze.z_right[1]; YARPImageOf<YarpPixelBGR> img; img.Refer(in_img.Content()); int width = img.GetWidth(); int height = img.GetHeight(); float s = 50; for (int i=0; i<width; i++) { YarpPixelBGR pix0(0,255,0); img(i,width/2) = pix0; } for (int i=0; i<width; i++) { float s2 = (i-width/2.0); float x = cos(roll)*s2; float y = -sin(roll)*s2; YarpPixelBGR pix(255,0,0); img.SafePixel((int)(0.5+x+(width+1)/2.0),(int)(0.5+y+(width+1)/2.0)) = pix; } int step = 500; for (int i=0; i<step; i++) { float theta = i*M_PI*2.0/step; YarpPixelBGR pix(255,0,0); float x = cos(theta)*s; float y = sin(theta)*s; //printf("%g %g %g\n", theta, x, y); img.SafePixel(x+width/2,y+width/2) = pix; } for (int i=0; i<MAX_TARGETS; i++) { if (target_manager.Exists(i)) { TargetLocation& loc = target_manager.Get(i); float target_theta = loc.theta; float target_phi = loc.phi; float z_y = loc.phi/(M_PI/2); float z_x = loc.theta/(M_PI/2); //printf("Drawing circle for %g %g\n", loc.theta, loc.phi); float x = z_x*s; float y = z_y*s; // YarpPixelBGR pix0(0,128,255); // AddCircle(img,pix0,(int)x+width/2,(int)y+height/2,4); // We now try to map back // onto approximate retinotopic coordinates. // current x, y, z available in gaze::x_right,y_right,z_right double x_vis, y_vis; int visible; visible = gaze.Intersect(target_theta,target_phi,x_vis,y_vis, CAMERA_SOURCE_RIGHT_WIDE); /* float zt[3]; zt[0] = sin(target_theta); zt[1] = -cos(target_phi)*cos(target_theta); zt[2] = sin(target_phi)*cos(target_theta); float delta_theta = zt[0]*gaze.x_right[0] + zt[1]*gaze.x_right[1] + zt[2]*gaze.x_right[2]; float delta_phi = zt[0]*gaze.y_right[0] + zt[1]*gaze.y_right[1] + zt[2]*gaze.y_right[2]; float sanity = zt[0]*gaze.z_right[0] + zt[1]*gaze.z_right[1] + zt[2]*gaze.z_right[2]; //float delta_theta = zt[0]; //target_theta - global_theta; //float delta_phi = zt[1]; //target_phi - global_phi; float factor_theta = 67; // just guessed these numbers float factor_phi = 67; // so far, not linear in reality float nx = delta_theta; float ny = delta_phi; float r = global_roll; float sinr = sin(r); float cosr = cos(r); float fx = factor_theta; float fy = factor_phi; //delta_theta = nx*cosr - ny*sinr; // just guessed the signs here //delta_phi = nx*sinr + ny*cosr; // so far //delta_theta = nx*cosr - ny*sinr; // just guessed the signs here //delta_phi = nx*sinr + ny*cosr; // so far delta_theta *= factor_theta; delta_phi *= factor_phi; delta_phi *= 4.0/3.0; float len = sqrt(delta_theta*delta_theta+delta_phi*delta_phi); delta_theta += img.GetWidth()/2; delta_phi += img.GetHeight()/2; */ int sanity = visible; double delta_theta = x_vis; double delta_phi = y_vis; delta_theta -= 64; delta_phi -= 64; float len = sqrt(delta_theta*delta_theta+delta_phi*delta_phi); delta_theta += 64; delta_phi += 64; if (sanity>0) { YarpPixelBGR pix1((len<50)?255:0,128,0); AddCircle(img,pix1,(int)(delta_theta+0.5), (int)(delta_phi+0.5),4); } else { //printf("Object occluded\n"); } } } z_y = phi/(M_PI/2); z_x = theta/(M_PI/2); if (0) for (int i=0; i<5; i++) { float x = z_x*s; float y = z_y*s; YarpPixelBGR pix(255,0,0); YarpPixelBGR pix2(0,0,255); img.SafePixel(i+x+width/2,y+width/2) = pix; img.SafePixel(-i+x+width/2,y+width/2) = pix; img.SafePixel(i+x+width/2,y+width/2-1) = pix2; img.SafePixel(-i+x+width/2,y+width/2+1) = pix2; img.SafePixel(x+width/2,i+y+width/2) = pix; img.SafePixel(x+width/2,-i+y+width/2) = pix; img.SafePixel(x+width/2+1,i+y+width/2) = pix2; img.SafePixel(x+width/2-1,-i+y+width/2) = pix2; } out_img.Content().PeerCopy(in_img.Content()); out_img.Write(); } return 0; }
Field::Field(QWidget *parent, int n_arch, int n_knig, int n_mach) : QWidget(parent){ QWidget* wgt = new QWidget(this); QPalette pal1 = wgt->palette(); pal1.setColor(QPalette::Base, QColor(255, 255, 255, 0)); wgt->setFixedSize(1350, 750); Sound* snd = new Sound(this, SOUND_GAME); QPixmap p(HUMAN_CURSOR); QCursor cur(p, 0, 0); setCursor(cur); whose_turn_wgt = new QPushButton; whose_turn_wgt->setFixedSize(97, 97); QPixmap pix_w(PALADIN_ICON); whose_turn_wgt->setIcon(pix_w); whose_turn_wgt->setIconSize(pix_w.size()); scene = new BattleScene(30, 33, 930, 496, n_arch, n_knig, n_mach); scene->setBackgroundBrush(QPixmap(LANDSCAPE)); end_turn = new QPushButton; QPixmap pix(FINISH_TURN_BUTTON); end_turn->setIcon(pix); end_turn->setIconSize(pix.size()); end_turn->setFixedSize(pix.width(), pix.height()); quit = new QPushButton; QPixmap pix1(EXIT_BUTTON); quit->setIcon(pix1); quit->setIconSize(pix1.size()); quit->setFixedSize(pix1.width(), pix1.height()); view = new FieldView; view->setScene(scene); view->setFixedSize(scene->width()+90, scene->height()+90); QPalette pal; pal.setBrush(this->backgroundRole(), QBrush(QPixmap(FIELD_BACKGROUND))); setPalette(pal); UnitInfo* uinf = new UnitInfo(this, scene); MovesLeft* ml = new MovesLeft(this, scene); QGridLayout* qglt = new QGridLayout; qglt->setMargin(20); qglt->setSpacing(15); if(QApplication::desktop()->width() >= 1366){ qglt->addWidget(ml, 0, 1, Qt::AlignCenter); qglt->addWidget(uinf, 1, 0, Qt::AlignTop); qglt->addWidget(whose_turn_wgt, 1, 0, Qt::AlignCenter); qglt->addWidget(quit, 2, 1, Qt::AlignRight); qglt->addWidget(view, 1, 1); qglt->addWidget(end_turn, 2, 0, Qt::AlignCenter); qglt->addWidget(snd, 2, 1, Qt::AlignCenter); } else if(QApplication::desktop()->width() < 1366){ wgt->setFixedSize(1240, 960); qglt->addWidget(uinf, 0, 1, Qt::AlignRight); qglt->addWidget(ml, 0, 1, Qt::AlignBottom); qglt->addWidget(whose_turn_wgt, 0, 1, Qt::AlignLeft); qglt->addWidget(quit, 2, 2, Qt::AlignCenter); qglt->addWidget(view, 1, 1); qglt->addWidget(end_turn, 2, 0, Qt::AlignCenter); qglt->addWidget(snd, 2, 1, Qt::AlignCenter); } wgt->setLayout(qglt); QVBoxLayout* main_lo = new QVBoxLayout; main_lo->addWidget(wgt); setLayout(main_lo); setWindowState(Qt::WindowFullScreen); connect(scene, SIGNAL(signal_end_turn()), end_turn, SIGNAL(clicked())); connect(scene, SIGNAL(signal_dead_humans_army()), this, SLOT(slot_orcs_victory())); connect(scene, SIGNAL(signal_dead_orcs_army()), this, SLOT(slot_humans_victory())); connect(scene, SIGNAL(signal_change_current_unit_icon()), this, SLOT(slot_change_icon())); connect(scene, SIGNAL(signal_press_next_turn_button()), end_turn, SIGNAL(clicked())); connect(end_turn, SIGNAL(clicked()), scene, SIGNAL(signal_click_count())); connect(end_turn, SIGNAL(clicked()), scene, SIGNAL(signal_move_end())); connect(end_turn, SIGNAL(clicked()), scene, SLOT(slot_null_to_turns_summ())); connect(end_turn, SIGNAL(clicked()), this, SLOT(slot_change_cursor())); connect(end_turn, SIGNAL(clicked()), ml, SLOT(slot_update_turns_info())); connect(end_turn, SIGNAL(clicked()), uinf, SLOT(slot_clear_field())); connect(quit, SIGNAL(clicked()), snd->med_obj, SLOT(stop())); connect(quit, SIGNAL(clicked()), this, SLOT(close())); connect(quit, SIGNAL(clicked()), this, SLOT(slot_start_window())); }
void EfficiencyLxy(){ TString fname = "mGamma_0250_ctau1"; TFile *f = new TFile(fname+".root"); f->cd("Analysis"); f->ls(); Int_t ev; Int_t run; Int_t lumi; Int_t genm; Int_t trig; Float_t ptgenm[20]; Float_t etagenm[20]; Int_t recm; Float_t ptrecm[20]; Float_t etarecm[20]; Float_t phirecm[20]; Int_t mjets; Int_t mj1mu; Int_t mj2mu; Float_t ptmumj1[20]; Float_t ptmumj2[20]; Float_t etamumj1[20]; Float_t etamumj2[20]; Int_t vtx; Float_t gen_dzmj1_0; Float_t gen_dzmj1_1; Float_t gen_mj1_0_pt; Float_t gen_mj1_1_pt; Float_t gen_mj1_0_eta; Float_t gen_mj1_1_eta; Float_t gen_mj1_0_phi; Float_t gen_mj1_1_phi; Float_t gen_dzmj2_0; Float_t gen_dzmj2_1; Float_t gen_mj2_0_pt; Float_t gen_mj2_1_pt; Float_t gen_mj2_0_eta; Float_t gen_mj2_1_eta; Float_t gen_mj2_0_phi; Float_t gen_mj2_1_phi; Float_t lxy_ge_1_0; Float_t lxy_ge_1_1; Float_t lxy_ge_2_0; Float_t lxy_ge_2_1; TTree *t = (TTree*)f->Get("Analysis/Events"); TCanvas* c1 = new TCanvas("c1","Example",800,600); c1->SetFillColor(0); gStyle->SetPalette(1); gStyle->SetOptStat(0); // SetPlotStyle(); t->SetBranchAddress("lxy_ge_1_0", &lxy_ge_1_0); t->SetBranchAddress("lxy_ge_1_1", &lxy_ge_1_1); t->SetBranchAddress("lxy_ge_2_0", &lxy_ge_2_0); t->SetBranchAddress("lxy_ge_2_1", &lxy_ge_2_1); t->SetBranchAddress("gen_dzmj1_0", &gen_dzmj1_0); t->SetBranchAddress("gen_dzmj1_1", &gen_dzmj1_1); t->SetBranchAddress("gen_mj1_0_pt", &gen_mj1_0_pt); t->SetBranchAddress("gen_mj1_1_pt", &gen_mj1_1_pt); t->SetBranchAddress("gen_mj1_0_eta", &gen_mj1_0_eta); t->SetBranchAddress("gen_mj1_1_eta", &gen_mj1_1_eta); t->SetBranchAddress("gen_mj1_0_phi", &gen_mj1_0_phi); t->SetBranchAddress("gen_mj1_1_phi", &gen_mj1_1_phi); t->SetBranchAddress("gen_dzmj2_0", &gen_dzmj2_0); t->SetBranchAddress("gen_dzmj2_1", &gen_dzmj2_1); t->SetBranchAddress("gen_mj2_0_pt", &gen_mj2_0_pt); t->SetBranchAddress("gen_mj2_1_pt", &gen_mj2_1_pt); t->SetBranchAddress("gen_mj2_0_eta", &gen_mj2_0_eta); t->SetBranchAddress("gen_mj2_1_eta", &gen_mj2_1_eta); t->SetBranchAddress("gen_mj2_0_phi", &gen_mj2_0_phi); t->SetBranchAddress("gen_mj2_1_phi", &gen_mj2_1_phi); t->SetBranchAddress("event",&ev); t->SetBranchAddress("run",&run); t->SetBranchAddress("lumi",&lumi); t->SetBranchAddress("trigger",&trig); t->SetBranchAddress("isVtx",&vtx); t->SetBranchAddress("genmuons",&genm); t->SetBranchAddress("ptgenMuons",&ptgenm); t->SetBranchAddress("etagenMuons",&etagenm); t->SetBranchAddress("recmuons",&recm); t->SetBranchAddress("ptrecMuons",&ptrecm); t->SetBranchAddress("etarecMuons",&etarecm); t->SetBranchAddress("phirecMuons",&phirecm); t->SetBranchAddress("recmujets",&mjets); t->SetBranchAddress("mj1muons",&mj1mu); t->SetBranchAddress("mj2muons",&mj2mu); t->SetBranchAddress("ptmj1muons",&ptmumj1); t->SetBranchAddress("ptmj2muons",&ptmumj2); t->SetBranchAddress("etamj1muons",&etamumj1); t->SetBranchAddress("etamj2muons",&etamumj2); Float_t bin_edges[19]={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36}; Float_t bin_center[18]; Float_t errbin_center[18]; Float_t erry[18]; Float_t bin_edges_lxy[19]={0,2,4,6,8,10,12,14,16,18,20,25,30,35,40,45,50,60,80}; Float_t bin_center_lxy[18]; Float_t errbin_center_lxy[18]; Float_t erry_lxy[18]; for(int k=0;k<18;k++){ bin_center[k] = bin_edges[k] + ( (bin_edges[k+1]-bin_edges[k])/2.0); errbin_center[k] = ( (bin_edges[k+1]-bin_edges[k])/2.0); erry[k] = 0.0; bin_center_lxy[k] = bin_edges_lxy[k] + ( (bin_edges_lxy[k+1]-bin_edges_lxy[k])/2.0); errbin_center_lxy[k] = ( (bin_edges_lxy[k+1]-bin_edges_lxy[k])/2.0); erry_lxy[k] = 0.0; } //=============================================== Float_t count_barrel_muonPair_1_0[18]={0.0}; Float_t count_rec_barrel_muonPair_1_0[18]={0.0}; Float_t count_barrel_muonPair_1_1[18]={0.0}; Float_t count_rec_barrel_muonPair_1_1[18]={0.0}; Float_t count_endcap_muonPair_1_0[18]={0.0}; Float_t count_rec_endcap_muonPair_1_0[18]={0.0}; Float_t count_endcap_muonPair_1_1[18]={0.0}; Float_t count_rec_endcap_muonPair_1_1[18]={0.0}; Float_t count_barrel_muonPair_2_0[18]={0.0}; Float_t count_rec_barrel_muonPair_2_0[18]={0.0}; Float_t count_barrel_muonPair_2_1[18]={0.0}; Float_t count_rec_barrel_muonPair_2_1[18]={0.0}; Float_t count_endcap_muonPair_2_0[18]={0.0}; Float_t count_rec_endcap_muonPair_2_0[18]={0.0}; Float_t count_endcap_muonPair_2_1[18]={0.0}; Float_t count_rec_endcap_muonPair_2_1[18]={0.0}; Float_t count_lxy_barrel_muonPair_1_0[18]={0.0}; Float_t count_lxy_rec_barrel_muonPair_1_0[18]={0.0}; Float_t count_lxy_barrel_muonPair_1_1[18]={0.0}; Float_t count_lxy_rec_barrel_muonPair_1_1[18]={0.0}; Float_t count_lxy_endcap_muonPair_1_0[18]={0.0}; Float_t count_lxy_rec_endcap_muonPair_1_0[18]={0.0}; Float_t count_lxy_endcap_muonPair_1_1[18]={0.0}; Float_t count_lxy_rec_endcap_muonPair_1_1[18]={0.0}; Float_t count_lxy_barrel_muonPair_2_0[18]={0.0}; Float_t count_lxy_rec_barrel_muonPair_2_0[18]={0.0}; Float_t count_lxy_barrel_muonPair_2_1[18]={0.0}; Float_t count_lxy_rec_barrel_muonPair_2_1[18]={0.0}; Float_t count_lxy_endcap_muonPair_2_0[18]={0.0}; Float_t count_lxy_rec_endcap_muonPair_2_0[18]={0.0}; Float_t count_lxy_endcap_muonPair_2_1[18]={0.0}; Float_t count_lxy_rec_endcap_muonPair_2_1[18]={0.0}; Int_t nentries = t->GetEntries(); Int_t mcount[4]={0}; Int_t rmcount[4]={0}; bool verbose = false; int entries = 0; for(int k=0;k<nentries;k++){ t->GetEntry(k); entries++; if (entries % 500 == 0) std::cout << "entries: " << entries << ", " << (entries*1.0/80000.0)*100.0 << " % " << std::endl; verbose = false; Int_t hptm_count=0; Int_t m_count=0; for(int j=0;j<genm;j++){ if(ptgenm[j]>17.0 && fabs(etagenm[j])<0.9) hptm_count++; if(ptgenm[j]>8.0 && fabs(etagenm[j])<2.4) m_count++; if (verbose) std::cout << "ptgenm[j]: " << ptgenm[j] << ", fabs(etagenm[j]): " << fabs(etagenm[j]) << std::endl; } if(hptm_count>0){ mcount[0]++; if(m_count>1) mcount[1]++; if(m_count>2) mcount[2]++; if(m_count>3) mcount[3]++; } if(hptm_count>0 && mcount>3){ bool lxy = true; bool dz = false; if (gen_mj1_0_pt > 8 && gen_mj1_1_pt > 8 && gen_mj2_1_pt > 8 && gen_mj2_1_pt > 8){ bool matchRec11 = false; double dphi11 = 1000.0; double deta11 = 1000.0; double dR11 = 1000.0; int match11 = 100; bool matchRec12 = false; double dphi12 = 1000.0; double deta12 = 1000.0; double dR12 = 1000.0; int match12 = 100; bool matchRec21 = false; double dphi21 = 1000.0; double deta21 = 1000.0; double dR21 = 1000.0; int match21 = 100; bool matchRec22 = false; double dphi22 = 1000.0; double deta22 = 1000.0; double dR22 = 1000.0; int match22 = 100; for(int j=0;j<recm;j++){ if(ptrecm[j]<8.0 || fabs(etarecm[j])>2.4) continue; dphi11 = My_dPhi(phirecm[j], gen_mj1_0_phi); dphi12 = My_dPhi(phirecm[j], gen_mj1_1_phi); deta11 = (etarecm[j] - gen_mj1_0_eta); deta12 = (etarecm[j] - gen_mj1_1_eta); dR11 = sqrt(dphi11*dphi11+deta11*deta11); dR12 = sqrt(dphi12*dphi12+deta12*deta12); if(dR11<0.5){ matchRec11 = true; match11 = j; } if(dR12<0.5){ matchRec12 = true; match12 = j; } dphi21 = My_dPhi(phirecm[j], gen_mj2_0_phi); dphi22 = My_dPhi(phirecm[j], gen_mj2_1_phi); deta21 = (etarecm[j] - gen_mj2_0_eta); deta22 = (etarecm[j] - gen_mj2_1_eta); dR21 = sqrt(dphi21*dphi21+deta21*deta21); dR22 = sqrt(dphi22*dphi22+deta22*deta22); if(dR21<0.5){ matchRec21 = true; match21 = j; } if(dR22<0.5){ matchRec22 = true; match22 = j; } } for(int m=0;m<18;m++){ if(fabs(lxy_ge_1_0)>bin_edges_lxy[m] && fabs(lxy_ge_1_0)<bin_edges_lxy[m+1]){ if (fabs(gen_mj1_0_eta) < 0.8){ count_lxy_barrel_muonPair_1_0[m]++; } if (fabs(gen_mj1_0_eta) > 0.8) count_lxy_endcap_muonPair_1_0[m]++; if (matchRec11){ if (fabs(gen_mj1_0_eta) < 0.8){ count_lxy_rec_barrel_muonPair_1_0[m]++; } if (fabs(gen_mj1_0_eta) > 0.8) count_lxy_rec_endcap_muonPair_1_0[m]++; if (verbose) std::cout << "event: " << ev << " gen1 pt: " << gen_mj1_0_pt << ", gen1 eta: " << gen_mj1_0_eta << ", rec match pt: " << ptrecm[match11] << ", rec match eta " << etarecm[match11] << ", lxy: " << lxy_ge_1_0 << std::endl; } } if(fabs(lxy_ge_1_1)>bin_edges_lxy[m] && fabs(lxy_ge_1_1)<bin_edges_lxy[m+1]){ if (fabs(gen_mj1_1_eta) < 0.8) count_lxy_barrel_muonPair_1_1[m]++; if (fabs(gen_mj1_1_eta) > 0.8) count_lxy_endcap_muonPair_1_1[m]++; if (matchRec12){ if (fabs(gen_mj1_1_eta) < 0.8) count_lxy_rec_barrel_muonPair_1_1[m]++; if (fabs(gen_mj1_1_eta) > 0.8) count_lxy_rec_endcap_muonPair_1_1[m]++; if (verbose) std::cout << "event: " << ev << " gen1 pt: " << gen_mj1_1_pt << ", gen1 eta: " << gen_mj1_1_eta << ", rec match pt: " << ptrecm[match12] << ", rec match eta " << etarecm[match12] << ", lxy: " << lxy_ge_1_1 << std::endl; } } if(fabs(lxy_ge_2_0)>bin_edges_lxy[m] && fabs(lxy_ge_2_0)<bin_edges_lxy[m+1]){ if (fabs(gen_mj2_0_eta) < 0.8){ count_lxy_barrel_muonPair_2_0[m]++; } if (fabs(gen_mj2_0_eta) > 0.8) count_lxy_endcap_muonPair_2_0[m]++; if (matchRec21){ if (fabs(gen_mj2_0_eta) < 0.8){ count_lxy_rec_barrel_muonPair_2_0[m]++; } if (fabs(gen_mj2_0_eta) > 0.8) count_lxy_rec_endcap_muonPair_2_0[m]++; if (verbose) std::cout << "event: " << ev << " gen1 pt: " << gen_mj2_0_pt << ", gen1 eta: " << gen_mj2_0_eta << ", rec match pt: " << ptrecm[match21] << ", rec match eta " << etarecm[match21] << ", lxy: " << lxy_ge_2_0 << std::endl; } } if(fabs(lxy_ge_2_1)>bin_edges_lxy[m] && fabs(lxy_ge_2_1)<bin_edges_lxy[m+1]){ if (fabs(gen_mj2_1_eta) < 0.8){ count_lxy_barrel_muonPair_2_1[m]++; } if (fabs(gen_mj2_1_eta) > 0.8) count_lxy_endcap_muonPair_2_1[m]++; if (matchRec22){ if (fabs(gen_mj2_1_eta) < 0.8){ count_lxy_rec_barrel_muonPair_2_1[m]++; } if (fabs(gen_mj2_1_eta) > 0.8) count_lxy_rec_endcap_muonPair_2_1[m]++; if (verbose) std::cout << "event: " << ev << " gen1 pt: " << gen_mj2_1_pt << ", gen1 eta: " << gen_mj2_1_eta << ", rec match pt: " << ptrecm[match22] << ", rec match eta " << etarecm[match22] << ", lxy: " << lxy_ge_2_1 << std::endl; } } } } } } std::cout << "entries: " << entries << std::endl; std::cout << "Entries loop finished" << std::endl; Float_t rval_barrel_lxy_muonPair_1_0[30]={0.0}; Float_t rval_endcap_lxy_muonPair_1_0[30]={0.0}; Float_t rval_barrel_lxy_muonPair_1_1[30]={0.0}; Float_t rval_endcap_lxy_muonPair_1_1[30]={0.0}; Float_t erval_barrel_lxy_muonPair_1_0[30]={0.0}; Float_t erval_endcap_lxy_muonPair_1_0[30]={0.0}; Float_t erval_barrel_lxy_muonPair_1_1[30]={0.0}; Float_t erval_endcap_lxy_muonPair_1_1[30]={0.0}; Float_t rval_barrel_lxy_muonPair_2_0[30]={0.0}; Float_t rval_endcap_lxy_muonPair_2_0[30]={0.0}; Float_t rval_barrel_lxy_muonPair_2_1[30]={0.0}; Float_t rval_endcap_lxy_muonPair_2_1[30]={0.0}; Float_t erval_barrel_lxy_muonPair_2_0[30]={0.0}; Float_t erval_endcap_lxy_muonPair_2_0[30]={0.0}; Float_t erval_barrel_lxy_muonPair_2_1[30]={0.0}; Float_t erval_endcap_lxy_muonPair_2_1[30]={0.0}; std::cout << "Starting fill" << std::endl; for(int k=0;k<18;k++) { if(count_lxy_barrel_muonPair_1_0[k]!=0) rval_barrel_lxy_muonPair_1_0[k] = count_lxy_rec_barrel_muonPair_1_0[k]/count_lxy_barrel_muonPair_1_0[k]; if(count_lxy_endcap_muonPair_1_0[k]!=0) rval_endcap_lxy_muonPair_1_0[k] = count_lxy_rec_endcap_muonPair_1_0[k]/count_lxy_endcap_muonPair_1_0[k]; if(count_lxy_barrel_muonPair_1_1[k]!=0) rval_barrel_lxy_muonPair_1_1[k] = count_lxy_rec_barrel_muonPair_1_1[k]/count_lxy_barrel_muonPair_1_1[k]; if(count_lxy_endcap_muonPair_1_1[k]!=0) rval_endcap_lxy_muonPair_1_1[k] = count_lxy_rec_endcap_muonPair_1_1[k]/count_lxy_endcap_muonPair_1_1[k]; if(count_lxy_barrel_muonPair_1_0[k]!=0 ) erval_barrel_lxy_muonPair_1_0[k] = sqrt( (rval_barrel_lxy_muonPair_1_0[k]*(1-rval_barrel_lxy_muonPair_1_0[k]))/count_lxy_barrel_muonPair_1_0[k]); if(count_lxy_endcap_muonPair_1_0[k]!=0) erval_endcap_lxy_muonPair_1_0[k] = sqrt( (rval_endcap_lxy_muonPair_1_0[k]*(1-rval_endcap_lxy_muonPair_1_0[k]))/count_lxy_endcap_muonPair_1_0[k]); if(count_lxy_barrel_muonPair_1_1[k]!=0 ) erval_barrel_lxy_muonPair_1_1[k] = sqrt( (rval_barrel_lxy_muonPair_1_1[k]*(1-rval_barrel_lxy_muonPair_1_1[k]))/count_lxy_barrel_muonPair_1_1[k]); if(count_lxy_endcap_muonPair_1_1[k]!=0) erval_endcap_lxy_muonPair_1_1[k] = sqrt( (rval_endcap_lxy_muonPair_1_1[k]*(1-rval_endcap_lxy_muonPair_1_1[k]))/count_lxy_endcap_muonPair_1_1[k]); if(count_lxy_barrel_muonPair_2_0[k]!=0) rval_barrel_lxy_muonPair_2_0[k] = count_lxy_rec_barrel_muonPair_2_0[k]/count_lxy_barrel_muonPair_2_0[k]; if(count_lxy_endcap_muonPair_2_0[k]!=0) rval_endcap_lxy_muonPair_2_0[k] = count_lxy_rec_endcap_muonPair_2_0[k]/count_lxy_endcap_muonPair_2_0[k]; if(count_lxy_barrel_muonPair_2_1[k]!=0) rval_barrel_lxy_muonPair_2_1[k] = count_lxy_rec_barrel_muonPair_2_1[k]/count_lxy_barrel_muonPair_2_1[k]; if(count_lxy_endcap_muonPair_2_1[k]!=0) rval_endcap_lxy_muonPair_2_1[k] = count_lxy_rec_endcap_muonPair_2_1[k]/count_lxy_endcap_muonPair_2_1[k]; if(count_lxy_barrel_muonPair_2_0[k]!=0 ) erval_barrel_lxy_muonPair_2_0[k] = sqrt( (rval_barrel_lxy_muonPair_2_0[k]*(1-rval_barrel_lxy_muonPair_2_0[k]))/count_lxy_barrel_muonPair_2_0[k]); if(count_lxy_endcap_muonPair_2_0[k]!=0) erval_endcap_lxy_muonPair_2_0[k] = sqrt( (rval_endcap_lxy_muonPair_2_0[k]*(1-rval_endcap_lxy_muonPair_2_0[k]))/count_lxy_endcap_muonPair_2_0[k]); if(count_lxy_barrel_muonPair_2_1[k]!=0 ) erval_barrel_lxy_muonPair_2_1[k] = sqrt( (rval_barrel_lxy_muonPair_2_1[k]*(1-rval_barrel_lxy_muonPair_2_1[k]))/count_lxy_barrel_muonPair_2_1[k]); if(count_lxy_endcap_muonPair_2_1[k]!=0) erval_endcap_lxy_muonPair_2_1[k] = sqrt( (rval_endcap_lxy_muonPair_2_1[k]*(1-rval_endcap_lxy_muonPair_2_1[k]))/count_lxy_endcap_muonPair_2_1[k]); } std::cout << "Starting TGraphs:" << std::endl; TGraphErrors *gr_r_barrel_lxy_muonPair_1_0 = new TGraphErrors(18,bin_center_lxy,rval_barrel_lxy_muonPair_1_0,errbin_center_lxy,erval_barrel_lxy_muonPair_1_0); TGraphErrors *gr_r_endcap_lxy_muonPair_1_0 = new TGraphErrors(18,bin_center_lxy,rval_endcap_lxy_muonPair_1_0,errbin_center_lxy,erval_endcap_lxy_muonPair_1_0); TGraphErrors *gr_r_barrel_lxy_muonPair_1_1 = new TGraphErrors(18,bin_center_lxy,rval_barrel_lxy_muonPair_1_1,errbin_center_lxy,erval_barrel_lxy_muonPair_1_1); TGraphErrors *gr_r_endcap_lxy_muonPair_1_1 = new TGraphErrors(18,bin_center_lxy,rval_endcap_lxy_muonPair_1_1,errbin_center_lxy,erval_endcap_lxy_muonPair_1_1); TGraphErrors *gr_r_barrel_lxy_muonPair_2_0 = new TGraphErrors(18,bin_center_lxy,rval_barrel_lxy_muonPair_2_0,errbin_center_lxy,erval_barrel_lxy_muonPair_2_0); TGraphErrors *gr_r_endcap_lxy_muonPair_2_0 = new TGraphErrors(18,bin_center_lxy,rval_endcap_lxy_muonPair_2_0,errbin_center_lxy,erval_endcap_lxy_muonPair_2_0); TGraphErrors *gr_r_barrel_lxy_muonPair_2_1 = new TGraphErrors(18,bin_center_lxy,rval_barrel_lxy_muonPair_2_1,errbin_center_lxy,erval_barrel_lxy_muonPair_2_1); TGraphErrors *gr_r_endcap_lxy_muonPair_2_1 = new TGraphErrors(18,bin_center_lxy,rval_endcap_lxy_muonPair_2_1,errbin_center_lxy,erval_endcap_lxy_muonPair_2_1); TCanvas *c = new TCanvas("c","c"); TLegend *leg3 = new TLegend(0.7,0.65,0.825,0.85); gr_r_barrel_lxy_muonPair_2_0->GetXaxis()->SetTitle("Lxy [cm]"); gr_r_barrel_lxy_muonPair_2_0->GetYaxis()->SetTitle("efficiency"); gr_r_barrel_lxy_muonPair_2_0->SetTitle(""); gr_r_barrel_lxy_muonPair_2_0->SetLineColor(kRed); gr_r_barrel_lxy_muonPair_2_0->SetMarkerColor(kRed); gr_r_barrel_lxy_muonPair_2_0->Draw("APL"); gr_r_barrel_lxy_muonPair_2_0->GetYaxis()->SetRangeUser(0.0,1.0); gr_r_barrel_lxy_muonPair_2_1->GetYaxis()->SetRangeUser(0.0,1.0); // gr_r_barrel_lxy_muonPair_2_0->GetXaxis()->SetRangeUser(0.0,30.0); // gr_r_barrel_lxy_muonPair_2_0->GetXaxis()->SetRangeUser(0.0,30.0); gr_r_endcap_lxy_muonPair_2_0->SetLineColor(kRed); gr_r_endcap_lxy_muonPair_2_0->SetMarkerColor(kRed); gr_r_endcap_lxy_muonPair_2_0->SetLineStyle(2); gr_r_endcap_lxy_muonPair_2_0->Draw("PLsame"); gr_r_barrel_lxy_muonPair_2_1->SetLineColor(kBlack); gr_r_barrel_lxy_muonPair_2_1->SetMarkerColor(kBlack); gr_r_endcap_lxy_muonPair_2_1->SetLineColor(kBlack); gr_r_endcap_lxy_muonPair_2_1->SetMarkerColor(kBlack); gr_r_endcap_lxy_muonPair_2_1->SetLineStyle(2); gr_r_endcap_lxy_muonPair_2_1->Draw("PLsame"); gr_r_barrel_lxy_muonPair_2_1->Draw("PLsame"); TLine pix1(4.4, 1e-8, 4.4,1.0); pix1.SetLineStyle(2); pix1.SetLineWidth(1); pix1.SetLineColor(kBlue); pix1.Draw("same"); TLine pix2(7.3, 1e-8, 7.3,1.0); pix2.SetLineStyle(2); pix2.SetLineWidth(1); pix2.SetLineColor(kBlue); pix2.Draw("same"); TLine pix3(10.2, 1e-8, 10.2,1.0); pix3.SetLineStyle(2); pix3.SetLineWidth(1); pix3.SetLineColor(kBlue); pix3.Draw("same"); TLine trk1(22,1e-8,22,1.0); trk1.SetLineStyle(2); trk1.SetLineWidth(1); trk1.SetLineColor(kGreen); trk1.Draw("same"); TLine trk2(60, 1e-8, 60,1.0); trk2.SetLineStyle(2); trk2.SetLineWidth(1); trk2.SetLineColor(kGreen); trk2.Draw("same"); leg3->SetBorderSize(0); leg3->SetFillColor(0); leg3->SetTextSize(0.036); leg3->AddEntry(gr_r_barrel_lxy_muonPair_2_0,"|#eta_{#gamma D}|<0.8 A1 #mu_{0}","PL"); leg3->AddEntry(gr_r_endcap_lxy_muonPair_2_0,"|#eta_{#gamma D}|>0.8 A1 #mu_{0}","PL"); leg3->AddEntry(gr_r_barrel_lxy_muonPair_2_1,"|#eta_{#gamma D}|<0.8 A1 #mu_{1}","PL"); leg3->AddEntry(gr_r_endcap_lxy_muonPair_2_1,"|#eta_{#gamma D}|>0.8 A1 #mu_{1}","PL"); leg3->Draw("same"); c->SaveAs(fname+"_eff_eta_lxy_1D_A1.pdf","recreate"); c->Clear(); TLegend *leg4 = new TLegend(0.7,0.65,0.825,0.85); gr_r_barrel_lxy_muonPair_1_0->GetXaxis()->SetTitle("Lxy [cm]"); gr_r_barrel_lxy_muonPair_1_0->GetYaxis()->SetTitle("efficiency"); gr_r_barrel_lxy_muonPair_1_0->SetTitle(""); gr_r_barrel_lxy_muonPair_1_0->SetLineColor(kRed); gr_r_barrel_lxy_muonPair_1_0->SetMarkerColor(kRed); gr_r_barrel_lxy_muonPair_1_0->Draw("APL"); gr_r_barrel_lxy_muonPair_1_0->GetYaxis()->SetRangeUser(0.0,1.0); gr_r_barrel_lxy_muonPair_1_1->GetYaxis()->SetRangeUser(0.0,1.0); // gr_r_barrel_lxy_muonPair_1_0->GetXaxis()->SetRangeUser(0.0,30.0); // gr_r_barrel_lxy_muonPair_1_0->GetXaxis()->SetRangeUser(0.0,30.0); gr_r_endcap_lxy_muonPair_1_0->SetLineColor(kRed); gr_r_endcap_lxy_muonPair_1_0->SetMarkerColor(kRed); gr_r_endcap_lxy_muonPair_1_0->SetLineStyle(2); gr_r_endcap_lxy_muonPair_1_0->Draw("PLsame"); gr_r_barrel_lxy_muonPair_1_1->SetLineColor(kBlack); gr_r_barrel_lxy_muonPair_1_1->SetMarkerColor(kBlack); gr_r_endcap_lxy_muonPair_1_1->SetLineColor(kBlack); gr_r_endcap_lxy_muonPair_1_1->SetMarkerColor(kBlack); gr_r_endcap_lxy_muonPair_1_1->SetLineStyle(2); gr_r_endcap_lxy_muonPair_1_1->Draw("PLsame"); gr_r_barrel_lxy_muonPair_1_1->Draw("PLsame"); pix1.Draw("same"); pix2.Draw("same"); pix3.Draw("same"); trk1.Draw("same"); trk2.Draw("same"); leg4->SetBorderSize(0); leg4->SetFillColor(0); leg4->SetTextSize(0.036); leg4->AddEntry(gr_r_barrel_lxy_muonPair_1_0,"|#eta_{#gamma D}|<0.8 A0 #mu_{0}","PL"); leg4->AddEntry(gr_r_endcap_lxy_muonPair_1_0,"|#eta_{#gamma D}|>0.8 A0 #mu_{0}","PL"); leg4->AddEntry(gr_r_barrel_lxy_muonPair_1_1,"|#eta_{#gamma D}|<0.8 A0 #mu_{1}","PL"); leg4->AddEntry(gr_r_endcap_lxy_muonPair_1_1,"|#eta_{#gamma D}|>0.8 A0 #mu_{1}","PL"); leg4->Draw("same"); c->SaveAs(fname+"_eff_eta_lxy_1D_A0.pdf","recreate"); c->Clear(); }