6 #include "TParticlePDG.h"
8 std::ostream& operator <<(std::ostream& os, const std::vector<Int_t>&
v)
11 Int_t lastIdx =
v.size()-1;
17 for (Int_t iVec = 0; iVec < lastIdx; ++iVec){
18 os <<
v[iVec] <<
", ";
20 os <<
v[lastIdx] <<
")";
26 std::ostream& operator <<(std::ostream& os, const std::vector< std::pair<Double_t,Double_t> >& vpair)
29 Int_t lastIdx = vpair.size()-1;
30 if(vpair.size() == 0){
35 for (Int_t iVec = 0; iVec < lastIdx; ++iVec){
37 os << vpair[iVec].first <<
", ";
38 os << vpair[iVec].second;
42 os << vpair[lastIdx].first <<
", ";
43 os << vpair[lastIdx].second;
49 std::ostream& operator <<(std::ostream& os, const std::vector< std::pair<Int_t,Int_t> >& vpair)
52 Int_t lastIdx = vpair.size()-1;
53 if(vpair.size() == 0){
58 for (Int_t iVec = 0; iVec < lastIdx; ++iVec){
60 os << vpair[iVec].first <<
", ";
61 os << vpair[iVec].second;
65 os << vpair[lastIdx].first <<
", ";
66 os << vpair[lastIdx].second;
72 std::ostream& operator <<(std::ostream& os, const std::map<Int_t, std::vector<Int_t> >& pdgGroupId)
74 if(pdgGroupId.begin() == pdgGroupId.end()){
78 for (
std::map<Int_t,std::vector<Int_t> >::const_iterator iPdgGroupId = pdgGroupId.begin(); iPdgGroupId != pdgGroupId.end(); ++iPdgGroupId){
79 os <<
"( "<< iPdgGroupId->first <<
", [";
80 os << iPdgGroupId->second;
89 FairEvtFilter(
" ",
"FairEvtFilterOnSingleParticleCounts"), fFilterPdg(kFALSE),fFilterCharge(kFALSE),
90 fFilterMom(kFALSE),fFilterGeom(kFALSE)
98 :
FairEvtFilter(name, title),fFilterPdg(kFALSE), fFilterCharge(kFALSE),
99 fFilterMom(kFALSE),fFilterGeom(kFALSE)
113 fMomMinMax.push_back(std::pair<Double_t, Double_t> (-99999.,99999.));
118 fGeomMinMax.push_back(std::pair<Double_t, Double_t> (-99999.,99999.));
130 std::vector<Int_t> pdgCodes;
131 pdgCodes.push_back(pdgCode1);
132 pdgCodes.push_back(pdgCode2);
133 pdgCodes.push_back(pdgCode3);
134 pdgCodes.push_back(pdgCode4);
135 pdgCodes.push_back(pdgCode5);
136 pdgCodes.push_back(pdgCode6);
137 pdgCodes.push_back(pdgCode7);
138 pdgCodes.push_back(pdgCode8);
147 Bool_t filterAdded = kFALSE;
150 std::cout << this->GetTitle() <<
": " << this->GetName() <<
"\n";
151 std::cout <<
"fPdgGroupId: " <<
fPdgGroupId <<
"\n";
158 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at least a number <= 0 of some particles. That makes no sense. Check your AndMinMaxPdgCodes calls!\n\n\n";
162 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at most a number of some particles which is less than the minimum number that you request. That makes no sense. Check your AndMinMaxPdgCodes calls!\n\n\n";
174 for (UInt_t iPdgCodes = 0; iPdgCodes < pdgCodes.size(); ++iPdgCodes){
182 std::vector<Int_t> & groupIdVector =
fPdgGroupId[pdgCodes[iPdgCodes]];
183 groupIdVector.push_back(newGroupId);
188 std::vector<Int_t> groupIdVector;
189 groupIdVector.push_back(newGroupId);
197 if ( kTRUE == filterAdded ){
202 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Tried to add filter, but that was not possible as all pdg codes were kInvalidPdgCode!\n\n\n";
210 std::cout <<
"FairEvtFilterOnSingleParticleCounts: After adding PdgFilter:\n";
211 std::cout <<
"fPdgGroupId: " <<
fPdgGroupId <<
"\n";
222 std::cout << this->GetTitle() <<
": " << this->GetName() <<
"\n";
228 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at least a number <= 0 of some particles. That makes no sense. Check your AndMinMaxCharge calls!\n\n\n";
232 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at most a number of some particles which is less than the minimum number that you request. That makes no sense. Check your AndMinMaxCharge calls!\n\n\n";
243 std::cout <<
"FairEvtFilterOnSingleParticleCounts: After adding ChargeFilter:\n";
254 std::cout << this->GetTitle() <<
": " << this->GetName() <<
"\n";
255 std::cout <<
"fMomMinMax { P , Pt , Pz }: " <<
fMomMinMax <<
"\n\n";
260 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at least a number <= 0 of some particles. Check your AndMinMaxMom calls.\n\n\n";
264 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at most a number of some particles which is less than the minimum number that you request. Check your AndMinMaxMom calls.\n\n\n";
275 std::cout <<
"FairEvtFilterOnSingleParticleCounts: After adding MomFilter:\n";
276 std::cout <<
"fMomMinMax { P , Pt , Pz }: " <<
fMomMinMax <<
"\n\n";
286 std::cout << this->GetTitle() <<
": " << this->GetName() <<
"\n";
287 std::cout <<
"fGeomMinMax { Theta , Phi, VertexZ, VertexRho, VertexRadius }: " <<
fGeomMinMax <<
"\n\n";
292 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at least a number <= 0 of some particles. Check your AndMinMaxGeom calls.\n\n\n";
296 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Filter could not be added. You are trying to request that your events should have at most a number of some particles which is less than the minimum number that you request. Check your AndMinMaxGeom calls.\n\n\n";
300 if(geom==0 || geom==1){
313 std::cout <<
"FairEvtFilterOnSingleParticleCounts: After adding GeomFilter:\n";
314 std::cout <<
"fGeomMinMax { Theta , Phi, VertexZ, VertexRho, VertexRadius }: " <<
fGeomMinMax <<
"\n\n";
331 std::cout <<
"fCountGroupId after initialization: " <<
fCountGroupId <<
"\n";
342 std::cout <<
"fCountCharge after initialization: " <<
fCountCharge <<
"\n";
350 std::cout <<
"{ P , Pt , Pz }: { " << particle->P() <<
", " << particle->Pt() <<
", " << particle->Pz() <<
" }\n";
358 momentum=particle->P();
362 momentum=particle->Pt();
366 momentum=particle->Pz();
370 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Check your filter calls!\n\n\n";
374 std::cout <<
"Set MomOk to kFALSE because of " << type <<
"< And" << type <<
"Range() minimum." <<
"\n";
380 std::cout <<
"Set MomOk to kFALSE because of " << type <<
" > And" << type <<
"Range() maximum." <<
"\n";
393 std::cout <<
"{ Theta , Phi , Vz, VRho, VRadius }: { " << particle->Theta()*180./
TMath::Pi() <<
", " << particle->Phi()*180./
TMath::Pi();
394 std::cout <<
", " << particle->Vz() <<
", " << particle->Rho() <<
", " << particle->R()<<
" }\n";
402 geom=particle->Theta();
406 geom=particle->Phi();
414 geom=particle->Rho();
422 std::cout <<
"\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Check your filter calls!\n\n\n";
427 std::cout <<
"Set GeomOk to kFALSE because of " << type <<
" < And" << type <<
"Range() minimum." <<
"\n";
433 std::cout <<
"Set GeomOk to kFALSE because of " << type <<
" > And" << type <<
"Range() maximum." <<
"\n";
448 for (UInt_t icountPdg = 0; icountPdg <
fCountGroupId.size(); ++icountPdg){
451 std::cout <<
"Event does NOT match filter because of fCountGroupId[icountPdg] < fGroupIdCountMinMax[icountPdg].first for icountPdg == " << icountPdg <<
"\n";
457 std::cout <<
"Event does NOT match filter because of fCountGroupId[icountPdg] > fGroupIdCountsMinMax[icountPdg].second for icountPdg == " << icountPdg <<
"\n";
475 std::cout <<
"Event does not match filter because of fCountCharge[icountChart] < fChargeCountMinMax[icountCharge].first for icountCharge == " << icountCharge <<
"\n";
481 std::cout <<
"Event does not match filter because of fCountCharge[icountCharge] > fChargeCountsMinMax[icountCharge].second for icountCharge == " << icountCharge <<
"\n";
499 Int_t partPdg = particle->GetPdgCode();
505 std::vector<Int_t> groupIdVector = it->second;
506 for (
size_t iGroupId = 0; iGroupId < groupIdVector.size(); ++iGroupId){
512 std::cout <<
"partPdg:" << partPdg <<
" -> " <<
"fCountGroupId: " <<
fCountGroupId <<
"\n";
519 Int_t partPdg = particle->GetPdgCode();
524 if ( kFALSE ==
GetCharge( partPdg, &pdgCodeCharge ) ) {
531 if(pdgCodeCharge!=0){
544 std::cout <<
"Charge:" << pdgCodeCharge <<
" -> " <<
"fCountCharge: " <<
fCountCharge <<
"\n";
553 std::cout <<
"Generated event: " << evtNr <<
"\n";
554 std::cout <<
"FairEvtFilterOnSingleParticleCounts: " << this->GetTitle() <<
": " << this->GetName() <<
" Beginning of EventMatches\n";
555 std::cout <<
"Nr. of simulated particles: " <<
fParticleList->GetEntries()<<
"\n";
557 std::cout <<
"fPdgGroupId: " <<
fPdgGroupId <<
"\n";
560 std::cout <<
"fMomMinMax: " <<
fMomMinMax <<
"\n";
561 std::cout <<
"fGeomMinMax: " <<
fGeomMinMax <<
"\n";
574 std::cout <<
"\n\n\n FairEvtFilterOnSingleParticleCounts: FATAL ERROR: No particle list! Event does not match.\n\n\n";
579 std::cout <<
"\n\n\n FairEvtFilterOnSingleParticleCounts: Event contains 0 particles. Event does not match.\n\n\n";
591 for (Int_t iPart= 0; iPart<
fParticleList->GetEntries(); iPart++) {
594 if (0 == particle) {
continue; }
623 std::cout <<
"\n Check if event matches the filter \n";
640 Bool_t evtOk=PdgOk && ChargeOk;
642 if ( kTRUE == evtOk ) {
647 if ( kTRUE == evtOk ) {
648 std::cout <<
"\n Event matches " << this->GetTitle() <<
": " << this->GetName() <<
"\n\n";
650 std::cout <<
"\n Event does NOT match " << this->GetTitle() <<
": " << this->GetName() <<
"\n\n";
static const Int_t kInvalidPdgCode
constant holding an integer number which is not used as a pdg code this serves as a place holder when...
Bool_t fFilterMom
is kTRUE if any momentum filter is set
void PrintAllTParticleInEvent()
std::vector< std::pair< Int_t, Int_t > > fChargeCountsMinMax
Bool_t AcceptMomentum(TParticle *particle)
Bool_t fFilterGeom
is kTRUE if any geometry filter is set
Bool_t fFilterCharge
is kTRUE if any filter on electrical charge is set (also kTRUE if filter on the total number of parti...
Bool_t GetCharge(Int_t inPdgCode, Double_t *pdgCodeCharge)
std::map< Int_t, std::vector< Int_t > >::iterator PdgGroupIdIterator
Bool_t AndMinMaxPdgCodes(Int_t min, Int_t max, Int_t pdgCode1, Int_t pdgCode2=kInvalidPdgCode, Int_t pdgCode3=kInvalidPdgCode, Int_t pdgCode4=kInvalidPdgCode, Int_t pdgCode5=kInvalidPdgCode, Int_t pdgCode6=kInvalidPdgCode, Int_t pdgCode7=kInvalidPdgCode, Int_t pdgCode8=kInvalidPdgCode)
void SetDefaultBoundaries()
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
PndStraightLineTrackFinderTask * finder
Bool_t AcceptChargeCounter()
std::vector< std::pair< Double_t, Double_t > > fGeomMinMax
Bool_t AndMinMaxMom(Double_t min, Double_t max, MomState mom)
std::vector< Int_t > fCountGroupId
Bool_t AndMinMaxCharge(Int_t min, Int_t max, ChargeState charge)
std::vector< std::pair< Int_t, Int_t > > fGroupIdCountsMinMax
std::set< Int_t > fAcceptedEventNumbers
void CountCharge(TParticle *particle)
Bool_t AndMinMaxGeom(Double_t min, Double_t max, GeomState geom)
TClonesArray * fParticleList
virtual ~FairEvtFilterOnSingleParticleCounts()
Bool_t fFilterPdg
is kTRUE if any pdg / group ID filter is set
std::vector< Int_t > fCountCharge
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Bool_t AcceptGeometry(TParticle *particle)
FairEvtFilterOnSingleParticleCounts()
Bool_t AcceptPdgCounter()
Bool_t EventMatches(Int_t evtNr)
std::vector< std::pair< Double_t, Double_t > > fMomMinMax
std::pair< Int_t, std::vector< Int_t > > PdgGroupIdPair
void CountPdg(TParticle *particle)