AliPhysics  9fe175b (9fe175b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalClustersRef.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 <array>
16 #include <bitset>
17 #include <iostream>
18 #include <map>
19 #include <sstream>
20 #include <vector>
21 
22 #include <TArrayD.h>
23 #include <TClonesArray.h>
24 #include <TGrid.h>
25 #include <THashList.h>
26 #include <THistManager.h>
27 #include <TLinearBinning.h>
28 #include <TLorentzVector.h>
29 #include <TObjArray.h>
30 #include <TParameter.h>
31 #include <TMath.h>
32 
33 #include "AliAnalysisUtils.h"
34 #include "AliCentrality.h"
35 #include "AliEMCALGeometry.h"
36 #include "AliEMCALTriggerPatchInfo.h"
38 #include "AliESDEvent.h"
39 #include "AliInputEventHandler.h"
40 #include "AliLog.h"
41 #include "AliOADBContainer.h"
42 #include "AliVCluster.h"
43 #include "AliVVertex.h"
44 #include "AliMultSelection.h"
45 #include "AliMultEstimator.h"
46 
48 
52 
53 namespace EMCalTriggerPtAnalysis {
54 
58 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef() :
59  AliAnalysisTaskSE(),
60  fAnalysisUtil(nullptr),
61  fTriggerSelection(nullptr),
62  fHistos(nullptr),
63  fGeometry(nullptr),
64  fTriggerPatches(nullptr),
65  fClusterContainer(""),
66  fRequestAnalysisUtil(kTRUE),
67  fTriggerStringFromPatches(kFALSE),
68  fCentralityRange(-999., 999.),
69  fVertexRange(-999., 999.),
70  fRequestCentrality(false),
71  fNameDownscaleOADB(""),
72  fDownscaleOADB(nullptr),
73  fDownscaleFactors(nullptr),
74  fCurrentRun(-1),
75  fInitialized(false)
76 {
77 }
78 
84  AliAnalysisTaskSE(name),
85  fAnalysisUtil(),
86  fTriggerSelection(nullptr),
87  fHistos(nullptr),
88  fGeometry(nullptr),
89  fTriggerPatches(nullptr),
90  fClusterContainer(""),
91  fRequestAnalysisUtil(kTRUE),
92  fTriggerStringFromPatches(kFALSE),
93  fCentralityRange(-999., 999.),
94  fVertexRange(-999., 999.),
95  fRequestCentrality(false),
96  fNameDownscaleOADB(""),
97  fDownscaleOADB(nullptr),
98  fDownscaleFactors(nullptr),
99  fCurrentRun(-1),
100  fInitialized(false)
101 {
102  DefineOutput(1, TList::Class());
103 }
104 
110 }
111 
116  AliInfoStream() << "Creating histograms for task " << GetName() << std::endl;
117  fAnalysisUtil = new AliAnalysisUtils;
118 
119  EnergyBinning energybinning;
120  TLinearBinning smbinning(21, -0.5, 20.5), etabinning(100, -0.7, 0.7);
121 
122  fHistos = new THistManager("Ref");
123  /*
124  * Exclusive classes are defined as triggered events
125  * in a class without lower threshold classes firing.
126  * This is needed to make the triggers statistically
127  * independent.
128  */
129  std::array<TString, 21> triggers = {
130  "MB", "EMC7", "DMC7",
131  "EJ1", "EJ2", "EG1", "EG2", "DJ1", "DJ2", "DG1", "DG2",
132  "EMC7excl", "DMC7excl", "EG2excl", "EJ2excl", "DG2excl", "DJ2excl",
133  "EJ1excl", "DJ1excl", "EG1excl", "DG1excl"
134  };
135  std::array<Double_t, 5> encuts = {1., 2., 5., 10., 20.};
136  Int_t sectorsWithEMCAL[10] = {4, 5, 6, 7, 8, 9, 13, 14, 15, 16};
137  for(auto trg : triggers){
138  fHistos->CreateTH1(Form("hEventCount%s", trg.Data()), Form("Event count for trigger class %s", trg.Data()), 1, 0.5, 1.5);
139  fHistos->CreateTH1(Form("hEventCentrality%s", trg.Data()), Form("Event centrality for trigger class %s", trg.Data()), 103, -2., 101.);
140  fHistos->CreateTH1(Form("hVertexZ%s", trg.Data()), Form("z-position of the primary vertex for trigger class %s", trg.Data()), 200, -40., 40.);
141  fHistos->CreateTH1(Form("hClusterEnergy%s", trg.Data()), Form("Cluster energy for trigger class %s", trg.Data()), energybinning);
142  fHistos->CreateTH1(Form("hClusterET%s", trg.Data()), Form("Cluster transverse energy for trigger class %s", trg.Data()), energybinning);
143  fHistos->CreateTH1(Form("hClusterEnergyFired%s", trg.Data()), Form("Cluster energy for trigger class %s, firing the trigger", trg.Data()), energybinning);
144  fHistos->CreateTH1(Form("hClusterETFired%s", trg.Data()), Form("Cluster transverse energy for trigger class %s, firing the trigger", trg.Data()), energybinning);
145  fHistos->CreateTH2(Form("hClusterEnergySM%s", trg.Data()), Form("Cluster energy versus supermodule for trigger class %s", trg.Data()), smbinning, energybinning);
146  fHistos->CreateTH2(Form("hClusterETSM%s", trg.Data()), Form("Cluster transverse energy versus supermodule for trigger class %s", trg.Data()), smbinning, energybinning);
147  fHistos->CreateTH2(Form("hClusterEnergyFiredSM%s", trg.Data()), Form("Cluster energy versus supermodule for trigger class %s, firing the trigger", trg.Data()), smbinning, energybinning);
148  fHistos->CreateTH2(Form("hClusterETFiredSM%s", trg.Data()), Form("Cluster transverse energy versus supermodule for trigger class %s, firing the trigger", trg.Data()), smbinning, energybinning);
149  fHistos->CreateTH2(Form("hEtaEnergy%s", trg.Data()), Form("Cluster energy vs. eta for trigger class %s", trg.Data()), etabinning, energybinning);
150  fHistos->CreateTH2(Form("hEtaET%s", trg.Data()), Form("Cluster transverse energy vs. eta for trigger class %s", trg.Data()), etabinning, energybinning);
151  fHistos->CreateTH2(Form("hEtaEnergyFired%s", trg.Data()), Form("Cluster energy vs. eta for trigger class %s, firing the trigger", trg.Data()), etabinning, energybinning);
152  fHistos->CreateTH2(Form("hEtaETFired%s", trg.Data()), Form("Cluster transverse energy vs. eta for trigger class %s, firing the trigger", trg.Data()), etabinning, energybinning);
153  for(int ism = 0; ism < 20; ism++){
154  fHistos->CreateTH2(Form("hEtaEnergySM%d%s", ism, trg.Data()), Form("Cluster energy vs. eta in Supermodule %d for trigger %s", ism, trg.Data()), etabinning, energybinning);
155  fHistos->CreateTH2(Form("hEtaETSM%d%s", ism, trg.Data()), Form("Cluster transverse energy vs. eta in Supermodule %d for trigger %s", ism, trg.Data()), etabinning, energybinning);
156  fHistos->CreateTH2(Form("hEtaEnergyFiredSM%d%s", ism, trg.Data()), Form("Cluster energy vs. eta in Supermodule %d for trigger %s, firing the trigger", ism, trg.Data()), etabinning, energybinning);
157  fHistos->CreateTH2(Form("hEtaETFiredSM%d%s", ism, trg.Data()), Form("Cluster transverse energy vs. eta in Supermodule %d for trigger %s, firing the trigger", ism, trg.Data()), etabinning, energybinning);
158  }
159  for(int isec = 0; isec < 10; isec++){
160  fHistos->CreateTH2(Form("hEtaEnergySec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster energy vs.eta in tracking sector %d for trigger %s", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
161  fHistos->CreateTH2(Form("hEtaETSec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster transverse energy vs.eta in tracking sector %d for trigger %s", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
162  fHistos->CreateTH2(Form("hEtaEnergyFiredSec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster energy vs.eta in tracking sector %d for trigger %s, firing the trigger", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
163  fHistos->CreateTH2(Form("hEtaETFiredSec%d%s", sectorsWithEMCAL[isec], trg.Data()), Form("Cluster transverse energy vs.eta in tracking sector %d for trigger %s, firing the trigger", sectorsWithEMCAL[isec], trg.Data()), etabinning, energybinning);
164  }
165  for(auto ien : encuts){
166  fHistos->CreateTH2(Form("hEtaPhi%dG%s", static_cast<int>(ien), trg.Data()), Form("cluster #eta-#phi map for clusters with energy larger than %f GeV/c for trigger class %s", ien, trg.Data()), 100, -0.7, 0.7, 200, 0, 2*TMath::Pi());
167  fHistos->CreateTH2(Form("hEtaPhiFired%dG%s", static_cast<int>(ien), trg.Data()), Form("cluster #eta-#phi map for clusters fired the trigger with energy larger than %f GeV/c for trigger class %s", ien, trg.Data()), 200, -0.7, 0.7, 200, 0, 2*TMath::Pi());
168  }
169  }
170  PostData(1, fHistos->GetListOfHistograms());
171  AliDebugStream(1) << "End creating histograms" << std::endl;
172 }
173 
174 
180  AliDebugStream(1) << GetName() << ": UserExec start" << std::endl;
181  if(!fInitialized){
182  AliInfoStream() << GetName() << ": Initializing ..." << std::endl;
183  ExecOnce();
184  fInitialized = kTRUE;
185  }
186  if(fCurrentRun != InputEvent()->GetRunNumber()){
187  AliInfoStream() << GetName() << ": Changing run from " << fCurrentRun << " to " << InputEvent()->GetRunNumber() << std::endl;
188  RunChanged(InputEvent()->GetRunNumber());
189  fCurrentRun = InputEvent()->GetRunNumber();
190  }
191 
192  TString triggerstring = "";
195  } else {
196  triggerstring = fInputEvent->GetFiredTriggerClasses();
197  }
198 
199  UInt_t selectionstatus = fInputHandler->IsEventSelected();
200  std::stringstream triggerdebug;
201  triggerdebug << "Offline bits: " << std::bitset<sizeof(UInt_t) * 8>(selectionstatus);
202  AliDebug(2, triggerdebug.str().c_str());
203  Bool_t isMinBias = selectionstatus & AliVEvent::kINT7,
204  isEJ1 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("EJ1"),
205  isEJ2 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("EJ2"),
206  isEG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG1"),
207  isEG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG2"),
208  isEMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("EMC7"),
209  isDJ1 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("DJ1"),
210  isDJ2 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("DJ2"),
211  isDG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("DG1"),
212  isDG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("DG2"),
213  isDMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("DMC7");
225  }
226  if(!(isMinBias || isEMC7 || isEG1 || isEG2 || isEJ1 || isEJ2 || isDMC7 || isDG1 || isDG2 || isDJ1 || isDJ2)){
227  AliDebugStream(1) << GetName() << ": Reject trigger" << std::endl;
228  return;
229  }
230  double centrality = -1;
231  AliDebugStream(1) << "Event selected" << std::endl;
232  if(fRequestCentrality){
233  AliMultSelection *mult = dynamic_cast<AliMultSelection *>(InputEvent()->FindListObject("MultSelection"));
234  if(!mult){
235  AliErrorStream() << GetName() << ": Centrality selection enabled but no centrality estimator found" << std::endl;
236  return;
237  }
238  if(mult->IsEventSelected()) return;
239  centrality = mult->GetEstimator("V0M")->GetPercentile();
240  AliDebugStream(1) << GetName() << ": Centrality " << centrality << std::endl;
241  if(!fCentralityRange.IsInRange(centrality)){
242  AliDebugStream(1) << GetName() << ": reject centrality: " << centrality << std::endl;
243  return;
244  } else {
245  AliDebugStream(1) << GetName() << ": select centrality " << centrality << std::endl;
246  }
247  } else {
248  AliDebugStream(1) << GetName() << ": No centrality selection applied" << std::endl;
249  }
250  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
251  if(!vtx) vtx = fInputEvent->GetPrimaryVertexSPD();
252  //if(!fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) return; // reject pileup event
253  if(vtx->GetNContributors() < 1){
254  AliDebug(1, Form("%s: Reject contributors\n", GetName()));
255  return;
256  }
257  // Fill reference distribution for the primary vertex before any z-cut
259  AliDebugStream(1) << GetName() << " : Reject analysis util" << std::endl;
260  if(fInputEvent->IsA() == AliESDEvent::Class() && fAnalysisUtil->IsFirstEventInChunk(fInputEvent)) return;
261  if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent)) return; // Apply new vertex cut
262  if(fAnalysisUtil->IsPileUpEvent(fInputEvent)) return; // Apply new vertex cut
263  }
264  // Apply vertex z cut
265  if(!fVertexRange.IsInRange(vtx->GetZ())){
266  AliDebugStream(1) << GetName() << ": Reject z[" << vtx->GetZ() << "]" << std::endl;
267  return;
268  }
269  AliDebugStream(1) << GetName() << ": Event Selected" << std::endl;
270 
271  // Fill Event counter and reference vertex distributions for the different trigger classes
272  if(isMinBias) FillEventHistograms("MB", centrality, vtx->GetZ());
273 
274  if(isEMC7){
275  FillEventHistograms("EMC7", centrality, vtx->GetZ());
276  // Check for exclusive classes
277  if(!(isMinBias)) FillEventHistograms("EMC7excl", centrality, vtx->GetZ());
278  }
279  if(isDMC7){
280  FillEventHistograms("DMC7", centrality, vtx->GetZ());
281  // Check for exclusive classes
282  if(!(isMinBias)) FillEventHistograms("DMC7excl", centrality, vtx->GetZ());
283  }
284 
285  if(isEJ2){
286  FillEventHistograms("EJ2", centrality, vtx->GetZ());
287  // Check for exclusive classes
288  if(!(isMinBias || isEMC7)) FillEventHistograms("EJ2excl", centrality, vtx->GetZ());
289  }
290  if(isDJ2){
291  FillEventHistograms("DJ2", centrality, vtx->GetZ());
292  // Check for exclusive classes
293  if(!(isMinBias || isDMC7)) FillEventHistograms("DJ2excl", centrality, vtx->GetZ());
294  }
295 
296  if(isEJ1){
297  FillEventHistograms("EJ1", centrality, vtx->GetZ());
298  // Check for exclusive classes
299  if(!(isMinBias || isEMC7 || isEJ2)) FillEventHistograms("EJ1excl", centrality, vtx->GetZ());
300  }
301 
302  if(isDJ1){
303  FillEventHistograms("DJ1", centrality, vtx->GetZ());
304  // Check for exclusive classes
305  if(!(isMinBias || isDMC7 || isDJ2)) FillEventHistograms("DJ1excl", centrality, vtx->GetZ());
306  }
307 
308  if(isEG2){
309  FillEventHistograms("EG2", centrality, vtx->GetZ());
310  // Check for exclusive classes
311  if(!(isMinBias || isEMC7)) FillEventHistograms("EG2excl", centrality, vtx->GetZ());
312  }
313  if(isDG2){
314  FillEventHistograms("DG2", centrality, vtx->GetZ());
315  // Check for exclusive classes
316  if(!(isMinBias || isDMC7)) FillEventHistograms("DG2excl", centrality, vtx->GetZ());
317  }
318 
319  if(isEG1){
320  FillEventHistograms("EG1", centrality, vtx->GetZ());
321  // Check for exclusive classes
322  if(!(isMinBias || isEMC7 || isEG1)) FillEventHistograms("EG1excl", centrality, vtx->GetZ());
323  }
324  if(isDG1){
325  FillEventHistograms("DG1", centrality, vtx->GetZ());
326  // Check for exclusive classes
327  if(!(isMinBias || isDMC7 || isDG1)) FillEventHistograms("DG1excl", centrality, vtx->GetZ());
328  }
329 
330  /*
331  TList *objects = fInputEvent->GetList();
332  for(TIter objiter = TIter(objects).Begin(); objiter != TIter::End(); ++ objiter){
333  printf("Object %s\n", (*objiter)->GetName());
334  }
335  */
336 
337  TObjArray clusterEvent(1000);
338 
339  TCollection *clusterArray = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject(fClusterContainer.Data()));
340  if(!clusterArray){
341  AliError(Form("Cluster array with name %s not found in the event", fClusterContainer.Data()));
342  for(int icl = 0; icl < fInputEvent->GetNumberOfCaloClusters(); icl++){
343  clusterEvent.Add(fInputEvent->GetCaloCluster(icl));
344  }
345  clusterArray = &clusterEvent;
346  }
347 
348  Double_t vertexpos[3];
349  fInputEvent->GetPrimaryVertex()->GetXYZ(vertexpos);
350 
351  Double_t energy, eta, phi;
352  for(TIter clustIter = TIter(clusterArray).Begin(); clustIter != TIter::End(); ++clustIter){
353  AliVCluster *clust = static_cast<AliVCluster *>(*clustIter);
354  if(!clust->IsEMCAL()) continue;
355  if(clust->GetIsExotic()) continue;
356 
357  TLorentzVector posvec;
358  energy = clust->GetNonLinCorrEnergy();
359  clust->GetMomentum(posvec, vertexpos);
360  eta = posvec.Eta();
361  phi = posvec.Phi();
362 
363  // fill histograms allEta
364  if(isMinBias){
365  FillClusterHistograms("MB", energy, posvec.Et(), eta, phi, nullptr);
366  }
367  if(isEMC7){
368  FillClusterHistograms("EMC7", energy, posvec.Et(), eta, phi, nullptr);
369  // check for exclusive classes
370  if(!isMinBias){
371  FillClusterHistograms("EMC7excl", energy, posvec.Et(), eta, phi, nullptr);
372  }
373  }
374  if(isDMC7){
375  FillClusterHistograms("DMC7", energy, posvec.Et(), eta, phi, nullptr);
376  // check for exclusive classes
377  if(!isMinBias){
378  FillClusterHistograms("DMC7excl", energy, posvec.Et(), eta, phi, nullptr);
379  }
380  }
381  if(isEJ2){
382  TList ej2patches;
383  FindPatchesForTrigger("EJ2", fTriggerPatches, ej2patches);
384  FillClusterHistograms("EJ2", energy, posvec.Et(), eta, phi, &ej2patches);
385  // check for exclusive classes
386  if(!(isMinBias || isEMC7)){
387  FillClusterHistograms("EJ2excl", energy, posvec.Et(), eta, phi, &ej2patches);
388  }
389  }
390  if(isDJ2){
391  TList dj2patches;
392  FindPatchesForTrigger("DJ2", fTriggerPatches, dj2patches);
393  FillClusterHistograms("DJ2", energy, posvec.Et(), eta, phi, &dj2patches);
394  // check for exclusive classes
395  if(!(isMinBias || isDMC7)){
396  FillClusterHistograms("DJ2excl", energy, posvec.Et(), eta, phi, &dj2patches);
397  }
398  }
399  if(isEJ1){
400  TList ej1patches;
401  FindPatchesForTrigger("EJ1", fTriggerPatches, ej1patches);
402  FillClusterHistograms("EJ1", energy, posvec.Et(), eta, phi, &ej1patches);
403  // check for exclusive classes
404  if(!(isMinBias || isEMC7 || isEJ2)){
405  FillClusterHistograms("EJ1excl", energy, posvec.Et(), eta, phi, &ej1patches);
406  }
407  }
408  if(isDJ1){
409  TList dj1patches;
410  FindPatchesForTrigger("DJ1", fTriggerPatches, dj1patches);
411  FillClusterHistograms("DJ1", energy, posvec.Et(), eta, phi, &dj1patches);
412  // check for exclusive classes
413  if(!(isMinBias || isEMC7 || isDJ2)){
414  FillClusterHistograms("DJ1excl", energy, posvec.Et(), eta, phi, &dj1patches);
415  }
416  }
417  if(isEG2){
418  TList eg2patches;
419  FindPatchesForTrigger("EG2", fTriggerPatches, eg2patches);
420  FillClusterHistograms("EG2", energy, posvec.Et(), eta, phi, &eg2patches);
421  // check for exclusive classes
422  if(!(isMinBias || isEMC7)){
423  FillClusterHistograms("EG2excl", energy, posvec.Et(), eta, phi, &eg2patches);
424  }
425  }
426  if(isDG2){
427  TList dg2patches;
428  FindPatchesForTrigger("DG2", fTriggerPatches, dg2patches);
429  FillClusterHistograms("DG2", energy, posvec.Et(), eta, phi, &dg2patches);
430  // check for exclusive classes
431  if(!(isMinBias || isDMC7)){
432  FillClusterHistograms("DG2excl", energy, posvec.Et(), eta, phi, &dg2patches);
433  }
434  }
435  if(isEG1){
436  TList eg1patches;
437  FindPatchesForTrigger("EG1", fTriggerPatches, eg1patches);
438  FillClusterHistograms("EG1", energy, posvec.Et(), eta, phi, &eg1patches);
439  // check for exclusive classes
440  if(!(isMinBias || isDMC7 || isEG2)){
441  FillClusterHistograms("EG1excl", energy, posvec.Et(), eta, phi, &eg1patches);
442  }
443  }
444  if(isDG1){
445  TList dg1patches;
446  FindPatchesForTrigger("DG1", fTriggerPatches, dg1patches);
447  FillClusterHistograms("DG1", energy, posvec.Et(), eta, phi, &dg1patches);
448  // check for exclusive classes
449  if(!(isMinBias || isDMC7 || isDG2)){
450  FillClusterHistograms("DG1excl", energy, posvec.Et(), eta, phi, &dg1patches);
451  }
452  }
453  }
454  PostData(1, fHistos->GetListOfHistograms());
455 }
456 
458  if(!fGeometry){
459  fGeometry = AliEMCALGeometry::GetInstance();
460  if(!fGeometry)
461  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
462  }
463  fTriggerPatches = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
464  // Handle OADB container with downscaling factors
465  if(fNameDownscaleOADB.Length()){
466  if(fNameDownscaleOADB.Contains("alien://") && ! gGrid) TGrid::Connect("alien://");
467  fDownscaleOADB = new AliOADBContainer("AliEmcalDownscaleFactors");
468  fDownscaleOADB->InitFromFile(fNameDownscaleOADB.Data(), "AliEmcalDownscaleFactors");
469  }
470 }
471 
473  if(fDownscaleOADB){
474  fDownscaleFactors = static_cast<TObjArray *>(fDownscaleOADB->GetObject(runnumber));
475  }
476 }
477 
486 Double_t AliAnalysisTaskEmcalClustersRef::GetTriggerWeight(const TString &triggerclass) const {
487  if(fDownscaleFactors){
488  TParameter<double> *result(nullptr);
489  // Downscaling only done on MB, L0 and the low threshold triggers
490  if(triggerclass.Contains("MB")) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("INT7"));
491  else if(triggerclass.Contains("EMC7")) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("EMC7"));
492  else if(triggerclass.Contains("EJ2")) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("EJ2"));
493  else if(triggerclass.Contains("EG2")) result = static_cast<TParameter<double> *>(fDownscaleFactors->FindObject("EG2"));
494  if(result) return 1./result->GetVal();
495  }
496  return 1.;
497 }
498 
499 void AliAnalysisTaskEmcalClustersRef::FillClusterHistograms(const TString &triggerclass, double energy, double transverseenergy, double eta, double phi, TList *fTriggerPatches){
500  Bool_t hasTriggerPatch = fTriggerPatches ? CorrelateToTrigger(eta, phi, fTriggerPatches) : kFALSE;
501  Int_t supermoduleID = -1, sector = -1;
502  Double_t weight = GetTriggerWeight(triggerclass);
503  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << triggerclass << std::endl;
504 
505  fGeometry->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
506  fHistos->FillTH1(Form("hClusterEnergy%s", triggerclass.Data()), energy, weight);
507  fHistos->FillTH1(Form("hClusterET%s", triggerclass.Data()), transverseenergy, weight);
508  fHistos->FillTH2(Form("hEtaEnergy%s", triggerclass.Data()), eta, energy, weight);
509  fHistos->FillTH2(Form("hEtaET%s", triggerclass.Data()), eta, transverseenergy, weight);
510  if(supermoduleID >= 0){
511  fHistos->FillTH2(Form("hClusterEnergySM%s", triggerclass.Data()), supermoduleID, energy, weight);
512  fHistos->FillTH2(Form("hClusterETSM%s", triggerclass.Data()), supermoduleID, transverseenergy, weight);
513  fHistos->FillTH2(Form("hEtaEnergySM%d%s", supermoduleID, triggerclass.Data()), eta, energy, weight);
514  fHistos->FillTH2(Form("hEtaETSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy, weight);
515  if(supermoduleID < 12)
516  sector = 4 + int(supermoduleID/2); // EMCAL
517  else
518  sector = 13 + int((supermoduleID-12)/2); // DCAL
519  fHistos->FillTH2(Form("hEtaEnergySec%d%s", sector, triggerclass.Data()), eta, energy, weight);
520  fHistos->FillTH2(Form("hEtaETSec%d%s", sector, triggerclass.Data()), eta, transverseenergy, weight);
521  }
522  if(hasTriggerPatch){
523  fHistos->FillTH1(Form("hClusterEnergyFired%s", triggerclass.Data()), energy, weight);
524  fHistos->FillTH1(Form("hClusterETFired%s", triggerclass.Data()), energy, weight);
525  fHistos->FillTH2(Form("hEtaEnergyFired%s", triggerclass.Data()), eta, energy, weight);
526  fHistos->FillTH2(Form("hEtaETFired%s", triggerclass.Data()), eta, energy, weight);
527  if(supermoduleID >= 0){
528  fHistos->FillTH2(Form("hClusterEnergyFiredSM%s", triggerclass.Data()), supermoduleID, energy, weight);
529  fHistos->FillTH2(Form("hClusterETFiredSM%s", triggerclass.Data()), supermoduleID, transverseenergy, weight);
530  fHistos->FillTH2(Form("hEtaEnergyFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, energy,weight);
531  fHistos->FillTH2(Form("hEtaETFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy, weight);
532  fHistos->FillTH2(Form("hEtaEnergyFiredSec%d%s", sector, triggerclass.Data()), eta, energy, weight);
533  fHistos->FillTH2(Form("hEtaETFiredSec%d%s", sector, triggerclass.Data()), eta, transverseenergy, weight);
534  }
535  }
536  Double_t encuts[5] = {1., 2., 5., 10., 20.};
537  for(int ien = 0; ien < 5; ien++){
538  if(energy > encuts[ien]){
539  fHistos->FillTH2(Form("hEtaPhi%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi, weight);
540  if(hasTriggerPatch){
541  fHistos->FillTH2(Form("hEtaPhiFired%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi, weight);
542  }
543  }
544  }
545 }
546 
558 void AliAnalysisTaskEmcalClustersRef::FillEventHistograms(const TString &triggerclass, double centrality, double vertexz){
559  Double_t weight = GetTriggerWeight(triggerclass);
560  fHistos->FillTH1(Form("hEventCount%s", triggerclass.Data()), 1, weight);
561  fHistos->FillTH1(Form("hEventCentrality%s", triggerclass.Data()), centrality, weight);
562  fHistos->FillTH1(Form("hVertexZ%s", triggerclass.Data()), vertexz, weight);
563 }
564 
572 Bool_t AliAnalysisTaskEmcalClustersRef::CorrelateToTrigger(Double_t etaclust, Double_t phiclust, TList *fTriggerPatches) const {
573  Bool_t hasfound = kFALSE;
574  for(TIter patchIter = TIter(fTriggerPatches).Begin(); patchIter != TIter::End(); ++patchIter){
575  Double_t boundaries[4];
576  GetPatchBoundaries(*patchIter, boundaries);
577  Double_t etamin = TMath::Min(boundaries[0], boundaries[1]),
578  etamax = TMath::Max(boundaries[0], boundaries[1]),
579  phimin = TMath::Min(boundaries[2], boundaries[3]),
580  phimax = TMath::Max(boundaries[2], boundaries[3]);
581  if(etaclust > etamin && etaclust < etamax && phiclust > phimin && phiclust < phimax){
582  hasfound = kTRUE;
583  break;
584  }
585  }
586  return hasfound;
587 }
588 
597 void AliAnalysisTaskEmcalClustersRef::FindPatchesForTrigger(TString triggerclass, const TClonesArray * fTriggerPatches, TList &foundtriggers) const {
598  foundtriggers.Clear();
599  if(!fTriggerPatches) return;
601  if(triggerclass == "EG1") myclass = AliEmcalTriggerOfflineSelection::kTrgEG1;
602  if(triggerclass == "EG2") myclass = AliEmcalTriggerOfflineSelection::kTrgEG2;
603  if(triggerclass == "EJ1") myclass = AliEmcalTriggerOfflineSelection::kTrgEJ1;
604  if(triggerclass == "EJ2") myclass = AliEmcalTriggerOfflineSelection::kTrgEJ2;
605  if(triggerclass == "DMC7") myclass = AliEmcalTriggerOfflineSelection::kTrgDL0;
606  if(triggerclass == "DG1") myclass = AliEmcalTriggerOfflineSelection::kTrgDG1;
607  if(triggerclass == "DG2") myclass = AliEmcalTriggerOfflineSelection::kTrgDG2;
608  if(triggerclass == "DJ1") myclass = AliEmcalTriggerOfflineSelection::kTrgDJ1;
609  if(triggerclass == "DJ2") myclass = AliEmcalTriggerOfflineSelection::kTrgDJ2;
610  for(TIter patchiter = TIter(fTriggerPatches).Begin(); patchiter != TIter::End(); ++patchiter){
611  if(!IsOfflineSimplePatch(*patchiter)) continue;
613  if(!SelectDCALPatch(*patchiter)) continue;
614  } else {
615  if(SelectDCALPatch(*patchiter)) continue;
616  }
618  if(!SelectSingleShowerPatch(*patchiter)) continue;
619  } else {
620  if(!SelectJetPatch(*patchiter)) continue;
621  }
622  double threshold = fTriggerSelection ? fTriggerSelection->GetThresholdForTrigger(myclass) : -1;
623  if(GetPatchEnergy(*patchiter) > threshold) foundtriggers.Add(*patchiter);
624  }
625 }
626 
632 TString AliAnalysisTaskEmcalClustersRef::GetFiredTriggerClassesFromPatches(const TClonesArray* fTriggerPatches) const {
633  TString triggerstring = "";
634  if(!fTriggerPatches) return triggerstring;
635  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0, nDJ1 = 0, nDJ2 = 0, nDG1 = 0, nDG2 = 0;
636  double minADC_J1 = 260.,
637  minADC_J2 = 127.,
638  minADC_G1 = 140.,
639  minADC_G2 = 89.;
640  for(TIter patchIter = TIter(fTriggerPatches).Begin(); patchIter != TIter::End(); ++patchIter){
641  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(*patchIter);
642  if(!patch->IsOfflineSimple()) continue;
643  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_J1){
644  if(patch->IsDCalPHOS()) nDJ1++;
645  else nEJ1++;
646  }
647  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_J2){
648  if(patch->IsDCalPHOS()) nDJ2++;
649  else nEJ2++;
650  }
651  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_G1){
652  if(patch->IsDCalPHOS()) nDG1++;
653  else nEG1++;
654  }
655  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_G2){
656  if(patch->IsDCalPHOS()) nDG2++;
657  else nEG2++;
658  }
659  }
660  if(nEJ1) triggerstring += "EJ1";
661  if(nEJ2){
662  if(triggerstring.Length()) triggerstring += ",";
663  triggerstring += "EJ2";
664  }
665  if(nEG1){
666  if(triggerstring.Length()) triggerstring += ",";
667  triggerstring += "EG1";
668  }
669  if(nEG2){
670  if(triggerstring.Length()) triggerstring += ",";
671  triggerstring += "EG2";
672  }
673  if(nDJ1){
674  if(triggerstring.Length()) triggerstring += ",";
675  triggerstring += "DJ1";
676  }
677  if(nDJ2){
678  if(triggerstring.Length()) triggerstring += ",";
679  triggerstring += "DJ2";
680  }
681  if(nDG1){
682  if(triggerstring.Length()) triggerstring += ",";
683  triggerstring += "DG1";
684  }
685  if(nDG2){
686  if(triggerstring.Length()) triggerstring += ",";
687  triggerstring += "DG2";
688  }
689  return triggerstring;
690 }
691 
692 void AliAnalysisTaskEmcalClustersRef::GetPatchBoundaries(TObject *o, Double_t *boundaries) const {
693  AliEMCALTriggerPatchInfo *patch= dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
694  boundaries[0] = patch->GetEtaMin();
695  boundaries[1] = patch->GetEtaMax();
696  boundaries[2] = patch->GetPhiMin();
697  boundaries[3] = patch->GetPhiMax();
698 }
699 
701  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
702  return patch->IsOfflineSimple();
703 }
704 
706  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
707  return patch->GetRowStart() >= 64;
708 }
709 
711  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
712  return patch->IsGammaLowSimple();
713 }
714 
716  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
717  if(!patch->IsOfflineSimple()) return false;
718  return patch->IsJetLowSimple();
719 }
720 
722  double energy = 0.;
723  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(o);
724  energy = patch->GetPatchE();
725  return energy;
726 }
727 
733 {
734  this->SetMinimum(0.);
735  this->AddStep(1, 0.05);
736  this->AddStep(2, 0.1);
737  this->AddStep(4, 0.2);
738  this->AddStep(7, 0.5);
739  this->AddStep(16, 1);
740  this->AddStep(32, 2);
741  this->AddStep(40, 4);
742  this->AddStep(50, 5);
743  this->AddStep(100, 10);
744  this->AddStep(200, 20);
745 }
746 
747 
748 } /* namespace EMCalTriggerPtAnalysis */
void GetPatchBoundaries(TObject *o, Double_t *boundaries) const
Class creating a linear binning, used in the histogram manager.
Bool_t CorrelateToTrigger(Double_t etaclust, Double_t phiclust, TList *triggerpatches) const
TClonesArray * fTriggerPatches
! Container with trigger patches
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
centrality
Bool_t fRequestCentrality
Swich on request for centrality range.
static Bool_t IsDCAL(EmcalTriggerClass cls)
void FillEventHistograms(const TString &triggerclass, double centrality, double vertexz)
void AddStep(Double_t max, Double_t binwidth)
AliAnalysisUtils * fAnalysisUtil
Analysis utils for additional event selection / pileup rejection.
void FillClusterHistograms(const TString &triggerclass, double energy, double transversenergy, double eta, double phi, TList *triggerpatches)
AliEmcalTriggerOfflineSelection * fTriggerSelection
EMCAL offline trigger selection tool.
const Double_t etamin
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
TString fClusterContainer
Name of the cluster container in the event.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Bool_t fTriggerStringFromPatches
Build trigger string from trigger patches.
Helper class creating user defined custom binning.
AliOADBContainer * fDownscaleOADB
! Container with downscale factors for different triggers
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
energy
Bool_t IsOfflineSelected(EmcalTriggerClass trgcls, const TClonesArray *const triggerpatches) const
Int_t fCurrentRun
Current run number (for RunChange method)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
AliCutValueRange< double > fCentralityRange
Selected centrality range.
const Double_t etamax
TString GetFiredTriggerClassesFromPatches(const TClonesArray *triggerpatches) const
AliCutValueRange< double > fVertexRange
Selected vertex range.
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
Bool_t fRequestAnalysisUtil
Switch on request for event selection using analysis utils.
TString fNameDownscaleOADB
Name of the downscale OADB container.
static Bool_t IsSingleShower(EmcalTriggerClass cls)
const Double_t phimin
void FindPatchesForTrigger(TString triggerclass, const TClonesArray *triggerpatches, TList &foundpatches) const
void SetMinimum(Double_t min)