FairRoot/PandaRoot
|
Primary generator with added event filtering capabilities. More...
#include <PndFilteredPrimaryGenerator.h>
Public Member Functions | |
PndFilteredPrimaryGenerator () | |
Default constructor. More... | |
PndFilteredPrimaryGenerator (TString filterset) | |
Constructor with filter-set string. More... | |
virtual | ~PndFilteredPrimaryGenerator () |
Destructor. More... | |
virtual Bool_t | Init () |
Initialize the event generator(s) and the event (veto) filter(s). More... | |
void | AddFilter (TString filterStr) |
Registers a filter as a string to be parsed Each filter set consist of one filter definition or a number of filters connected with logical && (AND) (= a certain event type). All filter sets are combined with a logical || (OR) (all event types to be accepted). Syntax: "Filt_1.1 && Filt_1.2 || Filt_2.1 || Filt_3.1 && Filt_3.2 && Filt_3.2". More... | |
virtual Bool_t | GenerateEvent (FairGenericStack *pStack) |
Calls event generators and the event filters. More... | |
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 filters. More... | |
Int_t | GetNumberOfFilterMaxTries () |
returns the maximum number of times that this object should try to find an event which suits all event filters. More... | |
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. More... | |
void | SetEventPrintFrequency (int freq) |
Sets the frequency (accepted events) for printout (verbose>0) of accepted and generated events. More... | |
Int_t | GetNumberOfFilterFailedEvents () |
Returns the number of cases in which no matching event was found within the set max. tries. More... | |
void | WriteEvtFilterStatsToRootFile (TFile *outputFile=NULL) |
Writes all relevant event filter information to the output root file. More... | |
void | SetVerbose (Int_t verbose=12) |
Set the level of commenting output. More... | |
Protected Member Functions | |
PndSmpCandList | CombineList (int pdg, PndSmpCandList *l0, PndSmpCandList *l1, PndSmpCandList *l2=0, PndSmpCandList *l3=0, PndSmpCandList *l4=0) |
Combines upt to five particle lists of PndSmpCand with overlap and double counting prevention. More... | |
void | PrintSmpCandList (PndSmpCandList l, TString name="") |
Prints a candidate lits. More... | |
StrVec | SplitString (TString s, TString delim=" ") |
Splits a TString to substrings. More... | |
bool | CheckKinematic (const PndSmpFilt &f, const TLorentzVector &p4) |
Checks whether P4 kinematics match the criteria of a PndSmpFilt. More... | |
int | AntiPdgCode (int pdg) |
Gets anti-pdg code, if exists. If not returns the code itself (particle is its anti-particle) More... | |
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. More... | |
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. More... | |
Protected Attributes | |
std::vector< PndSmpFilterSet > | fFilterSets |
Contains the filter-sets. Each filter set consist of one filter definition or a number of filters connected with logical AND (= a certain event type). All filter sets are combined with a logical OR (all event types to be accepted). Structure is like: (Filt_1.1 AND Filt_1.2) OR (Filt_2.1) OR (Filt_3.1 AND Filt_3.2 AND Filt_3.2) More... | |
FairEvtFilterParams | fEvtFilterStat |
Contains the statistics of the event filtering process. More... | |
Int_t | fVerbose |
Level of commenting output, 0 means no output, higher gives more output. More... | |
Int_t | fEventNrFiltered |
Event number (Set by the filtered primary generator. More... | |
Int_t | fEventPrintFreq |
Print frequency for filtered events. More... | |
TDatabasePDG * | fdbPdg |
Shortcut to TDatabasePDG. More... | |
std::vector< TString > | fPartNames |
particle names for particles to count (with and w/o charged specification, also simply tracks and neutrals) More... | |
std::vector< int > | fNamePdg |
particle codes for particles to count (with and w/o charged specification, also simply tracks and neutrals) More... | |
std::vector< int > | fCombFsPdg |
particle codes for the lists used for combinatorics; !!! the codes are not selected from MC truth, just the corresponding mass hypos are applied to charged tracks More... | |
std::unordered_set< int > | fSetFsPdg |
set to identify particles from MC truth list which can be combined More... | |
std::map< TString, int > | fNameCodeMap |
mapes names to (pdg) codes More... | |
std::map< int, TString > | fCodeNameMap |
mapes (pdg) codes to names More... | |
Private Member Functions | |
PndFilteredPrimaryGenerator (const PndFilteredPrimaryGenerator &) | |
PndFilteredPrimaryGenerator & | operator= (const PndFilteredPrimaryGenerator &) |
ClassDef (PndFilteredPrimaryGenerator, 1) | |
Primary generator with added event filtering capabilities.
This class adds event filtering capabilities to FairPrimaryGenerator which is used internally for handling the event generators. The event filtering is performed after the event generation and before the particle transport through the detector model.
The filter is configured with a string of the form "Filt_1.1 && Filt_1.2 || Filt_2.1 || Filt_3.1 && Filt_3.2 && Filt_3.2", where the logical && (AND) has higher priority than the logical || (OR). Each filter can be negated with a leading '!'.
There are two types of filters possible: particle type counters and invariant mass filters. The syntax is
count filter : C(<particle> ; <mult> ; [kinematic requirements]) ==> requires <mult> particles of type <particle> (counted in MC list) to meet certain kinematic conditions (p, pt, pz, theta, phi)
mass filter : M(<particle 1> <particle 2> [<particle 3> ... <particle 5>] ; <mult> ; <mass requirement>=""> ; [kinematic requirements]) ==> takes neutral particles and charged tracks, applies the mass hypotheses from <particle 1..5>, combines them and requires <mult> candidates with invariant mass to be in certain window
<particle> : e+, e-, e+-, mu+, mu-, mu+-, pi+, pi-, pi+-, K+, K-, K+-, p+, p-, p+-, n0, n0b, n00b (=n0 or n0b), gam, nt (neutral = gamma), t+ (positive tracks), t- (neg. tracks), t+- (chg. tracks), any (total multiplicity) <mult> : a..b, a (= a..a), ..a (= 0..a), a.. = (a..10000), not given (>=1 = 1..10000) <mass req.> : m[center,window] : center - window/2 < inv. mass < center + window/2 [kin. req.] : p[min,max] ; pt[min,max] ; pz[min,max] ; tht[min,max] ; phi[min,max]. Can be shortened to [,max] = [0.0,max] and [min,] = [min,1e8]
Example: C(any ; 4..) && C(tr+- ; 2 ; tht[5,20] ; p[1.0,]) && M(pi+ pi- gam gam ; m[0.782,0.1] ; pt[0.5,2.0])
Concerning FairPrimaryGenerator:
The PndFilteredPrimaryGenerator is responsible for the handling of the MC input. Several input generators can be registered to it; these have to be derived from the FairGenerator class. The PndFilteredPrimaryGenerator defines position and (optionally) smearing of the primary vertex. This class should be instantiated only once.
Definition at line 74 of file PndFilteredPrimaryGenerator.h.
PndFilteredPrimaryGenerator::PndFilteredPrimaryGenerator | ( | ) |
Default constructor.
Definition at line 15 of file PndFilteredPrimaryGenerator.cxx.
References fCodeNameMap, fCombFsPdg, fdbPdg, fNameCodeMap, fNamePdg, fPartNames, fSetFsPdg, and i.
PndFilteredPrimaryGenerator::PndFilteredPrimaryGenerator | ( | TString | filterset | ) |
Constructor with filter-set string.
Definition at line 44 of file PndFilteredPrimaryGenerator.cxx.
References AddFilter(), fCodeNameMap, fCombFsPdg, fdbPdg, fNameCodeMap, fNamePdg, fPartNames, fSetFsPdg, and i.
|
inlinevirtual |
|
private |
void PndFilteredPrimaryGenerator::AddFilter | ( | TString | filterStr | ) |
Registers a filter as a string to be parsed Each filter set consist of one filter definition or a number of filters connected with logical && (AND) (= a certain event type). All filter sets are combined with a logical || (OR) (all event types to be accepted). Syntax: "Filt_1.1 && Filt_1.2 || Filt_2.1 || Filt_3.1 && Filt_3.2 && Filt_3.2".
Definition at line 157 of file PndFilteredPrimaryGenerator.cxx.
References PndSmpFilt::compo, cuts, exit(), f, fFilterSets, fNameCodeMap, for(), fVerbose, GetRangeDouble(), GetRangeInt(), i, if(), jj, PndSmpFilt::mcntr, PndSmpFilt::mwin, PndSmpFilt::name, PndSmpFilt::ndau, PndSmpFilt::nmax, PndSmpFilt::nmin, PndSmpFilt::nocc, PndSmpFilt::pdg, PndSmpFilt::phimax, PndSmpFilt::phimin, PndSmpFilt::pmax, PndSmpFilt::pmin, PndSmpFilt::ptmax, PndSmpFilt::ptmin, PndSmpFilt::pzmax, PndSmpFilt::pzmin, SplitString(), PndSmpFilt::thtmax, PndSmpFilt::thtmin, TString, and PndSmpFilt::veto.
Referenced by PndFilteredPrimaryGenerator(), and prod_fsim().
|
protected |
Gets anti-pdg code, if exists. If not returns the code itself (particle is its anti-particle)
Definition at line 122 of file PndFilteredPrimaryGenerator.cxx.
References fdbPdg.
Referenced by GenerateEvent().
|
protected |
Checks whether P4 kinematics match the criteria of a PndSmpFilt.
Definition at line 107 of file PndFilteredPrimaryGenerator.cxx.
References PndSmpFilt::phimax, PndSmpFilt::phimin, PndSmpFilt::pmax, PndSmpFilt::pmin, PndSmpFilt::ptmax, PndSmpFilt::ptmin, PndSmpFilt::pzmax, PndSmpFilt::pzmin, PndSmpFilt::thtmax, and PndSmpFilt::thtmin.
Referenced by GenerateEvent().
|
private |
|
protected |
Combines upt to five particle lists of PndSmpCand with overlap and double counting prevention.
Definition at line 272 of file PndFilteredPrimaryGenerator.cxx.
References c1, c2, c3, c4, PndSmpCand::Overlap(), and res.
Referenced by GenerateEvent().
|
virtual |
Calls event generators and the event filters.
To be called at the beginning of each event from FairMCApplication. Generates an event vertex and calls the ReadEvent methods from the registered generators. Calls defined event (veto) filters to decide whether to process the event or to call the event generators again.
pStack | The particle stack |
Definition at line 364 of file PndFilteredPrimaryGenerator.cxx.
References all, AntiPdgCode(), CheckKinematic(), cnt, CombineList(), PndSmpFilt::compo, f, fabs(), fCodeNameMap, fCombFsPdg, fdbPdg, fEventNrFiltered, fEventPrintFreq, fEvtFilterStat, FairEvtFilterParams::fFailedFilterEvents, FairEvtFilterParams::fFilterMaxTries, fFilterSets, FairEvtFilterParams::fGeneratedEvents, fSetFsPdg, fVerbose, i, PndSmpFilt::mcntr, PndSmpFilt::mwin, nc, PndSmpFilt::ndau, PndSmpFilt::nmax, PndSmpFilt::nocc, particle, PndSmpFilt::pdg, PrintSmpCandList(), PndSmpCand::SetP4(), and PndSmpFilt::veto.
|
inline |
Returns the number of cases in which no matching event was found within the set max. tries.
This method returns 0 if everything works fine. If it returns a value >0 it means that you should set a higher limit in SetFilterMaxTries. If it returns a value which is equal to the number of events that you requested, it means that either the max. number of tries is set way too low or that the generator does not create such events that you are interested in or that your event filters cannot be satisfied at all (logical error).
Definition at line 145 of file PndFilteredPrimaryGenerator.h.
References fEvtFilterStat, and FairEvtFilterParams::fFailedFilterEvents.
Referenced by WriteEvtFilterStatsToRootFile().
|
inline |
returns the maximum number of times that this object should try to find an event which suits all event filters.
Definition at line 122 of file PndFilteredPrimaryGenerator.h.
References fEvtFilterStat, and FairEvtFilterParams::fFilterMaxTries.
|
inline |
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.
Definition at line 127 of file PndFilteredPrimaryGenerator.h.
References fEvtFilterStat, and FairEvtFilterParams::fGeneratedEvents.
Referenced by prod_fsim(), and WriteEvtFilterStatsToRootFile().
|
protected |
Turns a string of the form <float><delim><float> (e.g. "124.2,178.3") to a range a,b.
Definition at line 132 of file PndFilteredPrimaryGenerator.cxx.
Referenced by AddFilter().
|
protected |
Turns a string of the form <int><delim><int> (e.g. "3..8") to a range a,b.
Definition at line 142 of file PndFilteredPrimaryGenerator.cxx.
Referenced by AddFilter().
|
virtual |
Initialize the event generator(s) and the event (veto) filter(s).
Definition at line 75 of file PndFilteredPrimaryGenerator.cxx.
References fFilterSets, fVerbose, i, Init(), and Print().
|
private |
|
protected |
Prints a candidate lits.
Definition at line 354 of file PndFilteredPrimaryGenerator.cxx.
Referenced by GenerateEvent().
|
inline |
Sets the frequency (accepted events) for printout (verbose>0) of accepted and generated events.
Definition at line 132 of file PndFilteredPrimaryGenerator.h.
References fEventPrintFreq.
Referenced by prod_fsim().
|
inline |
Define the maximum number of times that this object should try to find an event which suits all event filters.
Definition at line 111 of file PndFilteredPrimaryGenerator.h.
References fEvtFilterStat, and FairEvtFilterParams::fFilterMaxTries.
|
inline |
Set the level of commenting output.
verbose | Level of commenting output, 0 means no output, higher gives more output. |
Definition at line 168 of file PndFilteredPrimaryGenerator.h.
References fVerbose, and verbose.
Referenced by prod_fsim().
Splits a TString to substrings.
Definition at line 92 of file PndFilteredPrimaryGenerator.cxx.
Referenced by AddFilter().
|
inline |
Writes all relevant event filter information to the output root file.
Definition at line 150 of file PndFilteredPrimaryGenerator.h.
References fEvtFilterStat, GetNumberOfFilterFailedEvents(), and GetNumberOfGeneratedEvents().
Referenced by prod_fsim().
mapes (pdg) codes to names
Definition at line 244 of file PndFilteredPrimaryGenerator.h.
Referenced by GenerateEvent(), and PndFilteredPrimaryGenerator().
|
protected |
particle codes for the lists used for combinatorics; !!! the codes are not selected from MC truth, just the corresponding mass hypos are applied to charged tracks
Definition at line 235 of file PndFilteredPrimaryGenerator.h.
Referenced by GenerateEvent(), and PndFilteredPrimaryGenerator().
|
protected |
Shortcut to TDatabasePDG.
Definition at line 226 of file PndFilteredPrimaryGenerator.h.
Referenced by AntiPdgCode(), GenerateEvent(), and PndFilteredPrimaryGenerator().
|
protected |
Event number (Set by the filtered primary generator.
Definition at line 220 of file PndFilteredPrimaryGenerator.h.
Referenced by GenerateEvent().
|
protected |
Print frequency for filtered events.
Definition at line 223 of file PndFilteredPrimaryGenerator.h.
Referenced by GenerateEvent(), and SetEventPrintFrequency().
|
protected |
Contains the statistics of the event filtering process.
Definition at line 214 of file PndFilteredPrimaryGenerator.h.
Referenced by GenerateEvent(), GetNumberOfFilterFailedEvents(), GetNumberOfFilterMaxTries(), GetNumberOfGeneratedEvents(), SetFilterMaxTries(), and WriteEvtFilterStatsToRootFile().
|
protected |
Contains the filter-sets. Each filter set consist of one filter definition or a number of filters connected with logical AND (= a certain event type). All filter sets are combined with a logical OR (all event types to be accepted). Structure is like: (Filt_1.1 AND Filt_1.2) OR (Filt_2.1) OR (Filt_3.1 AND Filt_3.2 AND Filt_3.2)
Definition at line 211 of file PndFilteredPrimaryGenerator.h.
Referenced by AddFilter(), GenerateEvent(), and Init().
mapes names to (pdg) codes
Definition at line 241 of file PndFilteredPrimaryGenerator.h.
Referenced by AddFilter(), and PndFilteredPrimaryGenerator().
|
protected |
particle codes for particles to count (with and w/o charged specification, also simply tracks and neutrals)
Definition at line 232 of file PndFilteredPrimaryGenerator.h.
Referenced by PndFilteredPrimaryGenerator().
|
protected |
particle names for particles to count (with and w/o charged specification, also simply tracks and neutrals)
Definition at line 229 of file PndFilteredPrimaryGenerator.h.
Referenced by PndFilteredPrimaryGenerator().
|
protected |
set to identify particles from MC truth list which can be combined
Definition at line 238 of file PndFilteredPrimaryGenerator.h.
Referenced by GenerateEvent(), and PndFilteredPrimaryGenerator().
|
protected |
Level of commenting output, 0 means no output, higher gives more output.
Definition at line 217 of file PndFilteredPrimaryGenerator.h.
Referenced by AddFilter(), GenerateEvent(), Init(), and SetVerbose().