Page MenuHomeHEPForge

No OneTemporary

diff --git a/Analysis/RivetAnalysis.cc b/Analysis/RivetAnalysis.cc
--- a/Analysis/RivetAnalysis.cc
+++ b/Analysis/RivetAnalysis.cc
@@ -1,109 +1,132 @@
// -*- C++ -*-
//
// This is the implementation of the non-inlined, non-templated member
// functions of the RivetAnalysis class.
//
#include "RivetAnalysis.h"
#include "ThePEG/Interface/ClassDocumentation.h"
#include "ThePEG/Interface/ParVector.h"
#include "ThePEG/Interface/Parameter.h"
+#include "ThePEG/Interface/Switch.h"
#include "ThePEG/Persistency/PersistentOStream.h"
#include "ThePEG/Persistency/PersistentIStream.h"
#include "ThePEG/Vectors/HepMCConverter.h"
#include "ThePEG/Config/HepMCHelper.h"
#include "ThePEG/Repository/EventGenerator.h"
#include "ThePEG/Repository/CurrentGenerator.h"
#include "HepMC/GenEvent.h"
#include "Rivet/AnalysisHandler.hh"
+#include "Rivet/Tools/Logging.hh"
using namespace ThePEG;
-RivetAnalysis::RivetAnalysis() : _rivet(), _nevent(0)
+RivetAnalysis::RivetAnalysis() : debug(false), _rivet(), _nevent(0)
{}
void RivetAnalysis::analyze(ThePEG::tEventPtr event, long ieve, int loop, int state) {
++_nevent;
AnalysisHandler::analyze(event, ieve, loop, state);
// Rotate to CMS, extract final state particles and call analyze(particles).
// convert to hepmc
HepMC::GenEvent * hepmc = ThePEG::HepMCConverter<HepMC::GenEvent>::convert(*event);
// analyse the event
CurrentGenerator::Redirect stdout(cout);
- _rivet->analyze(*hepmc);
+ _rivet && _rivet->analyze(*hepmc);
// delete hepmc event
delete hepmc;
}
ThePEG::IBPtr RivetAnalysis::clone() const {
return new_ptr(*this);
}
ThePEG::IBPtr RivetAnalysis::fullclone() const {
return new_ptr(*this);
}
void RivetAnalysis::persistentOutput(ThePEG::PersistentOStream & os) const {
- os << _analyses << filename;
+ os << _analyses << filename << debug;
}
void RivetAnalysis::persistentInput(ThePEG::PersistentIStream & is, int) {
- is >> _analyses >> filename;
+ is >> _analyses >> filename >> debug;
}
ThePEG::ClassDescription<RivetAnalysis> RivetAnalysis::initRivetAnalysis;
// Definition of the static class description member.
void RivetAnalysis::Init() {
static ThePEG::ClassDocumentation<RivetAnalysis> documentation
("The RivetAnalysis class is a simple class to allow analyses"
" from the Rivet library to be called from ThePEG");
static ThePEG::ParVector<RivetAnalysis,string> interfaceAnalyses
("Analyses",
"The names of the Rivet analyses to use",
&RivetAnalysis::_analyses, -1, "", "","" "",
false, false, ThePEG::Interface::nolimits);
static Parameter<RivetAnalysis,string> interfaceFilename
("Filename",
"The name of the file where the AIDA histograms are put. If empty, "
"the run name will be used instead. '.aida' will in any case be "
"appended to the file name.",
&RivetAnalysis::filename, "", true, false);
+ static Switch<RivetAnalysis,bool> interfaceDebug
+ ("Debug",
+ "Enable debug information from Rivet",
+ &RivetAnalysis::debug, false, true, false);
+ static SwitchOption interfaceDebugNo
+ (interfaceDebug,
+ "No",
+ "Disable debug information.",
+ false);
+ static SwitchOption interfaceDebugYes
+ (interfaceDebug,
+ "Yes",
+ "Enable debug information from Rivet.",
+ true);
+
+
interfaceAnalyses.rank(10);
}
void RivetAnalysis::dofinish() {
AnalysisHandler::dofinish();
- if(_nevent>0) {
+ if( _nevent > 0 && _rivet ) {
CurrentGenerator::Redirect stdout(cout);
_rivet->setCrossSection(generator()->integratedXSec()/picobarn);
_rivet->finalize();
- _rivet->writeData(generator()->runName()+".aida");
+
+ string fname = filename;
+ if ( fname.empty() ) fname = generator()->runName() + ".aida";
+ _rivet->writeData(fname);
}
+ delete _rivet;
+ _rivet = 0;
+}
+
+void RivetAnalysis::doinit() {
+ AnalysisHandler::doinit();
+ if(_analyses.empty())
+ throw ThePEG::Exception() << "Must have at least one analysis loaded in "
+ << "RivetAnalysis::doinitrun()"
+ << ThePEG::Exception::runerror;
}
void RivetAnalysis::doinitrun() {
AnalysisHandler::doinitrun();
- if(_analyses.empty())
- throw ThePEG::Exception() << "Must have at least one analysis loaded in "
- << "RivetAnalysis::doinitrun()"
- << ThePEG::Exception::runerror;
// create Rivet analysis handler
CurrentGenerator::Redirect stdout(cout);
- string fname = filename;
- if ( fname.empty() ) fname = generator()->runName();
- _rivet = new Rivet::AnalysisHandler(fname);
- // specify the analyses to be used
- for(unsigned int ix=0;ix<_analyses.size();++ix) {
- _rivet->addAnalysis(_analyses[ix]);
- }
- // initialize the rivet analysis handler
+ _rivet = new Rivet::AnalysisHandler; //(fname);
+ _rivet->addAnalyses(_analyses);
_rivet->init();
+ if ( debug )
+ Rivet::Log::setLevel("Rivet",Rivet::Log::DEBUG);
}
diff --git a/Analysis/RivetAnalysis.h b/Analysis/RivetAnalysis.h
--- a/Analysis/RivetAnalysis.h
+++ b/Analysis/RivetAnalysis.h
@@ -1,186 +1,196 @@
// -*- C++ -*-
#ifndef THEPEG_RivetAnalysis_H
#define THEPEG_RivetAnalysis_H
//
// This is the declaration of the RivetAnalysis class.
//
#include "ThePEG/Handlers/AnalysisHandler.h"
#include "Rivet/AnalysisHandler.hh"
namespace ThePEG {
/**
* Here is the documentation of the RivetAnalysis class.
*
* @see \ref RivetAnalysisInterfaces "The interfaces"
* defined for RivetAnalysis.
*/
class RivetAnalysis: public ThePEG::AnalysisHandler {
public:
/**
* The default constructor.
*/
RivetAnalysis();
public:
/** @name Virtual functions required by the AnalysisHandler class. */
//@{
/**
* Analyze a given Event. Note that a fully generated event
* may be presented several times, if it has been manipulated in
* between. The default version of this function will call transform
* to make a lorentz transformation of the whole event, then extract
* all final state particles and call analyze(tPVector) of this
* analysis object and those of all associated analysis objects. The
* default version will not, however, do anything on events which
* have not been fully generated, or have been manipulated in any
* way.
* @param event pointer to the Event to be analyzed.
* @param ieve the event number.
* @param loop the number of times this event has been presented.
* If negative the event is now fully generated.
* @param state a number different from zero if the event has been
* manipulated in some way since it was last presented.
*/
virtual void analyze(ThePEG::tEventPtr event, long ieve, int loop, int state);
//@}
public:
/** @name Functions used by the persistent I/O system. */
//@{
/**
* Function used to write out object persistently.
* @param os the persistent output stream written to.
*/
void persistentOutput(ThePEG::PersistentOStream & os) const;
/**
* Function used to read in object persistently.
* @param is the persistent input stream read from.
* @param version the version number of the object when written.
*/
void persistentInput(ThePEG::PersistentIStream & is, int version);
//@}
/**
* The standard Init function used to initialize the interfaces.
* Called exactly once for each class by the class description system
* before the main function starts or
* when this class is dynamically loaded.
*/
static void Init();
protected:
/** @name Clone Methods. */
//@{
/**
* Make a simple clone of this object.
* @return a pointer to the new object.
*/
virtual ThePEG::IBPtr clone() const;
/** Make a clone of this object, possibly modifying the cloned object
* to make it sane.
* @return a pointer to the new object.
*/
virtual ThePEG::IBPtr fullclone() const;
//@}
protected:
/** @name Standard Interfaced functions. */
//@{
/**
+ * Initialize this object. Called in the read phase.
+ */
+ virtual void doinit();
+
+ /**
* Initialize this object. Called in the run phase just before
* a run begins.
*/
virtual void doinitrun();
/**
* Finalize this object. Called in the run phase just after a
* run has ended. Used eg. to write out statistics.
*/
virtual void dofinish();
//@}
private:
/**
* The static object used to initialize the description of this class.
* Indicates that this is a concrete class with persistent data.
*/
static ThePEG::ClassDescription<RivetAnalysis> initRivetAnalysis;
/**
* The assignment operator is private and must never be called.
* In fact, it should not even be implemented.
*/
RivetAnalysis & operator=(const RivetAnalysis &);
private:
/**
* The Analyses to use
*/
vector<string> _analyses;
/**
* The base name of the output file.
*/
string filename;
/**
+ * Enable debugging information from Rivet
+ */
+ bool debug;
+
+ /**
* The RivetAnalysisHandler
*/
Rivet::AnalysisHandler * _rivet;
/**
* Event count
*/
unsigned long _nevent;
};
}
#include "ThePEG/Utilities/ClassTraits.h"
namespace ThePEG {
/** @cond TRAITSPECIALIZATIONS */
/** This template specialization informs ThePEG about the
* base classes of RivetAnalysis. */
template <>
struct BaseClassTrait<RivetAnalysis,1> {
/** Typedef of the first base class of RivetAnalysis. */
typedef AnalysisHandler NthBase;
};
/** This template specialization informs ThePEG about the name of
* the RivetAnalysis class and the shared object where it is defined. */
template <>
struct ClassTraits<RivetAnalysis>
: public ClassTraitsBase<RivetAnalysis> {
/** Return a platform-independent class name */
static string className() { return "ThePEG::RivetAnalysis"; }
/**
* The name of a file containing the dynamic library where the class
* RivetAnalysis is implemented. It may also include several, space-separated,
* libraries if the class RivetAnalysis depends on other classes (base classes
* excepted). In this case the listed libraries will be dynamically
* linked in the order they are specified.
*/
static string library() { return "RivetAnalysis.so"; }
};
/** @endcond */
}
#endif /* THEPEG_RivetAnalysis_H */

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jan 20, 10:21 PM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242603
Default Alt Text
(10 KB)

Event Timeline