// ------------------------------------------------------------------------- // ----- FairEvtFilterOnParticleDist header file ----- // ------------------------------------------------------------------------- /** FairEvtFilterOnParticleDist.h * @author A. Goerres * @date February 2015 * @brief Enables filtering generated events based on probability functions. * * This class offers a filter for the FairEvtFilter to filter based on a * probability function. This function may be applied to different geometrical * parameters such as cos(theta). * */ #ifndef FairEvtFilterOnParticleDist_H_ #define FairEvtFilterOnParticleDist_H_ #include "FairEvtFilter.h" #include "TParticle.h" #include "TF1.h" #include "TMath.h" #include "TRandom3.h" #include "RhoHistogram/RhoTuple.h" std::ostream& operator <<(std::ostream& os, const std::pair< std::pair, TF1 >& gd); std::ostream& operator <<(std::ostream& os, const std::vector< std::pair< std::pair, TF1 > >& gd); class FairEvtFilterOnParticleDist : public FairEvtFilter { public: /** * A list of possible geometries to apply distribtutions to. */ enum GeomFilter {kTheta=0, kCosTheta, kPhi, kVertexZ, kVertexRho, kVertexRadius}; /** * Make a type for the list of geometry distributions. */ typedef std::pair< std::pair, TF1 > GeomDist; /** * Default constructor */ FairEvtFilterOnParticleDist(const Float_t mom); /** * Constructor with name and title */ FairEvtFilterOnParticleDist(const char* name, const Float_t mom, const char* title="FairEvtFilterOnParticleDist"); /** * Destructor */ virtual ~FairEvtFilterOnParticleDist(); /// /// User Interface /// /** * @brief Adds a filter for the cos(theta) distribution of a particle * * @param func Pointer to the TF1 that is used as a probability distribution * @param pdgCode Integer with the pdgCode to apply the function to * @return kTRUE if event matches, kFALSE otherwise */ Bool_t AddCosThetaDist(TF1 * func, Int_t pdgCode) { return AndGeomDist(func, pdgCode, kCosTheta); }; /** * @brief Checks if the particles in the event suit the filter settings * @return kTRUE if event matches, kFALSE otherwise */ Bool_t EventMatches(Int_t evtNr); /** * @brief Get the current filter status * @return kTRUE if filter is activated */ Bool_t FilterActive() { return ( fDistFilterActive ); }; /** * @brief Write the filter statistics tuple to the output file */ void WriteEvtFilterStatsToRootFile(); private: /// /// Private Methods /// /** * Initialize class parameters */ void InitParameters(const Float_t mom); /** * Print the header containing class title and instance name */ void PrintVerboseOutputHeader(TString extraText); /** * General function to add a geometry distribution */ Bool_t AndGeomDist(TF1 * func, Int_t pdgCode, GeomFilter geom); /** * Get the geometrical value of the particle */ Float_t GetGeomValue(TParticle * par, GeomFilter geom); /** * Does the given distribution filter out the current particle? */ Bool_t RejectFromDist(TParticle * particle, Int_t evtNr, Int_t trkNr); /// /// Some internal variables/constants /// // is a distribution filter active Bool_t fDistFilterActive; // the vector of distribution filters std::vector fGeomDist; // the lorentz vector of the pbarpSystem's CMS TLorentzVector fPbarpCMS; TVector3 fPbarpCMSboost; // a random number generator TRandom3 fRnd; // collect some statistics RhoTuple * fFilterStats; ClassDef(FairEvtFilterOnParticleDist,1); }; #endif /* FairEvtFilterOnParticleDist_H_ */