AliPhysics  vAN-20150924 (e816f45)
 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 "AliInputEventHandler.h"
24 #include "AliVEvent.h"
25 #include "AliVVertex.h"
26 
28 
29 #if __cplusplus < 201103L
30 /*
31  * Old C++
32  */
33 #define nullptr NULL
34 #include <vector>
35 #else
36 #include <array>
37 #endif
38 
40 
41 namespace EMCalTriggerPtAnalysis {
42 
43 AliAnalysisTaskEmcalOnlinePatchesRef::AliAnalysisTaskEmcalOnlinePatchesRef():
44  AliAnalysisTaskSE(),
45  fAnalysisUtil(nullptr),
46  fGeometry(nullptr),
47  fHistos(nullptr)
48 {
49 }
50 
51 AliAnalysisTaskEmcalOnlinePatchesRef::AliAnalysisTaskEmcalOnlinePatchesRef(const char *name):
52  AliAnalysisTaskSE(name),
53  fAnalysisUtil(nullptr),
54  fGeometry(nullptr),
55  fHistos(nullptr)
56 {
57  DefineOutput(1, TList::Class());
58 }
59 
60 AliAnalysisTaskEmcalOnlinePatchesRef::~AliAnalysisTaskEmcalOnlinePatchesRef() {
61 }
62 
63 void AliAnalysisTaskEmcalOnlinePatchesRef::UserCreateOutputObjects(){
64  fAnalysisUtil = new AliAnalysisUtils;
65 
66  fHistos = new AliEMCalHistoContainer("Ref");
67  TString triggername;
68  // Plots at global level:
69  // Energy vs. supermodule
70  // Energy vs. eta (all sectors)
71  // Energy vs. eta for sector
72 #if __cplusplus >= 201103L
73  /*
74  * Version for beautifull C++11
75  */
76  std::array<TString, 3> patchnames = {
77  "EL0", "EG1", "EG2"
78  };
79  for(auto mytrg : patchnames){
80  triggername = mytrg;
81 #else
82  /*
83  * Backward compatible version for the ancient technology
84  */
85  std::vector<TString> patchnames;
86  patchnames.push_back("EL0");
87  patchnames.push_back("EG1");
88  patchnames.push_back("EG2");
89  for(std::vector<TString>::iterator mytrg = patchnames.begin(); mytrg != patchnames.end(); ++mytrg){
90  triggername = *mytrg;
91 #endif
92  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.);
93  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.);
94  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.);
95  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.);
96  for(int isec = 5; isec <= 10; isec++){
97  fHistos->CreateTH2(Form("hPatchEnergyEta%sSector%d", triggername.Data(), isec), Form("Patch energy versus eta for trigger %s", triggername.Data()), 100, -0.7, 0.7, 200., 0., 200.);
98  fHistos->CreateTH2(Form("hPatchADCEta%sSector%d", triggername.Data(), isec), Form("Patch energy versus eta for trigger %s", triggername.Data()), 100, -0.7, 0.7, 2100., 0., 2100.);
99  }
100  }
101  PostData(1, fHistos->GetListOfHistograms());
102 }
103 
104 void AliAnalysisTaskEmcalOnlinePatchesRef::UserExec(Option_t *){
105  if(!fGeometry){
106  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
107  }
108  TClonesArray *patches = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
109  TString triggerstring = fInputEvent->GetFiredTriggerClasses();
110  UInt_t selectionstatus = fInputHandler->IsEventSelected();
111  Bool_t isMinBias = selectionstatus & AliVEvent::kINT7,
112  isEG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG1"),
113  isEG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains("EG2"),
114  isEMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains("EMC7");
115  if(!(isMinBias || isEG1 || isEG2 || isEMC7)) return;
116  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
117  //if(!fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) return; // reject pileup event
118  if(vtx->GetNContributors() < 1) return;
119  // Fill reference distribution for the primary vertex before any z-cut
120  if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent)) return; // Apply new vertex cut
121  if(fAnalysisUtil->IsPileUpEvent(fInputEvent)) return; // Apply new vertex cut
122  // Apply vertex z cut
123  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return;
124 
125  AliEmcalTriggerPatchInfo *mypatch(nullptr);
126  Int_t supermoduleID = -1;
127  TString patchname;
128  for(TIter patchiter = TIter(patches).Begin(); patchiter != TIter::End(); ++patchiter){
129  mypatch = dynamic_cast<AliEmcalTriggerPatchInfo *>(*patchiter);
130  if(!mypatch) continue;
131  // Select only gamma and L0 online patches
132  if(mypatch->IsOfflineSimple()) continue;
133  if(!(mypatch->IsGammaHigh() || mypatch->IsGammaLow() || mypatch->IsLevel0())) continue;
134  fGeometry->SuperModuleNumberFromEtaPhi(mypatch->GetEtaCM(), mypatch->GetPhiCM(), supermoduleID);
135  Int_t sector = 5 + supermoduleID / 2;
136  // Plots at global level:
137  // Energy vs. supermodule
138  // Energy vs. eta (all sectors)
139  // Energy vs. eta for sector
140  if(mypatch->IsLevel0()) patchname = "EL0";
141  else if(mypatch->IsGammaHigh()) patchname = "EG1";
142  else patchname = "EG2";
143  fHistos->FillTH2(Form("hPatchEnergy%s", patchname.Data()), supermoduleID, mypatch->GetPatchE());
144  fHistos->FillTH2(Form("hPatchADC%s", patchname.Data()), supermoduleID, mypatch->GetADCAmp());
145  fHistos->FillTH2(Form("hPatchEnergyEta%s", patchname.Data()), mypatch->GetEtaCM(), mypatch->GetPatchE());
146  fHistos->FillTH2(Form("hPatchADCEta%s", patchname.Data()), mypatch->GetEtaCM(), mypatch->GetADCAmp());
147  fHistos->FillTH2(Form("hPatchEnergyEta%sSector%d", patchname.Data(), sector), mypatch->GetEtaCM(), mypatch->GetPatchE());
148  fHistos->FillTH2(Form("hPatchADCEta%sSector%d", patchname.Data(), sector), mypatch->GetEtaCM(), mypatch->GetADCAmp());
149  }
150 
151  PostData(1, fHistos->GetListOfHistograms());
152 }
153 
154 } /* 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