]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx
Minor upgrades to the cut and to the mini-event. Added a non-streamed temp data membe...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPrimaryVertex.cxx
CommitLineData
96ab9736 1//
2// Class AliRsnCutPrimaryVertex
3//
ceaa78d3 4// This cut implementation checks the quality of event primary vertex.
5// It currently works only with ESD events (not AOD).
96ab9736 6//
7// authors: Martin Vala (martin.vala@cern.ch)
8// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9//
96ab9736 10
96ab9736 11#include "AliRsnCutPrimaryVertex.h"
12
13ClassImp(AliRsnCutPrimaryVertex)
14
96ab9736 15//_________________________________________________________________________________________________
16AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
02e8aa99 17(const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
f34f960b 18 AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, -maxVz, maxVz + 1E-6),
2a1c7696 19 fAcceptTPC(acceptTPC),
20 fCheckPileUp(kFALSE)
96ab9736 21{
22//
23// Main constructor.
ceaa78d3 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.
96ab9736 35//
36}
37
38//_________________________________________________________________________________________________
32992791 39Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
96ab9736 40{
41//
42// Cut checker
43//
2a1c7696 44
99261e24 45 // coherence check
46 // which also fills data member objects
47 if (!TargetOK(object)) return kFALSE;
48
2a1c7696 49 // retrieve ESD event
f34f960b 50 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(fEvent->GetRef());
51 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(fEvent->GetRef());
2a1c7696 52
53 if (esd) {
54 // pile-up check
55 if (fCheckPileUp) {
56 if (esd->IsPileupFromSPD()) return kFALSE;
5faf5a07 57 }
2a1c7696 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) {
f34f960b 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();
110620ce 106 fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
f34f960b 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();
110620ce 113 fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
f34f960b 114 } else {
115 AliDebugClass(1, "Vertex TRK is BAD, and vertex SPD is BAD");
116 return kFALSE;
117 }
2a1c7696 118 }
2a1c7696 119 } else
5faf5a07 120 return kFALSE;
a378358c 121
2a1c7696 122 // output
123 Bool_t result = ((!OkRangeI()) && OkRangeD());
124 return result;
96ab9736 125}
aa24e021 126
127//_________________________________________________________________________________________________
128void AliRsnCutPrimaryVertex::Print(const Option_t *) const
129{
130//
131// Print information on this cut
132//
133
2a1c7696 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));
aa24e021 138}