sherpa is hosted by Hepforge, IPPP Durham
close Warning: Can't synchronize with repository "(default)" (/hepforge/svn/sherpa does not appear to be a Subversion repository.). Look in the Trac log for more information.

Ticket #80: event-selector.patch

File event-selector.patch, 4.3 KB (added by Frank Siegert, 14 years ago)
  • SHERPA/Tools/Input_Output_Handler.C

     
    3434#ifdef USING__HEPMC2
    3535  p_hepmc2(NULL),
    3636#endif
    37   p_hepevt(NULL)
     37  p_hepevt(NULL),
     38  p_eventhandler(NULL), p_mehandler(NULL)
    3839{
    3940  InitialiseOutput(dr);
    4041}
     
    167168bool Input_Output_Handler::OutputToFormat(ATOOLS::Blob_List *const blobs)
    168169{
    169170  double weight=blobs->Weight();
    170   weight/=p_mehandler->TotalXS()*rpa.Picobarn();
     171  if (p_mehandler) weight/=p_mehandler->TotalXS()*rpa.Picobarn();
    171172
    172   double xs(p_eventhandler->TotalXS()), xserr(p_eventhandler->TotalErr());
     173  double xs(1.0), xserr(0.0);
     174  if (p_eventhandler) {
     175    xs=p_eventhandler->TotalXS();
     176    xserr=p_eventhandler->TotalErr();
     177  }
    173178  for (map<string,Output_Base *>::iterator oit=m_outmap.begin();
    174179       oit!=m_outmap.end();oit++) {
    175180    oit->second->SetXS(xs, xserr);
     
    178183 
    179184  m_evtnumber++;
    180185  m_evtcount++;
    181  
     186
    182187  if (m_evtcount%m_filesize==0) {
    183188    m_evtcount = 0;
    184189    string number(ToString(int(m_evtnumber/m_filesize)));
  • AddOns/Analysis/Observables/Event_Output.C

     
     1#include "AddOns/Analysis/Observables/Primitive_Observable_Base.H"
     2#include "ATOOLS/Org/MyStrStream.H"
     3#include "ATOOLS/Org/Data_Reader.H"
     4#include "ATOOLS/Org/Exception.H"
     5
     6#include "SHERPA/Tools/Input_Output_Handler.H"
     7#include "AddOns/Analysis/Main/Primitive_Analysis.H"
     8
     9using namespace ANALYSIS;
     10using namespace ATOOLS;
     11using namespace SHERPA;
     12
     13namespace ANALYSIS {
     14
     15  class Event_Output : public Primitive_Observable_Base {
     16    Input_Output_Handler* p_io;
     17    std::string m_inlist;
     18  public:
     19
     20    Event_Output(Input_Output_Handler* io, const std::string& inlist) :
     21      Primitive_Observable_Base(), p_io(io), m_inlist(inlist)
     22    {
     23    }
     24
     25    ~Event_Output()
     26    {
     27      if (p_io) delete p_io; p_io=NULL;
     28    }
     29
     30
     31    void Evaluate(const ATOOLS::Blob_List & blobs, double value, double ncount)
     32    {
     33      if (!p_io) return;
     34      Particle_List * pl=p_ana->GetParticleList(m_inlist);
     35      if (pl->empty()) return;
     36      Blob_List* blobsptr=const_cast<Blob_List*>(&blobs);
     37      p_io->OutputToFormat(blobsptr);
     38    }
     39
     40
     41    Primitive_Observable_Base * Copy() const
     42    {
     43      // don't duplicate event output
     44      return new Event_Output(NULL, "");
     45    }
     46
     47  };// end of class Event_Output
     48
     49}
     50
     51
     52
     53DECLARE_GETTER(Event_Output_Getter,"Event_Output",
     54               Primitive_Observable_Base,Argument_Matrix);
     55
     56Primitive_Observable_Base *
     57Event_Output_Getter::operator()(const Argument_Matrix &parameters) const
     58{
     59  Data_Reader reader(" ",";","!","=");
     60  reader.AddComment("#");
     61  reader.AddWordSeparator("\t");
     62  std::string inlist="";
     63  for (size_t i=0; i<parameters.size(); ++i) {
     64    std::string line = "";
     65    for (size_t j=0; j<parameters[i].size(); ++j) {
     66      line += parameters[i][j]+" ";
     67    }
     68    reader.AddFileContent(line);
     69    if (parameters[i][0]=="InList" && parameters[i].size()>1) inlist=parameters[i][1];
     70  }
     71
     72  if (inlist=="") {
     73    THROW(fatal_error, "You didn't specify an InList for Event_Output");
     74  }
     75  return new Event_Output(new Input_Output_Handler(&reader), inlist);
     76}
     77
     78void Event_Output_Getter::PrintInfo(std::ostream &str,const size_t width) const
     79{
     80  str<<"{\n"
     81     <<std::setw(width+7)<<" "<<"InList  <triggeroutlist>\n"
     82     <<std::setw(width+7)<<" "<<"# event output settings cf. manual, e.g.:\n"
     83     <<std::setw(width+7)<<" "<<"HEPMC2_GENEVENT_OUTPUT <filename>\n"
     84     <<std::setw(width+7)<<" "<<"FILE_SIZE <n>\n"
     85     <<std::setw(width+7)<<" "<<"EVT_FILE_PATH <path>\n"
     86     <<std::setw(width+4)<<" "<<"}";
     87}
  • AddOns/Analysis/Observables/Makefile.am

     
    55endif
    66
    77ANAOBS_SOURCES        = \
     8                        Event_Output.C \
    89                        $(EXTRAOBS) \
    910                        Global_Calculator.C \
    1011                        Primitive_Observable_Base.C \