]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnCutPrimaryVertex.cxx
Updated macros for Sigma* analysis + debug option enabled in AliRsnCutV0 (M.Venaruzzo...
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutPrimaryVertex.cxx
1 //
2 // Class AliRsnCutPrimaryVertex
3 //
4 // This cut implementation checks the quality of event primary vertex.
5 // It currently works only with ESD events (not AOD).
6 //
7 // authors: Martin Vala (martin.vala@cern.ch)
8 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9 //
10
11 #include "AliRsnCutPrimaryVertex.h"
12
13 ClassImp(AliRsnCutPrimaryVertex)
14
15 //_________________________________________________________________________________________________
16 AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
17 (const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
18    AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, -maxVz, maxVz + 1E-6),
19    fAcceptTPC(acceptTPC),
20    fCheckPileUp(kFALSE)
21 {
22 //
23 // Main constructor.
24 // Defines the cut range between 0 and
25 // the minimum required number of contributors.
26 // The cut will be passed when if the event has a
27 // primary vertex with number of contributors outside this interval.
28 // ---
29 // If the 'acceptTPC' argument is true, events with TPC
30 // primary vertex will be checked, otherwise they will be
31 // rejected by default.
32 // ---
33 // Since the range check uses the '>=' and '<=', the high edge
34 // must be decreased by 1 to get the right behaviour, since this is integer.
35 //
36 }
37
38 //_________________________________________________________________________________________________
39 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
40 {
41 //
42 // Cut checker
43 //
44
45    // coherence check
46    // which also fills data member objects
47    if (!TargetOK(object)) return kFALSE;
48
49    // retrieve ESD event
50    AliESDEvent *esd = dynamic_cast<AliESDEvent *>(fEvent->GetRef());
51    AliAODEvent *aod = dynamic_cast<AliAODEvent *>(fEvent->GetRef());
52
53    if (esd) {
54       // pile-up check
55       if (fCheckPileUp) {
56          if (esd->IsPileupFromSPD()) return kFALSE;
57       }
58
59       // get the best primary vertex:
60       // first try the one with tracks
61       const AliESDVertex *vTrk  = esd->GetPrimaryVertexTracks();
62       const AliESDVertex *vSPD  = esd->GetPrimaryVertexSPD();
63       const AliESDVertex *vTPC  = esd->GetPrimaryVertexTPC();
64       Int_t               ncTrk = -1;
65       Int_t               ncSPD = -1;
66       Int_t               ncTPC = -1;
67       Double_t            vzTrk = 1000000.0;
68       Double_t            vzSPD = 1000000.0;
69       Double_t            vzTPC = 1000000.0;
70       if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
71       if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
72       if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
73       if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
74       if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
75       if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
76       if (vTrk && ncTrk > 0) {
77          fCutValueI = ncTrk;
78          fCutValueD = vzTrk;
79       } else if (vSPD && ncSPD > 0) {
80          fCutValueI = ncSPD;
81          fCutValueD = vzSPD;
82       } else if (vTPC && ncTPC > 0) {
83          if (!fAcceptTPC)
84             return kFALSE;
85          else {
86             fCutValueI = ncTPC;
87             fCutValueD = vzTPC;
88          }
89       } else
90          return kFALSE;
91    } else if (aod) {
92       // in this case, as suggested by Andrea Dainese,
93       // we first check if the SPD primary vertex is there
94       // if it is not, then the only available is the TPC
95       // stand-alone primary vertex, which is rejected
96       AliAODVertex *aodv = aod->GetPrimaryVertexSPD();
97       if (!aodv) {
98          AliDebugClass(1, "Not found SPD vertex --> TPC only available, skipped");
99          return kFALSE;
100       }
101       // now check primary vertex
102       aodv = (AliAODVertex *)aod->GetPrimaryVertex();
103       if (CheckVertex(aodv)) {
104          AliDebugClass(1, "Vertex TRK is OK");
105          fCutValueD = aodv->GetZ();
106          fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
107       }
108       else {
109          aodv = aod->GetPrimaryVertexSPD();
110          if (CheckVertex(aodv)) {
111             AliDebugClass(1, "Vertex TRK is BAD, but vertex SPD is OK");
112             fCutValueD = aodv->GetZ();
113             fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
114          } else {
115             AliDebugClass(1, "Vertex TRK is BAD, and vertex SPD is BAD");
116             return kFALSE;
117          }
118       }
119    } else
120       return kFALSE;
121
122    // output
123    Bool_t result = ((!OkRangeI()) && OkRangeD());
124    return result;
125 }
126
127 //_________________________________________________________________________________________________
128 void AliRsnCutPrimaryVertex::Print(const Option_t *) const
129 {
130 //
131 // Print information on this cut
132 //
133
134    AliInfo(Form("Cut name                     : %s", GetName()));
135    AliInfo(Form("Accepting TPC primary vertex : %s", (fAcceptTPC ? "YES" : "NO")));
136    AliInfo(Form("Contributors range (outside) : %d - %d", fMinI, fMaxI));
137    AliInfo(Form("Z-vertex     range (inside)  : %f - %f", fMinD, fMaxD));
138 }