AliPhysics  a6017e1 (a6017e1)
AliAnalysisTaskClusterQA.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Authors: Nicolas Schmidt *
5  * Version 1.0 *
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 
17 //---------------------------------------------
18 // Class used to create a tree for QA of clusters
19 //---------------------------------------------
21 
23 #include "TChain.h"
24 #include "TRandom.h"
25 #include "AliAnalysisManager.h"
26 #include "TParticle.h"
27 #include "TVectorF.h"
28 #include "AliPIDResponse.h"
29 #include "TFile.h"
30 #include "AliESDtrackCuts.h"
31 #include "AliAODMCParticle.h"
32 #include "AliAODMCHeader.h"
33 #include "AliAODEvent.h"
34 #include "AliMultSelection.h"
35 
36 class iostream;
37 
38 using namespace std;
39 
41 
42 //________________________________________________________________________
44  fV0Reader(NULL),
45  fV0ReaderName("V0ReaderV1"),
46  fCorrTaskSetting(""),
47  fConversionCuts(NULL),
48  fEventCuts(NULL),
49  fClusterCutsEMC(NULL),
50  fClusterCutsDMC(NULL),
51  fMesonCuts(NULL),
52  fMinNLMCut(1),
53  fMaxNLMCut(1),
54  fInputEvent(NULL),
55  fMCEvent(NULL),
56  fWeightJetJetMC(1),
57  fGeomEMCAL(NULL),
58  fClusterTree(NULL),
59  fIsHeavyIon(kFALSE),
60  ffillTree(-100),
61  ffillHistograms(kFALSE),
62  fOutputList(NULL),
63  fIsMC(kFALSE),
64  fCorrectForNonlinearity(kFALSE),
65  fSaveEventProperties(0),
66  fSaveCells(0),
67  fSaveSurroundingCells(0),
68  fSaveTracks(0),
69  fConeRadius(0),
70  fMinTrackPt(0),
71  fMinClusterEnergy(0),
72  fSaveMCInformation(0),
73  fSaveAdditionalHistos(0),
74  fExtractionPercentages(),
75  fExtractionPercentagePtBins(),
76  fBuffer_EventID(0),
77  fBuffer_ClusterE(0),
78  fBuffer_ClusterPhi(0),
79  fBuffer_ClusterEta(0),
80  fBuffer_ClusterIsEMCAL(kFALSE),
81  fBuffer_MC_Cluster_Flag(0),
82  fBuffer_ClusterNumCells(0),
83  fBuffer_LeadingCell_ID(0),
84  fBuffer_LeadingCell_E(0),
85  fBuffer_LeadingCell_Eta(0),
86  fBuffer_LeadingCell_Phi(0),
87  fBuffer_ClusterM02(0),
88  fBuffer_ClusterM20(0),
89  fBuffer_Event_Vertex_X(0),
90  fBuffer_Event_Vertex_Y(0),
91  fBuffer_Event_Vertex_Z(0),
92  fBuffer_Event_Multiplicity(0),
93  fBuffer_Event_NumActiveCells(0),
94  fBuffer_Cells_ID(0),
95  fBuffer_Cells_E(0),
96  fBuffer_Cells_RelativeEta(0),
97  fBuffer_Cells_RelativePhi(0),
98  fBuffer_Surrounding_NCells(0),
99  fBuffer_Surrounding_Cells_ID(0),
100  fBuffer_Surrounding_Cells_R(0),
101  fBuffer_Surrounding_Cells_E(0),
102  fBuffer_Surrounding_Cells_RelativeEta(0),
103  fBuffer_Surrounding_Cells_RelativePhi(0),
104  fBuffer_Surrounding_NTracks(10),
105  fBuffer_Surrounding_Tracks_R(0),
106  fBuffer_Surrounding_Tracks_Pt(0),
107  fBuffer_Surrounding_Tracks_RelativeEta(0),
108  fBuffer_Surrounding_Tracks_RelativePhi(0),
109  fBuffer_Cluster_MC_Label(-10),
110  hNCellsInClustersVsCentrality(NULL),
111  hNActiveCellsVsCentrality(NULL),
112  hNActiveCellsAbove50MeVVsCentrality(NULL),
113  hNActiveCellsAbove80MeVVsCentrality(NULL),
114  hNActiveCellsAbove100MeVVsCentrality(NULL),
115  hNActiveCellsAbove150MeVVsCentrality(NULL),
116  hECellsInClustersVsCentrality(NULL),
117  hEActiveCellsVsCentrality(NULL),
118  hEActiveCells50MeVVsCentrality(NULL),
119  hEActiveCells80MeVVsCentrality(NULL),
120  hEActiveCells100MeVVsCentrality(NULL),
121  hEActiveCells150MeVVsCentrality(NULL)
122 {
123  fBuffer_Cells_ID = new Int_t[kMaxActiveCells];
124  fBuffer_Cells_E = new Float_t[kMaxActiveCells];
125  fBuffer_Cells_RelativeEta = new Float_t[kMaxActiveCells];
126  fBuffer_Cells_RelativePhi = new Float_t[kMaxActiveCells];
127  fBuffer_Surrounding_Cells_ID = new Int_t[kMaxActiveCells];
128  fBuffer_Surrounding_Cells_R = new Float_t[kMaxActiveCells];
129  fBuffer_Surrounding_Cells_E = new Float_t[kMaxActiveCells];
130  fBuffer_Surrounding_Cells_RelativeEta = new Float_t[kMaxActiveCells];
131  fBuffer_Surrounding_Cells_RelativePhi = new Float_t[kMaxActiveCells];
132  fBuffer_Surrounding_Tracks_R = new Float_t[kMaxNTracks];
133  fBuffer_Surrounding_Tracks_Pt = new Float_t[kMaxNTracks];
134  fBuffer_Surrounding_Tracks_RelativeEta= new Float_t[kMaxNTracks];
135  fBuffer_Surrounding_Tracks_RelativePhi= new Float_t[kMaxNTracks];
136 }
137 
139  fV0Reader(NULL),
140  fV0ReaderName("V0ReaderV1"),
141  fCorrTaskSetting(""),
142  fConversionCuts(NULL),
143  fEventCuts(NULL),
144  fClusterCutsEMC(NULL),
145  fClusterCutsDMC(NULL),
146  fMesonCuts(NULL),
147  fMinNLMCut(1),
148  fMaxNLMCut(1),
149  fInputEvent(NULL),
150  fMCEvent(NULL),
151  fWeightJetJetMC(1),
152  fGeomEMCAL(NULL),
153  fClusterTree(NULL),
154  fIsHeavyIon(kFALSE),
155  ffillTree(-100),
156  ffillHistograms(kFALSE),
157  fOutputList(NULL),
158  fIsMC(kFALSE),
159  fCorrectForNonlinearity(kFALSE),
160  fSaveEventProperties(0),
161  fSaveCells(0),
162  fSaveSurroundingCells(0),
163  fSaveTracks(0),
164  fConeRadius(0),
165  fMinTrackPt(0),
166  fMinClusterEnergy(0),
167  fSaveMCInformation(0),
168  fSaveAdditionalHistos(0),
169  fExtractionPercentages(),
170  fExtractionPercentagePtBins(),
171  fBuffer_EventID(0),
172  fBuffer_ClusterE(0),
173  fBuffer_ClusterPhi(0),
174  fBuffer_ClusterEta(0),
175  fBuffer_ClusterIsEMCAL(kFALSE),
176  fBuffer_MC_Cluster_Flag(0),
177  fBuffer_ClusterNumCells(0),
178  fBuffer_LeadingCell_ID(0),
179  fBuffer_LeadingCell_E(0),
180  fBuffer_LeadingCell_Eta(0),
181  fBuffer_LeadingCell_Phi(0),
182  fBuffer_ClusterM02(0),
183  fBuffer_ClusterM20(0),
184  fBuffer_Event_Vertex_X(0),
185  fBuffer_Event_Vertex_Y(0),
186  fBuffer_Event_Vertex_Z(0),
187  fBuffer_Event_Multiplicity(0),
188  fBuffer_Event_NumActiveCells(0),
189  fBuffer_Cells_ID(0),
190  fBuffer_Cells_E(0),
191  fBuffer_Cells_RelativeEta(0),
192  fBuffer_Cells_RelativePhi(0),
193  fBuffer_Surrounding_NCells(0),
194  fBuffer_Surrounding_Cells_ID(0),
195  fBuffer_Surrounding_Cells_R(0),
196  fBuffer_Surrounding_Cells_E(0),
197  fBuffer_Surrounding_Cells_RelativeEta(0),
198  fBuffer_Surrounding_Cells_RelativePhi(0),
199  fBuffer_Surrounding_NTracks(10),
200  fBuffer_Surrounding_Tracks_R(0),
201  fBuffer_Surrounding_Tracks_Pt(0),
202  fBuffer_Surrounding_Tracks_RelativeEta(0),
203  fBuffer_Surrounding_Tracks_RelativePhi(0),
204  fBuffer_Cluster_MC_Label(-10),
205  hNCellsInClustersVsCentrality(NULL),
206  hNActiveCellsVsCentrality(NULL),
207  hNActiveCellsAbove50MeVVsCentrality(NULL),
208  hNActiveCellsAbove80MeVVsCentrality(NULL),
209  hNActiveCellsAbove100MeVVsCentrality(NULL),
210  hNActiveCellsAbove150MeVVsCentrality(NULL),
211  hECellsInClustersVsCentrality(NULL),
212  hEActiveCellsVsCentrality(NULL),
213  hEActiveCells50MeVVsCentrality(NULL),
214  hEActiveCells80MeVVsCentrality(NULL),
215  hEActiveCells100MeVVsCentrality(NULL),
216  hEActiveCells150MeVVsCentrality(NULL)
217 {
231  // Default constructor
232 
233  DefineInput(0, TChain::Class());
234  DefineOutput(1, TList::Class());
235  DefineOutput(2, TTree::Class());
236 }
237 
238 //________________________________________________________________________
240 {
241  // default deconstructor
242 
243 }
244 //________________________________________________________________________
246 {
247  // Create User Output Objects
248 
249  if(fOutputList != NULL){
250  delete fOutputList;
251  fOutputList = NULL;
252  }
253  if(fOutputList == NULL){
254  fOutputList = new TList();
255  fOutputList->SetOwner(kTRUE);
256  }
257 
258  if(ffillHistograms){
259 
260  if(((AliConvEventCuts*)fEventCuts)->GetCutHistograms()){
261  fOutputList->Add(((AliConvEventCuts*)fEventCuts)->GetCutHistograms());
262  }
263 
264  if(((AliCaloPhotonCuts*)fClusterCutsEMC)->GetCutHistograms()){
265  fOutputList->Add(((AliCaloPhotonCuts*)fClusterCutsEMC)->GetCutHistograms());
266  }
267  if(((AliCaloPhotonCuts*)fClusterCutsDMC)->GetCutHistograms()){
268  fOutputList->Add(((AliCaloPhotonCuts*)fClusterCutsDMC)->GetCutHistograms());
269  }
270  if(((AliConversionMesonCuts*)fMesonCuts)->GetCutHistograms()){
271  fOutputList->Add(((AliConversionMesonCuts*)fMesonCuts)->GetCutHistograms());
272  }
274  hNCellsInClustersVsCentrality = new TH2F("NCellsInClusters_Centrality","NCellsInClusters_Centrality",18000, 0, 18000, 100, 0, 100);
276  hNActiveCellsVsCentrality = new TH2F("NActiveCells_Centrality","NActiveCells_Centrality",18000, 0, 18000, 100, 0, 100);
278  hNActiveCellsAbove50MeVVsCentrality = new TH2F("NActiveCells50MeV_Centrality","NActiveCells50MeV_Centrality",18000, 0, 18000, 100, 0, 100);
280  hNActiveCellsAbove80MeVVsCentrality = new TH2F("NActiveCells80MeV_Centrality","NActiveCells80MeV_Centrality",18000, 0, 18000, 100, 0, 100);
282  hNActiveCellsAbove100MeVVsCentrality = new TH2F("NActiveCells100MeV_Centrality","NActiveCells100MeV_Centrality",18000, 0, 18000, 100, 0, 100);
284  hNActiveCellsAbove150MeVVsCentrality = new TH2F("NActiveCells150MeV_Centrality","NActiveCells150MeV_Centrality",18000, 0, 18000, 100, 0, 100);
286 
287  hECellsInClustersVsCentrality = new TH2F("EofCellsInClusters_Centrality","EofCellsInClusters_Centrality",2000, 0, 20, 100, 0, 100);
289  hEActiveCellsVsCentrality = new TH2F("EofActiveCells_Centrality","EofActiveCells_Centrality",2000, 0, 20, 100, 0, 100);
291  hEActiveCells50MeVVsCentrality = new TH2F("EofActiveCells50MeV_Centrality","EofActiveCells50MeV_Centrality",2000, 0, 20, 100, 0, 100);
293  hEActiveCells80MeVVsCentrality = new TH2F("EofActiveCells80MeV_Centrality","EofActiveCells80MeV_Centrality",2000, 0, 20, 100, 0, 100);
295  hEActiveCells100MeVVsCentrality = new TH2F("EofActiveCells100MeV_Centrality","EofActiveCells100MeV_Centrality",2000, 0, 20, 100, 0, 100);
297  hEActiveCells150MeVVsCentrality = new TH2F("EofActiveCells150MeV_Centrality","EofActiveCells150MeV_Centrality",2000, 0, 20, 100, 0, 100);
299  }
300  PostData(1, fOutputList);
301  }
302 
303  fClusterTree = new TTree(Form("ClusterQA_%s_%s_%s",(fEventCuts->GetCutNumber()).Data(),(fClusterCutsEMC->GetCutNumber()).Data(),(fClusterCutsDMC->GetCutNumber()).Data()),Form("ClusterQA_%s_%s_%s",(fEventCuts->GetCutNumber()).Data(),(fClusterCutsEMC->GetCutNumber()).Data(),(fClusterCutsDMC->GetCutNumber()).Data()));
304 
305  fClusterTree->Branch("Cluster_E", &fBuffer_ClusterE, "Cluster_E/F");
306  fClusterTree->Branch("Cluster_Eta", &fBuffer_ClusterEta, "Cluster_Eta/F");
307  fClusterTree->Branch("Cluster_Phi", &fBuffer_ClusterPhi, "Cluster_Phi/F");
308  fClusterTree->Branch("Cluster_IsEMCAL", &fBuffer_ClusterIsEMCAL, "Cluster_IsEMCAL/O");
309  fClusterTree->Branch("Cluster_NumCells", &fBuffer_ClusterNumCells, "Cluster_NumCells/I");
310  fClusterTree->Branch("Cluster_LeadingCell_ID", &fBuffer_LeadingCell_ID, "Cluster_LeadingCell_ID/I");
311  fClusterTree->Branch("Cluster_LeadingCell_E", &fBuffer_LeadingCell_E, "Cluster_LeadingCell_E/F");
312  fClusterTree->Branch("Cluster_LeadingCell_Eta", &fBuffer_LeadingCell_Eta, "Cluster_LeadingCell_Eta/F");
313  fClusterTree->Branch("Cluster_LeadingCell_Phi", &fBuffer_LeadingCell_Phi, "Cluster_LeadingCell_Phi/F");
314  fClusterTree->Branch("Cluster_M02", &fBuffer_ClusterM02, "Cluster_M02/F");
315  fClusterTree->Branch("Cluster_M20", &fBuffer_ClusterM20, "Cluster_M20/F");
317  {
318  fClusterTree->Branch("Event_ID", &fBuffer_EventID, "Event_ID/l");
319  fClusterTree->Branch("Event_Vertex_X", &fBuffer_Event_Vertex_X, "Event_Vertex_X/F");
320  fClusterTree->Branch("Event_Vertex_Y", &fBuffer_Event_Vertex_Y, "Event_Vertex_Y/F");
321  fClusterTree->Branch("Event_Vertex_Z", &fBuffer_Event_Vertex_Z, "Event_Vertex_Z/F");
322  fClusterTree->Branch("Event_Multiplicity", &fBuffer_Event_Multiplicity, "Event_Multiplicity/F");
323  fClusterTree->Branch("Event_NumActiveCells", &fBuffer_Event_NumActiveCells, "Event_NumActiveCells/I");
324  }
325 
326  if(fSaveCells)
327  {
328  fClusterTree->Branch("Cluster_Cells_ID", fBuffer_Cells_ID, "Cluster_Cells_ID[Cluster_NumCells]/I");
329  fClusterTree->Branch("Cluster_Cells_E", fBuffer_Cells_E, "Cluster_Cells_E[Cluster_NumCells]/F");
330  fClusterTree->Branch("Cluster_Cells_RelativeEta", fBuffer_Cells_RelativeEta, "Cluster_Cells_RelativeEta[Cluster_NumCells]/F");
331  fClusterTree->Branch("Cluster_Cells_RelativePhi", fBuffer_Cells_RelativePhi, "Cluster_Cells_RelativePhi[Cluster_NumCells]/F");
332  }
333 
335  {
336  fClusterTree->Branch("Surrounding_NCells", &fBuffer_Surrounding_NCells, "Surrounding_NCells/I");
337  fClusterTree->Branch("Surrounding_Cells_ID", fBuffer_Surrounding_Cells_ID, "Surrounding_Cells_ID[Surrounding_NCells]/I");
338  fClusterTree->Branch("Surrounding_Cells_R", fBuffer_Surrounding_Cells_R, "Surrounding_Cells_R[Surrounding_NCells]/F");
339  fClusterTree->Branch("Surrounding_Cells_E", fBuffer_Surrounding_Cells_E, "Surrounding_Cells_E[Surrounding_NCells]/F");
340  fClusterTree->Branch("Surrounding_Cells_RelativeEta", fBuffer_Surrounding_Cells_RelativeEta, "Surrounding_Cells_RelativeEta[Surrounding_NCells]/F");
341  fClusterTree->Branch("Surrounding_Cells_RelativePhi", fBuffer_Surrounding_Cells_RelativePhi, "Surrounding_Cells_RelativePhi[Surrounding_NCells]/F");
342  }
343  if(fSaveTracks)
344  {
345  fClusterTree->Branch("Surrounding_NTracks", &fBuffer_Surrounding_NTracks, "Surrounding_NTracks/I");
346  fClusterTree->Branch("Surrounding_Tracks_R", fBuffer_Surrounding_Tracks_R, "Surrounding_Tracks_R[Surrounding_NTracks]/F");
347  fClusterTree->Branch("Surrounding_Tracks_Pt", fBuffer_Surrounding_Tracks_Pt, "Surrounding_Tracks_Pt[Surrounding_NTracks]/F");
348  fClusterTree->Branch("Surrounding_Tracks_RelativeEta", fBuffer_Surrounding_Tracks_RelativeEta, "Surrounding_Tracks_RelativeEta[Surrounding_NTracks]/F");
349  fClusterTree->Branch("Surrounding_Tracks_RelativePhi", fBuffer_Surrounding_Tracks_RelativePhi, "Surrounding_Tracks_RelativePhi[Surrounding_NTracks]/F");
350  }
351 
353  {
354  fClusterTree->Branch("Cluster_MC_Label", &fBuffer_Cluster_MC_Label, "Cluster_MC_Label/I");
355  }
356 
357  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
358  OpenFile(2);
359  PostData(2, fClusterTree);
360 }
361 //_____________________________________________________________________________
363 {
368  }
369 
370  return kTRUE;
371 }
372 //________________________________________________________________________
374 
375  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
376  if(eventQuality != 0){// Event Not Accepted
377  return;
378  }
379  fInputEvent = InputEvent();
380  if(fIsMC) fMCEvent = MCEvent();
381 
383  if(eventNotAccepted) return; // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
384 
385  fGeomEMCAL = AliEMCALGeometry::GetInstance();
386  if(!fGeomEMCAL){ AliFatal("EMCal geometry not initialized!");}
387 
388  Int_t nclus = 0;
389  TClonesArray * arrClustersProcess = NULL;
390  // fNCurrentClusterBasic = 0;
391  if(!fCorrTaskSetting.CompareTo("")){
392  nclus = fInputEvent->GetNumberOfCaloClusters();
393  } else {
394  arrClustersProcess = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
395  if(!arrClustersProcess)
396  AliFatal(Form("%sClustersBranch was not found in AliAnalysisTaskGammaCalo! Check the correction framework settings!",fCorrTaskSetting.Data()));
397  nclus = arrClustersProcess->GetEntries();
398  }
399 
400  if(nclus == 0) return;
401 
402  ((AliCaloPhotonCuts*)fClusterCutsEMC)->FillHistogramsExtendedQA(fInputEvent,fIsMC);
403  // ((AliCaloPhotonCuts*)fClusterCutsDMC)->FillHistogramsExtendedQA(fInputEvent,fIsMC);
404 
405  // match tracks to clusters
406  ((AliCaloPhotonCuts*)fClusterCutsEMC)->MatchTracksToClusters(fInputEvent,fWeightJetJetMC,kTRUE, fMCEvent);
407  // ((AliCaloPhotonCuts*)fClusterCutsDMC)->MatchTracksToClusters(fInputEvent,fWeightJetJetMC,kTRUE, fMCEvent);
408 
409  AliVCaloCells* cells = fInputEvent->GetEMCALCells();
410  Double_t centrality = 0;
412  centrality = GetCentrality(fInputEvent);
413 
414  Int_t numberOfActiveCells50MeV =0;
415  Int_t numberOfActiveCells80MeV =0;
416  Int_t numberOfActiveCells100MeV =0;
417  Int_t numberOfActiveCells150MeV =0;
418  for(Int_t aCell=0;aCell<cells->GetNumberOfCells();aCell++){
419  // Define necessary variables
420  Short_t cellNumber = 0;
421  Double_t cellAmplitude = 0, cellTime = 0, cellEFrac = 0;
422  Int_t cellMCLabel = 0;
423  // Get Cell ID
424  cells->GetCell(aCell,cellNumber,cellAmplitude,cellTime,cellMCLabel,cellEFrac);
425  Double_t cellEnergy = cells->GetCellAmplitude(cellNumber);
426  hEActiveCellsVsCentrality->Fill(cellEnergy,centrality);
427  if(cellEnergy >0.050 ){
428  numberOfActiveCells50MeV++;
429  hEActiveCells50MeVVsCentrality->Fill(cellEnergy,centrality);
430  }
431  if(cellEnergy >0.080 ){
432  numberOfActiveCells80MeV++;
433  hEActiveCells80MeVVsCentrality->Fill(cellEnergy,centrality);
434  }
435  if(cellEnergy >0.100 ){
436  numberOfActiveCells100MeV++;
437  hEActiveCells100MeVVsCentrality->Fill(cellEnergy,centrality);
438  }
439  if(cellEnergy >0.150 ){
440  numberOfActiveCells150MeV++;
441  hEActiveCells150MeVVsCentrality->Fill(cellEnergy,centrality);
442  }
443  }
444  hNActiveCellsVsCentrality->Fill(cells->GetNumberOfCells(),centrality);
445  hNActiveCellsAbove50MeVVsCentrality->Fill(numberOfActiveCells50MeV,centrality);
446  hNActiveCellsAbove80MeVVsCentrality->Fill(numberOfActiveCells80MeV,centrality);
447  hNActiveCellsAbove100MeVVsCentrality->Fill(numberOfActiveCells100MeV,centrality);
448  hNActiveCellsAbove150MeVVsCentrality->Fill(numberOfActiveCells150MeV,centrality);
449  }
450 
451  // vertex
452  Double_t vertex[3] = {0};
453  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
454 
455  map<Long_t,Int_t> mapIsClusterAccepted;
456  map<Long_t,Int_t> mapIsClusterAcceptedWithoutTrackMatch;
457  Int_t nCellInCluster = 0;
458  // Loop over EMCal clusters
459  for(Long_t i = 0; i < nclus; i++){
460  Double_t tempClusterWeight = fWeightJetJetMC;
461  AliVCluster* clus = NULL;
462  if(fInputEvent->IsA()==AliESDEvent::Class()){
463  if(arrClustersProcess)
464  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(i));
465  else
466  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
467  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
468  if(arrClustersProcess)
469  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i));
470  else
471  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
472  }
473  if(!clus) continue;
474 
475 
476  if ( !clus->IsEMCAL()){ // for PHOS: cluster->GetType() == AliVCluster::kPHOSNeutral
477  delete clus;
478  continue;
479  }
481  nCellInCluster+=clus->GetNCells();
482  for(Int_t iCell=0;iCell<clus->GetNCells();iCell++){
483  hECellsInClustersVsCentrality->Fill(cells->GetCellAmplitude(clus->GetCellAbsId(iCell)),centrality);
484  }
485  }
486 
487  if ( clus->E() < fMinClusterEnergy){
488  delete clus;
489  continue;
490  }
491 
492  if(!((AliCaloPhotonCuts*)fClusterCutsEMC)->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC, tempClusterWeight,i) && !((AliCaloPhotonCuts*)fClusterCutsDMC)->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC, tempClusterWeight,i)){
493  delete clus;
494  continue;
495  }
497  }
499  hNCellsInClustersVsCentrality->Fill(nCellInCluster,centrality);
500 
501  PostData(1, fOutputList);
502 }
503 
505 void AliAnalysisTaskClusterQA::ProcessQATreeCluster(AliVEvent *event, AliVCluster* cluster, Long_t indexCluster){
506 
507  Float_t clusPos[3] = { 0,0,0 };
508  cluster->GetPosition(clusPos);
509  TVector3 clusterVector(clusPos[0],clusPos[1],clusPos[2]);
510  Double_t etaCluster = clusterVector.Eta();
511  Double_t phiCluster = clusterVector.Phi();
512  if (phiCluster < 0) phiCluster += 2*TMath::Pi();
513 
515  // Vertex position x, y, z
516  fBuffer_Event_Vertex_X = fInputEvent->GetPrimaryVertex()->GetX();
517  fBuffer_Event_Vertex_Y = fInputEvent->GetPrimaryVertex()->GetY();
518  fBuffer_Event_Vertex_Z = fInputEvent->GetPrimaryVertex()->GetZ();
519 
520  // Unique event ID of the current cluster
521  // AliESDEvent* esdEvent = dynamic_cast<AliESDEvent*>(event);
522  fBuffer_EventID = 0;
523  // if(esdEvent->GetHeader()){
524  // fBuffer_EventID = GetUniqueEventID(esdEvent->GetHeader());
525  // printf("event id: %lld\n",fBuffer_EventID);
526  // }
527 
528  // V0-based multiplicity of the event
529  fBuffer_Event_Multiplicity = fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C();
530  }
531 
532  // Properties of the current cluster
533  fBuffer_ClusterE = cluster->E();
534 
535  if(etaCluster < 0.67 && etaCluster > -0.67){
536  if(phiCluster < 3.2 && phiCluster > 1.4){
537  fBuffer_ClusterIsEMCAL = kTRUE;
538  }
539  }
540  if(etaCluster < 0.67 && etaCluster > -0.67){
541  if(etaCluster > 0.23 || etaCluster < -0.23){
542  if(phiCluster < 5.6 && phiCluster > 4.6){
543  fBuffer_ClusterIsEMCAL = kFALSE;
544  }
545  }
546  }
547 
548  fBuffer_ClusterPhi = phiCluster;
549  fBuffer_ClusterEta = etaCluster;
550  fBuffer_ClusterM02 = cluster->GetM02();
551  fBuffer_ClusterM20 = cluster->GetM20();
552 
553  // Get all cells from the event
554  AliVCaloCells* cells = NULL;
555  if(cluster->IsEMCAL())
556  cells = event->GetEMCALCells();
557  else
558  return;
559 
560  // Determine all active cells in the event
562  fBuffer_Event_NumActiveCells = cells->GetNumberOfCells();
563 
564  // Get the number of cells from the current cluster
565  Int_t nCellCluster = cluster->GetNCells();
566  fBuffer_ClusterNumCells = nCellCluster;
567 
568  // Find the leading cell in the cluster and its position
570  fBuffer_LeadingCell_E = cells->GetCellAmplitude(fBuffer_LeadingCell_ID);
571  Float_t leadcelleta = 0.;
572  Float_t leadcellphi = 0.;
573  fGeomEMCAL->EtaPhiFromIndex(fBuffer_LeadingCell_ID, leadcelleta, leadcellphi);
574  if ( leadcellphi < 0 ) leadcellphi+=TMath::TwoPi();
575  fBuffer_LeadingCell_Eta = leadcelleta;
576  fBuffer_LeadingCell_Phi = leadcellphi;
577  // Treat the remaining cells of the cluster and get their relative position compared to the leading cell
578  if(fSaveCells){
579  for(Int_t iCell=0;iCell<nCellCluster;iCell++){
580  if(iCell<100){ // maximum number of cells for a cluster is set to 100
581  fBuffer_Cells_ID[iCell] = cluster->GetCellAbsId(iCell);
582  fBuffer_Cells_E[iCell] = cells->GetCellAmplitude(cluster->GetCellAbsId(iCell));
583  Float_t celleta = 0.;
584  Float_t cellphi = 0.;
585  fGeomEMCAL->EtaPhiFromIndex(fBuffer_Cells_ID[iCell], celleta, cellphi);
586  if ( cellphi < 0 ) cellphi+=TMath::TwoPi();
587  fBuffer_Cells_RelativeEta[iCell] = leadcelleta-celleta;
588  fBuffer_Cells_RelativePhi[iCell] = leadcellphi-cellphi;
589  }
590  }
591  }
593  Int_t nActiveCellsSurroundingInR = 0;
594  // fill surrounding cell buffer
595  for(Int_t aCell=0;aCell<cells->GetNumberOfCells();aCell++){
596  // Define necessary variables
597  Short_t cellNumber = 0;
598  Double_t cellAmplitude = 0, cellTime = 0, cellEFrac = 0;
599  Int_t cellMCLabel = 0;
600  Float_t surrcelleta = 0.;
601  Float_t surrcellphi = 0.;
602  // Get Cell ID
603  cells->GetCell(aCell,cellNumber,cellAmplitude,cellTime,cellMCLabel,cellEFrac);
604 
605  // Get eta and phi for the surounding cells
606  fGeomEMCAL->EtaPhiFromIndex(cellNumber, surrcelleta, surrcellphi);
607  if ( surrcellphi < 0 ) surrcellphi+=TMath::TwoPi();
608  Double_t dR2 = pow(leadcelleta-surrcelleta,2) + pow(leadcellphi-surrcellphi,2);
609  // Select those cells that are within fConeRadius of the leading cluster cell
610  if( dR2 < fConeRadius){
611  fBuffer_Surrounding_Cells_E[aCell] = cells->GetCellAmplitude(cellNumber);
612  fBuffer_Surrounding_Cells_ID[aCell] = cellNumber;
613  fBuffer_Surrounding_Cells_R[aCell] = dR2;
614  fBuffer_Surrounding_Cells_RelativeEta[aCell] = leadcelleta-surrcelleta;
615  fBuffer_Surrounding_Cells_RelativePhi[aCell] = leadcellphi-surrcellphi;
616  nActiveCellsSurroundingInR+=1;
617  }
618  }
619  fBuffer_Surrounding_NCells = nActiveCellsSurroundingInR;
620  }
621  if(fIsMC) fBuffer_Cluster_MC_Label = MakePhotonCandidates(cluster, cells,indexCluster);
622  if(fSaveTracks) ProcessTracksAndMatching(cluster,indexCluster);
623  // Add everything to the tree
624  if (fClusterTree) fClusterTree->Fill();
625 }
626 
627 //________________________________________________________________________
629 
630 }
631 
632 //________________________________________________________________________
633 Int_t AliAnalysisTaskClusterQA::FindLargestCellInCluster(AliVCluster* cluster, AliVEvent* event){
634 
635  const Int_t nCells = cluster->GetNCells();
636  AliVCaloCells* cells = NULL;
637 
638  if(cluster->IsEMCAL())
639  cells = event->GetEMCALCells();
640  else if(cluster->IsPHOS())
641  cells = event->GetPHOSCells();
642 
643  Float_t eMax = 0.;
644  Int_t idMax = -1;
645 
646  if (nCells < 1) return idMax;
647  for (Int_t iCell = 0;iCell < nCells;iCell++){
648  Int_t cellAbsID = cluster->GetCellsAbsId()[iCell];
649  if (cells->GetCellAmplitude(cellAbsID)> eMax){
650  eMax = cells->GetCellAmplitude(cellAbsID);
651  idMax = cellAbsID;
652  }
653  }
654  return idMax;
655 }
656 
657 //________________________________________________________________________
659  Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0;
660  row=0;
661  column=0;
662  // Get SM number and relative row/column for SM
663  fGeomEMCAL->GetCellIndex(cellIndex, nSupMod,nModule,nIphi,nIeta);
664  fGeomEMCAL->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, row,column);
665  row += nSupMod/2 * 24;
666  column += nSupMod%2 * 48;
667 }
668 
669 //________________________________________________________________________
670 Int_t AliAnalysisTaskClusterQA::MakePhotonCandidates(AliVCluster* clus, AliVCaloCells* cells, Long_t indexCluster){
671 
672  Double_t vertex[3] = {0};
673  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
674 
675  TLorentzVector clusterVector;
676  clus->GetMomentum(clusterVector,vertex);
677 
678  TLorentzVector* tmpvec = new TLorentzVector();
679  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
680 
681  // convert to AODConversionPhoton
682  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
683  if(!PhotonCandidate){
684  delete clus;
685  delete tmpvec;
686  if (PhotonCandidate) delete PhotonCandidate;
687  return -9;
688  }
689  // Flag Photon as CaloPhoton
690  PhotonCandidate->SetIsCaloPhoton();
691  PhotonCandidate->SetCaloClusterRef(indexCluster);
692 
693  // get MC label
694  if(fIsMC> 0){
695  Int_t* mclabelsCluster = clus->GetLabels();
696  Int_t nValidClusters = 0;
697  if (clus->GetNLabels()>0){
698  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
699  if (mclabelsCluster[k]>0){
700  if (nValidClusters< 50)PhotonCandidate->SetCaloPhotonMCLabel(nValidClusters,mclabelsCluster[k]);
701  nValidClusters++;
702  }
703  }
704  }
705  PhotonCandidate->SetNCaloPhotonMCLabels(nValidClusters);
706  }
707 
708  AliAODCaloCluster* clusSub1 = new AliAODCaloCluster();
709  AliAODCaloCluster* clusSub2 = new AliAODCaloCluster();
710 
711 
712  // split clusters according to their shares in the cluster (NLM == 1) needs to be treated differently
713  if (fMinNLMCut == 1 && fMaxNLMCut == 1 ){
714  Int_t absCellIdFirst = ((AliCaloPhotonCuts*)fClusterCutsEMC)->FindLargestCellInCluster(clus, fInputEvent);
715  Int_t absCellIdSecond = ((AliCaloPhotonCuts*)fClusterCutsEMC)->FindSecondLargestCellInCluster(clus, fInputEvent);
716 
717  ((AliCaloPhotonCuts*)fClusterCutsEMC)->SplitEnergy(absCellIdFirst, absCellIdSecond, clus, fInputEvent, fIsMC, clusSub1, clusSub2);
718  } else if (fMinNLMCut > 1 ){
719  const Int_t nc = clus->GetNCells();
720  Int_t absCellIdList[nc];
721 
722  ((AliCaloPhotonCuts*)fClusterCutsEMC)->SplitEnergy(absCellIdList[0], absCellIdList[1], clus, fInputEvent, fIsMC, clusSub1, clusSub2);
723  }
724 
725  // TLorentzvector with sub cluster 1
726  TLorentzVector clusterVector1;
727  clusSub1->GetMomentum(clusterVector1,vertex);
728  TLorentzVector* tmpvec1 = new TLorentzVector();
729  tmpvec1->SetPxPyPzE(clusterVector1.Px(),clusterVector1.Py(),clusterVector1.Pz(),clusterVector1.E());
730  // convert to AODConversionPhoton
731  AliAODConversionPhoton *PhotonCandidate1=new AliAODConversionPhoton(tmpvec1);
732  if(!PhotonCandidate1){
733  delete clusSub1;
734  delete tmpvec1;
735  return -9;
736  }
737  // Flag Photon as CaloPhoton
738  PhotonCandidate1->SetIsCaloPhoton();
739  // TLorentzvector with sub cluster 2
740  TLorentzVector clusterVector2;
741  clusSub2->GetMomentum(clusterVector2,vertex);
742  TLorentzVector* tmpvec2 = new TLorentzVector();
743  tmpvec2->SetPxPyPzE(clusterVector2.Px(),clusterVector2.Py(),clusterVector2.Pz(),clusterVector2.E());
744  // convert to AODConversionPhoton
745  AliAODConversionPhoton *PhotonCandidate2=new AliAODConversionPhoton(tmpvec2);
746  if(!PhotonCandidate2){
747  delete clusSub2;
748  delete tmpvec2;
749  return -9;
750  }
751  // Flag Photon as CaloPhoton
752  PhotonCandidate2->SetIsCaloPhoton();
753  Int_t mclabel = -3;
754  // create pi0 candidate
755  AliAODConversionMother *pi0cand = new AliAODConversionMother(PhotonCandidate1,PhotonCandidate2);
756  if((((AliConversionMesonCuts*)fMesonCuts)->MesonIsSelected(pi0cand,kTRUE,fEventCuts->GetEtaShift()))){
757  if(fIsMC> 0 && PhotonCandidate && PhotonCandidate1 && PhotonCandidate2 && fSaveMCInformation){
758  // if(fInputEvent->IsA()==AliESDEvent::Class())
759  mclabel = ProcessTrueClusterCandidates(PhotonCandidate, clus->GetM02(), PhotonCandidate1, PhotonCandidate2);
760  // if(fInputEvent->IsA()==AliAODEvent::Class())
761  // ProcessTrueClusterCandidatesAOD(PhotonCandidate, clus->GetM02(), PhotonCandidate1, PhotonCandidate2);
762  return mclabel;
763  }
764  } else {
765  return -7;
766  }
767  return -1;
768 }
769 
770 //________________________________________________________________________
771 void AliAnalysisTaskClusterQA::ProcessTracksAndMatching(AliVCluster* clus, Long_t indexCluster){
772 
773 
774  Int_t nTracksInR = 0;
775  Int_t nModules = fGeomEMCAL->GetNumberOfSuperModules();
776 
777  AliESDEvent *esdev = dynamic_cast<AliESDEvent*>(fInputEvent);
778  AliESDtrackCuts *EsdTrackCuts = 0x0;
779  // Using standard function for setting Cuts
780  static int prevRun = -1;
781  // Using standard function for setting Cuts
782  if (esdev){
783  Int_t runNumber = fInputEvent->GetRunNumber();
784  if (prevRun!=runNumber) {
785  delete EsdTrackCuts;
786  EsdTrackCuts = 0;
787  prevRun = runNumber;
788  }
789  // if LHC11a or earlier or if LHC13g or if LHC12a-i -> use 2010 cuts
790  if( (runNumber<=146860) || (runNumber>=197470 && runNumber<=197692) || (runNumber>=172440 && runNumber<=193766) ){
791  EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
792  // else if run2 data use 2015 PbPb cuts
793  }else if (runNumber>=209122){
794  // hard coded track cuts for the moment, because AliESDtrackCuts::GetStandardITSTPCTrackCuts2015PbPb() gives spams warnings
795  EsdTrackCuts = new AliESDtrackCuts();
796  EsdTrackCuts->AliESDtrackCuts::SetMinNCrossedRowsTPC(70);
797  EsdTrackCuts->AliESDtrackCuts::SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
798  EsdTrackCuts->AliESDtrackCuts::SetMaxChi2PerClusterTPC(4);
799  EsdTrackCuts->AliESDtrackCuts::SetAcceptKinkDaughters(kFALSE);
800  EsdTrackCuts->AliESDtrackCuts::SetRequireTPCRefit(kTRUE);
801  // ITS
802  EsdTrackCuts->AliESDtrackCuts::SetRequireITSRefit(kTRUE);
803  EsdTrackCuts->AliESDtrackCuts::SetClusterRequirementITS(AliESDtrackCuts::kSPD,
804  AliESDtrackCuts::kAny);
805  EsdTrackCuts->AliESDtrackCuts::SetMaxDCAToVertexXYPtDep("0.0105+0.0350/pt^1.1");
806  EsdTrackCuts->AliESDtrackCuts::SetMaxChi2TPCConstrainedGlobal(36);
807  EsdTrackCuts->AliESDtrackCuts::SetMaxDCAToVertexZ(2);
808  EsdTrackCuts->AliESDtrackCuts::SetDCAToVertex2D(kFALSE);
809  EsdTrackCuts->AliESDtrackCuts::SetRequireSigmaToVertex(kFALSE);
810  EsdTrackCuts->AliESDtrackCuts::SetMaxChi2PerClusterITS(36);
811  // else use 2011 version of track cuts
812  }else{
813  EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
814  }
815  EsdTrackCuts->SetMaxDCAToVertexZ(2);
816  EsdTrackCuts->SetEtaRange(-0.8, 0.8);
817  EsdTrackCuts->SetPtRange(0.15);
818  }
819 
820  for (Int_t itr=0;itr<fInputEvent->GetNumberOfTracks();itr++){
821  AliVTrack *inTrack = esdev->GetTrack(itr);
822  if(!inTrack) continue;
823  if(inTrack->Pt()<fMinTrackPt) continue;
824  AliESDtrack *esdt = dynamic_cast<AliESDtrack*>(inTrack);
825  // check track cuts
826  if(!EsdTrackCuts->AcceptTrack(esdt)) continue;
827  const AliExternalTrackParam *in = esdt->GetInnerParam();
828  if (!in){AliError("Could not get InnerParam of Track, continue");continue;}
829  AliExternalTrackParam *trackParam =new AliExternalTrackParam(*in);
830  AliExternalTrackParam emcParam(*trackParam);
831  Float_t eta, phi, pt;
832 
833  //propagate tracks to emc surfaces
834  if (!AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&emcParam, 440., 0.139, 20., eta, phi, pt)) {
835  delete trackParam;
836  continue;
837  }
838  if( TMath::Abs(eta) > 0.75 ) {
839  delete trackParam;
840  continue;
841  }
842  // Save some time and memory in case of no DCal present
843  if( nModules < 13 && ( phi < 70*TMath::DegToRad() || phi > 190*TMath::DegToRad())){
844  delete trackParam;
845  continue;
846  }
847  // Save some time and memory in case of run2
848  if( nModules > 12 ){
849  if (( phi < 70*TMath::DegToRad() || phi > 190*TMath::DegToRad()) && ( phi < 250*TMath::DegToRad() || phi > 340*TMath::DegToRad())){
850  delete trackParam;
851  continue;
852  }
853  }
854  Float_t dEta=-999, dPhi=-999;
855  Double_t trkPos[3] = {0.,0.,0.};
856  if (!emcParam.GetXYZ(trkPos)){
857  delete trackParam;
858  continue;
859  }
860 
861  AliExternalTrackParam trackParamTmp(emcParam);//Retrieve the starting point every time before the extrapolation
862  if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trackParamTmp, clus, 0.139, 5., dEta, dPhi)) continue;
863 
864  Float_t dR2 = dPhi*dPhi + dEta*dEta;
865  if(dR2 < fConeRadius){
866  fBuffer_Surrounding_Tracks_R[nTracksInR]=dR2;
867  fBuffer_Surrounding_Tracks_Pt[nTracksInR]=inTrack->Pt();
870  nTracksInR+=1;
871  }
872  }
873  fBuffer_Surrounding_NTracks = nTracksInR;
874  if(nTracksInR==0){
875  fBuffer_Surrounding_Tracks_R[nTracksInR]=-1;
876  fBuffer_Surrounding_Tracks_Pt[nTracksInR]=-1;
879  }
880 
881  if(EsdTrackCuts){
882  delete EsdTrackCuts;
883  EsdTrackCuts=0x0;
884  }
885 }
886 
887 //________________________________________________________________________
889  AliAODConversionPhoton *TrueSubClusterCandidate1,
890  AliAODConversionPhoton *TrueSubClusterCandidate2)
891 {
892  Int_t mcLabelCluster = -5;
893  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
894  Double_t mcProdVtxX = primVtxMC->GetX();
895  Double_t mcProdVtxY = primVtxMC->GetY();
896  Double_t mcProdVtxZ = primVtxMC->GetZ();
897 
898  TParticle *Photon = NULL;
899  if (!TrueClusterCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
900  if (TrueClusterCandidate->GetCaloPhotonMCLabel(0) < 0) return mcLabelCluster;
901  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0) Photon = fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMCLabel(0));
902  else return mcLabelCluster;
903 
904  if(Photon == NULL){
905  return mcLabelCluster;
906  }
907  AliAODConversionMother *mesoncand = new AliAODConversionMother(TrueSubClusterCandidate1,TrueSubClusterCandidate2);
908  Bool_t mesonIsSelected = (((AliConversionMesonCuts*)fMesonCuts)->MesonIsSelected(mesoncand,kTRUE,fEventCuts->GetEtaShift()));
909  if (!mesonIsSelected){
910  delete mesoncand;
911  return mcLabelCluster;
912  }
913 
914  TrueClusterCandidate->SetCaloPhotonMCFlags(fMCEvent, kFALSE);
915 
916  Int_t clusterClass = 0;
917  Bool_t isPrimary = fEventCuts->IsConversionPrimaryESD( fMCEvent, TrueClusterCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
918 
919  // cluster classification:
920  // 1 - nice merged cluster (2 gamma | contributions from 2 gamma) from pi0/eta
921  // 2 - contribution from only 1 partner (1 gamma, 1 fully coverted gamma) from pi0/eta
922  // 3 - contribution from part of 1 partner (1 electron) from pi0/eta
923  Long_t motherLab = -1;
924  if (TrueClusterCandidate->IsMerged() || TrueClusterCandidate->IsMergedPartConv()){
925  clusterClass = 1;
926  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
927  } else if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 0){
928  if (TrueClusterCandidate->IsLargestComponentElectron() || TrueClusterCandidate->IsLargestComponentPhoton()){
929  if (TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) > -1 && (fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0))->GetPdgCode() == 111 || fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0))->GetPdgCode() == 221) ){
930  if ( TrueClusterCandidate->IsConversion() && !TrueClusterCandidate->IsConversionFullyContained() ){
931  clusterClass = 3;
932  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
933  } else {
934  clusterClass = 2;
935  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
936  }
937  }
938  } else if (TrueClusterCandidate->IsSubLeadingEM()){
939  if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 1){
940  if ( TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) > -1){
941  if (fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1))->GetPdgCode() == 111 || fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1))->GetPdgCode() == 221 ){
942  clusterClass = 2;
943  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1);
944  }
945  }
946  }
947  } else {
948  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
949  }
950  }
951 
952  // Get Mother particle
953  TParticle *mother = NULL;
954  Int_t motherPDG = -1;
955  if (motherLab > -1)
956  mother = fMCEvent->Particle(motherLab);
957  if (mother)
958  motherPDG = TMath::Abs(mother->GetPdgCode());
959 
960  //
961  if (clusterClass == 1 || clusterClass == 2 || clusterClass == 3 ){
962  // separate different components
963  if (clusterClass == 1 && TrueClusterCandidate->IsMerged()){
964  if (motherPDG == 111){
965  mcLabelCluster = 10; // NOTE merged pi0
966  if (!isPrimary && m02 >= 0 && m02 <= 4.8 )
967  mcLabelCluster = 11; // NOTE secondary merged pi0
968  }
969  if (motherPDG == 221)
970  mcLabelCluster = 12; // NOTE merged eta
971  } else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv()){
972  if (motherPDG == 111){
973  mcLabelCluster = 13; // NOTE merged pi0 with one converted gamma
974  if (!isPrimary && m02 >= 0 && m02 <= 4.8 )
975  mcLabelCluster = 14; // NOTE merged secondary pi0 with one converted gamma
976  }
977  if (motherPDG == 221)
978  mcLabelCluster = 15; // NOTE merged eta with one converted gamma
979  } else if (clusterClass == 2){
980  if (motherPDG == 111){
981  mcLabelCluster = 20; // NOTE decay photon from pi0
982  if (!isPrimary && m02 >= 0 && m02 <= 4.8 )
983  mcLabelCluster = 21; // NOTE decay photon from secondary pi0
984  }
985  if (motherPDG == 221)
986  mcLabelCluster = 22; // NOTE decay photon from eta
987  } else if (clusterClass == 3){
988  if (motherPDG == 111) {
989  mcLabelCluster = 30; // NOTE electron from decayed pi0
990  if (!isPrimary && m02 >= 0 && m02 <= 4.8 )
991  mcLabelCluster = 31; // NOTE electron from decayed secondary pi0
992  }
993  if (motherPDG == 221)
994  mcLabelCluster = 32; // NOTE electron from decayed eta
995  }
996  // leading particle is a photon or the conversion is fully contained and its not from pi0 || eta
997  } else if (TrueClusterCandidate->IsLargestComponentPhoton() || TrueClusterCandidate->IsConversionFullyContained()
998  || TrueClusterCandidate->IsElectronFromFragPhoton()){
999  if (motherLab == -1)
1000  mcLabelCluster = 40; // NOTE direct photon
1001  else
1002  mcLabelCluster = 41;
1003  // leading particle is an electron and its not from pi0 || eta and no electron from fragmentation photon conversion
1004  } else if (TrueClusterCandidate->IsLargestComponentElectron() && !TrueClusterCandidate->IsElectronFromFragPhoton()){
1005  mcLabelCluster = 50; // NOTE cluster from hadron
1006  } else {
1007  mcLabelCluster = 60; // NOTE BG cluster
1008  }
1009 
1010  delete mesoncand;
1011  return mcLabelCluster;
1012 }
1013 
1014 //_____________________________________________________________________________
1015 ULong64_t AliAnalysisTaskClusterQA::GetUniqueEventID(AliVHeader* header)
1016 {
1017  // To have a unique id for each event in a run!
1018  // Modified from AliRawReader.h
1019  return ((ULong64_t)header->GetBunchCrossNumber()+
1020  (ULong64_t)header->GetOrbitNumber()*3564+
1021  (ULong64_t)header->GetPeriodNumber()*16777215*3564);
1022 }
1023 
1024 //-------------------------------------------------------------
1026 { // Get Event Centrality
1027 
1028  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
1029  if(esdEvent){
1030  AliMultSelection *MultSelection = (AliMultSelection*)event->FindListObject("MultSelection");
1031  if(!MultSelection){
1032  AliWarning ("AliMultSelection object not found !");
1033  return -1;
1034  }else{
1035  return MultSelection->GetMultiplicityPercentile("V0M");// default
1036  }
1037  }
1038 
1039 
1040  return -1;
1041 }
void SetPeriodEnum(TString periodName)
Int_t fBuffer_Surrounding_NTracks
! array buffer
void SetCaloClusterRef(Long_t ref)
double Double_t
Definition: External.C:58
Float_t fBuffer_ClusterPhi
! array buffer
virtual void UserExec(Option_t *option)
Definition: External.C:236
void SetCaloPhotonMCFlags(AliMCEvent *mcEvent, Bool_t enableSort)
ULong64_t GetUniqueEventID(AliVHeader *header)
Float_t fBuffer_Event_Vertex_Y
! array buffer
Int_t MakePhotonCandidates(AliVCluster *clus, AliVCaloCells *cells, Long_t indexCluster)
PeriodVar GetPeriodEnum()
Bool_t fSaveMCInformation
save MC information
void SetPeriodEnumExplicit(PeriodVar periodEnum)
const Int_t kMaxNTracks
Float_t fBuffer_ClusterE
! array buffer
centrality
Float_t * fBuffer_Cells_RelativeEta
! array buffer
Double_t GetEtaShift()
Bool_t fSaveEventProperties
save general event properties (centrality etc.)
Float_t fConeRadius
save arrays of all cells in event
TString GetPeriodName()
void SetCaloPhotonMCLabel(Int_t i, Int_t labelCaloPhoton)
Float_t * fBuffer_Surrounding_Tracks_R
! array buffer
Float_t fBuffer_Event_Vertex_Z
! array buffer
Int_t GetCaloPhotonMotherMCLabel(Int_t i)
Bool_t fBuffer_ClusterIsEMCAL
! array buffer
Float_t fBuffer_Event_Vertex_X
! array buffer
Int_t fBuffer_LeadingCell_ID
! array buffer
void GetRowAndColumnFromAbsCellID(Int_t cellIndex, Int_t &row, Int_t &column)
void ProcessTracksAndMatching(AliVCluster *clus, Long_t indexCluster)
Float_t fBuffer_Event_Multiplicity
! array buffer
Int_t * fBuffer_Surrounding_Cells_ID
! array buffer
Int_t FindLargestCellInCluster(AliVCluster *cluster, AliVEvent *event)
Float_t * fBuffer_Surrounding_Cells_E
! array buffer
Float_t fBuffer_LeadingCell_Phi
! array buffer
Int_t IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis)
int Int_t
Definition: External.C:63
Float_t * fBuffer_Surrounding_Cells_R
! array buffer
Class handling all kinds of selection cuts for Gamma Calo analysis.
void ProcessQATreeCluster(AliVEvent *event, AliVCluster *cluster, Long_t indexCluster)
Float_t * fBuffer_Cells_RelativePhi
! array buffer
Float_t * fBuffer_Surrounding_Tracks_RelativeEta
! array buffer
float Float_t
Definition: External.C:68
Float_t * fBuffer_Surrounding_Tracks_Pt
! array buffer
Bool_t IsConversionPrimaryESD(AliMCEvent *mcEvent, Long_t eventpos, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ)
Int_t fBuffer_Cluster_MC_Label
! array buffer
Bool_t fSaveSurroundingCells
save arrays of all cells in event
Float_t fBuffer_ClusterM20
! array buffer
Bool_t fSaveAdditionalHistos
save MC information
Float_t fMinClusterEnergy
save arrays of all cells in event
Int_t * fBuffer_Cells_ID
! array buffer
Int_t fMaxNLMCut
save MC information
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
short Short_t
Definition: External.C:23
Float_t fBuffer_ClusterM02
! array buffer
virtual void Terminate(Option_t *)
Int_t fBuffer_Event_NumActiveCells
! array buffer
Float_t fBuffer_ClusterEta
! array buffer
Float_t GetCentrality(AliVEvent *event)
Bool_t fSaveCells
save arrays of cluster cells
static Bool_t ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, const AliVCluster *cluster, Double_t mass, Double_t step, Float_t &tmpEta, Float_t &tmpPhi)
ULong64_t fBuffer_EventID
! array buffer
Float_t * fBuffer_Surrounding_Cells_RelativePhi
! array buffer
Class handling all kinds of selection cuts for Gamma Conversion analysis.
Int_t fBuffer_ClusterNumCells
! array buffer
void SetNCaloPhotonMCLabels(Int_t nLabels)
Float_t fBuffer_LeadingCell_Eta
! array buffer
const Int_t kMaxActiveCells
Class handling all kinds of selection cuts for Gamma Conversion analysis.
Float_t * fBuffer_Surrounding_Cells_RelativeEta
! array buffer
AliConversionMesonCuts * fMesonCuts
Float_t fBuffer_LeadingCell_E
! array buffer
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:90
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
Float_t * fBuffer_Surrounding_Tracks_RelativePhi
! array buffer
Float_t * fBuffer_Cells_E
! array buffer
Int_t fMinNLMCut
save MC information
Int_t fBuffer_Surrounding_NCells
! array buffer
Bool_t fSaveTracks
save arrays of all cells in event
Int_t ProcessTrueClusterCandidates(AliAODConversionPhoton *TrueClusterCandidate, Float_t m02, AliAODConversionPhoton *TrueSubClusterCandidate1, AliAODConversionPhoton *TrueSubClusterCandidate2)
TList * OpenFile(const char *fname)
Definition: DrawAnaELoss.C:65
Float_t fMinTrackPt
save arrays of all cells in event