AliPhysics  vAN-20151012 (2287573)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskEmcalOnlinePatchesRef.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 <TString.h>
18 
19 #include "AliAnalysisUtils.h"
20 #include "AliEMCALGeometry.h"
22 #include "AliEMCalHistoContainer.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 AliAnalysisTaskEmcalOnlinePatchesRef::AliAnalysisTaskEmcalOnlinePatchesRef():
47  AliAnalysisTaskSE(),
48  fAnalysisUtil(nullptr),
49  fGeometry(nullptr),
50  fHistos(nullptr)
51 {
52 }
53 
54 AliAnalysisTaskEmcalOnlinePatchesRef::AliAnalysisTaskEmcalOnlinePatchesRef(const char *name):
55  AliAnalysisTaskSE(name),
56  fAnalysisUtil(nullptr),
57  fGeometry(nullptr),
58  fHistos(nullptr)
59 {
60  DefineOutput(1, TList::Class());
61 }
62 
63 AliAnalysisTaskEmcalOnlinePatchesRef::~AliAnalysisTaskEmcalOnlinePatchesRef() {
64 }
65 
66 void AliAnalysisTaskEmcalOnlinePatchesRef::UserCreateOutputObjects(){
67  fAnalysisUtil = new AliAnalysisUtils;
68 
69  fHistos = new AliEMCalHistoContainer("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("hPatchADC%s", triggername.Data()), Form("Patch online ADC versus supermodule for trigger %s", triggername.Data()), 12, -0.5, 11.5, 2100, 0., 2100.);
98  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.);
99  fHistos->CreateTH2(Form("hPatchADCEta%s", triggername.Data()), Form("Patch energy versus eta for trigger %s", triggername.Data()), 100, -0.7, 0.7, 2100., 0., 2100.);
100  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.);
101  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.);
102  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.);
103  fHistos->CreateTH2(Form("hEvSelPatchADCEta%s", triggername.Data()), Form("Patch energy versus eta for trigger %s in selected events", triggername.Data()), 100, -0.7, 0.7, 2100., 0., 2100.);
104  for(int ism = 0; ism <= 9; ism++){ // small sectors do not yet contribute to trigger decision, thus they are in here for the future
105  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.);
106  fHistos->CreateTH2(Form("hPatchADCEta%sSM%d", triggername.Data(), ism), Form("Patch energy versus eta for trigger %s, Supermodule %d", triggername.Data(), ism), 100, -0.7, 0.7, 2100., 0., 2100.);
107  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.);
108  fHistos->CreateTH2(Form("hEvSelPatchADCEta%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, 2100., 0., 2100.);
109  }
110  for(int isec = 4; isec <= 9; isec++){ // small sectors do not yet contribute to trigger decision, thus they are in here for the future
111  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.);
112  fHistos->CreateTH2(Form("hPatchADCEta%sSector%d", triggername.Data(), isec), Form("Patch energy versus eta for trigger %s, Sector %d", triggername.Data(), isec), 100, -0.7, 0.7, 2100., 0., 2100.);
113  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.);
114  fHistos->CreateTH2(Form("hEvSelPatchADCEta%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, 2100., 0., 2100.);
115  }
116  }
117  PostData(1, fHistos->GetListOfHistograms());
118 }
119 
120 void AliAnalysisTaskEmcalOnlinePatchesRef::UserExec(Option_t *){
121  if(!fGeometry){
122  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
123  }
124  TClonesArray *patches = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
125  TString triggerstring = fInputEvent->GetFiredTriggerClasses();
126  UInt_t selectionstatus = fInputHandler->IsEventSelected();
127  Bool_t isMinBias = selectionstatus & AliVEvent::kINT7,
128  isEG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG1"),
129  isEG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG2"),
130  isEMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("EMC7");
131  if(!(isMinBias || isEG1 || isEG2 || isEMC7)) return;
132  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
133  //if(!fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) return; // reject pileup event
134  if(vtx->GetNContributors() < 1) return;
135  if(fInputEvent->IsA() == AliESDEvent::Class() && fAnalysisUtil->IsFirstEventInChunk(fInputEvent)) return;
136  // Fill reference distribution for the primary vertex before any z-cut
137  if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent)) return; // Apply new vertex cut
138  if(fAnalysisUtil->IsPileUpEvent(fInputEvent)) return; // Apply new vertex cut
139  // Apply vertex z cut
140  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return;
141  if(isEMC7) fHistos->FillTH1("hEventCountEL0", 1);
142  if(isEG1) fHistos->FillTH1("hEventCountEG1", 1);
143  if(isEG2) fHistos->FillTH1("hEventCountEG2", 1);
144 
145  AliEmcalTriggerPatchInfo *mypatch(nullptr);
146  Int_t supermoduleID = -1;
147  TString patchname;
148  for(TIter patchiter = TIter(patches).Begin(); patchiter != TIter::End(); ++patchiter){
149  mypatch = dynamic_cast<AliEmcalTriggerPatchInfo *>(*patchiter);
150  if(!mypatch) continue;
151  // Select only gamma and L0 online patches
152  if(mypatch->IsOfflineSimple()) continue;
153  if(!(mypatch->IsGammaHigh() || mypatch->IsGammaLow() || mypatch->IsLevel0())) continue;
154  fGeometry->SuperModuleNumberFromEtaPhi(mypatch->GetEtaCM(), mypatch->GetPhiCM(), supermoduleID);
155  Int_t sector = 4 + int(supermoduleID / 2);
156  if(mypatch->IsLevel0()) FillTriggerPatchHistos("EL0", mypatch, supermoduleID, sector, kFALSE);
157  if(mypatch->IsGammaHigh()) FillTriggerPatchHistos("EG1", mypatch, supermoduleID, sector, kFALSE);
158  if(mypatch->IsGammaLow()) FillTriggerPatchHistos("EG2", mypatch, supermoduleID, sector, kFALSE);
159 
160  // correlate patches with real event classes selected
161  if(isEMC7 && mypatch->IsLevel0()) FillTriggerPatchHistos("EL0", mypatch, supermoduleID, sector, kTRUE);
162  if(isEG1 && mypatch->IsGammaHigh()) FillTriggerPatchHistos("EG1", mypatch, supermoduleID, sector, kTRUE);
163  if(isEG2 && mypatch->IsGammaLow()) FillTriggerPatchHistos("EG2", mypatch, supermoduleID, sector, kTRUE);
164  }
165 
166  PostData(1, fHistos->GetListOfHistograms());
167 }
168 
181 void AliAnalysisTaskEmcalOnlinePatchesRef::FillTriggerPatchHistos(const char *patchtype, const AliEmcalTriggerPatchInfo * const recpatch, Int_t supermoduleID, Int_t sector, Bool_t evsel){
182  TString fbase = evsel ? "hEvSel" : "h";
183  fHistos->FillTH2(Form("%sPatchEnergy%s", fbase.Data(), patchtype), supermoduleID, recpatch->GetPatchE());
184  fHistos->FillTH2(Form("%sPatchADC%s", fbase.Data(), patchtype), supermoduleID, recpatch->GetADCAmp());
185  fHistos->FillTH2(Form("%sPatchEnergyEta%s", fbase.Data(), patchtype), recpatch->GetEtaCM(), recpatch->GetPatchE());
186  fHistos->FillTH2(Form("%sPatchADCEta%s", fbase.Data(), patchtype), recpatch->GetEtaCM(), recpatch->GetADCAmp());
187  if(sector >= 4 && sector < 10){
188  fHistos->FillTH2(Form("%sPatchEnergyEta%sSector%d", fbase.Data(), patchtype, sector), recpatch->GetEtaCM(), recpatch->GetPatchE());
189  fHistos->FillTH2(Form("%sPatchADCEta%sSector%d", fbase.Data(), patchtype, sector), recpatch->GetEtaCM(), recpatch->GetADCAmp());
190  }
191  if(supermoduleID >= 0 && supermoduleID < 10){
192  fHistos->FillTH2(Form("%sPatchEnergyEta%sSM%d", fbase.Data(), patchtype, supermoduleID), recpatch->GetEtaCM(), recpatch->GetPatchE());
193  fHistos->FillTH2(Form("%sPatchADCEta%sSM%d", fbase.Data(), patchtype, supermoduleID), recpatch->GetEtaCM(), recpatch->GetADCAmp());
194  }
195 }
196 
197 } /* namespace EMCalTriggerPtAnalysis */
Main data structure storing all relevant information of EMCAL/DCAL trigger patches.
Declarartion of class AliEMCalHistoContainer.
ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskEmcalOnlinePatchesRef) namespace EMCalTriggerPtAnalysis
Class to make array of trigger patch objects in AOD/ESD events.
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235