AliPhysics  v5-06-40-01 (42bb456)
 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 <vector>
16 #include <map>
17 
18 #include <TArrayD.h>
19 #include <TClonesArray.h>
20 #include <THashList.h>
21 #include <TLorentzVector.h>
22 #include <TString.h>
23 
24 #include "AliAnalysisUtils.h"
26 #include "AliEMCalHistoContainer.h"
27 #include "AliInputEventHandler.h"
28 #include "AliLog.h"
29 #include "AliVCluster.h"
30 #include "AliVVertex.h"
31 
33 
35 
36 namespace EMCalTriggerPtAnalysis {
37 
41 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef() :
42  AliAnalysisTaskSE(),
43  fAnalysisUtil(NULL),
44  fHistos(NULL),
45  fClusterContainer(""),
46  fTriggerStringFromPatches(kFALSE)
47 {
48 
49 }
50 
55 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef(const char *name) :
56  AliAnalysisTaskSE(name),
57  fAnalysisUtil(),
58  fHistos(),
59  fClusterContainer(""),
60  fTriggerStringFromPatches(kFALSE)
61 {
62  DefineOutput(1, TList::Class());
63 }
64 
68 AliAnalysisTaskEmcalClustersRef::~AliAnalysisTaskEmcalClustersRef() {
69 }
70 
74 void AliAnalysisTaskEmcalClustersRef::UserCreateOutputObjects(){
75  fAnalysisUtil = new AliAnalysisUtils;
76 
77  TArrayD energybinning;
78  CreateEnergyBinning(energybinning);
79  fHistos = new AliEMCalHistoContainer("Ref");
80  TString triggers[14] = {"MB", "EJ1", "EJ2", "EG1", "EG2", "EG2excl", "EJ2excl", "MBexcl", "E1combined", "E1Jonly", "E1Gonly", "E2combined", "E2Jonly", "E2Gonly"};
81  Double_t encuts[5] = {1., 2., 5., 10., 20.};
82  for(TString *trg = triggers; trg < triggers+14; trg++){
83  fHistos->CreateTH1(Form("hEventCount%s", trg->Data()), Form("Event count for trigger class %s", trg->Data()), 1, 0.5, 1.5);
84  fHistos->CreateTH1(Form("hClusterEnergy%s", trg->Data()), Form("Cluster energy for trigger class %s", trg->Data()), energybinning);
85  for(int ien = 0; ien < 5; ien++){
86  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, 100, 1.4, 3.2);
87  }
88  }
89  PostData(1, fHistos->GetListOfHistograms());
90 }
91 
92 
97 void AliAnalysisTaskEmcalClustersRef::UserExec(Option_t *){
98  TString triggerstring = "";
99  if(fTriggerStringFromPatches){
100  triggerstring = GetFiredTriggerClassesFromPatches(dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers")));
101  } else {
102  triggerstring = fInputEvent->GetFiredTriggerClasses();
103  }
104  Bool_t isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7,
105  isEJ1 = triggerstring.Contains("EJ1"),
106  isEJ2 = triggerstring.Contains("EJ2"),
107  isEG1 = triggerstring.Contains("EG1"),
108  isEG2 = triggerstring.Contains("EG2");
109  if(!(isMinBias || isEG1 || isEG2 || isEJ1 || isEJ2)) return;
110  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
111  //if(!fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) return; // reject pileup event
112  if(vtx->GetNContributors() < 1) return;
113  // Fill reference distribution for the primary vertex before any z-cut
114  if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent)) return; // Apply new vertex cut
115  if(fAnalysisUtil->IsPileUpEvent(fInputEvent)) return; // Apply new vertex cut
116  // Apply vertex z cut
117  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return;
118 
119  // Fill Event counter and reference vertex distributions for the different trigger classes
120  if(isMinBias){
121  fHistos->FillTH1("hEventCountMB", 1);
122  // Check for exclusive classes
123  if(!(isEG1 || isEG2 || isEJ1 || isEJ2)){
124  fHistos->FillTH1("hEventCountMBexcl", 1);
125  }
126  }
127  if(isEJ1){
128  fHistos->FillTH1("hEventCountEJ1", 1);
129  if(isEG1 || isEG2){
130  fHistos->FillTH1("hEventCountE1combined", 1);
131  } else {
132  fHistos->FillTH1("hEventCountE1Jonly", 1);
133  }
134 
135  }
136  if(isEJ2){
137  fHistos->FillTH1("hEventCountEJ2", 1);
138  // Check for exclusive classes
139  if(!isEJ1){
140  fHistos->FillTH1("hEventCountEJ2excl", 1);
141  }
142  if(isEG1 || isEG2){
143  fHistos->FillTH1("hEventCountE2combined", 1);
144  } else {
145  fHistos->FillTH1("hEventCountE2Jonly", 1);
146  }
147 
148  }
149  if(isEG1){
150  fHistos->FillTH1("hEventCountEG1", 1);
151  }
152  if(isEG2){
153  fHistos->FillTH1("hEventCountEG2", 1);
154  // Check for exclusive classes
155  if(!isEG1){
156  fHistos->FillTH1("hEventCountEG2excl", 1);
157  }
158  }
159 
160  TClonesArray *clusterArray = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject(fClusterContainer.Data()));
161  if(!clusterArray){
162  AliError("Cluster array not found");
163  return;
164  }
165 
166  Double_t vertexpos[3];
167  fInputEvent->GetPrimaryVertex()->GetXYZ(vertexpos);
168 
169  Double_t energy, eta, phi;
170  for(TIter clustIter = TIter(clusterArray).Begin(); clustIter != TIter::End(); ++clustIter){
171  AliVCluster *clust = static_cast<AliVCluster *>(*clustIter);
172  if(!clust->IsEMCAL()) continue;
173 
174  TLorentzVector posvec;
175  energy = clust->E();
176  clust->GetMomentum(posvec, vertexpos);
177  eta = posvec.Eta();
178  phi = posvec.Phi();
179 
180  // fill histograms allEta
181  if(isMinBias){
182  FillClusterHistograms("MB", energy, eta, phi);
183  // check for exclusive classes
184  if(!(isEG1 || isEG2 || isEJ1 || isEJ2)){
185  FillClusterHistograms("MBexcl", energy, eta, phi);
186  }
187  }
188  if(isEJ1){
189  FillClusterHistograms("EJ1", energy, eta, phi);
190  if(isEG1 || isEG2) {
191  FillClusterHistograms("E1combined", energy, eta, phi);
192  } else {
193  FillClusterHistograms("E1Jonly", energy, eta, phi);
194  }
195  }
196  if(isEJ2){
197  FillClusterHistograms("EJ2", energy, eta, phi);
198  // check for exclusive classes
199  if(!isEJ1){
200  FillClusterHistograms("EJ2excl", energy, eta, phi);
201  }
202  if(isEG1 || isEG2){
203  FillClusterHistograms("E2combined", energy, eta, phi);
204  } else {
205  FillClusterHistograms("E2Jonly", energy, eta, phi);
206  }
207  }
208  if(isEG1){
209  FillClusterHistograms("EG1", energy, eta, phi);
210  if(!(isEJ1 || isEJ2)){
211  FillClusterHistograms("E1Gonly", energy, eta, phi);
212  }
213  }
214  if(isEG2){
215  FillClusterHistograms("EG2", energy, eta, phi);
216  // check for exclusive classes
217  if(!isEG1){
218  FillClusterHistograms("EG2excl", energy, eta, phi);
219  }
220  if(!(isEJ2 || isEJ1)){
221  FillClusterHistograms("E2Gonly", energy, eta, phi);
222  }
223  }
224 
225  }
226  PostData(1, fHistos->GetListOfHistograms());
227 }
228 
229 void AliAnalysisTaskEmcalClustersRef::FillClusterHistograms(TString triggerclass, double energy, double eta, double phi){
230  fHistos->FillTH1(Form("hClusterEnergy%s", triggerclass.Data()), energy);
231  Double_t encuts[5] = {1., 2., 5., 10., 20.};
232  for(int ien = 0; ien < 5; ien++){
233  if(energy > encuts[ien]){
234  fHistos->FillTH2(Form("hEtaPhi%dG%s", static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi);
235  }
236  }
237 }
238 
243 void AliAnalysisTaskEmcalClustersRef::CreateEnergyBinning(TArrayD& binning) const {
244  std::vector<double> mybinning;
245  std::map<double,double> definitions;
246  definitions.insert(std::pair<double, double>(1, 0.05));
247  definitions.insert(std::pair<double, double>(2, 0.1));
248  definitions.insert(std::pair<double, double>(4, 0.2));
249  definitions.insert(std::pair<double, double>(7, 0.5));
250  definitions.insert(std::pair<double, double>(16, 1));
251  definitions.insert(std::pair<double, double>(32, 2));
252  definitions.insert(std::pair<double, double>(40, 4));
253  definitions.insert(std::pair<double, double>(50, 5));
254  definitions.insert(std::pair<double, double>(100, 10));
255  definitions.insert(std::pair<double, double>(200, 20));
256  double currentval = 0.;
257  mybinning.push_back(currentval);
258  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
259  double limit = id->first, binwidth = id->second;
260  while(currentval < limit){
261  currentval += binwidth;
262  mybinning.push_back(currentval);
263  }
264  }
265  binning.Set(mybinning.size());
266  int ib = 0;
267  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
268  binning[ib++] = *it;
269 }
270 
276 TString AliAnalysisTaskEmcalClustersRef::GetFiredTriggerClassesFromPatches(const TClonesArray* triggerpatches) const {
277  TString triggerstring = "";
278  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
279  double minADC_EJ1 = 260.,
280  minADC_EJ2 = 127.,
281  minADC_EG1 = 140.,
282  minADC_EG2 = 89.;
283  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
284  AliEmcalTriggerPatchInfo *patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(*patchIter);
285  if(!patch->IsOfflineSimple()) continue;
286  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
287  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
288  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
289  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
290  }
291  if(nEJ1) triggerstring += "EJ1";
292  if(nEJ2){
293  if(triggerstring.Length()) triggerstring += ",";
294  triggerstring += "EJ2";
295  }
296  if(nEG1){
297  if(triggerstring.Length()) triggerstring += ",";
298  triggerstring += "EG1";
299  }
300  if(nEG2){
301  if(triggerstring.Length()) triggerstring += ",";
302  triggerstring += "EG2";
303  }
304  return triggerstring;
305 }
306 
307 
308 } /* namespace EMCalTriggerPtAnalysis */
ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskEmcalClustersRef) namespace EMCalTriggerPtAnalysis
Main data structure storing all relevant information of EMCAL/DCAL trigger patches.
Declarartion of class AliEMCalHistoContainer.
energy
Class to make array of trigger patch objects in AOD/ESD events.