]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx
Added a protection in case the raw data signal (channel) has a read out error (neg...
[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
15//_________________________________________________________________________________________________
16AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex() :
2dab9030 17 AliRsnCut(AliRsnCut::kEvent),
18 fAcceptTPC(kFALSE)
96ab9736 19{
20//
21// Default constructor.
22//
23}
24
25//_________________________________________________________________________________________________
26AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
02e8aa99 27(const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
2dab9030 28 AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1),
29 fAcceptTPC(acceptTPC)
96ab9736 30{
31//
32// Main constructor.
ceaa78d3 33// Defines the cut range between 0 and
34// the minimum required number of contributors.
35// The cut will be passed when if the event has a
36// primary vertex with number of contributors outside this interval.
37// ---
38// If the 'acceptTPC' argument is true, events with TPC
39// primary vertex will be checked, otherwise they will be
40// rejected by default.
41// ---
42// Since the range check uses the '>=' and '<=', the high edge
43// must be decreased by 1 to get the right behaviour, since this is integer.
96ab9736 44//
02e8aa99 45
46 fMinD = 0.0;
0d73200d 47 fMaxD = maxVz + 1E-6;
96ab9736 48}
49
50//_________________________________________________________________________________________________
2dab9030 51Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *obj1, TObject* /*obj2*/)
96ab9736 52{
53//
54// Cut checker
55//
56
0d73200d 57 static Int_t evNum = 0;
58 evNum++;
59
96ab9736 60 // retrieve ESD event
2dab9030 61 AliRsnEvent *rsn = dynamic_cast<AliRsnEvent*>(obj1);
62 if (!rsn) return kFALSE;
a378358c 63 AliESDEvent *esd = rsn->GetRefESD();
64 AliAODEvent *aod = rsn->GetRefAOD();
47c1a0e0 65
66 if (esd)
02e8aa99 67 {
47c1a0e0 68 // get the best primary vertex:
69 // first try the one with tracks
70 const AliESDVertex *vTrk = esd->GetPrimaryVertexTracks();
71 const AliESDVertex *vSPD = esd->GetPrimaryVertexSPD();
72 const AliESDVertex *vTPC = esd->GetPrimaryVertexTPC();
73 Int_t ncTrk = -1;
74 Int_t ncSPD = -1;
75 Int_t ncTPC = -1;
76 Double_t vzTrk = 2.0 * fMaxD;
77 Double_t vzSPD = 2.0 * fMaxD;
78 Double_t vzTPC = 2.0 * fMaxD;
79 if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
80 if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
81 if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
82 if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
83 if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
84 if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
85 if(vTrk && ncTrk > 0)
86 {
87 fCutValueI = ncTrk;
88 fCutValueD = vzTrk;
89 }
90 else if (vSPD && ncSPD > 0)
91 {
92 fCutValueI = ncSPD;
93 fCutValueD = vzSPD;
94 }
95 else if (vTPC && fAcceptTPC && ncTPC > 0)
96 {
97 fCutValueI = ncTPC;
98 fCutValueD = vzTPC;
99 }
100 else
101 {
102 fCutValueI = -1;
103 fCutValueD = 2.0 * fMaxD;
104 }
ceaa78d3 105 }
47c1a0e0 106 else if (aod)
02e8aa99 107 {
89202f72 108 // lines suggested by Andrea to reject TPC-only events
a378358c 109 if(!fAcceptTPC)
110 {
111 if (!aod->GetPrimaryVertexSPD()) return kFALSE;
112 else if(aod->GetPrimaryVertexSPD()->GetNContributors() < 1) return kFALSE;
113 }
89202f72 114
115 AliAODVertex *prim = (AliAODVertex*)aod->GetPrimaryVertex();
a378358c 116 if (!prim) return kFALSE;
117
118 //fCutValueI = prim->GetNContributors();
12ca7a91 119 fCutValueD = prim->GetZ();
02e8aa99 120 }
121 else
47c1a0e0 122 return kFALSE;
123
0d73200d 124 // output
125 Bool_t result = ((!OkRangeI()) && OkRangeD());
0d73200d 126 return result;
96ab9736 127}
128