3 #include "FairGenerator.h"
4 #include "FairGenericStack.h"
5 #include "FairLogger.h"
6 #include "FairMCEventHeader.h"
8 #include "TDatabasePDG.h"
10 #include "TIterator.h"
11 #include "TMCProcess.h"
14 #include "TParticlePDG.h"
29 : FairPrimaryGenerator(),
31 fVetoFilterList(new TObjArray()),
32 fVetoFilterIter(fVetoFilterList->MakeIterator()),
33 fFilterList(new TObjArray()),
34 fFilterIter(fFilterList->MakeIterator()),
37 fEventVetoFilterActive(kFALSE),
38 fEventFilterActive(kFALSE),
39 filterAcceptEvent(),fLogicalFilterOperation(),fFilterNegation(),
50 : FairPrimaryGenerator(name,title),
52 fVetoFilterList(new TObjArray()),
53 fVetoFilterIter(fVetoFilterList->MakeIterator()),
54 fFilterList(new TObjArray()),
55 fFilterIter(fFilterList->MakeIterator()),
58 fEventVetoFilterActive(kFALSE),
59 fEventFilterActive(kFALSE),
60 filterAcceptEvent(),fLogicalFilterOperation(),fFilterNegation(),
73 if(vetoFilter) { vetoFilter->
Init(); }
78 if(filter) { filter->
Init(); }
107 Bool_t acceptEvent = kFALSE;
112 std::cout <<
"\n\n\n -WARNING from FairFilteredPrimaryGenerator: size of the negation vector has to be equal to the number of added filters. Check your FilterNegation call!\n\n\n";
116 std::cout <<
"\n\n\n -WARNING from FairFilteredPrimaryGenerator: size of the operation vector has to be equal to the number of added filters minus one. Check your LogicalFilterOperation call!\n\n\n";
129 FairPrimaryGenerator::GenerateEvent(pStack);
137 TObject* vetoFilterObject = 0;
140 vetoFilter =
dynamic_cast<FairEvtFilter*
> (vetoFilterObject);
141 if ( ! vetoFilter ) {
142 cout <<
" \n\n\n -FATAL ERROR from FairFilteredPrimaryGenerator: Veto filter cast did not work!\n\n\n" << endl;
146 cout <<
" \n\n\n -WARNING from FairFilteredPrimaryGenerator: There are no filter settings for filter " << vetoFilter->GetName() <<
" : " << vetoFilter->GetTitle() <<
". Execution is halted!\n\n\n" << endl;
150 if( ! setParticlesOk ) {
151 cout <<
" \n\n\n -WARNING from FairFilteredPrimaryGenerator: Particles were not pushed correctly to veto filter.\n\n\n" << endl;
157 cout <<
"\n Event is NOT accepted because it matches a veto filter \n";
165 if ( vetoed ) {
continue; };
170 cout <<
"\n Event is accepted because event filtering is not requested.\n\n";
173 Int_t iCheckFilter=0;
176 TObject* eventFilterObject = 0;
179 while( (eventFilterObject =
fFilterIter->Next()) ) {
180 eventFilter =
dynamic_cast<FairEvtFilter*
> (eventFilterObject);
181 if ( ! eventFilter ) {
184 cout <<
" \n\n\n -WARNING from FairFilteredPrimaryGenerator: There are no filter settings for filter " << eventFilter->GetName() <<
" : " << eventFilter->GetTitle() <<
". Execution is halted!\n\n\n" << endl;
188 if( ! setParticlesOk ) {
216 std::cout <<
"\n\n\n -WARNING from FairFilteredPrimaryGenerator: the entries of the operation vector have to be kAnd or kOr. Check your LogicalFilterOperation call!\n\n\n";
222 cout <<
"\n Event is NOT accepted after combining the event filters.\n";
234 cout <<
"\n -E FairFilteredPrimaryGenerator: No event was found within " << iTry <<
" tries which satisfies your event filter.\n ";
235 cout <<
"I accept a random event as evtNr " <<
fEventNrFiltered <<
" to avoid infinite loops. \n";
236 cout <<
"Try increasing the max. number of tries or change your filter\n\n";
238 if(
fFilterList->GetEntriesFast() > 0){cout <<
"\n Event is accepted after combining the appointed filters.\n";}
239 cout << iTry <<
" events simulated until I found a good one.\n";
virtual Bool_t Init()
Initialize the event generator(s) and the event (veto) filter(s).
Bool_t fEventFilterActive
returns kTRUE if any non-veto event filter is registerd.
std::vector< UInt_t > fLogicalFilterOperation
vector containing the logical operations with which the outputs of the non-veto event filters should ...
TObjArray * fVetoFilterList
List of registered veto filters.
Int_t fEventNrFiltered
Event number (Set by the filtered primary generator.
TObjArray * fFilterList
List of registered filters.
Primary generator with added event filtering capabilities.
std::vector< Bool_t > fFilterNegation
vector determining whether the output of a non-veto event filter should be negated or not...
virtual Bool_t EventMatches(Int_t evtNr)=0
FairFilteredPrimaryGenerator()
Default constructor.
FairEvtFilterParams fEvtFilterStat
Contains the statistics of the event filtering process.
TIterator * fVetoFilterIter
Iterator over veto filter list.
static RhoFactory * Instance()
Int_t fVerbose
Level of commenting output, 0 means no output, higher gives more output.
Int_t fEventPrintFreq
Print frequency for filtered events.
Int_t fFailedFilterEvents
Bool_t SetListOfParticles(TClonesArray *ParticleList)
TIterator * fFilterIter
Iterator over filter list.
virtual Bool_t GenerateEvent(FairGenericStack *pStack)
Calls event generators and the event filters.
Bool_t fEventVetoFilterActive
returns kTRUE if any event veto filter is registered.
virtual Bool_t FilterActive()=0
std::vector< Bool_t > filterAcceptEvent
Vector containing the results of the EventMatches methods for every registered non-veto event filter ...
virtual ~FairFilteredPrimaryGenerator()
Destructor.