Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F11221579
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Subscribers
None
View Options
Index: trunk/Projections/Projection.h
===================================================================
--- trunk/Projections/Projection.h (revision 12)
+++ trunk/Projections/Projection.h (revision 13)
@@ -1,129 +1,134 @@
// -*- C++ -*-
#ifndef RIVET_Projection_H
#define RIVET_Projection_H
//
// This is the declaration of the Projection class.
//
// #include "Rivet/Config/Rivet.h"
#include "Rivet/Config/Rivet.h"
#include "Projection.fh"
#include "Rivet/Projections/Event.fh"
namespace Rivet {
/**
* Projection is the base class of all Projections to be used by
* Rivet. A Projection object can be assigned to an Event object and
* will then define a processed part of the information available in
* the Event, which then can be used by other Projection objects
* and/or Analysis objects.
*
* The main virtual functions to be overridden by concrete sub-classes
* are project(const Event &) and cmp(const Projection &).
*
*/
class Projection {
public:
+ /** Event is a friend. */
+ friend class Event;
+
+public:
+
/** @name Standard constructors and destructors. */
//@{
/**
* The default constructor.
*/
inline Projection();
/**
* The copy constructor.
*/
inline Projection(const Projection &);
/**
* The destructor.
*/
virtual ~Projection();
//@}
protected:
/**
* Take the information available in the Event and make the
* calculations necessary to obtain the projection. Note that this
* function must never be called except inside the
* Event::addProjection(Projection *) function. If the information
* from other projections are necessary, their project(const Event
* &) should not be called, rather the corresponding objects should
* be added to the Event using the Even::addProjection(Projection *)
* function.
*/
void project(const Event & e);
/**
* This function is used to define a unique ordering between
* different Projection objects of the same class. If this is
* considered to be equivalent to the Projector object, \a p, in the
* argument the function should return 0. If this object should be
* ordered before \a p a negative value should be returned,
* otherwise a positive value should be returned. This function must
* never be called explicitly, but should only be called from the
* operator<(const Projection &). When implementing the function in
* concrete sub-classes, it is then guarranteed that the Projection
* object \a p in the argument is of the same class as the sub-class
* and can be safely dynamically casted to that class.
*
* When implementing this function in a sub-class, the immediate
* base class version of the function should be called first. If the
* base class function returns a non-zero value, that value should
* be returned immediately. Only if zero is returned should this
* function check the member variables of the sub-class to determine
* whether this should be ordered before or after \a p, or if it is
* equivalent with \a p.
*/
int cmp(const Projection & p) const;
public:
/**
* Determine whether this object should be ordered before the object
* \a p given as argument. If \a p is of a different class than
* this, the before() function of the corresponding type_info
* objects is used. Otherwise, if the objects are of the same class,
* the virtual cmp(const Projection &) will be returned.
*/
inline bool before(const Projection & p) const;
private:
/**
* The assignment operator is private and must never be called.
* In fact, it should not even be implemented.
*/
Projection & operator=(const Projection &);
};
}
namespace std {
template <>
struct less<const Rivet::Projection *> :
public binary_function<const Rivet::Projection *,
const Rivet::Projection *, bool>
{
/**
* This is the function called when comparing two pointers to
* Rivet::Projection.
*/
bool operator()(const Rivet::Projection * x,
const Rivet::Projection * y) const {
return x->before(*y);
}
};
}
#include "Projection.icc"
#endif /* RIVET_Projection_H */
Index: trunk/Projections/Event.h
===================================================================
--- trunk/Projections/Event.h (revision 12)
+++ trunk/Projections/Event.h (revision 13)
@@ -1,100 +1,100 @@
// -*- C++ -*-
#ifndef RIVET_Event_H
#define RIVET_Event_H
//
// This is the declaration of the Event class.
//
#include "Rivet/Config/Rivet.h"
#include "Event.fh"
#include "Rivet/Projections/Projection.h"
#include "CLHEP/HepMC/GenEvent.h"
namespace Rivet {
/** Alias for the HepMC namespace. */
namespace CLHEPMC = HepMC;
/** Forward typedefs from CLHEPMC. */
typedef CLHEPMC::GenEvent GenEvent;
/**
* Event is a concrete class representing an generated event in
* Rivet. It is constructed given a HepMC::GenEvent, a pointer to
* which is kept by the Event object throughout its lifetime. The user
* must therefore make sure that the corresponding HepMC::GenEvent
* will persist at least as long as the Event object.
*
* In addition to the HepMC::GenEvent object the Event also keeps
* track of all Projections object which have been applied to the
* Event so far.
*/
class Event {
public:
/** @name Standard constructors and destructors. */
//@{
/**
* The default constructor.
*/
inline Event(const HepMC::GenEvent & geneve);
/**
* The copy constructor.
*/
inline Event(const Event &);
/**
* The destructor.
*/
virtual ~Event();
//@}
public:
/**
* Return the generated event obtained from an external event
* generator.
*/
inline const GenEvent & genEvent() const;
/**
* Add a projection \a p to this Event. If an equivalent Projection
* has been applied before, the Projection::project(const Event &)
* of \a p is not called and a pointer to the previous equivalent
* projection is returned. If no previous Projection was found, the
* Projection::project(const Event &) of \a p is called and a
* pointer to p is returned.
*/
template <typename PROJ>
inline const PROJ * addProjection(PROJ & p) const;
private:
/**
* A pointer to the generated event obtained from an external event
* generator.
*/
const GenEvent * theGenEvent;
/**
* The set of Projection objects applied so far.
*/
- set<const Projection *> theProjections;
+ mutable set<const Projection *> theProjections;
private:
/**
* The assignment operator is private and must never be called.
* In fact, it should not even be implemented.
*/
Event & operator=(const Event &);
};
}
#include "Event.icc"
#endif /* RIVET_Event_H */
Index: trunk/Projections/Event.icc
===================================================================
--- trunk/Projections/Event.icc (revision 12)
+++ trunk/Projections/Event.icc (revision 13)
@@ -1,28 +1,29 @@
// -*- C++ -*-
//
// This is the implementation of the inlined member functions of
// the Event class.
//
namespace Rivet {
inline Event::Event(const GenEvent & geneve)
: theGenEvent(&geneve) {}
inline Event::Event(const Event & x)
: theGenEvent(x.theGenEvent) {}
inline const HepMC::GenEvent & Event::genEvent() const {
return *theGenEvent;
}
template <typename PROJ>
inline const PROJ * Event::addProjection(PROJ & p) const {
- set<const Projection *>::iterator old = theProjections.find(&p);
- if ( old != theProjections.end() ) return *old;
- p.project(*this);
+ set<const Projection *>::const_iterator old = theProjections.find(&p);
+ if ( old != theProjections.end() ) return dynamic_cast<const PROJ *>(*old);
+ Projection * pp = &p;
+ pp->project(*this);
theProjections.insert(&p);
return &p;
}
}
Index: trunk/Analysis/Makefile.am
===================================================================
--- trunk/Analysis/Makefile.am (revision 12)
+++ trunk/Analysis/Makefile.am (revision 13)
@@ -1,9 +1,9 @@
-mySOURCES = AnalysisBase.cc RivetHandler.cc
+mySOURCES = AnalysisBase.cc RivetHandler.cc TestMultiplicity.cc
-DOCFILES = AnalysisBase.h RivetHandler.h
+DOCFILES = AnalysisBase.h RivetHandler.h TestMultiplicity.h
INCLUDEFILES = $(DOCFILES) AnalysisBase.fh AnalysisBase.icc \
- RivetHandler.fh RivetHandler.icc
+ RivetHandler.fh RivetHandler.icc TestMultiplicity.icc
noinst_LTLIBRARIES = libRivetAnalysis.la
libRivetAnalysis_la_SOURCES = $(mySOURCES) $(INCLUDEFILES)
Index: trunk/Analysis/TestMultiplicity.cc
===================================================================
--- trunk/Analysis/TestMultiplicity.cc (revision 0)
+++ trunk/Analysis/TestMultiplicity.cc (revision 13)
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the TestMultiplicity class.
+//
+
+#include "TestMultiplicity.h"
+
+using namespace Rivet;
+
+TestMultiplicity::~TestMultiplicity() {}
+
+void TestMultiplicity::init() {
+ // Book histogram here.
+}
+
+void TestMultiplicity::analyze(const Event & event) {
+ const FinalStateProjection * fs = event.addProjection(fsproj);
+ int mult = fs->particles().size();
+ // Fill histogram here.
+}
+
+void TestMultiplicity::finalize() {
+ // Nothing to do here.
+}
+
+
Property changes on: trunk/Analysis/TestMultiplicity.cc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: trunk/Analysis/TestMultiplicity.h
===================================================================
--- trunk/Analysis/TestMultiplicity.h (revision 0)
+++ trunk/Analysis/TestMultiplicity.h (revision 13)
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+#ifndef RIVET_TestMultiplicity_H
+#define RIVET_TestMultiplicity_H
+//
+// This is the declaration of the TestMultiplicity class.
+//
+
+#include "Rivet/Analysis/AnalysisBase.h"
+#include "Rivet/Projections/FinalStateProjection.h"
+
+namespace Rivet {
+
+/**
+ * This class simply measures the total multiplicity. It is only
+ * intended for testing purposes.
+ */
+class TestMultiplicity: public AnalysisBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ inline TestMultiplicity();
+
+ /**
+ * The copy constructor.
+ */
+ inline TestMultiplicity(const TestMultiplicity &);
+
+ /**
+ * The destructor.
+ */
+ virtual ~TestMultiplicity();
+ //@}
+
+public:
+
+ /**
+ * Initialize this analysis object. A concrete class should here
+ * book all necessary histograms. An overridden function must make
+ * sure it first calls the base class function.
+ */
+ virtual void init();
+
+ /**
+ * Analyze one event. A concrete class should here apply the
+ * necessary projections on the \a event and fill the relevant
+ * histograms. An overridden function must make sure it first calls
+ * the base class function.
+ */
+ virtual void analyze(const Event & event);
+
+ /**
+ * Finalize this analysis object. A concrete class should here make
+ * all necessary operations on the histograms. Writing the
+ * histograms to a file is, however, done by the Rivet class. An
+ * overridden function must make sure it first calls the base class
+ * function.
+ */
+ virtual void finalize();
+
+private:
+
+ /**
+ * The FinalStateProjector used.
+ */
+ FinalStateProjection fsproj;
+
+private:
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ TestMultiplicity & operator=(const TestMultiplicity &);
+
+};
+
+}
+
+#include "TestMultiplicity.icc"
+
+#endif /* RIVET_TestMultiplicity_H */
Property changes on: trunk/Analysis/TestMultiplicity.h
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: trunk/Analysis/TestMultiplicity.icc
===================================================================
--- trunk/Analysis/TestMultiplicity.icc (revision 0)
+++ trunk/Analysis/TestMultiplicity.icc (revision 13)
@@ -0,0 +1,14 @@
+// -*- C++ -*-
+//
+// This is the implementation of the inlined member functions of
+// the TestMultiplicity class.
+//
+
+namespace Rivet {
+
+inline TestMultiplicity::TestMultiplicity() {}
+
+inline TestMultiplicity::TestMultiplicity(const TestMultiplicity & x)
+ : AnalysisBase(x), fsproj(x.fsproj) {}
+
+}
Property changes on: trunk/Analysis/TestMultiplicity.icc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, May 14, 10:34 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5111199
Default Alt Text
(12 KB)
Attached To
rAGILESVN agilesvn
Event Timeline
Log In to Comment