-
Notifications
You must be signed in to change notification settings - Fork 257
/
AliAnalysisTaskPIDqa.cxx
3444 lines (2806 loc) · 127 KB
/
AliAnalysisTaskPIDqa.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
/* $Id: AliAnalysisTaskPIDqa.cxx 43811 2010-09-23 14:13:31Z wiechula $ */
#include <TList.h>
#include <TVectorD.h>
#include <TObjArray.h>
#include <TH2.h>
#include <TFile.h>
#include <TPRegexp.h>
#include <TChain.h>
#include <TF1.h>
#include <TSpline.h>
#include <TProfile2D.h>
#include <TObjString.h>
#include <AliAnalysisManager.h>
#include <AliInputEventHandler.h>
#include <AliVEventHandler.h>
#include <AliVEvent.h>
#include <AliVParticle.h>
#include <AliVTrack.h>
#include <AliLog.h>
#include <AliPID.h>
#include <AliPIDResponse.h>
#include <AliITSPIDResponse.h>
#include <AliTPCPIDResponse.h>
#include <AliTRDPIDResponse.h>
#include <AliTOFPIDResponse.h>
#include <AliTPCdEdxInfo.h>
#include <AliESDEvent.h>
#include <AliAODEvent.h>
#include <AliESDv0.h>
#include <AliAODv0.h>
#include <AliMultSelectionBase.h>
#include <AliESDv0KineCuts.h>
#include <AliESDtrackCuts.h>
#include <AliMCEvent.h>
#include "AliAnalysisTaskPIDqa.h"
ClassImp(AliAnalysisTaskPIDqa)
/// \file AliAnalysisTaskPIDqa.cxx
AliAnalysisTaskPIDqa::AliAnalysisTaskPIDqa():
AliAnalysisTaskSE(),
fPIDResponse(0x0),
fV0cuts(0x0),
fV0electrons(0x0),
fV0pions(0x0),
fV0kaons(0x0),
fV0protons(0x0),
fListQA(0x0),
fListQAits(0x0),
fListQAitsSA(0x0),
fListQAitsPureSA(0x0),
fListQAtpc(0x0),
fListQAtpcBasic(0x0),
fListQAtpcMCtruth(0x0),
//fListQAtpcHybrid(0x0), // -> not used and commented for now
//fListQAtpcOROChigh(0x0), // -> not used and commented for now
fListQAtpcV0(0x0),
fListQAtrd(0x0),
fListQAtrdBasic(0x0),
fListQAtrdLikelihood(0x0),
fListQAtrdTruncatedMean(0x0),
fListQAtrdMCtruth(0x0),
fListQAtrdV0(0x0),
fListQAtrdBasicV0(0x0),
fListQAtrdLikelihoodV0(0x0),
fListQAtrdTruncatedMeanV0(0x0),
fListQAtof(0x0),
fListQAt0(0x0),
fListQAemcal(0x0),
fListQAhmpid(0x0),
fListQAtofhmpid(0x0),
fListQAtpctof(0x0),
fListQAV0(0x0),
fListQAinfo(0x0),
fTPChistogramOffsets(kMaxHistOffset)
{
//
// Dummy constructor
//
}
//______________________________________________________________________________
AliAnalysisTaskPIDqa::AliAnalysisTaskPIDqa(const char* name):
AliAnalysisTaskSE(name),
fPIDResponse(0x0),
fV0cuts(0x0),
fV0electrons(0x0),
fV0pions(0x0),
fV0kaons(0x0),
fV0protons(0x0),
fListQA(0x0),
fListQAits(0x0),
fListQAitsSA(0x0),
fListQAitsPureSA(0x0),
fListQAtpc(0x0),
fListQAtpcBasic(0x0),
fListQAtpcMCtruth(0x0),
//fListQAtpcHybrid(0x0), // -> not used and commented for now
//fListQAtpcOROChigh(0x0), // -> not used and commented for now
fListQAtpcV0(0x0),
fListQAtrd(0x0),
fListQAtrdBasic(0x0),
fListQAtrdLikelihood(0x0),
fListQAtrdTruncatedMean(0x0),
fListQAtrdMCtruth(0x0),
fListQAtrdV0(0x0),
fListQAtrdBasicV0(0x0),
fListQAtrdLikelihoodV0(0x0),
fListQAtrdTruncatedMeanV0(0x0),
fListQAtof(0x0),
fListQAt0(0x0),
fListQAemcal(0x0),
fListQAhmpid(0x0),
fListQAtofhmpid(0x0),
fListQAtpctof(0x0),
fListQAV0(0x0),
fListQAinfo(0x0),
fTPChistogramOffsets(kMaxHistOffset)
{
/// Default constructor
DefineInput(0,TChain::Class());
DefineOutput(1,TList::Class());
}
//______________________________________________________________________________
AliAnalysisTaskPIDqa::~AliAnalysisTaskPIDqa()
{
/// Destructor
delete fV0cuts;
delete fV0electrons;
delete fV0pions;
delete fV0kaons;
delete fV0protons;
if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fListQA;
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::UserCreateOutputObjects()
{
/// Create the output QA objects
AliLog::SetClassDebugLevel("AliAnalysisTaskPIDqa",10);
//input hander
AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
if (!inputHandler) AliFatal("Input handler needed");
//pid response object
fPIDResponse=inputHandler->GetPIDResponse();
if (!fPIDResponse) AliError("PIDResponse object was not created");
// V0 Kine cuts
fV0cuts = new AliESDv0KineCuts;
// V0 PID Obj arrays
fV0electrons = new TObjArray;
fV0pions = new TObjArray;
fV0kaons = new TObjArray;
fV0protons = new TObjArray;
//
fListQA=new TList;
fListQA->SetOwner();
fListQAits=new TList;
fListQAits->SetOwner();
fListQAits->SetName("ITS");
fListQAitsSA=new TList;
fListQAitsSA->SetOwner();
fListQAitsSA->SetName("ITS_SA");
fListQAitsPureSA=new TList;
fListQAitsPureSA->SetOwner();
fListQAitsPureSA->SetName("ITS_PureSA");
fListQAtpc=new TList;
fListQAtpc->SetOwner();
fListQAtpc->SetName("TPC");
fListQAtrd=new TList;
fListQAtrd->SetOwner();
fListQAtrd->SetName("TRD");
fListQAtof=new TList;
fListQAtof->SetOwner();
fListQAtof->SetName("TOF");
fListQAt0=new TList;
fListQAt0->SetOwner();
fListQAt0->SetName("T0");
fListQAemcal=new TList;
fListQAemcal->SetOwner();
fListQAemcal->SetName("EMCAL");
fListQAhmpid=new TList;
fListQAhmpid->SetOwner();
fListQAhmpid->SetName("HMPID");
fListQAtpctof=new TList;
fListQAtpctof->SetOwner();
fListQAtpctof->SetName("TPC_TOF");
fListQAtofhmpid=new TList;
fListQAtofhmpid->SetOwner();
fListQAtofhmpid->SetName("TOF_HMPID");
fListQAV0=new TList;
fListQAV0->SetOwner();
fListQAV0->SetName("V0decay");
fListQAinfo=new TList;
fListQAinfo->SetOwner();
fListQAinfo->SetName("QAinfo");
fListQA->Add(fListQAits);
fListQA->Add(fListQAitsSA);
fListQA->Add(fListQAitsPureSA);
fListQA->Add(fListQAtpc);
fListQA->Add(fListQAtrd);
fListQA->Add(fListQAtof);
fListQA->Add(fListQAt0);
fListQA->Add(fListQAemcal);
fListQA->Add(fListQAhmpid);
fListQA->Add(fListQAtpctof);
fListQA->Add(fListQAtofhmpid);
fListQA->Add(fListQAV0);
fListQA->Add(fListQAinfo);
SetupITSqa();
// SetupTPCqa(kFALSE, kTRUE, kFALSE); // is called in first call of FillTPCqa
// SetupTRDqa(); // is called in FillTRDqa
SetupTOFqa();
SetupT0qa();
SetupEMCALqa();
SetupHMPIDqa();
SetupTPCTOFqa();
SetupTOFHMPIDqa();
SetupV0qa();
SetupQAinfo();
PostData(1,fListQA);
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::UserExec(Option_t */*option*/)
{
/// Setup the PID response functions and fill the QA histograms
AliVEvent *event=InputEvent();
if (!event||!fPIDResponse) return;
// Start with the V0 task (only possible for ESDs?)
FillV0PIDlist();
FillITSqa();
FillTPCqa();
FillTRDqa();
FillTOFqa();
FillEMCALqa();
FillHMPIDqa();
FillT0qa();
//combined detector QA
FillTPCTOFqa();
FillTOFHMPIDqa();
// Clear the V0 PID arrays
ClearV0PIDlist();
//QA info
FillQAinfo();
PostData(1,fListQA);
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::FillV0PIDlist(){
/// Fill the PID object arrays holding the pointers to identified particle tracks
// Dynamic cast to ESD events (DO NOTHING for AOD events)
AliESDEvent *event = dynamic_cast<AliESDEvent *>(InputEvent());
if ( !event ) return;
if(TString(event->GetBeamType())=="Pb-Pb" || TString(event->GetBeamType())=="A-A"){
fV0cuts->SetMode(AliESDv0KineCuts::kPurity,AliESDv0KineCuts::kPbPb);
}
else{
fV0cuts->SetMode(AliESDv0KineCuts::kPurity,AliESDv0KineCuts::kPP);
}
// V0 selection
// set event
fV0cuts->SetEvent(event);
// loop over V0 particles
for(Int_t iv0=0; iv0<event->GetNumberOfV0s();iv0++){
AliESDv0 *v0 = (AliESDv0 *) event->GetV0(iv0);
if(!v0) continue;
if(v0->GetOnFlyStatus()) continue;
// Get the particle selection
Bool_t foundV0 = kFALSE;
Int_t pdgV0, pdgP, pdgN;
foundV0 = fV0cuts->ProcessV0(v0, pdgV0, pdgP, pdgN);
if(!foundV0) continue;
Int_t iTrackP = v0->GetPindex(); // positive track
Int_t iTrackN = v0->GetNindex(); // negative track
// v0 Armenteros plot (QA)
Float_t armVar[2] = {0.0,0.0};
fV0cuts->Armenteros(v0, armVar);
TH2 *h=(TH2*)fListQAV0->At(0);
if (!h) continue;
h->Fill(armVar[0],armVar[1]);
// fill the Object arrays
// positive particles
if( pdgP == -11){
fV0electrons->Add((AliVTrack*)event->GetTrack(iTrackP));
}
else if( pdgP == 211){
fV0pions->Add((AliVTrack*)event->GetTrack(iTrackP));
}
else if( pdgP == 321){
fV0kaons->Add((AliVTrack*)event->GetTrack(iTrackP));
}
else if( pdgP == 2212){
fV0protons->Add((AliVTrack*)event->GetTrack(iTrackP));
}
// negative particles
if( pdgN == 11){
fV0electrons->Add((AliVTrack*)event->GetTrack(iTrackN));
}
else if( pdgN == -211){
fV0pions->Add((AliVTrack*)event->GetTrack(iTrackN));
}
else if( pdgN == -321){
fV0kaons->Add((AliVTrack*)event->GetTrack(iTrackN));
}
else if( pdgN == -2212){
fV0protons->Add((AliVTrack*)event->GetTrack(iTrackN));
}
}
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::ClearV0PIDlist(){
/// Clear the PID object arrays
fV0electrons->Clear();
fV0pions->Clear();
fV0kaons->Clear();
fV0protons->Clear();
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::FillITSqa()
{
/// Fill PID qa histograms for the ITS
AliVEvent *event=InputEvent();
Int_t ntracks=event->GetNumberOfTracks();
for(Int_t itrack = 0; itrack < ntracks; itrack++){
AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
ULong64_t status=track->GetStatus();
// not that nice. status bits not in virtual interface
// ITS refit + ITS pid selection
if (!( ( (status & AliVTrack::kITSrefit)==AliVTrack::kITSrefit ) ||
! ( (status & AliVTrack::kITSpid )==AliVTrack::kITSpid ) )) continue;
Double_t mom=track->P();
TList *theList = 0x0;
if(( (status & AliVTrack::kTPCin)==AliVTrack::kTPCin )){
//ITS+TPC tracks
theList=fListQAits;
}else{
if(!( (status & AliVTrack::kITSpureSA)==AliVTrack::kITSpureSA )){
//ITS Standalone tracks
theList=fListQAitsSA;
}else{
//ITS Pure Standalone tracks
theList=fListQAitsPureSA;
}
}
for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
TH2 *h=(TH2*)theList->At(ispecie);
if (!h) continue;
Double_t nSigma=fPIDResponse->NumberOfSigmasITS(track, (AliPID::EParticleType)ispecie);
h->Fill(mom,nSigma);
}
TH2 *h=(TH2*)theList->At(AliPID::kSPECIESC);
if (h) {
Double_t sig=track->GetITSsignal();
h->Fill(mom,sig);
}
}
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::FillTPCHistogramsSignal(TList *sublist, Int_t scenario, AliVTrack *track, Int_t mult)
{
/// Fill PID qa histograms for the TPC: Fill the histograms for the TPC signal for different settings
// List of possible scenarios with the numbering scheme (for information only):
// scenario == 0 : Basic
// scenario == 1 : MCtruth
// scenario == 2 : Hybrid (only for LHC11h) -> not used and commented now
// scenario == 3 : OROChigh (only for LHC11h) -> not used and commented now
// scenario == 40 : V0 - Electrons
// scenario == 41 : V0 - Muons (not implemented)
// scenario == 42 : V0 - Pions
// scenario == 43 : V0 - Kaons (not filled)
// scenario == 44 : V0 - Protons
AliMCEvent *eventMC=MCEvent(); // MC event for MC truth PID
const Double_t mom=track->GetTPCmomentum(); // track momentum
const Double_t eta=track->Eta(); // track eta
const Double_t phi=track->Phi(); // track phi
const Double_t sigStd=fPIDResponse->GetTPCResponse().GetTrackdEdx(track); // TPC dE/dx signal (standard = all ROCs)
Double_t sigIROC=0.; // TPC dE/dx signal (IROC)
Double_t sigOROCmedium=0.; // TPC dE/dx signal (OROCmedium)
Double_t sigOROClong=0.; // TPC dE/dx signal (OROClong)
Double_t eleLineDist=0.; // difference between TPC signal and electron expectation
Int_t trackLabel=0; // label of the AliVTrack to identify the corresponding MCtrack
Int_t pdgCode=0; // pdgcode of MC track for MC truth scenario
Int_t pdgCodeAbs=0; // absolute value of pdgcode to get both particles and antiparticles
Int_t iSigMax=1; // number of TPC signals (std = 1, set automatically higher if available)
Int_t nSpecies=0; // number of particle species under study (can be changed, e.g. in case of V0s)
Int_t count=0; // counter for the number of plot sets for all species (i.e. nsigma vs. p, eta and mult)
Int_t count2=0; // counter of extra nsigma plots (only for some scenarios)
Int_t count3=0; // counter of extra nsigma vs. p plots (only V0 scenario)
Int_t count4=0; // yet another counter for the V0 scenario
const Int_t pidInTracking = track->GetPIDForTracking(); // PID used during tracking
Double_t sig=0.; // TPC dE/dx signal
eleLineDist=sigStd-fPIDResponse->GetTPCResponse().GetExpectedSignal(track,AliPID::kElectron);
// Get number of particle species (less for V0 candidates = scenarios 40-44)
if (scenario > 39) nSpecies=(Int_t)AliPID::kSPECIES;
else nSpecies=(Int_t)AliPID::kSPECIESC;
// nSpecies is changed in case of V0, due to Muons and Kaons not being filled
if (scenario>39) nSpecies=nSpecies-2;
// Set number of plot sets for all species
// (i.e. only nsigma vs. p => count=1; also vs. eta and mult => count=3)
if ( scenario == 1 || scenario > 39 ) count=3; // MCtruth (scenario==1) and V0 (scenario>39)
else count=1;
// Set number of extra nsigma plots (only for some scenarios)
// (i.e. nsigma vs. eta and mult separately for MIPpions and for electrons)
// if ( scenario == 0 || scenario == 2 || scenario == 3 ) count2=4; // Basic, Hybrid, OROClong
if ( scenario == 0 ) count2=4; // Basic
else count2=0;
Int_t pid = scenario-40;
// Get MC track ( --> can be deleted if TPC signal is NOT filled for scenario=1 (MC truth)
if (eventMC) {
trackLabel=TMath::Abs(track->GetLabel());
AliVTrack *mcTrack=(AliVTrack*)eventMC->GetTrack(trackLabel);
pdgCode=mcTrack->PdgCode();
pdgCodeAbs=TMath::Abs(pdgCode);
// make pid for MC
pid=-1;
for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie) {
if (pdgCodeAbs == AliPID::ParticleCode(ispecie)) {
pid=ispecie;
break;
}
}
if (pid == -1) return;
}
// Get TPC dE/dx info and different TPC signals (IROC, OROCmedium, OROClong)
AliTPCdEdxInfo fTPCdEdxInfo;
if ( track->GetTPCdEdxInfo( fTPCdEdxInfo ) ) {
sigIROC=fTPCdEdxInfo.GetTPCsignalShortPad();
sigOROCmedium=fTPCdEdxInfo.GetTPCsignalMediumPad();
sigOROClong=fTPCdEdxInfo.GetTPCsignalLongPad();
iSigMax=4;
//printf("mom = %.3f sigStd = %.3f sigIROC = %.3f sigOROCmedium = %.3f sigOROClong = %.3f \n",mom,sigStd,sigIROC,sigOROCmedium,sigOROClong);
}
// ===| This part is not for MC |=============================================
//
if (scenario!=1) {
// TPC signal vs. momentum (for different particle species (V0s) or all particles (other scenarios))
if (scenario > 39) {
// TPC signal for different particle species vs. momentum (standard, IROC, OROCmedium, OROClong)
count3=8;
if (scenario == 40) count4=0;
else if (scenario == 42) count4=4;
else if (scenario == 44) count4=8;
TH2 *h1std=(TH2*)sublist->At(count*nSpecies+count2+count4);
if (h1std) {
h1std->Fill(mom,sigStd);
}
TH2 *h1iroc=(TH2*)sublist->At(count*nSpecies+count2+count4+1);
if ( h1iroc && sigIROC ) {
h1iroc->Fill(mom,sigIROC);
}
TH2 *h1orocm=(TH2*)sublist->At(count*nSpecies+count2+count4+2);
if (h1orocm && sigOROCmedium ) {
h1orocm->Fill(mom,sigOROCmedium);
}
TH2 *h1orocl=(TH2*)sublist->At(count*nSpecies+count2+count4+3);
if ( h1orocl && sigOROClong ) {
h1orocl->Fill(mom,sigOROClong);
}
}
else {
// TPC signal for all particles vs. momentum (standard, IROC, OROCmedium, OROClong)
TH2 *h1std=(TH2*)sublist->At(count*nSpecies+count2);
if (h1std) {
h1std->Fill(mom,sigStd);
}
TH2 *h1iroc=(TH2*)sublist->At(count*nSpecies+count2+1);
if ( h1iroc && sigIROC ) {
h1iroc->Fill(mom,sigIROC);
}
TH2 *h1orocm=(TH2*)sublist->At(count*nSpecies+count2+2);
if (h1orocm && sigOROCmedium ) {
h1orocm->Fill(mom,sigOROCmedium);
}
TH2 *h1orocl=(TH2*)sublist->At(count*nSpecies+count2+3);
if ( h1orocl && sigOROClong ) {
h1orocl->Fill(mom,sigOROClong);
}
}
// - Beginn: MIP pions: TPC signal vs. eta, phi and mult -
if (mom>0.45 && mom<0.5 && sigStd>40 && sigStd<60) {
if (scenario < 40 || scenario == 42) { // if scenario is "V0" then only take pions
Bool_t isPionMC=kTRUE;
if (scenario == 1) {
if ( pdgCodeAbs != 211 && pdgCodeAbs != 111 ) isPionMC=kFALSE;
}
// MIP pions: TPC signal vs. eta (standard, IROC, OROCmedium, OROClong)
for (Int_t iSig=0; iSig<iSigMax; iSig++) {
if (iSig==0) sig=sigStd;
else if (iSig==1) sig=sigIROC;
else if (iSig==2) sig=sigOROCmedium;
else if (iSig==3) sig=sigOROClong;
TH2 *h2=(TH2*)sublist->At(count*nSpecies+count2+count3+4+iSig);
if ( h2 && isPionMC ) {
h2->Fill(eta,sig);
}
}
// MIP pions: TPC signal vs. phi (standard, IROC, OROCmedium, OROClong)
for (Int_t iSig=0; iSig<iSigMax; iSig++) {
if (iSig==0) sig=sigStd;
else if (iSig==1) sig=sigIROC;
else if (iSig==2) sig=sigOROCmedium;
else if (iSig==3) sig=sigOROClong;
TH2 *h2=(TH2*)sublist->At(count*nSpecies+count2+count3+8+iSig);
if ( h2 && isPionMC ) {
h2->Fill(phi,sig);
}
}
// MIP pions: TPC signal vs. mult (standard, IROC, OROCmedium, OROClong)
for (Int_t iSig=0; iSig<iSigMax; iSig++) {
if (iSig==0) sig=sigStd;
else if (iSig==1) sig=sigIROC;
else if (iSig==2) sig=sigOROCmedium;
else if (iSig==3) sig=sigOROClong;
TH2 *h3=(TH2*)sublist->At(count*nSpecies+count2+count3+12+iSig);
if ( h3 && isPionMC && mult > 0 ) {
h3->Fill(mult,sig);
}
}
}
} // - End: MIP pions -
} // - End: not for MC
// - Beginn: Electrons: TPC signal vs. eta, phi and mult -
if (mom>0.32 && mom<0.38 && eleLineDist>-10. && eleLineDist<15.) {
if (scenario < 40 || scenario == 40) { // if scenario is "V0" then only take electrons
Bool_t isElectronMC=kTRUE;
if (scenario == 1) {
if ( pdgCodeAbs != 11 ) isElectronMC=kFALSE;
}
// Electrons: TPC signal vs. eta (standard, IROC, OROCmedium, OROClong)
for (Int_t iSig=0; iSig<iSigMax; iSig++) {
if (iSig==0) sig=sigStd;
else if (iSig==1) sig=sigIROC;
else if (iSig==2) sig=sigOROCmedium;
else if (iSig==3) sig=sigOROClong;
TH2 *h4=(TH2*)sublist->At(count*nSpecies+count2+count3+16+iSig);
if ( h4 && isElectronMC ) {
h4->Fill(eta,sig);
}
}
// Electrons: TPC signal vs. phi (standard, IROC, OROCmedium, OROClong)
for (Int_t iSig=0; iSig<iSigMax; iSig++) {
if (iSig==0) sig=sigStd;
else if (iSig==1) sig=sigIROC;
else if (iSig==2) sig=sigOROCmedium;
else if (iSig==3) sig=sigOROClong;
TH2 *h4=(TH2*)sublist->At(count*nSpecies+count2+count3+20+iSig);
if ( h4 && isElectronMC ) {
h4->Fill(phi,sig);
}
}
// Electrons: TPC signal vs. mult (standard, IROC, OROCmedium, OROClong)
for (Int_t iSig=0; iSig<iSigMax; iSig++) {
if (iSig==0) sig=sigStd;
else if (iSig==1) sig=sigIROC;
else if (iSig==2) sig=sigOROCmedium;
else if (iSig==3) sig=sigOROClong;
TH2 *h5=(TH2*)sublist->At(count*nSpecies+count2+count3+24+iSig);
if ( h5 && isElectronMC && mult > 0 ) {
h5->Fill(mult,sig);
}
}
}
} // - End: Electrons -
// ===| PID in tracking |=====================================================
{
Int_t offsetType=scenario;
if (scenario>39) offsetType=Int_t(kTrackPIDV0);
// const Int_t offsetPIDtracking=(scenario!=1)?count*nSpecies+count2+count3+24+iSigMax:27;
const Int_t offsetPIDtracking=fTPChistogramOffsets[offsetType];
TH2 *hDummy = (TH2*)sublist->At(offsetPIDtracking);
// printf("PID in tracking: %s (%s)\n", sublist->GetName(), hDummy->GetName());
// ---| V0 + MCcase |-------------------------------------------------------
if (scenario>39 || scenario==1) {
Int_t ispecie = pid;
if (scenario>39){
// Muon and Kaon not implemented for V0
if (pid==AliPID::kPion ) ispecie=1;
else if (pid==AliPID::kProton) ispecie=2;
}
// printf(" MC/V0 PID %d:%d (%d)\n", pid, pidInTracking, ispecie);
TH2 *hCorrectPIDtracking = (TH2*)sublist->At(offsetPIDtracking + 2*ispecie);
TH2 *hWrongPIDtracking = (TH2*)sublist->At(offsetPIDtracking + 2*ispecie + 1);
if (hCorrectPIDtracking && hWrongPIDtracking){
if (pidInTracking == pid) {
hCorrectPIDtracking->Fill(mom, sigStd);
}
else {
hWrongPIDtracking->Fill(mom, sigStd);
}
}
}
// ---| Basic case |--------------------------------------------------------
else {
// printf(" PID %d\n", pidInTracking);
TProfile2D *hPIDtracking = (TProfile2D*)sublist->At(offsetPIDtracking);
hPIDtracking->Fill(mom, sigStd, Double_t(pidInTracking+1));
TH2 *hPIDtrackingTrackedAs = (TH2*)sublist->At(offsetPIDtracking + 1 + pidInTracking);
hPIDtrackingTrackedAs->Fill(mom, sigStd);
}
}
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::FillTPCHistogramsNsigma(TList *sublist, Int_t scenario, AliVTrack *track, Int_t mult)
{
/// Fill PID qa histograms for the TPC: Fill the histograms for TPC Nsigma for different settings
// List of possible scenarios with the numbering scheme (for information only):
// scenario == 0 : Basic
// scenario == 1 : MCtruth
// scenario == 2 : Hybrid (only for LHC11h) -> not used and commented now
// scenario == 3 : OROChigh (only for LHC11h) -> not used and commented now
// scenario == 40 : V0 - Electrons
// scenario == 41 : V0 - Muons (not implemented)
// scenario == 42 : V0 - Pions
// scenario == 43 : V0 - Kaons (not filled)
// scenario == 44 : V0 - Protons
AliMCEvent *eventMC=MCEvent(); // MC event for MC truth PID
Double_t mom=0.; // track momentum
Double_t eta=0.; // track eta
Double_t nSigma=0.; // number of sigmas wrt. expected signal
Double_t sig=0.; // TPC dE/dx signal
Double_t eleLineDist=0.; // difference between TPC signal and electron expectation
Int_t trackLabel=0; // label of the AliVTrack to identify the corresponding MCtrack
Int_t pdgCode=0; // pdgcode of MC track for MC truth scenario
Int_t pdgCodeAbs=0; // absolute value of pdgcode to get both particles and antiparticles
Int_t nSpecies=0; // number of particle species under study (can be changed, e.g. in case of V0s)
Int_t numberSpecies=0; // number of particle species under study (stays constant for one scenario)
Int_t mvSpecie=0; // "move Specie", needed for V0s, as Muons and Kaons are not filled
Int_t count=0; // counter for the number of plot sets for all species (i.e. vs. p, eta and mult)
mom=track->GetTPCmomentum();
eta=track->Eta();
// sig=track->GetTPCsignal();
sig=fPIDResponse->GetTPCResponse().GetTrackdEdx(track);
eleLineDist=sig-fPIDResponse->GetTPCResponse().GetExpectedSignal(track,AliPID::kElectron);
// Get number of particle species (less for V0 candidates = scenarios 40-44)
if (scenario > 39) nSpecies=(Int_t)AliPID::kSPECIES;
else nSpecies=(Int_t)AliPID::kSPECIESC;
// numberSpecies always keeps the value obtained by AliPID::kSPECIES(C)
numberSpecies=nSpecies;
// nSpecies is changed in case of V0, due to Muons and Kaons not being filled
if (scenario>39) nSpecies=nSpecies-2;
// Set number of plot sets for all species
// (i.e. only vs. p => count=1; also vs. eta and mult => count=3)
if ( scenario == 1 || scenario > 39 ) count=3; // MCtruth (scenario==1) and V0 (scenario>39)
else count=1;
// Get MC track
if (eventMC) {
trackLabel=TMath::Abs(track->GetLabel());
AliVTrack *mcTrack=(AliVTrack*)eventMC->GetTrack(trackLabel);
if(mcTrack)
pdgCode=mcTrack->PdgCode();
//
pdgCodeAbs=TMath::Abs(pdgCode);
}
// - Beginn: Nsigma vs. p, vs. eta and vs. multiplicity for different particle species -
for (Int_t ispecie=0; ispecie<numberSpecies; ++ispecie){
if (scenario == 1) {
if ( ispecie == 0 && pdgCodeAbs != 11 ) continue; // Electron
if ( ispecie == 1 && pdgCodeAbs != 13 ) continue; // Muon
if ( ispecie == 2 && pdgCodeAbs != 211 && pdgCodeAbs!=111 ) continue; // Pion
if ( ispecie == 3 && pdgCodeAbs != 321 && pdgCodeAbs!=311 ) continue; // Kaon
if ( ispecie == 4 && pdgCodeAbs != 2212 ) continue; // Proton
if ( ispecie == 5 && pdgCodeAbs != 1000010020 ) continue; // Deuteron
if ( ispecie == 6 && pdgCodeAbs != 1000010030 ) continue; // Triton
if ( ispecie == 7 && pdgCodeAbs != 1000020030 ) continue; // Helium-3
if ( ispecie == 8 && pdgCodeAbs != 1000020040 ) continue; // Alpha
}
else if (scenario == 40) {
if ( ispecie != 0 ) continue; // Electron
}
else if (scenario == 41) continue; // Muon (not filled)
else if (scenario == 42) {
if ( ispecie != 2 ) continue; // Pion
}
else if (scenario == 43) continue; // Kaon (not filled)
else if (scenario == 44) {
if ( ispecie != 4 ) continue; // Proton
}
/* // special LHC11h setting not used and commented now
if (scenario == 2) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie, AliTPCPIDResponse::kdEdxHybrid);
}
else if (scenario == 3) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie, AliTPCPIDResponse::kdEdxOROC);
}
*/
// else {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie);
// }
mvSpecie=0; // Reset, in case it has been changed before
// For the V0 scenario, it is necessary to close the gaps due to Muons and Kaons not being filled.
// Electrons stay at position "0".
if (scenario>39) {
if (ispecie == 2) mvSpecie=1; // Pions are moved from position "2" -> "1".
else if (ispecie == 4) mvSpecie=2; // Protons are moved from position "4" -> "2".
}
TH2 *h=(TH2*)sublist->At(ispecie-mvSpecie);
if ( h ) h->Fill(mom,nSigma);
if (count == 3) {
TH2 *hEta=(TH2*)sublist->At(ispecie-mvSpecie+nSpecies);
TH2 *hMult=(TH2*)sublist->At(ispecie-mvSpecie+2*nSpecies);
if ( hEta ) hEta->Fill(eta,nSigma);
if ( hMult && mult > 0 ) hMult->Fill(mult,nSigma);
}
} // - End: different particle species -
// -- Beginn: Fill histograms for MIP pions and electrons (only for some scenarios) --
if ( scenario == 0 || scenario == 2 || scenario == 3 ) {
// - Beginn: MIP pions: Nsigma vs. eta, Nsigma vs. mult -
if (mom>0.45 && mom<0.5 && sig>40 && sig<60) {
Bool_t isPionMC=kTRUE;
TH2 *h1=(TH2*)sublist->At(count*nSpecies);
if (h1) {
if (scenario == 1) {
if ( pdgCodeAbs != 211 && pdgCodeAbs != 111 ) isPionMC=kFALSE;
if (isPionMC) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion);
}
}
/* // special LHC11h setting not used and commented now
else if (scenario == 2) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion, AliTPCPIDResponse::kdEdxHybrid);
}
else if (scenario == 3) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion, AliTPCPIDResponse::kdEdxOROC);
}
*/
else nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion);
if (isPionMC) h1->Fill(eta,nSigma);
}
TH2 *h2m=(TH2*)sublist->At(count*nSpecies+1);
if ( h2m && isPionMC && mult > 0 ) {
h2m->Fill(mult,nSigma);
}
} // - End: MIP pions -
// - Beginn: Electrons: Nsigma vs. eta, Nsigma vs. mult -
if (mom>0.32 && mom<0.38 && eleLineDist>-10. && eleLineDist<15.) {
Bool_t isElectronMC=kTRUE;
TH2 *h3=(TH2*)sublist->At(count*nSpecies+2);
if (h3) {
if (scenario == 1) {
if ( pdgCodeAbs != 11 ) isElectronMC=kFALSE;
if (isElectronMC) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
}
}
/* // special LHC11h setting not used and commented now
if (scenario == 2) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron, AliTPCPIDResponse::kdEdxHybrid);
}
else if (scenario == 3) {
nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron, AliTPCPIDResponse::kdEdxOROC);
}
*/
else nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
if (isElectronMC) h3->Fill(eta,nSigma);
}
TH2 *h4m=(TH2*)sublist->At(count*nSpecies+3);
if ( h4m && isElectronMC && mult > 0 ) {
h4m->Fill(mult,nSigma);
}
} // - End: Electrons -
} // -- End: Fill histograms for MIP pions and electrons --
}
//______________________________________________________________________________
void AliAnalysisTaskPIDqa::FillTPCqa()
{
/// Fill PID qa histograms for the TPC
// switches for the different scenarios
Bool_t scBasic=1; // default/basic
Bool_t scMCtruth=1; // for MC truth tracks
Bool_t scHybrid=0; // for hybrid PID (only LHC11h) -> not used and commented now
Bool_t scOROChigh=0; // only OROC signal (only LHC11h) -> not used and commented now
Bool_t scV0=1; // for V0 candidates (only for ESDs available)
Int_t scCounter=0; // counter of scenarios, used for the histograms at the end of FillTPCqa
// input handler
AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
if (!inputHandler) AliFatal("Input handler needed");
AliVEvent *event=InputEvent();
// ESD or AOD event needed to get reference multiplicity (not in AliVEvent)
AliAODEvent *fAODevent = 0x0; // AOD event
AliESDEvent *fESDevent = 0x0; // ESD event
AliESDtrackCuts *esdTrackCuts = 0x0; // ESD track Cuts (ref mult is in AliESDtrackCuts)
Double_t eta=0.; // track eta
Int_t mult=0; // event multiplicity (TPConlyRefMult)
//Int_t nacc=0; // counter for accepted multiplicity
// Check for MC
scMCtruth=(MCEvent()!=0x0);
/* // special LHC11h setting not used and commented now
// Check if period is data LHC11h by checking if
// the splines for ALLhigh have been set by AliPIDResponse
AliTPCPIDResponse &tpcResp=fPIDResponse->GetTPCResponse();
if (tpcResp.GetResponseFunction(AliPID::kPion, AliTPCPIDResponse::kALLhigh)==0x0) {
scHybrid = kFALSE;
scOROChigh = kFALSE;
}
*/
// Check if "ESD" or "AOD" and get the corresponding event and the beam type (or centrality)
TString analysisType = inputHandler->GetDataType(); // can be "ESD" or "AOD"
if (analysisType == "ESD") {
fESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
esdTrackCuts = new AliESDtrackCuts("esdTrackCuts");
//printf("\n--- New event - event type = ESD \n");
}
else if (analysisType == "AOD") {
fAODevent = dynamic_cast<AliAODEvent*>( InputEvent() );
//printf("\n--- New event - event type = AOD \n");
// disable V0 scenario, because V0s are not available for AODs in this current implementation
scV0=0;
}
// Check if Basic list is already created
// If not: Go to SetupTPCqa and creat lists and histograms
if(!fListQAtpcBasic) {
//printf("\n--- No list QA TPC Basic found -> go to SetupTPCqa! ---\n");
SetupTPCqa(scMCtruth, scHybrid, scV0);
}
// Get the number of scenarios by counting those, which are switched on
if (scBasic) scCounter++;
if (scMCtruth) scCounter++;
// if (scHybrid) scCounter++;
// if (scOROChigh) scCounter++;
if (scV0) scCounter++;
// Get reference multiplicity for ESDs
if ( analysisType == "ESD" && esdTrackCuts ) {
mult=esdTrackCuts->GetReferenceMultiplicity(fESDevent,kTRUE);
}