]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnPIDManager.cxx
Migration of PWG2/RESONANCES -> PWGLF/RESONANCES
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnPIDManager.cxx
1 #include <TEntryList.h>
2
3 #include "AliLog.h"
4 #include "AliPID.h"
5
6 #include "AliRsnCutSet.h"
7
8 #include "AliRsnPIDManager.h"
9
10 ClassImp(AliRsnPIDManager)
11
12 //_____________________________________________________________________________
13 AliRsnPIDManager::AliRsnPIDManager(const char *name, const char *title) : TNamed(name, title)
14 {
15 //
16 // Default constructor.
17 //
18    AliDebug(AliLog::kDebug + 10, "<-");
19    AliDebug(AliLog::kDebug + 10, "->");
20 }
21
22 //_____________________________________________________________________________
23 AliRsnPIDManager::~AliRsnPIDManager()
24 {
25    //
26    // Destructor
27    //
28    AliDebug(AliLog::kDebug + 10, "<-");
29    for (Int_t iCharge = 0; iCharge < 2; iCharge++) fIdParticles[iCharge].Delete();
30    AliDebug(AliLog::kDebug + 10, "->");
31 }
32
33 void AliRsnPIDManager::Print(Option_t *option) const
34 {
35    TNamed::Print(option);
36
37    TEntryList *el;
38    AliRsnCutSet *cut;
39    for (Int_t iCharge = 0; iCharge < 2; iCharge++) {
40       for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) {
41          cut = (AliRsnCutSet *) fCuts.At(iParticle);
42          if (!cut) continue;
43          el = (TEntryList *)fIdParticles[iCharge].At(iParticle);
44          if (el) AliInfo(Form("%d %d %lld %s", iCharge, iParticle, el->GetN(), cut->GetName()));
45       }
46    }
47 }
48
49 void AliRsnPIDManager::Init()
50 {
51    for (Int_t iCharge = 0; iCharge < 2; iCharge++) {
52       for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) {
53          fIdParticles[iCharge].Add(new TEntryList());
54 //          fCuts.Add(new AliRsnCutSet("", AliRsnTarget::kDaughter));
55       }
56    }
57 }
58
59
60 void AliRsnPIDManager::Reset()
61 {
62    TEntryList *el;
63    for (Int_t iCharge = 0; iCharge < 2; iCharge++) {
64       for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) {
65          el = (TEntryList *)fIdParticles[iCharge].At(iParticle);
66          el->Reset();
67       }
68    }
69 }
70
71
72 TEntryList *AliRsnPIDManager::GetParticles(const Int_t &charge, const Int_t &pidId)
73 {
74    return (TEntryList *)fIdParticles[charge].At(pidId);
75 }
76
77 void AliRsnPIDManager::SetCut(AliRsnCutSet *cut, const Int_t &pidId)
78 {
79    if (!cut) return;
80    if (!fCuts.GetEntriesFast()) Init();
81    fCuts.AddAt(cut, pidId);
82 }
83
84 void AliRsnPIDManager::ApplyCuts(AliRsnEvent *ev)
85 {
86
87    // Loop over event and add entruies to entry list
88    Int_t numTracks = ev->GetRefESD()->GetNumberOfTracks();
89    Int_t iTrack;
90    AliRsnDaughter daughter;
91    for (iTrack = 0; iTrack < numTracks; iTrack++) {
92       ev->SetDaughter(daughter, iTrack, AliRsnDaughter::kTrack);
93       daughter.SetRsnID(iTrack);
94       CheckTrack(&daughter, iTrack);
95    }
96
97 }
98
99 void AliRsnPIDManager::CheckTrack(AliRsnDaughter *d, const Int_t &id)
100 {
101    TEntryList *el;
102    AliRsnCutSet *cut;
103    TString cutName;
104    for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) {
105
106       cut = (AliRsnCutSet *) fCuts.At(iParticle);
107       if (!cut) continue;
108       cutName = cut->GetName();
109       if (!cutName.IsNull()) {
110          if (!cut->IsSelected(d)) continue;
111          if (d->IsPos()) {
112             el = (TEntryList *)fIdParticles[0].At(iParticle);
113             el->Enter(id);
114          } else if (d->IsNeg()) {
115             el = (TEntryList *)fIdParticles[1].At(iParticle);
116             el->Enter(id);
117          }
118       }
119    }
120 }