void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, Size corrsize, int ctype, Point anchor, double delta, int borderType ) { const double blockScale = 4.5; const int minBlockSize = 256; std::vector<uchar> buf; Mat templ = _templ; int depth = img.depth(), cn = img.channels(); int tdepth = templ.depth(), tcn = templ.channels(); int cdepth = CV_MAT_DEPTH(ctype), ccn = CV_MAT_CN(ctype); CV_Assert( img.dims <= 2 && templ.dims <= 2 && corr.dims <= 2 ); if( depth != tdepth && tdepth != std::max(CV_32F, depth) ) { _templ.convertTo(templ, std::max(CV_32F, depth)); tdepth = templ.depth(); } CV_Assert( depth == tdepth || tdepth == CV_32F); CV_Assert( corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1 ); CV_Assert( ccn == 1 || delta == 0 ); corr.create(corrsize, ctype); int maxDepth = depth > CV_8S ? CV_64F : std::max(std::max(CV_32F, tdepth), cdepth); Size blocksize, dftsize; blocksize.width = cvRound(templ.cols*blockScale); blocksize.width = std::max( blocksize.width, minBlockSize - templ.cols + 1 ); blocksize.width = std::min( blocksize.width, corr.cols ); blocksize.height = cvRound(templ.rows*blockScale); blocksize.height = std::max( blocksize.height, minBlockSize - templ.rows + 1 ); blocksize.height = std::min( blocksize.height, corr.rows ); dftsize.width = std::max(getOptimalDFTSize(blocksize.width + templ.cols - 1), 2); dftsize.height = getOptimalDFTSize(blocksize.height + templ.rows - 1); if( dftsize.width <= 0 || dftsize.height <= 0 ) CV_Error( CV_StsOutOfRange, "the input arrays are too big" ); // recompute block size blocksize.width = dftsize.width - templ.cols + 1; blocksize.width = MIN( blocksize.width, corr.cols ); blocksize.height = dftsize.height - templ.rows + 1; blocksize.height = MIN( blocksize.height, corr.rows ); Mat dftTempl( dftsize.height*tcn, dftsize.width, maxDepth ); Mat dftImg( dftsize, maxDepth ); int i, k, bufSize = 0; if( tcn > 1 && tdepth != maxDepth ) bufSize = templ.cols*templ.rows*CV_ELEM_SIZE(tdepth); if( cn > 1 && depth != maxDepth ) bufSize = std::max( bufSize, (blocksize.width + templ.cols - 1)* (blocksize.height + templ.rows - 1)*CV_ELEM_SIZE(depth)); if( (ccn > 1 || cn > 1) && cdepth != maxDepth ) bufSize = std::max( bufSize, blocksize.width*blocksize.height*CV_ELEM_SIZE(cdepth)); buf.resize(bufSize); // compute DFT of each template plane for( k = 0; k < tcn; k++ ) { int yofs = k*dftsize.height; Mat src = templ; Mat dst(dftTempl, Rect(0, yofs, dftsize.width, dftsize.height)); Mat dst1(dftTempl, Rect(0, yofs, templ.cols, templ.rows)); if( tcn > 1 ) { src = tdepth == maxDepth ? dst1 : Mat(templ.size(), tdepth, &buf[0]); int pairs[] = {k, 0}; mixChannels(&templ, 1, &src, 1, pairs, 1); } if( dst1.data != src.data ) src.convertTo(dst1, dst1.depth()); if( dst.cols > templ.cols ) { Mat part(dst, Range(0, templ.rows), Range(templ.cols, dst.cols)); part = Scalar::all(0); } dft(dst, dst, 0, templ.rows); } int tileCountX = (corr.cols + blocksize.width - 1)/blocksize.width; int tileCountY = (corr.rows + blocksize.height - 1)/blocksize.height; int tileCount = tileCountX * tileCountY; Size wholeSize = img.size(); Point roiofs(0,0); Mat img0 = img; if( !(borderType & BORDER_ISOLATED) ) { img.locateROI(wholeSize, roiofs); img0.adjustROI(roiofs.y, wholeSize.height-img.rows-roiofs.y, roiofs.x, wholeSize.width-img.cols-roiofs.x); } borderType |= BORDER_ISOLATED; // calculate correlation by blocks for( i = 0; i < tileCount; i++ ) { int x = (i%tileCountX)*blocksize.width; int y = (i/tileCountX)*blocksize.height; Size bsz(std::min(blocksize.width, corr.cols - x), std::min(blocksize.height, corr.rows - y)); Size dsz(bsz.width + templ.cols - 1, bsz.height + templ.rows - 1); int x0 = x - anchor.x + roiofs.x, y0 = y - anchor.y + roiofs.y; int x1 = std::max(0, x0), y1 = std::max(0, y0); int x2 = std::min(img0.cols, x0 + dsz.width); int y2 = std::min(img0.rows, y0 + dsz.height); Mat src0(img0, Range(y1, y2), Range(x1, x2)); Mat dst(dftImg, Rect(0, 0, dsz.width, dsz.height)); Mat dst1(dftImg, Rect(x1-x0, y1-y0, x2-x1, y2-y1)); Mat cdst(corr, Rect(x, y, bsz.width, bsz.height)); for( k = 0; k < cn; k++ ) { Mat src = src0; dftImg = Scalar::all(0); if( cn > 1 ) { src = depth == maxDepth ? dst1 : Mat(y2-y1, x2-x1, depth, &buf[0]); int pairs[] = {k, 0}; mixChannels(&src0, 1, &src, 1, pairs, 1); } if( dst1.data != src.data ) src.convertTo(dst1, dst1.depth()); if( x2 - x1 < dsz.width || y2 - y1 < dsz.height ) copyMakeBorder(dst1, dst, y1-y0, dst.rows-dst1.rows-(y1-y0), x1-x0, dst.cols-dst1.cols-(x1-x0), borderType); dft( dftImg, dftImg, 0, dsz.height ); Mat dftTempl1(dftTempl, Rect(0, tcn > 1 ? k*dftsize.height : 0, dftsize.width, dftsize.height)); mulSpectrums(dftImg, dftTempl1, dftImg, 0, true); dft( dftImg, dftImg, DFT_INVERSE + DFT_SCALE, bsz.height ); src = dftImg(Rect(0, 0, bsz.width, bsz.height)); if( ccn > 1 ) { if( cdepth != maxDepth ) { Mat plane(bsz, cdepth, &buf[0]); src.convertTo(plane, cdepth, 1, delta); src = plane; } int pairs[] = {0, k}; mixChannels(&src, 1, &cdst, 1, pairs, 1); } else { if( k == 0 ) src.convertTo(cdst, cdepth, 1, delta); else { if( maxDepth != cdepth ) { Mat plane(bsz, cdepth, &buf[0]); src.convertTo(plane, cdepth); src = plane; } add(src, cdst, cdst); } } } } }
int brw_disasm (FILE *file, struct brw_instruction *inst, int gen) { int err = 0; int space = 0; if (inst->header.predicate_control) { string (file, "("); err |= control (file, "predicate inverse", pred_inv, inst->header.predicate_inverse, NULL); string (file, "f0"); if (inst->bits2.da1.flag_reg_nr) format (file, ".%d", inst->bits2.da1.flag_reg_nr); if (inst->header.access_mode == BRW_ALIGN_1) err |= control (file, "predicate control align1", pred_ctrl_align1, inst->header.predicate_control, NULL); else err |= control (file, "predicate control align16", pred_ctrl_align16, inst->header.predicate_control, NULL); string (file, ") "); } err |= print_opcode (file, inst->header.opcode); err |= control (file, "saturate", saturate, inst->header.saturate, NULL); err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL); if (inst->header.opcode == BRW_OPCODE_MATH) { string (file, " "); err |= control (file, "function", math_function, inst->header.destreg__conditionalmod, NULL); } else if (inst->header.opcode != BRW_OPCODE_SEND && inst->header.opcode != BRW_OPCODE_SENDC) err |= control (file, "conditional modifier", conditional_modifier, inst->header.destreg__conditionalmod, NULL); if (inst->header.opcode != BRW_OPCODE_NOP) { string (file, "("); err |= control (file, "execution size", exec_size, inst->header.execution_size, NULL); string (file, ")"); } if (inst->header.opcode == BRW_OPCODE_SEND && gen < 6) format (file, " %d", inst->header.destreg__conditionalmod); if (opcode[inst->header.opcode].ndst > 0) { pad (file, 16); err |= dest (file, inst); } else if (gen >= 6 && (inst->header.opcode == BRW_OPCODE_IF || inst->header.opcode == BRW_OPCODE_ELSE || inst->header.opcode == BRW_OPCODE_ENDIF || inst->header.opcode == BRW_OPCODE_WHILE)) { format (file, " %d", inst->bits1.branch_gen6.jump_count); } if (opcode[inst->header.opcode].nsrc > 0) { pad (file, 32); err |= src0 (file, inst); } if (opcode[inst->header.opcode].nsrc > 1) { pad (file, 48); err |= src1 (file, inst); } if (inst->header.opcode == BRW_OPCODE_SEND || inst->header.opcode == BRW_OPCODE_SENDC) { int target; if (gen >= 6) target = inst->header.destreg__conditionalmod; else if (gen == 5) target = inst->bits2.send_gen5.sfid; else target = inst->bits3.generic.msg_target; newline (file); pad (file, 16); space = 0; if (gen >= 6) { err |= control (file, "target function", target_function_gen6, target, &space); } else { err |= control (file, "target function", target_function, target, &space); } switch (target) { case BRW_MESSAGE_TARGET_MATH: err |= control (file, "math function", math_function, inst->bits3.math.function, &space); err |= control (file, "math saturate", math_saturate, inst->bits3.math.saturate, &space); err |= control (file, "math signed", math_signed, inst->bits3.math.int_type, &space); err |= control (file, "math scalar", math_scalar, inst->bits3.math.data_type, &space); err |= control (file, "math precision", math_precision, inst->bits3.math.precision, &space); break; case BRW_MESSAGE_TARGET_SAMPLER: if (gen >= 5) { format (file, " (%d, %d, %d, %d)", inst->bits3.sampler_gen5.binding_table_index, inst->bits3.sampler_gen5.sampler, inst->bits3.sampler_gen5.msg_type, inst->bits3.sampler_gen5.simd_mode); } else if (0 /* FINISHME: is_g4x */) { format (file, " (%d, %d)", inst->bits3.sampler_g4x.binding_table_index, inst->bits3.sampler_g4x.sampler); } else { format (file, " (%d, %d, ", inst->bits3.sampler.binding_table_index, inst->bits3.sampler.sampler); err |= control (file, "sampler target format", sampler_target_format, inst->bits3.sampler.return_format, NULL); string (file, ")"); } break; case BRW_MESSAGE_TARGET_DATAPORT_READ: if (gen >= 6) { format (file, " (%d, %d, %d, %d, %d, %d)", inst->bits3.gen6_dp.binding_table_index, inst->bits3.gen6_dp.msg_control, inst->bits3.gen6_dp.msg_type, inst->bits3.gen6_dp.send_commit_msg, inst->bits3.gen6_dp.msg_length, inst->bits3.gen6_dp.response_length); } else if (gen >= 5 /* FINISHME: || is_g4x */) { format (file, " (%d, %d, %d)", inst->bits3.dp_read_gen5.binding_table_index, inst->bits3.dp_read_gen5.msg_control, inst->bits3.dp_read_gen5.msg_type); } else { format (file, " (%d, %d, %d)", inst->bits3.dp_read.binding_table_index, inst->bits3.dp_read.msg_control, inst->bits3.dp_read.msg_type); } break; case BRW_MESSAGE_TARGET_DATAPORT_WRITE: if (gen >= 6) { format (file, " ("); err |= control (file, "DP rc message type", dp_rc_msg_type_gen6, inst->bits3.gen6_dp.msg_type, &space); format (file, ", %d, %d, %d, %d, %d, %d)", inst->bits3.gen6_dp.binding_table_index, inst->bits3.gen6_dp.msg_control, inst->bits3.gen6_dp.msg_type, inst->bits3.gen6_dp.send_commit_msg, inst->bits3.gen6_dp.msg_length, inst->bits3.gen6_dp.response_length); } else { format (file, " (%d, %d, %d, %d)", inst->bits3.dp_write.binding_table_index, (inst->bits3.dp_write.pixel_scoreboard_clear << 3) | inst->bits3.dp_write.msg_control, inst->bits3.dp_write.msg_type, inst->bits3.dp_write.send_commit_msg); } break; case BRW_MESSAGE_TARGET_URB: if (gen >= 5) { format (file, " %d", inst->bits3.urb_gen5.offset); } else { format (file, " %d", inst->bits3.urb.offset); } space = 1; if (gen >= 5) { err |= control (file, "urb opcode", urb_opcode, inst->bits3.urb_gen5.opcode, &space); } err |= control (file, "urb swizzle", urb_swizzle, inst->bits3.urb.swizzle_control, &space); err |= control (file, "urb allocate", urb_allocate, inst->bits3.urb.allocate, &space); err |= control (file, "urb used", urb_used, inst->bits3.urb.used, &space); err |= control (file, "urb complete", urb_complete, inst->bits3.urb.complete, &space); if (gen >= 5) { format (file, " mlen %d, rlen %d\n", inst->bits3.urb_gen5.msg_length, inst->bits3.urb_gen5.response_length); } break; case BRW_MESSAGE_TARGET_THREAD_SPAWNER: break; default: format (file, "unsupported target %d", target); break; } if (space) string (file, " "); if (gen >= 5) { format (file, "mlen %d", inst->bits3.generic_gen5.msg_length); format (file, " rlen %d", inst->bits3.generic_gen5.response_length); } else { format (file, "mlen %d", inst->bits3.generic.msg_length); format (file, " rlen %d", inst->bits3.generic.response_length); } } pad (file, 64); if (inst->header.opcode != BRW_OPCODE_NOP) { string (file, "{"); space = 1; err |= control(file, "access mode", access_mode, inst->header.access_mode, &space); if (gen >= 6) err |= control (file, "write enable control", wectrl, inst->header.mask_control, &space); else err |= control (file, "mask control", mask_ctrl, inst->header.mask_control, &space); err |= control (file, "dependency control", dep_ctrl, inst->header.dependency_control, &space); if (gen >= 6) err |= qtr_ctrl (file, inst); else { if (inst->header.compression_control == BRW_COMPRESSION_COMPRESSED && opcode[inst->header.opcode].ndst > 0 && inst->bits1.da1.dest_reg_file == BRW_MESSAGE_REGISTER_FILE && inst->bits1.da1.dest_reg_nr & (1 << 7)) { format (file, " compr4"); } else { err |= control (file, "compression control", compr_ctrl, inst->header.compression_control, &space); } } err |= control (file, "thread control", thread_ctrl, inst->header.thread_control, &space); if (gen >= 6) err |= control (file, "acc write control", accwr, inst->header.acc_wr_control, &space); if (inst->header.opcode == BRW_OPCODE_SEND || inst->header.opcode == BRW_OPCODE_SENDC) err |= control (file, "end of thread", end_of_thread, inst->bits3.generic.end_of_thread, &space); if (space) string (file, " "); string (file, "}"); } string (file, ";"); newline (file); return err; }
int brw_disasm (FILE *file, struct brw_instruction *inst) { int err = 0; int space = 0; if (inst->header.predicate_control) { string (file, "("); err |= control (file, "predicate inverse", pred_inv, inst->header.predicate_inverse, NULL); string (file, "f0"); if (inst->bits2.da1.flag_reg_nr) format (file, ".%d", inst->bits2.da1.flag_reg_nr); if (inst->header.access_mode == BRW_ALIGN_1) err |= control (file, "predicate control align1", pred_ctrl_align1, inst->header.predicate_control, NULL); else err |= control (file, "predicate control align16", pred_ctrl_align16, inst->header.predicate_control, NULL); string (file, ") "); } err |= print_opcode (file, inst->header.opcode); err |= control (file, "saturate", saturate, inst->header.saturate, NULL); err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL); if (inst->header.opcode != BRW_OPCODE_SEND) err |= control (file, "conditional modifier", conditional_modifier, inst->header.destreg__conditionalmod, NULL); if (inst->header.opcode != BRW_OPCODE_NOP) { string (file, "("); err |= control (file, "execution size", exec_size, inst->header.execution_size, NULL); string (file, ")"); } if (inst->header.opcode == BRW_OPCODE_SEND) format (file, " %d", inst->header.destreg__conditionalmod); if (opcode[inst->header.opcode].ndst > 0) { pad (file, 16); err |= dest (file, inst); } if (opcode[inst->header.opcode].nsrc > 0) { pad (file, 32); err |= src0 (file, inst); } if (opcode[inst->header.opcode].nsrc > 1) { pad (file, 48); err |= src1 (file, inst); } if (inst->header.opcode == BRW_OPCODE_SEND) { newline (file); pad (file, 16); space = 0; err |= control (file, "target function", target_function, inst->bits3.generic.msg_target, &space); switch (inst->bits3.generic.msg_target) { case BRW_MESSAGE_TARGET_MATH: err |= control (file, "math function", math_function, inst->bits3.math.function, &space); err |= control (file, "math saturate", math_saturate, inst->bits3.math.saturate, &space); err |= control (file, "math signed", math_signed, inst->bits3.math.int_type, &space); err |= control (file, "math scalar", math_scalar, inst->bits3.math.data_type, &space); err |= control (file, "math precision", math_precision, inst->bits3.math.precision, &space); break; case BRW_MESSAGE_TARGET_SAMPLER: format (file, " (%d, %d, ", inst->bits3.sampler.binding_table_index, inst->bits3.sampler.sampler); err |= control (file, "sampler target format", sampler_target_format, inst->bits3.sampler.return_format, NULL); string (file, ")"); break; case BRW_MESSAGE_TARGET_DATAPORT_WRITE: format (file, " (%d, %d, %d, %d)", inst->bits3.dp_write.binding_table_index, (inst->bits3.dp_write.pixel_scoreboard_clear << 3) | inst->bits3.dp_write.msg_control, inst->bits3.dp_write.msg_type, inst->bits3.dp_write.send_commit_msg); break; case BRW_MESSAGE_TARGET_URB: format (file, " %d", inst->bits3.urb.offset); space = 1; err |= control (file, "urb swizzle", urb_swizzle, inst->bits3.urb.swizzle_control, &space); err |= control (file, "urb allocate", urb_allocate, inst->bits3.urb.allocate, &space); err |= control (file, "urb used", urb_used, inst->bits3.urb.used, &space); err |= control (file, "urb complete", urb_complete, inst->bits3.urb.complete, &space); break; case BRW_MESSAGE_TARGET_THREAD_SPAWNER: break; default: format (file, "unsupported target %d", inst->bits3.generic.msg_target); break; } if (space) string (file, " "); format (file, "mlen %d", inst->bits3.generic.msg_length); format (file, " rlen %d", inst->bits3.generic.response_length); } pad (file, 64); if (inst->header.opcode != BRW_OPCODE_NOP) { string (file, "{"); space = 1; err |= control(file, "access mode", access_mode, inst->header.access_mode, &space); err |= control (file, "mask control", mask_ctrl, inst->header.mask_control, &space); err |= control (file, "dependency control", dep_ctrl, inst->header.dependency_control, &space); err |= control (file, "compression control", compr_ctrl, inst->header.compression_control, &space); err |= control (file, "thread control", thread_ctrl, inst->header.thread_control, &space); if (inst->header.opcode == BRW_OPCODE_SEND) err |= control (file, "end of thread", end_of_thread, inst->bits3.generic.end_of_thread, &space); if (space) string (file, " "); string (file, "}"); } string (file, ";"); newline (file); return err; }
void compareTrkCorrPt_pp( TString outdir="fig" ) { TH1::SetDefaultSumw2(); gSystem->mkdir(outdir,kTRUE); float xmin=1,xmax=179.9; TString title="pp"; TString reftitle="PbPb"; const bool SaveFile=kTRUE ; ///////////////////////////////////////////////////////////////////////////////////// // Load Histograms ///////////////////////////////////////////////////////////////////////////////////// // HiForest * cpp = new HiForest("/net/hisrv0001/home/zhukova/scratch/HIHighPt/forest/pthat200/mergedFile.root","forest",1); HiForest * cpp = new HiForest("/mnt/hadoop/cms/store/user/dgulhan/ppHiIterativeTrack/P01/prod24/Signal_Pythia_pt80/HiForest_v84_merged01/pt80_JEC_ppHiIterativeTrack_P01_prod24_v84_merged_forest_0.root","forest",1); cpp->doTrackCorrections = true; cpp->doTrackingSeparateLeadingSubleading = false; cpp->InitTree(); TrackingCorrections * trkCorr = cpp->trackCorrections[0]; HiForest * cref = new HiForest("/net/hidsk0001/d00/scratch/yjlee/merge/v27/pthat200/Dijet200_HydjetDrum_v28_mergedV1.root","forestref",0); cref->doTrackCorrections = true; cref->doTrackingSeparateLeadingSubleading = false; cref->InitTree(); TrackingCorrections * trkCorrRef = cref->trackCorrections[0]; cout << endl << "========= plot =========" << endl; Int_t etaPM=5.; // 7+2,-3 for |eta|<1.2, 7+5,-6 for full eta Float_t jetPtMin=0; Float_t jetPtMax=500; Int_t jetBegBin = trkCorr->jetBin_->FindBin(jetPtMin); // Int_t jetEndBin = trkCorr->numJEtBins_; Int_t jetEndBin = trkCorr->jetBin_->FindBin(jetPtMax);; cout << Form("jet pt %.0f bin: ",jetPtMin) << jetBegBin << " to " << jetEndBin << endl; cout << "========================" << endl; string infpath=trkCorr->sample_[0]->GetName(); TString src0=infpath.substr(infpath.find_last_of('/')+1); TString src =src0(src0.First("Trk")+12,13); cout <<" src =" <<src <<endl ; // src.ReplaceAll(".root",""); TString tag = src+"_"+trkCorr->trkCorrModule_+Form("_vs_Pt_%s_%s_jet%.0f_%.0f_ieta%d_wts%d",title.Data(),reftitle.Data(),jetPtMin,jetPtMax, etaPM,trkCorr->weightSamples_); // TString tag = trkCorr->trkCorrModule_+Form("_vs_Pt_%s_%s_jet%.0f_ieta%d_wts%d",title.Data(),reftitle.Data(),jetPtMin,etaPM,trkCorr->weightSamples_); // Get Eff/fake histograms int numCentBin=trkCorr->numCentBins_; int numCentBinRef=trkCorrRef->numCentBins_; cout <<"ppncen=" << numCentBin <<" ncen=" << numCentBinRef <<endl ; TH1D * vhCorrPtRef[2][5], *vhCorrPt[2][5]; Int_t colors[10] = {kBlack,kRed,kYellow+2,kGreen+2,kBlue}; Int_t styles[2] = {kFullCircle,kOpenCircle}; int icent=0; // int icentRef=numCentBinRef-1; for (Int_t lv=0; lv<2; ++lv) { for (Int_t c=0; c<numCentBin; ++c) { vhCorrPt[lv][c] = (TH1D*) trkCorr->InspectCorr(lv,c,c,jetBegBin,jetEndBin,2,7-etaPM-1,7+etaPM); handsomeTH1(vhCorrPt[lv][c],kBlue,1,kOpenCircle); vhCorrPt[lv][icent]->SetAxisRange(xmin,xmax,"X"); vhCorrPt[lv][icent]->SetAxisRange(0,1,"Y"); } for (Int_t c=0; c<numCentBinRef; ++c) { vhCorrPtRef[lv][c] = (TH1D*) trkCorrRef->InspectCorr(lv,c,c,jetBegBin,jetEndBin,2,7-etaPM-1,7+etaPM); handsomeTH1(vhCorrPtRef[lv][c],colors[c]); vhCorrPtRef[lv][icent]->SetAxisRange(xmin,xmax,"X"); vhCorrPtRef[lv][icent]->SetAxisRange(0,1,"Y"); } } TCanvas * cEff = new TCanvas("cEff","cEff",500,500); cEff->SetLogx(); vhCorrPt[0][icent]->SetTitle(";Track p_{T} (GeV/c);A #times #epsilon"); vhCorrPt[0][icent]->SetTitleOffset(1.2); vhCorrPt[0][icent]->SetTitleSize(0.055); vhCorrPt[0][icent]->Draw("E"); vhCorrPt[1][icent]->Draw("sameE"); vhCorrPtRef[0][0]->Draw("sameE"); vhCorrPtRef[1][0]->Draw("sameE"); for (Int_t c=0; c<numCentBinRef; ++c) { vhCorrPtRef[0][c]->Draw("sameE"); vhCorrPtRef[1][c]->Draw("sameE"); } TLegend *leg0 = new TLegend(0.16,0.84,0.46,0.92); leg0->SetFillStyle(0); leg0->SetBorderSize(0); leg0->SetTextSize(0.04); leg0->AddEntry(vhCorrPt[0][0],"PYTHIA+HYDJET",""); if (etaPM==5) leg0->AddEntry(vhCorrPt[0][0],Form("Track |#eta|<2.4"),""); if (etaPM==2) leg0->AddEntry(vhCorrPt[0][0],Form("Track |#eta|<1.2"),""); leg0->Draw(); TLine * l = new TLine(xmin,1,xmax,1); l->SetLineStyle(2); l->Draw(); TLegend *leg = new TLegend(0.34,0.32,0.60,0.48); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextSize(0.035); leg->AddEntry(vhCorrPt[0][icent],title,"p"); if (numCentBinRef==2) { leg->AddEntry(vhCorrPtRef[0][0],reftitle+ "0-30%","p"); leg->AddEntry(vhCorrPtRef[0][1],reftitle+ "30-100%","p"); } else { leg->AddEntry(vhCorrPtRef[0][0],reftitle+ "0-10%","p"); leg->AddEntry(vhCorrPtRef[0][1],reftitle+ "10-30%","p"); leg->AddEntry(vhCorrPtRef[0][2],reftitle+ "30-50%","p"); leg->AddEntry(vhCorrPtRef[0][3],reftitle+ "50-100%","p"); } leg->Draw(); drawText("CMS Simulation",0.64,0.89); drawText("Fake Rate",0.69,0.26); cEff->Print(outdir+"/"+tag+".gif"); cEff->Print(outdir+"/"+tag+".pdf"); TCanvas * cJet = new TCanvas("cJet","cJet",500,500); cJet->SetLogy(); trkCorr->vhPtHat[1][icent]->Draw("E"); for (Int_t c=0; c<numCentBinRef; ++c) { trkCorrRef->vhPtHat[1][c]->SetMarkerColor(kRed+c); trkCorrRef->vhPtHat[1][c]->SetMarkerStyle(kOpenCircle+c); trkCorrRef->vhPtHat[1][c]->Draw("same E"); } TCanvas * cCent = new TCanvas("cCent","cCent",500,500); TH1D * hCent = (TH1D*)trkCorr->sample_[0]->Get("hCent"); TH1D * hCentRef = (TH1D*)trkCorrRef->sample_[0]->Get("hCent"); hCentRef->SetMarkerStyle(kOpenCircle); hCentRef->Scale(1./hCentRef->GetEntries()); hCent->Scale(1./hCent->GetEntries()); hCent->Draw("p"); hCentRef->Draw("same p"); if(SaveFile){ TFile * outf = new TFile(Form("%s/%sTrkEffFake.root", outdir.Data(),tag.Data()), "CREATE"); for (Int_t lv=0; lv<2; ++lv) { vhCorrPt[lv][icent]->Write(); for (Int_t c=numCentBinRef-1; c>=0; --c) { vhCorrPtRef[lv][c]->Write(); } } outf->Close(); } }
static void ocl_cvMoments( const void* array, CvMoments* mom, int binary ) { const int TILE_SIZE = 256; int type, depth, cn, coi = 0; CvMat stub, *mat = (CvMat*)array; CvContour contourHeader; CvSeq* contour = 0; CvSeqBlock block; if( CV_IS_SEQ( array )) { contour = (CvSeq*)array; if( !CV_IS_SEQ_POINT_SET( contour )) CV_Error( CV_StsBadArg, "The passed sequence is not a valid contour" ); } if( !moments ) CV_Error( CV_StsNullPtr, "" ); memset( mom, 0, sizeof(*mom)); if( !contour ) { mat = cvGetMat( mat, &stub, &coi ); type = CV_MAT_TYPE( mat->type ); if( type == CV_32SC2 || type == CV_32FC2 ) { contour = cvPointSeqFromMat( CV_SEQ_KIND_CURVE | CV_SEQ_FLAG_CLOSED, mat, &contourHeader, &block ); } } if( contour ) { icvContourMoments( contour, mom ); return; } type = CV_MAT_TYPE( mat->type ); depth = CV_MAT_DEPTH( type ); cn = CV_MAT_CN( type ); cv::Size size = cvGetMatSize( mat ); if( cn > 1 && coi == 0 ) CV_Error( CV_StsBadArg, "Invalid image type" ); if( size.width <= 0 || size.height <= 0 ) return; cv::Mat src0(mat); cv::ocl::oclMat src(src0); cv::Size tileSize; int blockx,blocky; if(size.width%TILE_SIZE == 0) blockx = size.width/TILE_SIZE; else blockx = size.width/TILE_SIZE + 1; if(size.height%TILE_SIZE == 0) blocky = size.height/TILE_SIZE; else blocky = size.height/TILE_SIZE + 1; cv::ocl::oclMat dst_m(blocky * 10, blockx, CV_64FC1); cl_mem sum = openCLCreateBuffer(src.clCxt,CL_MEM_READ_WRITE,10*sizeof(double)); int tile_width = std::min(size.width,TILE_SIZE); int tile_height = std::min(size.height,TILE_SIZE); size_t localThreads[3] = { tile_height, 1, 1}; size_t globalThreads[3] = { size.height, blockx, 1}; std::vector<std::pair<size_t , const void *> > args,args_sum; args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&src.data )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&tileSize.width )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&tileSize.height )); args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst_m.data )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.cols )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.step )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&blocky )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&type )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&depth )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cn )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&coi )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&binary )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&TILE_SIZE )); openCLExecuteKernel(dst_m.clCxt, &moments, "CvMoments", globalThreads, localThreads, args, -1, depth); size_t localThreadss[3] = { 128, 1, 1}; size_t globalThreadss[3] = { 128, 1, 1}; args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&tile_height )); args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&tile_width )); args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&TILE_SIZE )); args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sum )); args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst_m.data )); args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.step )); openCLExecuteKernel(dst_m.clCxt, &moments, "dst_sum", globalThreadss, localThreadss, args_sum, -1, -1); double* dstsum = new double[10]; memset(dstsum,0,10*sizeof(double)); openCLReadBuffer(dst_m.clCxt,sum,(void *)dstsum,10*sizeof(double)); mom->m00 = dstsum[0]; mom->m10 = dstsum[1]; mom->m01 = dstsum[2]; mom->m20 = dstsum[3]; mom->m11 = dstsum[4]; mom->m02 = dstsum[5]; mom->m30 = dstsum[6]; mom->m21 = dstsum[7]; mom->m12 = dstsum[8]; mom->m03 = dstsum[9]; delete [] dstsum; icvCompleteMomentState( mom ); }