AliPhysics  1168478 (1168478)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalMaxPatch.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, 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 <functional>
16 #include <iostream>
17 #include <map>
18 #include <string>
19 #include <TClonesArray.h>
20 #include <THashList.h>
21 #include <THistManager.h>
22 
23 #include "AliAnalysisUtils.h"
26 #include "AliEMCALTriggerPatchInfo.h"
27 #include "AliInputEventHandler.h"
28 #include "AliLog.h"
29 
33 
34 namespace EMCalTriggerPtAnalysis {
35 
36 AliAnalysisTaskEmcalMaxPatch::AliAnalysisTaskEmcalMaxPatch() :
38  fWeightHandler(nullptr),
39  fHistos(nullptr),
40  fSelectTrigger(AliVEvent::kINT7)
41 {
42  SetCaloTriggerPatchInfoName("EmcalTriggers");
43 }
44 
46  AliAnalysisTaskEmcal(name, kTRUE),
47  fWeightHandler(nullptr),
48  fHistos(nullptr),
49  fSelectTrigger(AliVEvent::kINT7)
50 {
51  SetCaloTriggerPatchInfoName("EmcalTriggers");
53 }
54 
56 }
57 
60 
61  if(!fAliAnalysisUtils) fAliAnalysisUtils = new AliAnalysisUtils;
62 
63  fHistos = new THistManager("histMaxPatch");
64  fHistos->CreateTH1("hTrueEventCount", "Maximum energy patch in the event", 1, 0.5, 1.5);
65 
66  const std::map<std::string, std::string> triggers {
67  {"EGAOffline", "offline EGA"}, {"EJEOffline", "offline EJE"}, {"DGAOffline", "offline DGA"}, {"DJEOffline", "offline DJE"},
68  {"EGARecalc", "recalc EGA"}, {"EJERecalc", "recalc EJE"}, {"DGARecalc", "recalc DGA"}, {"DJERecalc", "recalc DJE"},
69  {"EG1Online", "online EG1"}, {"EG2Online", "online EG2"}, {"DG1Online", "online DG1"}, {"DG2Online", "online DG2"},
70  {"EJ1Online", "online EJ1"}, {"EJ2Online", "online EJ2"}, {"DJ1Online", "online DJ1"}, {"DJ2Online", "online DJ2"},
71  };
72  // Calibrated FEE energy
73  for(const auto &t : triggers)
74  fHistos->CreateTH1(Form("hPatchEnergyMax%s", t.first.c_str()), Form("Energy spectrum of the maximum %s patch", t.second.c_str()), 2000, 0., 200.);
75 
76  // Online ADC counts
77  for(const auto &t : triggers)
78  fHistos->CreateTH1(Form("hPatchADCMax%s", t.first.c_str()), Form("ADC spectrum of the maximum %s patch", t.second.c_str()), 2049, -0.5, 2048.5);
79 
80  // ADC vs energy
81  for(const auto &t : triggers)
82  fHistos->CreateTH2(Form("hPatchADCvsEnergyMax%s", t.first.c_str()), Form("ADC vs. Energy of the maximum %s patch", t.second.c_str()), 300, 0., 3000, 200, 0., 200.);
83 
84  for(auto h : *(fHistos->GetListOfHistograms())) fOutput->Add(h);
85 
86  PostData(1, fOutput);
87 }
88 
90  AliDebugStream(2) << GetName() << ": Using custom event selection method" << std::endl;
91  if(!fTriggerPatchInfo){
92  AliErrorStream() << GetName() << ": Trigger patch container not found but required" << std::endl;
93  return false;
94  }
95  if(!(fInputHandler->IsEventSelected() & fSelectTrigger)) return false;
96  if(fTriggerPattern.Length()){
97  TString triggerstring = InputEvent()->GetFiredTriggerClasses();
98  if(!triggerstring.Contains(fTriggerPattern)) return false;
99  }
100  AliDebugStream(3) << GetName() << "Event is selected for the given trigger" << std::endl;
101 
102  // Generall event quality cuts
103  // The vertex cut also contains cuts on the number
104  // of contributors and the position in z
105  AliDebugStream(3) << GetName() << ": Applying vertex selection" << std::endl;
106  if(fAliAnalysisUtils){
107  if(!fAliAnalysisUtils->IsVertexSelected2013pA(InputEvent())) return false;
108  if(fAliAnalysisUtils->IsPileUpEvent(InputEvent())) return false;
109  AliDebugStream(3) << GetName() << ": Vertex selection passed" << std::endl;
110  }
111 
112  AliDebugStream(2) << GetName() << "Event selected" << std::endl;
113  return true;
114 }
115 
117  fHistos->FillTH1("hTrueEventCount", 1);
118 
119  const AliEMCALTriggerPatchInfo *currentpatch(nullptr),
120  *maxOfflineEGA(nullptr),
121  *maxOfflineEJE(nullptr),
122  *maxOfflineDGA(nullptr),
123  *maxOfflineDJE(nullptr),
124  *maxRecalcEGA(nullptr),
125  *maxRecalcEJE(nullptr),
126  *maxRecalcDGA(nullptr),
127  *maxRecalcDJE(nullptr),
128  *maxOnlineEG1(nullptr),
129  *maxOnlineEG2(nullptr),
130  *maxOnlineDG1(nullptr),
131  *maxOnlineDG2(nullptr),
132  *maxOnlineEJ1(nullptr),
133  *maxOnlineEJ2(nullptr),
134  *maxOnlineDJ1(nullptr),
135  *maxOnlineDJ2(nullptr);
136 
137  // Find the maximum patch for each cathegory
138  for(auto patchiter : *fTriggerPatchInfo){
139  currentpatch = static_cast<AliEMCALTriggerPatchInfo *>(patchiter);
140 
141  // Offline patches - make cut on energy
142  if(currentpatch->IsOfflineSimple()){
143  if(currentpatch->IsGammaHighSimple()){
144  if(currentpatch->IsEMCal()){
145  if(!maxOfflineEGA || currentpatch->GetPatchE() > maxOfflineEGA->GetPatchE())
146  maxOfflineEGA = currentpatch;
147  } else {
148  if(!maxOfflineDGA || currentpatch->GetPatchE() > maxOfflineDGA->GetPatchE())
149  maxOfflineDGA = currentpatch;
150  }
151  } else if(currentpatch->IsJetHighSimple()) {
152  if(currentpatch->IsEMCal()){
153  if(!maxOfflineEJE || currentpatch->GetPatchE() > maxOfflineEJE->GetPatchE())
154  maxOfflineEJE = currentpatch;
155  } else {
156  if(!maxOfflineDJE || currentpatch->GetPatchE() > maxOfflineDJE->GetPatchE())
157  maxOfflineDJE = currentpatch;
158  }
159  }
160  }
161 
162  // Recalc patches - make cut on FastOR ADC
163  if(currentpatch->IsRecalc()){
164  if(currentpatch->IsGammaHighRecalc()){
165  if(currentpatch->IsEMCal()){
166  if(!maxRecalcEGA || currentpatch->GetADCAmp() > maxRecalcEGA->GetADCAmp())
167  maxRecalcEGA = currentpatch;
168  } else {
169  if(!maxRecalcDGA || currentpatch->GetADCAmp() > maxRecalcDGA->GetADCAmp())
170  maxRecalcDGA = currentpatch;
171  }
172  } else if(currentpatch->IsJetHighSimple()) {
173  if(currentpatch->IsEMCal()){
174  if(!maxRecalcEJE || currentpatch->GetADCAmp() > maxRecalcEJE->GetADCAmp())
175  maxRecalcEJE = currentpatch;
176  } else {
177  if(!maxRecalcDJE || currentpatch->GetADCAmp() > maxRecalcDJE->GetADCAmp())
178  maxRecalcDJE = currentpatch;
179  }
180  }
181  }
182 
183  // Online patches
184  if(currentpatch->IsGammaHigh() || currentpatch->IsGammaLow()){
185  if(currentpatch->IsEMCal()){
186  if(currentpatch->IsGammaHigh()){
187  if(!maxOnlineEG1 || currentpatch->GetADCAmp() > maxOnlineEG1->GetADCAmp())
188  maxOnlineEG1 = currentpatch;
189  }
190  if(currentpatch->IsGammaLow()){
191  if(!maxOnlineEG2 || currentpatch->GetADCAmp() > maxOnlineEG2->GetADCAmp())
192  maxOnlineEG2 = currentpatch;
193  }
194  } else {
195  if(currentpatch->IsGammaHigh()){
196  if(!maxOnlineDG1 || currentpatch->GetADCAmp() > maxOnlineDG1->GetADCAmp())
197  maxOnlineDG1 = currentpatch;
198  }
199  if(currentpatch->IsGammaLow()){
200  if(!maxOnlineDG2 || currentpatch->GetADCAmp() > maxOnlineDG2->GetADCAmp())
201  maxOnlineDG2 = currentpatch;
202  }
203  }
204  }
205 
206  if(currentpatch->IsJetHigh() || currentpatch->IsJetLow()){
207  if(currentpatch->IsEMCal()){
208  if(currentpatch->IsJetHigh()){
209  if(!maxOnlineEJ1 || currentpatch->GetADCAmp() > maxOnlineEJ1->GetADCAmp())
210  maxOnlineEJ1 = currentpatch;
211  }
212  if(currentpatch->IsJetLow()){
213  if(!maxOnlineEJ2 || currentpatch->GetADCAmp() > maxOnlineEJ2->GetADCAmp())
214  maxOnlineEJ2 = currentpatch;
215  }
216  } else {
217  if(currentpatch->IsJetHigh()){
218  if(!maxOnlineDG1 || currentpatch->GetADCAmp() > maxOnlineDJ1->GetADCAmp())
219  maxOnlineDG1 = currentpatch;
220  }
221  if(currentpatch->IsJetLow()){
222  if(!maxOnlineDJ2 || currentpatch->GetADCAmp() > maxOnlineDJ2->GetADCAmp())
223  maxOnlineDJ2 = currentpatch;
224  }
225  }
226  }
227  }
228 
229  std::function<void (const AliEMCALTriggerPatchInfo *, const std::string &)> FillHistos = [this](const AliEMCALTriggerPatchInfo * testpatch, const std::string & triggername){
230  fHistos->FillTH1(Form("hPatchEnergyMax%s", triggername.c_str()), testpatch ? testpatch->GetPatchE() : 0.);
231  fHistos->FillTH1(Form("hPatchADCMax%s", triggername.c_str()), testpatch ? testpatch->GetADCAmp() : 0.);
232  fHistos->FillTH2(Form("hPatchADCvsEnergyMax%s", triggername.c_str()), testpatch ? testpatch->GetADCAmp() : 0, testpatch ? testpatch->GetPatchE() : 0.);
233  };
234 
235  FillHistos(maxOfflineEGA, "EGAOffline");
236  FillHistos(maxOfflineEJE, "EJEOffline");
237  FillHistos(maxOfflineDGA, "DGAOffline");
238  FillHistos(maxOfflineDJE, "DJEOffline");
239  FillHistos(maxRecalcEGA, "EGARecalc");
240  FillHistos(maxRecalcEJE, "EJERecalc");
241  FillHistos(maxRecalcDGA, "DGARecalc");
242  FillHistos(maxRecalcDJE, "DJERecalc");
243  FillHistos(maxOnlineEG1, "EG1Online");
244  FillHistos(maxOnlineEG2, "EG2Online");
245  FillHistos(maxOnlineDG1, "DG1Online");
246  FillHistos(maxOnlineDG2, "DG2Online");
247  FillHistos(maxOnlineEJ1, "EJ1Online");
248  FillHistos(maxOnlineEJ2, "EJ2Online");
249  FillHistos(maxOnlineDJ1, "DJ1Online");
250  FillHistos(maxOnlineDJ2, "DJ2Online");
251 
252  return true;
253 }
254 
255 } /* namespace EMCalTriggerPtAnalysis */
Base task in the EMCAL framework.
TString fTriggerPattern
Trigger pattern string (i.e. EG1)
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
Simple task monitoring the energy spectrum of the maximum patch in the event.
void SetCaloTriggerPatchInfoName(const char *n)
THistManager * fHistos
! Local Histogram handler. Histograms are stored in the AliEmcalList later
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
AliAnalysisUtils * fAliAnalysisUtils
!vertex selection (optional)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
AliEmcalList * fOutput
!output list
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
void SetMakeGeneralHistograms(Bool_t g)
TClonesArray * fTriggerPatchInfo
!trigger patch info array
Container class for histograms.
Definition: THistManager.h:99
void UserCreateOutputObjects()
Main initialization function on the worker.
bool Bool_t
Definition: External.C:53