Example #1
0
	blargg_err_t load_( Data_Reader& in )
	{
		int file_size = in.remain();
		if ( file_size <= h.size )
			return blargg_err_file_type;
		
		RETURN_ERR( in.read( &h, h.size ) );
		if ( !h.valid_tag() )
			return blargg_err_file_type;
		
		int gd3_offset = get_le32( h.gd3_offset ) - 0x2C;
		int remain = file_size - h.size - gd3_offset;
		byte gd3_h [gd3_header_size];
		if ( gd3_offset > 0 && remain >= gd3_header_size )
		{
			RETURN_ERR( in.skip( gd3_offset ) );
			RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) );
			int gd3_size = check_gd3_header( gd3_h, remain );
			if ( gd3_size )
			{
				RETURN_ERR( gd3.resize( gd3_size ) );
				RETURN_ERR( in.read( gd3.begin(), gd3.size() ) );
			}
		}
		return blargg_ok;
	}
Example #2
0
blargg_err_t Rom_Data_::load_rom_data_( Data_Reader& in,
		int header_size, void* header_out, int fill, long pad_size )
{
	long file_offset = pad_size - header_size;
	
	rom_addr = 0;
	mask     = 0;
	size_    = 0;
	rom.clear();
	
	file_size_ = in.remain();
	if ( file_size_ <= header_size ) // <= because there must be data after header
		return gme_wrong_file_type;
	blargg_err_t err = rom.resize( file_offset + file_size_ + pad_size );
	if ( !err )
		err = in.read( rom.begin() + file_offset, file_size_ );
	if ( err )
	{
		rom.clear();
		return err;
	}
	
	file_size_ -= header_size;
	memcpy( header_out, &rom [file_offset], header_size );
	
	memset( rom.begin()         , fill, pad_size );
	memset( rom.end() - pad_size, fill, pad_size );
	
	return 0;
}
Example #3
0
	blargg_err_t load_( Data_Reader& in )
	{
		long file_size = in.remain();
		if ( file_size <= Vgm_Emu::header_size )
			return gme_wrong_file_type;
		
		RETURN_ERR( in.read( &h, Vgm_Emu::header_size ) );
		RETURN_ERR( check_vgm_header( h ) );
		
		long gd3_offset = get_le32( h.gd3_offset ) - 0x2C;
		long remain = file_size - Vgm_Emu::header_size - gd3_offset;
		byte gd3_h [gd3_header_size];
		if ( gd3_offset > 0 && remain >= gd3_header_size )
		{
			RETURN_ERR( in.skip( gd3_offset ) );
			RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) );
			long gd3_size = check_gd3_header( gd3_h, remain );
			if ( gd3_size )
			{
				RETURN_ERR( gd3.resize( gd3_size ) );
				RETURN_ERR( in.read( gd3.begin(), gd3.size() ) );
			}
		}
		return 0;
	}
Example #4
0
	blargg_err_t load_( Data_Reader& in )
	{
		int file_size = in.remain();
		if ( file_size <= h.size_min )
			return blargg_err_file_type;
		
		RETURN_ERR( in.read( &h, h.size_min ) );
		if ( !h.valid_tag() )
			return blargg_err_file_type;

		if ( h.size() > h.size_min )
			RETURN_ERR( in.read( &h.rf5c68_rate, h.size() - h.size_min ) );

		h.cleanup();

		int data_offset = get_le32( h.data_offset ) + offsetof( Vgm_Core::header_t, data_offset );
		int data_size = file_size - offsetof( Vgm_Core::header_t, data_offset ) - data_offset;
		int gd3_offset = get_le32( h.gd3_offset );
		if ( gd3_offset > 0 )
			gd3_offset += offsetof( Vgm_Core::header_t, gd3_offset );

		int amount_to_skip = gd3_offset - h.size();

		if ( gd3_offset > 0 && gd3_offset > data_offset )
		{
			data_size = gd3_offset - data_offset;
			amount_to_skip = 0;

			RETURN_ERR( data.resize( data_size ) );
			RETURN_ERR( in.skip( data_offset - h.size() ) );
			RETURN_ERR( in.read( data.begin(), data_size ) );
		}

		int remain = file_size - gd3_offset;
		byte gd3_h [gd3_header_size];
		if ( gd3_offset > 0 && remain >= gd3_header_size )
		{
			RETURN_ERR( in.skip( amount_to_skip ) );
			RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) );
			int gd3_size = check_gd3_header( gd3_h, remain );
			if ( gd3_size )
			{
				RETURN_ERR( gd3.resize( gd3_size ) );
				RETURN_ERR( in.read( gd3.begin(), gd3.size() ) );
			}

			if ( data_offset > gd3_offset )
			{
				RETURN_ERR( data.resize( data_size ) );
				RETURN_ERR( in.skip( data_offset - gd3_offset - sizeof gd3_h - gd3.size() ) );
				RETURN_ERR( in.read( data.begin(), data.end() - data.begin() ) );
			}
		}

		return (blargg_err_t)blargg_ok;
	}
Example #5
0
bool Amisic::Initialize()
{
  if (InputPath()=="" && InputFile()=="") return false;
  Data_Reader *reader = new Data_Reader(" ",";","!","=");
  reader->AddComment("#");
  reader->AddWordSeparator("\t");
  reader->SetInputPath(InputPath());
  reader->SetInputFile(InputFile());
  std::vector<std::string> model;
  if (!reader->VectorFromFile(model,"HARD_MODEL_NAME")) {
    model.push_back("Simple_Chain");
  }
  for (size_t i=1;i<model.size();++i) model[0]+=" "+model[i];
  SelectHardModel(model[0]);
  if (!reader->VectorFromFile(model,"SOFT_MODEL_NAME")) {
    model.push_back("None");
  }
  for (size_t i=1;i<model.size();++i) model[0]+=" "+model[i];
  SelectSoftModel(model[0]);
  std::string file;
  if (!reader->ReadFromFile(file,"HARD_MODEL_FILE")) file=InputFile();
  p_hardbase->SetInputPath(InputPath());
  p_hardbase->SetInputFile(file);
  if (!reader->ReadFromFile(file,"SOFT_MODEL_FILE")) file=InputFile();
  p_softbase->SetInputPath(InputPath());
  p_softbase->SetInputFile(file);
  delete reader;
  bool success=true;
  success=success&&p_hardbase->Initialize();
  success=success&&p_softbase->Initialize();
  return success;
}
Example #6
0
// Reads file into array, placing file_offset bytes of padding before the beginning, and pad_size after the end
blargg_err_t Rom_Data::load_( Data_Reader& in, int header_size, int file_offset )
{
	clear();
	file_size_ = in.remain();
	if ( file_size_ <= header_size ) // <= because there must be data after header
		return blargg_err_file_type;
	
	RETURN_ERR( rom.resize( file_offset + file_size_ + pad_size ) );
	
	return in.read( rom.begin() + file_offset, file_size_ );
}
Example #7
0
void Hard_Decay_Handler::ReadDecayTable(Flavour decayer)
{
  DEBUG_FUNC(decayer);
  if (!m_store_results) return;
  Data_Reader reader = Data_Reader("|",";","!");
  reader.SetAddCommandLine(false);
  reader.AddComment("#");
  reader.AddComment("//");
  reader.AddWordSeparator("\t");
  reader.SetInputPath(m_resultdir);
  reader.SetInputFile(decayer.ShellName());
  
  vector<vector<string> > file;
  if(reader.MatrixFromFile(file)) {
    for (size_t iline=0; iline<file.size(); ++iline) {
      if (file[iline].size()==4) {
        string decaychannel=file[iline][0];
        vector<double> results(3);
        for (size_t i=0; i<3; ++i) results[i]=ToType<double>(file[iline][i+1]);
        m_read[decayer].insert(make_pair(decaychannel, results));
      }
      else {
        PRINT_INFO("Wrong format in decay table in "<<m_resultdir);
      }
    }
  }
}
Example #8
0
 blargg_err_t load_( Data_Reader& in )
 {
     int file_size = in.remain();
     if ( file_size < Sfm_Emu::sfm_min_file_size )
         return blargg_err_file_type;
     RETURN_ERR( data.resize( file_size ) );
     RETURN_ERR( in.read( data.begin(), data.end() - data.begin() ) );
     RETURN_ERR( check_sfm_header( data.begin() ) );
     int metadata_size = get_le32( data.begin() + 4 );
     byte temp = data[ 8 + metadata_size ];
     data[ 8 + metadata_size ] = '\0';
     metadata.parseDocument( (const char *)data.begin() + 8 );
     data[ 8 + metadata_size ] = temp;
     return blargg_ok;
 }
Example #9
0
	blargg_err_t load_( Data_Reader& in )
	{
		long file_size = in.remain();
		if ( file_size < Snes_Spc::spc_min_file_size )
			return gme_wrong_file_type;
		RETURN_ERR( in.read( &header, Spc_Emu::header_size ) );
		RETURN_ERR( check_spc_header( header.tag ) );
		long const xid6_offset = 0x10200;
		long xid6_size = file_size - xid6_offset;
		if ( xid6_size > 0 )
		{
			RETURN_ERR( xid6.resize( xid6_size ) );
			RETURN_ERR( in.skip( xid6_offset - Spc_Emu::header_size ) );
			RETURN_ERR( in.read( xid6.begin(), xid6.size() ) );
		}
		return 0;
	}
Example #10
0
	blargg_err_t load_( Data_Reader& in )
	{
		assert( offsetof (header_t,fields) == Hes_Emu::header_size + 0x20 );
		blargg_err_t err = in.read( &h, sizeof h );
		if ( err )
			return (err == in.eof_error ? gme_wrong_file_type : err);
		return check_hes_header( &h );
	}
Example #11
0
void InitialiseGenerator(int argc, char *argv[])
{
  if(argc<2) {
    cout<<"Usage: ./SingleDecay <PDG_CODE>"<<endl;
    THROW(normal_exit,"you didn't specify the decaying particle by PDG code.");
  }

  small_sherpa_init(argc, argv);

  hadrons = new SHERPA::Hadron_Decay_Handler(".", "Fragmentation.dat");

  Data_Reader * reader = new Data_Reader(" ",";","!","=");
  reader->AddWordSeparator("\t");
  reader->SetInputPath("./");
  reader->SetInputFile("YFS.dat");
  photons = new PHOTONS::Photons(reader,true);

  mother_flav = Flavour( (kf_code) abs(ToType<int>(argv[1])) );
  mother_flav.SetStable(false);
  if(ToType<int>(argv[1])<0) mother_flav=mother_flav.Bar();

  rpa->gen.SetEcms(mother_flav.HadMass());
  msg_Info()<<"Welcome. I am decaying a "<<mother_flav<<endl;

  Particle* mother_part = new Particle( 1,mother_flav,
                                        Vec4D(mother_flav.HadMass(),0.,0.,0.) );
  mother_part->SetTime();
  mother_part->SetFinalMass(mother_flav.HadMass());
  
  ref_blob = new Blob();
  ref_blob->SetType(btp::Hadron_Decay);
  ref_blob->SetStatus(blob_status::needs_hadrondecays);
  ref_blob->AddToInParticles(mother_part);

  try {
    hadrons->FillOnshellDecay(ref_blob, NULL);
  } catch (Return_Value::code ret) {
    msg_Error()<<METHOD<<" Something went wrong for blob: "<<ref_blob<<endl;
    return;
  }
}
Example #12
0
	blargg_err_t load_( Data_Reader& in )
	{
		blargg_err_t err = in.read( &h, h.size );
		if ( err )
			return (blargg_is_err_type( err, blargg_err_file_eof ) ? blargg_err_file_type : err);
		
		set_track_count( h.track_count );
		if ( !h.valid_tag() )
			return blargg_err_file_type;
		
		return blargg_ok;
	}
Example #13
0
	blargg_err_t load_( Data_Reader& in )
	{
		blargg_err_t err = in.read( &h, Nsf_Emu::header_size );
		if ( err )
			return (err == in.eof_error ? gme_wrong_file_type : err);
		
		if ( h.chip_flags & ~(namco_flag | vrc6_flag | fme7_flag) )
			set_warning( "Uses unsupported audio expansion hardware" );
		
		set_track_count( h.track_count );
		return check_nsf_header( &h );
	}
Example #14
0
bool Simple_String::Initialize()
{
  CleanUp();
  if (InputPath()=="" && InputFile()=="") return false;
  if (!rpa->gen.Beam1().IsHadron() ||
      !rpa->gen.Beam2().IsHadron()) return false;
  Data_Reader *reader = new Data_Reader(" ",";","!","=");
  reader->AddComment("#");
  reader->AddWordSeparator("\t");
  reader->SetInputPath(InputPath());
  reader->SetInputFile(InputFile());
  std::vector<std::vector<std::string> > helpsvv;
  if (!reader->MatrixFromFile(helpsvv,"REGGE_TRAJECTORY")) {
    helpsvv.push_back(std::vector<std::string>(3));
    helpsvv.back()[0]="Pomeron";
    helpsvv.back()[1]="1.0808";
    helpsvv.back()[2]="0.25";
  }
  msg_Info()<<"Simple_String::Initialize(): Adding Reggeon {\n";
  for (size_t i=0;i<helpsvv.size();++i) {
    if (helpsvv[i].size()<3) continue;
    m_reggeons.push_back(new Reggeon_Trajectory
			 (ToType<double>(helpsvv[i][1]),
			  ToType<double>(helpsvv[i][2])));
    m_reggeons.back()->SetS(sqr(rpa->gen.Ecms()));
    msg_Info()<<"   "<<std::setw(10)<<helpsvv[i][0]
	      <<" "<<std::setw(8)<<helpsvv[i][1]
	      <<" "<<std::setw(8)<<helpsvv[i][2]<<"\n";
  }
  msg_Info()<<"}"<<std::endl;
  p_remnants[0]=p_isr->GetRemnant(0);
  p_remnants[1]=p_isr->GetRemnant(1);
  return true;
}
Example #15
0
blargg_err_t Nes_Snapshot::read_sta_file( Data_Reader& in )
{
	sram_size = 0x2000;
	BLARGG_RETURN_ERR( in.read( sram, sram_size ) );
	
	ram_valid = true;
	BLARGG_RETURN_ERR( in.read( ram, 0x800 ) );
	
	sta_regs_t r;
	BLARGG_RETURN_ERR( in.read( &r, sizeof r ) );
	this->cpu.pc = r.pc [1] * 0x100 + r.pc [0];
	this->cpu.a = r.a;
	this->cpu.status = r.p;
	this->cpu.x = r.x;
	this->cpu.y = r.y;
	this->cpu.sp = r.s;
	cpu_valid = true;
	
	BLARGG_RETURN_ERR( in.read( spr_ram, 0x100 ) );
	spr_ram_valid = true;
	
	chr_size = 0x2000;
	BLARGG_RETURN_ERR( in.read( chr, chr_size ) );
	
	nametable_size = 0x1000;
	BLARGG_RETURN_ERR( in.read( nametable, nametable_size ) );
	
	return blargg_success;
}
Example #16
0
blargg_err_t Nes_Rom::load_patched_ines_rom( Data_Reader& in, Data_Reader& patch )
{
	// read file into memory
	long size = in.remain();
	byte* ines = (byte*) malloc( size );
	BLARGG_CHECK_ALLOC( ines );
	const char* err = in.read( ines, size );
	
	// apply patch
	if ( !err )
		err = apply_ips_patch( patch, &ines, &size );
	
	// load patched file
	if ( !err )
	{
		Mem_File_Reader patched( ines, size );
		err = load_ines_rom( patched );
	}
	
	free( ines );
	
	return err;
}
Example #17
0
blargg_err_t Nes_Rom::load_ines_rom( Data_Reader& in )
{
	ines_header_t h;
	BLARGG_RETURN_ERR( in.read( &h, sizeof h ) );
	
	if ( 0 != memcmp( h.signature, "NES\x1A", 4 ) )
		return "Not a iNES ROM file";
	
	if ( h.zero [7] ) // handle header defaced by a f*****g idiot's handle
		h.flags2 = 0;
	
	set_mapper( h.flags, h.flags2 );
	
	if ( h.flags & 0x04 ) // skip trainer
		BLARGG_RETURN_ERR( in.skip( 512 ) );
	
	BLARGG_RETURN_ERR( resize_prg( h.prg_count * 16 * 1024L ) );
	BLARGG_RETURN_ERR( resize_chr( h.chr_count * 8 * 1024L ) );
	
	BLARGG_RETURN_ERR( in.read( prg(), prg_size() ) );
	BLARGG_RETURN_ERR( in.read( chr(), chr_size() ) );
	
	return blargg_success;
}
Example #18
0
static blargg_err_t apply_ips_patch( Data_Reader& patch, byte** file, long* file_size )
{
	byte signature [5];
	BLARGG_RETURN_ERR( patch.read( signature, sizeof signature ) );
	if ( memcmp( signature, "PATCH", sizeof signature ) )
		return "Not an IPS patch file";
	
	while ( patch.remain() )
	{
		// read offset
		byte buf [6];
		BLARGG_RETURN_ERR( patch.read( buf, 3 ) );
		long offset = buf [0] * 0x10000 + buf [1] * 0x100 + buf [2];
		if ( offset == 'EOF' )
			break;
		
		// read size
		BLARGG_RETURN_ERR( patch.read( buf, 2 ) );
		long size = buf [0] * 0x100 + buf [1];
		
		// size = 0 signals a run of identical bytes
		int fill = -1;
		if ( size == 0 )
		{
			BLARGG_RETURN_ERR( patch.read( buf, 3 ) );
			size = buf [0] * 0x100 + buf [1];
			fill = buf [2];
		}
		
		// expand file if new data is at exact end of file
		if ( offset == *file_size )
		{
			*file_size = offset + size;
			void* p = realloc( *file, *file_size );
			BLARGG_CHECK_ALLOC( p );
			*file = (byte*) p;
		}
		
		//dprintf( "Patch offset: 0x%04X, size: 0x%04X\n", (int) offset, (int) size );
		
		if ( offset < 0 || *file_size < offset + size )
			return "IPS tried to patch past end of file";
		
		// read/fill data
		if ( fill < 0 )
			BLARGG_RETURN_ERR( patch.read( *file + offset, size ) );
		else
			memset( *file + offset, fill, size );
	}
	
	return blargg_success;
}
Example #19
0
// Read multiple strings and separate into individual strings
static blargg_err_t read_strs( Data_Reader& in, int size, blargg_vector<char>& chars,
		blargg_vector<const char*>& strs )
{
	RETURN_ERR( chars.resize( size + 1 ) );
	chars [size] = 0; // in case last string doesn't have terminator
	RETURN_ERR( in.read( &chars [0], size ) );
	
	RETURN_ERR( strs.resize( 128 ) );
	int count = 0;
	for ( int i = 0; i < size; i++ )
	{
		if ( (int) strs.size() <= count )
			RETURN_ERR( strs.resize( count * 2 ) );
		strs [count++] = &chars [i];
		while ( i < size && chars [i] )
			i++;
	}
	
	return strs.resize( count );
}
Example #20
0
blargg_err_t M3u_Playlist::load( Data_Reader& in )
{
	RETURN_ERR( data.resize( in.remain() + 1 ) );
	RETURN_ERR( in.read( data.begin(), data.size() - 1 ) );
	return parse();
}
Example #21
0
void Hadron_Decay_Channel::ProcessME( vector<vector<string> > me_svv,
                                      Data_Reader           & reader,
                                      GeneralModel          & model_for_ps )
{
  int nr_of_mes=0;
  Algebra_Interpreter ip;
  ip.AddTag("GF", "8.24748e-6");
  for (size_t i=0;i<me_svv.size();i++) {
    if(me_svv[i].size()==3) {
      msg_Tracking()<<"Selecting ME for "<<Name()<<endl;
      HD_ME_Base* me = SelectME( me_svv[i][2] );
      me->SetPath(m_path);
      msg_Tracking()<<"  "<<me->Name()<<endl;
      vector<vector<string> > parameter_svv;
      reader.SetFileBegin("<"+me_svv[i][2]+">"); reader.SetFileEnd("</"+me_svv[i][2]+">");
      reader.RereadInFile();
      reader.MatrixFromFile(parameter_svv);
      GeneralModel me_model=Parameters2Model(parameter_svv,model_for_ps);
      me->SetModelParameters( me_model );
      Complex factor = Complex(ToType<double>(ip.Interprete(me_svv[i][0])),
                               ToType<double>(ip.Interprete(me_svv[i][1])));
      me->SetFactor(factor);
      PHASIC::Color_Function_Decay* col=new PHASIC::Color_Function_Decay();
      AddDiagram(me, col);
      nr_of_mes++;
    }
    if(me_svv[i].size()==4) {
      msg_Tracking()<<"Selecting currents for "<<Name()<<endl;
      Current_Base* current1 = SelectCurrent(me_svv[i][2]);
      current1->SetPath(m_path);
      vector<vector<string> > parameter1_svv;
      reader.SetFileBegin("<"+me_svv[i][2]+">"); reader.SetFileEnd("</"+me_svv[i][2]+">");
      reader.RereadInFile();
      reader.MatrixFromFile(parameter1_svv);
      GeneralModel current1_model=Parameters2Model(parameter1_svv,model_for_ps);
      current1->SetModelParameters( current1_model );

      Current_Base* current2 = SelectCurrent(me_svv[i][3]);
      current2->SetPath(m_path);
      vector<vector<string> > parameter2_svv;
      reader.SetFileBegin("<"+me_svv[i][3]+">"); reader.SetFileEnd("</"+me_svv[i][3]+">");
      reader.RereadInFile();
      reader.MatrixFromFile(parameter2_svv);
      GeneralModel current2_model=Parameters2Model(parameter2_svv,model_for_ps);
      current2->SetModelParameters( current2_model );

      msg_Tracking()<<"  "<<current1->Name()<<endl;
      msg_Tracking()<<"  "<<current2->Name()<<endl;

      // Sanity checks for current selection
      if(size_t(1+NOut()) != current1->DecayIndices().size()+
         current2->DecayIndices().size()) {
        msg_Error()<<"Error in "<<METHOD<<": Current selection does not look sane "
                   <<"for "<<Name()<<". Check decaychannelfile."<<std::endl;
        abort();
      }

      Complex factor = Complex(ToType<double>(ip.Interprete(me_svv[i][0])),
                               ToType<double>(ip.Interprete(me_svv[i][1])));

      vector<int> indices (NOut()+1);
      for(int i=0; i<NOut()+1; i++) indices[i] = i;

      Current_ME* me=
        new Current_ME(m_physicalflavours, indices, "Current_ME");
      me->SetCurrent1(current1);
      me->SetCurrent2(current2);
      me->SetFactor(factor);
      PHASIC::Color_Function_Decay* col=new PHASIC::Color_Function_Decay();
      AddDiagram(me, col);
      nr_of_mes++;
    }
  }
  if(nr_of_mes == 0) {
    msg_Error()<<METHOD<<": Warning. No valid matrix element found in "
               <<m_path<<m_filename<<". Using Generic."<<endl;
    int n=NOut()+1;
    vector<int> decayindices(n);
    for(int i=0;i<n;i++) decayindices[i]=i;
    HD_ME_Base* me=new Generic(m_physicalflavours,decayindices,"Generic");
    PHASIC::Color_Function_Decay* col=new PHASIC::Color_Function_Decay();
    AddDiagram(me, col);
  }
}
Example #22
0
Lund_Interface::Lund_Interface(string _m_path,string _m_file):
  m_path(_m_path),m_file(_m_file), m_maxtrials(2),
  p_hepevt(NULL), 
  m_compress(true),m_writeout(false),
  p_phep(new double[5*HEPEVT_CB_SIZE]),
  p_vhep(new double[4*HEPEVT_CB_SIZE]),
  p_jmohep(new int[2*HEPEVT_CB_SIZE]),
  p_jdahep(new int[2*HEPEVT_CB_SIZE])
{
  exh->AddTerminatorObject(this);
  double win;
  string beam[2], frame("CMS");
  Flavour flav[2];
  for (size_t i=0;i<2;++i) flav[i]=rpa->gen.Bunch(i);
  if (flav[0].Kfcode()==kf_e && flav[1].Kfcode()==kf_p_plus) {
    if (flav[0].IsAnti()) beam[0]="e+"; else beam[0]="e-";
    if (flav[1].IsAnti()) beam[1]="p-"; else beam[1]="p+";
    pysubs.msub[9]=1;    
  }
  else if (flav[0].Kfcode()==kf_p_plus && flav[1].Kfcode()==kf_e) {
    if (flav[0].IsAnti()) beam[0]="p-"; else beam[0]="p+";
    if (flav[1].IsAnti()) beam[1]="e+"; else beam[1]="e-";
    pysubs.msub[9]=1;    
  }
  else if (flav[0]==Flavour(kf_e) && flav[1]==Flavour(kf_photon)) {
    if (flav[0].IsAnti()) beam[0]="e+"; else beam[0]="e-";
    beam[1]="gamma";
    pysubs.msub[33]=1;    
  }
  else if (flav[0]==Flavour(kf_photon) && flav[1]==Flavour(kf_e)) {
    beam[0]="gamma";
    if (flav[1].IsAnti()) beam[1]="e+"; else beam[1]="e-";
    pysubs.msub[33]=1;    
  }
  else if (flav[0]==Flavour(kf_photon) && flav[1]==Flavour(kf_photon)) {
    for (size_t i=0;i<2;++i) beam[i]="gamma";
    pysubs.msub[57]=1;    
  }
  else if (flav[0].Kfcode()==kf_e && flav[1].Kfcode()==kf_e) {
    for (size_t i=0;i<2;++i) if (flav[i].IsAnti()) beam[i]="e+"; else beam[i]="e-";
    pysubs.msub[0]=1;    
    pypars.mstp[47]=1;
    pydat1.mstj[100]=5;
  }
  else {
    for (size_t i=0;i<2;++i) if (flav[i].IsAnti()) beam[i]="p-"; else beam[i]="p+";
    pysubs.msub[0]=1;    
    pypars.mstp[47]=1;
    pydat1.mstj[100]=5;
  }
  win=rpa->gen.Ecms();
  s_maxerrors=rpa->gen.NumberOfEvents();
  vector<vector<double> > help;
  Data_Reader *reader = new Data_Reader(" ",";","!","=");
  reader->AddComment("#");
  reader->AddWordSeparator("\t");
  reader->SetInputPath(m_path);
  reader->SetInputFile(m_file);
  reader->AddIgnore("(");
  reader->AddIgnore(")");
  reader->AddIgnore(",");
  pysubs.msel=0;
  reader->MatrixFromFile(help,"MSUB");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pysubs.msub[(int)help[i][0]-1]=(int)help[i][1];
  }
  reader->MatrixFromFile(help,"KFIN");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>2) {
      if (((int)help[i][0]>0)&&((int)help[i][1]>-41)) {
	pysubs.kfin[(int)help[i][1]+40][(int)help[i][0]-1]=(int)help[i][2];
      }
    }
  }
  reader->MatrixFromFile(help,"CKIN");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pysubs.ckin[(int)help[i][0]-1]=help[i][1];
  }
  reader->MatrixFromFile(help,"MSTJ");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pydat1.mstj[(int)help[i][0]-1]=(int)help[i][1];
  }
  reader->MatrixFromFile(help,"MSTP");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pypars.mstp[(int)help[i][0]-1]=(int)help[i][1];
  }
  reader->MatrixFromFile(help,"MSTU");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pydat1.mstu[(int)help[i][0]-1]=(int)help[i][1];
  }
  reader->MatrixFromFile(help,"PARP");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pypars.parp[(int)help[i][0]-1]=help[i][1];
  }
  reader->MatrixFromFile(help,"PARJ");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pydat1.parj[(int)help[i][0]-1]=help[i][1];
  }
  reader->MatrixFromFile(help,"PARU");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>1) if ((int)help[i][0]>0) pydat1.paru[(int)help[i][0]-1]=help[i][1];
  }
  reader->MatrixFromFile(help,"MDME");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>2) {
      if ((int)help[i][0]>0 && abs((int)help[i][1]<2)) {
	pydat3.mdme[(int)help[i][1]-1][(int)help[i][0]-1]=(int)help[i][2];
      }
    }
  }
  reader->MatrixFromFile(help,"MDCYKF");
  for (size_t i=0;i<help.size();++i) {
    if (help[i].size()>2) {
      if ((int)help[i][0]>0 && abs((int)help[i][1]<2)) {
	msg_Tracking()<<"Lund_Interface::Lund_Interface(..): "
		      <<"Set MDCY("<<pycomp((int)help[i][0])<<","<<(int)help[i][1]
		      <<") ( from KF code "<<(int)help[i][0]<<" ) to "<<(int)help[i][2]<<endl;
	pydat3.mdcy[(int)help[i][1]-1][pycomp((int)help[i][0])-1]=(int)help[i][2];
      }
    }
  }
  // the next lines replace the apyinit_ call
  hepevt.nhep=100;
  for (int i=pydat3.mdcy[2-1][23-1];i<pydat3.mdcy[2-1][23-1]+pydat3.mdcy[3-1][23-1];++i) {
    if (abs(pydat3.kfdp[1-1][i-1])>=2) pydat3.mdme[1-1][i-1]=Min(0,pydat3.mdme[1-1][i-1]);
  }
  pyinit(frame.c_str(),beam[0].c_str(),beam[1].c_str(),100.0);
  // replacement ends here
  if (msg_LevelIsDebugging()) ListLundParameters();
  pylist(0);
  delete reader;
}
Example #23
0
void FeynRules_Model::ParticleInit() {
  m_partfile = p_dataread->GetValue<string>("FR_PARTICLES",std::string("Particle.dat"));
  Data_Reader reader = Data_Reader(" ",";","!","=");
  p_dataread->AddComment("#");
  reader.AddWordSeparator("\t");
  reader.SetAddCommandLine(false);
  reader.SetInputPath(m_dir);
  reader.SetInputFile(m_partfile);
  
  kf_code kfc;
  int     charge,icharge,spin,strong,Majorana;
  bool    Take,stable,massive;
  double  mass,width;
  std::string idname, texname;
  
  if (!reader.OpenInFile()) {
    msg_Error()<<METHOD<<"(): FeynRules particle data file '"
	       <<m_partfile<<"' not found."<<std::endl;
    return;
  }
  std::vector<std::vector<std::string> > helpsvv;
  reader.MatrixFromFile(helpsvv);
  for(size_t i(1);i<helpsvv.size();++i) {
    if (helpsvv[i].size()!=13) {
      msg_Error()<<METHOD<<"(): Inconsistent entry in line "<<i
  		 <<" of '"<<reader.InputFile()<<"'."<<std::endl;
      continue;
    }

    if (helpsvv[i][0]==std::string("kf")) continue;

    kfc=ToType<int>(helpsvv[i][0]); 
    mass=ToType<double>(helpsvv[i][1]); width=ToType<double>(helpsvv[i][2]);
    charge=ToType<int>(helpsvv[i][3]); icharge=ToType<int>(helpsvv[i][4]);
    strong=ToType<int>(helpsvv[i][5]); spin=ToType<int>(helpsvv[i][6]);
    Majorana=ToType<int>(helpsvv[i][7]); Take=ToType<int>(helpsvv[i][8]);
    stable=ToType<int>(helpsvv[i][9]); massive=ToType<int>(helpsvv[i][10]);
    idname=helpsvv[i][11]; texname=helpsvv[i][12];
    s_kftable[kfc] = new Particle_Info(kfc,mass,width,charge,icharge,strong,spin,
				       Majorana,Take,stable,massive,idname,texname);
  }
  ReadParticleData();
  
  // add containers
  s_kftable[kf_none] = new
    Particle_Info(kf_none,-1,0,0,0,0,0,-1,0,1,0,"no_particle","no particle",0,1);
  s_kftable[kf_resummed] = new
    Particle_Info(kf_resummed,0.,0.,0,0,1,2,0,1,1,0,"r","resummed",0,1);
  s_kftable[kf_bjet] = new
    Particle_Info(kf_bjet,0.,0.,0,0,1,2,0,1,1,0,"bj","bjet",0,1);

  s_kftable[kf_fermion] = new
    Particle_Info(kf_fermion,0.,0., 0,0,0,1,0,1,1,0,"fermion","fermion",0,1);
  s_kftable[kf_jet] = new
    Particle_Info(kf_jet,0.,0.,0,0,1, 2,0,1,1,0,"j","jet",0,1);
  s_kftable[kf_quark] = new
    Particle_Info(kf_quark,0.,0.,0, 0,1,1,0,1,1,0,"Q","Quark",0,1);
  s_kftable[kf_lepton] = new
    Particle_Info(kf_lepton,0.,0.,-3,-1,0,1,0,1,1,0,"lepton","lepton",0,1);
  s_kftable[kf_neutrino] = new
    Particle_Info(kf_neutrino,0.,0.,0,1,0, 1,0,1,1,0,"neutrino","neutrino",0,1);
  s_kftable[kf_fermion]->Clear();
  s_kftable[kf_jet]->Clear();
  s_kftable[kf_resummed]->Clear();
  s_kftable[kf_resummed]->m_resummed=true;
  s_kftable[kf_quark]->Clear();
  s_kftable[kf_lepton]->Clear();
  s_kftable[kf_neutrino]->Clear();
  for (int i=1;i<7;i++) {
    Flavour addit((kf_code)i);
    if (addit.Mass()==0.0 || (!addit.IsMassive() && addit.IsOn())) {
      s_kftable[kf_jet]->Add(addit);
      s_kftable[kf_jet]->Add(addit.Bar());
      s_kftable[kf_quark]->Add(addit);
      s_kftable[kf_quark]->Add(addit.Bar());
      s_kftable[kf_fermion]->Add(addit);
      s_kftable[kf_fermion]->Add(addit.Bar());
    }
  }
  s_kftable[kf_jet]->Add(Flavour(kf_gluon));
  s_kftable[kf_jet]->SetResummed();
  for (int i=11;i<17;i+=2) {
    Flavour addit((kf_code)i);
    if (addit.Mass()==0.0 || (!addit.IsMassive() && addit.IsOn())) {
      s_kftable[kf_lepton]->Add(addit);
      s_kftable[kf_lepton]->Add(addit.Bar());
      s_kftable[kf_fermion]->Add(addit);
      s_kftable[kf_fermion]->Add(addit.Bar());
    }
  }
  for (int i=12;i<18;i+=2) {
    Flavour addit((kf_code)i);
    if (addit.Mass()==0.0 && addit.IsOn()) {
      s_kftable[kf_neutrino]->Add(addit);
      s_kftable[kf_neutrino]->Add(addit.Bar());
      s_kftable[kf_fermion]->Add(addit);
      s_kftable[kf_fermion]->Add(addit.Bar());
    }
  }
}
Example #24
0
blargg_err_t Gme_File::load_( Data_Reader& in )
{
	RETURN_ERR( file_data.resize( in.remain() ) );
	RETURN_ERR( in.read( file_data.begin(), (long)file_data.size() ) );
	return load_mem_( file_data.begin(), (long)file_data.size() );
}
Example #25
0
blargg_err_t Gme_Loader::load_( Data_Reader& in )
{
	RETURN_ERR( file_data.resize( in.remain() ) );
	RETURN_ERR( in.read( file_data.begin(), file_data.size() ) );
	return load_mem_wrapper( file_data.begin(), file_data.size() );
}