Base for classes to construct collections of physics objects. More...
#include <CollectionBuilder.h>
Classes | |
class | MomentaWrapper |
Facade to access elements of the collection of momenta. More... | |
class | MomentumIt |
A constant iterator for MomentaWrapper. More... | |
Public Member Functions | |
CollectionBuilderBase (TTreeReader &reader) | |
Constructor. | |
void | EnableCleaning (std::initializer_list< CollectionBuilderBase const * > builders) |
Requests cleaning with respect to collections produced by given builders. | |
MomentaWrapper | GetMomenta () const |
Provides access to four-momenta of physics objects in the collection. | |
Momentum const & | GetSumMomentumShift () const |
Returns the accumulated change in momentum in the current event, introduced as a result of calibration and other changes to momenta of individual objects. | |
bool | IsDuplicate (Momentum const &p4, double maxDR) const |
Checks if the direction of the given momentum is close to that of a momentum in one of the collections for cleaning. | |
Protected Member Functions | |
void | AddMomentumShift (Momentum const &uncorrP4, Momentum const &corrP4) const |
Adds a shift to the sum four-momentum. | |
void | Update () const |
Makes sure that all construction for the current event has been performed. | |
Private Member Functions | |
virtual void | Build () const =0 |
A hook to perform construction for the current event. | |
virtual Momentum const & | GetMomentum (size_t i) const =0 |
Interface to access momentum of the object with the given index. | |
virtual size_t | GetNumMomenta () const =0 |
Interface to access the size of the collection. | |
Private Attributes | |
EventCache | cache_ |
An object to facilitate caching. | |
std::vector < CollectionBuilderBase const * > | prioritizedBuilders_ |
Collection of non-owning pointers to objects that produce collections against which the cleaning should be performed. | |
Momentum | sumP4Shift_ |
Total change in four-momentum accumulated in the current event with AddP4Shift. |
Base for classes to construct collections of physics objects.
This class provides an interface to access and iterate over four-momenta of physics objects in the collection produced by a derived class. For this, the derived class must implement methods GetMomentum and GetNumMomenta.
This class also provides a mechanism for per-event caching and lazy construction of the collection of physics objects, see methods Update and Build.
Methods EnableCleaning and IsDuplicate are helpful to avoid double counting of objects with collections produced by other builders. A derived class must make use of method IsDuplicate to skip objects identified as duplicates.
When a derived class changes momenta of physics objects in the collection, it should register the change using method AddMomentumShift. The change in the sum momentum aggregated in an event is provided with method GetSumMomentumShift, which is used by PtMissBuilder to propagate the change into missing pt.
CollectionBuilderBase::CollectionBuilderBase | ( | TTreeReader & | reader | ) |
Constructor.
The reader object provided as the argument is used to implement per-event caching.
void CollectionBuilderBase::AddMomentumShift | ( | Momentum const & | uncorrP4, | |
Momentum const & | corrP4 | |||
) | const [protected] |
Adds a shift to the sum four-momentum.
When a derived class changes momentum of a physics object as a result of an additional calibration or a systematic variation, it should register the change with the help of this method.
The accumulated shift is intended to be used to correct missing pt (see PtMissBuilder), and the objects that contribute to it should be chosen accordingly. These are not necessarily the same objects as included in the produced collection.
virtual void CollectionBuilderBase::Build | ( | ) | const [private, pure virtual] |
A hook to perform construction for the current event.
This method will be called at maximum once per event. Its implementation in the derived class should construct the collection of physics objects.
void CollectionBuilderBase::EnableCleaning | ( | std::initializer_list< CollectionBuilderBase const * > | builders | ) |
Requests cleaning with respect to collections produced by given builders.
It is up to a derived class to actually remove duplicates identified by method IsDuplicate. Objects provided in the argument are not owned by this. If this method is called multiple times, new builders are added to the list of already registered builders.
bool CollectionBuilderBase::IsDuplicate | ( | Momentum const & | p4, | |
double | maxDR | |||
) | const |
Checks if the direction of the given momentum is close to that of a momentum in one of the collections for cleaning.
The matching is done in the (eta, phi) metric.
void CollectionBuilderBase::Update | ( | ) | const [protected] |
Makes sure that all construction for the current event has been performed.
When this method is called for the first time for a given event, it calls Build. Otherwise it does nothing. A derived class must call this method before it attempts to return the collection of physics objects in the current event.