AliPhysics  c923f52 (c923f52)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskChargedParticlesRef.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2015, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <algorithm>
16 #include <array>
17 #include <functional>
18 #include <iostream>
19 #include <map>
20 
21 #include <TArrayD.h>
22 #include <TMath.h>
23 #include <TGrid.h>
24 #include <THashList.h>
25 #include <THistManager.h>
26 #include <TLinearBinning.h>
27 #include <TObjArray.h>
28 #include <TParameter.h>
29 
30 #include "AliAnalysisUtils.h"
31 #include "AliAODInputHandler.h"
32 #include "AliAODTrack.h"
34 #include "AliEMCALGeometry.h"
35 #include "AliEMCALRecoUtils.h"
36 #include "AliEMCALTriggerPatchInfo.h"
37 #include "AliEmcalTrackSelection.h"
39 #include "AliESDtrackCuts.h"
40 #include "AliESDEvent.h"
41 #include "AliInputEventHandler.h"
42 #include "AliOADBContainer.h"
43 #include "AliPIDResponse.h"
44 #include "AliTOFPIDResponse.h"
45 #include "AliVVertex.h"
46 
49 
53 
54 namespace EMCalTriggerPtAnalysis {
55 
59 AliAnalysisTaskChargedParticlesRef::AliAnalysisTaskChargedParticlesRef() :
61  fTrackCuts(nullptr),
62  fAnalysisUtil(nullptr),
63  fTriggerSelection(nullptr),
64  fHistos(nullptr),
65  fGeometry(nullptr),
66  fTriggerPatches(nullptr),
67  fTriggerStringFromPatches(kFALSE),
68  fYshift(0.465),
69  fEtaSign(1),
70  fEtaLabCut(-0.5, 0.5),
71  fEtaCmsCut(-0.13, 0.13),
72  fPhiCut(0., TMath::TwoPi()),
73  fKineCorrelation(false),
74  fStudyPID(false),
75  fNameDownscaleOADB(""),
76  fDownscaleOADB(nullptr),
77  fDownscaleFactors(nullptr),
78  fNameMaskedFastorOADB(),
79  fMaskedFastorOADB(nullptr),
80  fMaskedFastors(),
81  fSelectNoiseEvents(false),
82  fRejectNoiseEvents(false),
83  fUseOnlineTriggerSelectorV1(false),
84  fCurrentRun(-1),
85  fLocalInitialized(false)
86 {
87  // Restrict analysis to the EMCAL acceptance
88 }
89 
95  AliAnalysisTaskSE(name),
96  fTrackCuts(nullptr),
97  fAnalysisUtil(nullptr),
98  fTriggerSelection(nullptr),
99  fHistos(nullptr),
100  fGeometry(nullptr),
101  fTriggerPatches(nullptr),
102  fTriggerStringFromPatches(kFALSE),
103  fYshift(0.465),
104  fEtaSign(1),
105  fEtaLabCut(-0.5, 0.5),
106  fEtaCmsCut(-0.13, 0.13),
107  fPhiCut(0., TMath::TwoPi()),
108  fKineCorrelation(false),
109  fStudyPID(false),
110  fNameDownscaleOADB(""),
111  fDownscaleOADB(nullptr),
112  fDownscaleFactors(nullptr),
113  fNameMaskedFastorOADB(),
114  fMaskedFastorOADB(nullptr),
115  fMaskedFastors(),
116  fSelectNoiseEvents(false),
117  fRejectNoiseEvents(false),
118  fUseOnlineTriggerSelectorV1(false),
119  fCurrentRun(-1),
120  fLocalInitialized(false)
121 {
122  // Restrict analysis to the EMCAL acceptance
123  DefineOutput(1, TList::Class());
124 }
125 
130  //if(fTrackCuts) delete fTrackCuts;
131  if(fAnalysisUtil) delete fAnalysisUtil;
133  if(fHistos) delete fHistos;
134  if(fDownscaleOADB) delete fDownscaleOADB;
135 }
136 
141  fAnalysisUtil = new AliAnalysisUtils;
142 
143  if(!fTrackCuts) InitializeTrackCuts("standard", fInputHandler->IsA() == AliAODInputHandler::Class());
144 
145  NewPtBinning newbinning;
146 
147  fHistos = new THistManager("Ref");
148  // Exclusive means classes without lower trigger classes (which are downscaled) - in order to make samples statistically independent:
149  // MBExcl means MinBias && !EMCAL trigger
150  std::array<TString, 11> triggers = {
151  "MB", "EMC7",
152  "EJ1", "EJ2", "EG1", "EG2",
153  "EMC7excl", "EG1excl", "EG2excl", "EJ1excl", "EJ2excl"
154  };
155  std::array<Double_t, 5> ptcuts = {1., 2., 5., 10., 20.};
156  // Binning for the PID histogram
157  const int kdimPID = 3;
158  const int knbinsPID[kdimPID] = {1000, 200, 300};
159  const double kminPID[kdimPID] = {-100., 0., 0.}, kmaxPID[kdimPID] = {100., 200., 1.5};
160  for(auto trg : triggers){
161  fHistos->CreateTH1(Form("hEventCount%s", trg.Data()), Form("Event Counter for trigger class %s", trg.Data()), 1, 0.5, 1.5);
162  fHistos->CreateTH1(Form("hVertexBefore%s", trg.Data()), Form("Vertex distribution before z-cut for trigger class %s", trg.Data()), 500, -50, 50);
163  fHistos->CreateTH1(Form("hVertexAfter%s", trg.Data()), Form("Vertex distribution after z-cut for trigger class %s", trg.Data()), 100, -10, 10);
164  fHistos->CreateTH1(Form("hPtEtaAll%s", trg.Data()), Form("Charged particle pt distribution all eta new binning trigger %s", trg.Data()), newbinning);
165  fHistos->CreateTH1(Form("hPtEtaCent%s", trg.Data()), Form("Charged particle pt distribution central eta new binning trigger %s", trg.Data()), newbinning);
166  fHistos->CreateTH1(Form("hPtEMCALEtaAll%s", trg.Data()), Form("Charged particle in EMCAL pt distribution all eta new binning trigger %s", trg.Data()), newbinning);
167  fHistos->CreateTH1(Form("hPtEMCALEtaCent%s", trg.Data()), Form("Charged particle in EMCAL pt distribution central eta new binning trigger %s", trg.Data()), newbinning);
168  fHistos->CreateTH1(Form("hPtEMCALNoTRDEtaAll%s", trg.Data()), Form("Charged particle in EMCAL (no TRD in front) pt distribution all eta new binning trigger %s", trg.Data()), newbinning);
169  fHistos->CreateTH1(Form("hPtEMCALNoTRDEtaCent%s", trg.Data()), Form("Charged particle in EMCAL (no TRD in front) pt distribution central eta new binning trigger %s", trg.Data()), newbinning);
170  fHistos->CreateTH1(Form("hPtEMCALWithTRDEtaAll%s", trg.Data()), Form("Charged particle in EMCAL (with TRD in front) pt distribution all eta new binning trigger %s", trg.Data()), newbinning);
171  fHistos->CreateTH1(Form("hPtEMCALWithTRDEtaCent%s", trg.Data()), Form("Charged particle in EMCAL (with TRD in front) pt distribution central eta new binning trigger %s", trg.Data()), newbinning);
172  if(fKineCorrelation){
173  fHistos->CreateTH3(Form("hPtEtaPhiAll%s", trg.Data()), Form("p_{t}-#eta-#phi distribution of all accepted tracks for trigger %s; p_{t} (GeV/c); #eta; #phi", trg.Data()), newbinning, TLinearBinning(64, -0.8, 0.8), TLinearBinning(100, 0., 2*TMath::Pi()));
174  fHistos->CreateTH3(Form("hPtEtaPhiEMCALAll%s", trg.Data()), Form("p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger %s; p_{t} (GeV/c); #eta; #phi", trg.Data()), newbinning, TLinearBinning(64, -0.8, 0.8), TLinearBinning(100, 0., 2*TMath::Pi()));
175  }
176  if(fStudyPID){
177  fHistos->CreateTH2(Form("hTPCdEdxEMCAL%s", trg.Data()), Form("TPC dE/dx of charged particles in the EMCAL region for trigger %s", trg.Data()), 400, -20., 20., 200, 0., 200.);
178  fHistos->CreateTH2(Form("hTOFBetaEMCAL%s", trg.Data()), Form("TOF beta of charged particles in the EMCAL region for trigger %s", trg.Data()), 400, -20., 20., 150, 0., 1.5);
179  fHistos->CreateTHnSparse(Form("hPIDcorrEMCAL%s", trg.Data()), Form("Correlation of PID observables for Trigger %s", trg.Data()), kdimPID, knbinsPID, kminPID, kmaxPID);
180  }
181  for(auto ptcut : ptcuts) {
183  Form("hEtaLabDistAllPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
184  Form("Eta (lab) distribution without etacut for tracks with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
185  100,
186  -1.,
187  1.
188  );
190  Form("hEtaLabDistCutPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
191  Form("Eta (lab) distribution with etacut for tracks with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
192  100,
193  -1.,
194  1.
195  );
197  Form("hEtaCentDistAllPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
198  Form("Eta (cent) distribution without etacut for tracks with Pt above %.1f GeV/c trigger %s",
199  ptcut, trg.Data()),
200  160,
201  -1.3,
202  1.3
203  );
205  Form("hEtaCentDistCutPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
206  Form("Eta (cent) distribution with etacut for tracks with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
207  160,
208  -1.3,
209  1.3
210  );
212  Form("hEtaLabDistAllEMCALPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
213  Form("Eta (lab) distribution without etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
214  100,
215  -1.,
216  1.
217  );
219  Form("hEtaLabDistCutEMCALPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
220  Form("Eta (lab) distribution with etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
221  100,
222  -1.,
223  1.
224  );
226  Form("hEtaCentDistAllEMCALPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
227  Form("Eta (cent) distribution without etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
228  160,
229  -1.3,
230  1.3
231  );
233  Form("hEtaCentDistCutEMCALPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
234  Form("Eta (cent) distribution with etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
235  160,
236  -1.3,
237  1.3
238  );
240  Form("hPhiDistAllPt%d%s", static_cast<Int_t>(ptcut), trg.Data()),
241  Form("#phi distribution of particles with Pt above %.1f GeV/c trigger %s", ptcut, trg.Data()),
242  300,
243  0.,
244  2*TMath::Pi()
245  );
246  }
247  }
249  PostData(1, fHistos->GetListOfHistograms());
250 }
251 
261  if(!fLocalInitialized){
262  AliInfoStream() << GetName() << ": Initializing ..." << std::endl;
263  ExecOnce();
264  fLocalInitialized = kTRUE;
265  }
266  if(InputEvent()->GetRunNumber() != fCurrentRun){
267  AliInfoStream() << GetName() << ": Changing run from " << fCurrentRun << " to " << InputEvent()->GetRunNumber() << std::endl;
268  RunChanged(InputEvent()->GetRunNumber());
269  fCurrentRun = InputEvent()->GetRunNumber();
270  }
271  Bool_t hasPIDresponse = fInputHandler->GetPIDResponse() != nullptr;
272  if(fStudyPID && !hasPIDresponse) AliErrorStream() << "PID requested but PID response not available" << std::endl;
273  // Select event
274  TString triggerstring = "";
277  } else {
278  triggerstring = fInputEvent->GetFiredTriggerClasses();
279  }
280  UInt_t selectionstatus = fInputHandler->IsEventSelected();
281  Bool_t isMinBias = selectionstatus & AliVEvent::kINT7,
282  isEJ1 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("EJ1"),
283  isEJ2 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("EJ2"),
284  isEG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG1"),
285  isEG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG2"),
286  isEMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("CEMC7");
293  }
294  // Online selection / rejection
296  std::function<bool (OnlineTrigger_t)> selector;
298  selector = [this](OnlineTrigger_t t) -> bool { return this->SelectOnlineTriggerV1(t); } ;
299  } else{
300  selector = [this](OnlineTrigger_t t) -> bool { return this->SelectOnlineTrigger(t); };
301  }
302  if(fRejectNoiseEvents){
303  if(isEJ1) isEJ1 &= selector(kCPREJ1);
304  if(isEJ2) isEJ2 &= selector(kCPREJ2);
305  if(isEG1) isEG1 &= selector(kCPREG1);
306  if(isEG2) isEG2 &= selector(kCPREG2);
307  if(isEMC7) isEMC7 &= selector(kCPREL0);
308  } else {
309  if(isEJ1) isEJ1 &= !selector(kCPREJ1);
310  if(isEJ1) isEJ2 &= !selector(kCPREJ2);
311  if(isEG1) isEG1 &= !selector(kCPREG1);
312  if(isEG2) isEG2 &= !selector(kCPREG2);
313  if(isEMC7) isEMC7 &= !selector(kCPREL0);
314  }
315  }
316  if(!(isMinBias || isEMC7 || isEG1 || isEG2 || isEJ1 || isEJ2)) return;
317  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
318  //if(!fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) return; // reject pileup event
319  if(vtx->GetNContributors() < 1) return;
320  if(fInputEvent->IsA() == AliESDEvent::Class() && fAnalysisUtil->IsFirstEventInChunk(fInputEvent)) return;
321  bool isSelected = kTRUE;
322  if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent)) isSelected = kFALSE; // Apply new vertex cut
323  if(fAnalysisUtil->IsPileUpEvent(fInputEvent)) isSelected = kFALSE; // Apply new vertex cut
324  // Apply vertex z cut
325  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) isSelected = kFALSE;
326 
327  // Fill Event counter and reference vertex distributions for the different trigger classes
328  if(isMinBias){
329  FillEventCounterHists("MB", vtx->GetZ(), isSelected);
330  }
331  if(isEMC7){
332  FillEventCounterHists("EMC7", vtx->GetZ(), isSelected);
333  if(!isMinBias){
334  FillEventCounterHists("EMC7excl", vtx->GetZ(), isSelected);
335  }
336  }
337  if(isEJ2){
338  FillEventCounterHists("EJ2", vtx->GetZ(), isSelected);
339  // Check for exclusive classes
340  if(!(isMinBias || isEMC7)){
341  FillEventCounterHists("EJ2excl", vtx->GetZ(), isSelected);
342  }
343  }
344  if(isEJ1){
345  FillEventCounterHists("EJ1", vtx->GetZ(), isSelected);
346  // Check for exclusive classes
347  if(!(isMinBias || isEMC7 || isEJ2)){
348  FillEventCounterHists("EJ1excl", vtx->GetZ(), isSelected);
349  }
350  }
351  if(isEG2){
352  FillEventCounterHists("EG2", vtx->GetZ(), isSelected);
353  // Check for exclusive classes
354  if(!(isMinBias || isEMC7)){
355  FillEventCounterHists("EG2excl", vtx->GetZ(), isSelected);
356  }
357  }
358  if(isEG1){
359  FillEventCounterHists("EG1", vtx->GetZ(), isSelected);
360  // Check for exclusive classes
361  if(!(isMinBias || isEMC7 || isEG2)){
362  FillEventCounterHists("EG1excl", vtx->GetZ(), isSelected);
363  }
364  }
365 
366  if(!isSelected) return;
367 
368  // Loop over tracks, fill select particles
369  // Histograms
370  // - Full eta_{lab} (-0.8, 0.8), new binning
371  // - Full eta_{lab} (-0.8, 0.8), old binning
372  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
373  // - Central eta_{cms} (-0.3, -0.2), new binning,
374  // - Central eta_{cms} (-0.8, -0.2), old binning,
375  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
376  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
377  AliVTrack *checktrack(nullptr);
378  int ptmin[5] = {1,2,5,10,20}; // for eta distributions
379  Bool_t isEMCAL(kFALSE), hasTRD(kFALSE);
380  Double_t etaEMCAL(0.), phiEMCAL(0.);
381  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
382  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
383  if(!checktrack) continue;
384  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
385  if(!fPhiCut.IsInRange(checktrack->Phi())) continue;
386  if(TMath::Abs(checktrack->Pt()) < 0.1) continue;
387  if(checktrack->IsA() == AliESDtrack::Class()){
388  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
389  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
390  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
391  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
392  } else {
393  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
394  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
395  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
396  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
397  }
398  Int_t supermoduleID = -1;
399  isEMCAL = fGeometry->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
400  // Exclude supermodules 10 and 11 as they did not participate in the trigger
401  isEMCAL = isEMCAL && supermoduleID < 10;
402  hasTRD = isEMCAL && supermoduleID >= 4; // supermodules 4 - 10 have TRD in front in the 2012-2013 ALICE setup
403 
404  // Calculate eta in cms frame according
405  // EPJC74 (2014) 3054:
406  // eta_cms = - eta_lab - |yshift|
407  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
408  etacent *= fEtaSign;
409 
410  Bool_t etacentcut = fEtaCmsCut.IsInRange(etacent);
411 
412  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
413 
414  // fill histograms allEta
415  if(isMinBias){
416  FillTrackHistos("MB", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
417  if(fStudyPID && hasPIDresponse)
418  if(isEMCAL) FillPIDHistos("MB", *checktrack);
419  }
420  if(isEMC7){
421  FillTrackHistos("EMC7", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
422  if(fStudyPID && hasPIDresponse)
423  if(isEMCAL) FillPIDHistos("EMC7", *checktrack);
424  if(!isMinBias){
425  FillTrackHistos("EMC7excl", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
426  if(fStudyPID && hasPIDresponse)
427  if(isEMCAL) FillPIDHistos("EMC7excl", *checktrack);
428  }
429  }
430  if(isEJ2){
431  FillTrackHistos("EJ2", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
432  if(fStudyPID && hasPIDresponse)
433  if(isEMCAL) FillPIDHistos("EJ2", *checktrack);
434  // check for exclusive classes
435  if(!(isMinBias || isEMC7)){
436  FillTrackHistos("EJ2excl", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
437  if(fStudyPID && hasPIDresponse)
438  if(isEMCAL) FillPIDHistos("EJ2excl", *checktrack);
439  }
440  }
441  if(isEJ1){
442  FillTrackHistos("EJ1", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
443  if(fStudyPID && hasPIDresponse)
444  if(isEMCAL) FillPIDHistos("EJ1", *checktrack);
445  // check for exclusive classes
446  if(!(isMinBias ||isEMC7 || isEJ2)){
447  FillTrackHistos("EJ1excl", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
448  if(fStudyPID && hasPIDresponse)
449  if(isEMCAL) FillPIDHistos("EJ1excl", *checktrack);
450  }
451  }
452  if(isEG2){
453  FillTrackHistos("EG2", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
454  if(fStudyPID && hasPIDresponse)
455  if(isEMCAL) FillPIDHistos("EG2", *checktrack);
456  // check for exclusive classes
457  if(!(isMinBias || isEMC7)){
458  FillTrackHistos("EG2excl", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
459  if(fStudyPID && hasPIDresponse)
460  if(isEMCAL) FillPIDHistos("EG2excl", *checktrack);
461  }
462  }
463  if(isEG1){
464  FillTrackHistos("EG1", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
465  if(fStudyPID && hasPIDresponse)
466  if(isEMCAL) FillPIDHistos("EG1", *checktrack);
467  if(!(isMinBias || isEMC7 || isEG2)){
468  FillTrackHistos("EG1excl", checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD);
469  if(fStudyPID && hasPIDresponse)
470  if(isEMCAL) FillPIDHistos("EG1excl", *checktrack);
471  }
472  }
473  }
474  PostData(1, fHistos->GetListOfHistograms());
475 }
476 
484  const std::string &triggerclass,
485  double vtxz,
486  bool isSelected
487 )
488 {
489  Double_t weight = GetTriggerWeight(triggerclass);
490  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << triggerclass << " in event histograms." << std::endl;
491  // Fill reference distribution for the primary vertex before any z-cut
492  fHistos->FillTH1(Form("hVertexBefore%s", triggerclass.c_str()), vtxz, weight);
493  if(isSelected){
494  // Fill Event counter and reference vertex distributions after event selection
495  fHistos->FillTH1(Form("hEventCount%s", triggerclass.c_str()), 1, weight);
496  fHistos->FillTH1(Form("hVertexAfter%s", triggerclass.c_str()), vtxz, weight);
497  }
498 }
499 
507  // Handle geometry
508  if(!fGeometry){
509  fGeometry = AliEMCALGeometry::GetInstance();
510  if(!fGeometry)
511  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
512  }
513  fTriggerPatches = static_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
514  // Handle OADB container with downscaling factors
515  if(fNameDownscaleOADB.Length()){
516  if(fNameDownscaleOADB.Contains("alien://") && ! gGrid) TGrid::Connect("alien://");
517  fDownscaleOADB = new AliOADBContainer("AliEmcalDownscaleFactors");
518  fDownscaleOADB->InitFromFile(fNameDownscaleOADB.Data(), "AliEmcalDownscaleFactors");
519  }
520  // Load OADB container with masked fastors (in case fastor masking is switched on)
522  if(fNameMaskedFastorOADB.Contains("alien://") && ! gGrid) TGrid::Connect("alien://");
523  fMaskedFastorOADB = new AliOADBContainer("AliEmcalMaskedFastors");
524  fMaskedFastorOADB->InitFromFile(fNameMaskedFastorOADB.Data(), "AliEmcalMaskedFastors");
525  }
526 }
527 
536  if(fDownscaleOADB){
537  fDownscaleFactors = static_cast<TObjArray *>(fDownscaleOADB->GetObject(runnumber));
538  }
539  if(fMaskedFastorOADB){
540  fMaskedFastors.clear();
541  TObjArray *ids = static_cast<TObjArray *>(fMaskedFastorOADB->GetObject(runnumber));
542  for(auto m : *ids){
543  TParameter<int> *id = static_cast<TParameter<int> *>(m);
544  fMaskedFastors.push_back(id->GetVal());
545  }
546  }
547 }
548 
560  const std::string &eventclass,
561  Double_t pt,
562  Double_t etalab,
563  Double_t etacent,
564  Double_t phi,
565  Bool_t etacut,
566  Bool_t inEmcal,
567  Bool_t hasTRD
568  )
569 {
570  Double_t weight = GetTriggerWeight(eventclass);
571  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in particle histograms." << std::endl;
572  fHistos->FillTH1(Form("hPtEtaAll%s", eventclass.c_str()), TMath::Abs(pt), weight);
573  double kinepoint[3] = {TMath::Abs(pt), etalab, phi};
574  if(fKineCorrelation) fHistos->FillTH3(Form("hPtEtaPhiAll%s", eventclass.c_str()),kinepoint , weight);
575  if(inEmcal){
576  fHistos->FillTH1(Form("hPtEMCALEtaAll%s", eventclass.c_str()), TMath::Abs(pt), weight);
577  if(fKineCorrelation) fHistos->FillTH3(Form("hPtEtaPhiEMCALAll%s", eventclass.c_str()), kinepoint, weight);
578  if(hasTRD){
579  fHistos->FillTH1(Form("hPtEMCALWithTRDEtaAll%s", eventclass.c_str()), TMath::Abs(pt), weight);
580  } else {
581  fHistos->FillTH1(Form("hPtEMCALNoTRDEtaAll%s", eventclass.c_str()), TMath::Abs(pt), weight);
582  }
583  }
584 
585  std::array<int, 5> ptmin = {1,2,5,10,20}; // for eta distributions
586  for(auto ptmincut : ptmin){
587  if(TMath::Abs(pt) > static_cast<double>(ptmincut)){
588  fHistos->FillTH1(Form("hPhiDistAllPt%d%s", ptmincut, eventclass.c_str()), phi, weight);
589  fHistos->FillTH1(Form("hEtaLabDistAllPt%d%s", ptmincut, eventclass.c_str()), etalab, weight);
590  fHistos->FillTH1(Form("hEtaCentDistAllPt%d%s", ptmincut, eventclass.c_str()), etacent, weight);
591  if(inEmcal){
592  fHistos->FillTH1(Form("hEtaLabDistAllEMCALPt%d%s", ptmincut, eventclass.c_str()), etalab, weight);
593  fHistos->FillTH1(Form("hEtaCentDistAllEMCALPt%d%s", ptmincut, eventclass.c_str()), etacent, weight);
594  }
595  }
596  }
597 
598  if(etacut){
599  fHistos->FillTH1(Form("hPtEtaCent%s", eventclass.c_str()), TMath::Abs(pt), weight);
600  if(inEmcal){
601  fHistos->FillTH1(Form("hPtEMCALEtaCent%s", eventclass.c_str()), TMath::Abs(pt), weight);
602  if(hasTRD){
603  fHistos->FillTH1(Form("hPtEMCALWithTRDEtaCent%s", eventclass.c_str()), TMath::Abs(pt), weight);
604  } else {
605  fHistos->FillTH1(Form("hPtEMCALNoTRDEtaCent%s", eventclass.c_str()), TMath::Abs(pt), weight);
606  }
607  }
608  for(auto ptmincut : ptmin){
609  if(TMath::Abs(pt) > static_cast<double>(ptmincut)){
610  fHistos->FillTH1(Form("hEtaLabDistCutPt%d%s", ptmincut, eventclass.c_str()), etalab, weight);
611  fHistos->FillTH1(Form("hEtaCentDistCutPt%d%s", ptmincut, eventclass.c_str()), etacent, weight);
612  if(inEmcal){
613  fHistos->FillTH1(Form("hEtaLabDistCutEMCALPt%d%s", ptmincut, eventclass.c_str()), etalab, weight);
614  fHistos->FillTH1(Form("hEtaCentDistCutEMCALPt%d%s", ptmincut, eventclass.c_str()), etacent, weight);
615  }
616  }
617  }
618  }
619 }
620 
622  const std::string &eventclass,
623  const AliVTrack &trk
624 ) {
625  Double_t weight = GetTriggerWeight(eventclass);
626  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in PID histograms." << std::endl;
627  AliPIDResponse *pid = fInputHandler->GetPIDResponse();
628  if(TMath::Abs(trk.Eta()) > 0.5) return;
629  if(!((trk.GetStatus() & AliVTrack::kTOFout) && (trk.GetStatus() & AliVTrack::kTIME))) return;
630 
631  double poverz = TMath::Abs(trk.P())/static_cast<double>(trk.Charge());
632  fHistos->FillTH2(Form("hTPCdEdxEMCAL%s", eventclass.c_str()), poverz, trk.GetTPCsignal(), weight);
633  // correct for units - TOF in ps, track length in cm
634  Double_t trtime = (trk.GetTOFsignal() - pid->GetTOFResponse().GetTimeZero()) * 1e-12;
635  Double_t v = trk.GetIntegratedLength()/(100. * trtime);
636  Double_t beta = v / TMath::C();
637  fHistos->FillTH2(Form("hTOFBetaEMCAL%s", eventclass.c_str()), poverz, beta, weight);
638  double datapoint[3] = {poverz, trk.GetTPCsignal(), beta};
639  fHistos->FillTHnSparse(Form("hPIDcorrEMCAL%s", eventclass.c_str()), datapoint, weight);
640 }
641 
648  AliDebugStream(1) << "Using nominal online trigger selector" << std::endl;
649  int ngood(0);
650  const int kEJ1threshold = 223, kEJ2threshold = 140;
651  std::function<bool(const AliEMCALTriggerPatchInfo *)> PatchSelector[5] = {
652  [](const AliEMCALTriggerPatchInfo * patch) -> bool {
653  return patch->IsGammaHigh();
654  },
655  [](const AliEMCALTriggerPatchInfo * patch) -> bool {
656  return patch->IsGammaLow();
657  },
658  [kEJ1threshold](const AliEMCALTriggerPatchInfo * patch) -> bool {
659  return patch->IsJetLowRecalc() && patch->GetADCAmp() > kEJ1threshold;
660  },
661  [kEJ2threshold](const AliEMCALTriggerPatchInfo * patch) -> bool {
662  return patch->IsJetLowRecalc() && patch->GetADCAmp() > kEJ1threshold;
663  },
664  [](const AliEMCALTriggerPatchInfo * patch) -> bool {
665  return patch->IsLevel0();
666  }
667  };
668  for(auto p : *fTriggerPatches){
669  AliEMCALTriggerPatchInfo *patch = static_cast<AliEMCALTriggerPatchInfo *>(p);
670  if(PatchSelector[trg](patch)){
671  bool patchMasked(false);
672  for(int icol = patch->GetColStart(); icol < patch->GetColStart() + patch->GetPatchSize(); icol++){
673  for(int irow = patch->GetRowStart(); irow < patch->GetRowStart() + patch->GetPatchSize(); irow++){
674  int fastorAbs(-1);
675  fGeometry->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, fastorAbs);
676  if(std::find(fMaskedFastors.begin(), fMaskedFastors.end(), fastorAbs) != fMaskedFastors.end()){
677  patchMasked = true;
678  break;
679  }
680  }
681  }
682  if(!patchMasked) ngood++;
683  }
684  }
685  return ngood > 0;
686 }
687 
696  AliDebugStream(1) << "Using V1 online trigger selector" << std::endl;
697  if(trigger == kCPREL0) return true;
698  double onlinethresholds[5] = {140., 89., 260., 127., 0.};
699  int ngood(0);
700  for(auto p : *fTriggerPatches){
701  AliEMCALTriggerPatchInfo *patch = static_cast<AliEMCALTriggerPatchInfo *>(p);
702  if(((trigger == kCPREG1 || trigger == kCPREG2) && patch->IsGammaLowRecalc()) ||
703  ((trigger == kCPREJ1 || trigger == kCPREJ2) && patch->IsJetLowRecalc())){
704  if(patch->GetADCAmp() > onlinethresholds[trigger]) ngood++;
705  }
706  }
707  return ngood > 0;
708 }
709 
718 Double_t AliAnalysisTaskChargedParticlesRef::GetTriggerWeight(const std::string &triggerclass) const {
719  if(fDownscaleFactors){
720  TParameter<double> *result(nullptr);
721  // Downscaling only done on MB, L0 and the low threshold triggers
722  if(triggerclass.find("MB") != std::string::npos) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("INT7"));
723  else if(triggerclass.find("EMC7") != std::string::npos) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("EMC7"));
724  else if(triggerclass.find("EJ2") != std::string::npos) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("EJ2"));
725  else if(triggerclass.find("EG2") != std::string::npos) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("EG2"));
726  if(result) return 1./result->GetVal();
727  }
728  return 1.;
729 }
730 
738 }
739 
746  TString triggerstring = "";
747  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
748  double minADC_EJ1 = 260.,
749  minADC_EJ2 = 127.,
750  minADC_EG1 = 140.,
751  minADC_EG2 = 89.;
752  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
753  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(*patchIter);
754  if(!patch->IsOfflineSimple()) continue;
755  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
756  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
757  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
758  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
759  }
760  if(nEJ1) triggerstring += "EJ1";
761  if(nEJ2){
762  if(triggerstring.Length()) triggerstring += ",";
763  triggerstring += "EJ2";
764  }
765  if(nEG1){
766  if(triggerstring.Length()) triggerstring += ",";
767  triggerstring += "EG1";
768  }
769  if(nEG2){
770  if(triggerstring.Length()) triggerstring += ",";
771  triggerstring += "EG2";
772  }
773  return triggerstring;
774 }
775 
782 {
783  this->SetMinimum(0.);
784  this->AddStep(1, 0.05);
785  this->AddStep(2, 0.1);
786  this->AddStep(4, 0.2);
787  this->AddStep(7, 0.5);
788  this->AddStep(16, 1);
789  this->AddStep(36, 2);
790  this->AddStep(40, 4);
791  this->AddStep(50, 5);
792  this->AddStep(100, 10);
793  this->AddStep(200, 20);
794 }
795 
796 } /* namespace EMCalTriggerPtAnalysis */
Bool_t fSelectNoiseEvents
Explicitly select events triggered only by noisy fastors.
Bool_t fUseOnlineTriggerSelectorV1
Switch separating between different trigger selection methods.
TString fNameMaskedFastorOADB
Name of the masked fastor OADB container.
double Double_t
Definition: External.C:58
Double_t fEtaSign
Sign of the eta distribution (swaps when beam directions swap): p-Pb: +1, Pb-p: -1.
AliEmcalTriggerOfflineSelection * fTriggerSelection
Offline trigger selection.
AliEmcalTrackSelection * fTrackCuts
Standard track selection.
Class creating a linear binning, used in the histogram manager.
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
AliOADBContainer * fMaskedFastorOADB
! Container with masked fastors
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
void FillTH3(const char *hname, double x, double y, double z, double weight=1., Option_t *opt="")
void AddStep(Double_t max, Double_t binwidth)
AliOADBContainer * fDownscaleOADB
! Container with downscale factors for different triggers
TString GetFiredTriggerClassesFromPatches(const TClonesArray *triggerpatches) const
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
Bool_t fTriggerStringFromPatches
Do rebuild the trigger string from trigger patches.
void FillPIDHistos(const std::string &eventclass, const AliVTrack &track)
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Helper class creating user defined custom binning.
const Double_t ptmin
void FillEventCounterHists(const std::string &triggerclass, double vtxz, bool isSelected)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Declaration of class AliEMCalTriggerExtraCuts.
Bool_t IsOfflineSelected(EmcalTriggerClass trgcls, const TClonesArray *const triggerpatches) const
Bool_t fRejectNoiseEvents
Reject events triggered by noisy fastors.
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
const char Option_t
Definition: External.C:48
void FillTrackHistos(const std::string &eventclass, Double_t pt, Double_t eta, Double_t etacent, Double_t phi, Bool_t etacut, Bool_t inEmcal, Bool_t hasTRD)
bool Bool_t
Definition: External.C:53
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
ClassImp(AliAnalysisTaskCascadeTester) AliAnalysisTaskCascadeTester
TH3 * CreateTH3(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, int nbinsz, double zmin, double zmax, Option_t *opt="")
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
void SetMinimum(Double_t min)