]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx
Add new version of macros for RSN analysis
[u/mrichter/AliRoot.git] / PWG2 / 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, 0.0, maxVz),
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    fMinD = 0.0;
38    fMaxD = maxVz + 1E-6;
39 }
40
41 //_________________________________________________________________________________________________
42 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
43 {
44 //
45 // Cut checker
46 //
47
48    // coherence check
49    // which also fills data member objects
50    if (!TargetOK(object)) return kFALSE;
51
52    // retrieve ESD event
53    AliESDEvent *esd = fEvent->GetRefESD();
54    AliAODEvent *aod = fEvent->GetRefAOD();
55
56    if (esd) {
57       // pile-up check
58       if (fCheckPileUp) {
59          if (esd->IsPileupFromSPD()) return kFALSE;
60       }
61
62       // get the best primary vertex:
63       // first try the one with tracks
64       const AliESDVertex *vTrk  = esd->GetPrimaryVertexTracks();
65       const AliESDVertex *vSPD  = esd->GetPrimaryVertexSPD();
66       const AliESDVertex *vTPC  = esd->GetPrimaryVertexTPC();
67       Int_t               ncTrk = -1;
68       Int_t               ncSPD = -1;
69       Int_t               ncTPC = -1;
70       Double_t            vzTrk = 1000000.0;
71       Double_t            vzSPD = 1000000.0;
72       Double_t            vzTPC = 1000000.0;
73       if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
74       if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
75       if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
76       if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
77       if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
78       if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
79       if (vTrk && ncTrk > 0) {
80          fCutValueI = ncTrk;
81          fCutValueD = vzTrk;
82       } else if (vSPD && ncSPD > 0) {
83          fCutValueI = ncSPD;
84          fCutValueD = vzSPD;
85       } else if (vTPC && ncTPC > 0) {
86          if (!fAcceptTPC)
87             return kFALSE;
88          else {
89             fCutValueI = ncTPC;
90             fCutValueD = vzTPC;
91          }
92       } else
93          return kFALSE;
94    } else if (aod) {
95       // pile-up check is not yet available for AODs
96
97       // lines suggested by Andrea to reject TPC-only events
98       if (!fAcceptTPC) {
99          if (!aod->GetPrimaryVertexSPD()) return kFALSE;
100          else if (aod->GetPrimaryVertexSPD()->GetNContributors() < 1) return kFALSE;
101       }
102
103       AliAODVertex *prim = (AliAODVertex*)aod->GetPrimaryVertex();
104       if (!prim) return kFALSE;
105
106       fCutValueI = prim->GetNContributors();
107       fCutValueD = prim->GetZ();
108    } else
109       return kFALSE;
110
111    // output
112    Bool_t result = ((!OkRangeI()) && OkRangeD());
113    return result;
114 }
115
116 //_________________________________________________________________________________________________
117 void AliRsnCutPrimaryVertex::Print(const Option_t *) const
118 {
119 //
120 // Print information on this cut
121 //
122
123    AliInfo(Form("Cut name                     : %s", GetName()));
124    AliInfo(Form("Accepting TPC primary vertex : %s", (fAcceptTPC ? "YES" : "NO")));
125    AliInfo(Form("Contributors range (outside) : %d - %d", fMinI, fMaxI));
126    AliInfo(Form("Z-vertex     range (inside)  : %f - %f", fMinD, fMaxD));
127 }