/** @file CbmStackFilter.h ** @author Volker Friese ** @since 16.02.2019 ** @date 16.03.2019 **/ #ifndef CBMSTACKFILTER_H #define CBMSTACKFILTER_H 1 #include #include #include "Rtypes.h" #include "CbmDefs.h" class TClonesArray; class TParticle; /** @class CbmStackFilter ** @brief Class for filtering the stack before writing ** @author Volker Friese ** @since 12.02.2019 ** @version 1.0 ** ** During transport simulation, the stack is filled with ** primary particles (defined by the generator) and secondary ** particles generated by the transport engine. For each ** particle, a TParticle object is created. After the event ** is finished, the particle objects are converted into ** CbmMCTrack objects and written to the respective branch ** in the output tree. ** ** Not all of the tracks created during the transport are of ** interest for analysis or further processing - e.g., secondary ** tracks not registered in any detector. The CbmStackFilter ** allows to define selection criteria for the persistent ** storage of MCTracks in the output - such as number of MCPoints ** in some detector or kinetic energy. ** ** The default behaviour is: ** - Primary particles are store in any case ** - Particles with at least one point in any detector are stored ** (except for PSD, where the minimum required is 5). ** - All mother particles of particles to be stored are also stored. ** ** This default behaviour can be modified by the appropriate methods: ** - SetMinNofPoints: set the minimum number of points for a particular ** detector. Note that when the value 0 is chosen, all tracks will be stored ** irrespectively of the points in any detector. To exclude tracks which ** have points only in one particular detector, select a large cut value ** for this detector, i.e. SetMinNofPoints(kPsd, 999999). ** - SetMinEkin: set the minimum kinetic energy. This cut is additive to ** the number of points cut, i.e. both have to be fulfilled. ** - SetStoreAllPrimaries, SetStoreAllMothers, SetStoreAllPrimaryDecays. ** ** If a cut logic is desired which cannot be achieved with the above scheme, ** it can be implemented in a derived class re-implementing the method Select. ** The user stack filter class has to be registered by ** CbmRunTransport::SetStackFilter. **/ class CbmStackFilter { public: /** @brief Map holding the number of points for each detector. ** The key is a pair of (track index, detector ID), ** the value is the number of points of the track in the ** detector. **/ typedef std::map, Int_t> PointMap; /** @brief Constructor **/ CbmStackFilter(); /** @brief Destructor **/ virtual ~CbmStackFilter(); /** @brief Check the stack particles for fulfilling the storage criteria ** @param particles TClonesArray of TParticles ** @param points MapĀ holding the number of points in each detector ** @return Storage decision for each index in the TClonesArray ** ** The implemented behaviour is described in the class documentation. ** When re-implementing in a derived class: The nPoints map gives ** access to the number of points of a particle in each detector. ** The key is pair, with the index of the particle ** in its array and the detector identifier (EcbmModuleId). ** The return vector must have the same size as the TClonesArray. **/ virtual const std::vector& Select(const TClonesArray& particles, const PointMap& points); /** @brief Set the minimum kinetic energy ** @param minimum Minimum kinetic energy [GeV] ** ** Tracks with kinetic energy less than the minimum will not be stored, ** irrespectively of their number of points in the detectors. ** ** The default value is 0., meaning no energy cut. **/ void SetMinEkin(Double_t minimum) { fMinEkin = minimum; } /** @brief Set the minimum number of MCPoints for a given detector ** @param detector Detector ID ** @param minimum Minimum number of points in detector ** ** Tracks with a number of points in the detector not less than ** the minimum will be stored. In case this cut is defined for ** several detector systems, the cuts are connected by logical OR, ** i.e., at least one cut has to be satisfied. ** ** Note that selecting MinNofPoints = 0 for any detectors means ** storing all tracks, which is not advisable. ** ** Excluding tracks which have points only in one detector can ** be achieved by setting MinOfPoints to a large number for ** this detector. ** ** By default, the cut values are 1 for all detectors except for ** the PSD, where the cut value is 5. **/ void SetMinNofPoints(ECbmModuleId detector, UInt_t minimum) { if ( detector >= kNofSystems ) return; fMinNofPoints[detector] = minimum; } /** @brief Set the storage of all mothers of selected tracks ** @param choice If kTRUE, all mothers will be stored. ** ** If activated, all mother tracks of selected tracks will be stored, ** irrespective of any other selection criteria. This holds recursively, ** i.e. also for grandmothers and grand-grand-mothers etc. ** ** By default, storage of mother tracks is activated. **/ void SetStoreAllMothers(Bool_t choice) { fStoreAllMothers = choice; } /** @brief Set the storage of primary tracks ** @param choice If kTRUE, all primaries will be stored. ** ** If activated, all primary tracks will be stored, irrespective of ** any other selection criteria. ** ** By default, storage of all primary tracks is activated. **/ void SetStoreAllPrimaries(Bool_t choice) { fStoreAllPrimaries = choice; } /** @brief Set the storage of all decay daughters of primaries ** @param choice If kTRUE, all daughters will be stored. ** ** If activated, all particles in the decay chain of a primary ** particle will be stored, irrespective of any other selection ** criteria. ** ** By default, storage of decay daughters is deactivated. **/ void SetStoreAllPrimaryDecays(Bool_t choice = kTRUE) { fStoreAllDecays = choice; } private: Bool_t fStoreAllPrimaries; ///< Flag for storage of primaries Bool_t fStoreAllMothers; ///< Flag for storage of mothers Bool_t fStoreAllDecays; ///< Flag for storage of all primary decay daughters std::vector fMinNofPoints; ///< Cut values for the number of points Double_t fMinEkin; ///< Cut value for kinetic energy std::vector fStore; ///< Vector with storage decision ClassDef(CbmStackFilter,1); }; #endif /* CBMSTACKFILTER_H */