AliPhysics  3b4a69f (3b4a69f)
AliAnalysisTaskEmcalOfflinePatchesRef.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 <TClonesArray.h>
16 #include <THashList.h>
17 #include <THistManager.h>
18 #include <TString.h>
19 
20 #include "AliAnalysisUtils.h"
21 #include "AliEMCALGeometry.h"
22 #include "AliEMCALTriggerPatchInfo.h"
23 #include "AliESDEvent.h"
24 #include "AliInputEventHandler.h"
25 #include "AliVEvent.h"
26 #include "AliVVertex.h"
27 
29 
30 #if __cplusplus < 201103L
31 /*
32  * Old C++
33  */
34 #ifndef nullptr
35 #define nullptr NULL
36 #endif
37 #include <vector>
38 #else
39 #include <array>
40 #endif
41 
43 
44 namespace EMCalTriggerPtAnalysis {
45 
46 AliAnalysisTaskEmcalOfflinePatchesRef::AliAnalysisTaskEmcalOfflinePatchesRef():
48  fAnalysisUtil(nullptr),
49  fGeometry(nullptr),
50  fHistos(nullptr)
51 {
52 }
53 
55  AliAnalysisTaskSE(name),
59 {
60  DefineOutput(1, TList::Class());
61 }
62 
64 }
65 
67  fAnalysisUtil = new AliAnalysisUtils;
68 
69  fHistos = new THistManager("Ref");
70  TString triggername;
71  // Plots at global level:
72  // Energy vs. supermodule
73  // Energy vs. eta (all sectors)
74  // Energy vs. eta for sector
75 #if __cplusplus >= 201103L
76  /*
77  * Version for beautifull C++11
78  */
79  std::array<TString, 3> patchnames = {
80  "EL0", "EG1", "EG2"
81  };
82  for(auto mytrg : patchnames){
83  triggername = mytrg;
84 #else
85  /*
86  * Backward compatible version for the ancient technology
87  */
88  std::vector<TString> patchnames;
89  patchnames.push_back("EL0");
90  patchnames.push_back("EG1");
91  patchnames.push_back("EG2");
92  for(std::vector<TString>::iterator mytrg = patchnames.begin(); mytrg != patchnames.end(); ++mytrg){
93  triggername = *mytrg;
94 #endif
95  fHistos->CreateTH1(Form("hEventCount%s", triggername.Data()), Form("Event counter for trigger type %s", triggername.Data()), 1, 0.5, 1.5);
96  fHistos->CreateTH2(Form("hPatchEnergy%s", triggername.Data()), Form("Patch energy versus supermodule for trigger %s", triggername.Data()), 12, -0.5, 11.5, 200, 0., 200.);
97  fHistos->CreateTH2(Form("hPatchET%s", triggername.Data()), Form("Patch transverse energy versus supermodule for trigger %s", triggername.Data()), 12, -0.5, 11.5, 200, 0., 200.);
98  fHistos->CreateTH2(Form("hPatchADC%s", triggername.Data()), Form("Patch online ADC versus supermodule for trigger %s", triggername.Data()), 12, -0.5, 11.5, 2100, 0., 2100.);
99  fHistos->CreateTH2(Form("hPatchEnergyEta%s", triggername.Data()), Form("Patch energy versus eta for trigger %s", triggername.Data()), 100, -0.7, 0.7, 200., 0., 200.);
100  fHistos->CreateTH2(Form("hPatchETEta%s", triggername.Data()), Form("Patch transverse energy versus eta for trigger %s", triggername.Data()), 100, -0.7, 0.7, 200., 0., 200.);
101  fHistos->CreateTH2(Form("hPatchADCEta%s", triggername.Data()), Form("Patch online ADC versus eta for trigger %s", triggername.Data()), 100, -0.7, 0.7, 2100., 0., 2100.);
102  fHistos->CreateTH2(Form("hEvSelPatchEnergy%s", triggername.Data()), Form("Patch energy versus supermodule for trigger %s in selected events", triggername.Data()), 12, -0.5, 11.5, 200, 0., 200.);
103  fHistos->CreateTH2(Form("hEvSelPatchET%s", triggername.Data()), Form("Patch transverse energy versus supermodule for trigger %s in selected events", triggername.Data()), 12, -0.5, 11.5, 200, 0., 200.);
104  fHistos->CreateTH2(Form("hEvSelPatchADC%s", triggername.Data()), Form("Patch online ADC versus supermodule for trigger %s in selected events", triggername.Data()), 12, -0.5, 11.5, 2100, 0., 2100.);
105  fHistos->CreateTH2(Form("hEvSelPatchEnergyEta%s", triggername.Data()), Form("Patch energy versus eta for trigger %s in selected events", triggername.Data()), 100, -0.7, 0.7, 200., 0., 200.);
106  fHistos->CreateTH2(Form("hEvSelPatchETEta%s", triggername.Data()), Form("Patch transverse energy versus eta for trigger %s in selected events", triggername.Data()), 100, -0.7, 0.7, 200., 0., 200.);
107  fHistos->CreateTH2(Form("hEvSelPatchADCEta%s", triggername.Data()), Form("Patch online ADC versus eta for trigger %s in selected events", triggername.Data()), 100, -0.7, 0.7, 2100., 0., 2100.);
108  for(int ism = 0; ism <= 9; ism++){ // small sectors do not yet contribute to trigger decision, thus they are in here for the future
109  fHistos->CreateTH2(Form("hPatchEnergyEta%sSM%d", triggername.Data(), ism), Form("Patch energy versus eta for trigger %s, Supermodule %d", triggername.Data(), ism), 100, -0.7, 0.7, 200., 0., 200.);
110  fHistos->CreateTH2(Form("hPatchETEta%sSM%d", triggername.Data(), ism), Form("Patch transverse energy versus eta for trigger %s, Supermodule %d", triggername.Data(), ism), 100, -0.7, 0.7, 200., 0., 200.);
111  fHistos->CreateTH2(Form("hPatchADCEta%sSM%d", triggername.Data(), ism), Form("Patch online ADC versus eta for trigger %s, Supermodule %d", triggername.Data(), ism), 100, -0.7, 0.7, 2100., 0., 2100.);
112  fHistos->CreateTH2(Form("hEvSelPatchEnergyEta%sSM%d", triggername.Data(), ism), Form("Patch energy versus eta for trigger %s, Supermodule %d in selected events", triggername.Data(), ism), 100, -0.7, 0.7, 200., 0., 200.);
113  fHistos->CreateTH2(Form("hEvSelPatchETEta%sSM%d", triggername.Data(), ism), Form("Patch transverse energy versus eta for trigger %s, Supermodule %d in selected events", triggername.Data(), ism), 100, -0.7, 0.7, 200., 0., 200.);
114  fHistos->CreateTH2(Form("hEvSelPatchADCEta%sSM%d", triggername.Data(), ism), Form("Patch online ADC versus eta for trigger %s, Supermodule %d in selected events", triggername.Data(), ism), 100, -0.7, 0.7, 2100., 0., 2100.);
115  }
116  for(int isec = 4; isec <= 9; isec++){ // small sectors do not yet contribute to trigger decision, thus they are in here for the future
117  fHistos->CreateTH2(Form("hPatchEnergyEta%sSector%d", triggername.Data(), isec), Form("Patch energy versus eta for trigger %s Sector %d", triggername.Data(), isec), 100, -0.7, 0.7, 200., 0., 200.);
118  fHistos->CreateTH2(Form("hPatchETEta%sSector%d", triggername.Data(), isec), Form("Patch transverse energy versus eta for trigger %s Sector %d", triggername.Data(), isec), 100, -0.7, 0.7, 200., 0., 200.);
119  fHistos->CreateTH2(Form("hPatchADCEta%sSector%d", triggername.Data(), isec), Form("Patch online ADC versus eta for trigger %s, Sector %d", triggername.Data(), isec), 100, -0.7, 0.7, 2100., 0., 2100.);
120  fHistos->CreateTH2(Form("hEvSelPatchEnergyEta%sSector%d", triggername.Data(), isec), Form("Patch energy versus eta for trigger %s Sector %d in selectedEvents", triggername.Data(), isec), 100, -0.7, 0.7, 200., 0., 200.);
121  fHistos->CreateTH2(Form("hEvSelPatchETEta%sSector%d", triggername.Data(), isec), Form("Patch transverse energy versus eta for trigger %s Sector %d in selectedEvents", triggername.Data(), isec), 100, -0.7, 0.7, 200., 0., 200.);
122  fHistos->CreateTH2(Form("hEvSelPatchADCEta%sSector%d", triggername.Data(), isec), Form("Patch online ADC versus eta for trigger %s, Sector %d in selectedEvents", triggername.Data(), isec), 100, -0.7, 0.7, 2100., 0., 2100.);
123  }
124  }
125  PostData(1, fHistos->GetListOfHistograms());
126 }
127 
129  if(!fGeometry){
130  fGeometry = AliEMCALGeometry::GetInstance();
131  if(!fGeometry)
132  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
133  }
134  TClonesArray *patches = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
135  TString triggerstring = fInputEvent->GetFiredTriggerClasses();
136  UInt_t selectionstatus = fInputHandler->IsEventSelected();
137  Bool_t isMinBias = selectionstatus & AliVEvent::kINT7,
138  isEG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG1"),
139  isEG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG2"),
140  isEMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("EMC7");
141  if(!(isMinBias || isEG1 || isEG2 || isEMC7)) return;
142  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
143  //if(!fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) return; // reject pileup event
144  if(vtx->GetNContributors() < 1) return;
145  if(fInputEvent->IsA() == AliESDEvent::Class() && fAnalysisUtil->IsFirstEventInChunk(fInputEvent)) return;
146  // Fill reference distribution for the primary vertex before any z-cut
147  if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent)) return; // Apply new vertex cut
148  if(fAnalysisUtil->IsPileUpEvent(fInputEvent)) return; // Apply new vertex cut
149  // Apply vertex z cut
150  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return;
151  if(isEMC7) fHistos->FillTH1("hEventCountEL0", 1);
152  if(isEG1) fHistos->FillTH1("hEventCountEG1", 1);
153  if(isEG2) fHistos->FillTH1("hEventCountEG2", 1);
154 
155  AliEMCALTriggerPatchInfo *mypatch(nullptr);
156  Int_t supermoduleID = -1;
157  TString patchname;
158  for(TIter patchiter = TIter(patches).Begin(); patchiter != TIter::End(); ++patchiter){
159  mypatch = dynamic_cast<AliEMCALTriggerPatchInfo *>(*patchiter);
160  if(!mypatch) continue;
161  // Select only gamma and L0 online patches
162  if(!mypatch->IsOfflineSimple()) continue;
163  if(!mypatch->IsGammaLowSimple()) continue;
164  fGeometry->SuperModuleNumberFromEtaPhi(mypatch->GetEtaCM(), mypatch->GetPhiCM(), supermoduleID);
165  Int_t sector = 4 + int(supermoduleID / 2);
166  if(mypatch->IsGammaLowSimple() && mypatch->GetPatchE() > 3){
167  FillTriggerPatchHistos("EL0", mypatch, supermoduleID, sector, kFALSE);
168  FillTriggerPatchHistos("EG1", mypatch, supermoduleID, sector, kFALSE);
169  FillTriggerPatchHistos("EG2", mypatch, supermoduleID, sector, kFALSE);
170  }
171 
172  // correlate patches with real event classes selected
173  if(isEMC7 && mypatch->IsGammaLowSimple()) FillTriggerPatchHistos("EL0", mypatch, supermoduleID, sector, kTRUE);
174  if(isEG1 && mypatch->IsGammaLowSimple()) FillTriggerPatchHistos("EG1", mypatch, supermoduleID, sector, kTRUE);
175  if(isEG2 && mypatch->IsGammaLowSimple()) FillTriggerPatchHistos("EG2", mypatch, supermoduleID, sector, kTRUE);
176  }
177 
178  PostData(1, fHistos->GetListOfHistograms());
179 }
180 
194 void AliAnalysisTaskEmcalOfflinePatchesRef::FillTriggerPatchHistos(const char *patchtype, const AliEMCALTriggerPatchInfo * const recpatch, Int_t supermoduleID, Int_t sector, Bool_t evsel){
195  TString fbase = evsel ? "hEvSel" : "h";
196  fHistos->FillTH2(Form("%sPatchEnergy%s", fbase.Data(), patchtype), supermoduleID, recpatch->GetPatchE());
197  fHistos->FillTH2(Form("%sPatchET%s", fbase.Data(), patchtype), supermoduleID, recpatch->GetLorentzVectorCenterGeo().Et());
198  fHistos->FillTH2(Form("%sPatchADC%s", fbase.Data(), patchtype), supermoduleID, recpatch->GetADCAmp());
199  fHistos->FillTH2(Form("%sPatchEnergyEta%s", fbase.Data(), patchtype), recpatch->GetEtaCM(), recpatch->GetPatchE());
200  fHistos->FillTH2(Form("%sPatchETEta%s", fbase.Data(), patchtype), recpatch->GetEtaCM(), recpatch->GetLorentzVectorCenterGeo().Et());
201  fHistos->FillTH2(Form("%sPatchADCEta%s", fbase.Data(), patchtype), recpatch->GetEtaCM(), recpatch->GetADCAmp());
202  if(sector >= 4 && sector < 10){
203  fHistos->FillTH2(Form("%sPatchEnergyEta%sSector%d", fbase.Data(), patchtype, sector), recpatch->GetEtaCM(), recpatch->GetPatchE());
204  fHistos->FillTH2(Form("%sPatchETEta%sSector%d", fbase.Data(), patchtype, sector), recpatch->GetEtaCM(), recpatch->GetLorentzVectorCenterGeo().Et());
205  fHistos->FillTH2(Form("%sPatchADCEta%sSector%d", fbase.Data(), patchtype, sector), recpatch->GetEtaCM(), recpatch->GetADCAmp());
206  }
207  if(supermoduleID >= 0 && supermoduleID < 10){
208  fHistos->FillTH2(Form("%sPatchEnergyEta%sSM%d", fbase.Data(), patchtype, supermoduleID), recpatch->GetEtaCM(), recpatch->GetPatchE());
209  fHistos->FillTH2(Form("%sPatchETEta%sSM%d", fbase.Data(), patchtype, supermoduleID), recpatch->GetEtaCM(), recpatch->GetLorentzVectorCenterGeo().Et());
210  fHistos->FillTH2(Form("%sPatchADCEta%sSM%d", fbase.Data(), patchtype, supermoduleID), recpatch->GetEtaCM(), recpatch->GetADCAmp());
211  }
212 }
213 
214 } /* namespace EMCalTriggerPtAnalysis */
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
void FillTriggerPatchHistos(const char *patchtype, const AliEMCALTriggerPatchInfo *const recpatch, Int_t supermodule, Int_t sector, Bool_t evsel)
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.
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
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.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Analysis of high- tracks in triggered events.
Container class for histograms.
Definition: THistManager.h:99
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53