int main(int argc, char** argv) { Verificator verificator; Performance performance; Name sampleName("/a/b/c"); Consumer c(sampleName, RDR); c.setContextOption(MUST_BE_FRESH_S, true); c.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&Performance::onDataEnters, &performance, _1, _2)); c.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&Performance::onInterestLeaves, &performance, _1, _2)); c.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&Performance::onContent, &performance, _1, _2, _3)); c.consume(Name()); sleep(50); std::cout << "Now consuming with more strict verification" << std::endl; c.setContextOption(DATA_TO_VERIFY, (ConsumerDataVerificationCallback)bind(&Verificator::onPacket, &verificator, _1, _2)); c.consume(Name()); sleep(50); return 0; }
void test(int argc, char** argv) { auto t1 = std::chrono::high_resolution_clock::now(); std::string suffix = "1"; if (argc > 1) { suffix = argv[1]; } Verificator verificator; Performance performance; Name sampleName(PREFIX_NAME + suffix); Consumer c(sampleName, SDR); c.setContextOption(MUST_BE_FRESH_S, true); c.setContextOption(INTEREST_RETX, 1000); c.setContextOption(INTEREST_LIFETIME, 20000); c.setContextOption(MAX_WINDOW_SIZE, 1); c.setContextOption(MIN_WINDOW_SIZE, 1); c.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&Performance::onDataEnters, &performance, _1, _2)); c.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&Performance::onInterestLeaves, &performance, _1, _2)); c.setContextOption(DATA_TO_VERIFY, (ConsumerDataVerificationCallback)bind(&Verificator::onPacket, &verificator, _1, _2)); c.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&Performance::onContent, &performance, _1, _2, _3)); std::vector<bool> vec(20, false); std::vector<int> vec_segments(20, 0); int ran = -1; for (int i = 0; i < 20 * 30; i++) { while (1) { auto t2 = std::chrono::high_resolution_clock::now(); srand(std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count()); ran = rand() % 20; if (vec_segments[ran] < 30) { break; } } std::cout << "frame:" << ran << " segment: " << vec_segments[ran] << std::endl; c.consume(Name(std::to_string(ran)).append(name::Component::fromSegment(vec_segments[ran]))); vec_segments[ran]++; } }
int main(int argc, char** argv) { Name sampleName("/q/w/e/r"); CallbackContainer c; Producer p1(sampleName); p1.setContextOption(INTEREST_ENTER_CNTX, (ProducerInterestCallback)bind(&CallbackContainer::onP1, &c, _1, _2)); p1.attach(); Producer p2(sampleName); p2.setContextOption(INTEREST_ENTER_CNTX, (ProducerInterestCallback)bind(&CallbackContainer::onP2, &c, _1, _2)); p2.attach(); sleep(300); return 0; }
int main(int argc, char** argv) { Name sampleName("/a/b/c"); CallbackContainer stubs; Consumer c(sampleName, RDR); c.setContextOption(MUST_BE_FRESH_S, true); c.setContextOption(INTEREST_LEAVE_CNTX, (ConsumerInterestCallback)bind(&CallbackContainer::processLeavingInterest, &stubs, _1, _2)); c.setContextOption(DATA_ENTER_CNTX, (ConsumerDataCallback)bind(&CallbackContainer::processData, &stubs, _1, _2)); c.setContextOption(CONTENT_RETRIEVED, (ConsumerContentCallback)bind(&CallbackContainer::processPayload, &stubs, _1, _2, _3)); c.consume(Name()); return 0; }
int main( int argc, char* argv[] ) { if( argc!=2 ) { std::cout << "USAGE: ./computeLostLepton [samplesFileName]" << std::endl; std::cout << "Exiting." << std::endl; exit(11); } std::string sampleName(argv[1]); std::string samplesFileName = "samples/samples_" + sampleName + ".dat"; std::cout << std::endl << std::endl; std::cout << "-> Loading samples from file: " << samplesFileName << std::endl; std::vector<MT2Sample> fSamples = MT2Common::loadSamples(samplesFileName); std::ostringstream HLT_metHT; HLT_metHT << "( ( (" << "trigger.HLT_PFMET150_v2 == 1 || trigger.HLT_PFMET150_v3 == 1 || trigger.HLT_PFMET150_v4 == 1 || " << "trigger.HLT_PFMET150_v5 == 1 || trigger.HLT_PFMET150_v6 == 1 || trigger.HLT_PFMET150_v7 == 1 )" << "||(" << "trigger.HLT_PFHT350_PFMET100_v3==1 || trigger.HLT_PFHT350_PFMET100_v4==1 || trigger.HLT_PFHT350_PFMET100_v5==1 || " << "trigger.HLT_PFHT350_PFMET100_v6==1 || trigger.HLT_PFHT350_PFMET100_v7==1 || trigger.HLT_PFNoPUHT350_PFMET100_v1==1 || " << "trigger.HLT_PFNoPUHT350_PFMET100_v3==1 || trigger.HLT_PFNoPUHT350_PFMET100_v4==1 ) ) &&TOBTECTagger<=8&&ExtraBeamHaloFilter==0)"; std::ostringstream HLT_HT; HLT_HT << "( (" << "trigger.HLT_PFHT650_v5 == 1 || trigger.HLT_PFHT650_v6 == 1 || trigger.HLT_PFHT650_v7 == 1 || " << "trigger.HLT_PFHT650_v8 == 1 || trigger.HLT_PFHT650_v9 == 1 || " << "trigger.HLT_PFNoPUHT650_v1 == 1 || trigger.HLT_PFNoPUHT650_v3 == 1 || trigger.HLT_PFNoPUHT650_v4 == 1) &&TOBTECTagger<=8&&ExtraBeamHaloFilter==0)"; std::vector<MT2HTRegion> HTRegions; HTRegions.push_back(MT2HTRegion("lowHT", 450., 750., 200., HLT_metHT.str())); HTRegions.push_back(MT2HTRegion("mediumHT", 750., 1200., 30., HLT_HT.str())); HTRegions.push_back(MT2HTRegion("highHT", 1200., 100000., 30., HLT_HT.str())); std::vector<MT2SignalRegion> signalRegions; signalRegions.push_back(MT2SignalRegion(2, 2, 0, 0)); // 2j0b signalRegions.push_back(MT2SignalRegion(2, 2, 1, 2)); // 2j1to2b signalRegions.push_back(MT2SignalRegion(3, 5, 0, 0)); // 3to5j0b signalRegions.push_back(MT2SignalRegion(3, 5, 1, 1)); // 3to5j1b signalRegions.push_back(MT2SignalRegion(3, 5, 2, 2)); // 3to5j2b signalRegions.push_back(MT2SignalRegion(6, -1, 0, 0)); // 6j0b signalRegions.push_back(MT2SignalRegion(6, -1, 1, 1)); // 6j1b signalRegions.push_back(MT2SignalRegion(6, -1, 2, 2)); // 6j2b signalRegions.push_back(MT2SignalRegion(-1, -1, 3, -1)); // 3b TH1::AddDirectory(kFALSE); // stupid ROOT memory allocation needs this std::vector<MT2LostLeptonEstimate*> llest; for( unsigned i=0; i<fSamples.size(); ++i ) llest.push_back( computeLostLepton( fSamples[i], HTRegions, signalRegions ) ); system( "rm tmp.root" ); std::cout << "-> Done looping on samples. Start merging." << std::endl; MT2LostLeptonEstimate* ll_data = mergeEstimates( llest, "HT-Data", "MET-Data" ); //MT2LostLeptonEstimate* ll_data = mergeEstimates( llest, "HT-Data", "MET-Data" ); MT2LostLeptonEstimate* ll_top = mergeEstimates( llest, "Top" ); MT2LostLeptonEstimate* ll_qcd = mergeEstimates( llest, "QCD" ); MT2LostLeptonEstimate* ll_wjets = mergeEstimates( llest, "Wtolnu" ); MT2LostLeptonEstimate* ll_other = mergeEstimates( llest, "DY", "VV" ); MT2LostLeptonEstimate* ll_topW = new MT2LostLeptonEstimate(*ll_top + *ll_wjets); MT2LostLeptonEstimate* ll_bg = new MT2LostLeptonEstimate(*ll_qcd + *ll_other); MT2LostLeptonEstimate* ll_allMC = new MT2LostLeptonEstimate(*ll_topW + *ll_bg); std::cout << "-> Done merging. Start computing preditions." << std::endl; std::vector<TH1D*> vh1_data_ele = getPredictionHistos( "Prediction", "Ele", HTRegions, signalRegions, ll_data, ll_bg, ll_topW ); std::vector<TH1D*> vh1_data_mu = getPredictionHistos( "Prediction", "Muo", HTRegions, signalRegions, ll_data, ll_bg, ll_topW ); std::vector<TH1D*> vh1_mc_ele = getPredictionHistos( "PredictionMC", "Ele", HTRegions, signalRegions, ll_allMC, ll_bg, ll_topW ); std::vector<TH1D*> vh1_mc_mu = getPredictionHistos( "PredictionMC", "Muo", HTRegions, signalRegions, ll_allMC, ll_bg, ll_topW ); std::vector<TH1D*> vh1_sim_ele = getSimTruthHistos( "SimulationTruth", "Ele", HTRegions, signalRegions, ll_topW ); std::vector<TH1D*> vh1_sim_mu = getSimTruthHistos( "SimulationTruth", "Muo", HTRegions, signalRegions, ll_topW ); std::string outputdir = "LostLeptonFiles"; system(Form("mkdir -p %s", outputdir.c_str())); TFile* outfile = TFile::Open(Form("%s/LostLepton_%s.root", outputdir.c_str(), sampleName.c_str()), "recreate"); outfile->cd(); for( unsigned i=0; i<HTRegions.size(); ++i ) { vh1_data_ele[i]->Write(); vh1_data_mu [i]->Write(); vh1_mc_ele [i]->Write(); vh1_mc_mu [i]->Write(); vh1_sim_ele [i]->Write(); vh1_sim_mu [i]->Write(); } outfile->Close(); std::cout << "-> Done computing preditions. Written to file: " << outfile->GetName() << std::endl; return 0; }
void AMSamplePlatePre2013ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QString sampleName(index.data(Qt::DisplayRole).toString()); QString elementString(index.data(AM::UserRole).toString()); if(!elementString.isEmpty()) { elementString.prepend("("); elementString.append(")"); } QString createdString(index.data(AM::DescriptionRole).toString()); QString positionsString(index.data(AM::UserRole+1).toString()); if(positionsString.isEmpty()) { positionsString = "[Unknown sample position]"; } QStyleOptionViewItemV4 opt(option); initStyleOption(&opt, index); QStyle* sty = QApplication::style(); // Draw the background: (this will handle selection for us. You can also probe selection directly with opt.state & QStyle::State_Selected) sty->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter); int textStartingPoint = 0; // Do we have a pixmap available? QRect iconRect = opt.rect; iconRect.adjust(6, 0, 0, 0); if(opt.features & QStyleOptionViewItemV4::HasDecoration) { QPixmap p = opt.icon.pixmap(opt.decorationSize); sty->drawItemPixmap(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter, p); textStartingPoint += 6 + p.width() + 6; } // textRect starts 6px from the edge of the decoration, and is inset 6px on top and bottom and right. It's the full room we have available for text. QRect textRect = opt.rect; textRect.adjust( textStartingPoint, 6, -6, -6); QFont font = opt.font; font.setPointSize(font.pointSize()+4); painter->setFont(font); painter->setPen(opt.palette.text().color()); QRect actualNameTextRect; painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, sampleName, &actualNameTextRect); // Move over by the amount that we filled with text QRect elementTextRect(actualNameTextRect.right() + 6, textRect.top(), textRect.width()-actualNameTextRect.width() - 6, actualNameTextRect.height()); font.setPointSize(font.pointSize()-4); font.setItalic(true); font.setBold(true); painter->setFont(font); painter->setPen(Qt::darkGray); QFontMetrics fm(font); QString elidedElements = fm.elidedText(elementString, Qt::ElideRight, elementTextRect.width()); painter->drawText(elementTextRect, Qt::AlignLeft | Qt::AlignBottom, elidedElements); QRect descriptionTextRect(textRect.left(), actualNameTextRect.bottom(), textRect.width(), textRect.height()-actualNameTextRect.height()); font.setPointSize(font.pointSize()-2); font.setItalic(false); font.setBold(false); painter->setFont(font); painter->setPen(Qt::darkGray); painter->drawText(descriptionTextRect, Qt::AlignLeft | Qt::AlignTop, createdString); QFontMetrics fm2(font); QRect actualPositionsTextRect; painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, fm2.elidedText(positionsString, Qt::ElideMiddle, textRect.width()), &actualPositionsTextRect); int dividerLineY = actualPositionsTextRect.top() - 4; painter->drawLine(QPoint(textRect.left(), dividerLineY), QPoint(textRect.right(), dividerLineY)); }