AliPhysics  fde8a9f (fde8a9f)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliDisplacedVertexSelectionAD.cxx
Go to the documentation of this file.
2 #include "AliESDEvent.h"
3 #include "AliESDfriend.h"
4 #include "AliESDAD.h"
5 #include "AliESDADfriend.h"
6 #include <AliCDBManager.h>
7 #include <AliCDBEntry.h>
8 #include <AliADCalibData.h>
9 #include <TList.h>
10 #include <TH2.h>
11 #include <TH1.h>
12 #include <TSpline.h>
13 #include <TMath.h>
14 
15 //--------------------------------------------------------------------
16 //
17 // See
18 //
19 // https://twiki.cern.ch/twiki/bin/viewauth/ALICE/AD_Offlline
20 //
21 
22 namespace {
23  const Bool_t kCminusA = true;
24 }
25 //--------------------------------------------------------------------
26 void
28  const char* name,
29  Bool_t mc)
30 {
31  // --- Get Calibrations from OCDB ----------------------------------
32  AliCDBManager* cdb = AliCDBManager::Instance();
33  AliCDBEntry* slew = cdb->Get("AD/Calib/TimeSlewing");
34  AliCDBEntry* calib = cdb->Get("AD/Calib/Data");
35  if (slew) fSlewing = static_cast<TList*>(slew->GetObject());
36  if (calib) fCalib = static_cast<AliADCalibData*>(calib->GetObject());
37 
38  // --- Make diagnostics --------------------------------------------
39  TList* out = new TList;
40  out->SetName("displacedVertexAD");
41  out->SetOwner();
42  l->Add(out);
43 
44  Int_t nT = 1000;
45  Double_t minT = -100;
46  Double_t maxT = +100;
47  Int_t nZ = Int_t(2*fMaxBunch*37.5)*2; // half-centimeter bins
48  Double_t minZ = -fMaxBunch*37.5;
49  Double_t maxZ = +fMaxBunch*37.5;
50 
51  fAC = new TH2D("ac", "t_{A} vs t_{C}", nT, minT, maxT, nT, minT, maxT);
52  fAC->SetDirectory(0);
53  fAC->SetXTitle("t_{A}");
54  fAC->SetYTitle("t_{C}");
55 
56  const char* diffText = (kCminusA ?
57  "#Deltat = t_{C}-t_{A}" :
58  "#Deltat = t_{A}-t_{C}");
59  const char* sumText = (kCminusA ?
60  "#sumt = t_{C}+t_{A}" :
61  "#sumt = t_{A}+t_{C}");
62 
63  fSumDelta = new TH2D("sumDelta","#Deltat vs #sumt",
64  nT, minT, maxT, 1.5*nT, minT, 2*maxT);
65  fSumDelta->SetXTitle(diffText);
66  fSumDelta->SetYTitle(sumText);
67  fSumDelta->SetDirectory(0);
68 
69  fSumDeltaSatA = static_cast<TH2*>(fSumDelta->Clone("sumDeltaSatA"));
70  fSumDeltaSatA->SetTitle("#Deltat vs #sumt (A)");
71  fSumDeltaSatA->SetDirectory(0);
72  fSumDeltaSatA->SetMarkerColor(kRed-3);
73  fSumDeltaSatA->SetMarkerStyle(20);
74  fSumDeltaSatA->SetMarkerSize(.2);
75 
76  fSumDeltaSatC = static_cast<TH2*>(fSumDelta->Clone("sumDeltaSatC"));
77  fSumDeltaSatC->SetTitle("#Deltat vs #sumt (C)");
78  fSumDeltaSatC->SetDirectory(0);
79  fSumDeltaSatC->SetMarkerColor(kBlue-3);
80  fSumDeltaSatC->SetMarkerStyle(21);
81  fSumDeltaSatC->SetMarkerSize(.2);
82 
83  fIPzAll = new TH1D("ipZ", "AD IP_{#it{z}}",
84  nZ, minZ, maxZ);
85  fIPzAll->SetDirectory(0);
86  fIPzAll->SetXTitle("IP_{#it{z}} [cm]");
87  fIPzAll->SetYTitle("Events");
88  fIPzAll->SetFillStyle(3001);
89  fIPzAll->SetFillColor(kGray+2);
90  fIPzAll->SetLineColor(kGray+2);
91 
92  fIPzSatA = static_cast<TH1*>(fIPzAll->Clone("ipZsatA"));
93  fIPzSatA->SetTitle("Main-Satellite IP_{#it{z}} (A)");
94  fIPzSatA->SetFillColor(kRed-3);
95  fIPzSatA->SetLineColor(kRed-3);
96  fIPzSatA->SetDirectory(0);
97 
98  fIPzSatC = static_cast<TH1*>(fIPzAll->Clone("ipZsatC"));
99  fIPzSatC->SetTitle("Satellite-Main IP_{#it{z}} (C)");
100  fIPzSatC->SetFillColor(kBlue-3);
101  fIPzSatC->SetLineColor(kBlue-3);
102  fIPzSatC->SetDirectory(0);
103 
104  fIPzMain = static_cast<TH1*>(fIPzAll->Clone("ipZmain"));
105  fIPzMain->SetTitle("Main-Main IP_{#it{z}}");
106  fIPzMain->SetFillColor(kGreen-3);
107  fIPzMain->SetLineColor(kGreen-3);
108  fIPzMain->SetDirectory(0);
109 
110  fIPzDelta = new TH2D("deltaIPz", "#Deltat vs IP_{#it{z}}",
111  nT/5, minT/2.5, maxT/2.5, nZ, minZ, maxZ);
112  fIPzDelta->SetDirectory(0);
113  fIPzDelta->SetXTitle(diffText);
114  fIPzDelta->SetYTitle("IP_{#it{z}} [cm]");
115 
116  fIPzSum = new TH2D("sumIPz", "#sumt vs IP_{#it{z}}",
117  1.5*nT, minT, 2*maxT, nZ, minZ, maxZ);
118  fIPzSum->SetDirectory(0);
119  fIPzSum->SetXTitle(sumText);
120  fIPzSum->SetYTitle("IP_{#it{z}} [cm]");
121 
122  fIPzBunch = new TH2D("bunchIpz", "De-bunch # vs IP_{#it{z}}",
123  2*fMaxBunch+1, -fMaxBunch-.5, +fMaxBunch+.5,
124  nZ, minZ, maxZ);
125  fIPzBunch->SetDirectory(0);
126  fIPzBunch->SetXTitle("De-bunch #");
127  fIPzBunch->SetYTitle("IP_{#it{z}} [cm]");
128 
129  out->Add(fAC);
130  out->Add(fSumDelta);
131  out->Add(fSumDeltaSatA);
132  out->Add(fSumDeltaSatC);
133  out->Add(fIPzAll);
134  out->Add(fIPzSatA);
135  out->Add(fIPzSatC);
136  out->Add(fIPzMain);
137  out->Add(fIPzDelta);
138  out->Add(fIPzSum);
139  out->Add(fIPzBunch);
140 }
141 
142 //--------------------------------------------------------------------
143 void
145 {
146  Printf("Displaced vertex from AD signal");
147 }
148 
149 //--------------------------------------------------------------------
150 Bool_t
152 {
153  fIPz = kInvalidVtxZ;
155  AliESDAD* adESD = esd->GetADData();
156  AliESDfriend* esdFriend = esd->FindFriend();
157  AliESDADfriend* adFriend = esdFriend->GetADfriend();
158 
159  Double_t tA = MeanTime(adESD, adFriend, true);
160  Double_t tC = MeanTime(adESD, adFriend, false);
161  if (tA == -kInvalidTime || tC == -kInvalidTime) return true;
162 
163  fAC->Fill(tA, tC);
164 
165  Double_t sumT = tA + tC;
166  Double_t deltaT = tC - tA;
167 
168  fSumDelta->Fill(deltaT, sumT);
169 
170  // C [m/s] * deltaT [ns] / 2 * 10^-9 [s/ns] * 10^2 [cm/m]
171  fIPz = TMath::C() * deltaT / 2 * 1e-9 * 1e2;
172  fIPzAll->Fill(fIPz);
173 
174  fIPzDelta->Fill(deltaT, fIPz);
175  fIPzSum->Fill(sumT, fIPz);
176 
177  Double_t r2 = 2*fSpacing/2*fSpacing/2;
178  // Double_t r = TMath::Sqrt(r2);
179  Int_t b = -100;
180  for (Int_t i = -fMaxBunch; i <= fMaxBunch; i++) {
181  Double_t ir = i*fSpacing;
182  Double_t x2 = TMath::Power(deltaT-ir,2);
183  Double_t y2 = TMath::Power(sumT -ir,2);
184  Double_t u2 = TMath::Power(-sumT -ir,2);
185 
186  if ((x2+y2) < r2 || (x2+u2) < r2) {
187  // Got a collision - which kind?
188  b = i;
189  if (i == 0)
190  // Main-main
191  fEventType = kMain;
192  // else if (TMath::SignBit(deltaT) == TMath::SignBit(sumT))
193  else if (std::signbit(deltaT) == std::signbit(sumT))
194  // If difference and sum have same signs
195  fEventType = (kCminusA ? kSatelliteA : kSatelliteC);
196  else
197  // If difference and sum have opposite signs
198  fEventType = (kCminusA ? kSatelliteC : kSatelliteA);
199  break;
200  }
201  }
202  switch (fEventType) {
203  case kMain: fIPzMain->Fill(fIPz); break;
204  case kSatelliteA: fIPzSatA->Fill(fIPz);fSumDeltaSatA->Fill(deltaT,sumT);break;
205  case kSatelliteC: fIPzSatC->Fill(fIPz);fSumDeltaSatC->Fill(deltaT,sumT);break;
206  default: break;
207  }
208 
209  if (b > -100) fIPzBunch->Fill(b, fIPz);
210 
211  return true;
212 }
213 //--------------------------------------------------------------------
214 Double_t
216  AliESDADfriend* adFriend,
217  Bool_t aNotC) const
218 {
219  if (!fCalib || !fSlewing) return -kInvalidTime;
220  if (!adESD || !adFriend) return -kInvalidTime;
221 
222  const Int_t chMin = (aNotC ? 8 : 0);
223  const Int_t chMax = (aNotC ? 16 : 8);
224 
225  const Double_t tRes = fCalib->GetTimeResolution(aNotC);
226 
227  Int_t cnt = 0;
228  Double_t sumW = 0;
229  Double_t sumWT = 0;
230  for (Int_t ch = chMin; ch < chMax; ++ch) {
231  const Double_t charge = adESD->GetAdc(ch);
232  if (adFriend->GetWidth(ch) <= 1e-6 || charge <= 10.) continue;
233 
234  TSpline3* sts = static_cast<TSpline3*>(fSlewing->At(ch));
235  Double_t q2 = TMath::Power(charge, 2);
236  cnt++;
237  sumW += q2;
238  sumWT += q2 * (adFriend->GetTime(ch) -
239  tRes * sts->Eval(TMath::Log10(1./charge)));
240  }
241 
242  return (cnt > 0 ? sumWT/sumW : -kInvalidTime);
243 }
244 //--------------------------------------------------------------------
245 //
246 // EOF
247 //
Int_t charge
double Double_t
Definition: External.C:58
void Print(Option_t *option="") const
int Int_t
Definition: External.C:63
Definition: External.C:228
Definition: External.C:212
Definition: External.C:220
void SetupForData(TList *l, const char *name=0, Bool_t mc=false)
Double_t MeanTime(AliESDAD *adESD, AliESDADfriend *adFriend, Bool_t aNotC) const
Bool_t Process(const AliESDEvent *esd)
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
Definition: External.C:196