AliPhysics  0937c79 (0937c79)
AliEmcalTriggerRejectionMaker.cxx
Go to the documentation of this file.
1 /**************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  **************************************************************************************/
27 #include <functional>
28 #include <iostream>
29 #include <map>
30 #include <string>
31 #include <TClonesArray.h>
32 #include <THashList.h>
33 #include <THistManager.h>
34 
35 #include "AliAnalysisUtils.h"
36 #include "AliEMCALTriggerPatchInfo.h"
38 #include "AliInputEventHandler.h"
39 #include "AliLog.h"
40 
44 
45 using namespace PWG::EMCAL;
46 
49  fHistos(nullptr),
50  fSelectTrigger(AliVEvent::kINT7)
51 {
52  SetCaloTriggerPatchInfoName("EmcalTriggers");
53 }
54 
55 AliEmcalTriggerRejectionMaker::AliEmcalTriggerRejectionMaker(const char *name) :
56  AliAnalysisTaskEmcal(name, kTRUE),
57  fHistos(nullptr),
58  fSelectTrigger(AliVEvent::kINT7)
59 {
60  SetCaloTriggerPatchInfoName("EmcalTriggers");
62 }
63 
65 }
66 
69 
70  if(!fAliAnalysisUtils) fAliAnalysisUtils = new AliAnalysisUtils;
71 
72  fHistos = new THistManager("histMaxPatch");
73  fHistos->CreateTH1("hTrueEventCount", "Maximum energy patch in the event", 1, 0.5, 1.5);
74 
75  const std::map<TString, TString> triggers {
76  {"EGAOffline", "offline EGA"}, {"EJEOffline", "offline EJE"}, {"DGAOffline", "offline DGA"}, {"DJEOffline", "offline DJE"},
77  {"EGARecalc", "recalc EGA"}, {"EJERecalc", "recalc EJE"}, {"DGARecalc", "recalc DGA"}, {"DJERecalc", "recalc DJE"},
78  {"EG1Online", "online EG1"}, {"EG2Online", "online EG2"}, {"DG1Online", "online DG1"}, {"DG2Online", "online DG2"},
79  {"EJ1Online", "online EJ1"}, {"EJ2Online", "online EJ2"}, {"DJ1Online", "online DJ1"}, {"DJ2Online", "online DJ2"},
80  };
81  // Calibrated FEE energy
82  for(const auto &t : triggers)
83  fHistos->CreateTH1("hPatchEnergyMax" + t.first, "Energy spectrum of the maximum " + t.second + " patch", 2000, 0., 200.);
84 
85  // Online ADC counts
86  for(const auto &t : triggers)
87  fHistos->CreateTH1("hPatchADCMax" + t.first, "ADC spectrum of the maximum " + t.second + " patch", 2049, -0.5, 2048.5);
88 
89  // ADC vs energy
90  for(const auto &t : triggers)
91  fHistos->CreateTH2("hPatchADCvsEnergyMax" + t.first, "ADC vs. Energy of the maximum " + t.second + " patch", 300, 0., 3000, 200, 0., 200.);
92 
93  for(auto h : *(fHistos->GetListOfHistograms())) fOutput->Add(h);
94 
95  PostData(1, fOutput);
96 }
97 
99  AliDebugStream(2) << GetName() << ": Using custom event selection method" << std::endl;
100  if(!fTriggerPatchInfo){
101  AliErrorStream() << GetName() << ": Trigger patch container not found but required" << std::endl;
102  return false;
103  }
104  if(!(fInputHandler->IsEventSelected() & fSelectTrigger)) return false;
105  if(fTriggerPattern.Length()){
106  TString triggerstring = InputEvent()->GetFiredTriggerClasses();
107  if(!triggerstring.Contains(fTriggerPattern)) return false;
108  }
109  AliDebugStream(3) << GetName() << "Event is selected for the given trigger" << std::endl;
110 
111  // Generall event quality cuts
112  // The vertex cut also contains cuts on the number
113  // of contributors and the position in z
114  AliDebugStream(3) << GetName() << ": Applying vertex selection" << std::endl;
115  if(fAliAnalysisUtils){
116  if(!fAliAnalysisUtils->IsVertexSelected2013pA(InputEvent())) return false;
117  if(fAliAnalysisUtils->IsPileUpEvent(InputEvent())) return false;
118  AliDebugStream(3) << GetName() << ": Vertex selection passed" << std::endl;
119  }
120 
121  AliDebugStream(2) << GetName() << "Event selected" << std::endl;
122  return true;
123 }
124 
126  fHistos->FillTH1("hTrueEventCount", 1);
127 
128  const AliEMCALTriggerPatchInfo *currentpatch(nullptr),
129  *maxOfflineEGA(nullptr),
130  *maxOfflineEJE(nullptr),
131  *maxOfflineDGA(nullptr),
132  *maxOfflineDJE(nullptr),
133  *maxRecalcEGA(nullptr),
134  *maxRecalcEJE(nullptr),
135  *maxRecalcDGA(nullptr),
136  *maxRecalcDJE(nullptr),
137  *maxOnlineEG1(nullptr),
138  *maxOnlineEG2(nullptr),
139  *maxOnlineDG1(nullptr),
140  *maxOnlineDG2(nullptr),
141  *maxOnlineEJ1(nullptr),
142  *maxOnlineEJ2(nullptr),
143  *maxOnlineDJ1(nullptr),
144  *maxOnlineDJ2(nullptr);
145 
146  // Find the maximum patch for each cathegory
147  for(auto patchiter : *fTriggerPatchInfo){
148  currentpatch = static_cast<AliEMCALTriggerPatchInfo *>(patchiter);
149 
150  // Offline patches - make cut on energy
151  if(currentpatch->IsOfflineSimple()){
152  if(currentpatch->IsGammaHighSimple()){
153  if(currentpatch->IsEMCal()){
154  if(!maxOfflineEGA || currentpatch->GetPatchE() > maxOfflineEGA->GetPatchE())
155  maxOfflineEGA = currentpatch;
156  } else {
157  if(!maxOfflineDGA || currentpatch->GetPatchE() > maxOfflineDGA->GetPatchE())
158  maxOfflineDGA = currentpatch;
159  }
160  } else if(currentpatch->IsJetHighSimple()) {
161  if(currentpatch->IsEMCal()){
162  if(!maxOfflineEJE || currentpatch->GetPatchE() > maxOfflineEJE->GetPatchE())
163  maxOfflineEJE = currentpatch;
164  } else {
165  if(!maxOfflineDJE || currentpatch->GetPatchE() > maxOfflineDJE->GetPatchE())
166  maxOfflineDJE = currentpatch;
167  }
168  }
169  }
170 
171  // Recalc patches - make cut on FastOR ADC
172  if(currentpatch->IsRecalc()){
173  if(currentpatch->IsGammaHighRecalc()){
174  if(currentpatch->IsEMCal()){
175  if(!maxRecalcEGA || currentpatch->GetADCAmp() > maxRecalcEGA->GetADCAmp())
176  maxRecalcEGA = currentpatch;
177  } else {
178  if(!maxRecalcDGA || currentpatch->GetADCAmp() > maxRecalcDGA->GetADCAmp())
179  maxRecalcDGA = currentpatch;
180  }
181  } else if(currentpatch->IsJetHighSimple()) {
182  if(currentpatch->IsEMCal()){
183  if(!maxRecalcEJE || currentpatch->GetADCAmp() > maxRecalcEJE->GetADCAmp())
184  maxRecalcEJE = currentpatch;
185  } else {
186  if(!maxRecalcDJE || currentpatch->GetADCAmp() > maxRecalcDJE->GetADCAmp())
187  maxRecalcDJE = currentpatch;
188  }
189  }
190  }
191 
192  // Online patches
193  if(currentpatch->IsGammaHigh() || currentpatch->IsGammaLow()){
194  if(currentpatch->IsEMCal()){
195  if(currentpatch->IsGammaHigh()){
196  if(!maxOnlineEG1 || currentpatch->GetADCAmp() > maxOnlineEG1->GetADCAmp())
197  maxOnlineEG1 = currentpatch;
198  }
199  if(currentpatch->IsGammaLow()){
200  if(!maxOnlineEG2 || currentpatch->GetADCAmp() > maxOnlineEG2->GetADCAmp())
201  maxOnlineEG2 = currentpatch;
202  }
203  } else {
204  if(currentpatch->IsGammaHigh()){
205  if(!maxOnlineDG1 || currentpatch->GetADCAmp() > maxOnlineDG1->GetADCAmp())
206  maxOnlineDG1 = currentpatch;
207  }
208  if(currentpatch->IsGammaLow()){
209  if(!maxOnlineDG2 || currentpatch->GetADCAmp() > maxOnlineDG2->GetADCAmp())
210  maxOnlineDG2 = currentpatch;
211  }
212  }
213  }
214 
215  if(currentpatch->IsJetHigh() || currentpatch->IsJetLow()){
216  if(currentpatch->IsEMCal()){
217  if(currentpatch->IsJetHigh()){
218  if(!maxOnlineEJ1 || currentpatch->GetADCAmp() > maxOnlineEJ1->GetADCAmp())
219  maxOnlineEJ1 = currentpatch;
220  }
221  if(currentpatch->IsJetLow()){
222  if(!maxOnlineEJ2 || currentpatch->GetADCAmp() > maxOnlineEJ2->GetADCAmp())
223  maxOnlineEJ2 = currentpatch;
224  }
225  } else {
226  if(currentpatch->IsJetHigh()){
227  if(!maxOnlineDG1 || currentpatch->GetADCAmp() > maxOnlineDJ1->GetADCAmp())
228  maxOnlineDG1 = currentpatch;
229  }
230  if(currentpatch->IsJetLow()){
231  if(!maxOnlineDJ2 || currentpatch->GetADCAmp() > maxOnlineDJ2->GetADCAmp())
232  maxOnlineDJ2 = currentpatch;
233  }
234  }
235  }
236  }
237 
238  std::function<void (const AliEMCALTriggerPatchInfo *, const TString &)> FillHistos = [this](const AliEMCALTriggerPatchInfo * testpatch, const TString & triggername){
239  fHistos->FillTH1("hPatchEnergyMax" + triggername, testpatch ? testpatch->GetPatchE() : 0.);
240  fHistos->FillTH1("hPatchADCMax" + triggername, testpatch ? testpatch->GetADCAmp() : 0.);
241  fHistos->FillTH2("hPatchADCvsEnergyMax" + triggername, testpatch ? testpatch->GetADCAmp() : 0, testpatch ? testpatch->GetPatchE() : 0.);
242  };
243 
244  FillHistos(maxOfflineEGA, "EGAOffline");
245  FillHistos(maxOfflineEJE, "EJEOffline");
246  FillHistos(maxOfflineDGA, "DGAOffline");
247  FillHistos(maxOfflineDJE, "DJEOffline");
248  FillHistos(maxRecalcEGA, "EGARecalc");
249  FillHistos(maxRecalcEJE, "EJERecalc");
250  FillHistos(maxRecalcDGA, "DGARecalc");
251  FillHistos(maxRecalcDJE, "DJERecalc");
252  FillHistos(maxOnlineEG1, "EG1Online");
253  FillHistos(maxOnlineEG2, "EG2Online");
254  FillHistos(maxOnlineDG1, "DG1Online");
255  FillHistos(maxOnlineDG2, "DG2Online");
256  FillHistos(maxOnlineEJ1, "EJ1Online");
257  FillHistos(maxOnlineEJ2, "EJ2Online");
258  FillHistos(maxOnlineDJ1, "DJ1Online");
259  FillHistos(maxOnlineDJ2, "DJ2Online");
260 
261  return true;
262 
263 } /* namespace EMCalTriggerPtAnalysis */
Base task in the EMCAL framework.
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)
Namespace for EMCAL framework classes and task.
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
TString fTriggerPattern
Trigger pattern string (i.e. EG1)
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)
Namespace for PWG framework classes.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
THistManager * fHistos
! Local Histogram handler. Histograms are stored in the AliEmcalList later
AliEmcalList * fOutput
!output list
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