int updateLookupTable(unsigned char *rgbframe, short **lookup_table, int *max_index, short *top_left_x, short *top_left_y, short *object_width, short *object_height, int num_objects, int width, int bin_size, int bins_per_color) { int i; int row, col; for (i = 0; i < num_objects; i++) { for( row = 0; row < object_height[i]; row++ ) { for ( col = 0; col < object_width[i]; col++ ) { int index = findBin(rgbframe[(width * (row + top_left_y[i]) + (col + top_left_x[i])) * 3 + 2], rgbframe[(width * (row + top_left_y[i]) + (col + top_left_x[i])) * 3 + 1], rgbframe[(width * (row + top_left_y[i]) + (col + top_left_x[i])) * 3], bin_size, bins_per_color); if((*lookup_table)[index] == 0) { (*lookup_table)[index] = (*max_index); (*max_index) ++; } } } } return 0; }
/* construct the nd dimensional histogram */ void histcND( double* h, double* A, double* wtMask, int n, int nd, double**edges, int* nBins ) { int i, j, k, inbounds; int *subMul, *sub, ind; sub = (int *) mxMalloc( nd * sizeof(int) ); subMul = sub2ind_init( nBins, nd ); for( i=0; i < n; i++) { inbounds = 1; for( j=0; j < nd; j++) { sub[j] = findBin( A[ n*j+i ], edges[j], nBins[j] ); if(sub[j]==nBins[j]) { inbounds=0; break; } } if( inbounds ) { sub2ind(ind, sub, subMul, nd); h[ ind ] += wtMask[i]; } } mxFree( sub ); mxFree( subMul ); }
float SimpleJetCorrectionUncertainty::uncertaintyBin(unsigned fBin, float fY, bool fDirection) const { if (fBin >= mParameters->size()) //throw cms::Exception("SimpleJetCorrectionUncertainty")<<" wrong bin: "<<fBin<<": only "<<mParameters->size()<<" are available"; handleError("SimpleJetCorrectionUncertainty"," wrong bin"); const std::vector<float>& p = mParameters->record(fBin).parameters(); if ((p.size() % 3) != 0) //throw cms::Exception ("SimpleJetCorrectionUncertainty")<<"wrong # of parameters: multiple of 3 expected, "<<p.size()<< " got"; handleError("SimpleJetCorrectionUncertainty"," wrong # of parameters: multiple of 3 expected"); std::vector<float> yGrid,value; unsigned int N = p.size()/3; float result = -1.0; for(unsigned i=0;i<N;i++) { unsigned ind = 3*i; yGrid.push_back(p[ind]); if (fDirection)// true = UP value.push_back(p[ind+1]); else // false = DOWN value.push_back(p[ind+2]); } if (fY <= yGrid[0]) result = value[0]; else if (fY >= yGrid[N-1]) result = value[N-1]; else { int bin = findBin(yGrid,fY); float vx[2],vy[2]; for(int i=0;i<2;i++) { vx[i] = yGrid[bin+i]; vy[i] = value[bin+i]; } result = linearInterpolation(fY,vx,vy); } return result; }
void RAA_plot_jeidvariables_OneSetPlots(){ TH1::SetDefaultSumw2(); gStyle->SetOptStat(0); TFile * fData = TFile::Open("/export/d00/scratch/rkunnawa/rootfiles/PbPb_Data_calo_pf_jet_correlation_deltaR_0p2_akPu3_20150320.root"); TTree * Data_matched = (TTree*)fData->Get("matchedJets"); TTree * Data_unmatched = (TTree*)fData->Get("unmatchedPFJets"); TFile * fMC = TFile::Open("/export/d00/scratch/rkunnawa/rootfiles/PbPb_MC_calo_pf_jet_correlation_deltaR_0p2_akPu3_20150326.root"); TTree * MC_matched = (TTree*)fMC->Get("matchedJets"); TTree * MC_unmatched = (TTree*)fMC->Get("unmatchedPFJets"); const int nbins_cent = 6; const int boundaries_cent[nbins_cent+1] = {0,2,4,12,20,28,36}; int centrality_bins[nbins_cent+1] = {0,5,10,30,50,70,90}; float pfptmin = 50; TH1F * hData_chMaxJtpt[nbins_cent], * hData_phMaxJtpt[nbins_cent], * hData_neMaxJtpt[nbins_cent], * hData_muMaxJtpt[nbins_cent], * hData_eMaxJtpt[nbins_cent]; TH1F * hData_chSumJtpt[nbins_cent], * hData_phSumJtpt[nbins_cent], * hData_neSumJtpt[nbins_cent], * hData_muSumJtpt[nbins_cent], * hData_eSumJtpt[nbins_cent]; TH1F * hMC_chMaxJtpt[nbins_cent], * hMC_phMaxJtpt[nbins_cent], * hMC_neMaxJtpt[nbins_cent], * hMC_muMaxJtpt[nbins_cent], * hMC_eMaxJtpt[nbins_cent]; TH1F * hMC_chSumJtpt[nbins_cent], * hMC_phSumJtpt[nbins_cent], * hMC_neSumJtpt[nbins_cent], * hMC_muSumJtpt[nbins_cent], * hMC_eSumJtpt[nbins_cent]; TH1F * hData_chMaxJtpt_keep[nbins_cent], * hData_phMaxJtpt_keep[nbins_cent], * hData_neMaxJtpt_keep[nbins_cent], * hData_muMaxJtpt_keep[nbins_cent], * hData_eMaxJtpt_keep[nbins_cent]; TH1F * hData_chSumJtpt_keep[nbins_cent], * hData_phSumJtpt_keep[nbins_cent], * hData_neSumJtpt_keep[nbins_cent], * hData_muSumJtpt_keep[nbins_cent], * hData_eSumJtpt_keep[nbins_cent]; TH1F * hMC_chMaxJtpt_keep[nbins_cent], * hMC_phMaxJtpt_keep[nbins_cent], * hMC_neMaxJtpt_keep[nbins_cent], * hMC_muMaxJtpt_keep[nbins_cent], * hMC_eMaxJtpt_keep[nbins_cent]; TH1F * hMC_chSumJtpt_keep[nbins_cent], * hMC_phSumJtpt_keep[nbins_cent], * hMC_neSumJtpt_keep[nbins_cent], * hMC_muSumJtpt_keep[nbins_cent], * hMC_eSumJtpt_keep[nbins_cent]; TH1F * hData_chMaxJtpt_rej[nbins_cent], * hData_phMaxJtpt_rej[nbins_cent], * hData_neMaxJtpt_rej[nbins_cent], * hData_muMaxJtpt_rej[nbins_cent], * hData_eMaxJtpt_rej[nbins_cent]; TH1F * hData_chSumJtpt_rej[nbins_cent], * hData_phSumJtpt_rej[nbins_cent], * hData_neSumJtpt_rej[nbins_cent], * hData_muSumJtpt_rej[nbins_cent], * hData_eSumJtpt_rej[nbins_cent]; TH1F * hMC_chMaxJtpt_rej[nbins_cent], * hMC_phMaxJtpt_rej[nbins_cent], * hMC_neMaxJtpt_rej[nbins_cent], * hMC_muMaxJtpt_rej[nbins_cent], * hMC_eMaxJtpt_rej[nbins_cent]; TH1F * hMC_chSumJtpt_rej[nbins_cent], * hMC_phSumJtpt_rej[nbins_cent], * hMC_neSumJtpt_rej[nbins_cent], * hMC_muSumJtpt_rej[nbins_cent], * hMC_eSumJtpt_rej[nbins_cent]; for(int i = 0 ; i < nbins_cent ; ++i){ hData_chMaxJtpt[i] = new TH1F(Form("hData_chMaxJtpt_cent%d",i),Form("Data chMax/jtpt in centrality bin %d",i),100,0,1); hMC_chMaxJtpt[i] = new TH1F(Form("hMC_chMaxJtpt_cent%d",i),Form("MC chMax/jtpt in centrality bin ",i),100,0,1); hData_chSumJtpt[i] = new TH1F(Form("hData_chSumJtpt_cent%d",i),Form("Data chSum/jtpt in centrality bin %d",i),100,0,3); hMC_chSumJtpt[i] = new TH1F(Form("hMC_chSumJtpt_cent%d",i),Form("MC chSum/jtpt in centrality bin ",i),100,0,3); hData_eMaxJtpt[i] = new TH1F(Form("hData_eMaxJtpt_cent%d",i),Form("Data eMax/jtpt in centrality bin %d",i),100,0,1); hMC_eMaxJtpt[i] = new TH1F(Form("hMC_eMaxJtpt_cent%d",i),Form("MC eMax/jtpt in centrality bin ",i),100,0,1); hData_eSumJtpt[i] = new TH1F(Form("hData_eSumJtpt_cent%d",i),Form("Data eSum/jtpt in centrality bin %d",i),100,0,1.5); hMC_eSumJtpt[i] = new TH1F(Form("hMC_eSumJtpt_cent%d",i),Form("MC eSum/jtpt in centrality bin ",i),100,0,1.5); hData_neMaxJtpt[i] = new TH1F(Form("hData_neMaxJtpt_cent%d",i),Form("Data neMax/jtpt in centrality bin %d",i),100,0,1); hMC_neMaxJtpt[i] = new TH1F(Form("hMC_neMaxJtpt_cent%d",i),Form("MC neMax/jtpt in centrality bin ",i),100,0,1); hData_neSumJtpt[i] = new TH1F(Form("hData_neSumJtpt_cent%d",i),Form("Data neSum/jtpt in centrality bin %d",i),100,0,1.5); hMC_neSumJtpt[i] = new TH1F(Form("hMC_neSumJtpt_cent%d",i),Form("MC neSum/jtpt in centrality bin ",i),100,0,1.5); hData_phMaxJtpt[i] = new TH1F(Form("hData_phMaxJtpt_cent%d",i),Form("Data phMax/jtpt in centrality bin %d",i),100,0,1); hMC_phMaxJtpt[i] = new TH1F(Form("hMC_phMaxJtpt_cent%d",i),Form("MC phMax/jtpt in centrality bin ",i),100,0,1); hData_phSumJtpt[i] = new TH1F(Form("hData_phSumJtpt_cent%d",i),Form("Data phSum/jtpt in centrality bin %d",i),100,0,1); hMC_phSumJtpt[i] = new TH1F(Form("hMC_phSumJtpt_cent%d",i),Form("MC phSum/jtpt in centrality bin ",i),100,0,1); hData_muMaxJtpt[i] = new TH1F(Form("hData_muMaxJtpt_cent%d",i),Form("Data muMax/jtpt in centrality bin %d",i),100,0,1); hMC_muMaxJtpt[i] = new TH1F(Form("hMC_muMaxJtpt_cent%d",i),Form("MC muMax/jtpt in centrality bin ",i),100,0,1); hData_muSumJtpt[i] = new TH1F(Form("hData_muSumJtpt_cent%d",i),Form("Data muSum/jtpt in centrality bin %d",i),100,0,1); hMC_muSumJtpt[i] = new TH1F(Form("hMC_muSumJtpt_cent%d",i),Form("MC muSum/jtpt in centrality bin ",i),100,0,1); hData_chMaxJtpt_keep[i] = new TH1F(Form("hData_chMaxJtpt_keep_cent%d",i),Form("Data chMax/Jtpt pass cutA in centrality bin %d",i),100,0,1); hMC_chMaxJtpt_keep[i] = new TH1F(Form("hMC_chMaxJtpt_keep_cent%d",i),Form("MC chMax/Jtpt pass cutA in centrality bin ",i),100,0,1); hData_chSumJtpt_keep[i] = new TH1F(Form("hData_chSumJtpt_keep_cent%d",i),Form("Data chSum/Jtpt pass cutA in centrality bin %d",i),100,0,3); hMC_chSumJtpt_keep[i] = new TH1F(Form("hMC_chSumJtpt_keep_cent%d",i),Form("MC chSum/Jtpt pass cutA in centrality bin ",i),100,0,3); hData_eMaxJtpt_keep[i] = new TH1F(Form("hData_eMaxJtpt_keep_cent%d",i),Form("Data eMax/Jtpt pass cutA in centrality bin %d",i),100,0,1); hMC_eMaxJtpt_keep[i] = new TH1F(Form("hMC_eMaxJtpt_keep_cent%d",i),Form("MC eMax/Jtpt pass cutA in centrality bin ",i),100,0,1); hData_eSumJtpt_keep[i] = new TH1F(Form("hData_eSumJtpt_keep_cent%d",i),Form("Data eSum/Jtpt pass cutA in centrality bin %d",i),100,0,1.5); hMC_eSumJtpt_keep[i] = new TH1F(Form("hMC_eSumJtpt_keep_cent%d",i),Form("MC eSum/Jtpt pass cutA in centrality bin ",i),100,0,1.5); hData_neMaxJtpt_keep[i] = new TH1F(Form("hData_neMaxJtpt_keep_cent%d",i),Form("Data neMax/Jtpt pass cutA in centrality bin %d",i),100,0,1); hMC_neMaxJtpt_keep[i] = new TH1F(Form("hMC_neMaxJtpt_keep_cent%d",i),Form("MC neMax/Jtpt pass cutA in centrality bin ",i),100,0,1); hData_neSumJtpt_keep[i] = new TH1F(Form("hData_neSumJtpt_keep_cent%d",i),Form("Data neSum/Jtpt pass cutA in centrality bin %d",i),100,0,1.5); hMC_neSumJtpt_keep[i] = new TH1F(Form("hMC_neSumJtpt_keep_cent%d",i),Form("MC neSum/Jtpt pass cutA in centrality bin ",i),100,0,1.5); hData_phMaxJtpt_keep[i] = new TH1F(Form("hData_phMaxJtpt_keep_cent%d",i),Form("Data phMax/Jtpt pass cutA in centrality bin %d",i),100,0,1); hMC_phMaxJtpt_keep[i] = new TH1F(Form("hMC_phMaxJtpt_keep_cent%d",i),Form("MC phMax/Jtpt pass cutA in centrality bin ",i),100,0,1); hData_phSumJtpt_keep[i] = new TH1F(Form("hData_phSumJtpt_keep_cent%d",i),Form("Data phSum/Jtpt pass cutA in centrality bin %d",i),100,0,1); hMC_phSumJtpt_keep[i] = new TH1F(Form("hMC_phSumJtpt_keep_cent%d",i),Form("MC phSum/Jtpt pass cutA in centrality bin ",i),100,0,1); hData_muMaxJtpt_keep[i] = new TH1F(Form("hData_muMaxJtpt_keep_cent%d",i),Form("Data muMax/Jtpt pass cutA in centrality bin %d",i),100,0,1); hMC_muMaxJtpt_keep[i] = new TH1F(Form("hMC_muMaxJtpt_keep_cent%d",i),Form("MC muMax/Jtpt pass cutA in centrality bin ",i),100,0,1); hData_muSumJtpt_keep[i] = new TH1F(Form("hData_muSumJtpt_keep_cent%d",i),Form("Data muSum/Jtpt pass cutA in centrality bin %d",i),100,0,1); hMC_muSumJtpt_keep[i] = new TH1F(Form("hMC_muSumJtpt_keep_cent%d",i),Form("MC muSum/Jtpt pass cutA in centrality bin ",i),100,0,1); hData_chMaxJtpt_rej[i] = new TH1F(Form("hData_chMaxJtpt_rej_cent%d",i),Form("Data chMax/Jtpt fail cutA in centrality bin %d",i),100,0,1); hMC_chMaxJtpt_rej[i] = new TH1F(Form("hMC_chMaxJtpt_rej_cent%d",i),Form("MC chMax/Jtpt fail cutA in centrality bin ",i),100,0,1); hData_chSumJtpt_rej[i] = new TH1F(Form("hData_chSumJtpt_rej_cent%d",i),Form("Data chSum/Jtpt fail cutA in centrality bin %d",i),100,0,3); hMC_chSumJtpt_rej[i] = new TH1F(Form("hMC_chSumJtpt_rej_cent%d",i),Form("MC chSum/Jtpt fail cutA in centrality bin ",i),100,0,3); hData_eMaxJtpt_rej[i] = new TH1F(Form("hData_eMaxJtpt_rej_cent%d",i),Form("Data eMax/Jtpt fail cutA in centrality bin %d",i),100,0,1); hMC_eMaxJtpt_rej[i] = new TH1F(Form("hMC_eMaxJtpt_rej_cent%d",i),Form("MC eMax/Jtpt fail cutA in centrality bin ",i),100,0,1); hData_eSumJtpt_rej[i] = new TH1F(Form("hData_eSumJtpt_rej_cent%d",i),Form("Data eSum/Jtpt fail cutA in centrality bin %d",i),100,0,1.5); hMC_eSumJtpt_rej[i] = new TH1F(Form("hMC_eSumJtpt_rej_cent%d",i),Form("MC eSum/Jtpt fail cutA in centrality bin ",i),100,0,1.5); hData_neMaxJtpt_rej[i] = new TH1F(Form("hData_neMaxJtpt_rej_cent%d",i),Form("Data neMax/Jtpt fail cutA in centrality bin %d",i),100,0,1); hMC_neMaxJtpt_rej[i] = new TH1F(Form("hMC_neMaxJtpt_rej_cent%d",i),Form("MC neMax/Jtpt fail cutA in centrality bin ",i),100,0,1); hData_neSumJtpt_rej[i] = new TH1F(Form("hData_neSumJtpt_rej_cent%d",i),Form("Data neSum/Jtpt fail cutA in centrality bin %d",i),100,0,1.5); hMC_neSumJtpt_rej[i] = new TH1F(Form("hMC_neSumJtpt_rej_cent%d",i),Form("MC neSum/Jtpt fail cutA in centrality bin ",i),100,0,1.5); hData_phMaxJtpt_rej[i] = new TH1F(Form("hData_phMaxJtpt_rej_cent%d",i),Form("Data phMax/Jtpt fail cutA in centrality bin %d",i),100,0,1); hMC_phMaxJtpt_rej[i] = new TH1F(Form("hMC_phMaxJtpt_rej_cent%d",i),Form("MC phMax/Jtpt fail cutA in centrality bin ",i),100,0,1); hData_phSumJtpt_rej[i] = new TH1F(Form("hData_phSumJtpt_rej_cent%d",i),Form("Data phSum/Jtpt fail cutA in centrality bin %d",i),100,0,1); hMC_phSumJtpt_rej[i] = new TH1F(Form("hMC_phSumJtpt_rej_cent%d",i),Form("MC phSum/Jtpt fail cutA in centrality bin ",i),100,0,1); hData_muMaxJtpt_rej[i] = new TH1F(Form("hData_muMaxJtpt_rej_cent%d",i),Form("Data muMax/Jtpt fail cutA in centrality bin %d",i),100,0,1); hMC_muMaxJtpt_rej[i] = new TH1F(Form("hMC_muMaxJtpt_rej_cent%d",i),Form("MC muMax/Jtpt fail cutA in centrality bin ",i),100,0,1); hData_muSumJtpt_rej[i] = new TH1F(Form("hData_muSumJtpt_rej_cent%d",i),Form("Data muSum/Jtpt fail cutA in centrality bin %d",i),100,0,1); hMC_muSumJtpt_rej[i] = new TH1F(Form("hMC_muSumJtpt_rej_cent%d",i),Form("MC muSum/Jtpt fail cutA in centrality bin ",i),100,0,1); } // 1 - Data, 2 - MC Float_t pfpt_1, pfpt_2; Float_t pfrefpt_2; Float_t calopt_1, calopt_2; Float_t chMax_1, chMax_2; Float_t phMax_1, phMax_2; Float_t neMax_1, neMax_2; Float_t muMax_1, muMax_2; Float_t eMax_1, eMax_2; Float_t chSum_1, chSum_2; Float_t phSum_1, phSum_2; Float_t neSum_1, neSum_2; Float_t muSum_1, muSum_2; Float_t eSum_1, eSum_2; Int_t jet55_1, jet65_1, jet80_1; Int_t jet55_p_1, jet65_p_1, jet80_p_1; Int_t jet55_2, jet65_2, jet80_2; Int_t jet55_p_2, jet65_p_2, jet80_p_2; Int_t hiBin_1, hiBin_2; Float_t weight_2; Data_matched->SetBranchAddress("calopt",&calopt_1); Data_matched->SetBranchAddress("pfpt",&pfpt_1); Data_matched->SetBranchAddress("eMax",&eMax_1); Data_matched->SetBranchAddress("phMax",&phMax_1); Data_matched->SetBranchAddress("muMax",&muMax_1); Data_matched->SetBranchAddress("neMax",&neMax_1); Data_matched->SetBranchAddress("chMax",&chMax_1); Data_matched->SetBranchAddress("chSum",&chSum_1); Data_matched->SetBranchAddress("phSum",&phSum_1); Data_matched->SetBranchAddress("neSum",&neSum_1); Data_matched->SetBranchAddress("muSum",&muSum_1); Data_matched->SetBranchAddress("eSum",&eSum_1); Data_matched->SetBranchAddress("hiBin",&hiBin_1); Data_matched->SetBranchAddress("jet55",&jet55_1); Data_matched->SetBranchAddress("jet65",&jet65_1); Data_matched->SetBranchAddress("jet80",&jet80_1); Data_matched->SetBranchAddress("jet55_prescl",&jet55_p_1); Data_matched->SetBranchAddress("jet65_prescl",&jet65_p_1); Data_matched->SetBranchAddress("jet80_prescl",&jet80_p_1); Data_unmatched->SetBranchAddress("pfpt",&pfpt_1); Data_unmatched->SetBranchAddress("eMax",&eMax_1); Data_unmatched->SetBranchAddress("phMax",&phMax_1); Data_unmatched->SetBranchAddress("muMax",&muMax_1); Data_unmatched->SetBranchAddress("neMax",&neMax_1); Data_unmatched->SetBranchAddress("chMax",&chMax_1); Data_unmatched->SetBranchAddress("chSum",&chSum_1); Data_unmatched->SetBranchAddress("phSum",&phSum_1); Data_unmatched->SetBranchAddress("neSum",&neSum_1); Data_unmatched->SetBranchAddress("muSum",&muSum_1); Data_unmatched->SetBranchAddress("eSum",&eSum_1); Data_unmatched->SetBranchAddress("hiBin",&hiBin_1); Data_unmatched->SetBranchAddress("jet55",&jet55_1); Data_unmatched->SetBranchAddress("jet65",&jet65_1); Data_unmatched->SetBranchAddress("jet80",&jet80_1); Data_unmatched->SetBranchAddress("jet55_prescl",&jet55_p_1); Data_unmatched->SetBranchAddress("jet65_prescl",&jet65_p_1); Data_unmatched->SetBranchAddress("jet80_prescl",&jet80_p_1); MC_matched->SetBranchAddress("calopt",&calopt_2); MC_matched->SetBranchAddress("pfpt",&pfpt_2); MC_matched->SetBranchAddress("eMax",&eMax_2); MC_matched->SetBranchAddress("phMax",&phMax_2); MC_matched->SetBranchAddress("muMax",&muMax_2); MC_matched->SetBranchAddress("neMax",&neMax_2); MC_matched->SetBranchAddress("chMax",&chMax_2); MC_matched->SetBranchAddress("chSum",&chSum_2); MC_matched->SetBranchAddress("phSum",&phSum_2); MC_matched->SetBranchAddress("neSum",&neSum_2); MC_matched->SetBranchAddress("muSum",&muSum_2); MC_matched->SetBranchAddress("eSum",&eSum_2); MC_matched->SetBranchAddress("hiBin",&hiBin_2); MC_matched->SetBranchAddress("weight",&weight_2); MC_matched->SetBranchAddress("pfrefpt",&pfrefpt_2); MC_matched->SetBranchAddress("jet55",&jet55_2); MC_matched->SetBranchAddress("jet65",&jet65_2); MC_matched->SetBranchAddress("jet80",&jet80_2); MC_unmatched->SetBranchAddress("pfpt",&pfpt_2); MC_unmatched->SetBranchAddress("eMax",&eMax_2); MC_unmatched->SetBranchAddress("phMax",&phMax_2); MC_unmatched->SetBranchAddress("muMax",&muMax_2); MC_unmatched->SetBranchAddress("neMax",&neMax_2); MC_unmatched->SetBranchAddress("chMax",&chMax_2); MC_unmatched->SetBranchAddress("chSum",&chSum_2); MC_unmatched->SetBranchAddress("phSum",&phSum_2); MC_unmatched->SetBranchAddress("neSum",&neSum_2); MC_unmatched->SetBranchAddress("muSum",&muSum_2); MC_unmatched->SetBranchAddress("eSum",&eSum_2); MC_unmatched->SetBranchAddress("hiBin",&hiBin_2); MC_unmatched->SetBranchAddress("weight",&weight_2); MC_unmatched->SetBranchAddress("pfrefpt",&pfrefpt_2); MC_unmatched->SetBranchAddress("jet55",&jet55_2); MC_unmatched->SetBranchAddress("jet65",&jet65_2); MC_unmatched->SetBranchAddress("jet80",&jet80_2); // data loop long entries = Data_matched->GetEntries(); //entries = 1; entries = 1000; cout<<"matched Data ntuple: "<<entries<<" entries"<<endl; for(long nentry = 0; nentry < entries; ++nentry){ if(nentry%10000 == 0) cout<<" nentry = "<<nentry<<endl; Data_matched->GetEntry(nentry); if(hiBin_1>=180) continue; int centb1=-1; centb1 = findBin(hiBin_1); Float_t Sumcand = chSum_1 + phSum_1 + neSum_1 + muSum_1; if(pfpt_1>pfptmin){ hData_chMaxJtpt[centb1]->Fill(chMax_1/pfpt_1); hData_eMaxJtpt[centb1]->Fill(eMax_1/pfpt_1); hData_neMaxJtpt[centb1]->Fill(neMax_1/pfpt_1); hData_phMaxJtpt[centb1]->Fill(phMax_1/pfpt_1); hData_muMaxJtpt[centb1]->Fill(muMax_1/pfpt_1); hData_chSumJtpt[centb1]->Fill(chSum_1/pfpt_1); hData_eSumJtpt[centb1]->Fill(eSum_1/pfpt_1); hData_neSumJtpt[centb1]->Fill(neSum_1/pfpt_1); hData_phSumJtpt[centb1]->Fill(phSum_1/pfpt_1); hData_muSumJtpt[centb1]->Fill(muSum_1/pfpt_1); if(calopt_1/pfpt_1 <= 0.5 && eMax_1/Sumcand < 0.05) { hData_chMaxJtpt_keep[centb1]->Fill(chMax_1/pfpt_1); hData_eMaxJtpt_keep[centb1]->Fill(eMax_1/pfpt_1); hData_neMaxJtpt_keep[centb1]->Fill(neMax_1/pfpt_1); hData_phMaxJtpt_keep[centb1]->Fill(phMax_1/pfpt_1); hData_muMaxJtpt_keep[centb1]->Fill(muMax_1/pfpt_1); hData_chSumJtpt_keep[centb1]->Fill(chSum_1/pfpt_1); hData_eSumJtpt_keep[centb1]->Fill(eSum_1/pfpt_1); hData_neSumJtpt_keep[centb1]->Fill(neSum_1/pfpt_1); hData_phSumJtpt_keep[centb1]->Fill(phSum_1/pfpt_1); hData_muSumJtpt_keep[centb1]->Fill(muSum_1/pfpt_1); } if(calopt_1/pfpt_1 > 0.5 && calopt_1/pfpt_1 <= 0.85 && eMax_1/Sumcand < (18/7 *(Float_t)calopt_1/pfpt_1 - 9/7)) ){ hData_chMaxJtpt_keep[centb1]->Fill(chMax_1/pfpt_1); hData_eMaxJtpt_keep[centb1]->Fill(eMax_1/pfpt_1); hData_neMaxJtpt_keep[centb1]->Fill(neMax_1/pfpt_1); hData_phMaxJtpt_keep[centb1]->Fill(phMax_1/pfpt_1); hData_muMaxJtpt_keep[centb1]->Fill(muMax_1/pfpt_1); hData_chSumJtpt_keep[centb1]->Fill(chSum_1/pfpt_1); hData_eSumJtpt_keep[centb1]->Fill(eSum_1/pfpt_1); hData_neSumJtpt_keep[centb1]->Fill(neSum_1/pfpt_1); hData_phSumJtpt_keep[centb1]->Fill(phSum_1/pfpt_1); hData_muSumJtpt_keep[centb1]->Fill(muSum_1/pfpt_1); } if(calopt_1/pfpt_1 > 0.85){ hData_chMaxJtpt_keep[centb1]->Fill(chMax_1/pfpt_1); hData_eMaxJtpt_keep[centb1]->Fill(eMax_1/pfpt_1); hData_neMaxJtpt_keep[centb1]->Fill(neMax_1/pfpt_1); hData_phMaxJtpt_keep[centb1]->Fill(phMax_1/pfpt_1); hData_muMaxJtpt_keep[centb1]->Fill(muMax_1/pfpt_1); hData_chSumJtpt_keep[centb1]->Fill(chSum_1/pfpt_1); hData_eSumJtpt_keep[centb1]->Fill(eSum_1/pfpt_1); hData_neSumJtpt_keep[centb1]->Fill(neSum_1/pfpt_1); hData_phSumJtpt_keep[centb1]->Fill(phSum_1/pfpt_1); hData_muSumJtpt_keep[centb1]->Fill(muSum_1/pfpt_1); } // rejected: if(calopt_1/pfpt_1 > 0.5 && calopt_1/pfpt_1 <= 0.85 && eMax_1/Sumcand >= (18/7 *(Float_t)calopt_1/pfpt_1 - 9/7)) ){ hData_chMaxJtpt_rej[centb1]->Fill(chMax_1/pfpt_1); hData_eMaxJtpt_rej[centb1]->Fill(eMax_1/pfpt_1); hData_neMaxJtpt_rej[centb1]->Fill(neMax_1/pfpt_1); hData_phMaxJtpt_rej[centb1]->Fill(phMax_1/pfpt_1); hData_muMaxJtpt_rej[centb1]->Fill(muMax_1/pfpt_1); hData_chSumJtpt_rej[centb1]->Fill(chSum_1/pfpt_1); hData_eSumJtpt_rej[centb1]->Fill(eSum_1/pfpt_1); hData_neSumJtpt_rej[centb1]->Fill(neSum_1/pfpt_1); hData_phSumJtpt_rej[centb1]->Fill(phSum_1/pfpt_1); hData_muSumJtpt_rej[centb1]->Fill(muSum_1/pfpt_1); } if(calopt_1/pfpt_1 <= 0.5 && eMax_1/Sumcand >= 0.05) { hData_chMaxJtpt_rej[centb1]->Fill(chMax_1/pfpt_1); hData_eMaxJtpt_rej[centb1]->Fill(eMax_1/pfpt_1); hData_neMaxJtpt_rej[centb1]->Fill(neMax_1/pfpt_1); hData_phMaxJtpt_rej[centb1]->Fill(phMax_1/pfpt_1); hData_muMaxJtpt_rej[centb1]->Fill(muMax_1/pfpt_1); hData_chSumJtpt_rej[centb1]->Fill(chSum_1/pfpt_1); hData_eSumJtpt_rej[centb1]->Fill(eSum_1/pfpt_1); hData_neSumJtpt_rej[centb1]->Fill(neSum_1/pfpt_1); hData_phSumJtpt_rej[centb1]->Fill(phSum_1/pfpt_1); hData_muSumJtpt_rej[centb1]->Fill(muSum_1/pfpt_1); } } // end pfptmin loop } // end data matched loop
int update_bins_lut(unsigned char *rgbframe, short **bins, short *lookup_table, int first_index, int last_index, int max_object_size, short *top_left_x, short *top_left_y, short *object_width, short *object_height, char *converged_objects, int *frame_indexes, int num_neighbors, int width, int height, int bin_size, int bins_per_color) { int i; int row, col; int search_distance = (sqrt(num_neighbors)-1)/2; for(i = first_index; i < last_index; i++) { if(converged_objects[i] == 0) { for(row = 0; row < object_height[i] + 2*search_distance; row++) { for(col = 0; col < object_width[i] + 2*search_distance; col++) { (*bins)[i*max_object_size + (object_width[i]+2*search_distance) * row + col] = lookup_table[findBin(rgbframe[frame_indexes[i]*width*height*3 + (width * (row-search_distance + top_left_y[i]) + (col-search_distance + top_left_x[i])) * 3 + 2], rgbframe[frame_indexes[i]*width*height*3 + (width * (row-search_distance + top_left_y[i]) + (col-search_distance + top_left_x[i])) * 3 + 1], rgbframe[frame_indexes[i]*width*height*3 + (width * (row-search_distance + top_left_y[i]) + (col-search_distance + top_left_x[i])) * 3], bin_size, bins_per_color)]; } } } } return 0; }
template<typename PointT, typename NormalT> void pcl::NormalSpaceSampling<PointT, NormalT>::applyFilter (PointCloud &output) { // If sample size is 0 or if the sample size is greater then input cloud size // then return entire copy of cloud if (sample_ >= input_->size ()) { output = *input_; return; } // Resize output cloud to sample size output.points.resize (sample_); output.width = sample_; output.height = 1; // allocate memory for the histogram of normals.. Normals will then be sampled from each bin.. unsigned int n_bins = binsx_ * binsy_ * binsz_; // list<int> holds the indices of points in that bin.. Using list to avoid repeated resizing of vectors.. Helps when the point cloud is // large.. std::vector< std::list <int> > normals_hg; normals_hg.reserve (n_bins); for (unsigned int i = 0; i < n_bins; i++) normals_hg.push_back (std::list<int> ()); for (unsigned int i = 0; i < input_normals_->points.size (); i++) { unsigned int bin_number = findBin (input_normals_->points[i].normal, n_bins); normals_hg[bin_number].push_back (i); } // Setting up random access for the list created above.. Maintaining the iterators to individual elements of the list in a vector.. Using // vector now as the size of the list is known.. std::vector< std::vector <std::list<int>::iterator> > random_access (normals_hg.size ()); for (unsigned int i = 0; i < normals_hg.size (); i++) { random_access.push_back (std::vector< std::list<int>::iterator> ()); random_access[i].resize (normals_hg[i].size ()); unsigned int j=0; for (std::list<int>::iterator itr = normals_hg[i].begin (); itr != normals_hg[i].end (); itr++, j++) { random_access[i][j] = itr; } } unsigned int* start_index = new unsigned int[normals_hg.size ()]; start_index[0] = 0; unsigned int prev_index = start_index[0]; for (unsigned int i = 1; i < normals_hg.size (); i++) { start_index[i] = prev_index + normals_hg[i-1].size (); prev_index = start_index[i]; } // maintaining flags to check if a point is sampled boost::dynamic_bitset<> is_sampled_flag (input_normals_->points.size ()); // maintaining flags to check if all points in the bin are sampled boost::dynamic_bitset<> bin_empty_flag (normals_hg.size ()); unsigned int i = 0; while (i < sample_) { // iterating through every bin and picking one point at random, until the required number of points are sampled.. for (unsigned int j = 0; j < normals_hg.size (); j++) { unsigned int M = normals_hg[j].size (); if (M == 0 || bin_empty_flag.test (j))// bin_empty_flag(i) is set if all points in that bin are sampled.. { continue; } unsigned int pos = 0; unsigned int random_index = 0; //picking up a sample at random from jth bin do { random_index = std::rand () % M; pos = start_index[j] + random_index; } while (is_sampled_flag.test (pos)); is_sampled_flag.flip (start_index[j] + random_index); // checking if all points in bin j are sampled.. if (isEntireBinSampled (is_sampled_flag, start_index[j], normals_hg[j].size ())) { bin_empty_flag.flip (j); } unsigned int index = *(random_access[j][random_index]); output.points[i] = input_->points[index]; i++; if (i == sample_) { break; } } } delete[] start_index; }
void assignToBins( double *B, double* A, double* edges, int n, int nBins ) { int j; for( j=0; j<n; j++ ) B[j]=(double) findBin( A[j], edges, nBins ); }
std::string Binning::findBinStr(const std::vector<float> &v, float x, const char* precision) { int bin= findBin(v,x); if (bin<0) return "NotFound"; return Form(precision, v[bin],v[bin+1]); }
template<typename PointT, typename NormalT> void pcl::NormalSpaceSampling<PointT, NormalT>::applyFilter (std::vector<int> &indices) { if (!initCompute ()) { indices = *indices_; return; } unsigned int max_values = (std::min) (sample_, static_cast<unsigned int> (input_normals_->size ())); // Resize output indices to sample size indices.resize (max_values); removed_indices_->resize (max_values); // Allocate memory for the histogram of normals. Normals will then be sampled from each bin. unsigned int n_bins = binsx_ * binsy_ * binsz_; // list<int> holds the indices of points in that bin. Using list to avoid repeated resizing of vectors. // Helps when the point cloud is large. std::vector<std::list <int> > normals_hg; normals_hg.reserve (n_bins); for (unsigned int i = 0; i < n_bins; i++) normals_hg.emplace_back(); for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it) { unsigned int bin_number = findBin (input_normals_->points[*it].normal, n_bins); normals_hg[bin_number].push_back (*it); } // Setting up random access for the list created above. Maintaining the iterators to individual elements of the list // in a vector. Using vector now as the size of the list is known. std::vector<std::vector<std::list<int>::iterator> > random_access (normals_hg.size ()); for (size_t i = 0; i < normals_hg.size (); i++) { random_access.emplace_back(); random_access[i].resize (normals_hg[i].size ()); size_t j = 0; for (std::list<int>::iterator itr = normals_hg[i].begin (); itr != normals_hg[i].end (); itr++, j++) random_access[i][j] = itr; } std::vector<size_t> start_index (normals_hg.size ()); start_index[0] = 0; size_t prev_index = 0; for (size_t i = 1; i < normals_hg.size (); i++) { start_index[i] = prev_index + normals_hg[i-1].size (); prev_index = start_index[i]; } // Maintaining flags to check if a point is sampled boost::dynamic_bitset<> is_sampled_flag (input_normals_->points.size ()); // Maintaining flags to check if all points in the bin are sampled boost::dynamic_bitset<> bin_empty_flag (normals_hg.size ()); unsigned int i = 0; while (i < sample_) { // Iterating through every bin and picking one point at random, until the required number of points are sampled. for (size_t j = 0; j < normals_hg.size (); j++) { unsigned int M = static_cast<unsigned int> (normals_hg[j].size ()); if (M == 0 || bin_empty_flag.test (j)) // bin_empty_flag(i) is set if all points in that bin are sampled.. continue; unsigned int pos = 0; unsigned int random_index = 0; // Picking up a sample at random from jth bin do { random_index = static_cast<unsigned int> ((*rng_uniform_distribution_) () % M); pos = start_index[j] + random_index; } while (is_sampled_flag.test (pos)); is_sampled_flag.flip (start_index[j] + random_index); // Checking if all points in bin j are sampled. if (isEntireBinSampled (is_sampled_flag, start_index[j], static_cast<unsigned int> (normals_hg[j].size ()))) bin_empty_flag.flip (j); unsigned int index = *(random_access[j][random_index]); indices[i] = index; i++; if (i == sample_) break; } } // If we need to return the indices that we haven't sampled if (extract_removed_indices_) { std::vector<int> indices_temp = indices; std::sort (indices_temp.begin (), indices_temp.end ()); std::vector<int> all_indices_temp = *indices_; std::sort (all_indices_temp.begin (), all_indices_temp.end ()); set_difference (all_indices_temp.begin (), all_indices_temp.end (), indices_temp.begin (), indices_temp.end (), inserter (*removed_indices_, removed_indices_->begin ())); } }