FairRoot/PandaRoot
FairEvtFilterOnSingleParticleCounts.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- FairEvtFilterOnSingleParticleCounts source file -----
3 // -------------------------------------------------------------------------
4 
6 #include "TParticlePDG.h"
7 
8 std::ostream& operator <<(std::ostream& os, const std::vector<Int_t>& v)
9 {
10  os << "(";
11  Int_t lastIdx = v.size()-1;
12  if(lastIdx < 0){
13  os << ")" ;
14  return os;
15  }
16 
17  for (Int_t iVec = 0; iVec < lastIdx; ++iVec){
18  os << v[iVec] << ", ";
19  }
20  os << v[lastIdx] << ")";
21  return os;
22 }
23 
24 
25 
26 std::ostream& operator <<(std::ostream& os, const std::vector< std::pair<Double_t,Double_t> >& vpair)
27 {
28  os << "( ";
29  Int_t lastIdx = vpair.size()-1;
30  if(vpair.size() == 0){
31  os << ")" ;
32  return os;
33  }
34 
35  for (Int_t iVec = 0; iVec < lastIdx; ++iVec){
36  os << "{";
37  os << vpair[iVec].first << ", ";
38  os << vpair[iVec].second;
39  os << "},";
40  }
41  os << "{";
42  os << vpair[lastIdx].first << ", ";
43  os << vpair[lastIdx].second;
44  os << "} )";
45  return os;
46 }
47 
48 
49 std::ostream& operator <<(std::ostream& os, const std::vector< std::pair<Int_t,Int_t> >& vpair)
50 {
51  os << "( ";
52  Int_t lastIdx = vpair.size()-1;
53  if(vpair.size() == 0){
54  os << ")" ;
55  return os;
56  }
57 
58  for (Int_t iVec = 0; iVec < lastIdx; ++iVec){
59  os << "{";
60  os << vpair[iVec].first << ", ";
61  os << vpair[iVec].second;
62  os << "},";
63  }
64  os << "{";
65  os << vpair[lastIdx].first << ", ";
66  os << vpair[lastIdx].second;
67  os << "} )";
68  return os;
69 }
70 
71 
72 std::ostream& operator <<(std::ostream& os, const std::map<Int_t, std::vector<Int_t> >& pdgGroupId)
73 {
74  if(pdgGroupId.begin() == pdgGroupId.end()){
75  os << "( , [ ] )";
76  return os;
77  }
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;
81  os << "] )";
82  }
83  return os;
84 }
85 
86 
87 // ----- Default constructor -------------------------------------------
89  FairEvtFilter(" ", "FairEvtFilterOnSingleParticleCounts"), fFilterPdg(kFALSE),fFilterCharge(kFALSE),
90  fFilterMom(kFALSE),fFilterGeom(kFALSE)
91 {
93 }
94 
95 
96 // ----- Constructor with name and title ------------------------------------
98 : FairEvtFilter(name, title),fFilterPdg(kFALSE), fFilterCharge(kFALSE),
99  fFilterMom(kFALSE),fFilterGeom(kFALSE)
100 {
102 }
103 
104 
106  // initialize a default fChargeCountsMinMax with kChargeLastElement entries
107  for (UInt_t icount = 0; icount < FairEvtFilter::kChargeLastElement; ++icount){
108  fChargeCountsMinMax.push_back(std::pair<Int_t, Int_t> (0,99999));
109  }
110 
111  // initialize a default fMomMinMax with kMomLastElement entries
112  for (UInt_t icount = 0; icount < FairEvtFilter::kMomLastElement; ++icount){
113  fMomMinMax.push_back(std::pair<Double_t, Double_t> (-99999.,99999.));
114  }
115 
116  // initialize a default fGeomMinMax with kGeomLastElement entries
117  for (UInt_t icount = 0; icount < FairEvtFilter::kGeomLastElement; ++icount){
118  fGeomMinMax.push_back(std::pair<Double_t, Double_t> (-99999.,99999.));
119  }
120 }
121 
122 // ----- Destructor ----------------------------------------------------
124 
125 
126 Bool_t FairEvtFilterOnSingleParticleCounts::AndMinMaxPdgCodes( Int_t min, Int_t max, Int_t pdgCode1, Int_t pdgCode2, Int_t pdgCode3, Int_t pdgCode4, Int_t pdgCode5, Int_t pdgCode6, Int_t pdgCode7, Int_t pdgCode8 )
127 {
128  // construct a vector pdgCodes containing all pdg codes given by caller
129  // and call the general AndMinMaxPdgCodes method
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);
139 
140  return AndMinMaxPdgCodes( min, max, pdgCodes );
141 }
142 
143 
144 Bool_t FairEvtFilterOnSingleParticleCounts::AndMinMaxPdgCodes( Int_t min, Int_t max, std::vector<Int_t> &pdgCodes )
145 {
146  // was adding of the filter successful
147  Bool_t filterAdded = kFALSE;
148 
149  if (fVerbose > 0){
150  std::cout << this->GetTitle() << ": " << this->GetName() << "\n";
151  std::cout << "fPdgGroupId: " << fPdgGroupId << "\n";
152  std::cout << "fGroupIdCountsMinMax: " << fGroupIdCountsMinMax << "\n\n";
153  }
154 
155 
156  // check if filter can be applied (make sure that min and max make sense)
157  if ( min < 0 ){
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";
159  return kFALSE;
160  }
161  if ( max < min ){
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";
163  return kFALSE;
164  }
165 
166  // find the groupId for the pdgCodes
167  // the current pdgCodes are appended to the pre-existing vector
168  Int_t newGroupId = fGroupIdCountsMinMax.size();
169 
170  // for every entry in pdgCodes
171  // -- save a new entry in the map fPdgGroupId if the entry is not already in map
172  // -- add a new groupId to the vector in fPdgGroupId if the entry already exists in the map
173 
174  for (UInt_t iPdgCodes = 0; iPdgCodes < pdgCodes.size(); ++iPdgCodes){
175  // skip kInvalidPdgCode entries in pdgCodes
176  if ( kInvalidPdgCode != pdgCodes[iPdgCodes] ) {
177  // check if map has already an entry for the pdgCode
178  PdgGroupIdIterator finder = fPdgGroupId.find(pdgCodes[iPdgCodes]);
179  if ( fPdgGroupId.end() != finder){
180  // pdgCode is already in map, add groupId to vector
181 
182  std::vector<Int_t> & groupIdVector = fPdgGroupId[pdgCodes[iPdgCodes]];
183  groupIdVector.push_back(newGroupId);
184  }
185  else {
186  // pdgCode is not in map yet, create new entry of Int_t and vector<Int_t>
187 
188  std::vector<Int_t> groupIdVector;
189  groupIdVector.push_back(newGroupId);
190  fPdgGroupId.insert(PdgGroupIdPair(pdgCodes[iPdgCodes],groupIdVector));
191  }
192 
193  filterAdded = kTRUE;
194  }
195  }
196 
197  if ( kTRUE == filterAdded ){
198  // set the minimum and maximum number of particles for the current groupId
199  fGroupIdCountsMinMax.push_back(std::pair<Int_t, Int_t> (min,max));
200 
201  } else {
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";
203  return kFALSE;
204  }
205 
206  // turn filter on
207  fFilterPdg = kTRUE;
208 
209  if (fVerbose > 0){
210  std::cout << "FairEvtFilterOnSingleParticleCounts: After adding PdgFilter:\n";
211  std::cout << "fPdgGroupId: " << fPdgGroupId << "\n";
212  std::cout << "fGroupIdCountsMinMax: " << fGroupIdCountsMinMax << "\n\n";
213  }
214  return kTRUE;
215 }
216 
217 
219 {
220 
221  if (fVerbose > 0){
222  std::cout << this->GetTitle() << ": " << this->GetName() << "\n";
223  std::cout << "fChargeCountsMinMax: " << fChargeCountsMinMax << "\n\n";
224  }
225 
226  // check if filter can be applied (make sure that min and max make sense)
227  if ( min < 0 ){
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";
229  return kFALSE;
230  }
231  if ( max < min ){
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";
233  return kFALSE;
234  }
235 
236  // saving the lower and upper limit of particle multiplicities for the corresponding ChargeState in fChargeCountsMinMax
237  fChargeCountsMinMax[charge]=std::pair<Int_t, Int_t> (min,max);
238 
239  // turn filter on
240  fFilterCharge=kTRUE;
241 
242  if (fVerbose > 0){
243  std::cout << "FairEvtFilterOnSingleParticleCounts: After adding ChargeFilter:\n";
244  std::cout << "fGroupIdCountsMinMax: " << fChargeCountsMinMax << "\n\n";
245  }
246  return kTRUE;
247 }
248 
249 
251 {
252 
253  if (fVerbose > 0){
254  std::cout << this->GetTitle() << ": " << this->GetName() << "\n";
255  std::cout << "fMomMinMax { P , Pt , Pz }: " << fMomMinMax << "\n\n";
256  }
257 
258  // check if filter can be applied (make sure that min and max make sense)
259  if ( min < 0 ){
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";
261  return kFALSE;
262  }
263  if ( max < min ){
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";
265  return kFALSE;
266  }
267 
268  // saving the lower and upper limit for the corresponding MomState in fMomMinMax
269  fMomMinMax[mom]=std::pair<Double_t, Double_t> (min,max);
270 
271  // turn filter on
272  fFilterMom=kTRUE;
273 
274  if (fVerbose > 0){
275  std::cout << "FairEvtFilterOnSingleParticleCounts: After adding MomFilter:\n";
276  std::cout << "fMomMinMax { P , Pt , Pz }: " << fMomMinMax << "\n\n";
277  }
278  return kTRUE;
279 }
280 
281 
283 {
284 
285  if (fVerbose > 0){
286  std::cout << this->GetTitle() << ": " << this->GetName() << "\n";
287  std::cout << "fGeomMinMax { Theta , Phi, VertexZ, VertexRho, VertexRadius }: " << fGeomMinMax << "\n\n";
288  }
289 
290  // check if filter can be applied (make sure that min and max make sense)
291  if ( min < 0 ){
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";
293  return kFALSE;
294  }
295  if ( max < min ){
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";
297  return kFALSE;
298  }
299 
300  if(geom==0 || geom==1){
301  min=min*2*(TMath::Pi())/360;
302  max=max*2*(TMath::Pi())/360;
303  }
304 
305  // saving the lower and upper limit for the corresponding GeomState in fGeomMinMax
306  fGeomMinMax[geom]=std::pair<Double_t, Double_t> (min,max);
307 
308 
309  // turn filter on
310  fFilterGeom=kTRUE;
311 
312  if (fVerbose > 0){
313  std::cout << "FairEvtFilterOnSingleParticleCounts: After adding GeomFilter:\n";
314  std::cout << "fGeomMinMax { Theta , Phi, VertexZ, VertexRho, VertexRadius }: " << fGeomMinMax << "\n\n";
315  }
316 
317  return kTRUE;
318 }
319 
320 
322 {
323  // initialize a 0 fCountGroupId of same size as fGroupIdCountsMinMax
324  fCountGroupId.clear();
325  for (UInt_t icountPdg = 0; icountPdg < fGroupIdCountsMinMax.size(); ++icountPdg){
326  fCountGroupId.push_back(0);
327  }
328 
329  // fCountGroupId counts up, event matches if all entries in fCountGroupId are between the according entries in fGroupIdCountsMinMax
330  if (fVerbose >11){
331  std::cout << "fCountGroupId after initialization: " << fCountGroupId << "\n";
332  }
333 
334  // initialize a 0 fCountCharge of same size as fChargeCountsMinMax
335  fCountCharge.clear();
336  for (UInt_t icountCharge = 0; icountCharge < FairEvtFilter::kChargeLastElement; ++icountCharge){
337  fCountCharge.push_back(0);
338  }
339 
340  // fCountCharge counts up, event matches if all entries in fCountCharge are between the according entries in fChargeCountsMinMax
341  if (fVerbose >11){
342  std::cout << "fCountCharge after initialization: " << fCountCharge << "\n";
343  }
344 }
345 
346 
348 {
349  if (fVerbose > 9){
350  std::cout << "{ P , Pt , Pz }: { " << particle->P() << ", " << particle->Pt() << ", " << particle->Pz() << " }\n";
351  }
352 
353  Double_t momentum;
354  std::string type;
355  for(UInt_t iMom=0; iMom < FairEvtFilter::kMomLastElement; iMom++){//check every momentum constraint for the considered particle
356  switch(iMom){
357  case kMomTotal:
358  momentum=particle->P();
359  type="P";
360  break;
361  case kMomTrans:
362  momentum=particle->Pt();
363  type="Pt";
364  break;
365  case kMomZ:
366  momentum=particle->Pz();
367  type="Pz";
368  break;
369  default:
370  std::cout << "\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Check your filter calls!\n\n\n";
371  return kFALSE;
372  if ( momentum < fMomMinMax[iMom].first){
373  if (fVerbose >9){
374  std::cout << "Set MomOk to kFALSE because of " << type << "< And" << type << "Range() minimum." << "\n";
375  }
376  return kFALSE;
377  }
378  if ( momentum > fMomMinMax[iMom].second ){
379  if (fVerbose >9){
380  std::cout << "Set MomOk to kFALSE because of " << type << " > And" << type << "Range() maximum." << "\n";
381  }
382  return kFALSE;
383  }
384  }
385  }
386  return kTRUE;
387 }
388 
389 
391 {
392  if (fVerbose > 9){
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";
395  }
396 
397  Double_t geom;
398  std::string type;
399  for(UInt_t iGeom=0; iGeom < FairEvtFilter::kGeomLastElement; iGeom++){//check every geometry constraint for the considered particle
400  switch(iGeom){
401  case kTheta:
402  geom=particle->Theta();
403  type="Theta";
404  break;
405  case kPhi:
406  geom=particle->Phi();
407  type="Phi";
408  break;
409  case kVertexZ:
410  geom=particle->Vz();
411  type="Vz";
412  break;
413  case kVertexRho:
414  geom=particle->Rho();
415  type="VRho";
416  break;
417  case kVertexRadius:
418  geom=particle->R();
419  type="VRadius";
420  break;
421  default:
422  std::cout << "\n\n\n -WARNING from FairEvtFilterOnSingleParticleCounts: Check your filter calls!\n\n\n";
423  return kFALSE;
424  }
425  if ( geom < fGeomMinMax[iGeom].first){
426  if (fVerbose >9){
427  std::cout << "Set GeomOk to kFALSE because of " << type << " < And" << type << "Range() minimum." << "\n";
428  }
429  return kFALSE;
430  }
431  if ( geom > fGeomMinMax[iGeom].second ){
432  if (fVerbose >9){
433  std::cout << "Set GeomOk to kFALSE because of " << type << " > And" << type << "Range() maximum." << "\n";
434  }
435  return kFALSE;
436  }
437  }
438  return kTRUE;
439 }
440 
441 
443 { // check if event matches the filter
444  // event matches if
445  // fCountGroupId[icountPdg] >= fGroupIdCountsMinMax[icountPdg].first
446  // and
447  // fCountGroupId[icountPdg] <= fGroupIdCountsMinMax[icountPdg].second
448  for (UInt_t icountPdg = 0; icountPdg < fCountGroupId.size(); ++icountPdg){
449  if ( fCountGroupId[icountPdg] < fGroupIdCountsMinMax[icountPdg].first){
450  if (fVerbose >9){
451  std::cout << "Event does NOT match filter because of fCountGroupId[icountPdg] < fGroupIdCountMinMax[icountPdg].first for icountPdg == " << icountPdg << "\n";
452  }
453  return kFALSE;
454  }
455  if ( fCountGroupId[icountPdg] > fGroupIdCountsMinMax[icountPdg].second ){
456  if (fVerbose >9){
457  std::cout << "Event does NOT match filter because of fCountGroupId[icountPdg] > fGroupIdCountsMinMax[icountPdg].second for icountPdg == " << icountPdg << "\n";
458  }
459  return kFALSE;
460  }
461  }
462  return kTRUE;
463 }
464 
465 
467 { // check if event matches the filter
468  // event matches if
469  // fCountCharge[icountPdg] >= fChargeCountsMinMax[icountPdg].first
470  // and
471  // fCountCharge[icountPdg] <= fChargeCountsMinMax[icountPdg].second
472  for (UInt_t icountCharge = 0; icountCharge < FairEvtFilter::kChargeLastElement; ++icountCharge){
473  if ( fCountCharge[icountCharge] < fChargeCountsMinMax[icountCharge].first){
474  if (fVerbose >9){
475  std::cout << "Event does not match filter because of fCountCharge[icountChart] < fChargeCountMinMax[icountCharge].first for icountCharge == " << icountCharge << "\n";
476  }
477  return kFALSE;
478  }
479  if ( fCountCharge[icountCharge] > fChargeCountsMinMax[icountCharge].second ){
480  if (fVerbose >9){
481  std::cout << "Event does not match filter because of fCountCharge[icountCharge] > fChargeCountsMinMax[icountCharge].second for icountCharge == " << icountCharge << "\n";
482  }
483  return kFALSE;
484  }
485  }
486  return kTRUE;
487 }
488 
489 
491  // every restriction that is placed on a pdg code is described by a groupId
492  // one groupId can belong to several particles assuming that they are indistinguishable
493  // fPdgGroupId contains all the user defined constraints on particles with certain pdg codes organized in a map
494  // all elements in this map have the pdg code as first entry and a vector of groupId's as second entry
495  // if there exists an entry for the considered particle in the map the appropriate entry of fCountGroupId is counted up
496  // whereat the associated groupId's are exactly representing the index of the incremented fCountGroupId vector
497 
498  // get pdg code for particle
499  Int_t partPdg = particle->GetPdgCode();
500 
501  // check if the pdg code is contained in some groupId
502  PdgGroupIdIterator it = fPdgGroupId.find(partPdg);
503  if ( fPdgGroupId.end() != it ){
504  // pdg code was found
505  std::vector<Int_t> groupIdVector = it->second;
506  for (size_t iGroupId = 0; iGroupId < groupIdVector.size(); ++iGroupId){
507  ++fCountGroupId[groupIdVector[iGroupId]];
508  }
509  }
510 
511  if (fVerbose >9){
512  std::cout << "partPdg:" << partPdg << " -> " << "fCountGroupId: " << fCountGroupId << "\n";
513  }
514 }
515 
516 
518  // get pdg code for particle
519  Int_t partPdg = particle->GetPdgCode();
520 
521 
522  // get charge for pdg code
523  Double_t pdgCodeCharge = 0;
524  if ( kFALSE == GetCharge( partPdg, &pdgCodeCharge ) ) {
525  // skip particles of unknown charge
526  return;
527  }
528 
529 
530  // Based on charge increment the according entry in fChargeCountsMinMax
531  if(pdgCodeCharge!=0){
533  if(pdgCodeCharge>0){
535  }else{
537  }
538  }else{
540  }
542 
543  if (fVerbose >9){
544  std::cout << "Charge:" << pdgCodeCharge << " -> " << "fCountCharge: " << fCountCharge << "\n";
545  }
546 }
547 
548 
550 {
551  if (fVerbose > 3){
552  std::cout << "\n\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";
558  std::cout << "fGroupIdCountsMinMax: " << fGroupIdCountsMinMax << "\n";
559  std::cout << "fChargeCountsMinMax: " << fChargeCountsMinMax << "\n";
560  std::cout << "fMomMinMax: " << fMomMinMax << "\n";
561  std::cout << "fGeomMinMax: " << fGeomMinMax << "\n";
562  }
563 
564 
565  // Not necessary as FairFilteredPrimaryGenerator already checks this
566  // // event matches if filter is not set
567  // if ( kFALSE == FilterActive() ) {
568  // return kTRUE;
569  // }
570 
571 
572  // sanity checks
573  if (0==fParticleList){
574  std::cout << "\n\n\n FairEvtFilterOnSingleParticleCounts: FATAL ERROR: No particle list! Event does not match.\n\n\n";
575  return kFALSE;
576  }
577 
578  if (0==fParticleList->GetEntriesFast()){
579  std::cout << "\n\n\n FairEvtFilterOnSingleParticleCounts: Event contains 0 particles. Event does not match.\n\n\n";
580  return kFALSE;
581  }
582 
583  // reset all counters for each new event
584  InitCounters();
585 
586 
587  // loop the produced particles and count up
588  // the specified "groupIDs"
589  // and charge states
590  // for particles which satisfy the momentum, angular and vertex constraints
591  for (Int_t iPart= 0; iPart< fParticleList->GetEntries(); iPart++) {
592 
593  TParticle* particle=(TParticle*)fParticleList->At(iPart);
594  if (0 == particle) { continue; }
595 
596  // check whether the particle satisfies the momentum constraints
597  if(fFilterMom){
598  if(!AcceptMomentum(particle)){ continue; } // if the particle doesn't suit the momentum filter settings go ahead to the next particle
599  }
600 
601  // check whether the particle satisfies the geometric constraints
602  if(fFilterGeom){
603  if(!AcceptGeometry(particle)){ continue; } // if the particle doesn't suit the geometric filter settings go ahead to the next particle
604  }
605 
606  // count up the appropriate element of fCountGroupId and fCountCharge
607  // important: Do not count before all of the above tests were passed!
608  if(fFilterPdg){
609  CountPdg(particle);
610  }
611  if(fFilterCharge){
612  CountCharge(particle);
613  }
614 
615  }// end of the loop over all particles
616 
617  // reset PdgOk and ChargeOk to kTRUE for each new event
618  // for checking if event matches
619  Bool_t PdgOk= kTRUE;
620  Bool_t ChargeOk = kTRUE;
621 
622  if (fVerbose >9){
623  std::cout << "\n Check if event matches the filter \n";
624  std::cout << "fCountGroupId: " << fCountGroupId << "\n";
625  std::cout << "fGroupIdCountsMinMax: " << fGroupIdCountsMinMax << "\n";
626  std::cout << "fCountCharge: " << fCountCharge << "\n";
627  std::cout << "fChargeCountsMinMax: " << fChargeCountsMinMax << "\n";
628  }
629 
630 
631  if(fFilterPdg){
632  PdgOk=AcceptPdgCounter();
633  }
634 
635  if(fFilterCharge){
636  ChargeOk=AcceptChargeCounter();
637  }
638 
639  // event matches if pdg and charges are ok
640  Bool_t evtOk=PdgOk && ChargeOk;
641 
642  if ( kTRUE == evtOk ) {
643  fAcceptedEventNumbers.insert(evtNr); // for QA
644  }
645 
646  if (fVerbose >5){
647  if ( kTRUE == evtOk ) {
648  std::cout << "\n Event matches " << this->GetTitle() << ": " << this->GetName() << "\n\n";
649  } else {
650  std::cout << "\n Event does NOT match " << this->GetTitle() << ": " << this->GetName() << "\n\n";
651  }
652  }
653  return evtOk;
654 }
655 
656 
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 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...
PndTransMap * map
Definition: sim_emc_apd.C:99
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)
Double_t mom
Definition: plot_dirc.C:14
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
__m128 v
Definition: P4_F32vec4.h:4
PndStraightLineTrackFinderTask * finder
const int particle
std::vector< std::pair< Double_t, Double_t > > fGeomMinMax
Bool_t AndMinMaxMom(Double_t min, Double_t max, MomState mom)
Bool_t AndMinMaxCharge(Int_t min, Int_t max, ChargeState charge)
Double_t
std::vector< std::pair< Int_t, Int_t > > fGroupIdCountsMinMax
std::set< Int_t > fAcceptedEventNumbers
Bool_t AndMinMaxGeom(Double_t min, Double_t max, GeomState geom)
TClonesArray * fParticleList
Bool_t fFilterPdg
is kTRUE if any pdg / group ID filter is set
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
TString name
ClassImp(PndAnaContFact)
Double_t Pi
std::vector< std::pair< Double_t, Double_t > > fMomMinMax
std::pair< Int_t, std::vector< Int_t > > PdgGroupIdPair