Fix compilation
[u/mrichter/AliRoot.git] / PWG4 / TwoPartCorr / AutoCorr.C
CommitLineData
1ea9a8fc 1// $Id$
2
88a5a45e 3#include "AutoCorr.h"
4
1ea9a8fc 5ClassImp(AutoCorr)
6
88a5a45e 7Int_t AutoCorr::InitEventPools(Int_t depth,
8 Int_t nMultBins, Double_t multbin[],
8e96fdc6 9 Int_t nZvtxBins, Double_t zvtxbin[],
b2745644 10 Double_t /*ptMin*/, Double_t /*ptMax*/)
88a5a45e 11{
12 // First assign AutoCorr members
13 fNMultBins = nMultBins;
14 fNZvtxBins = nZvtxBins;
15
1000cb24 16 for (Int_t iM=0; iM<nMultBins; iM++) {
88a5a45e 17 std::vector<EventPool*> evp;
1000cb24 18 for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
88a5a45e 19 evp.push_back(new EventPool(depth,
20 multbin[iM], multbin[iM+1],
b2745644 21 zvtxbin[iZ], zvtxbin[iZ+1]));
88a5a45e 22 }
23 fEvPool.push_back(evp);
24 }
25
1000cb24 26 for (Int_t iM=0; iM<nMultBins; iM++) {
27 for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
88a5a45e 28 fEvPool.at(iM).at(iZ)->SetMultBinIndex(iM);
29 fEvPool.at(iM).at(iZ)->SetZvtxBinIndex(iZ);
30 }
31 }
32
33 bool print_this = false;
34 if (print_this) {
35 cout << "fEvPool outer size: " << fEvPool.size() << endl;
1000cb24 36 for (Int_t iM=0; iM<nMultBins; iM++) {
37 for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
88a5a45e 38 if(fEvPool.at(iM).at(iZ)) {
39 cout << "multiplicity bin: " << iM;
40 cout << ", z-vertex bin: " << iZ;
41 fEvPool.at(iM).at(iZ)->PrintInfo();
42 }
43 }
44 }
45 }
46
47 return 0;
48}
49
1000cb24 50EventPool* AutoCorr::GetEventPool(Int_t iMult, Int_t iZvtx) const
88a5a45e 51{
52 if (iMult < 0 || iMult >= fNMultBins) return 0x0;
53 if (iZvtx < 0 || iZvtx >= fNZvtxBins) return 0x0;
54 return fEvPool.at(iMult).at(iZvtx);
55}
56
1000cb24 57Int_t AutoCorr::UpdatePools(Int_t iEvent, const MyHeader* ev, TClonesArray* trk)
88a5a45e 58{
1000cb24 59 for (Int_t iM=0; iM<fNMultBins; iM++) {
60 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
88a5a45e 61 fEvPool.at(iM).at(iZ)->UpdatePool(iEvent, ev, trk);
62 }
63 }
64 return 0;
65}
66
1ea9a8fc 67Double_t AutoCorr::DeltaPhi(const MyPart &t1, const MyPart &t2,
68 Double_t rangeMin, Double_t rangeMax) const
88a5a45e 69{
70 Double_t dphi = -999;
71 Double_t pi = TMath::Pi();
75617407 72 Double_t phia = t1.fPhi;
73 Double_t phib = t2.fPhi;
88a5a45e 74
75 if (phia < 0) phia += 2*pi;
76 else if (phia > 2*pi) phia -= 2*pi;
77 if (phib < 0) phib += 2*pi;
78 else if (phib > 2*pi) phib -= 2*pi;
79 dphi = phib - phia;
80 if (dphi < rangeMin) dphi += 2*pi;
81 else if (dphi > rangeMax) dphi -= 2*pi;
82
83 return dphi;
84}
85
1ea9a8fc 86Double_t AutoCorr::DeltaEta(const MyPart &t1, const MyPart &t2) const
88a5a45e 87{
75617407 88 return t1.fEta - t2.fEta;
88a5a45e 89}
90
1ea9a8fc 91Bool_t AutoCorr::InBounds(Double_t val, Double_t min, Double_t max) const
88a5a45e 92{
1ea9a8fc 93 if (val<min)
94 return 0;
95 if (val>max)
96 return 0;
97 return 1;
88a5a45e 98}
99
1ea9a8fc 100Bool_t AutoCorr::InBounds(Int_t val, Int_t min, Int_t max) const
88a5a45e 101{
1ea9a8fc 102 if (val<min)
103 return 0;
104 if (val>max)
105 return 0;
106 return 1;
107}
88a5a45e 108
1ea9a8fc 109Bool_t AutoCorr::IsEventOk(const MyHeader &ev, Int_t minVc,
1000cb24 110 Int_t maxNTracklets, Double_t zMin, Double_t zMax,
111 Int_t trbit) const
1ea9a8fc 112{
113 Bool_t VcOk = ev.fVc >= minVc;
114 Bool_t NTrackletsOK = ev.fNTracklets <= maxNTracklets;
115 Bool_t zOk = InBounds(ev.fVz, zMin, zMax);
1000cb24 116 Bool_t trOk = 1;
117 if (trbit)
118 trOk = (ev.fTrClassMask>>trbit&1);
119 return (!ev.fIsPileupSPD && VcOk && NTrackletsOK && zOk && trOk);
1ea9a8fc 120}
88a5a45e 121
1ea9a8fc 122Bool_t AutoCorr::IsTrackOk(const MyPart &t, Double_t etaMin, Double_t etaMax) const
123{
75617407 124 return InBounds(t.fEta, etaMin, etaMax);
88a5a45e 125}
126
1ea9a8fc 127Bool_t AutoCorr::IsTrackOk(const MyPart &t, Double_t etaMin, Double_t etaMax,
128 Double_t ptMin, Double_t ptMax) const
88a5a45e 129{
75617407 130 Bool_t etaOk = InBounds(t.fEta, etaMin, etaMax);
131 Bool_t ptOk = InBounds(t.fPt, ptMin, ptMax);
1ea9a8fc 132 return etaOk && ptOk;
133}
88a5a45e 134
1ea9a8fc 135Bool_t AutoCorr::IsPairOk(const MyPart &t1, const MyPart &t2) const
136{
137 Double_t deta = DeltaEta(t1, t2);
138 Double_t dphi = DeltaPhi(t1, t2);
139 Double_t dpmax = 0.03;
8e96fdc6 140 Double_t demax = 0.03;
1ea9a8fc 141 Double_t dr = dphi*dphi/(dpmax*dpmax) + deta*deta/(demax*demax);
142 return (dr > 1);
143}
88a5a45e 144
1ea9a8fc 145Bool_t AutoCorr::IsMixedPairOk(const MyPart &t1, const MyPart &t2) const
146{
147 Double_t deta = DeltaEta(t1, t2);
148 Double_t dphi = DeltaPhi(t1, t2);
8e96fdc6 149 Double_t dpmax = 0.03;
150 Double_t demax = 0.03;
1ea9a8fc 151 Double_t dr = dphi*dphi/(dpmax*dpmax) + deta*deta/(demax*demax);
88a5a45e 152 return (dr > 1);
153}
154
1ea9a8fc 155Double_t AutoCorr::InvMass(const MyPart &p1, const MyPart &p2) const
156{
157 Double_t px1 = p1.Px();
158 Double_t py1 = p1.Py();
159 Double_t pz1 = p1.Pz();
160 Double_t px2 = p2.Px();
161 Double_t py2 = p2.Py();
162 Double_t pz2 = p2.Pz();
163 Double_t pm1 = TMath::Sqrt(px1*px1+py1*py1+pz1*pz1);
164 Double_t pm2 = TMath::Sqrt(px2*px2+py2*py2+pz1*pz2);
165 Double_t p12 = px1*px2+py1*py2+pz1*pz2;
166 Double_t m = TMath::Sqrt(pm1*pm2-p12);
167 return m;
168}