static void test_inserts(int level) { static bool first = TRUE; int ch; int limit; int row = 1; int col; int row2, col2; int length; wchar_t buffer[BUFSIZ]; WINDOW *look = 0; WINDOW *work = 0; WINDOW *show = 0; int margin = (2 * MY_TABSIZE) - 1; Options option = ((m_opt ? oMove : oDefault) | ((w_opt || (level > 0)) ? oWindow : oDefault)); if (first) { static char cmd[80]; setlocale(LC_ALL, ""); putenv(strcpy(cmd, "TABSIZE=8")); initscr(); (void) cbreak(); /* take input chars one at a time, no wait for \n */ (void) noecho(); /* don't echo input */ keypad(stdscr, TRUE); } limit = LINES - 5; if (level > 0) { look = newwin(limit, COLS - (2 * (level - 1)), 0, level - 1); work = newwin(limit - 2, COLS - (2 * level), 1, level); show = newwin(4, COLS, limit + 1, 0); box(look, 0, 0); wnoutrefresh(look); limit -= 2; } else { work = stdscr; show = derwin(stdscr, 4, COLS, limit + 1, 0); } keypad(work, TRUE); for (col = margin + 1; col < COLS; col += MY_TABSIZE) MvWVLine(work, row, col, '.', limit - 2); MvWVLine(work, row, margin, ACS_VLINE, limit - 2); MvWVLine(work, row, margin + 1, ACS_VLINE, limit - 2); limit /= 2; MvWAddStr(work, 1, 2, "String"); MvWAddStr(work, limit + 1, 2, "Chars"); wnoutrefresh(work); buffer[length = 0] = '\0'; legend(show, level, option, buffer, length); wnoutrefresh(show); doupdate(); /* * Show the characters inserted in color, to distinguish from those that * are shifted. */ if (has_colors()) { start_color(); init_pair(1, COLOR_WHITE, COLOR_BLUE); wbkgdset(work, COLOR_PAIR(1) | ' '); } while ((ch = read_linedata(work)) != ERR && !isQUIT(ch)) { wmove(work, row, margin + 1); switch (ch) { case key_RECUR: test_inserts(level + 1); touchwin(look); touchwin(work); touchwin(show); wnoutrefresh(look); wnoutrefresh(work); wnoutrefresh(show); doupdate(); break; case key_NEWLINE: if (row < limit) { ++row; /* put the whole string in, all at once */ col2 = margin + 1; switch (option) { case oDefault: if (n_opt > 1) { for (col = 0; col < length; col += n_opt) { col2 = ColOf(buffer, col, margin); if (move(row, col2) != ERR) { InsNStr(buffer + col, LEN(col)); } } } else { if (move(row, col2) != ERR) { InsStr(buffer); } } break; case oMove: if (n_opt > 1) { for (col = 0; col < length; col += n_opt) { col2 = ColOf(buffer, col, margin); MvInsNStr(row, col2, buffer + col, LEN(col)); } } else { MvInsStr(row, col2, buffer); } break; case oWindow: if (n_opt > 1) { for (col = 0; col < length; col += n_opt) { col2 = ColOf(buffer, col, margin); if (wmove(work, row, col2) != ERR) { WInsNStr(work, buffer + col, LEN(col)); } } } else { if (wmove(work, row, col2) != ERR) { WInsStr(work, buffer); } } break; case oMoveWindow: if (n_opt > 1) { for (col = 0; col < length; col += n_opt) { col2 = ColOf(buffer, col, margin); MvWInsNStr(work, row, col2, buffer + col, LEN(col)); } } else { MvWInsStr(work, row, col2, buffer); } break; } /* do the corresponding single-character insertion */ row2 = limit + row; for (col = 0; col < length; ++col) { col2 = ColOf(buffer, col, margin); switch (option) { case oDefault: if (move(row2, col2) != ERR) { InsCh((chtype) buffer[col]); } break; case oMove: MvInsCh(row2, col2, (chtype) buffer[col]); break; case oWindow: if (wmove(work, row2, col2) != ERR) { WInsCh(work, (chtype) buffer[col]); } break; case oMoveWindow: MvWInsCh(work, row2, col2, (chtype) buffer[col]); break; } } } else { beep(); } break; default: buffer[length++] = ch; buffer[length] = '\0'; /* put the string in, one character at a time */ col = ColOf(buffer, length - 1, margin); switch (option) { case oDefault: if (move(row, col) != ERR) { InsStr(buffer + length - 1); } break; case oMove: MvInsStr(row, col, buffer + length - 1); break; case oWindow: if (wmove(work, row, col) != ERR) { WInsStr(work, buffer + length - 1); } break; case oMoveWindow: MvWInsStr(work, row, col, buffer + length - 1); break; } /* do the corresponding single-character insertion */ switch (option) { case oDefault: if (move(limit + row, col) != ERR) { InsCh((chtype) ch); } break; case oMove: MvInsCh(limit + row, col, (chtype) ch); break; case oWindow: if (wmove(work, limit + row, col) != ERR) { WInsCh(work, (chtype) ch); } break; case oMoveWindow: MvWInsCh(work, limit + row, col, (chtype) ch); break; } wnoutrefresh(work); legend(show, level, option, buffer, length); wnoutrefresh(show); doupdate(); break; } } if (level > 0) { delwin(show); delwin(work); delwin(look); } }
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const { if ( !legend() || legend()->isEmpty() ) return; QLayout *l = legend()->contentsWidget()->layout(); if ( l == 0 || !l->inherits("QwtDynGridLayout") ) return; QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l; uint numCols = legendLayout->columnsForWidth(rect.width()); #if QT_VERSION < 0x040000 QValueList<QRect> itemRects = legendLayout->layoutItems(rect, numCols); #else QList<QRect> itemRects = legendLayout->layoutItems(rect, numCols); #endif int index = 0; #if QT_VERSION < 0x040000 QLayoutIterator layoutIterator = legendLayout->iterator(); for ( QLayoutItem *item = layoutIterator.current(); item != 0; item = ++layoutIterator) { #else for ( int i = 0; i < legendLayout->count(); i++ ) { QLayoutItem *item = legendLayout->itemAt(i); #endif QWidget *w = item->widget(); if ( w ) { painter->save(); painter->setClipping(true); QwtPainter::setClipRect(painter, itemRects[index]); printLegendItem(painter, w, itemRects[index]); index++; painter->restore(); } } } /*! Print the legend item into a given rectangle. \param painter Painter \param w Widget representing a legend item \param rect Bounding rectangle */ void QwtPlot::printLegendItem(QPainter *painter, const QWidget *w, const QRect &rect) const { if ( w->inherits("QwtLegendItem") ) { QwtLegendItem *item = (QwtLegendItem *)w; painter->setFont(item->font()); item->drawItem(painter, rect); } } /*! \brief Paint a scale into a given rectangle. Paint the scale into a given rectangle. \param painter Painter \param axisId Axis \param startDist Start border distance \param endDist End border distance \param baseDist Base distance \param rect Bounding rectangle */ void QwtPlot::printScale(QPainter *painter, int axisId, int startDist, int endDist, int baseDist, const QRect &rect) const { if (!axisEnabled(axisId)) return; const QwtScaleWidget *scaleWidget = axisWidget(axisId); if ( scaleWidget->isColorBarEnabled() && scaleWidget->colorBarWidth() > 0) { const QwtMetricsMap map = QwtPainter::metricsMap(); QRect r = map.layoutToScreen(rect); r.setWidth(r.width() - 1); r.setHeight(r.height() - 1); scaleWidget->drawColorBar(painter, scaleWidget->colorBarRect(r)); const int off = scaleWidget->colorBarWidth() + scaleWidget->spacing(); if ( scaleWidget->scaleDraw()->orientation() == Qt::Horizontal ) baseDist += map.screenToLayoutY(off); else baseDist += map.screenToLayoutX(off); } QwtScaleDraw::Alignment align; int x, y, w; switch(axisId) { case yLeft: { x = rect.right() - baseDist; y = rect.y() + startDist; w = rect.height() - startDist - endDist; align = QwtScaleDraw::LeftScale; break; } case yRight: { x = rect.left() + baseDist; y = rect.y() + startDist; w = rect.height() - startDist - endDist; align = QwtScaleDraw::RightScale; break; } case xTop: { x = rect.left() + startDist; y = rect.bottom() - baseDist; w = rect.width() - startDist - endDist; align = QwtScaleDraw::TopScale; break; } case xBottom: { x = rect.left() + startDist; y = rect.top() + baseDist; w = rect.width() - startDist - endDist; align = QwtScaleDraw::BottomScale; break; } default: return; } scaleWidget->drawTitle(painter, align, rect); painter->save(); painter->setFont(scaleWidget->font()); QPen pen = painter->pen(); pen.setWidth(scaleWidget->penWidth()); painter->setPen(pen); QwtScaleDraw *sd = (QwtScaleDraw *)scaleWidget->scaleDraw(); const QPoint sdPos = sd->pos(); const int sdLength = sd->length(); sd->move(x, y); sd->setLength(w); #if QT_VERSION < 0x040000 sd->draw(painter, scaleWidget->palette().active()); #else QPalette palette = scaleWidget->palette(); palette.setCurrentColorGroup(QPalette::Active); sd->draw(painter, palette); #endif // reset previous values sd->move(sdPos); sd->setLength(sdLength); painter->restore(); } /*! Print the canvas into a given rectangle. \param painter Painter \param map Maps mapping between plot and paint device coordinates \param boundingRect Bounding rectangle \param canvasRect Canvas rectangle \param pfilter Print filter \sa QwtPlotPrintFilter */ void QwtPlot::printCanvas(QPainter *painter, const QRect &boundingRect, const QRect &canvasRect, const QwtScaleMap map[axisCnt], const QwtPlotPrintFilter &pfilter) const { if ( pfilter.options() & QwtPlotPrintFilter::PrintBackground ) { QBrush bgBrush; #if QT_VERSION >= 0x040000 bgBrush = canvas()->palette().brush(backgroundRole()); #else QColorGroup::ColorRole role = QPalette::backgroundRoleFromMode( backgroundMode() ); bgBrush = canvas()->colorGroup().brush( role ); #endif QRect r = boundingRect; if ( !(pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales) ) { r = canvasRect; #if QT_VERSION >= 0x040000 // Unfortunately the paint engines do no always the same const QPaintEngine *pe = painter->paintEngine(); if ( pe ) { switch(painter->paintEngine()->type() ) { case QPaintEngine::Raster: case QPaintEngine::X11: break; default: r.setWidth(r.width() - 1); r.setHeight(r.height() - 1); break; } } #else if ( painter->device()->isExtDev() ) { r.setWidth(r.width() - 1); r.setHeight(r.height() - 1); } #endif } QwtPainter::fillRect(painter, r, bgBrush); } if ( pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales ) { painter->save(); painter->setPen(QPen(Qt::black)); painter->setBrush(QBrush(Qt::NoBrush)); QwtPainter::drawRect(painter, boundingRect); painter->restore(); } painter->setClipping(true); QwtPainter::setClipRect(painter, canvasRect); drawItems(painter, canvasRect, map, pfilter); }
void QgsLegendLayer::addToPopupMenu( QMenu& theMenu ) { QgsMapLayer *lyr = layer(); QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing(); QAction *saveLayerEditsAction = QgisApp::instance()->actionSaveActiveLayerEdits(); QAction *allEditsAction = QgisApp::instance()->actionAllEdits(); // zoom to layer extent theMenu.addAction( QgsApplication::getThemeIcon( "/mActionZoomToLayer.png" ), tr( "&Zoom to Layer Extent" ), legend(), SLOT( legendLayerZoom() ) ); if ( lyr->type() == QgsMapLayer::RasterLayer ) { theMenu.addAction( tr( "&Zoom to Best Scale (100%)" ), legend(), SLOT( legendLayerZoomNative() ) ); QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( lyr ); if ( rasterLayer && rasterLayer->rasterType() != QgsRasterLayer::Palette ) { theMenu.addAction( tr( "&Stretch Using Current Extent" ), legend(), SLOT( legendLayerStretchUsingCurrentExtent() ) ); } } // show in overview QAction* showInOverviewAction = theMenu.addAction( tr( "&Show in Overview" ), this, SLOT( showInOverview() ) ); showInOverviewAction->setCheckable( true ); showInOverviewAction->blockSignals( true ); showInOverviewAction->setChecked( mLyr.isInOverview() ); showInOverviewAction->blockSignals( false ); // remove from canvas theMenu.addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.png" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) ); // duplicate layer QAction* duplicateLayersAction = theMenu.addAction( QgsApplication::getThemeIcon( "/mActionAddMap.png" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) ); // set layer crs theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) ); // assign layer crs to project theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) ); theMenu.addSeparator(); if ( lyr->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( lyr ); // attribute table theMenu.addAction( QgsApplication::getThemeIcon( "/mActionOpenTable.png" ), tr( "&Open Attribute Table" ), QgisApp::instance(), SLOT( attributeTable() ) ); // allow editing int cap = vlayer->dataProvider()->capabilities(); if ( cap & QgsVectorDataProvider::EditingCapabilities ) { if ( toggleEditingAction ) { theMenu.addAction( toggleEditingAction ); toggleEditingAction->setChecked( vlayer->isEditable() ); } if ( saveLayerEditsAction && vlayer->isModified() ) { theMenu.addAction( saveLayerEditsAction ); } } if ( allEditsAction->isEnabled() ) { theMenu.addAction( allEditsAction ); } // disable duplication of memory layers if ( vlayer->storageType() == "Memory storage" && legend()->selectedLayers().count() == 1 ) { duplicateLayersAction->setEnabled( false ); } // save as vector file theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) ); // save selection as vector file QAction* saveSelectionAsAction = theMenu.addAction( tr( "Save Selection As..." ), QgisApp::instance(), SLOT( saveSelectionAsVectorFile() ) ); if ( vlayer->selectedFeatureCount() == 0 ) { saveSelectionAsAction->setEnabled( false ); } if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() && vlayer->vectorJoins().isEmpty() ) theMenu.addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) ); //show number of features in legend if requested QAction* showNFeaturesAction = new QAction( tr( "Show Feature Count" ), &theMenu ); showNFeaturesAction->setCheckable( true ); showNFeaturesAction->setChecked( mShowFeatureCount ); QObject::connect( showNFeaturesAction, SIGNAL( toggled( bool ) ), this, SLOT( setShowFeatureCount( bool ) ) ); theMenu.addAction( showNFeaturesAction ); theMenu.addSeparator(); }
// Action_NativeContacts::WriteContacts() void Action_NativeContacts::WriteContacts(contactListType& ContactsIn, bool isNative) { if (ContactsIn.empty()) return; // Map of residue pairs to total contact values. typedef std::map<Cpair, resContact> resContactMap; resContactMap ResContacts; std::pair<resContactMap::iterator, bool> ret; // Normalize native contacts. Place them into an array where they will // be sorted. Sum up total contact over residue pairs. std::vector<contactType> sortedList; for (contactListType::iterator it = ContactsIn.begin(); it != ContactsIn.end(); ++it) { it->second.Finalize(); sortedList.push_back( it->second ); ret = ResContacts.insert( Rpair(Cpair(it->second.Res1(),it->second.Res2()), resContact(it->second.Nframes(), it->second.DataPtr())) ); if (!ret.second) // residue pair exists, update it. ret.first->second.Increment( it->second.Nframes(), it->second.DataPtr() ); } std::sort( sortedList.begin(), sortedList.end() ); // Place residue pairs into an array to be sorted. std::vector<Rpair> ResList; for (resContactMap::const_iterator it = ResContacts.begin(); it != ResContacts.end(); ++it) { ResList.push_back( *it ); if (Rseries_ != NO_RESSERIES) { const char* resDsAspect; std::string lprefix = ""; if (isNative) resDsAspect = "NCRES"; else { resDsAspect = "NNRES"; lprefix = "nn_"; } // Ensure r1 < r2 so we can calculate a unique index for residue pairs // that can match between native/non-native contacts int r1, r2; if (it->first.second < it->first.first) { r1 = it->first.second; r2 = it->first.first; } else { r1 = it->first.first; r2 = it->first.second; } int ridx = (r2 * CurrentParm_->Nres()) + r1; std::string legend(lprefix + CurrentParm_->TruncResNameNum(r1) + "_" + CurrentParm_->TruncResNameNum(r2)); MetaData md(numnative_->Meta().Name(), resDsAspect, ridx); md.SetLegend( legend ); DataSet_integer* ds = (DataSet_integer*)masterDSL_->AddSet(DataSet::INTEGER, md); if (ds != 0) { ds->Allocate(DataSet::SizeArray(1, nframes_)); if (seriesRout_ != 0) seriesRout_->AddDataSet( ds ); // All series will be the same size thanks to UpdateSeries() for (unsigned int f = 0; f != nframes_; f++) { int total_present = 0; for (DSarray::const_iterator set = it->second.Sets().begin(); set != it->second.Sets().end(); ++set) total_present += (*(*set))[f]; if (Rseries_ == RES_PRESENT && total_present > 0) total_present = 1; ds->AddElement( total_present ); } } } } std::sort( ResList.begin(), ResList.end(), res_cmp() ); // Print out total fraction frames for residue pairs. const char* ctitle; if (isNative) ctitle = "Contacts"; else ctitle = "nnContacts"; rfile_->Printf("%-8s %8s %10s %10s\n", "#Res1", "#Res2", "TotalFrac", ctitle); //for (resContactMap::const_iterator it = ResContacts.begin(); it != ResContacts.end(); ++it) for (std::vector<Rpair>::const_iterator it = ResList.begin(); it != ResList.end(); ++it) rfile_->Printf("%-8i %8i %10g %10i\n", it->first.first+1, it->first.second+1, (double)it->second.Nframes()/(double)nframes_, it->second.Ncontacts()); // Print out sorted atom contacts. cfile_->Printf("%-8s %20s %8s %8s %8s %8s\n", "#", "Contact", "Nframes", "Frac.", "Avg", "Stdev"); unsigned int num = 1; for (std::vector<contactType>::const_iterator NC = sortedList.begin(); NC != sortedList.end(); ++NC, ++num) { double fracPresent = (double)NC->Nframes() / (double)nframes_; cfile_->Printf("%8u %20s %8i %8.3g %8.3g %8.3g\n", num, NC->id(), NC->Nframes(), fracPresent, NC->Avg(), NC->Stdev()); } }
void make_weights(TString tag="sel", TString var="_qt", Bool_t asym=true) { TString ifile="plotter_2015_11_12.root"; TString dydir, dydir2; // DY+jets dydir="Ztoll_M-50"; dydir2="Ztoll_M-10to50"; TString gdir, gdir2, gdir3, gdir4, gdir5; // G+jets gdir="GJets_HT-40to100"; gdir2="GJets_HT-100to200"; gdir3="GJets_HT-200to400"; gdir4="GJets_HT-400to600"; gdir5="GJets_HT-600toInf"; Bool_t bfit=false; double xmin,xmax; double ymin, ymax; ymin=0.5; ymax=1000000.; if (var=="_qt") { // bfit=true; xmin=45.01; xmax=1000.01; } else if ( (var=="_met") || var=="_mt") { xmin=1.; xmax=1000.0; } setTDRStyle(); // TString cat1,cat2,hcat[2]; // cat1="eq0jets"; hcat[1]="geq1jets"; hcat[2]="vbf"; TString hcat[3]={"eq0jets","geq1jets","vbf"}; TString cat="ee"; Int_t rbin=5; TH1F *h_zpt_ee_1=readHist(cat+hcat[0]+var,ifile,dydir,rbin); //h_zpt_ee->Scale(dyweight); TH1F *h_zpt_ee_2=readHist(cat+hcat[1]+var,ifile,dydir,rbin); TH1F *h_zpt_ee_3=readHist(cat+hcat[2]+var,ifile,dydir,rbin); h_zpt_ee_1->SetFillColor(0); h_zpt_ee_2->SetFillColor(0); h_zpt_ee_3->SetFillColor(0); // Adddy2 // TH1F *h2_zpt_ee_1=readHist(cat+hcat[0]+var,ifile,dydir2,rbin); //h_zpt_ee->Scale(dyweight); // TH1F *h2_zpt_ee_2=readHist(cat+hcat[1]+var,ifile,dydir2,rbin); // TH1F *h2_zpt_ee_3=readHist(cat+hcat[2]+var,ifile,dydir2,rbin); // h_zpt_ee_1->Add(h2_zpt_ee_1); // h_zpt_ee_2->Add(h2_zpt_ee_2); // h_zpt_ee_3->Add(h2_zpt_ee_3); TCanvas *c=getanotherCanvas("c"); c->Divide(3,1); c->cd(1); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[0]); h_zpt_ee_1->Draw("EHIST"); if (bfit) h_zpt_ee_1->Fit("pol2","FR+","EHISTSAME",60.,500.); h_zpt_ee_1->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_ee_1->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); c->cd(2); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[1]); h_zpt_ee_2->Draw("EHIST"); if (bfit) h_zpt_ee_2->Fit("pol2","FR+","EHIST",60.,500.); h_zpt_ee_2->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_ee_2->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); c->cd(3); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[2]); h_zpt_ee_3->Draw("EHIST"); if (bfit) h_zpt_ee_3->Fit("pol2","FR+","",60.,500.); h_zpt_ee_3->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_ee_3->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); // DIMUONS cat="mumu"; TH1F *h_zpt_mm_1=readHist(cat+hcat[0]+var,ifile,dydir,rbin);//h_zpt_mm->Scale(dyweight); TH1F *h_zpt_mm_2=readHist(cat+hcat[1]+var,ifile,dydir,rbin);//h_zpt_mm_2->Scale(dyweight); TH1F *h_zpt_mm_3=readHist(cat+hcat[2]+var,ifile,dydir,rbin);//h_zpt_mm_3->Scale(dyweight); h_zpt_mm_1->SetFillColor(0); h_zpt_mm_2->SetFillColor(0); h_zpt_mm_3->SetFillColor(0); // Adddy2 // TH1F *h2_zpt_mm_1=readHist(cat+hcat[0]+var,ifile,dydir2,rbin); //h_zpt_mm->Scale(dyweight); // TH1F *h2_zpt_mm_2=readHist(cat+hcat[1]+var,ifile,dydir2,rbin); // TH1F *h2_zpt_mm_3=readHist(cat+hcat[2]+var,ifile,dydir2,rbin); // h_zpt_mm_1->Add(h2_zpt_mm_1); // h_zpt_mm_2->Add(h2_zpt_mm_2); // h_zpt_mm_3->Add(h2_zpt_mm_3); TCanvas *cm=getanotherCanvas("cm"); cm->Divide(3,1); cm->cd(1); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[0]); h_zpt_mm_1->Draw("EHIST"); h_zpt_mm_1->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_mm_1->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cm->cd(2); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[1]); h_zpt_mm_2->Draw("EHIST"); h_zpt_mm_2->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_mm_2->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cm->cd(3); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[2]); h_zpt_mm_3->Draw("EHIST"); h_zpt_mm_3->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_mm_3->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); // Photon+jet weight //double gweight= ((224012.*20.*1000.)/12365798.); cat="ee"; // var="_phopt"; // Photon + Jet // std::cout << "=0jets: " << cat+hcat[0]+var << std::endl; // std::cout << ">=2: " << cat+hcat[1]+var << std::endl; // std::cout << "VBF: " << cat+hcat[2]+var << std::endl; TH1F *h_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir,rbin);// h_zpt_gj->Scale(gweight);//h_zpt_gj->Sumw2(); TH1F *h_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir,rbin); //h_zpt_gj_2->Scale(gweight);//h_zpt_gj_2->Sumw2(); TH1F *h_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir,rbin);// h_zpt_gj_3->Scale(gweight);//h_zpt_gj_3->Sumw2(); h_zpt_gj_1->SetFillColor(0); h_zpt_gj_2->SetFillColor(0); h_zpt_gj_3->SetFillColor(0); TH1F *h2_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir2,rbin); TH1F *h2_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir2,rbin); TH1F *h2_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir2,rbin); h2_zpt_gj_1->SetFillColor(0); h2_zpt_gj_2->SetFillColor(0); h2_zpt_gj_3->SetFillColor(0); TH1F *h3_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir3,rbin); TH1F *h3_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir3,rbin); TH1F *h3_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir3,rbin); h3_zpt_gj_1->SetFillColor(0); h3_zpt_gj_2->SetFillColor(0); h3_zpt_gj_3->SetFillColor(0); TH1F *h4_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir4,rbin); TH1F *h4_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir4,rbin); TH1F *h4_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir4,rbin); h4_zpt_gj_1->SetFillColor(0); h4_zpt_gj_2->SetFillColor(0); h4_zpt_gj_3->SetFillColor(0); TH1F *h5_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir5,rbin); TH1F *h5_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir5,rbin); TH1F *h5_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir5,rbin); h5_zpt_gj_1->SetFillColor(0); h5_zpt_gj_2->SetFillColor(0); h5_zpt_gj_3->SetFillColor(0); h_zpt_gj_1->Add(h2_zpt_gj_1); h_zpt_gj_1->Add(h3_zpt_gj_1); h_zpt_gj_1->Add(h4_zpt_gj_1); h_zpt_gj_1->Add(h5_zpt_gj_1); h_zpt_gj_2->Add(h2_zpt_gj_2); h_zpt_gj_2->Add(h3_zpt_gj_2); h_zpt_gj_2->Add(h4_zpt_gj_2); h_zpt_gj_2->Add(h5_zpt_gj_2); h_zpt_gj_3->Add(h2_zpt_gj_3); h_zpt_gj_3->Add(h3_zpt_gj_3); h_zpt_gj_3->Add(h4_zpt_gj_3); h_zpt_gj_3->Add(h5_zpt_gj_3); cat="g+jet"; TCanvas *cg=getanotherCanvas("cg"); cg->Divide(3,1); cg->cd(1); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[0]); // fermiFunction->SetParameters(params); h_zpt_gj_1->Draw("EHIST"); h_zpt_gj_1->GetXaxis()->SetRangeUser(xmin,xmax); //h_zpt_gj->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cg->cd(2); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[1]); //fermiFunction->SetParameters(params); h_zpt_gj_2->Draw("EHIST"); h_zpt_gj_2->GetXaxis()->SetRangeUser(xmin,xmax); //h_zpt_gj_2->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cg->cd(3); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[2]); // fermiFunction->SetParameters(params); h_zpt_gj_3->Draw("EHIST"); h_zpt_gj_3->GetXaxis()->SetRangeUser(xmin,xmax); //h_zpt_gj_3->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); // Superimpose all rbin=1; Double_t xbins[27] = {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80, 90, 100, 125, 150, 175, 200, 250, 300, 400, 500, 1000,1500}; // hee1->Rebin(26,"nhee1",xbins); hee2->Rebin(26,"nhee2",xbins); hee3->Rebin(26,"nhee3",xbins); // hmm1->Rebin(26,"nhmm1",xbins); hmm2->Rebin(26,"nhmm2",xbins); hmm3->Rebin(26,"nhmm3",xbins); TCanvas *call=getanotherCanvas("call"); call->Divide(3,1); // TH1F *h_ee1=h_zpt_ee_1->Clone(); h_ee1->Rebin(rbin); // TH1F *h_mm1=h_zpt_mm_1->Clone(); h_mm1->Rebin(rbin); // TH1F *h_gj1=h_zpt_gj_1->Clone(); h_gj1->Rebin(rbin); if (asym) { h_zpt_ee_1->Rebin(26,"h_ee1",xbins); h_zpt_mm_1->Rebin(26,"h_mm1",xbins); h_zpt_gj_1->Rebin(26,"h_gj1",xbins); } else { TH1F *h_ee1=h_zpt_ee_1->Clone(); h_ee1->Rebin(rbin); TH1F *h_mm1=h_zpt_mm_1->Clone(); h_mm1->Rebin(rbin); TH1F *h_gj1=h_zpt_gj_1->Clone(); h_gj1->Rebin(rbin); } // h_ee1->Scale(1./h_ee1->Integral()); // h_mm1->Scale(1./h_mm1->Integral()); // h_gj1->Scale(1./h_gj1->Integral()); if (asym) { h_zpt_ee_2->Rebin(26,"h_ee2",xbins); h_zpt_mm_2->Rebin(26,"h_mm2",xbins); h_zpt_gj_2->Rebin(26,"h_gj2",xbins); } else { TH1F *h_ee2=h_zpt_ee_2->Clone(); h_ee2->Rebin(rbin); TH1F *h_mm2=h_zpt_mm_2->Clone(); h_mm2->Rebin(rbin); TH1F *h_gj2=h_zpt_gj_2->Clone(); h_gj2->Rebin(rbin); } // h_ee2->Scale(1./h_ee2->Integral()); // h_mm2->Scale(1./h_mm2->Integral()); // h_gj2->Scale(1./h_gj2->Integral()); if (asym) { h_zpt_ee_3->Rebin(26,"h_ee3",xbins); h_zpt_mm_3->Rebin(26,"h_mm3",xbins); h_zpt_gj_3->Rebin(26,"h_gj3",xbins); } else { TH1F *h_ee3=h_zpt_ee_3->Clone(); h_ee3->Rebin(rbin); TH1F *h_mm3=h_zpt_mm_3->Clone(); h_mm3->Rebin(rbin); TH1F *h_gj3=h_zpt_gj_3->Clone(); h_gj3->Rebin(rbin); } // h_ee3->Scale(1./h_ee3->Integral()); // h_mm3->Scale(1./h_mm3->Integral()); // h_gj3->Scale(1./h_gj3->Integral()); call->cd(1); gPad->SetLogy(); TLegend *leg=legend(); leg->SetHeader("=0 jets"); leg->AddEntry(h_ee1,"ee","LP"); leg->AddEntry(h_mm1,"#mu#mu","LP"); leg->AddEntry(h_gj1,"#gamma+jet","LP"); h_ee1->Draw("ehist"); h_ee1->GetXaxis()->SetRangeUser(xmin,xmax); h_ee1->SetLineColor(kBlue); h_ee1->SetMarkerColor(kBlue); h_ee1->SetLineWidth(2); h_ee1->SetMarkerStyle(20); h_ee1->SetMarkerSize(0.3); h_mm1->Draw("ehistsame"); h_mm1->SetLineColor(kBlue-6); h_mm1->SetMarkerColor(kBlue-6); h_mm1->SetLineWidth(2); h_mm1->SetMarkerStyle(22); h_mm1->SetMarkerSize(0.3); h_gj1->Draw("ehistsame"); h_gj1->SetLineColor(kRed+1); h_gj1->SetMarkerColor(kRed+1); h_gj1->SetLineWidth(2); h_gj1->SetMarkerStyle(29); h_gj1->SetMarkerSize(0.3); leg->Draw("SAME"); call->cd(2); gPad->SetLogy(); TLegend *leg=legend(); leg->SetHeader(">= 1jets"); leg->AddEntry(h_ee2,"ee","LP"); leg->AddEntry(h_mm2,"#mu#mu","LP"); leg->AddEntry(h_gj2,"#gamma+jet","LP"); h_ee2->Draw("ehist"); h_ee2->GetXaxis()->SetRangeUser(xmin,xmax); h_ee2->SetLineColor(kBlue); h_ee2->SetMarkerColor(kBlue); h_ee2->SetLineWidth(2); h_ee2->SetMarkerStyle(20); h_ee2->SetMarkerSize(0.3); h_mm2->Draw("ehistsame"); h_mm2->SetLineColor(kBlue-6); h_mm2->SetMarkerColor(kBlue-6); h_mm2->SetLineWidth(2); h_mm2->SetMarkerStyle(22); h_mm2->SetMarkerSize(0.3); h_gj2->Draw("ehistsame"); h_gj2->SetLineColor(kRed+1); h_gj2->SetMarkerColor(kRed+1); h_gj2->SetLineWidth(2); h_gj2->SetMarkerStyle(29); h_gj2->SetMarkerSize(0.3); leg->Draw("SAME"); call->cd(3); gPad->SetLogy(); TLegend *leg=legend(); leg->SetHeader("VBF"); leg->AddEntry(h_ee3,"ee","LP"); leg->AddEntry(h_mm3,"#mu#mu","LP"); leg->AddEntry(h_gj3,"#gamma+jet","LP"); h_ee3->Draw("ehist"); h_ee3->GetXaxis()->SetRangeUser(xmin,10000000.); h_ee3->SetLineColor(kBlue); h_ee3->SetMarkerColor(kBlue); h_ee3->SetLineWidth(2); h_ee3->SetMarkerStyle(20); h_ee3->SetMarkerSize(0.3); h_mm3->Draw("ehistsame"); h_mm3->SetLineColor(kBlue-6); h_mm3->SetMarkerColor(kBlue-6); h_mm3->SetLineWidth(2); h_mm3->SetMarkerStyle(22); h_mm3->SetMarkerSize(0.3); h_gj3->Draw("ehistsame"); h_gj3->SetLineColor(kRed+1); h_gj3->SetMarkerColor(kRed+1); h_gj3->SetLineWidth(2); h_gj3->SetMarkerStyle(29); h_gj3->SetMarkerSize(0.3); leg->Draw("SAME"); // return; // REDRAW in one CANVAS TCanvas *call1 = new TCanvas("call1"); call1->SetWindowSize(500,600); call1->cd(); //distributions TPad *t1 = new TPad("p1","p1",0,0.3,1.0,1.0); t1->Draw(); t1->cd(); t1->SetLogy(); t1->SetLogx(); t1->SetTopMargin(0.08); t1->SetBottomMargin(0); t1->SetRightMargin(0.05); h_ee1->SetTitle("ee"); h_ee1->GetYaxis()->SetLabelSize(0.06); h_ee1->GetYaxis()->SetTitleSize(0.05); h_ee1->GetYaxis()->SetTitleOffset(0.9); h_ee1->GetYaxis()->SetLabelSize(0.05); h_ee1->GetXaxis()->SetRangeUser(25.01,1000.01); h_ee1->GetYaxis()->SetTitle("Events / 100 pb^{-1}"); // h_ee1->SetLineColor(1); // h_ee1->SetMarkerColor(1); // h_ee1->SetMarkerStyle(1); // h_ee1->SetFillStyle(3001); // h_ee1->SetFillColor(5); h_ee1->Draw("ehistsame"); h_mm1->SetTitle("#mu#mu"); h_mm1->Draw("ehistsame"); // h_mm1->SetMarkerColor(9); // h_mm1->SetMarkerStyle(20); // h_mm1->SetMarkerSize(0.8); h_gj1->SetTitle("#gamma + jets"); h_gj1->Draw("ehistsame"); // h_gj1->SetFillColor(kRed+1); h_gj1->SetFillStyle(3001); TPaveText *pave = new TPaveText(0.7,0.85,0.95,0.9,"brNDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->SetTextSize(0.05); pave->SetTextColor(kBlue); pave->AddText("=0 jets"); pave->Draw(); TLegend *leg=new TLegend(0.6,0.6,0.9,0.8); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextAlign(12); leg->SetTextSize(0.05); leg->SetNColumns(2); leg->AddEntry(h_ee1,"ee","L"); leg->AddEntry(h_mm1,"#mu#mu","L"); leg->AddEntry(h_gj1,"#gamma+jets","L"); leg->Draw("same"); //closure call1->cd(); TPad *t2 = new TPad("p2","p2",0,0.0,1.0,0.3); t2->SetTopMargin(0); t2->SetBottomMargin(0.25); t2->SetRightMargin(0.05); t2->Draw(); t2->cd(); t2->SetLogx(); t2->SetGridx(); t2->SetGridy(); leg = new TLegend(0.6,0.6,0.9,0.8,"","brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(3001); leg->SetFillColor(0); leg->SetTextFont(42); leg->SetTextSize(0.11); leg->SetTextAlign(12); TH1D *hee1=h_ee1->Clone(); hee1->Divide(h_gj1); TH1D *hmm1=h_mm1->Clone(); hmm1->Divide(h_gj1); hee1->Draw("e"); hee1->SetLineColor(kBlue); hee1->SetMarkerColor(kBlue);hee1->SetLineWidth(2); hmm1->Draw("esame"); hmm1->SetLineColor(kBlue-6); hmm1->SetMarkerColor(kBlue-6);hmm1->SetLineWidth(2); hee1->GetYaxis()->SetRangeUser(-0.1,0.5); // hee1->GetYaxis()->SetRangeUser(-0.2,1.74); hee1->GetXaxis()->SetTitle(hee1->GetXaxis()->GetTitle()); hee1->GetXaxis()->SetLabelSize(0.12); hee1->GetXaxis()->SetTitleSize(0.14); hee1->GetXaxis()->SetTitleOffset(0.8); hee1->GetYaxis()->SetLabelSize(0.12); hee1->GetYaxis()->SetNdivisions(5); hee1->GetYaxis()->SetTitleSize(0.12); //gr->GetYaxis()->SetTitle("Pred. rel. bias"); hee1->GetYaxis()->SetTitle("Weight"); hee1->GetYaxis()->SetTitleOffset(0.3); hee1->GetXaxis()->SetRangeUser(25.01,1000.01); leg->AddEntry(hee1,"ee","L"); leg->AddEntry(hmm1,"#mu#mu","L"); leg->Draw(); leg->SetNColumns(4); // 2 TCanvas *call2 = new TCanvas("call2"); call2->SetWindowSize(500,600); call2->cd(); //distributions TPad *t1 = new TPad("p1","p1",0,0.3,1.0,1.0); t1->Draw(); t1->cd(); t1->SetLogy(); t1->SetLogx(); t1->SetTopMargin(0.08); t1->SetBottomMargin(0); t1->SetRightMargin(0.05); h_ee2->SetTitle("ee"); h_ee2->GetYaxis()->SetLabelSize(0.06); h_ee2->GetYaxis()->SetTitleSize(0.05); h_ee2->GetYaxis()->SetTitleOffset(0.9); h_ee2->GetYaxis()->SetLabelSize(0.05); h_ee2->GetXaxis()->SetRangeUser(25.01,1000.01); h_ee2->GetYaxis()->SetTitle("Events / 100 pb^{-1}"); h_ee2->Draw("ehistsame"); h_mm2->SetTitle("#mu#mu"); h_mm2->Draw("ehistsame"); // h_mm2->SetMarkerColor(9); // h_mm2->SetMarkerStyle(20); // h_mm2->SetMarkerSize(0.8); h_gj2->SetTitle("#gamma + jets"); h_gj2->Draw("ehistsame"); TPaveText *pave = new TPaveText(0.7,0.85,0.95,0.9,"brNDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->SetTextSize(0.05); pave->SetTextColor(kBlue); pave->AddText(">=1 jet"); pave->Draw(); TLegend *leg=new TLegend(0.6,0.6,0.9,0.8); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextAlign(12); leg->SetTextSize(0.05); leg->SetNColumns(2); leg->AddEntry(h_ee2,"ee","L"); leg->AddEntry(h_mm2,"#mu#mu","L"); leg->AddEntry(h_gj1,"#gamma+jets","L"); leg->Draw("same"); //closure call2->cd(); TPad *t2 = new TPad("p2","p2",0,0.0,1.0,0.3); t2->SetTopMargin(0); t2->SetBottomMargin(0.25); t2->SetRightMargin(0.05); t2->Draw(); t2->cd(); t2->SetLogx(); t2->SetGridx(); t2->SetGridy(); leg = new TLegend(0.6,0.6,0.9,0.8,"","brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(3001); leg->SetFillColor(0); leg->SetTextFont(42); leg->SetTextSize(0.11); leg->SetTextAlign(12); TH1D *hee2=h_ee2->Clone(); hee2->Divide(h_gj2); TH1D *hmm2=h_mm2->Clone(); hmm2->Divide(h_gj2); hee2->Draw("e"); hee2->SetLineColor(kBlue); hee2->SetMarkerColor(kBlue);hee2->SetLineWidth(2); hmm2->Draw("esame"); hmm2->SetLineColor(kBlue-6); hmm2->SetMarkerColor(kBlue-6);hmm2->SetLineWidth(2); hee2->GetYaxis()->SetRangeUser(-0.2,0.2); // hee2->GetYaxis()->SetRangeUser(-0.2,1.74); hee2->GetXaxis()->SetTitle(hee2->GetXaxis()->GetTitle()); hee2->GetXaxis()->SetLabelSize(0.12); hee2->GetXaxis()->SetTitleSize(0.14); hee2->GetXaxis()->SetTitleOffset(0.8); hee2->GetYaxis()->SetLabelSize(0.12); hee2->GetYaxis()->SetNdivisions(5); hee2->GetYaxis()->SetTitleSize(0.12); //gr->GetYaxis()->SetTitle("Pred. rel. bias"); hee2->GetYaxis()->SetTitle("Weight"); hee2->GetYaxis()->SetTitleOffset(0.3); hee2->GetXaxis()->SetRangeUser(25.01,1000.01); leg->AddEntry(hee2,"ee","L"); leg->AddEntry(hmm2,"#mu#mu","L"); leg->Draw(); leg->SetNColumns(4); // 3 TCanvas *call3 = new TCanvas("call3"); call3->SetWindowSize(500,600); call3->cd(); //distributions TPad *t1 = new TPad("p1","p1",0,0.3,1.0,1.0); t1->Draw(); t1->cd(); t1->SetLogy(); t1->SetLogx(); t1->SetTopMargin(0.08); t1->SetBottomMargin(0); t1->SetRightMargin(0.05); h_ee3->SetTitle("ee"); h_ee3->GetYaxis()->SetLabelSize(0.06); h_ee3->GetYaxis()->SetTitleSize(0.05); h_ee3->GetYaxis()->SetTitleOffset(0.9); h_ee3->GetYaxis()->SetLabelSize(0.05); h_ee3->GetXaxis()->SetRangeUser(25.01,1000.01); h_ee3->GetYaxis()->SetTitle("Events / 100 pb^{-1}"); h_ee3->Draw("ehistsame"); h_mm3->SetTitle("#mu#mu"); h_mm3->Draw("ehistsame"); // h_mm3->SetMarkerColor(9); // h_mm3->SetMarkerStyle(20); // h_mm3->SetMarkerSize(0.8); h_gj3->SetTitle("#gamma + jets"); h_gj3->Draw("ehistsame"); TPaveText *pave = new TPaveText(0.7,0.85,0.95,0.9,"brNDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->SetTextSize(0.05); pave->SetTextColor(kBlue); pave->AddText("VBF"); pave->Draw(); TLegend *leg=new TLegend(0.6,0.6,0.9,0.8); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextAlign(12); leg->SetTextSize(0.05); leg->SetNColumns(2); leg->AddEntry(h_ee3,"ee","L"); leg->AddEntry(h_mm3,"#mu#mu","L"); leg->AddEntry(h_gj1,"#gamma+jets","L"); leg->Draw("same"); //closure call3->cd(); TPad *t2 = new TPad("p2","p2",0,0.0,1.0,0.3); t2->SetTopMargin(0); t2->SetBottomMargin(0.25); t2->SetRightMargin(0.05); t2->Draw(); t2->cd(); t2->SetLogx(); t2->SetGridx(); t2->SetGridy(); leg = new TLegend(0.6,0.6,0.9,0.8,"","brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(3001); leg->SetFillColor(0); leg->SetTextFont(42); leg->SetTextSize(0.11); leg->SetTextAlign(12); TH1D *hee3=h_ee3->Clone(); hee3->Divide(h_gj3); TH1D *hmm3=h_mm3->Clone(); hmm3->Divide(h_gj3); hee3->Draw("e"); hee3->SetLineColor(kBlue); hee3->SetMarkerColor(kBlue);hee3->SetLineWidth(2); hmm3->Draw("esame"); hmm3->SetLineColor(kBlue-6); hmm3->SetMarkerColor(kBlue-6);hmm3->SetLineWidth(2); hee3->GetYaxis()->SetRangeUser(-0.4,0.2); // hee3->GetYaxis()->SetRangeUser(-0.2,1.74); hee3->GetXaxis()->SetTitle(hee3->GetXaxis()->GetTitle()); hee3->GetXaxis()->SetLabelSize(0.12); hee3->GetXaxis()->SetTitleSize(0.14); hee3->GetXaxis()->SetTitleOffset(0.8); hee3->GetYaxis()->SetLabelSize(0.12); hee3->GetYaxis()->SetNdivisions(5); hee3->GetYaxis()->SetTitleSize(0.12); //gr->GetYaxis()->SetTitle("Pred. rel. bias"); hee3->GetYaxis()->SetTitle("Weight"); hee3->GetYaxis()->SetTitleOffset(0.3); hee3->GetXaxis()->SetRangeUser(25.01,1000.01); leg->AddEntry(hee3,"ee","L"); leg->AddEntry(hmm3,"#mu#mu","L"); leg->Draw(); leg->SetNColumns(4); // return; // printWeight(hee1); // printWeight(hee1); // return; // TH1F *n_hee1=hee1->Clone(); // gDirectory->ls(); return; // TFile *outfile=new TFile("photonWeights_Spring15_ght.root","recreate"); // TDirectory *dir=outfile->mkdir("photonWgt_graphs",""); dir->cd(); // Graphs TCanvas *gff=getanotherCanvas("gff"); gff->Divide(3,1); gff->cd(1); gPad->SetGridy(); gPad->SetGridx(); // GRaph1 TGraphErrors *gr_e1=new TGraphErrors(hee1); gr_e1->SetName("eeeq0jets_qt_datafitwgts"); TGraphErrors *gr_m1=new TGraphErrors(hmm1); gr_m1->SetName("mumueq0jets_qt_datafitwgts"); TLegend *leg=legend(); leg->SetHeader("0jet category"); leg->AddEntry(gr_e1,"ee","LP"); leg->AddEntry(gr_m1,"#mu#mu","LP"); gr_e1->Draw("AP"); gr_e1->SetMarkerSize(0.1); gr_e1->SetMarkerColor(4); gr_m1->Draw("P"); gr_m1->SetMarkerSize(0.1); gr_m1->SetMarkerColor(2); leg->Draw("SAME"); gff->cd(2); gPad->SetGridy(); gPad->SetGridx(); // GRaph1 TGraphErrors *gr_e2=new TGraphErrors(hee2);gr_e2->SetName("eegeq1jets_qt_datafitwgts"); TGraphErrors *gr_m2=new TGraphErrors(hmm2);gr_m2->SetName("mumugeq1jets_qt_datafitwgts"); TLegend *leg=legend(); leg->SetHeader(">=1jet category"); leg->AddEntry(gr_e2,"ee","LP"); leg->AddEntry(gr_m2,"#mu#mu","LP"); gr_e2->Draw("AP"); gr_e2->SetMarkerSize(0.2); gr_e2->SetMarkerColor(4); gr_m2->Draw("P"); gr_m2->SetMarkerSize(0.2); gr_m2->SetMarkerColor(2); leg->Draw("SAME"); gff->cd(3); gPad->SetGridy(); gPad->SetGridx(); // GRaph1 TGraphErrors *gr_e3=new TGraphErrors(hee3);gr_e3->SetName("eevbf_qt_datafitwgts"); TGraphErrors *gr_m3=new TGraphErrors(hmm3);gr_m3->SetName("mumuvbf_qt_datafitwgts"); TLegend *leg=legend(); leg->SetHeader("VBF category"); leg->AddEntry(gr_e3,"ee","LP"); leg->AddEntry(gr_m3,"#mu#mu","LP"); gr_e3->Draw("AP"); gr_e3->SetMarkerSize(0.2); gr_e3->SetMarkerColor(4); gr_m3->Draw("P"); gr_m3->SetMarkerSize(0.2); gr_m3->SetMarkerColor(2); leg->Draw("SAME"); TFile *outfile=new TFile("photonWeights_Spring15.root","recreate"); gr_e1->Write(); gr_m1->Write(); gr_e2->Write(); gr_m2->Write(); gr_e3->Write(); gr_m3->Write(); outfile->Write(); outfile->Close(); }
void openplt(long n0, long n1, int sq0off, int sq1off, char *xtitle, char *ytitle) { char *getenv(), *sptr; time_t tt; tt = time(NULL); if (strlen(lvstr)>0) { sscanf(lvstr,"%lg %lg %lg",&elinval[0],&elinval[1],&elinval[2]); } else if ((sptr=getenv("LINEVAL"))!=NULL && strlen(sptr)>0) { sscanf(sptr,"%lg %lg %lg",&elinval[0],&elinval[1],&elinval[2]); } printf("%%!PS-Adobe-2.0\n"); printf("%%%%Creator: plalign\n"); printf("%%%%CreationDate: %s",ctime(&tt)); printf("%%%%DocumentFonts: Courier\n"); printf("%%%%Pages: 1\n"); printf("%%%%BoundingBox: 18 18 564 588\n"); printf("%%%%EndComments\n"); printf("%%%%EndProlog\n"); printf("%%%%Page: 1 1\n"); printf("/Courier findfont 14 scalefont setfont\n"); printf("/vcprint { gsave 90 rotate dup stringwidth pop 2 div neg 0 rmoveto\n"); printf("show newpath stroke grestore } def\n"); printf("/hcprint { gsave dup stringwidth pop 2 div neg 0 rmoveto\n"); printf("show newpath stroke grestore } def\n"); printf("/hrprint { gsave dup stringwidth pop neg 0 rmoveto\n"); printf("show newpath stroke grestore } def\n"); printf("/hprint { gsave show newpath stroke grestore } def\n"); pmaxx = n0; pmaxy = n1; fxscal = (double)(max_x-1)/(double)(n1); fyscal = (double)(max_y-1)/(double)(n0); if (fxscal > fyscal) fxscal = fyscal; else fyscal = fxscal; if (fyscal * n0 < (double)max_y/5.0) fyscal = (double)(max_y-1)/((double)(n0)*5.0); fxscal *= 0.9; fxoff = (double)(max_x-1)/11.0; fyscal *= 0.9; fyoff = (double)(max_y-1)/11.0; printf("%% openplt - frame - %ld %ld\n", n0, n1); linetype(0); printf("gsave\n"); printf("currentlinewidth 1.5 mul setlinewidth\n"); newline(); move(SX(0),SY(0)); draw(SX(0),SY(n1+1)); draw(SX(n0+1),SY(n1+1)); draw(SX(n0+1),SY(0)); draw(SX(0),SY(0)); clsline(n0,n1,100000); printf("grestore\n"); xaxis(n0,sq1off, xtitle); yaxis(n1,sq0off, ytitle); legend(); printf("%% openplt done\n"); }
void caStripPlot::setLegendAttribute(QColor c, QFont f, LegendAtttribute SW) { int i; #if QWT_VERSION < 0x060100 for(i=0; i < NumberOfCurves; i++) { switch (SW) { case TEXT: if(thisLegendshow) { QwtText text; text.setText(legendText(i)); qobject_cast<QwtLegendItem*>(this->legend()->find(curve[i]))->setText(text); } break; case FONT: if(getLegendEnabled()) { if(legend() != (QwtLegend*) 0) { QList<QWidget *> list = legend()->legendItems(); for (QList<QWidget*>::iterator it = list.begin(); it != list.end(); ++it ) { QWidget *w = *it; w->setFont(f); } } } break; case COLOR: if(legend() != (QwtLegend*) 0) { QList<QWidget *> list = legend()->legendItems(); for (QList<QWidget*>::iterator it = list.begin(); it != list.end(); ++it ) { QWidget *w = *it; QPalette palette = w->palette(); palette.setColor( QPalette::WindowText, c); // for ticks palette.setColor( QPalette::Text, c); // for ticks' labels w->setPalette (palette); w->setFont(f); } } break; } } #else i=0; foreach (QwtPlotItem *plt_item, itemList()) { if ( plt_item->rtti() == QwtPlotItem::Rtti_PlotCurve ) { QwtLegend *lgd = qobject_cast<QwtLegend *>(legend()); QList<QWidget *> legendWidgets = lgd->legendWidgets(itemToInfo(plt_item)); if ( legendWidgets.size() == 1 ) { QwtLegendLabel *b = qobject_cast<QwtLegendLabel *>(legendWidgets[0]); switch (SW) { case TEXT: if(thisLegendshow) { QwtText text; text.setText(legendText(i++)); //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); b->setText(text); b->update(); } break; case FONT: //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); b->setFont(f); b->update(); break; case COLOR: //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); QPalette palette = b->palette(); palette.setColor( QPalette::WindowText, c); // for ticks palette.setColor( QPalette::Text, c); // for ticks' labels b->setPalette(palette); b->update(); break; } } } } #endif }
void macro_MakeQcdClosureTest() { // parameters ////////////////////////////////////////////////////////////// //TFile input("./emuSpec_19619pb-1.root", "open"); TFile input("test_19619pb-1.root", "open"); input.cd(); TParameter<float> *lumi = (TParameter<float> *)input.Get("lumi"); const int nBins = 75; const bool usePu = 1; const bool useWeight = 1; const int qcdEst = 1; // estimation method of QCD contribution. none(0), from SS spectrum(1), from fake rate(2) int eRegion = 2; // electron region EB(0), EE(1), EB+EE(2) bool plotSign[3]; plotSign[0] = 1; // all plotSign[1] = 1; // SS same sign plotSign[2] = 1; // OS opposite sign bool plotType[2]; plotType[0] = 1; // emu spectrum plotType[1] = 1; // cumulative emu spectrum const bool plotPull = 0; // plot (data-bkg)/bkg const bool plotPullBelowSpec = 0; // plot (data-bkg)/bkg below spectrum const bool logPlotX = 0; const bool logPlotY = 1; const bool prelim = 1; const bool groupedPlot = 0; const bool overflowBin = 1; float xRangeMin = 60.; float xRangeMax = 1200.; //float xRangeMin = 0.; //float xRangeMax = 1500.; float yRangeMin[6] = {0.002, 0.002, 0.002, 0.4, 0.4, 0.4}; float yRangeMax[6] = {30, 10, 30, 3000, 1000, 3000}; float yRangeMinRatio[3] = {-0.7, -0.7, -0.7}; float yRangeMaxRatio[3] = {0.7, 0.7, 0.7}; float fitMin = xRangeMin; float fitMax = 1100.; // set to highest bin with a data point float xRangeMinRatio = fitMin; float xRangeMaxRatio = fitMax; // output file formats const bool savePull = 0; const bool saveSpec = 0; const bool saveCumSpec = 0; const bool saveAsPdf = 0; const bool saveAsPng = 1; const bool saveAsRoot = 0; const char *fileNameExtra = ""; //const char *fileNameExtra = "madgraphTTbar_"; const char *plotDir = "./plottemp/"; // plot style int wjetColour= TColor::GetColor("#ffd324"); int jetBkgColour = TColor::GetColor("#ffff66"); int font = 42; //62 //////////////////////////////////////////////////////////////////////////// // systematic errors float systErrLumi = ((TParameter<float> *)input.Get("systErrLumi"))->GetVal(); systErrLumi = 0.; // since we normalize to the Z peak float systErrEff = ((TParameter<float> *)input.Get("systErrEff"))->GetVal(); // muon err & ele err THashList *systErrMCs = (THashList *)input.Get("systErrMCs"); vector<float> systErrMC; systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTtbar"))->GetVal()); // NNLO ttbar //systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTtbar700to1000"))->GetVal()); // NLO ttbar700to1000 //systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTtbar1000up"))->GetVal()); // NLO ttbar1000up systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcDyTauTau"))->GetVal()); //z->tt systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcWW"))->GetVal()); //WW systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcWZ"))->GetVal()); //WZ systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcZZ"))->GetVal()); //ZZ systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTW"))->GetVal()); //tW systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcDyMuMu"))->GetVal()); //Z->mm systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcDyEE"))->GetVal()); //Z->ee if (qcdEst == 2) systErrMC.push_back(0.4); // qcd error else systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcWJets"))->GetVal()); //WJets // to keep the histogram when the file is closed TH1::AddDirectory(kFALSE); TH1::SetDefaultSumw2(kTRUE); TString histoSign[3] = {"", "SS_", "OS_"}; TString xAxisTitle[3] = {"m(e#mu)", "m(e^{#pm}#mu^{#pm})", "m(e^{#pm}#mu^{#mp})"}; TString nameSuffix[2] = {"", "cumul"}; TString titleSuffix[2] = {"", " - Cumulative"}; vector<TH1F *> emuMass_wjets; vector<TH1F *> emuMass_qcd; vector<TH1F *> emuMass_qcdFromFake; // define the binning vector<float> binning; if (logPlotX) { //for (float bin = 0.; bin < 100.; bin += 5.) // binning.push_back(bin); for (float bin = 0.; bin < 200.; bin += 10.) binning.push_back(bin); for (float bin = 200.; bin < 400.; bin += 20.) binning.push_back(bin); for (float bin = 400.; bin < 500.; bin += 25.) binning.push_back(bin); for (float bin = 500.; bin <= 620.; bin += 40.) binning.push_back(bin); binning.push_back(670.); binning.push_back(720.); binning.push_back(780.); binning.push_back(840.); binning.push_back(920.); binning.push_back(1000.); binning.push_back(1100.); binning.push_back(1220.); binning.push_back(1380.); binning.push_back(1500.); } else { //for (float bin = 0.; bin <= 1500.; bin += 20.) // binning.push_back(bin); for (float bin = 0.; bin < 200.; bin += 20.) binning.push_back(bin); for (float bin = 200.; bin < 400.; bin += 40.) binning.push_back(bin); for (float bin = 400.; bin < 700.; bin += 50.) binning.push_back(bin); for (float bin = 700.; bin < 1000.; bin += 75.) binning.push_back(bin); for (float bin = 1000.; bin < 1200.; bin += 100.) binning.push_back(bin); for (float bin = 1200.; bin <= 1500.; bin += 150.) binning.push_back(bin); } THashList *mcWeights = (THashList *)input.Get("mcWeights"); TParameter<float> *mcWeight = (TParameter<float> *)mcWeights->FindObject("ttbar"); TParameter<float> *mcWeight700to1000 = (TParameter<float> *)mcWeights->FindObject("ttbar700to1000"); TParameter<float> *mcWeight1000up = (TParameter<float> *)mcWeights->FindObject("ttbar1000up"); float totMcWeight = 1.; // determine qcd contribution TH1F *qcdContrib; TH1F *ssData = MakeHistoFromBranch(&input, "emuTree_data", "mass", SS, eRegion, "", 0., 0., binning, 0x100); TH1F *ssBg = MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "genMTtbar", 0., 700., binning, 0x1DF); totMcWeight = 1. / (1 / mcWeight->GetVal() + 1 / mcWeight700to1000->GetVal()); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "genMTtbar", 700., 1000., binning, 0x19F), totMcWeight); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar700to1000", "mass", SS, eRegion, "genMTtbar", 700., 1000., binning, 0x19F), totMcWeight); totMcWeight = 1. / (1 / mcWeight->GetVal() + 1 / mcWeight1000up->GetVal()); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "genMTtbar", 1000., 1000000000., binning, 0x19F), totMcWeight); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar1000up", "mass", SS, eRegion, "genMTtbar", 1000., 1000000000., binning, 0x19F), totMcWeight); //TH1F *ssBg = MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF); //TH1F *ssBg = MakeHistoFromBranch(&input, "emuTree_ttbarto2l", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ztautau", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ww", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_wz", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_zz", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_tw", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_zmumu", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_zee", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_wjets", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); qcdContrib = (TH1F *)ssData->Clone("qcdContrib_SS"); qcdContrib->Add(ssBg, -1); for (int i = 0; i < qcdContrib->GetNbinsX() + 2; ++i) { if (qcdContrib->GetBinContent(i) < 0) qcdContrib->SetBinContent(i, 0.); } cout << "expected SS QCD events: " << ssData->Integral() - ssBg->Integral() << endl; cout << "derived SS QCD events: " << qcdContrib->Integral() << endl; cout << "scale factor: " << (ssData->Integral() - ssBg->Integral()) / qcdContrib->Integral()<< endl; qcdContrib->Scale((ssData->Integral() - ssBg->Integral()) / qcdContrib->Integral()); // loop over full spectrum, SS and OS for (int k = 0; k < 3; ++k) { // loop to get normal and cumulated spectrum for (unsigned int j = 0; j < 2; ++j) { input.cd(); bool normToBin = true; if (j > 0) normToBin = false; if (k == 2) k = -1; // make the histograms emuMass_wjets.push_back(MakeHistoFromBranch(&input, "emuTree_wjets", "mass", k, eRegion, "", 0., 0., binning, 0x1DF, normToBin)); if (k == -1) k = 2; emuMass_wjets.back()->SetName("emuMass_" + histoSign[k] + "wjets" + nameSuffix[j]); // qcd contribution if (k == 2) k = -1; emuMass_qcdFromFake.push_back((TH1F *)MakeHistoFromBranch(&input, "frEmuTree_data", "mass", k, eRegion, "", 0., 0., binning, 0x300)); emuMass_qcd.push_back((TH1F *)qcdContrib->Clone("emuMass_" + histoSign[k] + "qcd")); if (k == ALL) emuMass_qcd.back()->Scale(2.); // normalize to bin width if (j < 1) { for (int i = 1; i < emuMass_qcd.back()->GetNbinsX() + 1; ++i) { emuMass_qcd.back()->SetBinContent(i, emuMass_qcd.back()->GetBinContent(i) / emuMass_qcd.back()->GetBinWidth(i)); emuMass_qcd.back()->SetBinError(i, emuMass_qcd.back()->GetBinError(i) / emuMass_qcd.back()->GetBinWidth(i)); emuMass_qcdFromFake.back()->SetBinContent(i, emuMass_qcdFromFake.back()->GetBinContent(i) / emuMass_qcdFromFake.back()->GetBinWidth(i)); emuMass_qcdFromFake.back()->SetBinError(i, emuMass_qcdFromFake.back()->GetBinError(i) / emuMass_qcdFromFake.back()->GetBinWidth(i)); } } if (k == -1) k = 2; // add overflow in last bin if (j == 0 && overflowBin) { emuMass_wjets.back()->SetBinContent(emuMass_wjets.back()->GetNbinsX(), emuMass_wjets.back()->GetBinContent(emuMass_wjets.back()->GetNbinsX()) + emuMass_wjets.back()->GetBinContent(emuMass_wjets.back()->GetNbinsX() + 1)); emuMass_qcd.back()->SetBinContent(emuMass_qcd.back()->GetNbinsX(), emuMass_qcd.back()->GetBinContent(emuMass_qcd.back()->GetNbinsX()) + emuMass_qcd.back()->GetBinContent(emuMass_qcd.back()->GetNbinsX() + 1)); emuMass_qcdFromFake.back()->SetBinContent(emuMass_qcdFromFake.back()->GetNbinsX(), emuMass_qcdFromFake.back()->GetBinContent(emuMass_qcdFromFake.back()->GetNbinsX()) + emuMass_qcdFromFake.back()->GetBinContent(emuMass_qcdFromFake.back()->GetNbinsX() + 1)); } // integrate from the right side if (j == 1) { // loop over bins double error; for (int i = 1; i < nBins + 1; ++i) { emuMass_wjets.back()->SetBinContent(i, emuMass_wjets.back()->IntegralAndError(i, nBins, error)); emuMass_wjets.back()->SetBinError(i, error); emuMass_qcd.back()->SetBinContent(i, emuMass_qcd.back()->IntegralAndError(i, nBins, error)); emuMass_qcd.back()->SetBinError(i, error); emuMass_qcdFromFake.back()->SetBinContent(i, emuMass_qcdFromFake.back()->IntegralAndError(i, nBins, error)); emuMass_qcdFromFake.back()->SetBinError(i, error); } } if (!plotSign[k]) continue; if (!plotType[j]) continue; TCanvas *emuPlot; TPad *specPad; if (plotPullBelowSpec && j == 0) { emuPlot = new TCanvas("emuPlot" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 100, 100, 900, 900); specPad = new TPad("specPad" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 0., 0.33, 1., 1.); specPad->SetBottomMargin(0.06); } else { emuPlot = new TCanvas("emuPlot" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 100, 100, 900, 600); specPad = new TPad("specPad" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 0., 0., 1., 1.); specPad->SetBottomMargin(0.12); } specPad->SetBorderMode(0); specPad->SetBorderSize(2); specPad->SetFrameBorderMode(0); specPad->SetFillColor(0); specPad->SetFrameFillColor(0); if (logPlotX) specPad->SetLogx(); if (logPlotY) specPad->SetLogy(); specPad->SetLeftMargin(0.11); specPad->SetRightMargin(0.09); specPad->SetTopMargin(0.08); specPad->SetTickx(1); specPad->SetTicky(1); specPad->Draw(); specPad->cd(); gStyle->SetTitleFont(font); gStyle->SetLabelFont(font); gStyle->SetLegendFont(font); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetTitleXOffset(1.); gStyle->SetTitleYOffset(1.3); gPad->SetTicks(1, 1); // make a histogram stack with the bg THStack *bgStack = new THStack("bgStack" + histoSign[k] + nameSuffix[j], "Invariant Mass" + titleSuffix[j]); bgStack->Add(emuMass_qcd.back()); bgStack->Add(emuMass_wjets.back()); // plot spectrum emuMass_wjets.back()->SetFillColor(wjetColour); emuMass_wjets.back()->SetMarkerColor(wjetColour); emuMass_wjets.back()->SetLineColor(kBlack); emuMass_wjets.back()->SetLineWidth(2); //emuMass_wjets.back()->Draw("HISTsames"); emuMass_qcd.back()->SetFillColor(jetBkgColour); emuMass_qcd.back()->SetMarkerColor(jetBkgColour); emuMass_qcd.back()->SetLineColor(kBlack); emuMass_qcd.back()->SetLineWidth(2); //emuMass_qcd.back()->Draw("HISTsames"); bgStack->Draw("hist"); emuMass_qcdFromFake.back()->SetLineColor(kRed); emuMass_qcdFromFake.back()->SetLineWidth(2); emuMass_qcdFromFake.back()->Draw("esame"); if (plotPullBelowSpec && j == 0) { bgStack->GetXaxis()->SetTitle(""); } else { bgStack->GetXaxis()->SetTitle(xAxisTitle[k] + " [GeV]"); } bgStack->GetXaxis()->SetTitleFont(font); bgStack->GetXaxis()->SetTitleSize(0.047); bgStack->GetXaxis()->SetTitleOffset(0.9); bgStack->GetXaxis()->SetLabelFont(font); bgStack->GetXaxis()->SetLabelSize(0.05); bgStack->GetXaxis()->SetMoreLogLabels(); bgStack->GetXaxis()->SetNoExponent(); //bgStack->GetXaxis()->SetRangeUser(xRangeMin, xRangeMax); bgStack->GetXaxis()->SetLimits(xRangeMin, xRangeMax); if (j == 1) bgStack->GetYaxis()->SetTitle("Events #geq " + xAxisTitle[k]); else bgStack->GetYaxis()->SetTitle("Events / GeV"); bgStack->GetYaxis()->SetTitleFont(font); bgStack->GetYaxis()->SetTitleSize(0.047); bgStack->GetYaxis()->SetTitleOffset(1.1); bgStack->GetYaxis()->SetLabelFont(font); bgStack->GetYaxis()->SetLabelSize(0.05); bgStack->SetMinimum(yRangeMin[k + j * 3]); bgStack->SetMaximum(yRangeMax[k + j * 3]); // redraw axis emuMass_qcd.back()->Draw("sameaxis"); // legend and labels TLegend legend(0.710, 0.646, 0.901, 0.885); legend.SetTextFont(font); legend.SetTextSize(0.03); legend.SetBorderSize(0); legend.SetLineColor(1); legend.SetLineStyle(1); legend.SetLineWidth(1); legend.SetFillColor(19); legend.SetFillStyle(0); legend.AddEntry(emuMass_wjets.back(), "W+jets (MC)" ,"F"); legend.AddEntry(emuMass_qcd.back(), "jets (SS data)" ,"F"); legend.AddEntry(emuMass_qcdFromFake.back(), "jets (Fake Rate)" ,"le"); legend.DrawClone("sames"); TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextFont(font); tex->SetLineWidth(2); tex->SetTextSize(0.042); if (prelim) tex->DrawLatex(0.325, 0.853, "CMS Preliminary, 8 TeV, 19.6 fb^{-1}"); else tex->DrawLatex(0.405, 0.853, "CMS, 8 TeV, 19.6 fb^{-1}"); if (eRegion == 0) tex->DrawLatex(0.325, 0.775, "e in barrel"); if (eRegion == 1) tex->DrawLatex(0.325, 0.775, "e in endcap"); // safe in various file formats stringstream sStream; if (!plotPullBelowSpec || j > 0) { sStream << plotDir << "qcdClosureTestSpec"; if (k == 0) sStream << "_"; sStream << histoSign[k]; if (eRegion == 0) sStream << "EB_"; if (eRegion == 1) sStream << "EE_"; sStream << fileNameExtra << nameSuffix[j]; if (j > 0) sStream << "_"; if (groupedPlot) sStream << "grouped_"; if (!logPlotY) sStream << "lin_"; sStream << lumi->GetVal() << "pb-1"; TString saveFileName = sStream.str(); if ((j == 0 && saveSpec) || (j > 0 && saveCumSpec)) { if (saveAsPdf) emuPlot->Print(saveFileName + ".pdf", "pdf"); if (saveAsPng) emuPlot->Print(saveFileName + ".png", "png"); if (saveAsRoot) emuPlot->Print(saveFileName + ".root", "root"); } } } // end loop over normal or cumulated } // end loop over full, SS and OS // generate one object containing everything vector<vector<TH1F *> > emuMasses; emuMasses.push_back(emuMass_wjets); emuMasses.push_back(emuMass_qcd); // // define groups of MC samples // vector<bool> ttLikeSamples(6, true); // vector<bool> contamSamples(6, false); // contamSamples.push_back(true); // Zmm // contamSamples.push_back(true); // Zee // contamSamples.push_back(true); // WJets or QCD // vector<bool> contamSamplesNoQcd(contamSamples); // vector<bool> allSamples(9, true); // vector<bool> onlyQCD(emuMasses.size() - 1, false); // if (qcdEst > 0) { // onlyQCD.back() = true; // if (qcdEst != 2) { // allSamples.push_back(true); // contamSamples.push_back(true); // contamSamplesNoQcd.push_back(false); // systErrMC.push_back(0.); // QCD error will be calculated later // } else { // contamSamplesNoQcd.back() = false; // } // } // vector<bool> allSamplesNoQcd(allSamples); // if (qcdEst > 0) allSamplesNoQcd.back() = false; // unsigned int qcdInd = onlyQCD.size(); // unsigned int qcdErrInd = qcdInd - 1; // // // calculate rate of syst errors // float systErrLuEff = sqrt(systErrLumi*systErrLumi + systErrEff*systErrEff); // vector<float> systErrMCLuEff; // for (unsigned int it = 0; it < systErrMC.size(); ++it) // systErrMCLuEff.push_back(sqrt(systErrMC[it]*systErrMC[it] + systErrLuEff*systErrLuEff)); // // bool calcQcdErr = false; // if (qcdEst == 1) calcQcdErr = true; // // //cout << "qcdInd " << qcdInd << ", emuMasses.size() " << emuMasses.size() << ", systErrMC.size() " << systErrMC.size() // // << ", systErrMCLuEff.size() " << systErrMCLuEff.size() << ", allSamples.size() " << allSamples.size() // // << ", allSamplesNoQcd.size() " << allSamplesNoQcd.size() << ", contamSamplesNoQcd.size() " << contamSamplesNoQcd.size() // // << ", contamSamples.size() " << contamSamples.size() << ", onlyQCD.size() " << onlyQCD.size() << endl; // //for (unsigned int sIt = 0; sIt < emuMasses.size() - 1; ++sIt) { // // cout << "allSamples " << allSamples[sIt] << ", allSamplesNoQcd " << allSamplesNoQcd[sIt] // // << ", contamSamples " << contamSamples[sIt] << ", contamSamplesNoQcd " << contamSamplesNoQcd[sIt] // // << ", onlyQCD " << onlyQCD[sIt] << ", systErrMC " << systErrMC[sIt] << ", systErrMCLuEff " << systErrMCLuEff[sIt] << endl; // //} // // // define special bins corresponding to specific masses // int bin60 = emuMass_data.at(ALL)->FindBin(60.); // int bin120 = emuMass_data.at(ALL)->FindBin(120.); // int bin200 = emuMass_data.at(ALL)->FindBin(200.); // int bin400 = emuMass_data.at(ALL)->FindBin(400.); // int bin500 = emuMass_data.at(ALL)->FindBin(500.); // // vector<const char *> sampleNames; // sampleNames.push_back("data "); // sampleNames.push_back("ttbar "); // sampleNames.push_back("Ztautau"); // sampleNames.push_back("WW "); // sampleNames.push_back("WZ "); // sampleNames.push_back("ZZ "); // sampleNames.push_back("tW "); // sampleNames.push_back("Zmumu "); // sampleNames.push_back("Zee "); // if (qcdEst != 2) sampleNames.push_back("WJets "); // if (qcdEst > 0) sampleNames.push_back("QCD "); // // // write numbers // cout << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // cout << "HEEP - TIGHT MU Lumi = " << lumi->GetVal() << "pb-1" << endl; // //cout << " e pT EB > " << bar_et << "GeV/c" << endl; // //cout << " e pT EE > " << end_et << "GeV/c" << endl; // //cout << " mu pT > " << muon_et << "GeV/c" << endl; // //cout << " mu |eta| < " << muon_etaMax << endl; // cout << endl; // cout << "Systematic errors" << endl; // cout << " Luminosity: " << systErrLumi * 100 << "%" << endl; // cout << " Efficiency: " << systErrEff * 100 << "%" << endl; // cout << " ttbar: " << systErrMC[TTBAR-1] * 100 << "%" << endl; // cout << " Z->tautau: " << systErrMC[ZTT-1] * 100 << "%" << endl; // cout << " WW: " << systErrMC[WW-1] * 100 << "%" << endl; // cout << " WZ: " << systErrMC[WZ-1] * 100 << "%" << endl; // cout << " ZZ: " << systErrMC[ZZ-1] * 100 << "%" << endl; // cout << " tW, tbarW: " << systErrMC[TW-1] * 100 << "%" << endl; // cout << " Z->mumu: " << systErrMC[ZMM-1] * 100 << "%" << endl; // cout << " Z->ee: " << systErrMC[ZEE-1] * 100 << "%" << endl; // if (qcdEst != 2) cout << " W+Jets: " << systErrMC[WJET-1] * 100 << "%" << endl; // else cout << " QCD: " << systErrMC.back() * 100 << "%" << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // if (signIt == 3) cout << "-SS--------------------------------------------------------------------------------------------------------" << endl; // if (signIt == 5) cout << "-OS--------------------------------------------------------------------------------------------------------" << endl; // cout << "-----------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | > 60GeV/c^2 | > 120GeV/c^2 | > 200GeV/c^2 | > 400GeV/c^2 |" << endl; // cout << "-----------------------------------------------------------------------------------------------------------------------------------------" << endl; // // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMass_data.at(signIt)->GetBinContent(bin60), sqrt(emuMass_data.at(signIt)->GetBinContent(bin60)), // emuMass_data.at(signIt)->GetBinContent(bin120), sqrt(emuMass_data.at(signIt)->GetBinContent(bin120)), // emuMass_data.at(signIt)->GetBinContent(bin200), sqrt(emuMass_data.at(signIt)->GetBinContent(bin200)), // emuMass_data.at(signIt)->GetBinContent(bin400), sqrt(emuMass_data.at(signIt)->GetBinContent(bin400))); // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int sampleIt = 1; sampleIt < sampleNames.size(); ++sampleIt) { // if (sampleIt == 7) cout << "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" << endl; // if (qcdEst == 1 && sampleIt == sampleNames.size() - 1) { // printf("nb %7s | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", sampleNames[sampleIt], // emuMass_qcd.at(signIt)->GetBinContent(bin60), emuMass_qcd.at(signIt)->GetBinContent(bin60) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin60), // emuMass_qcd.at(signIt)->GetBinContent(bin120), emuMass_qcd.at(signIt)->GetBinContent(bin120) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin120), // emuMass_qcd.at(signIt)->GetBinContent(bin200), emuMass_qcd.at(signIt)->GetBinContent(bin200) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin200), // emuMass_qcd.at(signIt)->GetBinContent(bin400), emuMass_qcd.at(signIt)->GetBinContent(bin400) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin400)); // } else { // printf("nb %7s | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", sampleNames[sampleIt], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin60), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin60) * systErrMCLuEff[sampleIt-1], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin120), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin120) * systErrMCLuEff[sampleIt-1], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin200), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin200) * systErrMCLuEff[sampleIt-1], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin400), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin400) * systErrMCLuEff[sampleIt-1]); // } // } // cout << endl; // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("TOT ttlike | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin60), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin60), // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin120), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin120), // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin200), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin200), // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin400), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin400)); // printf("TOT contam | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, contamSamples, signIt, bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin60, -1, calcQcdErr), // CalcBgSum(emuMasses, contamSamples, signIt, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin120, -1, calcQcdErr), // CalcBgSum(emuMasses, contamSamples, signIt, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin200, -1, calcQcdErr), // CalcBgSum(emuMasses, contamSamples, signIt, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin400, -1, calcQcdErr)); // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // // printf("TOT Bkg | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamples, signIt, bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin60, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin120, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin200, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin400, -1, calcQcdErr)); // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << endl << endl; // } // cout << endl; // // cout << "--Without adding QCD contribution:--------------------------------------------------------------------------------------------------------" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | > 60GeV/c^2 | > 120GeV/c^2 | > 200GeV/c^2 | > 400GeV/c^2 |" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // if (signIt == 3) cout << "-SS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // if (signIt == 5) cout << "-OS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMasses.at(DATA).at(signIt)->GetBinContent(bin60), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin60)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin120), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin120)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin200), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin200)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin400), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin400))); // printf("nb MC | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin60), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin60), // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin120), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin120), // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin200), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin200), // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin400), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin400)); // } // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // // if (qcdEst == 1) { // //systErrMC.back() = 2 * sqrt(emuMasses.at(DATA).at(SS)->Integral() + pow(CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, SS, 1), 2)) / emuMasses.at(qcdInd).at(ALL)->Integral(); // //systErrMC.back() = CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, SSCUM, 1) / emuMass_qcd.at(SSCUM)->GetBinContent(1); // //systErrMCLuEff.back() = systErrMC[qcdErrInd]; // // cout << endl; // cout << "---QCD events from SS spectrum:----------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "-----------------------------------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("nb QCD SS+OS | %9.3f +- %8.3f (%.1f%%) (syst) | %9.3f +- %8.3f (%.1f%%) (syst) | %9.3f +- %8.3f (%.1f%%) (syst) | %9.3f +- %8.3f (%.1f%%) (syst) |\n", // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin60, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin60, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin60), // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin120, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin120, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin120), // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin200, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin200, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin200), // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin400, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin400, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin400)); // printf("%% of total MC | %7.3f%% +- %7.3f%% (syst) | %7.3f%% +- %7.3f%% (syst) | %7.3f%% +- %7.3f%% (syst) | %7.3f%% +- %7.3f%% (syst) |\n", // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin60) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin60), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin60, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin60), // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin120) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin120), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin120, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin120), // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin200) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin200), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin200, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin200), // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin400) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin400), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin400, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin400)); // cout << "-----------------------------------------------------------------------------------------------------------------------------------------------------------------" << endl; // } // // // top up bg contribution with qcd // if (qcdEst > 0) { // cout << endl; // cout << "--After adding QCD contribution:----------------------------------------------------------------------------------------------------------" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | > 60GeV/c^2 | > 120GeV/c^2 | > 200GeV/c^2 | > 400GeV/c^2 |" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // if (signIt == 3) cout << "-SS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // if (signIt == 5) cout << "-OS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMasses.at(DATA).at(signIt)->GetBinContent(bin60), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin60)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin120), sqrt((emuMasses.at(DATA).at(signIt))->GetBinContent(bin120)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin200), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin200)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin400), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin400))); // printf("nb MC | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamples, signIt, bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin60, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin120, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin200, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin400, -1, calcQcdErr)); // } // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // } // // cout << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | 60 - 120GeV/c^2 | 120 - 200GeV/c^2 | 200 - 400GeV/c^2 |" << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMasses.at(DATA).at(signIt)->GetBinContent(bin60) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin120), // sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin60) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin120)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin120) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin200), // sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin120) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin200)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin200) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin400), // sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin200) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin400))); // printf("nb MC | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamples, signIt, bin60, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin60, bin120, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin120, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin120, bin200, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin200, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin200, bin400, calcQcdErr)); // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // } }
/* >>>>>>>>>> EX10_1 <<<<<<<<<< */ void ex10_1 (void) { int nya = 2700, i; static char *ctit = "Bar Graphs (BARS)", cbuf[25]; static float x[9] = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f}, y[9] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}, y1[9] = {1.f, 1.5f, 2.5f, 1.3f, 2.0f, 1.2f, 0.7f, 1.4f, 1.1f}, y2[9] = {2.f, 2.7f, 3.5f, 2.1f, 3.2f, 1.9f, 2.0f, 2.3f, 1.8f}, y3[9] = {4.f, 3.5f, 4.5f, 3.7f, 4.0f, 2.9f, 3.0f, 3.2f, 2.6f}; setpag ("da4p"); disini (); pagera (); hwfont (); ticks (1, "x"); intax ();; axslen (1600, 700); titlin (ctit, 3); legini (cbuf, 3, 8); leglin (cbuf, "FIRST", 1); leglin (cbuf, "SECOND", 2); leglin (cbuf, "THIRD", 3); legtit (" "); shdpat (5L); for (i = 1; i <= 3; i++) { if (i > 1) labels ("none", "x"); axspos (300, nya - (i - 1) * 800); graf (0.f, 10.f, 0.f, 1.f, 0.f, 5.f, 0.f, 1.f); if (i == 1) { bargrp (3, 0.15f); color ("red"); bars (x, y, y1, 9); color ("green"); bars (x, y, y2, 9); color ("blue"); bars (x, y, y3, 9); color ("fore"); reset ("bargrp"); } else if (i == 2) { height (30); labels ("delta", "bars"); labpos ("center", "bars"); color ("red"); bars (x, y, y1, 9); color ("green"); bars (x, y1, y2, 9); color ("blue"); bars (x, y2, y3, 9); color ("fore"); reset ("height"); } else if (i == 3) { labels ("second", "bars"); labpos ("outside", "bars"); color ("red"); bars (x, y, y1, 9); color ("fore"); } if (i != 3) legend (cbuf, 7); if (i == 3) { height (50); title (); } endgrf (); } disfin (); }