16 #include <TClonesArray.h>
17 #include <TMCProcess.h>
19 #include <TParticle.h>
22 #include "FairRootManager.h"
48 : fMCEvent(0x0), fHasMC(kFALSE), fMCArray(0x0) {
68 Error(
"PairAnalysisMC::",
"No fMCArray");
80 if (label < 0)
return NULL;
82 Error(
"PairAnalysisMC::",
"No fMCArray");
86 if (label >
fMCArray->GetEntriesFast()) {
87 Info(
"PairAnalysisMC::",
88 "track %d out of array size %d",
109 FairRootManager* man = FairRootManager::Instance();
110 if (!man) { Fatal(
"PairAnalysisMC::Instance",
"No FairRootManager!"); }
112 fMCArray =
dynamic_cast<TClonesArray*
>(man->GetObject(
"MCTrack"));
114 Error(
"PairAnalysisMC::Instance",
"Initialization of MC object failed!");
137 if (!mcpart)
return NULL;
159 if (!mcmother)
return -99999;
168 if (!_track)
return -99999;
170 if (!mcmother)
return -99999;
180 if (!mcmother)
return -9999;
195 if (!mcPart1 || !mcPart2)
return -1;
200 if (lblMother1 != lblMother2)
return -1;
202 if (!mcMother1)
return -1;
208 if (mcMother1->
GetPdgCode() != pdgMother)
return -1;
242 if (daughterLabel < 0)
return -1;
256 if (label < 0)
return 0;
267 Bool_t checkBothCharges)
const {
271 Bool_t result = kTRUE;
272 Int_t absRequiredPDG = TMath::Abs(requiredPDG);
274 switch (absRequiredPDG) {
279 if (checkBothCharges)
281 TMath::Abs(particlePDG) >= 100 && TMath::Abs(particlePDG) <= 199;
283 if (requiredPDG > 0) result = particlePDG >= 100 && particlePDG <= 199;
285 result = particlePDG >= -199 && particlePDG <= -100;
289 if (checkBothCharges)
291 TMath::Abs(particlePDG) >= 1000 && TMath::Abs(particlePDG) <= 1999;
294 result = particlePDG >= 1000 && particlePDG <= 1999;
296 result = particlePDG >= -1999 && particlePDG <= -1000;
300 if (checkBothCharges)
302 TMath::Abs(particlePDG) >= 200 && TMath::Abs(particlePDG) <= 299;
304 if (requiredPDG > 0) result = particlePDG >= 200 && particlePDG <= 299;
306 result = particlePDG >= -299 && particlePDG <= -200;
310 if (checkBothCharges)
312 TMath::Abs(particlePDG) >= 2000 && TMath::Abs(particlePDG) <= 2999;
315 result = particlePDG >= 2000 && particlePDG <= 2999;
317 result = particlePDG >= -2999 && particlePDG <= -2000;
321 if (checkBothCharges)
323 TMath::Abs(particlePDG) >= 300 && TMath::Abs(particlePDG) <= 399;
325 if (requiredPDG > 0) result = particlePDG >= 300 && particlePDG <= 399;
327 result = particlePDG >= -399 && particlePDG <= -300;
331 if (checkBothCharges)
333 TMath::Abs(particlePDG) >= 3000 && TMath::Abs(particlePDG) <= 3999;
336 result = particlePDG >= 3000 && particlePDG <= 3999;
338 result = particlePDG >= -3999 && particlePDG <= -3000;
342 if (checkBothCharges)
344 TMath::Abs(particlePDG) >= 400 && TMath::Abs(particlePDG) <= 499;
346 if (requiredPDG > 0) result = particlePDG >= 400 && particlePDG <= 499;
348 result = particlePDG >= -499 && particlePDG <= -400;
352 if (checkBothCharges)
354 TMath::Abs(particlePDG) >= 400 && TMath::Abs(particlePDG) <= 439;
356 if (requiredPDG > 0) result = particlePDG >= 400 && particlePDG <= 439;
358 result = particlePDG >= -439 && particlePDG <= -400;
362 if (checkBothCharges)
364 (TMath::Abs(particlePDG) >= 400 && TMath::Abs(particlePDG) <= 439)
365 || (TMath::Abs(particlePDG) >= 4000
366 && TMath::Abs(particlePDG) <= 4399);
369 result = (particlePDG >= 400 && particlePDG <= 439)
370 || (particlePDG >= 4000 && particlePDG <= 4399);
372 result = (particlePDG >= -439 && particlePDG <= -400)
373 || (particlePDG >= -4399 && particlePDG <= -4000);
377 if (checkBothCharges)
379 (TMath::Abs(particlePDG) >= 400 && TMath::Abs(particlePDG) <= 499)
380 || (TMath::Abs(particlePDG) >= 4000
381 && TMath::Abs(particlePDG) <= 4999);
384 result = (particlePDG >= 400 && particlePDG <= 499)
385 || (particlePDG >= 4000 && particlePDG <= 4999);
387 result = (particlePDG >= -499 && particlePDG <= -400)
388 || (particlePDG >= -4999 && particlePDG <= -4000);
392 if (checkBothCharges)
394 TMath::Abs(particlePDG) >= 4000 && TMath::Abs(particlePDG) <= 4999;
397 result = particlePDG >= 4000 && particlePDG <= 4999;
399 result = particlePDG >= -4999 && particlePDG <= -4000;
403 if (checkBothCharges)
405 TMath::Abs(particlePDG) >= 4000 && TMath::Abs(particlePDG) <= 4399;
408 result = particlePDG >= 4000 && particlePDG <= 4399;
410 result = particlePDG >= -4399 && particlePDG <= -4000;
414 if (checkBothCharges)
416 TMath::Abs(particlePDG) >= 500 && TMath::Abs(particlePDG) <= 599;
418 if (requiredPDG > 0) result = particlePDG >= 500 && particlePDG <= 599;
420 result = particlePDG >= -599 && particlePDG <= -500;
424 if (checkBothCharges)
426 TMath::Abs(particlePDG) >= 500 && TMath::Abs(particlePDG) <= 549;
428 if (requiredPDG > 0) result = particlePDG >= 500 && particlePDG <= 549;
430 result = particlePDG >= -549 && particlePDG <= -500;
434 if (checkBothCharges)
436 (TMath::Abs(particlePDG) >= 500 && TMath::Abs(particlePDG) <= 549)
437 || (TMath::Abs(particlePDG) >= 5000
438 && TMath::Abs(particlePDG) <= 5499);
441 result = (particlePDG >= 500 && particlePDG <= 549)
442 || (particlePDG >= 5000 && particlePDG <= 5499);
444 result = (particlePDG >= -549 && particlePDG <= -500)
445 || (particlePDG >= -5499 && particlePDG <= -5000);
449 if (checkBothCharges)
451 (TMath::Abs(particlePDG) >= 500 && TMath::Abs(particlePDG) <= 599)
452 || (TMath::Abs(particlePDG) >= 5000
453 && TMath::Abs(particlePDG) <= 5999);
456 result = (particlePDG >= 500 && particlePDG <= 599)
457 || (particlePDG >= 5000 && particlePDG <= 5999);
459 result = (particlePDG >= -599 && particlePDG <= -500)
460 || (particlePDG >= -5999 && particlePDG <= -5000);
464 if (checkBothCharges)
466 TMath::Abs(particlePDG) >= 5000 && TMath::Abs(particlePDG) <= 5999;
469 result = particlePDG >= 5000 && particlePDG <= 5999;
471 result = particlePDG >= -5999 && particlePDG <= -5000;
475 if (checkBothCharges)
477 TMath::Abs(particlePDG) >= 5000 && TMath::Abs(particlePDG) <= 5499;
480 result = particlePDG >= 5000 && particlePDG <= 5499;
482 result = particlePDG >= -5499 && particlePDG <= -5000;
486 if (checkBothCharges)
488 (TMath::Abs(particlePDG) >= 400 && TMath::Abs(particlePDG) <= 439)
489 || (TMath::Abs(particlePDG) >= 4000
490 && TMath::Abs(particlePDG) <= 4399)
491 || (TMath::Abs(particlePDG) >= 500 && TMath::Abs(particlePDG) <= 549)
492 || (TMath::Abs(particlePDG) >= 5000
493 && TMath::Abs(particlePDG) <= 5499);
496 result = (particlePDG >= 400 && particlePDG <= 439)
497 || (particlePDG >= 4000 && particlePDG <= 4399)
498 || (particlePDG >= 500 && particlePDG <= 549)
499 || (particlePDG >= 5000 && particlePDG <= 5499);
501 result = (particlePDG >= -439 && particlePDG <= -400)
502 || (particlePDG >= -4399 && particlePDG <= -4000)
503 || (particlePDG >= -549 && particlePDG <= -500)
504 || (particlePDG >= -5499 && particlePDG <= -5000);
508 if (checkBothCharges)
509 result = (absRequiredPDG == TMath::Abs(particlePDG));
511 result = (requiredPDG == particlePDG);
514 if (absRequiredPDG != 0 && pdgExclusion) result = !result;
520 TMCProcess process)
const {
524 if (label < 0)
return kFALSE;
530 return (process == processID);
552 return (processID == kPPrimary);
588 default:
return kFALSE;
603 for (Int_t ipart = label; ipart < label + 5;
607 if (!daughter)
continue;
609 if (daughter->
GetMotherId() == label)
return kTRUE;
622 if (!signalMC)
return kFALSE;
638 Int_t branch)
const {
643 if (label < 0)
return kFALSE;
652 "PairAnalysisMC::",
"Could not find MC particle with label %d", label);
745 Int_t branch)
const {
762 Int_t labelD1 = (mcD1 ? mcD1->
GetLabel() : -1);
763 Int_t labelD2 = (mcD2 ? mcD2->
GetLabel() : -1);
768 Bool_t processGEANT = kTRUE;
788 Bool_t directTerm = kTRUE;
790 directTerm = directTerm && mcD1
797 directTerm = directTerm && mcD2
894 Bool_t crossTerm = kTRUE;
896 crossTerm = crossTerm && mcD2
903 crossTerm = crossTerm && mcD1
913 if (!mcM2 && labelD2 > -1) {
928 if (!mcM1 && labelD1 > -1) {
976 if (!mcGG2 && mcG2) {
992 if (!mcGG1 && mcG1) {
1005 Bool_t motherRelation = kTRUE;
1014 return ((directTerm || crossTerm) && motherRelation && processGEANT);
1025 if (!daughter1 || !daughter2)
return 0;
1029 if (!mcDaughter1 || !mcDaughter2)
return 0;
1033 Bool_t sameMother = (labelMother1 > -1) && (labelMother2 > -1)
1034 && (labelMother1 == labelMother2);
1043 if (processID != kPPrimary)
return kFALSE;
1046 Double_t isStable = kFALSE;
1051 if (pdg > 1000000000) isStable = kTRUE;
1082 if (!mother)
return kTRUE;
1083 Int_t pdgMother = TMath::Abs(mother->
GetPdgCode());
1087 if ((pdgMother == kSigma0) && (processMother == kPPrimary))
return kTRUE;
1089 if ((pdgMother ==
kPi0) && (processMother == kPPrimary))
return kTRUE;
1092 Int_t(pdgMother / TMath::Power(10, Int_t(TMath::Log10(pdgMother))));
1093 if (mfl < 4)
return kFALSE;
1095 if (processMother == kPPrimary)
return kTRUE;
1098 while ((mLabel = mother->
GetMotherId() && mLabel >= 0)) {
1101 pdgMother = TMath::Abs(mother->
GetPdgCode());
1102 mfl = Int_t(pdgMother / TMath::Power(10, Int_t(TMath::Log10(pdgMother))));
1103 return (mfl < 4 ? kFALSE : kTRUE);
1108 UInt_t processID)
const {
1110 if (processID != kPDecay)
return kFALSE;
1116 Int_t(pdgMother / TMath::Power(10, Int_t(TMath::Log10(pdgMother))));
1118 if (mfl == 3 || pdgMother == 211 || pdgMother == 13)
1125 UInt_t processID)
const {