コード例 #1
0
void ms_cl_cmdlinet::process_response_file(const std::string &file)
{
  std::ifstream infile(file.c_str());
  
  if(!infile)
  {
    std::cerr << "failed to open response file `"
              << file << "'" << std::endl;
    return;
  }

  // these may be Unicode -- which is indicated by 0xff 0xfe
  std::string line;
  getline(infile, line);
  if(line.size()>=2 &&
     line[0]==char(0xff) &&
     line[1]==char(0xfe))
  {
    // Unicode, UTF-16 little endian
    
    #if 1
    // Re-open -- should be using wifstream,
    // but this isn't available everywhere.
    std::ifstream infile2(file.c_str(), std::ios::binary);
    infile2.seekg(2);
    std::wstring wline;
    
    while(my_wgetline(infile2, wline))
      process_response_file_line(narrow(wline)); // we UTF-8 it

    #else
    
    std::wifstream infile2(file.c_str(), std::ios::binary);
    std::wstring wline;
    
    while(std::getline(infile2, wline))
      process_response_file_line(narrow(wline)); // we UTF-8 it
    
    #endif
  }
  else if(line.size()>=3 &&
          line[0]==char(0xef) &&
          line[1]==char(0xbb) &&
          line[2]==char(0xbf))
  {
    // This is the UTF-8 BOM. We can proceed as usual, since
    // we use UTF-8 internally.
    infile.seekg(3);
    
    while(getline(infile, line))
      process_response_file_line(line);
  }
  else
  {
    // normal ASCII
    infile.seekg(0);
    while(getline(infile, line))
      process_response_file_line(line);
  }
}
コード例 #2
0
void ExtractMatchingPairs(
    const char* model_file,
    const char* scene_file,
    const T& threshold,
    const char* extracted_model_file,
    const char* extracted_scene_file) {

  std::ifstream infile1(model_file);
  vnl_matrix<T> model;
  model.read_ascii(infile1);

  std::ifstream infile2(scene_file);
  vnl_matrix<T> scene;
  scene.read_ascii(infile2);

  vnl_matrix<T> extracted_model, extracted_scene;
  ExtractMatchingPairs<T>(
      model, scene, threshold, extracted_model, extracted_scene);

  std::ofstream outfile1(extracted_model_file, std::ios_base::out);
  extracted_model.print(outfile1);

  std::ofstream outfile2(extracted_scene_file, std::ios_base::out);
  extracted_scene.print(outfile2);
}
コード例 #3
0
vec AdultParser::getClassifications() {
    string line;
    ifstream infile2(this->classificationsPath);
    vector<double> y_temp;
    while (std::getline(infile2, line))
    {
        y_temp.push_back(stof(line));
    }
    return vec(y_temp);
}
コード例 #4
0
ファイル: plot_dyb_ls.C プロジェクト: brettviren/WbLS
void plot_dyb_ls(){
  ifstream infile1("dyb_ls_slow.dat");
  ifstream infile2("dyb_ls_fast.dat");
  Double_t x[2][300],y[2][300];
  for (Int_t i=0;i!=273;i++){
    infile1 >> x[0][i] >> y[0][i];
    infile2 >> x[1][i] >> y[1][i];
    
    x[0][i] = 1240./x[0][i];
    x[1][i] = 1240./x[1][i];
    
  }
  TGraph *g1 = new TGraph(273,x[0],y[0]);
  g1->Draw("A*");
  
  TGraph *g2 = new TGraph(273,x[1],y[1]);
  g1->Draw("*same");
  g1->SetMarkerColor(2);
}
コード例 #5
0
void checkOverlap(string file1, string file2){

  vector<TrackerStrip> vec1;
  vector<TrackerStrip> vec2;

  ifstream infile1 (file1.c_str());
  ifstream infile2 (file2.c_str());

  TrackerStrip* strip = new TrackerStrip();
  if(infile1.is_open()){
    while(!infile1.eof()){
      infile1 >> strip->fecCrate_ >> strip->fecSlot_ >> strip->fecRing_ >> strip->ccuAdd_ >> strip->ccuCh_ >> strip->fedKey_ >> strip->lldCh_ >> strip->apvid_ >> strip->stripid_ ;
      vec1.push_back(*strip);
    }
  }
  infile1.close();

  if(infile2.is_open()){
    while(!infile2.eof()){
      infile2 >> strip->fecCrate_ >> strip->fecSlot_ >> strip->fecRing_ >> strip->ccuAdd_ >> strip->ccuCh_ >> strip->fedKey_ >> strip->lldCh_ >> strip->apvid_ >> strip->stripid_ ;
      vec2.push_back(*strip);
    }
  }
  infile2.close();

  long int total_vec1 = vec1.size();
  long int total_vec2 = vec2.size();
  long int common_strip;

  for(auto element : vec1){
    if(std::find(vec2.begin(),vec2.end(),element) != vec2.end())
      common_strip++;
  }
  
  cout<<"Total number of strips from file 1 "<<total_vec1<<endl;
  cout<<"Total number of strips from file 2 "<<total_vec2<<endl;
  cout<<"Common tagged strips "<<common_strip<<endl;
  cout<<"Fraction wrt file 1 "<<double(common_strip)/total_vec1<<endl;
  cout<<"Fraction wrt file 2 "<<double(common_strip)/total_vec2<<endl;

}
コード例 #6
0
ファイル: prog12_2.C プロジェクト: jiayuehua/cpp-primer
main()
{
     vector<textwords, allocator> sample;
     vector<string,allocator> 	  t1, t2; 
     string 			  t1fn, t2fn;

     cout << "text file #1: "; cin >> t1fn;
     cout << "text file #2: "; cin >> t2fn;

     ifstream infile1( t1fn.c_str());
     ifstream infile2( t2fn.c_str());

     istream_iterator< string, diff_type > input_set1( infile1 ), eos; 
     istream_iterator< string, diff_type > input_set2( infile2 );

     copy( input_set1, eos, back_inserter( t1 ));
     copy( input_set2, eos, back_inserter( t2 ));

     sample.push_back( t1 ); sample.push_back( t2 );
     process_vocab( &sample );
}
コード例 #7
0
void g( const char* model_file,
    const char* scene_file,
    double threshold,
    const char* extracted_model_file,
    const char* extracted_scene_file) {

  std::ifstream infile1(model_file);
  vnl_matrix<double> model;
  model.read_ascii(infile1);

  std::ifstream infile2(scene_file);
  vnl_matrix<double> scene;
  scene.read_ascii(infile2);

  vnl_matrix<double> extracted_model, extracted_scene;
  f(model, scene, threshold, extracted_model, extracted_scene);

  std::ofstream outfile1(extracted_model_file, std::ios_base::out);
  extracted_model.print(outfile1);

  std::ofstream outfile2(extracted_scene_file, std::ios_base::out);
  extracted_scene.print(outfile2);
}
コード例 #8
0
void endpointFormat() {

	TFile infile1("tmp1.root","open");
	TFile infile2("tmp2.root","open");

	TTree* intree1 = (TTree*)infile1.Get("tree");
	TTree* intree2 = (TTree*)infile2.Get("tree");
		

	_OutType outTrk;	


	TFile outfile("endpoint.root","recreate");
	TTree* outTree1 = new TTree("muonsTrk","muonsTrk");
	TTree* outTree2 = new TTree("muonsOpt","muonsOpt");

	
	float k,eta,phi;
	intree1->SetBranchAddress("k",&k);
	intree1->SetBranchAddress("eta",&eta);
	intree1->SetBranchAddress("phi",&phi);

	outTree1->Branch("trk1",&outTrk,"k/F:eta:phi:ptErr");

	int numEntries = intree1->GetEntries();
	std::cout<<"num entries: "<<numEntries<<std::endl;

	outTrk.ptErr=1.;

	for (int jEntry =0; jEntry < numEntries; ++jEntry) {
		intree1->GetEntry(jEntry);
		outTrk.k=k;
		outTrk.eta=eta;
		outTrk.phi=phi;

		outTree1->Fill();
	}

	intree2->SetBranchAddress("k",&k);
	intree2->SetBranchAddress("eta",&eta);
	intree2->SetBranchAddress("phi",&phi);
	outTree2->Branch("trk1",&outTrk,"k/F:eta:phi:ptErr");

	numEntries = intree1->GetEntries();
	std::cout<<"num entries: "<<numEntries<<std::endl;

	outTrk.ptErr=1.;

	for (int jEntry =0; jEntry < numEntries; ++jEntry) {
		intree2->GetEntry(jEntry);
		outTrk.k=k;
		outTrk.eta=eta;
		outTrk.phi=phi;

		outTree2->Fill();
	}

	outTree1->Write();
	outTree2->Write();
	


/*
	_outTree->Branch("trk1",&_outTrk1, "k/F:eta:phi:ptErr");
	_outTree->Branch("trk2",&_outTrk2, "k/F:eta:phi:ptErr");
*/

}
コード例 #9
0
ファイル: Discovery.cpp プロジェクト: rtaudio/ulltra
std::string Discovery::getHwAddress()
{
	static std::string addr;
	if (addr.length() > 0)
		return addr;

#ifndef _WIN32

	std::ifstream infile("/sys/class/net/et*/address");
	if (infile.good()) {
		std::getline(infile, addr);
		return addr;
	}

    std::ifstream infile2("/sys/class/net/wl*/address");
    if (infile2.good()) {
        std::getline(infile2, addr);
		return addr;
	}


	DIR *dir;
	struct dirent *ent;
	if (!(dir = opendir("/sys/class/net/")))
		return "";

	
	while ((ent = readdir(dir)) != NULL) {
		if (ent->d_name[0] == '.' || strlen(ent->d_name) < 4)
			continue;
		if ((ent->d_name[0] == 'w' && ent->d_name[1] == 'l') || ent->d_name[0] == 'e') {
            std::ifstream if3("/sys/class/net/" + std::string(ent->d_name )+"/address");
            if (if3.good()) {
                std::getline(if3, addr);
				closedir(dir);
				LOG(logDEBUG4) << "Using " << ent->d_name << "'s address";
				return addr;
			}
		}		
	}
	closedir(dir);

#else	
	char *mac_addr = (char*)malloc(17);
	IP_ADAPTER_INFO AdapterInfo[16];	
	DWORD dwBufLen = sizeof(AdapterInfo);

	GetAdaptersInfo(AdapterInfo, &dwBufLen);

	if (GetAdaptersInfo(AdapterInfo, &dwBufLen) != NO_ERROR) {
		LOG(logERROR) << "GetAdaptersInfo failed!";
		return "";
	}

	PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;

	do {
		sprintf(mac_addr, "%02X:%02X:%02X:%02X:%02X:%02X",
			pAdapterInfo->Address[0], pAdapterInfo->Address[1],
			pAdapterInfo->Address[2], pAdapterInfo->Address[3],
			pAdapterInfo->Address[4], pAdapterInfo->Address[5]);
		//printf("Address: %s, mac: %s\n", pAdapterInfo->IpAddressList.IpAddress.String, mac_addr);
		addr = std::string(mac_addr);
		break;
		pAdapterInfo = pAdapterInfo->Next;
	} while (pAdapterInfo);
#endif

	return addr;
}
コード例 #10
0
bool    
VulnerableBranch::runOnModule(Module &M) {
  std::vector<const Value*> taint_list, untrust_list;
  std::string line;
  std::set<std::string> kinds;

  ifa = &getAnalysis<Infoflow>();
  if (!ifa) {errs() << "No instance\n"; return false;}

  //copied from taint analysis 
  std::ifstream infile("taint.txt"); // read tainted values from txt file
  std::ifstream infile2("untrust.txt"); // reas untrust values from txt file

  while (std::getline(infile, line)) {
    taint_list = taintStr("taint", line);
    errs() << "taint var " << line << "\n";
  }
  while (std::getline(infile2, line)) {
    untrust_list = taintStr("untrust", line);
    errs() << "untrust var " << line << "\n";
  }

  kinds.insert("taint");
  kinds.insert("untrust");

  errs() << "Least solution with explicit contraints\n";
  InfoflowSolution* soln = ifa->leastSolution(kinds, false, true);

  std::vector<const Value*> both_list;

  for (std::vector<const Value*>::iterator taint_it=taint_list.begin(); taint_it!=taint_list.end(); ++taint_it){
    for (std::vector<const Value*>::iterator untrust_it=untrust_list.begin(); untrust_it!=untrust_list.end(); ++untrust_it){
      if(ifa->getOriginalLocation(*taint_it) == ifa->getOriginalLocation(*untrust_it)){
        both_list.push_back(*taint_it);
      }
     }
  }

  for (std::vector<const Value*>::iterator both_it=both_list.begin(), both_end=both_list.end(); both_it!=both_end; ++both_it){
    errs() << " final :\n";
    int num = ifa->getOriginalLocation(*both_it);
    errs() << "\n";
  }
  soln->allTainted();

  // // get the constraint sets with tag taint and untrust
  // std::vector<LHConstraint> &taint_set = ifa->kit->getOrCreateConstraintSet("taint");
  // std::vector<LHConstraint> &untrust_set = ifa->kit->getOrCreateConstraintSet("untrust");

  // // get the line number, ConElem pair from solution
  // std::vector<std::pair<const int , const ConsElem *>> line_elem = soln->allTainted();

  // // iterate line number ConsElem pair 
  // for (std::vector<std::pair<const int, const ConsElem *>>::iterator it = line_elem.begin(), end = line_elem.end(); it != end; ++it) {
  //   errs() << std::to_string((it->first)) << "\n";
    
  //   for (std::vector<LHConstraint>::iterator taint_it = taint_set.begin(), taint_end = taint_set.end(); taint_it != taint_end; ++taint_it) {
  //     errs() << "there is 1 untrusted value in untrust_set \n";
  //     if(it->second == &taint_it->rhs()){
  //       errs() << "find!\n";
  //     }
  //   }
  // }

  return false;
}
コード例 #11
0
ファイル: dnn.cpp プロジェクト: Nikraaaazy/bosen
void dnn::predict(const char * model_weight_file, const char * model_bias_file, char * outputfile)
{

  float *** local_weights=new float **[num_layers-1];
  for(int l=0;l<num_layers-1;l++){
    int dim1=num_units_ineach_layer[l+1], dim2=num_units_ineach_layer[l];
    local_weights[l]=new float*[dim1];
    for(int i=0;i<dim1;i++){
      local_weights[l][i]=new float[dim2];
      memset(local_weights[l][i],0,sizeof(float)*dim2);
    }
  }
  float ** local_biases=new float*[num_layers-1];
  for(int l=0;l<num_layers-1;l++){
    local_biases[l]=new float[num_units_ineach_layer[l+1]];
    memset(local_biases[l],0,sizeof(float)*num_units_ineach_layer[l+1]);
  }

  //std::ifstream infile;
  //infile.open(model_weight_file);
  petuum::io::ifstream infile(model_weight_file);


  for(int l=0;l<num_layers-1;l++){
    int dim1=num_units_ineach_layer[l+1], dim2=num_units_ineach_layer[l];
    for(int j=0;j<dim1;j++){
      for(int i=0;i<dim2;i++){
        infile>>local_weights[l][j][i];
      }
    }
  }
  infile.close();


  petuum::io::ifstream infile2(model_bias_file);

  //infile.open(model_bias_file);
  for(int l=0;l<num_layers-1;l++){
    int dim=num_units_ineach_layer[l+1];
    for(int j=0;j<dim;j++){
      infile2>>local_biases[l][j];
    }
  }
  infile2.close();



  float ** z=new float*[num_layers];
  for(int i=0;i<num_layers;i++)
    z[i]=new float[num_units_ineach_layer[i]];

  //std::ofstream outfile;
  //outfile.open(outputfile);
  petuum::io::ofstream outfile(outputfile);


  for(int i=0;i<num_test_data;i++){
    int pred=predict_single_data(i, local_weights, local_biases, z);
    outfile<<pred<<std::endl;
  }
  outfile.close();  

  for(int i=0;i<num_layers;i++)
    delete[]z[i];
  delete []z;


  //release parameter buffer
  for(int l=0;l<num_layers-1;l++){
    int dim1=num_units_ineach_layer[l+1];
    for(int i=0;i<dim1;i++)
      delete []local_weights[l][i];
    delete[]local_weights[l];
  }
  delete[]local_weights;


  for(int l=0;l<num_layers-1;l++)
    delete []local_biases[l];
  delete []local_biases;


}
コード例 #12
0
void final_pdf_error(){
const int nPoints0 = 53;
double pdf00[nPoints0],pdf01[nPoints0];

const int nPoints1 = 101;
double pdf10[nPoints1],pdf11[nPoints1];

const int nPoints2 = 41;
double pdf20[nPoints2],pdf21[nPoints2];

const int nPoints3 = 2;
double pdf30[nPoints3],pdf31[nPoints3];

const int nPoints4 = 2;
double pdf40[nPoints4],pdf41[nPoints4];

const int nPoints5 = 2;
double pdf50[nPoints5],pdf51[nPoints5];

int i = 0;
ifstream infile0("pdf_cteq66.txt");
while (infile0>>pdf00[i]
              >>pdf01[i]){ i++;}

i = 0;
ifstream infile1("pdf_nnpdf.txt");
while (infile1>>pdf10[i]
              >>pdf11[i]){ i++;}
	     
i = 0;
ifstream infile2("pdf_mstw.txt");
while (infile2>>pdf20[i]
              >>pdf21[i]){ i++;}
	     
i = 0;
ifstream infile3("pdf_cteq66_alphas.txt");
while (infile3>>pdf30[i]
              >>pdf31[i]){ i++;}

i = 0;
ifstream infile4("pdf_nnpdf_alphas.txt");
while (infile4>>pdf40[i]
              >>pdf41[i]){ i++;}
	     
i = 0;
ifstream infile5("pdf_mstw_alphas.txt");
while (infile5>>pdf50[i]
              >>pdf51[i]){ i++;}

double results00[2],results10[2],results20[2];
mstw_cteq(pdf00, nPoints0, results00);
nnpdf    (pdf10, nPoints1, results10);
mstw_cteq(pdf20, nPoints2, results20);
double results01[2],results11[2],results21[2];
mstw_cteq(pdf01, nPoints0, results01);
nnpdf    (pdf11, nPoints1, results11);
mstw_cteq(pdf21, nPoints2, results21);

double resultsN00[2],resultsN10[2],resultsN20[2];
combined_syst(pdf00, nPoints0, false, resultsN00);
combined_syst(pdf10, nPoints1, true , resultsN10);
combined_syst(pdf20, nPoints2, false, resultsN20);
double resultsN01[2],resultsN11[2],resultsN21[2];
combined_syst(pdf01, nPoints0, false, resultsN01);
combined_syst(pdf11, nPoints1, true , resultsN11);
combined_syst(pdf21, nPoints2, false, resultsN21);

printf("CTEQ  Acc syst. => + %5.3f - %5.3f\n",results00[0],results00[1]);
printf("NNPDF Acc syst. => + %5.3f - %5.3f\n",results10[0],results10[1]);
printf("MSTW  Acc syst. => + %5.3f - %5.3f\n",results20[0],results20[1]);
printf("CTEQ  Rec syst. => + %5.3f - %5.3f\n",results01[0],results01[1]);
printf("NNPDF Rec syst. => + %5.3f - %5.3f\n",results11[0],results11[1]);
printf("MSTW  Rec syst. => + %5.3f - %5.3f\n",results21[0],results21[1]);

printf("CTEQ  Acc syst. => + %5.3f - %5.3f\n",resultsN00[0],resultsN00[1]);
printf("NNPDF Acc syst. => + %5.3f - %5.3f\n",resultsN10[0],resultsN10[1]);
printf("MSTW  Acc syst. => + %5.3f - %5.3f\n",resultsN20[0],resultsN20[1]);
printf("CTEQ  Rec syst. => + %5.3f - %5.3f\n",resultsN01[0],resultsN01[1]);
printf("NNPDF Rec syst. => + %5.3f - %5.3f\n",resultsN11[0],resultsN11[1]);
printf("MSTW  Rec syst. => + %5.3f - %5.3f\n",resultsN21[0],resultsN21[1]);

double alpha_s_acc[3] = {100*(pdf30[0]-pdf30[1])/2.0/pdf00[0],100*(pdf40[0]-pdf40[1])/2.0/pdf10[0],100*(pdf50[0]-pdf50[1])/2.0/pdf20[0]};
double alpha_s_rec[3] = {100*(pdf31[0]-pdf31[1])/2.0/pdf01[0],100*(pdf41[0]-pdf41[1])/2.0/pdf11[0],100*(pdf51[0]-pdf51[1])/2.0/pdf21[0]};

printf("CTEQ/NNPDF/MSTW  Acc-alphas syst. => %5.3f  %5.3f  %5.3f\n",alpha_s_acc[0],alpha_s_acc[1],alpha_s_acc[2]);
printf("CTEQ/NNPDF/MSTW  Rec-alphas syst. => %5.3f  %5.3f  %5.3f\n",alpha_s_rec[0],alpha_s_rec[1],alpha_s_rec[2]);

double Vmax_acc = (1.0+resultsN00[0]/100.)*pdf00[0];
if((1.0+resultsN10[0]/100.)*pdf10[0] > Vmax_acc) Vmax_acc = (resultsN10[0]/100.+1)*pdf10[0];
if((1.0+resultsN20[0]/100.)*pdf20[0] > Vmax_acc) Vmax_acc = (resultsN20[0]/100.+1)*pdf20[0];
double Vmin_acc = (1.0-resultsN00[1]/100.)*pdf00[0];
if((1.0-resultsN10[0]/100.)*pdf10[0] < Vmin_acc) Vmin_acc = (1.0-resultsN10[0]/100.)*pdf10[0];
if((1.0-resultsN20[0]/100.)*pdf20[0] < Vmin_acc) Vmin_acc = (1.0-resultsN20[0]/100.)*pdf20[0];

double sigma_acc     = (Vmax_acc-Vmin_acc)/2.;
double x_central_acc = (Vmax_acc+Vmin_acc)/2.;

printf("Acc-additional syst. x,sigma: %7.5f +/- %7.5f ==> %7.5f\n",x_central_acc,sigma_acc,100*sigma_acc/x_central_acc);

double Vmax_rec = (1.0+resultsN01[0]/100.)*pdf01[0];
if((1.0+resultsN11[0]/100.)*pdf11[0] > Vmax_rec) Vmax_rec = (resultsN11[0]/100.+1)*pdf11[0];
if((1.0+resultsN21[0]/100.)*pdf21[0] > Vmax_rec) Vmax_rec = (resultsN21[0]/100.+1)*pdf21[0];
double Vmin_rec = (1.0-resultsN01[1]/100.)*pdf01[0];
if((1.0-resultsN11[0]/100.)*pdf11[0] < Vmin_rec) Vmin_rec = (1.0-resultsN11[0]/100.)*pdf11[0];
if((1.0-resultsN21[0]/100.)*pdf21[0] < Vmin_rec) Vmin_rec = (1.0-resultsN21[0]/100.)*pdf21[0];

double sigma_rec     = (Vmax_rec-Vmin_rec)/2.;
double x_central_rec = (Vmax_rec+Vmin_rec)/2.;

printf("Rec-additional syst. x,sigma: %7.5f +/- %7.5f ==> %7.5f\n",x_central_rec,sigma_rec,100*sigma_rec/x_central_rec);

double total0[2] = {sqrt((resultsN00[0]+resultsN00[1])*(resultsN00[0]+resultsN00[1])/4.+alpha_s_acc[0]*alpha_s_acc[0]+(100*sigma_acc/x_central_acc)*(100*sigma_acc/x_central_acc)),
                    sqrt((resultsN01[0]+resultsN01[1])*(resultsN01[0]+resultsN01[1])/4.+alpha_s_rec[0]*alpha_s_rec[0]+(100*sigma_rec/x_central_rec)*(100*sigma_rec/x_central_rec))};
printf("Acc-total syst CTEQ: %5.3f\n",total0[0]);
printf("Rec-total syst CTEQ: %5.3f\n",total0[1]);

double total1[2] = {sqrt((resultsN10[0]+resultsN10[1])*(resultsN10[0]+resultsN10[1])/4.+alpha_s_acc[1]*alpha_s_acc[1]+(100*sigma_acc/x_central_acc)*(100*sigma_acc/x_central_acc)),
                    sqrt((resultsN11[0]+resultsN11[1])*(resultsN11[0]+resultsN11[1])/4.+alpha_s_rec[1]*alpha_s_rec[1]+(100*sigma_rec/x_central_rec)*(100*sigma_rec/x_central_rec))};
printf("Acc-total syst MSTW: %5.3f\n",total1[0]);
printf("Rec-total syst MSTW: %5.3f\n",total1[1]);

double total2[2] = {sqrt((resultsN20[0]+resultsN20[1])*(resultsN20[0]+resultsN20[1])/4.+alpha_s_acc[2]*alpha_s_acc[2]+(100*sigma_acc/x_central_acc)*(100*sigma_acc/x_central_acc)),
                    sqrt((resultsN21[0]+resultsN21[1])*(resultsN21[0]+resultsN21[1])/4.+alpha_s_rec[2]*alpha_s_rec[2]+(100*sigma_rec/x_central_rec)*(100*sigma_rec/x_central_rec))};
printf("Acc-total syst NNPDF: %5.3f\n",total2[0]);
printf("Rec-total syst NNPDF: %5.3f\n",total2[1]);


}
コード例 #13
0
ファイル: plotLimit_width.C プロジェクト: UBParker/B2GTTbar
void plotLimit(int signal = 0){
//signal: 0 = ZPN, 1 = ZPW, 2 = ZPXW, 3 = RSG  

setTDRStyle();

//gROOT->SetStyle("Plain");
gStyle->SetOptStat(0000000000); //this clears all the boxes and crap
gStyle->SetLegendBorderSize(1);

TGraph * limit_obs = new TGraph(3);
TGraph * limit_exp = new TGraph(3);
TGraphAsymmErrors * band_exp1 = new TGraphAsymmErrors();
TGraphAsymmErrors * band_exp2 = new TGraphAsymmErrors();

TGraph * limit_obs_2 = new TGraph(3);
TGraph * limit_exp_2 = new TGraph(3);
TGraphAsymmErrors * band_exp1_2 = new TGraphAsymmErrors();
TGraphAsymmErrors * band_exp2_2 = new TGraphAsymmErrors();
TGraph * limit_obs_3 = new TGraph(3);
TGraph * limit_exp_3 = new TGraph(3);
TGraphAsymmErrors * band_exp1_3 = new TGraphAsymmErrors();
TGraphAsymmErrors * band_exp2_3 = new TGraphAsymmErrors();
TGraph * limit_obs_4 = new TGraph(3);
TGraph * limit_exp_4 = new TGraph(3);
TGraphAsymmErrors * band_exp1_4 = new TGraphAsymmErrors();
TGraphAsymmErrors * band_exp2_4 = new TGraphAsymmErrors();
TGraph *theory = new TGraph(3);
TGraph *theory2 = new TGraph(3);
TGraph *theory3 = new TGraph(3);
TGraph *theory4 = new TGraph(3);

   theory->SetPoint(0,  0.01, 4.24671);

   theory->SetPoint(1,  0.1, 42.24246);

   theory->SetPoint(2,  0.3, 122.17487);
   theory2->SetPoint(0,  0.01, 0.17980);
   theory2->SetPoint(1,  0.1, 2.00723);
   theory2->SetPoint(2,  0.3, 6.99950);
   theory3->SetPoint(0, 0.01, 0.01659*0.1);
   theory3->SetPoint(1,  0.1, 0.23030*0.1);
   theory3->SetPoint(2,  0.3, 1.03387*0.1);
   theory4->SetPoint(0, 0.01, 0.00203*0.01);
   theory4->SetPoint(1, 0.1, 0.04254*0.01);
   theory4->SetPoint(2, 0.3, 0.25352*0.01); 

 string filename = "Limits/comb_width_1TeV.txt";
 if (signal == 1) filename= "Limits/comb_width_2TeV.txt";
 if (signal == 2) filename= "Limits/comb_width_3TeV.txt";
 if (signal == 3) filename= "Limits/comb_width_4TeV.txt";

ifstream infile(filename);

double mass, exp, obs, up1, up2, dn1, dn2;
int point = 0;

while (!infile.eof()){

  //infile >> mass >> exp >>  dn2 >> up2 >> dn1 >> up1;
  //obs = exp;	

  infile >> mass >> obs >> exp >>  dn2 >> up2 >> dn1 >> up1;

 
  double sf = 1.0;
  cout.precision(3);
  //cout << mass << " & " << obs << " & " << exp << " & " << "["<<dn1<<", "<<up1<<"] & ["<<dn2<<", "<<up2<<"] \\" << endl;
  cout << mass << " & \\textbf{" << obs*sf << "} & " << dn2*sf << " & " << dn1*sf << " & \\textbf{" << exp*sf << "} & " << up1*sf << " & " << up2*sf <<  " \\\\" << endl;


  //if (mass == 2500) sf = 0.01;
  //if (mass == 3000) sf = 0.001;
  //if (mass == 3500) sf = 0.0001;
  //if (mass == 4000) sf = 0.0001;


  limit_obs->SetPoint(point, mass, obs*sf);
  limit_exp->SetPoint(point, mass, exp*sf);
  band_exp1->SetPoint(point, mass, exp*sf);
  band_exp2->SetPoint(point, mass, exp*sf);
  
  band_exp1->SetPointEYhigh(point, up1*sf - exp*sf);
  band_exp1->SetPointEYlow(point, exp*sf - dn1*sf);
  band_exp2->SetPointEYhigh(point, up2*sf - exp*sf);
  band_exp2->SetPointEYlow(point, exp*sf - dn2*sf);
  point++;

}

ifstream infile2 ("Limits/comb_width_2TeV.txt");
point = 0;
while (!infile2.eof()){

  //infile >> mass >> exp >>  dn2 >> up2 >> dn1 >> up1;
  //obs = exp;	

  infile2 >> mass >> obs >> exp >>  dn2 >> up2 >> dn1 >> up1;

 
  double sf = 1.0;
  cout.precision(3);
  //cout << mass << " & " << obs << " & " << exp << " & " << "["<<dn1<<", "<<up1<<"] & ["<<dn2<<", "<<up2<<"] \\" << endl;
  cout << mass << " & \\textbf{" << obs*sf << "} & " << dn2*sf << " & " << dn1*sf << " & \\textbf{" << exp*sf << "} & " << up1*sf << " & " << up2*sf <<  " \\\\" << endl;


  //if (mass == 2500) sf = 0.01;
  //if (mass == 3000) sf = 0.001;
  //if (mass == 3500) sf = 0.0001;
  //if (mass == 4000) sf = 0.0001;


  limit_obs_2->SetPoint(point, mass, obs*sf);
  limit_exp_2->SetPoint(point, mass, exp*sf);
  band_exp1_2->SetPoint(point, mass, exp*sf);
  band_exp2_2->SetPoint(point, mass, exp*sf);
  
  band_exp1_2->SetPointEYhigh(point, up1*sf - exp*sf);
  band_exp1_2->SetPointEYlow(point, exp*sf - dn1*sf);
  band_exp2_2->SetPointEYhigh(point, up2*sf - exp*sf);
  band_exp2_2->SetPointEYlow(point, exp*sf - dn2*sf);
  point++;

}

ifstream infile3 ("Limits/comb_width_3TeV.txt");
point = 0;

while (!infile3.eof()){

  //infile >> mass >> exp >>  dn2 >> up2 >> dn1 >> up1;
  //obs = exp;	

  infile3 >> mass >> obs >> exp >>  dn2 >> up2 >> dn1 >> up1;

 
  double sf = 0.1;
  cout.precision(3);
  //cout << mass << " & " << obs << " & " << exp << " & " << "["<<dn1<<", "<<up1<<"] & ["<<dn2<<", "<<up2<<"] \\" << endl;
  cout << mass << " & \\textbf{" << obs*sf << "} & " << dn2*sf << " & " << dn1*sf << " & \\textbf{" << exp*sf << "} & " << up1*sf << " & " << up2*sf <<  " \\\\" << endl;


  //if (mass == 2500) sf = 0.01;
  //if (mass == 3000) sf = 0.001;
  //if (mass == 3500) sf = 0.0001;
  //if (mass == 4000) sf = 0.0001;


  limit_obs_3->SetPoint(point, mass, obs*sf);
  limit_exp_3->SetPoint(point, mass, exp*sf);
  band_exp1_3->SetPoint(point, mass, exp*sf);
  band_exp2_3->SetPoint(point, mass, exp*sf);

  band_exp1_3->SetPointEYhigh(point, up1*sf - exp*sf);
  band_exp1_3->SetPointEYlow(point, exp*sf - dn1*sf);
  band_exp2_3->SetPointEYhigh(point, up2*sf - exp*sf);
  band_exp2_3->SetPointEYlow(point, exp*sf - dn2*sf);
  point++;

}

ifstream infile4 ("Limits/comb_width_4TeV.txt");
point = 0;

while (!infile4.eof()){

  //infile >> mass >> exp >>  dn2 >> up2 >> dn1 >> up1;
  //obs = exp;	

  infile4 >> mass >> obs >> exp >>  dn2 >> up2 >> dn1 >> up1;

 
  double sf = 0.01;
  cout.precision(3);
  //cout << mass << " & " << obs << " & " << exp << " & " << "["<<dn1<<", "<<up1<<"] & ["<<dn2<<", "<<up2<<"] \\" << endl;
  cout << mass << " & \\textbf{" << obs*sf << "} & " << dn2*sf << " & " << dn1*sf << " & \\textbf{" << exp*sf << "} & " << up1*sf << " & " << up2*sf <<  " \\\\" << endl;


  //if (mass == 2500) sf = 0.01;
  //if (mass == 3000) sf = 0.001;
  //if (mass == 3500) sf = 0.0001;
  //if (mass == 4000) sf = 0.0001;


  limit_obs_4->SetPoint(point, mass, obs*sf);
  limit_exp_4->SetPoint(point, mass, exp*sf);
  band_exp1_4->SetPoint(point, mass, exp*sf);
  band_exp2_4->SetPoint(point, mass, exp*sf);
  band_exp1_4->SetPointEYhigh(point, up1*sf - exp*sf);
  band_exp1_4->SetPointEYlow(point, exp*sf - dn1*sf);
  band_exp2_4->SetPointEYhigh(point, up2*sf - exp*sf);
  band_exp2_4->SetPointEYlow(point, exp*sf - dn2*sf);
  point++;

}





double max = 200000.0; //band_exp2->GetHistogram()->GetMaximum()*50;

  TCanvas *canvas = new TCanvas("limit set ZPN","limit set ZPN", 500,500);

  limit_exp->SetMinimum(0.00001);
  limit_exp->GetXaxis()->SetLabelSize(0.05);
  limit_exp->GetYaxis()->SetLabelSize(0.05);
  limit_exp->Draw("AL");
  if (signal == 0){
    limit_exp->GetXaxis()->SetTitle("#Gamma_{Z'} / M_{Z'}");
    limit_exp->GetYaxis()->SetTitle("95% CL Limit on #sigma_{Z'} #times B(Z'#rightarrowt#bar{t}) [pb]");
  }
  else if (signal == 1){
    limit_exp->GetXaxis()->SetTitle("M_{Z'} [GeV]");
    limit_exp->GetYaxis()->SetTitle("95% CL Limit on #sigma_{Z'} #times B(Z'#rightarrowt#bar{t}) [pb]");
  }
  else if (signal == 2){
    limit_exp->GetXaxis()->SetTitle("M_{Z'} [GeV]");
    limit_exp->GetYaxis()->SetTitle("95% CL Limit on #sigma_{Z'} #times B(Z'#rightarrowt#bar{t}) [pb]");
  }
  else if (signal == 3){
    limit_exp->GetXaxis()->SetTitle("M_{g_{KK}} [GeV]");
    limit_exp->GetYaxis()->SetTitle("95% CL Limit on #sigma_{g_{KK}} #times B(g_{KK}#rightarrowt#bar{t}) [pb]");
  }
  //limit_exp->GetYaxis()->SetTitleOffset(1.2);
  limit_exp->GetYaxis()->SetRangeUser(0.00001,2000);


  band_exp2->SetFillColor(5);
  band_exp2->SetLineColor(0);
  //band_exp2->SetFillStyle(4000);
  band_exp2->Draw("3same");

  band_exp1->SetFillColor(3);
  band_exp1->SetLineColor(0);
  //band_exp1->SetFillStyle(4000);
  band_exp1->Draw("3same");

  limit_obs->Draw("Lsame");
  limit_obs->SetLineWidth(2);
  limit_obs->SetMarkerSize(1.0);
  limit_obs->SetMarkerStyle(20);
   
  limit_exp->Draw("Lsame");
  limit_exp->SetLineStyle(2);
  limit_exp->SetLineWidth(2);
  limit_exp->SetMarkerSize(1.0);
  limit_exp->SetMaximum(max);
  limit_exp->SetMinimum(0.000001);
  limit_exp->SetMarkerStyle(20);
  

  band_exp2_2->SetFillColor(5);
  band_exp2_2->SetLineColor(0);
  band_exp1_2->SetFillColor(3);
  band_exp1_2->SetLineColor(0);
  band_exp2_3->SetFillColor(5);
  band_exp2_3->SetLineColor(0);
  band_exp1_3->SetFillColor(3);
  band_exp1_3->SetLineColor(0);
  band_exp2_4->SetFillColor(5);
  band_exp2_4->SetLineColor(0);
  band_exp1_4->SetFillColor(3);
  band_exp1_4->SetLineColor(0);
  band_exp2_2->Draw("3same");
  band_exp1_2->Draw("3same");
  limit_obs_2->Draw("Lsame");
  limit_obs_2->SetLineWidth(2);
  limit_obs_2->SetMarkerSize(1.0);
  limit_obs_2->SetMarkerStyle(20);
  band_exp2_3->Draw("3same");
  band_exp1_3->Draw("3same");
  limit_obs_3->Draw("Lsame");
  limit_obs_3->SetLineWidth(2);
  limit_obs_3->SetMarkerSize(1.0);
  limit_obs_3->SetMarkerStyle(20);
  band_exp2_4->Draw("3same");
  band_exp1_4->Draw("3same");
  limit_obs_4->Draw("Lsame");
  limit_obs_4->SetLineWidth(2);
  limit_obs_4->SetMarkerSize(1.0);
  limit_obs_4->SetMarkerStyle(20);

  limit_exp_2->Draw("L same");
  limit_exp_2->SetLineStyle(2);
  limit_exp_2->SetLineWidth(2);
  limit_exp_2->SetMarkerSize(1.0);
  limit_exp_3->Draw("L same");
  limit_exp_3->SetLineStyle(2);
  limit_exp_3->SetLineWidth(2);
  limit_exp_3->SetMarkerSize(1.0);
  limit_exp_4->Draw("L same");
  limit_exp_4->SetLineStyle(2);
  limit_exp_4->SetLineWidth(2);
  limit_exp_4->SetMarkerSize(1.0);








    canvas->RedrawAxis();

  double x1 = 595; 
  double y1 = 1.0;
  double x2 = 905;
  double y2 = 1.0;
  TLine * line = new TLine(x1, y1, x2, y2);
  theory->SetLineColor(2);
  theory->SetLineWidth(2);
  theory->Draw("same");
	theory2->SetLineColor(kBlue);
	theory2->SetLineWidth(2);
	theory2->Draw("same");
	theory3->SetLineColor(kMagenta);
	theory3->SetLineWidth(2);
	theory3->Draw("same");
	theory4->SetLineColor(kCyan);
	theory4->SetLineWidth(2);
	theory4->Draw("same");

  CMS_lumi(canvas, 4, 10);

  float t = canvas->GetTopMargin();
  float r = canvas->GetRightMargin();

  //Legend
  TLegend *l = new TLegend(0.51,0.63,0.99-r,0.99-t);
  l->AddEntry(limit_obs,"Observed", "L");
  l->AddEntry(limit_exp,"Expected", "L");
  l->AddEntry(band_exp1,"#pm1 #sigma Exp.", "F");
  l->AddEntry(band_exp2,"#pm2 #sigma Exp.", "F");
    l->AddEntry(theory, "Z' 1 TeV (NLO)", "L");
    l->AddEntry(theory2, "Z' 2 TeV (NLO)", "L");
    l->AddEntry(theory3, "Z' 3 TeV (NLO x 0.1)", "L");
    l->AddEntry(theory4, "Z' 4 TeV (NLO x 0.01)", "L");
  l->SetFillColor(0);
  l->SetLineColor(0);
  l->SetTextSize(0.04);
  l->SetTextFont(42);
  l->Draw();

  //TLatex * label = new TLatex();
  //label->SetNDC();
  //label->DrawLatex(0.2,0.86,"CMS Preliminary, 19.7 fb^{-1}");
  //label->DrawLatex(0.2,0.80,"#sqrt{s} = 8 TeV");
  //label->DrawLatex(0.6,0.80, Form("BR(b'#rightarrow %s) = 1", channel.Data()));
  //label->DrawLatex(0.55,0.80, "BR(b'#rightarrow tW) = 0.5");
  //label->DrawLatex(0.55,0.74, "BR(b'#rightarrow bH) = 0.25");
  //label->DrawLatex(0.55,0.68, "BR(b'#rightarrow bZ) = 0.25");
  //label->DrawLatex(0.2,0.74, lepton.Data());

  canvas->SetLogy(1);
  canvas->SetLogx(1);
  canvas->SetTickx(1);
  canvas->SetTicky(1);


  if (signal == 0){
    canvas->Print("Limits/comb_ZPN_limit.pdf");
    canvas->Print("Limits/comb_ZPN_limit.root");
  }
  else if (signal == 1){
    canvas->Print("Limits/comb_ZPW_limit.pdf");
    canvas->Print("Limits/comb_ZPW_limit.root");
  }
  else if (signal == 2){
    canvas->Print("Limits/comb_ZPXW_limit.pdf");
    canvas->Print("Limits/comb_ZPXW_limit.root");
  }
  else if (signal == 3){
    canvas->Print("Limits/comb_RSG_limit.pdf");
    canvas->Print("Limits/comb_RSG_limit.root");
  }
}
コード例 #14
0
ファイル: Unit5.cpp プロジェクト: yanosh-igor/Filter_app
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{



double B[N] = {0.286, 0.106, -0.077, -0.039, -0.048, -0.013, 0.082, 0.087, -0.085, 0.014};
double Rv[N] = {0.46, 0.3, 0, -0.2, -0.24, -0.14, 0, 0.05, 0.02, 0};
double Re[N] = {0.95, 0.69, 0.37, 0.05, -0.19, -0.37, -0.43, -0.36, -0.14, -0.05};
double Rx[N][N], Xt[1001],Yt[1001];
double kor[n];
AnsiString q;
char symb;
ifstream infile("Lb7_11_s.prn");
for(int i=0;infile;)
 {
 infile.get(symb);
 if ((symb>='0' && symb<='9') || symb=='.'||symb=='-')
 {   if(symb=='.') {symb=',';};
     q=q+symb;
  }
  else if(q.Length()>=2)
     {kor[i]=StrToFloat(q);
      q=""; i++;
     }}


     double zav[n];
AnsiString q2;
char symb2;
ifstream infile2("Lb7_11_z.prn");
for(int i=0;infile2;)
 {
 infile2.get(symb2);
 if ((symb2>='0' && symb2<='9') || symb2=='.'||symb2=='-')
 {   if(symb2=='.') {symb2=',';};
     q2=q2+symb2;
  }
  else if(q2.Length()>=2)
     {zav[i]=StrToFloat(q2);
      q2=""; i++;
     }}


 //======Matrix R===============
int s, a=-1;
for (int i=0;i<=N;i++){
a++;
for (int j=0;j<=N;j++) {
s=abs(j-a);
Rx[i][j] = Rv[s] + Re[s];

 }
}
for (int i=0;i<=N;i++){
for (int j=0;j<=N;j++) {
StringGrid1->Cells[i][j]=Rx[i][j];
            }
        }


//===Kor signal============
 for(int i=0;i<=152;i++)
 Series3->Add(kor[i],i);
  //===zavada==============
 for(int i=0;i<=152;i++)
Series4->Add(zav[i],i);
 //===input signal
 for(int i=0;i<=1001;i++){
 Xt[i]=kor[i]+zav[i];


}
//====OUTPUT SIGNAL============
   double sum,korel_summ=0,v,Y[101],Y2[101];
for(int t=0;t<=1001;t++){
 sum=0;
 for (int j=0;j<=10;j++){
 sum+=B[j]*Xt[t-j];
 }
 Yt[t]=sum;
korel_summ+=Yt[t];
}
v=0.001*korel_summ;
for(int i=0;i<=150;i++){
Series8->Add(Yt[i],i);
Series7->Add(Xt[i],i);
}
  for(int i=0;i<=151;i++){
 Series5->Add(kor[i],i);
  Series13->Add(Yt[i],i);

}
//Korel function==============

  for(int t=0;t<=10;t++)
   {
    sum=0;
   for(int k=1;k<1000-t;k++) {
   sum+=(Yt[k]-v)*(Yt[k+t]-v);
   }
   Y[t]=(1.0/(n-t))*sum;
    Series10->Add(Y[t],t);
    }

 //Duspertion

 double d;
 d=Y[0];
 Label1->Caption = d;

//Impulse Reaction=============
Xt[0]=1;
   for(int i=1;i<=150;i++){
 Xt[i]=0;
}
 for(int t=0;t<=50;t++){
 sum=0;
 for (int j=0;j<=10;j++){
 sum=B[j]*Xt[t-j];

 }
 Yt[t]=sum;

 Series1->Add(Yt[t],t);

}

  //usefull signal============
  for(int i=0;i<=9;i++){
Series2->Add(Rv[i],i);
  Series11->Add(Rv[i],i);
    Series12->Add(Y[i],i);
}
 for(int i=0;i<=9;i++){
 Series9->Add(Rx[i][0],i);

}


}
コード例 #15
0
ファイル: stringlist.cpp プロジェクト: cmd184psu/fs-tools
bool cStringList::FileExists( const cString & fname ) {
	ifstream infile2(fname);
	if (! infile2) return false;
	infile2.close();
	return true;
}