![]() |
AliPhysics
master (3d17d9d)
|
Container or array to index mapping for AliEmcalContainer derived classes. More...
#include <AliEmcalContainerIndexMap.h>
Public Member Functions | |
AliEmcalContainerIndexMap () | |
AliEmcalContainerIndexMap (const AliEmcalContainerIndexMap &map) | |
AliEmcalContainerIndexMap & | operator= (AliEmcalContainerIndexMap map) |
AliEmcalContainerIndexMap (AliEmcalContainerIndexMap< U, V > &&other) | |
virtual | ~AliEmcalContainerIndexMap () |
int | RegisterArray (U *inputObject) |
template<class U2 > | |
void | CopyMappingFrom (const AliEmcalContainerIndexMap< U2, V > &map, U *cont) |
template<class U2 > | |
void | CopyMappingFrom (const AliEmcalContainerIndexMap< U2, V > &map, TCollection &containers) |
template<class U2 > | |
int | GetOffset (const U2 *inputObject) const |
int | GlobalIndexFromLocalIndex (const U *inputObject, const int localIndex) const |
std::pair< int, U * > | LocalIndexFromGlobalIndex (const int globalIndex) const |
V * | GetObjectFromGlobalIndex (const int globalIndex) const |
Protected Member Functions | |
const TClonesArray * | GetObject (const AliEmcalContainer *inputObject) const |
const TClonesArray * | GetObject (const TClonesArray *inputObject) const |
bool | IsUnderlyingInputObjectTypeCompatible (const U *inputObject) const |
Protected Attributes | |
std::map< int, U * > | fGlobalIndexMap |
! Map between index and input object More... | |
int | fOffset |
Offset between each TClonesArray. More... | |
TClass * | fClass |
Used to compare the type of V against the underlying input object type. More... | |
Friends | |
template<class X , class Y > | |
void | swap (AliEmcalContainerIndexMap< X, Y > &first, AliEmcalContainerIndexMap< X, Y > &second) |
Container or array to index mapping for AliEmcalContainer derived classes.
AliEmcalContainerIndexMap contains index mapping for AliEmcalContainer derived classes. The mapping is from a single global linear array to an index in a collection of a container. For example, if there are two containers, then container a would be at offset 0 and container b at offset 1000. Then, the third particle in container b would be indexed as 1002, while the third particle in container a would be indexed as 2.
Below, input object (or inputObject) should be read as a TClonesArray or AliEmcalContainer derived class. An object of interest will usually be what we are trying to retrieve, so usually a AliVCluster or AliVParticle derived class, but could be any type derived from TObject.
Generally, U corresponds to the input object and V corresponds to the object of interest.
Actually using the index mapping requires a few steps. The mapping between the TClonesArrays used by cluster or particle containers and indices is stored in each container class. Thus, the first step is to copy that mapping, adapting it to map between the containers in your task and the indices. To do so, create an instance of AliEmcalContainerIndexMap for your class and then copy the mapping with CopyMappingFrom()
. For example:
Now, we can access the objects as desired. Some example might include:
For some additional information, see the framework details in the embedding documentation.
Definition at line 74 of file AliEmcalContainerIndexMap.h.
AliEmcalContainerIndexMap< U, V >::AliEmcalContainerIndexMap | ( | ) |
Standard constructor
Definition at line 127 of file AliEmcalContainerIndexMap.h.
AliEmcalContainerIndexMap< U, V >::AliEmcalContainerIndexMap | ( | const AliEmcalContainerIndexMap< U, V > & | map | ) |
Copy Constructor
Definition at line 138 of file AliEmcalContainerIndexMap.h.
AliEmcalContainerIndexMap< U, V >::AliEmcalContainerIndexMap | ( | AliEmcalContainerIndexMap< U, V > && | other | ) |
Move constructor
Definition at line 149 of file AliEmcalContainerIndexMap.h.
|
inlinevirtual |
Definition at line 87 of file AliEmcalContainerIndexMap.h.
void AliEmcalContainerIndexMap< U, V >::CopyMappingFrom | ( | const AliEmcalContainerIndexMap< U2, V > & | map, |
U * | cont | ||
) |
Copy a given index mapping from one AliEmcalContainerIndexMap object to the current one. The map values which are copied are those corresponding to the input object passed to this function. For a collection of input objects, see the other signature for this function.
map | AliEmcalContainerIndexMap object containing the index map that should be copied. |
cont | The input object whose index value should be copied from the index map. |
Definition at line 400 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalCorrectionClusterHadronicCorrection::ExecOnce(), AliEmcalCorrectionClusterTrackMatcher::ExecOnce(), AliEmcalJetTask::ExecOnce(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
void AliEmcalContainerIndexMap< U, V >::CopyMappingFrom | ( | const AliEmcalContainerIndexMap< U2, V > & | map, |
TCollection & | containers | ||
) |
Copy a given index mapping from one AliEmcalContainerIndexMap object to the current one. The map values which are copied are those corresponding to the input objects collection passed to this function. For a single input object, see the other signature for this function.
map | AliEmcalContainerIndexMap object containing the index map that should be copied. |
containers | The collection of input objects whose index values should be copied from the index map. |
Definition at line 372 of file AliEmcalContainerIndexMap.h.
|
inlineprotected |
Get the proper object to use in comparison. This function handles AliEmcalContainer derived classes.
Note: If we use enable_if<> in the future, we should check that it is an AliEmcalContainer derived class with std::is_conertible<>.
inputObject | AliEmcalContainer derived class. |
Definition at line 190 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalContainerIndexMap< U, V >::GetOffset(), AliEmcalContainerIndexMap< U, V >::RegisterArray(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
|
inlineprotected |
Get the proper object to use in comparison. This function handles a TClonesArray. It is really just a dummy function, but is needed so that AliEmcalContainer derived classes work correctly.
inputObject | The TClonesArray to be mapped. |
Definition at line 204 of file AliEmcalContainerIndexMap.h.
V * AliEmcalContainerIndexMap< U, V >::GetObjectFromGlobalIndex | ( | const int | globalIndex | ) | const |
Gets the object of interest at the global index. Leverages LocalIndexFromGlobalIndex() to get the array location of the object, as well as the input object.
globalIndex |
Definition at line 352 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalCorrectionClusterHadronicCorrection::ApplyHadCorrAllTracks(), AliEmcalCorrectionClusterHadronicCorrection::ApplyHadCorrOneTrack(), AliEmcalJet::Cluster(), AliEmcalCorrectionClusterHadronicCorrection::DoMatchedTracksLoop(), AliEmcalJet::Track(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
int AliEmcalContainerIndexMap< U, V >::GetOffset | ( | const U2 * | inputObject | ) | const |
Get the offset assigned to a particular input object.
inputObject | Input object which we want to get the offset of in the map. |
Definition at line 309 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalContainerIndexMap< U, V >::CopyMappingFrom(), AliEmcalContainerIndexMap< U, V >::GlobalIndexFromLocalIndex(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
int AliEmcalContainerIndexMap< U, V >::GlobalIndexFromLocalIndex | ( | const U * | inputObject, |
const int | localIndex | ||
) | const |
Get the global index from the local index of an object of interest in the input object. The input object is needed to determine the offset.
inputObject | Input object where the object of interest resides. |
localIndex | Local index of the object of interest in the input object. |
Definition at line 285 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalJetTask::FillJetConstituents(), AliEmcalCorrectionClusterTrackMatcher::GenerateEmcalParticles(), AliEmcalCorrectionClusterHadronicCorrection::Run(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
|
inlineprotected |
Check if the type to cast the object of interest (ie V) is compatible with the underlying object type of the input object. Note that the input object must implement GetClass() (which for AliEmcalContainer derived classes, it passes through the GetClass() of the underlying TClonesArray) in order to check the type.
If the types are incompatible (ie returns false), then an AliError is thrown!
inputObject | Input object to be checked. |
Definition at line 221 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalContainerIndexMap< U, V >::CopyMappingFrom(), AliEmcalContainerIndexMap< U, V >::RegisterArray(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
std::pair< int, U * > AliEmcalContainerIndexMap< U, V >::LocalIndexFromGlobalIndex | ( | const int | globalIndex | ) | const |
Get the local index of an object of interest from the global index.
globalIndex | Global index of the object of interest |
Definition at line 332 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalCorrectionClusterHadronicCorrection::ApplyHadCorrAllTracks(), AliEmcalCorrectionClusterHadronicCorrection::ApplyHadCorrOneTrack(), AliEmcalJet::ClusterAt(), AliEmcalCorrectionClusterHadronicCorrection::DoMatchedTracksLoop(), AliEmcalContainerIndexMap< U, V >::GetObjectFromGlobalIndex(), AliEmcalJet::TrackAt(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
AliEmcalContainerIndexMap< U, V > & AliEmcalContainerIndexMap< U, V >::operator= | ( | AliEmcalContainerIndexMap< U, V > | map | ) |
Assignment operator. Note that we pass by value, so a copy is created and it is fine to swap the values with the created object!
Definition at line 160 of file AliEmcalContainerIndexMap.h.
int AliEmcalContainerIndexMap< U, V >::RegisterArray | ( | U * | inputObject | ) |
Add arrays to the map. We are just comparing the address that the TClonesArray points to. Given that we should be in control of everyting, this should always be a fine way to make the comparison, and much faster than comparing the entire object.
inputObject | Input object to be registered in the map. Can be either AliEmcalContainer or TClonesArray |
Definition at line 242 of file AliEmcalContainerIndexMap.h.
Referenced by AliParticleContainer::SetArray(), AliClusterContainer::SetArray(), and AliEmcalContainerIndexMap< AliClusterContainer, AliVCluster >::~AliEmcalContainerIndexMap().
|
friend |
Swap function. Created using guide described here: https://stackoverflow.com/a/3279550
Definition at line 171 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalContainerIndexMap< U, V >::AliEmcalContainerIndexMap(), AliEmcalContainerIndexMap< U, V >::operator=(), and swap().
|
protected |
Used to compare the type of V against the underlying input object type.
Definition at line 120 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalContainerIndexMap< U, V >::IsUnderlyingInputObjectTypeCompatible(), and swap().
|
protected |
! Map between index and input object
Definition at line 117 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalContainerIndexMap< U, V >::CopyMappingFrom(), AliEmcalContainerIndexMap< U, V >::GetOffset(), AliEmcalContainerIndexMap< U, V >::LocalIndexFromGlobalIndex(), AliEmcalContainerIndexMap< U, V >::RegisterArray(), and swap().
|
protected |
Offset between each TClonesArray.
Definition at line 119 of file AliEmcalContainerIndexMap.h.
Referenced by AliEmcalContainerIndexMap< U, V >::LocalIndexFromGlobalIndex(), and AliEmcalContainerIndexMap< U, V >::RegisterArray().