Ejemplo n.º 1
0
vector<floatType> FeatureExtract::getFeature(Mat src){

	getHist(src);

	vector<floatType> feature;

	for (int i=0; i <= X/CELL - BLOCK; i+=STRIDE)
		for (int j=0; j <= Y/CELL - BLOCK; j+=STRIDE){
			
			floatType len = EPS;
			for (int s=0; s<BLOCK; ++s)
				for (int t=0; t<BLOCK; ++t)
					for (int r=0; r<BIN; ++r)
						len += SQR(hist[i+s][j+t][r]);

			len = sqrt(len);
			for (int s=0; s<BLOCK; ++s)
				for (int t=0; t<BLOCK; ++t){
					for (int r=0; r<BIN; ++r){
						feature.push_back(hist[i+s][j+t][r]/len);
					}
				}

		}

	return feature;
}
Ejemplo n.º 2
0
void plotSpectraMin() {

    vector<TH1F*> hists;

    for(int i = 0; i < fileNames.size(); i++) {
        hists.push_back(getHist(fileNames[i]));
    }

    TLegend * leg = new TLegend(0.60, 0.70, 0.88, 0.88);
    leg->SetHeader("LED Pulse Width");
    
    for(int i =0; i < hists.size(); i++) {
        hists[i]->SetLineColor(i+1);
        hists[i]->SetLineWidth(2);
        //hists[i]->Sumw2();
        hists[i]->Draw("SAME"); 
        leg->AddEntry(hists[i], (TString)leg_entries[i]);
        
    }

    hists[hists.size()-1]->SetLineColor(hists.size()+1);
    hists[hists.size()-1]->SetTitle("PMT Spectra with Varying LED Pulse Width");
    hists[hists.size()-1]->GetXaxis()->SetTitle("Integrated Charge / (pC)");
    hists[hists.size()-1]->GetYaxis()->SetTitle("Events");
    hists[hists.size()-1]->GetYaxis()->SetRangeUser(0.5, 20000);
    gStyle->SetOptStat(0);
    leg->Draw();

}
Ejemplo n.º 3
0
//------------------------------------------//
// Format amplitude plots
//------------------------------------------//
void npulsePlot(TFile* file, vector<TString> filters)
{

  // Specify the titles
  TString xtitle = "Number of Pulses";
  TString ytitle = "Entries";

  // Histogram name
  TString pname = "h_npulse";

  // Create canvas
  TCanvas* c = makeCanvas("c");
  
  // Make legend
  TLegend* leg = makeLegend(0.7,0.8,0.6,0.9);
  //TLegend* leg = makeLegend(0.7,0.8,0.8,0.9);

  // Loop and plot
  TH1* hist[6];
  float maximum = -999;
  for(unsigned int i=0; i<filters.size(); ++i){
    TString filter = filters.at(i);
    
    hist[i] = getHist(file,pname+"_"+filter,xtitle,ytitle,
		   m_colors[i], m_markers[i]);
    
    leg->AddEntry(hist[i],(filter+"%").Data(),"l");

    if( maximum < hist[i]->GetMaximum() )
      maximum = hist[i]->GetMaximum();

  }// end loop over filters
  /*
  for(unsigned int i=0; i<filters.size(); ++i){
    leg->Clear();
    leg->SetHeader("Filter");
    leg->AddEntry(hist[i],(filters.at(i)+"%").Data(),"l");
    hist[i]->Draw();
    leg->Draw("same");
    c->SaveAs((savedir+"npulse_filter"+filters.at(i)+".png").Data());
  }

  return;
  */

  // Set maximum correctly
  hist[0]->SetMaximum(1.1*maximum);
  hist[0]->Draw();
  for(unsigned int i=1; i<filters.size(); ++i){
    hist[i]->Draw("same");
  }

  // Draw legend
  leg->SetHeader("Filter");
  leg->Draw("same");
  
  c->SaveAs((savedir+"npulse_perLumi.png").Data());

}
Ejemplo n.º 4
0
double getHistEntriesSumDiffFiles( vector<TFile*> vf, TString dirname, TString hname, vector<int> binrange, double scale ){
  double entries=0;
  for( unsigned int ifile=0; ifile < vf.size(); ifile++ ){
    TH1D *h = getHist(vf[ifile], dirname, hname);
    entries = entries + getHistEntries( h, binrange, scale );
  }

  return entries;
}
Ejemplo n.º 5
0
			void setPrefixAndRegisterAsTemp(std::string const & prefix, uint64_t const numbwt, uint64_t const numgt)
			{
				setPrefix(prefix, numbwt, numgt);
				for ( uint64_t i = 0; i < getGT().size(); ++i )
					::libmaus2::util::TempFileRemovalContainer::addTempFile(getGT()[i]);
				for ( uint64_t i = 0; i < getBWT().size(); ++i )
					::libmaus2::util::TempFileRemovalContainer::addTempFile(getBWT()[i]);
				::libmaus2::util::TempFileRemovalContainer::addTempFile(getHWT());
				::libmaus2::util::TempFileRemovalContainer::addTempFile(getHist());
				::libmaus2::util::TempFileRemovalContainer::addTempFile(getSampledISA());			
			}
Ejemplo n.º 6
0
void makeDatacard(double mh, int nbins, double xmin, double xmax, std::string cat, int order) {

    std::vector<std::string> datpaths;
    std::vector<std::string> bkgpaths;
    std::vector<std::string> sigpaths;
    
    datpaths.push_back("/media/Disk1/avartak/CMS/Data/Dileptons/DoubleMuon/trim.root");
    bkgpaths.push_back("/media/Disk1/avartak/CMS/Data/Dileptons/DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/trim.root");
    bkgpaths.push_back("/media/Disk1/avartak/CMS/Data/Dileptons/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/trim.root");
    bkgpaths.push_back("/media/Disk1/avartak/CMS/Data/Dileptons/TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/trim.root");

    std::stringstream sigfname_ss;
    sigfname_ss << "/media/Disk1/avartak/CMS/Data/Dileptons/DarkPhoton/trim_M" << int(mh) << ".root";
    sigpaths.push_back(sigfname_ss.str().c_str());
    
    TH1F* sighist = new TH1F("sighist", "", nbins, xmin, xmax);
    TH1F* bkghist = new TH1F("bkghist", "", nbins, xmin, xmax);
    TH1F* dathist = new TH1F("dathist", "", nbins, xmin, xmax);
    
    getHist(sigpaths, sighist, cat);
    getHist(bkgpaths, bkghist, cat);
    getHist(datpaths, dathist, cat);

    sighist->Scale(1./400.);
   
    if (order < 0) order = getBestOrder(bkghist, mh, nbins, xmin, xmax, cat);
 
    std::map<std::string, double> sparams = fit("sig", sighist, mh, "signal", 2    , true);
    std::map<std::string, double> bparams = fit("dat", bkghist, mh, "bkgpol", order, true);
    
    std::cout << "Best polynomial order : " << order << std::endl;

    makeWorkspace(mh, dathist, sparams, bparams, cat);

    delete sighist;
    delete bkghist;
    delete dathist;
}
Ejemplo n.º 7
0
    yarp::sig::Matrix parzenWindowEstimator::getHist()
    {
        yarp::sig::Matrix Hist(binsNum[0],binsNum[1]);
        Hist.zero();

        for (size_t i = 0; i < binsNum[0]; i++)
        {
            for (size_t j = 0; j < binsNum[1]; j++)
            {
                Hist(i,j)=getHist(i,j);
            }
        }

        return Hist;
    }
Ejemplo n.º 8
0
//------------------------------------------//
// Basic plot
//------------------------------------------//
void basicPlot(TFile* file)
{

  // There are three basic plots to make
  vector<TString> pnames;
  pnames.push_back("amp");
  pnames.push_back("npulse");
  pnames.push_back("tDiff");
  pnames.push_back("maxTDiff");

  // Set x-titles
  vector<TString> xtitles;
  xtitles.push_back("Amplitude [V]");
  xtitles.push_back("Number of Pulses");
  xtitles.push_back("LEtime - wavetime [ns]");
  xtitles.push_back("Max(LEtime - wavetime) [ns]");

  // Only one ytitle
  TString ytitle = "Entries";

  // Make Canvas
  TCanvas* c = makeCanvas("c");

  // Loop and plot
  TH1* hist = NULL;
  for(unsigned int i=0; i<pnames.size(); ++i){

    // Get Hist
    TString pname = "h_"+pnames.at(i);
    hist = getHist(file,pname,xtitles[i],ytitle,kBlack,20);

    // Plot
    hist->Draw();

    // Save
    c->SaveAs((savedir+pnames[i]+"_total.png").Data());

  }// end loop

  delete hist;
  delete c;
    
}
Ejemplo n.º 9
0
//------------------------------------------//
// Format amplitude plots
//------------------------------------------//
void ampPlot(TFile* file, vector<TString> filters)
{

  // Specify the titles
  TString xtitle = "Amplitude [v]";
  TString ytitle = "Entries";

  // Histogram name
  TString pname = "h_amp";

  // Create canvas
  TCanvas* c = makeCanvas("c");
  c->SetLogx();
  c->SetLogy();

  // Make legend
  TLegend* leg = makeLegend(0.7,0.8,0.8,0.9);

  // Loop and plot
  TH1* hist = NULL;
  for(unsigned int i=0; i<filters.size(); ++i){
    leg->Clear();
    leg->SetHeader("Filter");
    
    TString filter = filters.at(i);
    
    hist = getHist(file,pname+"_"+filter,xtitle,ytitle,
		   m_colors[i], m_markers[i]);
    
    leg->AddEntry(hist,(filter+"%").Data(),"l");
    hist->Draw();

    // Draw legend
    leg->Draw("same");

    c->SaveAs((savedir+"amp_filter"+filter+".png").Data());

  }// end loop over filters


	       
}
Ejemplo n.º 10
0
//------------------------------------------//
// Plotting the maximum time difference
// for the maximum amplitude wave
//------------------------------------------//
void tDiffMaxPlotForMaxV(TFile* file, vector<TString> filters)
{

  // Specify the titles
  TString xtitle = "Max(LEtime - wavetime) [ns]";
  TString ytitle = "Entries";

  // Histogram name
  TString pname = "h_maxTDiff_forMaxV";

  // Create canvas
  TCanvas* c = makeCanvas("c");
  //c->SetLogy();
  
  // Make legend
  TLegend* leg = makeLegend(0.7,0.8,0.8,0.9);

  // Loop and plot
  TH1* hist = NULL;
  for(unsigned int i=0; i<filters.size(); ++i){
    leg->Clear();
    leg->SetHeader("Filter");
    TString filter = filters.at(i);
    
    hist = getHist(file,pname+"_"+filter,xtitle,ytitle,
		   m_colors[i], m_markers[i]);
    
    leg->AddEntry(hist,(filter+"%").Data(),"l");
    hist->Draw();

    // Draw legend
    leg->Draw("same");

    // Save 
    //c->SaveAs((savedir+"maxTimeDiff_filter"+filter+"_nonlog.png").Data());
    //c->SaveAs((savedir+"maxTimeDiff_cutOnCounter_filter"+filter+"_nonlog.png").Data());

  }// end loop over filters

	       
}
Ejemplo n.º 11
0
void QuickFeatureExtract::init(Mat src){
	getHist(src);
}