AliPhysics  v5-07-15-01 (b3d7633)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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 <bitset>
16 #include <iostream>
17 #include <map>
18 #include <sstream>
19 #include <vector>
20 
21 #include <TArrayD.h>
22 #include <TClonesArray.h>
23 #include <THashList.h>
24 #include <TLorentzVector.h>
25 #include <TMath.h>
26 #include <TString.h>
27 
28 #include "AliAnalysisUtils.h"
29 #include "AliEMCALGeometry.h"
30 #include "AliEmcalTriggerPatchInfoAP.h"
31 #include "AliEmcalTriggerPatchInfoAPV1.h"
32 #include "AliEMCalHistoContainer.h"
33 #include "AliESDEvent.h"
34 #include "AliInputEventHandler.h"
35 #include "AliLog.h"
36 #include "AliVCluster.h"
37 #include "AliVVertex.h"
38 
40 
42 
43 namespace EMCalTriggerPtAnalysis {
44 
48 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef() :
49  AliAnalysisTaskSE(),
50  fAnalysisUtil(NULL),
51  fHistos(NULL),
52  fGeometry(NULL),
53  fClusterContainer(""),
54  fRequestAnalysisUtil(kTRUE),
55  fTriggerStringFromPatches(kFALSE)
56 {
57  for(int itrg = 0; itrg < kECRntrig; itrg++){
58  fOfflineEnergyThreshold[itrg] = -1;
59  }
60 }
61 
66 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef(const char *name) :
67  AliAnalysisTaskSE(name),
68  fAnalysisUtil(),
69  fHistos(NULL),
70  fGeometry(NULL),
71  fClusterContainer(""),
72  fRequestAnalysisUtil(kTRUE),
73  fTriggerStringFromPatches(kFALSE)
74 {
75  for(int itrg = 0; itrg < kECRntrig; itrg++){
76  fOfflineEnergyThreshold[itrg] = -1;
77  }
78  DefineOutput(1, TList::Class());
79 }
80 
84 AliAnalysisTaskEmcalClustersRef::~AliAnalysisTaskEmcalClustersRef() {
85 }
86 
90 void AliAnalysisTaskEmcalClustersRef::UserCreateOutputObjects(){
91  fAnalysisUtil = new AliAnalysisUtils;
92 
93  TArrayD energybinning;
94  CreateEnergyBinning(energybinning);
95  TArrayD smbinning(14); CreateLinearBinning(smbinning, 21, -0.5, 20.5);
96  TArrayD etabinning; CreateLinearBinning(etabinning, 100, -0.7, 0.7);
97  fHistos = new AliEMCalHistoContainer("Ref");
98  TString triggers[18] = {
99  "MB", "EMC7", "DMC7",
100  "EJ1", "EJ2", "EG1", "EG2", "DJ1", "DJ2", "DG1", "DG2",
101  "MBexcl", "EMC7excl", "DMC7excl", "EG2excl", "EJ2excl", "DG2excl", "DJ2excl"
102  };
103  Double_t encuts[5] = {1., 2., 5., 10., 20.};
104  Int_t sectorsWithEMCAL[10] = {4, 5, 6, 7, 8, 9, 13, 14, 15, 16};
105  for(TString *trg = triggers; trg < triggers + sizeof(triggers)/sizeof(TString); trg++){
106  fHistos->CreateTH1(Form("hEventCount%s", trg->Data()), Form("Event count for trigger class %s", trg->Data()), 1, 0.5, 1.5);
107  fHistos->CreateTH1(Form("hClusterEnergy%s", trg->Data()), Form("Cluster energy for trigger class %s", trg->Data()), energybinning);
108  fHistos->CreateTH1(Form("hClusterET%s", trg->Data()), Form("Cluster transverse energy for trigger class %s", trg->Data()), energybinning);
109  fHistos->CreateTH1(Form("hClusterEnergyFired%s", trg->Data()), Form("Cluster energy for trigger class %s, firing the trigger", trg->Data()), energybinning);
110  fHistos->CreateTH1(Form("hClusterETFired%s", trg->Data()), Form("Cluster transverse energy for trigger class %s, firing the trigger", trg->Data()), energybinning);
111  fHistos->CreateTH2(Form("hClusterEnergySM%s", trg->Data()), Form("Cluster energy versus supermodule for trigger class %s", trg->Data()), smbinning, energybinning);
112  fHistos->CreateTH2(Form("hClusterETSM%s", trg->Data()), Form("Cluster transverse energy versus supermodule for trigger class %s", trg->Data()), smbinning, energybinning);
113  fHistos->CreateTH2(Form("hClusterEnergyFiredSM%s", trg->Data()), Form("Cluster energy versus supermodule for trigger class %s, firing the trigger", trg->Data()), smbinning, energybinning);
114  fHistos->CreateTH2(Form("hClusterETFiredSM%s", trg->Data()), Form("Cluster transverse energy versus supermodule for trigger class %s, firing the trigger", trg->Data()), smbinning, energybinning);
115  fHistos->CreateTH2(Form("hEtaEnergy%s", trg->Data()), Form("Cluster energy vs. eta for trigger class %s", trg->Data()), etabinning, energybinning);
116  fHistos->CreateTH2(Form("hEtaET%s", trg->Data()), Form("Cluster transverse energy vs. eta for trigger class %s", trg->Data()), etabinning, energybinning);
117  fHistos->CreateTH2(Form("hEtaEnergyFired%s", trg->Data()), Form("Cluster energy vs. eta for trigger class %s, firing the trigger", trg->Data()), etabinning, energybinning);
118  fHistos->CreateTH2(Form("hEtaETFired%s", trg->Data()), Form("Cluster transverse energy vs. eta for trigger class %s, firing the trigger", trg->Data()), etabinning, energybinning);
119  for(int ism = 0; ism < 20; ism++){
120  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);
121  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);
122  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);
123  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);
124  }
125  for(int isec = 0; isec < 10; isec++){
126  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);
127  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);
128  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);
129  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);
130  }
131  for(int ien = 0; ien < 5; ien++){
132  fHistos->CreateTH2(Form("hEtaPhi%dG%s", static_cast<int>(encuts[ien]), trg->Data()), Form("cluster #eta-#phi map for clusters with energy larger than %f GeV/c for trigger class %s", encuts[ien], trg->Data()), 100, -0.7, 0.7, 200, 0, 2*TMath::Pi());
133  fHistos->CreateTH2(Form("hEtaPhiFired%dG%s", static_cast<int>(encuts[ien]), trg->Data()), Form("cluster #eta-#phi map for clusters fired the trigger with energy larger than %f GeV/c for trigger class %s", encuts[ien], trg->Data()), 200, -0.7, 0.7, 200, 0, 2*TMath::Pi());
134  }
135  }
136  PostData(1, fHistos->GetListOfHistograms());
137 }
138 
139 
144 void AliAnalysisTaskEmcalClustersRef::UserExec(Option_t *){
145  if(!fGeometry){
146  fGeometry = AliEMCALGeometry::GetInstance();
147  if(!fGeometry)
148  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
149  }
150  TString triggerstring = "";
151  TClonesArray *triggerpatches = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
152 
153  if(fTriggerStringFromPatches){
154  triggerstring = GetFiredTriggerClassesFromPatches(triggerpatches);
155  } else {
156  triggerstring = fInputEvent->GetFiredTriggerClasses();
157  }
158 
159  UInt_t selectionstatus = fInputHandler->IsEventSelected();
160  std::stringstream triggerdebug;
161  triggerdebug << "Offline bits: " << std::bitset<sizeof(UInt_t) * 8>(selectionstatus);
162  AliDebug(2, triggerdebug.str().c_str());
163  Bool_t isMinBias = selectionstatus & AliVEvent::kINT7,
164  isEJ1 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("EJ1") && IsOfflineSelected(kECREJ1, triggerpatches),
165  isEJ2 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("EJ2") && IsOfflineSelected(kECREJ2, triggerpatches),
166  isEG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG1") && IsOfflineSelected(kECREG1, triggerpatches),
167  isEG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG2") && IsOfflineSelected(kECREG2, triggerpatches),
168  isEMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("EMC7") && IsOfflineSelected(kECREL0, triggerpatches),
169  isDJ1 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("DJ1") && IsOfflineSelected(kECREJ1, triggerpatches),
170  isDJ2 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains("DJ2") && IsOfflineSelected(kECREJ2, triggerpatches),
171  isDG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("DG1") && IsOfflineSelected(kECREG1, triggerpatches),
172  isDG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("DG2") && IsOfflineSelected(kECREG2, triggerpatches),
173  isDMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("DMC7") && IsOfflineSelected(kECREL0, triggerpatches);
174  if(!(isMinBias || isEMC7 || isEG1 || isEG2 || isEJ1 || isEJ2 || isDMC7 || isDG1 || isDG2 || isDJ1 || isDJ2)) return;
175  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
176  //if(!fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) return; // reject pileup event
177  if(vtx->GetNContributors() < 1) return;
178  // Fill reference distribution for the primary vertex before any z-cut
179  if(fRequestAnalysisUtil){
180  if(fInputEvent->IsA() == AliESDEvent::Class() && fAnalysisUtil->IsFirstEventInChunk(fInputEvent)) return;
181  if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent)) return; // Apply new vertex cut
182  if(fAnalysisUtil->IsPileUpEvent(fInputEvent)) return; // Apply new vertex cut
183  }
184  // Apply vertex z cut
185  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return;
186 
187  // Fill Event counter and reference vertex distributions for the different trigger classes
188  if(isMinBias){
189  fHistos->FillTH1("hEventCountMB", 1);
190  if(!(isEMC7 || isDMC7 || isEJ1 || isEJ2 || isEG1 || isEG2 || isDJ1 || isDJ2 || isDG1 || isDG2)){
191  fHistos->FillTH1("hEventCountMBexcl", 1);
192  }
193  }
194 
195  if(isEMC7){
196  fHistos->FillTH1("hEventCountEMC7", 1);
197  if(!(isEJ1 || isEJ2 || isEG1 || isEG2)){
198  fHistos->FillTH1("hEventCountEMC7excl", 1);
199  }
200  }
201  if(isDMC7){
202  fHistos->FillTH1("hEventCountDMC7", 1);
203  if(!(isDJ1 || isDJ2 || isDG1 || isDG2)){
204  fHistos->FillTH1("hEventCountEMC7excl", 1);
205  }
206  }
207 
208  if(isEJ2){
209  fHistos->FillTH1("hEventCountEJ2", 1);
210  // Check for exclusive classes
211  if(!isEJ1){
212  fHistos->FillTH1("hEventCountEJ2excl", 1);
213  }
214  }
215  if(isDJ2){
216  fHistos->FillTH1("hEventCountDJ2", 1);
217  // Check for exclusive classes
218  if(!isDJ1){
219  fHistos->FillTH1("hEventCountDJ2excl", 1);
220  }
221  }
222 
223  if(isEJ1){
224  fHistos->FillTH1("hEventCountEJ1", 1);
225  }
226  if(isDJ1){
227  fHistos->FillTH1("hEventCountDJ1", 1);
228  }
229 
230  if(isEG2){
231  fHistos->FillTH1("hEventCountEG2", 1);
232  // Check for exclusive classes
233  if(!(isEG1)){
234  fHistos->FillTH1("hEventCountEG2excl", 1);
235  }
236  }
237  if(isDG2){
238  fHistos->FillTH1("hEventCountDG2", 1);
239  // Check for exclusive classes
240  if(!(isDG1)){
241  fHistos->FillTH1("hEventCountDG2excl", 1);
242  }
243  }
244 
245  if(isEG1){
246  fHistos->FillTH1("hEventCountEG1", 1);
247  }
248  if(isDG1){
249  fHistos->FillTH1("hEventCountDG1", 1);
250  }
251 
252  /*
253  TList *objects = fInputEvent->GetList();
254  for(TIter objiter = TIter(objects).Begin(); objiter != TIter::End(); ++ objiter){
255  printf("Object %s\n", (*objiter)->GetName());
256  }
257  */
258 
259  TClonesArray *clusterArray = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject(fClusterContainer.Data()));
260  if(!clusterArray){
261  AliError(Form("Cluster array with name %s not found in the event", fClusterContainer.Data()));
262  return;
263  }
264 
265  Double_t vertexpos[3];
266  fInputEvent->GetPrimaryVertex()->GetXYZ(vertexpos);
267 
268  Double_t energy, eta, phi;
269  for(TIter clustIter = TIter(clusterArray).Begin(); clustIter != TIter::End(); ++clustIter){
270  AliVCluster *clust = static_cast<AliVCluster *>(*clustIter);
271  if(!clust->IsEMCAL()) continue;
272 
273  TLorentzVector posvec;
274  energy = clust->E();
275  clust->GetMomentum(posvec, vertexpos);
276  eta = posvec.Eta();
277  phi = posvec.Phi();
278 
279  // fill histograms allEta
280  if(isMinBias){
281  FillClusterHistograms("MB", energy, posvec.Et(), eta, phi, NULL);
282  if(!(isEMC7 || isDMC7 || isEJ1 || isEJ2 || isEG1 || isEG2 || isDJ1 || isDJ2 || isDG1 || isDG2)){
283  FillClusterHistograms("MBexcl", energy, posvec.Et(), eta, phi, NULL);
284  }
285  }
286  if(isEMC7){
287  FillClusterHistograms("EMC7", energy, posvec.Et(), eta, phi, NULL);
288  if(!(isEJ1 || isEJ2 || isEG1 || isEG2)){
289  FillClusterHistograms("EMC7excl", energy, posvec.Et(), eta, phi, NULL);
290  }
291  }
292  if(isDMC7){
293  FillClusterHistograms("DMC7", energy, posvec.Et(), eta, phi, NULL);
294  if(!(isDJ1 || isDJ2 || isDG1 || isDG2)){
295  FillClusterHistograms("DMC7excl", energy, posvec.Et(), eta, phi, NULL);
296  }
297  }
298  if(isEJ2){
299  TList ej2patches;
300  FindPatchesForTrigger("EJ2", triggerpatches, ej2patches);
301  FillClusterHistograms("EJ2", energy, posvec.Et(), eta, phi, &ej2patches);
302  // check for exclusive classes
303  if(!isEJ1){
304  FillClusterHistograms("EJ2excl", energy, posvec.Et(), eta, phi, &ej2patches);
305  }
306  }
307  if(isDJ2){
308  TList dj2patches;
309  FindPatchesForTrigger("DJ2", triggerpatches, dj2patches);
310  FillClusterHistograms("DJ2", energy, posvec.Et(), eta, phi, &dj2patches);
311  // check for exclusive classes
312  if(!isDJ1){
313  FillClusterHistograms("DJ2excl", energy, posvec.Et(), eta, phi, &dj2patches);
314  }
315  }
316  if(isEJ1){
317  TList ej1patches;
318  FindPatchesForTrigger("EJ1", triggerpatches, ej1patches);
319  FillClusterHistograms("EJ1", energy, posvec.Et(), eta, phi, &ej1patches);
320  }
321  if(isDJ1){
322  TList dj1patches;
323  FindPatchesForTrigger("DJ1", triggerpatches, dj1patches);
324  FillClusterHistograms("DJ1", energy, posvec.Et(), eta, phi, &dj1patches);
325  }
326  if(isEG2){
327  TList eg2patches;
328  FindPatchesForTrigger("EG2", triggerpatches, eg2patches);
329  FillClusterHistograms("EG2", energy, posvec.Et(), eta, phi, &eg2patches);
330  // check for exclusive classes
331  if(!isEG1){
332  FillClusterHistograms("EG2excl", energy, posvec.Et(), eta, phi, &eg2patches);
333  }
334  }
335  if(isDG2){
336  TList dg2patches;
337  FindPatchesForTrigger("DG2", triggerpatches, dg2patches);
338  FillClusterHistograms("DG2", energy, posvec.Et(), eta, phi, &dg2patches);
339  // check for exclusive classes
340  if(!isDG1){
341  FillClusterHistograms("DG2excl", energy, posvec.Et(), eta, phi, &dg2patches);
342  }
343  }
344  if(isEG1){
345  TList eg1patches;
346  FindPatchesForTrigger("EG1", triggerpatches, eg1patches);
347  FillClusterHistograms("EG1", energy, posvec.Et(), eta, phi, &eg1patches);
348  }
349  if(isDG1){
350  TList dg1patches;
351  FindPatchesForTrigger("DG1", triggerpatches, dg1patches);
352  FillClusterHistograms("DG1", energy, posvec.Et(), eta, phi, &dg1patches);
353  }
354  }
355  PostData(1, fHistos->GetListOfHistograms());
356 }
357 
358 void AliAnalysisTaskEmcalClustersRef::FillClusterHistograms(TString triggerclass, double energy, double transverseenergy, double eta, double phi, TList *triggerpatches){
359  Bool_t hasTriggerPatch = triggerpatches ? CorrelateToTrigger(eta, phi, triggerpatches) : kFALSE;
360  Int_t supermoduleID = -1, sector = -1;
361  fGeometry->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
362  fHistos->FillTH1(Form("hClusterEnergy%s", triggerclass.Data()), energy);
363  fHistos->FillTH1(Form("hClusterET%s", triggerclass.Data()), transverseenergy);
364  fHistos->FillTH2(Form("hEtaEnergy%s", triggerclass.Data()), eta, energy);
365  fHistos->FillTH2(Form("hEtaET%s", triggerclass.Data()), eta, transverseenergy);
366  if(supermoduleID >= 0){
367  fHistos->FillTH2(Form("hClusterEnergySM%s", triggerclass.Data()), supermoduleID, energy);
368  fHistos->FillTH2(Form("hClusterETSM%s", triggerclass.Data()), supermoduleID, transverseenergy);
369  fHistos->FillTH2(Form("hEtaEnergySM%d%s", supermoduleID, triggerclass.Data()), eta, energy);
370  fHistos->FillTH2(Form("hEtaETSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy);
371  if(supermoduleID < 12)
372  sector = 4 + int(supermoduleID/2); // EMCAL
373  else
374  sector = 13 + int((supermoduleID-12)/2); // DCAL
375  fHistos->FillTH2(Form("hEtaEnergySec%d%s", sector, triggerclass.Data()), eta, energy);
376  fHistos->FillTH2(Form("hEtaETSec%d%s", sector, triggerclass.Data()), eta, transverseenergy);
377  }
378  if(hasTriggerPatch){
379  fHistos->FillTH1(Form("hClusterEnergyFired%s", triggerclass.Data()), energy);
380  fHistos->FillTH1(Form("hClusterETFired%s", triggerclass.Data()), energy);
381  fHistos->FillTH2(Form("hEtaEnergyFired%s", triggerclass.Data()), eta, energy);
382  fHistos->FillTH2(Form("hEtaETFired%s", triggerclass.Data()), eta, energy);
383  if(supermoduleID >= 0){
384  fHistos->FillTH2(Form("hClusterEnergyFiredSM%s", triggerclass.Data()), supermoduleID, energy);
385  fHistos->FillTH2(Form("hClusterETFiredSM%s", triggerclass.Data()), supermoduleID, transverseenergy);
386  fHistos->FillTH2(Form("hEtaEnergyFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, energy);
387  fHistos->FillTH2(Form("hEtaETFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy);
388  fHistos->FillTH2(Form("hEtaEnergyFiredSec%d%s", sector, triggerclass.Data()), eta, energy);
389  fHistos->FillTH2(Form("hEtaETFiredSec%d%s", sector, triggerclass.Data()), eta, transverseenergy);
390  }
391  }
392  Double_t encuts[5] = {1., 2., 5., 10., 20.};
393  for(int ien = 0; ien < 5; ien++){
394  if(energy > encuts[ien]){
395  fHistos->FillTH2(Form("hEtaPhi%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi);
396  if(hasTriggerPatch){
397  fHistos->FillTH2(Form("hEtaPhiFired%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi);
398  }
399  }
400  }
401 }
402 
407 void AliAnalysisTaskEmcalClustersRef::CreateEnergyBinning(TArrayD& binning) const {
408  std::vector<double> mybinning;
409  std::map<double,double> definitions;
410  definitions.insert(std::pair<double, double>(1, 0.05));
411  definitions.insert(std::pair<double, double>(2, 0.1));
412  definitions.insert(std::pair<double, double>(4, 0.2));
413  definitions.insert(std::pair<double, double>(7, 0.5));
414  definitions.insert(std::pair<double, double>(16, 1));
415  definitions.insert(std::pair<double, double>(32, 2));
416  definitions.insert(std::pair<double, double>(40, 4));
417  definitions.insert(std::pair<double, double>(50, 5));
418  definitions.insert(std::pair<double, double>(100, 10));
419  definitions.insert(std::pair<double, double>(200, 20));
420  double currentval = 0.;
421  mybinning.push_back(currentval);
422  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
423  double limit = id->first, binwidth = id->second;
424  while(currentval < limit){
425  currentval += binwidth;
426  mybinning.push_back(currentval);
427  }
428  }
429  binning.Set(mybinning.size());
430  int ib = 0;
431  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
432  binning[ib++] = *it;
433 }
434 
442 void AliAnalysisTaskEmcalClustersRef::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
443  double binwidth = (max-min)/static_cast<double>(nbins);
444  binning.Set(nbins+1);
445  binning[0] = min;
446  double currentlimit = min + binwidth;
447  for(int ibin = 0; ibin < nbins; ibin++){
448  binning[ibin+1] = currentlimit;
449  currentlimit += binwidth;
450  }
451 }
452 
460 Bool_t AliAnalysisTaskEmcalClustersRef::CorrelateToTrigger(Double_t etaclust, Double_t phiclust, TList *triggerpatches) const {
461  Bool_t hasfound = kFALSE;
462  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
463  Double_t boundaries[4];
464  GetPatchBoundaries(*patchIter, boundaries);
465  Double_t etamin = TMath::Min(boundaries[0], boundaries[1]),
466  etamax = TMath::Max(boundaries[0], boundaries[1]),
467  phimin = TMath::Min(boundaries[2], boundaries[3]),
468  phimax = TMath::Max(boundaries[2], boundaries[3]);
469  if(etaclust > etamin && etaclust < etamax && phiclust > phimin && phiclust < phimax){
470  hasfound = kTRUE;
471  break;
472  }
473  }
474  return hasfound;
475 }
476 
485 void AliAnalysisTaskEmcalClustersRef::FindPatchesForTrigger(TString triggerclass, const TClonesArray * triggerpatches, TList &foundtriggers) const {
486  foundtriggers.Clear();
487  if(!triggerpatches) return;
488  EmcalTriggerClass myclass = kECREL0;
489  if(triggerclass == "EG1") myclass = kECREG1;
490  if(triggerclass == "EG2") myclass = kECREG2;
491  if(triggerclass == "EJ1") myclass = kECREJ1;
492  if(triggerclass == "EJ2") myclass = kECREJ2;
493  if(triggerclass == "DMC7") myclass = kECRDL0;
494  if(triggerclass == "DG1") myclass = kECRDG1;
495  if(triggerclass == "DG2") myclass = kECRDG2;
496  if(triggerclass == "DJ1") myclass = kECRDJ1;
497  if(triggerclass == "DJ2") myclass = kECRDJ2;
498  bool isSingleShower = (
499  (myclass == kECREG1) || (triggerclass == kECREG2) || (myclass == kECREL0)
500  || (myclass == kECRDG1) || (triggerclass == kECRDG2) || (myclass == kECRDL0)
501  ),
502  isDCAL = ((myclass == kECRDL0) || (myclass == kECRDG1) || (myclass == kECRDG2) || (myclass == kECRDJ1) || (myclass == kECRDJ2));
503  AliEmcalTriggerPatchInfoAPV1 *mypatch = NULL;
504  for(TIter patchiter = TIter(triggerpatches).Begin(); patchiter != TIter::End(); ++patchiter){
505  if(!IsOfflineSimplePatch(*patchiter)) continue;
506  if(isDCAL){
507  if(!SelectDCALPatch(*patchiter)) continue;
508  } else {
509  if(SelectDCALPatch(*patchiter)) continue;
510  }
511  if(isSingleShower){
512  if(!SelectSingleShowerPatch(*patchiter)) continue;
513  } else {
514  if(!SelectJetPatch(*patchiter)) continue;
515  }
516  if(GetPatchEnergy(*patchiter) > fOfflineEnergyThreshold[myclass]) foundtriggers.Add(mypatch);
517  }
518 }
519 
528 Bool_t AliAnalysisTaskEmcalClustersRef::IsOfflineSelected(EmcalTriggerClass trgcls, const TClonesArray * const triggerpatches) const {
529  if(fOfflineEnergyThreshold[trgcls] < 0) return true;
530  bool isSingleShower = ((trgcls == kECREL0) || (trgcls == kECREG1) || (trgcls == kECREG2) ||
531  (trgcls == kECRDL0) || (trgcls == kECRDG1) || (trgcls == kECRDG2)),
532  isDCAL = ((trgcls == kECRDL0) || (trgcls == kECRDG1) || (trgcls == kECRDG2) || (trgcls == kECRDJ1) || (trgcls == kECRDJ2));
533  int nfound = 0;
534  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
535  bool isDCALpatch = SelectDCALPatch(*patchIter);
536  if(isDCAL){
537  if(!isDCALpatch) continue;
538  } else {
539  if(isDCALpatch) continue;
540  }
541  if(!IsOfflineSimplePatch(*patchIter)) continue;
542  if(isSingleShower){
543  if(!SelectSingleShowerPatch(*patchIter)) continue;
544  } else{
545  if(!SelectJetPatch(*patchIter)) continue;
546  }
547  if(GetPatchEnergy(*patchIter) > fOfflineEnergyThreshold[trgcls]) nfound++;
548  }
549  return nfound > 0;
550 }
551 
557 TString AliAnalysisTaskEmcalClustersRef::GetFiredTriggerClassesFromPatches(const TClonesArray* triggerpatches) const {
558  TString triggerstring = "";
559  if(!triggerpatches) return triggerstring;
560  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
561  double minADC_EJ1 = 260.,
562  minADC_EJ2 = 127.,
563  minADC_EG1 = 140.,
564  minADC_EG2 = 89.;
565  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
566  AliEmcalTriggerPatchInfo *patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(*patchIter);
567  if(!patch->IsOfflineSimple()) continue;
568  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
569  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
570  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
571  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
572  }
573  if(nEJ1) triggerstring += "EJ1";
574  if(nEJ2){
575  if(triggerstring.Length()) triggerstring += ",";
576  triggerstring += "EJ2";
577  }
578  if(nEG1){
579  if(triggerstring.Length()) triggerstring += ",";
580  triggerstring += "EG1";
581  }
582  if(nEG2){
583  if(triggerstring.Length()) triggerstring += ",";
584  triggerstring += "EG2";
585  }
586  return triggerstring;
587 }
588 
589 void AliAnalysisTaskEmcalClustersRef::GetPatchBoundaries(TObject *o, Double_t *boundaries) const {
590  AliEmcalTriggerPatchInfo *patch(NULL);
591  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
592  boundaries[0] = patch->GetEtaMin();
593  boundaries[1] = patch->GetEtaMax();
594  boundaries[2] = patch->GetPhiMin();
595  boundaries[3] = patch->GetPhiMax();
596  } else {
597  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
598  if(newpatch){
599  boundaries[0] = newpatch->GetEtaMin();
600  boundaries[1] = newpatch->GetEtaMax();
601  boundaries[2] = newpatch->GetPhiMin();
602  boundaries[3] = newpatch->GetPhiMax();
603  }
604  }
605 
606 }
607 
608 bool AliAnalysisTaskEmcalClustersRef::IsOfflineSimplePatch(TObject *o) const {
609  AliEmcalTriggerPatchInfo *patch(NULL);
610  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
611  return patch->IsOfflineSimple();
612  } else {
613  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
614  if(newpatch) return newpatch->IsOfflineSimple();
615  }
616  return false;
617 }
618 
619 bool AliAnalysisTaskEmcalClustersRef::SelectDCALPatch(TObject *o) const {
620  AliEmcalTriggerPatchInfo *patch(NULL);
621  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
622  return patch->GetRowStart() >= 64;
623  } else {
624  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
625  if(newpatch) return newpatch->GetRowStart() >= 64;
626  }
627  return false;
628 }
629 
630 bool AliAnalysisTaskEmcalClustersRef::SelectSingleShowerPatch(TObject *o) const{
631  AliEmcalTriggerPatchInfo *patch(NULL);
632  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
633  if(!patch->IsOfflineSimple()) return false;
634  return patch->IsGammaLowSimple();
635  } else {
636  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
637  if(newpatch) return newpatch->IsGammaLowSimple();
638  }
639  return false;
640 }
641 
642 bool AliAnalysisTaskEmcalClustersRef::SelectJetPatch(TObject *o) const{
643  AliEmcalTriggerPatchInfo *patch(NULL);
644  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
645  if(!patch->IsOfflineSimple()) return false;
646  return patch->IsJetLowSimple();
647  } else {
648  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
649  if(newpatch) return newpatch->IsJetLowSimple();
650  }
651  return false;
652 }
653 
654 
655 double AliAnalysisTaskEmcalClustersRef::GetPatchEnergy(TObject *o) const {
656  double energy = 0.;
657  AliEmcalTriggerPatchInfo *patch(NULL);
658  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
659  if(!patch->IsOfflineSimple()) return false;
660  energy = patch->GetPatchE();
661  } else {
662  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
663  if(newpatch) energy = newpatch->GetPatchE();
664  }
665  return energy;
666 }
667 
668 } /* namespace EMCalTriggerPtAnalysis */
ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskEmcalClustersRef) namespace EMCalTriggerPtAnalysis
const Double_t etamin
Declarartion of class AliEMCalHistoContainer.
energy
const Double_t etamax
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
const Int_t nbins
const Double_t phimin