]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEemcalPIDqa.cxx
Transition PWG3 --> PWGHF
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEemcalPIDqa.cxx
CommitLineData
c2690925 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15//
16// Class AliHFEemcalPIDqa
17//
18// Monitoring EMCAL PID in the HFE PID montioring framework. The following
19// quantities are monitored:
20// TPC Signal distribution
21// (Always as function of momentum, particle species and centrality
22// before and after cut)
23// More information about the PID monitoring framework can be found in
24// AliHFEpidQAmanager.cxx and AliHFEdetPIDqa.cxx
25//
26// Author:
27//
28// Shingo Sakai <ssakai@lbl.gov>
29#include <TClass.h>
30#include <TH2.h>
31#include <THnSparse.h>
32#include <TString.h>
33
e156c3bb 34#include <TMath.h>
35#include "AliESDInputHandler.h"
36//#include "AliVCluster.h"
37//#include "AliVCaloCells.h"
38//#include "AliVEvent.h"
39#include "AliMagF.h"
8c1c76e9 40#include "AliPIDResponse.h"
e156c3bb 41
c2690925 42#include "AliLog.h"
43#include "AliPID.h"
44#include "AliVParticle.h"
e156c3bb 45//#include "AliVTrack.h"
46//#include "AliESDtrack.h"
c2690925 47#include "AliHFEcollection.h"
48#include "AliHFEpid.h"
49#include "AliHFEpidBase.h"
50#include "AliHFEpidQAmanager.h"
51#include "AliHFEpidTPC.h"
52#include "AliHFEpidEMCAL.h"
53#include "AliHFEtools.h"
54#include "AliHFEemcalPIDqa.h"
8c1c76e9 55#include "AliTrackerBase.h"
c2690925 56
e156c3bb 57ClassImp(AliHFEemcalPIDqa)
c2690925 58
59//_________________________________________________________
60AliHFEemcalPIDqa::AliHFEemcalPIDqa():
61 AliHFEdetPIDqa()
62 , fHistos(NULL)
63{
64 //
65 // Dummy constructor
66 //
67}
68
69//_________________________________________________________
70AliHFEemcalPIDqa::AliHFEemcalPIDqa(const char* name):
71 AliHFEdetPIDqa(name, "QA for EMCAL")
72 , fHistos(NULL)
73{
74 //
75 // Default constructor
76 //
77}
78
79//_________________________________________________________
80AliHFEemcalPIDqa::AliHFEemcalPIDqa(const AliHFEemcalPIDqa &o):
81 AliHFEdetPIDqa(o)
82 , fHistos()
83{
84 //
85 // Copy constructor
86 //
87 o.Copy(*this);
88}
89
90//_________________________________________________________
91AliHFEemcalPIDqa &AliHFEemcalPIDqa::operator=(const AliHFEemcalPIDqa &o){
92 //
93 // Do assignment
94 //
95 AliHFEdetPIDqa::operator=(o);
96 if(&o != this) o.Copy(*this);
97 return *this;
98}
99
100//_________________________________________________________
101AliHFEemcalPIDqa::~AliHFEemcalPIDqa(){
102 //
103 // Destructor
104 //
105 if(fHistos) delete fHistos;
106}
107
108//_________________________________________________________
109void AliHFEemcalPIDqa::Copy(TObject &o) const {
110 //
111 // Make copy
112 //
113 AliHFEemcalPIDqa &target = dynamic_cast<AliHFEemcalPIDqa &>(o);
114 if(target.fHistos){
115 delete target.fHistos;
116 target.fHistos = NULL;
117 }
118 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
119}
120
121//_________________________________________________________
122Long64_t AliHFEemcalPIDqa::Merge(TCollection *coll){
123 //
124 // Merge with other objects
125 //
126 if(!coll) return 0;
127 if(coll->IsEmpty()) return 1;
128
129 TIter it(coll);
130 AliHFEemcalPIDqa *refQA = NULL;
131 TObject *o = NULL;
132 Long64_t count = 0;
133 TList listHistos;
134 while((o = it())){
135 refQA = dynamic_cast<AliHFEemcalPIDqa *>(o);
136 if(!refQA) continue;
137
138 listHistos.Add(refQA->fHistos);
139 count++;
140 }
141 fHistos->Merge(&listHistos);
142 return count + 1;
143}
144
145//_________________________________________________________
146void AliHFEemcalPIDqa::Initialize(){
147 //
148 // Define Histograms
149 //
150
151 fHistos = new AliHFEcollection("emcalqahistos", "Collection of EMCAL QA histograms");
152
153 // Make common binning
154 const Int_t kCentralityBins = 11;
155 const Double_t kMinP = 0.;
8c1c76e9 156 const Double_t kMaxP = 50.;
c2690925 157 const Double_t kTPCSigMim = 40.;
158 const Double_t kTPCSigMax = 140.;
159
c9f1d8ef 160 // 1st histogram: TPC dEdx with/without EMCAL (p, pT, TPC Signal, phi, eta, Sig, e/p, Centrality, select)
161 Int_t nBins[10] = {AliPID::kSPECIES + 1, 500, 500, 400, 630, 200, 400, 300, kCentralityBins, 2};
162 Double_t min[10] = {-1, kMinP, kMinP, kTPCSigMim, 0., -1.0, -4.0, 0, 0, 0.};
163 Double_t max[10] = {AliPID::kSPECIES, kMaxP, kMaxP, kTPCSigMax, 6.3, 1.0, 4.0, 3.0, 11., 2.};
164 fHistos->CreateTHnSparse("EMCAL_TPCdedx", "EMCAL signal; species; p [GeV/c]; pT [GeV/c] ; TPC signal [a.u.]; phi ; eta ; nSig ; E/p ; Centrality; PID Step; ", 10, nBins, min, max);
e156c3bb 165
8c1c76e9 166 //2nd histogram: EMCAL signal - E/p
167 Int_t nBins2[7] = {AliPID::kSPECIES + 1, 500, 500, 500, 125, 400, 2};
168 Double_t min2[7] = {-1, kMinP, kMinP, 0, 0, -4., 0.};
169 Double_t max2[7] = {AliPID::kSPECIES, kMaxP, kMaxP, 5, 0.5, 4., 2.};
170 fHistos->CreateTHnSparse("EMCAL_Signal", "EMCAL true signal; species; p [GeV/c]; pT [GeV/c] ; E/p; Rmatch; TPCnsigma; PID Step", 7, nBins2, min2, max2);
e156c3bb 171
c2690925 172}
173
e156c3bb 174
175
176
c2690925 177//_________________________________________________________
e156c3bb 178void AliHFEemcalPIDqa::ProcessTrack(const AliHFEpidObject *track,AliHFEdetPIDqa::EStep_t step){
c2690925 179 //
180 // Fill TPC histograms
181 //
182 //AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
183 Float_t centrality = track->GetCentrality();
184
e156c3bb 185 //const AliVTrack *vtrack = dynamic_cast<const AliVTrack *>(track->GetRecTrack());
186 //const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(vtrack);
6c70d827 187 const AliESDtrack *esdtrack = static_cast<const AliESDtrack *>(track->GetRecTrack());
c2690925 188
e156c3bb 189 Int_t species = track->GetAbInitioPID();
190 if(species >= AliPID::kSPECIES) species = -1;
191
8c1c76e9 192 // Get TPC nSigma (based on AliHFEtpcPIDqa)
193 AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
194 const AliPIDResponse *pidResponse = tpcpid ? tpcpid->GetPIDResponse() : NULL;
195 Float_t nSigmatpc = pidResponse ? pidResponse->NumberOfSigmasTPC(static_cast<const AliVTrack *>(track->GetRecTrack()), AliPID::kElectron) : 0.;
196 //printf("nSigmatpc = %f\n",nSigmatpc);
197 AliDebug(2, Form("nSigmatpc = %f\n",nSigmatpc));
198 //
199
c9f1d8ef 200
201
202 //printf("phi %f, eta %f\n;",phi,eta);
e156c3bb 203
8c1c76e9 204 // Get E/p
e156c3bb 205 TVector3 emcsignal = MomentumEnergyMatchV2(esdtrack);
206
8c1c76e9 207 Double_t contentSignal2[7];
e156c3bb 208 contentSignal2[0] = species;
209 contentSignal2[1] = track->GetRecTrack()->P();
210 contentSignal2[2] = track->GetRecTrack()->Pt();
8c1c76e9 211 contentSignal2[3] = emcsignal(0);//e over p
212 contentSignal2[4] = emcsignal(1);//residual
213 contentSignal2[5] = nSigmatpc;
c9f1d8ef 214 contentSignal2[6] = step == AliHFEdetPIDqa::kBeforePID ? 0. : 1.;
215
216 // QA array
217 Double_t contentSignal[10];
218 contentSignal[0] = species;
219 contentSignal[1] = track->GetRecTrack()->P();
220 contentSignal[2] = track->GetRecTrack()->Pt();
221 contentSignal[3] = esdtrack->GetTPCsignal(); //?
222 double phi = track->GetRecTrack()->Phi();
223 double eta = track->GetRecTrack()->Eta();
224 contentSignal[4] = phi;
225 contentSignal[5] = eta;
226 contentSignal[6] = nSigmatpc;
227 contentSignal[7] = emcsignal(0);
228 contentSignal[8] = centrality;
229 contentSignal[9] = step == AliHFEdetPIDqa::kBeforePID ? 0. : 1.;
230
e156c3bb 231
c2690925 232 //printf("ProcessTrack ; Print Content %g; %g; %g; %g \n",contentSignal[0],contentSignal[1],contentSignal[2],contentSignal[3]);
233 fHistos->Fill("EMCAL_TPCdedx", contentSignal);
e156c3bb 234 fHistos->Fill("EMCAL_Signal", contentSignal2);
c2690925 235}
236
237//_________________________________________________________
238TH1 *AliHFEemcalPIDqa::GetHistogram(const char *name){
239 //
240 // Get the histogram
241 //
242 if(!fHistos) return NULL;
243 TObject *histo = fHistos->Get(name);
244 if(!histo->InheritsFrom("TH1")) return NULL;
245 return dynamic_cast<TH1 *>(histo);
246}
247
e156c3bb 248
249//___________________________________________________________________________
250TVector3 AliHFEemcalPIDqa::MomentumEnergyMatchV2(const AliESDtrack *esdtrack) const
251{ // Returns e/p & Rmatch
252
253 Float_t clsPos[3];
254 Double_t trkPos[3];
255 Double_t matchclsE = 9999.9;
8c1c76e9 256 Double_t fMass=0.139;
257 Double_t fStep=10; //This is taken from EMCAL tender, hardcoded!
e156c3bb 258 TVector3 refVec(-9999,-9999,-9999);
259
0ecbfc1b 260 const AliESDEvent *evt = esdtrack->GetESDEvent();
e156c3bb 261
8c1c76e9 262 //Proper trackmatching, added by Tomas
263 //Get matched cluster
264 Int_t icl = esdtrack->GetEMCALcluster(); //From tender
265 AliVCluster *cluster = (AliVCluster*) evt->GetCaloCluster(icl);
266 if(!cluster->IsEMCAL()) return refVec;
267 cluster->GetPosition(clsPos);
268 TVector3 vec(clsPos[0],clsPos[1],clsPos[2]);//Vector of emcal cluster
269
270 //Extrapolate track to emcal, properly! First, get external params!
271 AliExternalTrackParam *trackParam = 0;
272 const AliESDfriendTrack* friendTrack = esdtrack->GetFriendTrack();
273 if(friendTrack && friendTrack->GetTPCOut())
274 {
275 //Use TPC Out as starting point if it is available
276 trackParam= const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut());
277 }
278 else
279 {
280 //Otherwise use TPC inner
281 trackParam = const_cast<AliExternalTrackParam*>(esdtrack->GetInnerParam());
282 }
283
284 Double_t alpha = ((int)(vec.Phi()*TMath::RadToDeg()/20)+0.5)*20*TMath::DegToRad();
285 vec.RotateZ(-alpha); //Rotate the cluster to the local extrapolation coordinate system
286 trackParam->Rotate(alpha); //Rotate the track to the same local extrapolation system
287
288 //Do extrapolation:
289 if(!AliTrackerBase::PropagateTrackToBxByBz(trackParam, vec.X(), fMass, fStep,kFALSE, 0.8, -1)) return refVec;
290 trackParam->GetXYZ(trkPos); //Get the extrapolated global position, done!
291
292
293
294 TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
295 TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
296
297
298 Double_t delEmcphi = clsPosVec.Phi()-trkPosVec.Phi(); // track cluster matching
299 Double_t delEmceta = clsPosVec.Eta()-trkPosVec.Eta(); // track cluster matching
300
301 double rmatch = sqrt(pow(delEmcphi,2)+pow(delEmceta,2));
302
303 matchclsE = cluster->E();
304
305 //double feop = -9999.9;
306 //if(matchclsE<9999)
307 double feop = matchclsE/esdtrack->P();
308
309 // if(feop!=-9999.9)printf("%f\n",feop) ;
310 TVector3 emcsignal(feop,rmatch,0);
311
312 return emcsignal;
313
e156c3bb 314}
315
316
317
318
319/*
320//___________________________________________________________________________
321TVector3 AliHFEemcalPIDqa::MomentumEnergyMatchV1(const AliESDtrack *esdtrack) const
322{ // Returns e/p & Rmatch
323
324 Float_t clsPos[3];
325 Double_t trkPos[3];
326 Double_t Rmatch;
327 Double_t matchclsE = 9999.9;
328 TVector3 refVec(-9999,-9999,-9999);
329
330 AliESDEvent *evt = esdtrack->GetESDEvent();
331 Double_t magF = evt->GetMagneticField();
332 Double_t magSign = 1.0;
333 if(magF<0)magSign = -1.0;
334 //printf("magF ; %g ; %g \n", magF,magSign);
335
336 if (!TGeoGlobalMagField::Instance()->GetField()) {
337 printf("Loading field map...\n");
338 //AliMagF* field = new AliMagF("Maps","Maps", 1., 1., AliMagF::k5kG);
339 AliMagF* field = new AliMagF("Maps","Maps", magSign, magSign, AliMagF::k5kG); // for 10d
340 TGeoGlobalMagField::Instance()->SetField(field);
341 }
342
343 AliEMCALTrack *emctrack = new AliEMCALTrack(*esdtrack);
344 Double_t fieldB[3];
345 emctrack->GetBxByBz(fieldB);
346 //printf("%g %g %g \n", fieldB[0], fieldB[1], fieldB[2]);
347
348 for(Int_t icl=0; icl<evt->GetNumberOfCaloClusters(); icl++)
349 {
350
351 AliVCluster *cluster = (AliVCluster*) evt->GetCaloCluster(icl);
352 if(!cluster->IsEMCAL()) return refVec;
353
354 cluster->GetPosition(clsPos);
355 if(!emctrack->PropagateToGlobal(clsPos[0],clsPos[1],clsPos[2],0.,0.) ) return refVec;
356 emctrack->GetXYZ(trkPos);
357
358 TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
359 TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
360
361 Double_t delEmcphi = clsPosVec.Phi()-trkPosVec.Phi(); // track cluster matching
362 Double_t delEmceta = clsPosVec.Eta()-trkPosVec.Eta(); // track cluster matching
363
364 double rmatch = sqrt(pow(delEmcphi,2)+pow(delEmceta,2));
365
366 if(rmatch<0.02)
367 {
368 matchclsE = cluster->E();
369 Rmatch = rmatch;
370 }
371 }
372 delete emctrack;
373
374 //double feop = -9999.9;
375 //if(matchclsE<9999)
376 double feop = matchclsE/esdtrack->P();
377
378 // if(feop!=-9999.9)printf("%f\n",feop) ;
379 TVector3 emcsignal(feop, Rmatch, 0);
380
381 return emcsignal;
382
383}
384*/
385