]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnCutPrimaryVertex.cxx
Extended pT-axis range (Neelima)
[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 #include "AliAnalysisUtils.h"
13
14 ClassImp(AliRsnCutPrimaryVertex)
15
16 //_________________________________________________________________________________________________
17 AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
18 (const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
19    AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, -maxVz, maxVz + 1E-6),
20    fAcceptTPC(acceptTPC),
21    fCheckPileUp(kFALSE)
22 {
23 //
24 // Main constructor.
25 // Defines the cut range between 0 and
26 // the minimum required number of contributors.
27 // The cut will be passed when if the event has a
28 // primary vertex with number of contributors outside this interval.
29 // ---
30 // If the 'acceptTPC' argument is true, events with TPC
31 // primary vertex will be checked, otherwise they will be
32 // rejected by default.
33 // ---
34 // Since the range check uses the '>=' and '<=', the high edge
35 // must be decreased by 1 to get the right behaviour, since this is integer.
36 //
37 }
38
39 //_________________________________________________________________________________________________
40 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
41 {
42 //
43 // Cut checker
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    AliVEvent *vevt = dynamic_cast<AliVEvent *>(fEvent->GetRef());
53    // pile-up check
54    if (fCheckPileUp) {
55      AliAnalysisUtils * utils = new AliAnalysisUtils();
56      if (utils->IsPileUpSPD(vevt)) return kFALSE;
57    }
58    
59    if (esd) {
60       // get the best primary vertex:
61       // first try the one with tracks
62       const AliESDVertex *vTrk  = esd->GetPrimaryVertexTracks();
63       const AliESDVertex *vSPD  = esd->GetPrimaryVertexSPD();
64       const AliESDVertex *vTPC  = esd->GetPrimaryVertexTPC();
65       Int_t               ncTrk = -1;
66       Int_t               ncSPD = -1;
67       Int_t               ncTPC = -1;
68       Double_t            vzTrk = 1000000.0;
69       Double_t            vzSPD = 1000000.0;
70       Double_t            vzTPC = 1000000.0;
71       if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
72       if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
73       if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
74       if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
75       if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
76       if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
77       if (vTrk && ncTrk > 0) {
78          fCutValueI = ncTrk;
79          fCutValueD = vzTrk;
80       } else if (vSPD && ncSPD > 0) {
81          fCutValueI = ncSPD;
82          fCutValueD = vzSPD;
83       } else if (vTPC && ncTPC > 0) {
84          if (!fAcceptTPC)
85             return kFALSE;
86          else {
87             fCutValueI = ncTPC;
88             fCutValueD = vzTPC;
89          }
90       } else
91          return kFALSE;
92    } else if (aod) {
93       // in this case, as suggested by Andrea Dainese,
94       // we first check if the SPD primary vertex is there
95       // if it is not, then the only available is the TPC
96       // stand-alone primary vertex, which is rejected
97       AliAODVertex *aodv = aod->GetPrimaryVertexSPD();
98       if (!aodv) {
99          AliDebugClass(1, "Not found SPD vertex --> TPC only available, skipped");
100          return kFALSE;
101       }
102       // now check primary vertex
103       aodv = (AliAODVertex *)aod->GetPrimaryVertex();
104       if (CheckVertex(aodv)) {
105          AliDebugClass(1, "Vertex TRK is OK");
106          fCutValueD = aodv->GetZ();
107          fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
108       }
109       else {
110          aodv = aod->GetPrimaryVertexSPD();
111          if (CheckVertex(aodv)) {
112             AliDebugClass(1, "Vertex TRK is BAD, but vertex SPD is OK");
113             fCutValueD = aodv->GetZ();
114             fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
115          } else {
116             AliDebugClass(1, "Vertex TRK is BAD, and vertex SPD is BAD");
117             return kFALSE;
118          }
119       }
120    } else
121       return kFALSE;
122
123    // output
124    Bool_t result = ((!OkRangeI()) && OkRangeD());
125    return result;
126 }
127
128 //_________________________________________________________________________________________________
129 void AliRsnCutPrimaryVertex::Print(const Option_t *) const
130 {
131 //
132 // Print information on this cut
133 //
134
135    AliInfo(Form("Cut name                     : %s", GetName()));
136    AliInfo(Form("Accepting TPC primary vertex : %s", (fAcceptTPC ? "YES" : "NO")));
137    AliInfo(Form("Contributors range (outside) : %d - %d", fMinI, fMaxI));
138    AliInfo(Form("Z-vertex     range (inside)  : %f - %f", fMinD, fMaxD));
139 }
140
141 //__________________________________________________________________________________________________
142 Bool_t AliRsnCutPrimaryVertex::CheckVertex(AliVVertex *vertex)
143 {
144 //
145 // Checks if a candidate primary vertex is good,
146 // which is true if it is not null and has at
147 // least one contributor
148 //
149
150    if (!vertex) return kFALSE;
151    if (vertex->GetNContributors() < 1) return kFALSE;
152    return kTRUE;
153 }