Exemplo n.º 1
0
int main(int argc, char ** argv) 
{
  if(argc < 4)
    {
      cout << "Usage:   " << argv[0] 
           << " fileToSplit.lhe events_per_file tag_for_splitting" << endl ;
      return -1;
    }

  std::ifstream ifs (argv[1]) ;
  LHEF::Reader reader (ifs) ;

  int eventsPerFile = atoi (argv[2]) ;

  LHEF::Writer * writer ;
  ofstream outputStream ;

  int ieve = 0 ;
  int index = 0 ;
  //PG loop over input events
  while (reader.readEvent ()) 
    {
      if (ieve == 0)
        { 
          stringstream filename ;
          filename << argv[3] << "_" << index << ".lhe" ;
          outputStream.open (filename.str ().c_str ()) ;
          cout << "opening in output : " << filename.str () << endl ;
          writer = new LHEF::Writer (outputStream) ;
          writer->headerBlock() << reader.headerBlock ;
          writer->initComments() << reader.initComments ;
          writer->heprup = reader.heprup ;
          writer->init () ;
        }

      if ( reader.outsideBlock.length() ) std::cout << reader.outsideBlock;
      writer->eventComments() << reader.eventComments;
      writer->hepeup = reader.hepeup;
      writer->writeEvent();
      ieve++ ;

      if (ieve % eventsPerFile == 0)
        {
          ieve = 0 ;
          index++ ;
          delete writer ;
          outputStream.close () ;
        }
    } //PG loop over input events

  if (ieve % eventsPerFile != 0)  delete writer ;
  return 0 ;
}
Exemplo n.º 2
0
int main (int argc, char ** argv) 
{
  if(argc < 3)
    {
      cout << "Usage:   " << argv[0] 
           << " input.lhe output.lhe" << endl ;
      return -1;
    }

  std::ifstream ifs (argv[1]) ;
  LHEF::Reader reader (ifs) ;

  ofstream outputStream (argv[2]) ;
  LHEF::Writer writer (outputStream) ;

  writer.headerBlock () << reader.headerBlock ;
  writer.initComments () << reader.initComments ;
  writer.heprup = reader.heprup ;
  writer.init () ;

//PG mu massless in phantom
//  float k2 = 0.1056583715 * 0.1056583715 - 1.77682 * 1.77682 ; // GeV -3.14592562093
  float k2 = 0. - 1.77682 * 1.77682 ; // GeV -3.14592562093

  int count = 0 ;
  //PG loop over input events
  while (reader.readEvent ()) 
    {
      ++count ;
      if ( reader.outsideBlock.length ()) std::cout << reader.outsideBlock;

      // loop over particles in the event
      for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) 
        {
           // outgoing particles          
           if (reader.hepeup.ISTUP.at (iPart) == 1)
             {
               if (abs (reader.hepeup.IDUP.at (iPart)) == 13)
                 {
                   TLorentzVector dummy
                     (
                       reader.hepeup.PUP.at (iPart).at (0), // px
                       reader.hepeup.PUP.at (iPart).at (1), // py
                       reader.hepeup.PUP.at (iPart).at (2), // pz
                       reader.hepeup.PUP.at (iPart).at (3) // E
                     ) ;
                   float p2 = dummy.Vect ().Mag2 () ;

                   float scale = sqrt (1 + k2 / p2) ;
                   if (p2 < (-1 * k2))
                     {
                       cout << "warning: p2 is smaller than the mass difference " << p2 << endl ;
                       scale = 1 ;                     
                     }
                   reader.hepeup.PUP.at (iPart).at (0) *= scale ; // px
                   reader.hepeup.PUP.at (iPart).at (1) *= scale ; // px
                   reader.hepeup.PUP.at (iPart).at (2) *= scale ; // px
    
                   if (reader.hepeup.IDUP.at (iPart) == 13) reader.hepeup.IDUP.at (iPart) = 15 ;
                   if (reader.hepeup.IDUP.at (iPart) == -13) reader.hepeup.IDUP.at (iPart) = -15 ;
                 }
               if (reader.hepeup.IDUP.at (iPart) == 14) reader.hepeup.IDUP.at (iPart) = 16 ;
               if (reader.hepeup.IDUP.at (iPart) == -14) reader.hepeup.IDUP.at (iPart) = -16 ;
             } // outgoing particles
        } // loop over particles in the event
      writer.eventComments () << reader.eventComments ;
      writer.hepeup = reader.hepeup ;
      bool written = writer.writeEvent () ;
      if (!written)
        {
          cout << "warning: event " << count << " not written" << endl ;
        }

    } //PG loop over input events

  cout << "end loop over " << count << " events" << endl ;
  return 0 ;
}