AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs 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  TObjArray clusterEvent(1000);
260 
261  TCollection *clusterArray = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject(fClusterContainer.Data()));
262  if(!clusterArray){
263  AliError(Form("Cluster array with name %s not found in the event", fClusterContainer.Data()));
264  for(int icl = 0; icl < fInputEvent->GetNumberOfCaloClusters(); icl++){
265  clusterEvent.Add(fInputEvent->GetCaloCluster(icl));
266  }
267  clusterArray = &clusterEvent;
268  }
269 
270  Double_t vertexpos[3];
271  fInputEvent->GetPrimaryVertex()->GetXYZ(vertexpos);
272 
273  Double_t energy, eta, phi;
274  for(TIter clustIter = TIter(clusterArray).Begin(); clustIter != TIter::End(); ++clustIter){
275  AliVCluster *clust = static_cast<AliVCluster *>(*clustIter);
276  if(!clust->IsEMCAL()) continue;
277  if(clust->GetIsExotic()) continue;
278 
279  TLorentzVector posvec;
280  energy = clust->GetNonLinCorrEnergy();
281  clust->GetMomentum(posvec, vertexpos);
282  eta = posvec.Eta();
283  phi = posvec.Phi();
284 
285  // fill histograms allEta
286  if(isMinBias){
287  FillClusterHistograms("MB", energy, posvec.Et(), eta, phi, NULL);
288  if(!(isEMC7 || isDMC7 || isEJ1 || isEJ2 || isEG1 || isEG2 || isDJ1 || isDJ2 || isDG1 || isDG2)){
289  FillClusterHistograms("MBexcl", energy, posvec.Et(), eta, phi, NULL);
290  }
291  }
292  if(isEMC7){
293  FillClusterHistograms("EMC7", energy, posvec.Et(), eta, phi, NULL);
294  if(!(isEJ1 || isEJ2 || isEG1 || isEG2)){
295  FillClusterHistograms("EMC7excl", energy, posvec.Et(), eta, phi, NULL);
296  }
297  }
298  if(isDMC7){
299  FillClusterHistograms("DMC7", energy, posvec.Et(), eta, phi, NULL);
300  if(!(isDJ1 || isDJ2 || isDG1 || isDG2)){
301  FillClusterHistograms("DMC7excl", energy, posvec.Et(), eta, phi, NULL);
302  }
303  }
304  if(isEJ2){
305  TList ej2patches;
306  FindPatchesForTrigger("EJ2", triggerpatches, ej2patches);
307  FillClusterHistograms("EJ2", energy, posvec.Et(), eta, phi, &ej2patches);
308  // check for exclusive classes
309  if(!isEJ1){
310  FillClusterHistograms("EJ2excl", energy, posvec.Et(), eta, phi, &ej2patches);
311  }
312  }
313  if(isDJ2){
314  TList dj2patches;
315  FindPatchesForTrigger("DJ2", triggerpatches, dj2patches);
316  FillClusterHistograms("DJ2", energy, posvec.Et(), eta, phi, &dj2patches);
317  // check for exclusive classes
318  if(!isDJ1){
319  FillClusterHistograms("DJ2excl", energy, posvec.Et(), eta, phi, &dj2patches);
320  }
321  }
322  if(isEJ1){
323  TList ej1patches;
324  FindPatchesForTrigger("EJ1", triggerpatches, ej1patches);
325  FillClusterHistograms("EJ1", energy, posvec.Et(), eta, phi, &ej1patches);
326  }
327  if(isDJ1){
328  TList dj1patches;
329  FindPatchesForTrigger("DJ1", triggerpatches, dj1patches);
330  FillClusterHistograms("DJ1", energy, posvec.Et(), eta, phi, &dj1patches);
331  }
332  if(isEG2){
333  TList eg2patches;
334  FindPatchesForTrigger("EG2", triggerpatches, eg2patches);
335  FillClusterHistograms("EG2", energy, posvec.Et(), eta, phi, &eg2patches);
336  // check for exclusive classes
337  if(!isEG1){
338  FillClusterHistograms("EG2excl", energy, posvec.Et(), eta, phi, &eg2patches);
339  }
340  }
341  if(isDG2){
342  TList dg2patches;
343  FindPatchesForTrigger("DG2", triggerpatches, dg2patches);
344  FillClusterHistograms("DG2", energy, posvec.Et(), eta, phi, &dg2patches);
345  // check for exclusive classes
346  if(!isDG1){
347  FillClusterHistograms("DG2excl", energy, posvec.Et(), eta, phi, &dg2patches);
348  }
349  }
350  if(isEG1){
351  TList eg1patches;
352  FindPatchesForTrigger("EG1", triggerpatches, eg1patches);
353  FillClusterHistograms("EG1", energy, posvec.Et(), eta, phi, &eg1patches);
354  }
355  if(isDG1){
356  TList dg1patches;
357  FindPatchesForTrigger("DG1", triggerpatches, dg1patches);
358  FillClusterHistograms("DG1", energy, posvec.Et(), eta, phi, &dg1patches);
359  }
360  }
361  PostData(1, fHistos->GetListOfHistograms());
362 }
363 
364 void AliAnalysisTaskEmcalClustersRef::FillClusterHistograms(TString triggerclass, double energy, double transverseenergy, double eta, double phi, TList *triggerpatches){
365  Bool_t hasTriggerPatch = triggerpatches ? CorrelateToTrigger(eta, phi, triggerpatches) : kFALSE;
366  Int_t supermoduleID = -1, sector = -1;
367  fGeometry->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
368  fHistos->FillTH1(Form("hClusterEnergy%s", triggerclass.Data()), energy);
369  fHistos->FillTH1(Form("hClusterET%s", triggerclass.Data()), transverseenergy);
370  fHistos->FillTH2(Form("hEtaEnergy%s", triggerclass.Data()), eta, energy);
371  fHistos->FillTH2(Form("hEtaET%s", triggerclass.Data()), eta, transverseenergy);
372  if(supermoduleID >= 0){
373  fHistos->FillTH2(Form("hClusterEnergySM%s", triggerclass.Data()), supermoduleID, energy);
374  fHistos->FillTH2(Form("hClusterETSM%s", triggerclass.Data()), supermoduleID, transverseenergy);
375  fHistos->FillTH2(Form("hEtaEnergySM%d%s", supermoduleID, triggerclass.Data()), eta, energy);
376  fHistos->FillTH2(Form("hEtaETSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy);
377  if(supermoduleID < 12)
378  sector = 4 + int(supermoduleID/2); // EMCAL
379  else
380  sector = 13 + int((supermoduleID-12)/2); // DCAL
381  fHistos->FillTH2(Form("hEtaEnergySec%d%s", sector, triggerclass.Data()), eta, energy);
382  fHistos->FillTH2(Form("hEtaETSec%d%s", sector, triggerclass.Data()), eta, transverseenergy);
383  }
384  if(hasTriggerPatch){
385  fHistos->FillTH1(Form("hClusterEnergyFired%s", triggerclass.Data()), energy);
386  fHistos->FillTH1(Form("hClusterETFired%s", triggerclass.Data()), energy);
387  fHistos->FillTH2(Form("hEtaEnergyFired%s", triggerclass.Data()), eta, energy);
388  fHistos->FillTH2(Form("hEtaETFired%s", triggerclass.Data()), eta, energy);
389  if(supermoduleID >= 0){
390  fHistos->FillTH2(Form("hClusterEnergyFiredSM%s", triggerclass.Data()), supermoduleID, energy);
391  fHistos->FillTH2(Form("hClusterETFiredSM%s", triggerclass.Data()), supermoduleID, transverseenergy);
392  fHistos->FillTH2(Form("hEtaEnergyFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, energy);
393  fHistos->FillTH2(Form("hEtaETFiredSM%d%s", supermoduleID, triggerclass.Data()), eta, transverseenergy);
394  fHistos->FillTH2(Form("hEtaEnergyFiredSec%d%s", sector, triggerclass.Data()), eta, energy);
395  fHistos->FillTH2(Form("hEtaETFiredSec%d%s", sector, triggerclass.Data()), eta, transverseenergy);
396  }
397  }
398  Double_t encuts[5] = {1., 2., 5., 10., 20.};
399  for(int ien = 0; ien < 5; ien++){
400  if(energy > encuts[ien]){
401  fHistos->FillTH2(Form("hEtaPhi%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi);
402  if(hasTriggerPatch){
403  fHistos->FillTH2(Form("hEtaPhiFired%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi);
404  }
405  }
406  }
407 }
408 
413 void AliAnalysisTaskEmcalClustersRef::CreateEnergyBinning(TArrayD& binning) const {
414  std::vector<double> mybinning;
415  std::map<double,double> definitions;
416  definitions.insert(std::pair<double, double>(1, 0.05));
417  definitions.insert(std::pair<double, double>(2, 0.1));
418  definitions.insert(std::pair<double, double>(4, 0.2));
419  definitions.insert(std::pair<double, double>(7, 0.5));
420  definitions.insert(std::pair<double, double>(16, 1));
421  definitions.insert(std::pair<double, double>(32, 2));
422  definitions.insert(std::pair<double, double>(40, 4));
423  definitions.insert(std::pair<double, double>(50, 5));
424  definitions.insert(std::pair<double, double>(100, 10));
425  definitions.insert(std::pair<double, double>(200, 20));
426  double currentval = 0.;
427  mybinning.push_back(currentval);
428  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
429  double limit = id->first, binwidth = id->second;
430  while(currentval < limit){
431  currentval += binwidth;
432  mybinning.push_back(currentval);
433  }
434  }
435  binning.Set(mybinning.size());
436  int ib = 0;
437  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
438  binning[ib++] = *it;
439 }
440 
448 void AliAnalysisTaskEmcalClustersRef::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
449  double binwidth = (max-min)/static_cast<double>(nbins);
450  binning.Set(nbins+1);
451  binning[0] = min;
452  double currentlimit = min + binwidth;
453  for(int ibin = 0; ibin < nbins; ibin++){
454  binning[ibin+1] = currentlimit;
455  currentlimit += binwidth;
456  }
457 }
458 
466 Bool_t AliAnalysisTaskEmcalClustersRef::CorrelateToTrigger(Double_t etaclust, Double_t phiclust, TList *triggerpatches) const {
467  Bool_t hasfound = kFALSE;
468  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
469  Double_t boundaries[4];
470  GetPatchBoundaries(*patchIter, boundaries);
471  Double_t etamin = TMath::Min(boundaries[0], boundaries[1]),
472  etamax = TMath::Max(boundaries[0], boundaries[1]),
473  phimin = TMath::Min(boundaries[2], boundaries[3]),
474  phimax = TMath::Max(boundaries[2], boundaries[3]);
475  if(etaclust > etamin && etaclust < etamax && phiclust > phimin && phiclust < phimax){
476  hasfound = kTRUE;
477  break;
478  }
479  }
480  return hasfound;
481 }
482 
491 void AliAnalysisTaskEmcalClustersRef::FindPatchesForTrigger(TString triggerclass, const TClonesArray * triggerpatches, TList &foundtriggers) const {
492  foundtriggers.Clear();
493  if(!triggerpatches) return;
494  EmcalTriggerClass myclass = kECREL0;
495  if(triggerclass == "EG1") myclass = kECREG1;
496  if(triggerclass == "EG2") myclass = kECREG2;
497  if(triggerclass == "EJ1") myclass = kECREJ1;
498  if(triggerclass == "EJ2") myclass = kECREJ2;
499  if(triggerclass == "DMC7") myclass = kECRDL0;
500  if(triggerclass == "DG1") myclass = kECRDG1;
501  if(triggerclass == "DG2") myclass = kECRDG2;
502  if(triggerclass == "DJ1") myclass = kECRDJ1;
503  if(triggerclass == "DJ2") myclass = kECRDJ2;
504  bool isSingleShower = (
505  (myclass == kECREG1) || (triggerclass == kECREG2) || (myclass == kECREL0)
506  || (myclass == kECRDG1) || (triggerclass == kECRDG2) || (myclass == kECRDL0)
507  ),
508  isDCAL = ((myclass == kECRDL0) || (myclass == kECRDG1) || (myclass == kECRDG2) || (myclass == kECRDJ1) || (myclass == kECRDJ2));
509  AliEmcalTriggerPatchInfoAPV1 *mypatch = NULL;
510  for(TIter patchiter = TIter(triggerpatches).Begin(); patchiter != TIter::End(); ++patchiter){
511  if(!IsOfflineSimplePatch(*patchiter)) continue;
512  if(isDCAL){
513  if(!SelectDCALPatch(*patchiter)) continue;
514  } else {
515  if(SelectDCALPatch(*patchiter)) continue;
516  }
517  if(isSingleShower){
518  if(!SelectSingleShowerPatch(*patchiter)) continue;
519  } else {
520  if(!SelectJetPatch(*patchiter)) continue;
521  }
522  if(GetPatchEnergy(*patchiter) > fOfflineEnergyThreshold[myclass]) foundtriggers.Add(mypatch);
523  }
524 }
525 
534 Bool_t AliAnalysisTaskEmcalClustersRef::IsOfflineSelected(EmcalTriggerClass trgcls, const TClonesArray * const triggerpatches) const {
535  if(fOfflineEnergyThreshold[trgcls] < 0) return true;
536  bool isSingleShower = ((trgcls == kECREL0) || (trgcls == kECREG1) || (trgcls == kECREG2) ||
537  (trgcls == kECRDL0) || (trgcls == kECRDG1) || (trgcls == kECRDG2)),
538  isDCAL = ((trgcls == kECRDL0) || (trgcls == kECRDG1) || (trgcls == kECRDG2) || (trgcls == kECRDJ1) || (trgcls == kECRDJ2));
539  int nfound = 0;
540  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
541  bool isDCALpatch = SelectDCALPatch(*patchIter);
542  if(isDCAL){
543  if(!isDCALpatch) continue;
544  } else {
545  if(isDCALpatch) continue;
546  }
547  if(!IsOfflineSimplePatch(*patchIter)) continue;
548  if(isSingleShower){
549  if(!SelectSingleShowerPatch(*patchIter)) continue;
550  } else{
551  if(!SelectJetPatch(*patchIter)) continue;
552  }
553  if(GetPatchEnergy(*patchIter) > fOfflineEnergyThreshold[trgcls]) nfound++;
554  }
555  return nfound > 0;
556 }
557 
563 TString AliAnalysisTaskEmcalClustersRef::GetFiredTriggerClassesFromPatches(const TClonesArray* triggerpatches) const {
564  TString triggerstring = "";
565  if(!triggerpatches) return triggerstring;
566  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
567  double minADC_EJ1 = 260.,
568  minADC_EJ2 = 127.,
569  minADC_EG1 = 140.,
570  minADC_EG2 = 89.;
571  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
572  AliEmcalTriggerPatchInfo *patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(*patchIter);
573  if(!patch->IsOfflineSimple()) continue;
574  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
575  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
576  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
577  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
578  }
579  if(nEJ1) triggerstring += "EJ1";
580  if(nEJ2){
581  if(triggerstring.Length()) triggerstring += ",";
582  triggerstring += "EJ2";
583  }
584  if(nEG1){
585  if(triggerstring.Length()) triggerstring += ",";
586  triggerstring += "EG1";
587  }
588  if(nEG2){
589  if(triggerstring.Length()) triggerstring += ",";
590  triggerstring += "EG2";
591  }
592  return triggerstring;
593 }
594 
595 void AliAnalysisTaskEmcalClustersRef::GetPatchBoundaries(TObject *o, Double_t *boundaries) const {
596  AliEmcalTriggerPatchInfo *patch(NULL);
597  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
598  boundaries[0] = patch->GetEtaMin();
599  boundaries[1] = patch->GetEtaMax();
600  boundaries[2] = patch->GetPhiMin();
601  boundaries[3] = patch->GetPhiMax();
602  } else {
603  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
604  if(newpatch){
605  boundaries[0] = newpatch->GetEtaMin();
606  boundaries[1] = newpatch->GetEtaMax();
607  boundaries[2] = newpatch->GetPhiMin();
608  boundaries[3] = newpatch->GetPhiMax();
609  }
610  }
611 
612 }
613 
614 bool AliAnalysisTaskEmcalClustersRef::IsOfflineSimplePatch(TObject *o) const {
615  AliEmcalTriggerPatchInfo *patch(NULL);
616  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
617  return patch->IsOfflineSimple();
618  } else {
619  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
620  if(newpatch) return newpatch->IsOfflineSimple();
621  }
622  return false;
623 }
624 
625 bool AliAnalysisTaskEmcalClustersRef::SelectDCALPatch(TObject *o) const {
626  AliEmcalTriggerPatchInfo *patch(NULL);
627  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
628  return patch->GetRowStart() >= 64;
629  } else {
630  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
631  if(newpatch) return newpatch->GetRowStart() >= 64;
632  }
633  return false;
634 }
635 
636 bool AliAnalysisTaskEmcalClustersRef::SelectSingleShowerPatch(TObject *o) const{
637  AliEmcalTriggerPatchInfo *patch(NULL);
638  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
639  if(!patch->IsOfflineSimple()) return false;
640  return patch->IsGammaLowSimple();
641  } else {
642  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
643  if(newpatch) return newpatch->IsGammaLowSimple();
644  }
645  return false;
646 }
647 
648 bool AliAnalysisTaskEmcalClustersRef::SelectJetPatch(TObject *o) const{
649  AliEmcalTriggerPatchInfo *patch(NULL);
650  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
651  if(!patch->IsOfflineSimple()) return false;
652  return patch->IsJetLowSimple();
653  } else {
654  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
655  if(newpatch) return newpatch->IsJetLowSimple();
656  }
657  return false;
658 }
659 
660 
661 double AliAnalysisTaskEmcalClustersRef::GetPatchEnergy(TObject *o) const {
662  double energy = 0.;
663  AliEmcalTriggerPatchInfo *patch(NULL);
664  if((patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(o))){
665  if(!patch->IsOfflineSimple()) return false;
666  energy = patch->GetPatchE();
667  } else {
668  AliEmcalTriggerPatchInfoAPV1 *newpatch = dynamic_cast<AliEmcalTriggerPatchInfoAPV1 *>(o);
669  if(newpatch) energy = newpatch->GetPatchE();
670  }
671  return energy;
672 }
673 
674 } /* 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