AliPhysics  1c9c77b (1c9c77b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnaClusterPileUp.cxx
Go to the documentation of this file.
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 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 // --- ROOT system ---
17 #include <TH2F.h>
18 #include <TClonesArray.h>
19 #include <TObjString.h>
20 
21 // --- Analysis system ---
22 #include "AliAnaClusterPileUp.h"
23 #include "AliCaloTrackReader.h"
24 #include "AliFiducialCut.h"
25 #include "AliVCluster.h"
26 #include "AliAODEvent.h"
27 #include "AliESDEvent.h"
28 
32 
33 //___________________________________________
35 //___________________________________________
38 fNCellsCut(0),
39 fMomentum(),
40 // Histograms
41 fhTimePtNoCut(0), fhTimePtSPD(0),
42 fhTimeNPileUpVertSPD(0), fhTimeNPileUpVertTrack(0),
43 fhTimeNPileUpVertContributors(0),
44 fhTimePileUpMainVertexZDistance(0), fhTimePileUpMainVertexZDiamond(0),
45 fhClusterMultSPDPileUp(), fhClusterMultNoPileUp(),
46 fhEtaPhiBC0(0), fhEtaPhiBCPlus(0), fhEtaPhiBCMinus(0),
47 fhEtaPhiBC0PileUpSPD(0),
48 fhEtaPhiBCPlusPileUpSPD(0), fhEtaPhiBCMinusPileUpSPD(0),
49 fhPtNPileUpSPDVtx(0), fhPtNPileUpTrkVtx(0),
50 fhPtNPileUpSPDVtxTimeCut(0), fhPtNPileUpTrkVtxTimeCut(0),
51 fhPtNPileUpSPDVtxTimeCut2(0), fhPtNPileUpTrkVtxTimeCut2(0)
52 {
53  for(Int_t i = 0; i < 7; i++)
54  {
55  fhPtPileUp [i] = 0;
56  fhPtNeutralPileUp[i] = 0;
57 
58  fhLambda0PileUp [i] = 0;
60 
62 
66 
67  }
68 
69  for(Int_t i = 0; i < 4; i++)
70  {
72  fhClusterMultNoPileUp [i] = 0;
73  }
74 
76 }
77 
78 //__________________________________________________
80 //__________________________________________________
82 {
83  TString parList ; //this will be list of parameters used for this analysis.
84  const Int_t buffersize = 255;
85  char onePar[buffersize] ;
86 
87  snprintf(onePar,buffersize,"--- AliAnaClusterPileUp---:") ;
88  parList+=onePar ;
89  snprintf(onePar,buffersize,"Calorimeter: %s",GetCalorimeterString().Data()) ;
90  parList+=onePar ;
91 
92  //Get parameters set in base class.
93  //parList += GetBaseParametersList() ;
94 
95  return new TObjString(parList) ;
96 }
97 
98 //____________________________________________________
101 //____________________________________________________
103 {
104  TList * outputContainer = new TList() ;
105  outputContainer->SetName("PhotonHistos") ;
106 
112 
113  fhTimePtNoCut = new TH2F ("hTimePt_NoCut","time of cluster vs pT of clusters, no event selection", nptbins,ptmin,ptimecluster, ntimebins,timemin,timemax);
114  fhTimePtNoCut->SetXTitle("#it{p}_{T} (GeV/#it{c})");
115  fhTimePtNoCut->SetYTitle("#it{time} (ns)");
116  outputContainer->Add(fhTimePtNoCut);
117 
118  fhTimePtSPD = new TH2F ("hTimePt_SPD","time of cluster vs pT of clusters, SPD Pile-up events", nptbins,ptmin,ptimecluster, ntimebins,timemin,timemax);
119  fhTimePtSPD->SetXTitle("#it{p}_{T} (GeV/#it{c})");
120  fhTimePtSPD->SetYTitle("#it{time} (ns)");
121  outputContainer->Add(fhTimePtSPD);
122 
123  fhTimeNPileUpVertSPD = new TH2F ("hTime_NPileUpVertSPD","time of cluster vs N pile-up SPD vertex", ntimebins,timemin,timemax,20,0,20);
124  fhTimeNPileUpVertSPD->SetYTitle("# vertex ");
125  fhTimeNPileUpVertSPD->SetXTitle("#it{time} (ns)");
126  outputContainer->Add(fhTimeNPileUpVertSPD);
127 
128  fhTimeNPileUpVertTrack = new TH2F ("hTime_NPileUpVertTracks","time of cluster vs N pile-up Tracks vertex", ntimebins,timemin,timemax, 20,0,20 );
129  fhTimeNPileUpVertTrack->SetYTitle("# vertex ");
130  fhTimeNPileUpVertTrack->SetXTitle("#it{time} (ns)");
131  outputContainer->Add(fhTimeNPileUpVertTrack);
132 
133  fhTimeNPileUpVertContributors = new TH2F ("hTime_NPileUpVertContributors","time of cluster vs N constributors to pile-up SPD vertex", ntimebins,timemin,timemax,50,0,50);
134  fhTimeNPileUpVertContributors->SetYTitle("# vertex ");
135  fhTimeNPileUpVertContributors->SetXTitle("#it{time} (ns)");
136  outputContainer->Add(fhTimeNPileUpVertContributors);
137 
138  fhTimePileUpMainVertexZDistance = new TH2F ("hTime_PileUpMainVertexZDistance","time of cluster vs distance in Z pile-up SPD vertex - main SPD vertex",ntimebins,timemin,timemax,100,0,50);
139  fhTimePileUpMainVertexZDistance->SetYTitle("distance Z (cm) ");
140  fhTimePileUpMainVertexZDistance->SetXTitle("#it{time} (ns)");
141  outputContainer->Add(fhTimePileUpMainVertexZDistance);
142 
143  fhTimePileUpMainVertexZDiamond = new TH2F ("hTime_PileUpMainVertexZDiamond","time of cluster vs distance in Z pile-up SPD vertex - z diamond",ntimebins,timemin,timemax,100,0,50);
144  fhTimePileUpMainVertexZDiamond->SetYTitle("diamond distance Z (cm) ");
145  fhTimePileUpMainVertexZDiamond->SetXTitle("#it{time} (ns)");
146  outputContainer->Add(fhTimePileUpMainVertexZDiamond);
147 
148  fhEtaPhiBC0 = new TH2F ("hEtaPhiBC0","eta-phi for clusters tof corresponding to BC=0",netabins,etamin,etamax, nphibins,phimin,phimax);
149  fhEtaPhiBC0->SetXTitle("#eta ");
150  fhEtaPhiBC0->SetYTitle("#phi (rad)");
151  outputContainer->Add(fhEtaPhiBC0);
152 
153  fhEtaPhiBCPlus = new TH2F ("hEtaPhiBCPlus","eta-phi for clusters tof corresponding to BC>0",netabins,etamin,etamax, nphibins,phimin,phimax);
154  fhEtaPhiBCPlus->SetXTitle("#eta ");
155  fhEtaPhiBCPlus->SetYTitle("#phi (rad)");
156  outputContainer->Add(fhEtaPhiBCPlus);
157 
158  fhEtaPhiBCMinus = new TH2F ("hEtaPhiBCMinus","eta-phi for clusters tof corresponding to BC<0",netabins,etamin,etamax, nphibins,phimin,phimax);
159  fhEtaPhiBCMinus->SetXTitle("#eta ");
160  fhEtaPhiBCMinus->SetYTitle("#phi (rad)");
161  outputContainer->Add(fhEtaPhiBCMinus);
162 
163  fhEtaPhiBC0PileUpSPD = new TH2F ("hEtaPhiBC0PileUpSPD","eta-phi for clusters tof corresponding to BC=0, SPD pile-up",netabins,etamin,etamax, nphibins,phimin,phimax);
164  fhEtaPhiBC0PileUpSPD->SetXTitle("#eta ");
165  fhEtaPhiBC0PileUpSPD->SetYTitle("#phi (rad)");
166  outputContainer->Add(fhEtaPhiBC0PileUpSPD);
167 
168  fhEtaPhiBCPlusPileUpSPD = new TH2F ("hEtaPhiBCPlusPileUpSPD","eta-phi for clusters tof corresponding to BC>0, SPD pile-up",netabins,etamin,etamax, nphibins,phimin,phimax);
169  fhEtaPhiBCPlusPileUpSPD->SetXTitle("#eta ");
170  fhEtaPhiBCPlusPileUpSPD->SetYTitle("#phi (rad)");
171  outputContainer->Add(fhEtaPhiBCPlusPileUpSPD);
172 
173  fhEtaPhiBCMinusPileUpSPD = new TH2F ("hEtaPhiBCMinusPileUpSPD","eta-phi for clusters tof corresponding to BC<0, SPD pile-up",netabins,etamin,etamax, nphibins,phimin,phimax);
174  fhEtaPhiBCMinusPileUpSPD->SetXTitle("#eta ");
175  fhEtaPhiBCMinusPileUpSPD->SetYTitle("#phi (rad)");
176  outputContainer->Add(fhEtaPhiBCMinusPileUpSPD);
177 
178  TString title[] = {"no |t diff| cut","|t diff|<20 ns","|t diff|>20 ns","|t diff|>40 ns"};
179  TString name [] = {"TDiffNoCut","TDiffSmaller20ns","TDiffLarger20ns","TDiffLarger40ns"};
180  for(Int_t i = 0; i < 4; i++)
181  {
182  fhClusterMultSPDPileUp[i] = new TH2F(Form("fhClusterMultSPDPileUp_%s", name[i].Data()),
183  Form("Number of clusters per pile up event with #it{E} > 0.5 and %s respect cluster max vs cluster max E ",title[i].Data()),
184  nptbins,ptmin,ptimecluster,100,0,100);
185  fhClusterMultSPDPileUp[i]->SetYTitle("n clusters ");
186  fhClusterMultSPDPileUp[i]->SetXTitle("#it{E}_{cluster max} (GeV)");
187  outputContainer->Add(fhClusterMultSPDPileUp[i]) ;
188 
189  fhClusterMultNoPileUp[i] = new TH2F(Form("fhClusterMultNoPileUp_%s", name[i].Data()),
190  Form("Number of clusters per non pile up event with #it{E} > 0.5 and %s respect cluster max vs cluster max E ",title[i].Data()),
191  nptbins,ptmin,ptimecluster,100,0,100);
192  fhClusterMultNoPileUp[i]->SetYTitle("n clusters ");
193  fhClusterMultNoPileUp[i]->SetXTitle("#it{E}_{cluster max} (GeV)");
194  outputContainer->Add(fhClusterMultNoPileUp[i]) ;
195  }
196 
197  fhPtNPileUpSPDVtx = new TH2F ("hPt_NPileUpVertSPD","pT of cluster vs N pile-up SPD vertex",
198  nptbins,ptmin,ptimecluster,20,0,20);
199  fhPtNPileUpSPDVtx->SetYTitle("# vertex ");
200  fhPtNPileUpSPDVtx->SetXTitle("#it{p}_{T} (GeV/#it{c})");
201  outputContainer->Add(fhPtNPileUpSPDVtx);
202 
203  fhPtNPileUpTrkVtx = new TH2F ("hPt_NPileUpVertTracks","pT of cluster vs N pile-up Tracks vertex",
204  nptbins,ptmin,ptimecluster, 20,0,20 );
205  fhPtNPileUpTrkVtx->SetYTitle("# vertex ");
206  fhPtNPileUpTrkVtx->SetXTitle("#it{p}_{T} (GeV/#it{c})");
207  outputContainer->Add(fhPtNPileUpTrkVtx);
208 
209  fhPtNPileUpSPDVtxTimeCut = new TH2F ("hPt_NPileUpVertSPD_TimeCut","pT of cluster vs N pile-up SPD vertex, |tof| < 25 ns",
210  nptbins,ptmin,ptimecluster,20,0,20);
211  fhPtNPileUpSPDVtxTimeCut->SetYTitle("# vertex ");
212  fhPtNPileUpSPDVtxTimeCut->SetXTitle("#it{p}_{T} (GeV/#it{c})");
213  outputContainer->Add(fhPtNPileUpSPDVtxTimeCut);
214 
215  fhPtNPileUpTrkVtxTimeCut = new TH2F ("hPt_NPileUpVertTracks_TimeCut","pT of cluster vs N pile-up Tracks vertex, |tof| < 25 ns",
216  nptbins,ptmin,ptimecluster, 20,0,20 );
217  fhPtNPileUpTrkVtxTimeCut->SetYTitle("# vertex ");
218  fhPtNPileUpTrkVtxTimeCut->SetXTitle("#it{p}_{T} (GeV/#it{c})");
219  outputContainer->Add(fhPtNPileUpTrkVtxTimeCut);
220 
221  fhPtNPileUpSPDVtxTimeCut2 = new TH2F ("hPt_NPileUpVertSPD_TimeCut2","pT of cluster vs N pile-up SPD vertex, -25 < tof < 75 ns",
222  nptbins,ptmin,ptimecluster,20,0,20);
223  fhPtNPileUpSPDVtxTimeCut2->SetYTitle("# vertex ");
224  fhPtNPileUpSPDVtxTimeCut2->SetXTitle("#it{p}_{T} (GeV/#it{c})");
225  outputContainer->Add(fhPtNPileUpSPDVtxTimeCut2);
226 
227  fhPtNPileUpTrkVtxTimeCut2 = new TH2F ("hPt_NPileUpVertTracks_TimeCut2","pT of cluster vs N pile-up Tracks vertex, -25 < tof < 75 ns",
228  nptbins,ptmin,ptimecluster, 20,0,20 );
229  fhPtNPileUpTrkVtxTimeCut2->SetYTitle("# vertex ");
230  fhPtNPileUpTrkVtxTimeCut2->SetXTitle("#it{p}_{T} (GeV/#it{c})");
231  outputContainer->Add(fhPtNPileUpTrkVtxTimeCut2);
232 
233 
234  TString pileUpName[] = {"SPD",kEMCAL,"SPDOrEMCAL","SPDAndEMCAL","SPDAndNotEMCAL","EMCALAndNotSPD","NotSPDAndNotEMCAL"} ;
235 
236  for(Int_t i = 0 ; i < 7 ; i++)
237  {
238  fhPtPileUp[i] = new TH1F(Form("hPtPileUp%s",pileUpName[i].Data()),
239  Form("Cluster #it{p}_{T} distribution, %s Pile-Up event",pileUpName[i].Data()), nptbins,ptmin,ptimecluster);
240  fhPtPileUp[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
241  outputContainer->Add(fhPtPileUp[i]);
242 
243  fhPtNeutralPileUp[i] = new TH1F(Form("hPtNeutralPileUp%s",pileUpName[i].Data()),
244  Form("Neutral clusters #it{p}_{T} distribution, %s Pile-Up event",pileUpName[i].Data()), nptbins,ptmin,ptimecluster);
245  fhPtNeutralPileUp[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
246  outputContainer->Add(fhPtNeutralPileUp[i]);
247 
248  fhClusterEFracLongTimePileUp[i] = new TH2F(Form("hClusterEFracLongTimePileUp%s",pileUpName[i].Data()),
249  Form("Cluster E vs fraction of cluster energy from large T cells, %s Pile-Up event",pileUpName[i].Data()),
250  nptbins,ptmin,ptimecluster,200,0,1);
251  fhClusterEFracLongTimePileUp[i]->SetXTitle("#it{E} (GeV)");
252  fhClusterEFracLongTimePileUp[i]->SetYTitle("E(large time) / E");
253  outputContainer->Add(fhClusterEFracLongTimePileUp[i]);
254 
255  fhClusterCellTimePileUp[i] = new TH2F(Form("hClusterCellTimePileUp%s",pileUpName[i].Data()),
256  Form("Cluster E vs cell time in cluster, %s Pile-Up event",pileUpName[i].Data()),
257  nptbins,ptmin,ptimecluster,ntimebins,timemin,timemax);
258  fhClusterCellTimePileUp[i]->SetXTitle("#it{E} (GeV)");
259  fhClusterCellTimePileUp[i]->SetYTitle("t_{cell} (ns)");
260  outputContainer->Add(fhClusterCellTimePileUp[i]);
261 
262  fhClusterTimeDiffPileUp[i] = new TH2F(Form("hClusterTimeDiffPileUp%s",pileUpName[i].Data()),
263  Form("Cluster E vs t_{max}-t_{cell} in cluster, %s Pile-Up event",pileUpName[i].Data()),
264  nptbins,ptmin,ptimecluster,400,-200,200);
265  fhClusterTimeDiffPileUp[i]->SetXTitle("#it{E} (GeV)");
266  fhClusterTimeDiffPileUp[i]->SetYTitle("t_{max}-t_{cell} (ns)");
267  outputContainer->Add(fhClusterTimeDiffPileUp[i]);
268 
269  fhClusterTimeDiffNeutralPileUp[i] = new TH2F(Form("hClusterTimeDiffNeutralPileUp%s",pileUpName[i].Data()),
270  Form("Neutral clusters E vs t_{max}-t_{cell} in cluster, %s Pile-Up event",pileUpName[i].Data()),
271  nptbins,ptmin,ptimecluster,400,-200,200);
272  fhClusterTimeDiffNeutralPileUp[i]->SetXTitle("#it{E} (GeV)");
273  fhClusterTimeDiffNeutralPileUp[i]->SetYTitle("t_{max}-t_{cell} (ns)");
274  outputContainer->Add(fhClusterTimeDiffNeutralPileUp[i]);
275 
276  fhLambda0PileUp[i] = new TH2F(Form("hLambda0PileUp%s",pileUpName[i].Data()),
277  Form("Cluster E vs #lambda^{2}_{0} in cluster, %s Pile-Up event",pileUpName[i].Data()),
278  nptbins,ptmin,ptimecluster,ssbins,ssmin,ssmax);
279  fhLambda0PileUp[i]->SetXTitle("#it{E} (GeV)");
280  fhLambda0PileUp[i]->SetYTitle("#lambda^{2}_{0}");
281  outputContainer->Add(fhLambda0PileUp[i]);
282 
283  fhLambda0NeutralPileUp[i] = new TH2F(Form("hLambda0NeutralPileUp%s",pileUpName[i].Data()),
284  Form("Neutral clusters E vs #lambda^{2}_{0}in cluster, %s Pile-Up event",pileUpName[i].Data()), nptbins,ptmin,ptimecluster,ssbins,ssmin,ssmax);
285  fhLambda0NeutralPileUp[i]->SetXTitle("#it{E} (GeV)");
286  fhLambda0NeutralPileUp[i]->SetYTitle("#lambda^{2}_{0}");
287  outputContainer->Add(fhLambda0NeutralPileUp[i]);
288 
289  }
290 
291  return outputContainer ;
292 }
293 
294 //______________________________
297 //______________________________
299 {
300  if(GetCalorimeter() == kPHOS && !GetReader()->IsPHOSSwitchedOn())
301  AliFatal("You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!");
302 
303  if(GetCalorimeter() == kEMCAL && !GetReader()->IsEMCALSwitchedOn())
304  AliFatal("You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!");
305 
306  if(GetReader()->GetDataType() == AliCaloTrackReader::kMC)
307  AliFatal("You want to use MC data in analysis but this is not possible in pile-up!!");
308 }
309 
310 //________________________________________
312 //________________________________________
314 {
315  AddToHistogramsName("AnaClusterPileUp_");
316 
317  fNCellsCut = 2;
318 }
319 
320 //_____________________________________________________
323 //_____________________________________________________
325 {
326  // Select the calorimeter
327  TObjArray * pl = 0x0;
328  AliVCaloCells* cells = 0;
329  if (GetCalorimeter() == kPHOS )
330  {
331  pl = GetPHOSClusters();
332  cells = GetPHOSCells();
333  }
334  else if (GetCalorimeter() == kEMCAL)
335  {
336  pl = GetEMCALClusters();
337  cells = GetEMCALCells();
338  }
339 
340  if(!pl)
341  {
342  AliInfo(Form("TObjArray with %s clusters is NULL!",GetCalorimeterString().Data()));
343  return;
344  }
345 
346  AliVEvent * event = GetReader()->GetInputEvent();
347  AliESDEvent* esdEv = dynamic_cast<AliESDEvent*> (event);
348  AliAODEvent* aodEv = dynamic_cast<AliAODEvent*> (event);
349 
350  //-------------------
351  // N pile up vertices
352  Int_t nVtxSPD = -1;
353  Int_t nVtxTrk = -1;
354 
355  if (esdEv)
356  {
357  nVtxSPD = esdEv->GetNumberOfPileupVerticesSPD();
358  nVtxTrk = esdEv->GetNumberOfPileupVerticesTracks();
359  }//ESD
360  else if (aodEv)
361  {
362  nVtxSPD = aodEv->GetNumberOfPileupVerticesSPD();
363  nVtxTrk = aodEv->GetNumberOfPileupVerticesTracks();
364  }//AOD
365 
366  //-------------------
367  // Loop on clusters
368  Int_t nCaloClusters = pl->GetEntriesFast();
369 
370  AliDebug(1,Form("Input %s cluster entries %d", GetCalorimeterString().Data(), nCaloClusters));
371 
372  // Init variables
373  Int_t idMax = 0;
374  Float_t ptMax = 0;
375  Float_t tMax = 0;
376 
377  for(Int_t icalo = 0; icalo < nCaloClusters; icalo++)
378  {
379  AliVCluster * calo = (AliVCluster*) (pl->At(icalo));
380  //printf("calo %d, %f\n",icalo,calo->E());
381 
382  if(!calo) continue; // it should not happen, but just in case
383 
384  calo->GetMomentum(fMomentum,GetVertex(0)) ;
385 
386  Float_t ecluster = fMomentum.E();
387  Float_t ptcluster = fMomentum.Pt();
388  Float_t l0cluster = calo->GetM02();
389  Float_t etacluster = fMomentum.Eta();
390  Float_t phicluster = fMomentum.Phi();
391  if(phicluster < 0) phicluster+=TMath::TwoPi();
392  Float_t tofcluster = calo->GetTOF()*1.e9;
393 
394  Bool_t matched = IsTrackMatched(calo,GetReader()->GetInputEvent());
395 
396  //.......................................
397  // If too small or big energy, skip it
398  if(ecluster < GetMinEnergy() || ecluster > GetMaxEnergy() ) continue ;
399 
400  //.......................................
401  if(calo->GetNCells() <= fNCellsCut && GetReader()->GetDataType() != AliCaloTrackReader::kMC) continue;
402 
403  //.......................................
404  // Check acceptance selection
405  if(IsFiducialCutOn())
406  {
408  if(! in ) continue;
409  }
410 
411  // Select highest pt cluster passing the cuts
412  if(ptcluster > ptMax && tofcluster < 30)
413  {
414  ptMax = ptcluster;
415  tMax = tofcluster;
416  idMax = icalo;
417  }
418 
419  //-------------------------------------
420  // Cluster timing for different pile-up
421 
422  fhTimePtNoCut->Fill(ptcluster, tofcluster, GetEventWeight());
423  if(GetReader()->IsPileUpFromSPD()) fhTimePtSPD->Fill(ptcluster, tofcluster, GetEventWeight());
424 
425  //----------------------------------------
426  // Correlate cluster and number of vertices
427 
428  fhPtNPileUpSPDVtx->Fill(ptcluster, nVtxSPD, GetEventWeight());
429  fhPtNPileUpTrkVtx->Fill(ptcluster, nVtxTrk, GetEventWeight());
430 
431  if(TMath::Abs(tofcluster) < 30)
432  {
433  fhPtNPileUpSPDVtxTimeCut->Fill(ptcluster, nVtxSPD, GetEventWeight());
434  fhPtNPileUpTrkVtxTimeCut->Fill(ptcluster, nVtxTrk, GetEventWeight());
435  }
436 
437  if(tofcluster < 75 && tofcluster > -30)
438  {
439  fhPtNPileUpSPDVtxTimeCut2->Fill(ptcluster, nVtxSPD, GetEventWeight());
440  fhPtNPileUpTrkVtxTimeCut2->Fill(ptcluster, nVtxTrk, GetEventWeight());
441  }
442 
443  // Loop on the vertices arrays, correlate with timing
444  // only for sufficiently large cluster energy
445  if(ecluster > 8)
446  {
447  fhTimeNPileUpVertSPD ->Fill(tofcluster, nVtxSPD, GetEventWeight());
448  fhTimeNPileUpVertTrack->Fill(tofcluster, nVtxTrk, GetEventWeight());
449 
450  Int_t ncont = -1;
451  Float_t z1 = -1, z2 = -1;
452  Float_t diamZ = -1;
453  for(Int_t iVert=0; iVert<nVtxSPD;iVert++)
454  {
455  if (esdEv)
456  {
457  const AliESDVertex* pv=esdEv->GetPileupVertexSPD(iVert);
458  ncont=pv->GetNContributors();
459  z1 = esdEv->GetPrimaryVertexSPD()->GetZ();
460  z2 = pv->GetZ();
461  diamZ = esdEv->GetDiamondZ();
462  }//ESD
463  else if (aodEv)
464  {
465  AliAODVertex *pv=aodEv->GetVertex(iVert);
466  if(pv->GetType()!=AliAODVertex::kPileupSPD) continue;
467  ncont=pv->GetNContributors();
468  z1=aodEv->GetPrimaryVertexSPD()->GetZ();
469  z2=pv->GetZ();
470  diamZ = aodEv->GetDiamondZ();
471  }// AOD
472 
473  Double_t distZ = TMath::Abs(z2-z1);
474  diamZ = TMath::Abs(z2-diamZ);
475 
476  fhTimeNPileUpVertContributors ->Fill(tofcluster, ncont, GetEventWeight());
477  fhTimePileUpMainVertexZDistance->Fill(tofcluster, distZ, GetEventWeight());
478  fhTimePileUpMainVertexZDiamond ->Fill(tofcluster, diamZ, GetEventWeight());
479 
480  }// vertex loop
481  }
482 
483  //------------------------------------
484  // Eta-Phi cluster position depending on timing
485  // Continue only for BC0
486  if (tofcluster > 28)
487  {
488  fhEtaPhiBCPlus ->Fill(etacluster, phicluster, GetEventWeight());
489  if(GetReader()->IsPileUpFromSPD())
490  fhEtaPhiBCPlusPileUpSPD ->Fill(etacluster, phicluster, GetEventWeight());
491  continue;
492  }
493  else if (tofcluster <-28)
494  {
495  fhEtaPhiBCMinus->Fill(etacluster, phicluster, GetEventWeight());
496  if(GetReader()->IsPileUpFromSPD())
497  fhEtaPhiBCMinusPileUpSPD->Fill(etacluster, phicluster, GetEventWeight());
498 
499  continue ;
500  }
501 
502  //--------------------------------------
503  // Fill histograms for clusters in BC=0
504 
505  fhEtaPhiBC0->Fill(etacluster, phicluster, GetEventWeight());
506 
507  if(GetReader()->IsPileUpFromSPD()) fhEtaPhiBC0PileUpSPD->Fill(etacluster, phicluster, GetEventWeight());
508 
509  if(GetReader()->IsPileUpFromSPD())
510  {
511  fhPtPileUp [0]->Fill(ptcluster, GetEventWeight());
512  fhLambda0PileUp[0]->Fill(ptcluster, l0cluster, GetEventWeight());
513  }
514  if(GetReader()->IsPileUpFromEMCal())
515  {
516  fhPtPileUp [1]->Fill(ptcluster, GetEventWeight());
517  fhLambda0PileUp[1]->Fill(ptcluster, l0cluster, GetEventWeight());
518  }
519  if(GetReader()->IsPileUpFromSPDOrEMCal())
520  {
521  fhPtPileUp [2]->Fill(ptcluster, GetEventWeight());
522  fhLambda0PileUp[2]->Fill(ptcluster, l0cluster, GetEventWeight());
523  }
524  if(GetReader()->IsPileUpFromSPDAndEMCal())
525  {
526  fhPtPileUp [3]->Fill(ptcluster, GetEventWeight());
527  fhLambda0PileUp[3]->Fill(ptcluster, l0cluster, GetEventWeight());
528  }
529  if(GetReader()->IsPileUpFromSPDAndNotEMCal())
530  {
531  fhPtPileUp [4]->Fill(ptcluster, GetEventWeight());
532  fhLambda0PileUp[4]->Fill(ptcluster, l0cluster, GetEventWeight());
533  }
534  if(GetReader()->IsPileUpFromEMCalAndNotSPD())
535  {
536  fhPtPileUp [5]->Fill(ptcluster, GetEventWeight());
537  fhLambda0PileUp[5]->Fill(ptcluster, l0cluster, GetEventWeight());
538  }
539  if(GetReader()->IsPileUpFromNotSPDAndNotEMCal())
540  {
541  fhPtPileUp [6]->Fill(ptcluster, GetEventWeight());
542  fhLambda0PileUp[6]->Fill(ptcluster, l0cluster, GetEventWeight());
543  }
544 
545  if(!matched)
546  {
547  if(GetReader()->IsPileUpFromSPD())
548  {
549  fhPtNeutralPileUp [0]->Fill(ptcluster, GetEventWeight());
550  fhLambda0NeutralPileUp[0]->Fill(ptcluster, l0cluster, GetEventWeight());
551  }
552  if(GetReader()->IsPileUpFromEMCal())
553  {
554  fhPtNeutralPileUp [1]->Fill(ptcluster, GetEventWeight());
555  fhLambda0NeutralPileUp[1]->Fill(ptcluster, l0cluster, GetEventWeight());
556  }
557  if(GetReader()->IsPileUpFromSPDOrEMCal())
558  {
559  fhPtNeutralPileUp [2]->Fill(ptcluster, GetEventWeight());
560  fhLambda0NeutralPileUp[2]->Fill(ptcluster, l0cluster, GetEventWeight());
561  }
562  if(GetReader()->IsPileUpFromSPDAndEMCal())
563  {
564  fhPtNeutralPileUp [3]->Fill(ptcluster, GetEventWeight());
565  fhLambda0NeutralPileUp[3]->Fill(ptcluster, l0cluster, GetEventWeight());
566  }
567  if(GetReader()->IsPileUpFromSPDAndNotEMCal())
568  {
569  fhPtNeutralPileUp [4]->Fill(ptcluster, GetEventWeight());
570  fhLambda0NeutralPileUp[4]->Fill(ptcluster, l0cluster, GetEventWeight());
571  }
572  if(GetReader()->IsPileUpFromEMCalAndNotSPD())
573  {
574  fhPtNeutralPileUp [5]->Fill(ptcluster, GetEventWeight());
575  fhLambda0NeutralPileUp[5]->Fill(ptcluster, l0cluster, GetEventWeight());
576  }
577  if(GetReader()->IsPileUpFromNotSPDAndNotEMCal())
578  {
579  fhPtNeutralPileUp [6]->Fill(ptcluster, GetEventWeight());
580  fhLambda0NeutralPileUp[6]->Fill(ptcluster, l0cluster, GetEventWeight());
581  }
582  }
583 
584  //----------------------------------------------------------------------------
585  // Loop on cells inside cluster, max cell must be over 100 MeV and time in BC=0
586  // Get the fraction of the cluster energy that carries the cell with highest
587  // energy and its absId
588 
589  Float_t maxCellFraction = 0.;
590  Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(cells, calo,maxCellFraction);
591 
592  Float_t clusterLongTimePt = 0;
593  Float_t clusterOKTimePt = 0;
594 
595  if(cells->GetCellAmplitude(absIdMax) < 0.1) continue ;
596 
597  for (Int_t ipos = 0; ipos < calo->GetNCells(); ipos++)
598  {
599  Int_t absId = calo->GetCellsAbsId()[ipos];
600 
601  if( absId == absIdMax ) continue ;
602 
603  Double_t time = cells->GetCellTime(absId);
604  Float_t amp = cells->GetCellAmplitude(absId);
605  Int_t bc = GetReader()->GetInputEvent()->GetBunchCrossNumber();
606  GetCaloUtils()->GetEMCALRecoUtils()->AcceptCalibrateCell(absId,bc,amp,time,cells);
607  time*=1e9;
608 
609  Float_t diff = (tofcluster-time);
610 
611  if(GetReader()->IsInTimeWindow(time,amp)) clusterOKTimePt += amp;
612  else clusterLongTimePt += amp;
613 
614  if( cells->GetCellAmplitude(absIdMax) < 0.1 ) continue ;
615 
616  if(GetReader()->IsPileUpFromSPD())
617  {
618  fhClusterCellTimePileUp[0]->Fill(ptcluster, time, GetEventWeight());
619  fhClusterTimeDiffPileUp[0]->Fill(ptcluster, diff), GetEventWeight();
620  if(!matched) fhClusterTimeDiffNeutralPileUp[0]->Fill(ptcluster, diff, GetEventWeight());
621  }
622 
623  if(GetReader()->IsPileUpFromEMCal())
624  {
625  fhClusterCellTimePileUp[1]->Fill(ptcluster, time, GetEventWeight());
626  fhClusterTimeDiffPileUp[1]->Fill(ptcluster, diff, GetEventWeight());
627  if(!matched) fhClusterTimeDiffNeutralPileUp[1]->Fill(ptcluster, diff, GetEventWeight());
628  }
629 
630  if(GetReader()->IsPileUpFromSPDOrEMCal())
631  {
632  fhClusterCellTimePileUp[2]->Fill(ptcluster, time, GetEventWeight());
633  fhClusterTimeDiffPileUp[2]->Fill(ptcluster, diff, GetEventWeight());
634  if(!matched) fhClusterTimeDiffNeutralPileUp[2]->Fill(ptcluster, diff, GetEventWeight());
635  }
636 
637  if(GetReader()->IsPileUpFromSPDAndEMCal())
638  {
639  fhClusterCellTimePileUp[3]->Fill(ptcluster, time, GetEventWeight());
640  fhClusterTimeDiffPileUp[3]->Fill(ptcluster, diff, GetEventWeight());
641  if(!matched) fhClusterTimeDiffNeutralPileUp[3]->Fill(ptcluster, diff, GetEventWeight());
642  }
643 
644  if(GetReader()->IsPileUpFromSPDAndNotEMCal())
645  {
646  fhClusterCellTimePileUp[4]->Fill(ptcluster, time, GetEventWeight());
647  fhClusterTimeDiffPileUp[4]->Fill(ptcluster, diff, GetEventWeight());
648  if(!matched) fhClusterTimeDiffNeutralPileUp[4]->Fill(ptcluster, diff, GetEventWeight());
649  }
650 
651  if(GetReader()->IsPileUpFromEMCalAndNotSPD())
652  {
653  fhClusterCellTimePileUp[5]->Fill(ptcluster, time, GetEventWeight());
654  fhClusterTimeDiffPileUp[5]->Fill(ptcluster, diff, GetEventWeight());
655  if(!matched) fhClusterTimeDiffNeutralPileUp[5]->Fill(ptcluster, diff, GetEventWeight());
656  }
657 
658  if(GetReader()->IsPileUpFromNotSPDAndNotEMCal())
659  {
660  fhClusterCellTimePileUp[6]->Fill(ptcluster, time, GetEventWeight());
661  fhClusterTimeDiffPileUp[6]->Fill(ptcluster, diff, GetEventWeight());
662  if(!matched) fhClusterTimeDiffNeutralPileUp[6]->Fill(ptcluster, diff, GetEventWeight());
663  }
664  }//loop
665 
666  Float_t frac = 0;
667  if(clusterLongTimePt+clusterOKTimePt > 0.001)
668  frac = clusterLongTimePt/(clusterLongTimePt+clusterOKTimePt);
669  //printf("E long %f, E OK %f, Fraction large time %f, E %f\n",clusterLongTimePt,clusterOKTimePt,frac,ptcluster);
670 
671  if(GetReader()->IsPileUpFromSPD()) fhClusterEFracLongTimePileUp[0]->Fill(ptcluster, frac, GetEventWeight());
672  if(GetReader()->IsPileUpFromEMCal()) fhClusterEFracLongTimePileUp[1]->Fill(ptcluster, frac, GetEventWeight());
673  if(GetReader()->IsPileUpFromSPDOrEMCal()) fhClusterEFracLongTimePileUp[2]->Fill(ptcluster, frac, GetEventWeight());
678  }//loop
679 
680  //----------------------------------------------------------------------------------------------
681  // Loop again on clusters to compare this max cluster t and the rest of the clusters, if E > 0.3
682  Int_t n20 = 0;
683  Int_t n40 = 0;
684  Int_t n = 0;
685  Int_t nOK = 0;
686 
687  for(Int_t icalo = 0; icalo < nCaloClusters; icalo++)
688  {
689  AliVCluster * calo = (AliVCluster*) (pl->At(icalo));
690 
691  if(!calo || calo->E() < 0.3 || icalo == idMax) continue;
692 
693  Float_t tdiff = TMath::Abs(tMax-calo->GetTOF()*1e9);
694  n++;
695  if(tdiff < 25) nOK++;
696  else
697  {
698  n20++;
699  if(tdiff > 40 ) n40++;
700  }
701  }
702 
703  // Check pile-up and fill histograms depending on the different cluster multiplicities
704  if(GetReader()->IsPileUpFromSPD())
705  {
706  fhClusterMultSPDPileUp[0]->Fill(ptMax, n , GetEventWeight());
707  fhClusterMultSPDPileUp[1]->Fill(ptMax, nOK, GetEventWeight());
708  fhClusterMultSPDPileUp[2]->Fill(ptMax, n20, GetEventWeight());
709  fhClusterMultSPDPileUp[3]->Fill(ptMax, n40, GetEventWeight());
710  }
711  else
712  {
713  fhClusterMultNoPileUp[0]->Fill(ptMax, n , GetEventWeight());
714  fhClusterMultNoPileUp[1]->Fill(ptMax, nOK, GetEventWeight());
715  fhClusterMultNoPileUp[2]->Fill(ptMax, n20, GetEventWeight());
716  fhClusterMultNoPileUp[3]->Fill(ptMax, n40, GetEventWeight());
717  }
718 
719  AliDebug(1,"End fill histograms");
720 }
721 
722 
723 
724 //_________________________________________________________
726 //_________________________________________________________
727 void AliAnaClusterPileUp::Print(const Option_t * opt) const
728 {
729  if(! opt)
730  return;
731 
732  printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
734 
735  printf("Calorimeter = %s\n", GetCalorimeterString().Data()) ;
736  printf(" \n") ;
737 }
Bool_t IsPileUpFromSPD() const
Float_t GetHistoPtMax() const
TH2F * fhLambda0PileUp[7]
! E vs M02 distribution of clusters, before any selection
Float_t GetHistoPtMin() const
double Double_t
Definition: External.C:58
Int_t GetHistoShowerShapeBins() const
virtual void AddToHistogramsName(TString add)
virtual AliVCaloCells * GetEMCALCells() const
AliAnaClusterPileUp()
Default constructor. Initialize parameters.
Definition: External.C:236
const char * title
Definition: MakeQAPdf.C:26
AliEMCALRecoUtils * GetEMCALRecoUtils() const
virtual void GetVertex(Double_t vertex[3]) const
TH2F * fhPtNPileUpTrkVtx
! Cluster pt vs number of track pile-up vertices
TH2F * fhPtNPileUpSPDVtxTimeCut
! Cluster pt vs number of spd pile-up vertices, time cut +-25 ns
virtual AliVEvent * GetInputEvent() const
Bool_t IsPileUpFromSPDAndNotEMCal() const
Check if event is from pile-up determined by SPD and not by EMCal.
virtual Bool_t IsTrackMatched(AliVCluster *cluster, AliVEvent *event)
TH2F * fhTimePileUpMainVertexZDiamond
! Time of cluster vs difference of z diamond and pile-up vertex
Int_t GetHistoPhiBins() const
TH2F * fhTimeNPileUpVertContributors
! Time of cluster vs n pile-up vertex from SPD contributors
Bool_t IsPileUpFromNotSPDAndNotEMCal() const
Check if event not from pile-up determined neither by SPD nor by EMCal.
TObjString * GetAnalysisCuts()
Save parameters used for analysis.
Float_t GetHistoPhiMin() const
Bool_t IsPileUpFromSPDOrEMCal() const
Check if event is from pile-up determined by SPD or EMCal.
TH2F * fhTimePtNoCut
! Time of cluster vs Pt, no cut
Bool_t IsPileUpFromEMCalAndNotSPD() const
Check if event is from pile-up determined by EMCal, not by SPD.
TH2F * fhClusterTimeDiffNeutralPileUp[7]
! E vs Time difference inside cluster for track matched clusters
const Double_t etamin
TH2F * fhTimePileUpMainVertexZDistance
! Time of cluster vs difference of z main vertex and pile-up vertex
TH2F * fhLambda0NeutralPileUp[7]
! E vs M02 distribution of clusters, track matched clusters
TH2F * fhTimeNPileUpVertSPD
! Time of cluster vs n pile-up vertices from SPD
Base class for CaloTrackCorr analysis algorithms.
virtual TString GetCalorimeterString() const
TH2F * fhEtaPhiBCPlusPileUpSPD
! eta/phi of clusters in BC>0, SPD pile-up
virtual AliFiducialCut * GetFiducialCut()
TH2F * fhClusterCellTimePileUp[7]
! E vs Time inside cluster, before any selection, not max cell
int Int_t
Definition: External.C:63
TLorentzVector fMomentum
! Cluster momentum
virtual AliHistogramRanges * GetHistogramRanges()
float Float_t
Definition: External.C:68
TH2F * fhPtNPileUpTrkVtxTimeCut
! Cluster pt vs number of track pile-up vertices, time cut +- 25 ns
Fill histograms for cluster spectra dependence on pile-up.
Bool_t IsInFiducialCut(Float_t eta, Float_t phi, Int_t det) const
TH2F * fhEtaPhiBC0
! eta/phi of clusters in BC=0
TH2F * fhEtaPhiBC0PileUpSPD
! eta/phi of clusters in BC=0, SPD pile-up
Float_t GetHistoShowerShapeMin() const
virtual AliCalorimeterUtils * GetCaloUtils() const
void InitParameters()
Initialize the parameters of the analysis.
const Double_t ptmin
virtual Double_t GetEventWeight() const
TH2F * fhPtNPileUpSPDVtxTimeCut2
! Cluster pt vs number of spd pile-up vertices, time cut +-75 ns
virtual TObjArray * GetPHOSClusters() const
TH2F * fhEtaPhiBCMinus
! eta/phi of clusters in BC<0
TH2F * fhPtNPileUpTrkVtxTimeCut2
! Cluster pt vs number of track pile-up vertices, time cut +- 75 ns
Float_t GetHistoEtaMin() const
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)
void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
Int_t fNCellsCut
Accept for the analysis clusters with more than fNCellsCut cells.
TH2F * fhTimePtSPD
! Time of cluster vs Pt, IsSPDPileUp
Float_t GetHistoEtaMax() const
TH1F * fhPtNeutralPileUp[7]
! pT distribution of track matched clusters
Int_t GetHistoPtBins() const
TH1F * fhPtPileUp[7]
! pT distribution of clusters before any selection
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TH2F * fhTimeNPileUpVertTrack
! Time of cluster vs n pile-up vertices from Tracks
const Double_t etamax
TH2F * fhEtaPhiBCPlus
! eta/phi of clusters in BC>0
Bool_t IsInTimeWindow(Double_t tof, Float_t energy) const
TH2F * fhPtNPileUpSPDVtx
! Cluster pt vs number of spd pile-up vertices
virtual void Print(const Option_t *) const
Print some relevant parameters set for the analysis.
Int_t GetHistoTimeBins() const
const char Option_t
Definition: External.C:48
Float_t GetHistoTimeMax() const
virtual Int_t GetDataType() const
Float_t GetHistoTimeMin() const
Float_t GetHistoShowerShapeMax() const
Bool_t IsPileUpFromEMCal() const
Check if event is from pile-up determined by EMCal.
Float_t GetHistoPhiMax() const
bool Bool_t
Definition: External.C:53
virtual AliCaloTrackReader * GetReader() const
Int_t GetHistoEtaBins() const
Double_t ptMax
TH2F * fhClusterTimeDiffPileUp[7]
! E vs Time difference inside cluster, before any selection
virtual TObjArray * GetEMCALClusters() const
TH2F * fhClusterMultSPDPileUp[4]
! E max cluster vs event cluster multiplicity, for tmax-tdiff cuts, pile up event ...
TH2F * fhEtaPhiBCMinusPileUpSPD
! eta/phi of clusters in BC<0, SPD pile-up
virtual AliVCaloCells * GetPHOSCells() const
TH2F * fhClusterMultNoPileUp[4]
! E max cluster vs event cluster multiplicity, for tmax-tdiff cuts, not pile up event ...
Int_t GetMaxEnergyCell(AliVCaloCells *cells, AliVCluster *clu, Float_t &fraction) const
For a given CaloCluster, it gets the absId of the cell with maximum energy deposit.
Int_t nptbins
TH2F * fhClusterEFracLongTimePileUp[7]
! E vs fraction of cluster energy from cells with large time
const Double_t phimin
Bool_t IsPileUpFromSPDAndEMCal() const
Check if event is from pile-up determined by SPD and EMCal.