43 #ifndef PndFilteredPrimaryGenerator_H 44 #define PndFilteredPrimaryGenerator_H 46 #include "FairPrimaryGenerator.h" 48 #include "FairRunSim.h" 49 #include "FairRootFileSink.h" 55 #include "TLorentzVector.h" 62 #include <unordered_set> 65 class FairGenericStack;
85 virtual Bool_t
Init();
113 std::cout <<
"\n\n\n -WARNING from PndFilteredPrimaryGenerator: maxTries must be a positive number! Check your SetFilterMaxTries call!\n\n\n";
143 std::cout <<
"Random events were accepted to avoid infinite loops. \n";
144 std::cout <<
"Try increasing the max. number of tries or change your filter (maybe the generators do not produce such events as you want).\n\n";
146 if (outputFile ==
nullptr)
147 outputFile = ((FairRootFileSink*)FairRunSim::Instance()->GetSink())->GetRootFile();
150 outputFile->mkdir(
"FairEvtFilter");
151 outputFile->cd(
"FairEvtFilter");
163 std::cout <<
"PndFilteredPrimaryGenerator: fVerbose is now set to " << verbose <<
"\n";
165 std::cout <<
"\n\n\n -WARNING from PndFilteredPrimaryGenerator: verbose must be a positive number! Check your SetVerbose call!\n\n\n";
186 void GetRangeDouble(TString s,
double &a,
double &b, TString delim =
",",
bool forceset =
false);
189 void GetRangeInt(TString s,
int &a,
int &b, TString delim =
"..");
std::vector< PndSmpCand > PndSmpCandList
std::vector< TString > StrVec
StrVec SplitString(TString s, TString delim=" ")
Splits a TString to substrings.
std::unordered_set< int > fSetFsPdg
set to identify particles from MC truth list which can be combined
Int_t GetNumberOfFilterMaxTries()
returns the maximum number of times that this object should try to find an event which suits all even...
Simple container for filter definition (criteria) for PndFilteredPrimaryGenerator.
PndFilteredPrimaryGenerator()
Default constructor.
virtual Bool_t GenerateEvent(FairGenericStack *pStack)
Calls event generators and the event filters.
void SetEventPrintFrequency(int freq)
Sets the frequency (accepted events) for printout (verbose>0) of accepted and generated events...
void WriteEvtFilterStatsToRootFile(TFile *outputFile=nullptr)
Writes all relevant event filter information to the output root file.
std::map< TString, int > fNameCodeMap
mapes names to (pdg) codes
bool CheckKinematic(const PndSmpFilt &f, const TLorentzVector &p4)
Checks whether P4 kinematics match the criteria of a PndSmpFilt.
Int_t fEventNrFiltered
Event number (Set by the filtered primary generator.
std::map< int, TString > fCodeNameMap
mapes (pdg) codes to names
TDatabasePDG * fdbPdg
Shortcut to TDatabasePDG.
std::vector< TString > fPartNames
particle names for particles to count (with and w/o charged specification, also simply tracks and neu...
Primary generator with added event filtering capabilities.
Int_t GetNumberOfGeneratedEvents()
returns the total (accepted + rejected) number of events generated by the event generators. If no event filters are used this number is equal to the number of simulated events.
vector< PndSmpFilt > PndSmpFilterSet
PndSmpCandList CombineList(int pdg, PndSmpCandList *l0, PndSmpCandList *l1, PndSmpCandList *l2=nullptr, PndSmpCandList *l3=nullptr, PndSmpCandList *l4=nullptr)
Combines upt to five particle lists of PndSmpCand with overlap and double counting prevention...
virtual ~PndFilteredPrimaryGenerator()
Destructor.
Int_t GetNumberOfFilterFailedEvents()
Returns the number of cases in which no matching event was found within the set max. tries.
Int_t fFailedFilterEvents
FairEvtFilterParams fEvtFilterStat
Contains the statistics of the event filtering process.
void AddFilter(TString filterStr)
Registers a filter as a string to be parsed Each filter set consist of one filter definition or a num...
std::vector< PndSmpFilterSet > fFilterSets
Contains the filter-sets. Each filter set consist of one filter definition or a number of filters con...
Int_t fEventPrintFreq
Print frequency for filtered events.
void PrintSmpCandList(PndSmpCandList l, TString name="")
Prints a candidate lits.
void SetVerbose(Int_t verbose=12)
Set the level of commenting output.
void GetRangeInt(TString s, int &a, int &b, TString delim="..")
Turns a string of the form <int><delim><int> (e.g. "3..8") to a range a,b.
virtual Bool_t Init()
Initialize the event generator(s) and the event (veto) filter(s).
Int_t fVerbose
Level of commenting output, 0 means no output, higher gives more output.
std::vector< int > fNamePdg
particle codes for particles to count (with and w/o charged specification, also simply tracks and neu...
void SetFilterMaxTries(Int_t maxTries=99999)
Define the maximum number of times that this object should try to find an event which suits all event...
int AntiPdgCode(int pdg)
Gets anti-pdg code, if exists. If not returns the code itself (particle is its anti-particle) ...
std::vector< int > fCombFsPdg
particle codes for the lists used for combinatorics; !!! the codes are not selected from MC truth...
void GetRangeDouble(TString s, double &a, double &b, TString delim=",", bool forceset=false)
Turns a string of the form <float><delim><float> (e.g. "124.2,178.3") to a range a,b.