AliPhysics  29d4213 (29d4213)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskEMCALDCALTrigger2015.cxx
Go to the documentation of this file.
1 #include <map>
2 #include <vector>
3 
4 #include <TArrayD.h>
5 #include <TClonesArray.h>
6 #include <THashList.h>
7 #include <TLorentzVector.h>
8 
9 #include "AliAnalysisUtils.h"
10 #include "AliEMCALGeometry.h"
11 #include "AliEMCalHistoContainer.h"
12 #include "AliEmcalTriggerPatchInfoAP.h"
13 #include "AliVCluster.h"
14 #include "AliVEvent.h"
15 #include "AliVTrack.h"
16 
18 
19 #if __cplusplus < 201103L
20 /*
21  * Old C++
22  */
23 #ifndef nullptr
24 #define nullptr NULL
25 #endif
26 #endif
27 
29 
30 namespace EMCalTriggerPtAnalysis {
31 
32 const TString AliAnalysisTaskEMCALDCALTrigger2015::fkTriggerClasses[6] = {"INT7", "INT8", "EMC7", "EMC8", "DMC7", "DMC8"};
33 
34 AliAnalysisTaskEMCALDCALTrigger2015::AliAnalysisTaskEMCALDCALTrigger2015() :
35  AliAnalysisTaskSE(),
36  fHistos(nullptr),
37  fGeometry(nullptr),
38  fClusterContainer(nullptr),
39  fPatchContainer(nullptr)
40 {
41 }
42 
43 AliAnalysisTaskEMCALDCALTrigger2015::AliAnalysisTaskEMCALDCALTrigger2015(const char *name) :
44  AliAnalysisTaskSE(name),
45  fHistos(nullptr),
46  fGeometry(nullptr),
47  fClusterContainer(nullptr),
48  fPatchContainer(nullptr)
49 {
50  DefineOutput(1, TList::Class());
51 }
52 
53 void AliAnalysisTaskEMCALDCALTrigger2015::UserCreateOutputObjects(){
54  TArrayD energybinning, etabinning, supermodulebinning;
55  CreateEnergyBinning(energybinning);
56  CreateLinearBinning(etabinning, 100, -1, 1);
57  CreateLinearBinning(supermodulebinning, 20, -0.5, 19.5);
58 
59  const TString beamdirs[4] = {"B", "A", "C", "E"};
60 
61  fHistos = new AliEMCalHistoContainer("histos");
62  for(const TString *trgit = fkTriggerClasses; trgit < fkTriggerClasses + sizeof(fkTriggerClasses)/sizeof(const TString); ++trgit){
63  for(const TString *beamit = beamdirs; beamit < beamdirs + sizeof(beamdirs)/sizeof(const TString); ++beamit){
64  fHistos->CreateTH1(Form("hEventCount%s%s", trgit->Data(), beamit->Data()), Form("Event counter for trigger class %s-%s", trgit->Data(), beamit->Data()), 1, 0.5, 1.5);
65  fHistos->CreateTH1(Form("hVertexDistBefore%s%s", trgit->Data(), beamit->Data()), Form("Vertex distribution in trigger class %s-%s before event selection", trgit->Data(), beamit->Data()), 100, -40., 40.);
66  fHistos->CreateTH1(Form("hVertexDistAfter%s%s", trgit->Data(), beamit->Data()), Form("Vertex distribution in trigger class %s-%s after event selection", trgit->Data(), beamit->Data()), 100, -40., 40.);
67  fHistos->CreateTH1(Form("hClusterEnergyUncalib%s%s", trgit->Data(), beamit->Data()), Form("(Uncalibrated) cluster energy distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), energybinning);
68  fHistos->CreateTH1(Form("hClusterEnergyCalib%s%s", trgit->Data(), beamit->Data()), Form("(Calibrated) cluster energy distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), energybinning);
69  fHistos->CreateTH2(Form("hClusterEnergyEtaUncalib%s%s", trgit->Data(), beamit->Data()), Form("(Uncalibrated) cluster energy vs eta distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), etabinning, energybinning);
70  fHistos->CreateTH2(Form("hClusterEnergyEtaCalib%s%s", trgit->Data(), beamit->Data()), Form("(Calibrated) cluster energy vs eta distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), etabinning, energybinning);
71  fHistos->CreateTH2(Form("hClusterEnergySupermoduleUncalib%s%s", trgit->Data(), beamit->Data()), Form("(Uncalibrated) cluster energy vs sm distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), supermodulebinning, energybinning);
72  fHistos->CreateTH2(Form("hClusterEnergySupermoduleCalib%s%s", trgit->Data(), beamit->Data()), Form("(Calibrated) cluster energy vs sm distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), supermodulebinning, energybinning);
73  fHistos->CreateTH1(Form("hPatchEnergyOnline%s%s", trgit->Data(), beamit->Data()), Form("(Online) patch energy distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), energybinning);
74  fHistos->CreateTH1(Form("hPatchEnergyOffline%s%s", trgit->Data(), beamit->Data()), Form("(Offline) patch energy distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), energybinning);
75  fHistos->CreateTH2(Form("hPatchEnergyEtaOnline%s%s", trgit->Data(), beamit->Data()), Form("(Online) patch energy vs eta distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), etabinning, energybinning);
76  fHistos->CreateTH2(Form("hPatchEnergyEtaOffline%s%s", trgit->Data(), beamit->Data()), Form("(Offline) patch energy vs eta distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), etabinning, energybinning);
77  fHistos->CreateTH2(Form("hPatchEnergySupermoduleOnline%s%s", trgit->Data(), beamit->Data()), Form("(Online) patch energy vs sm distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), supermodulebinning, energybinning);
78  fHistos->CreateTH2(Form("hPatchEnergySupermoduleOffline%s%s", trgit->Data(), beamit->Data()), Form("(Offline) patch energy vs sm distribution in trigger class %s-%s", trgit->Data(), beamit->Data()), supermodulebinning, energybinning);
79  for(int ism = 0; ism < 20; ism++){
80  fHistos->CreateTH2(Form("hClusterEnergyEtaSupermodule%dCalib%s%s", ism, trgit->Data(), beamit->Data()), Form("(Calibrated) cluster energy vs eta for sm %d in trigger %s-%s", ism, trgit->Data(), beamit->Data()), etabinning, energybinning);
81  fHistos->CreateTH2(Form("hClusterEnergyEtaSupermodule%dUncalib%s%s", ism, trgit->Data(), beamit->Data()), Form("(Uncalibrated) cluster energy vs eta for sm %d in trigger %s-%s", ism, trgit->Data(), beamit->Data()), etabinning, energybinning);
82  fHistos->CreateTH2(Form("hPatchEnergyEtaSupermodule%dOnline%s%s", ism, trgit->Data(), beamit->Data()), Form("(Online) patch energy vs eta for sm %d in trigger %s-%s", ism, trgit->Data(), beamit->Data()), etabinning, energybinning);
83  fHistos->CreateTH2(Form("hPatchEnergyEtaSupermodule%dOffline%s%s", ism, trgit->Data(), beamit->Data()), Form("(Offline) patch energy vs eta for sm %d in trigger %s-%s", ism, trgit->Data(), beamit->Data()), etabinning, energybinning);
84  }
85  }
86  }
87 
88  PostData(1, fHistos->GetListOfHistograms());
89 }
90 
91 void AliAnalysisTaskEMCALDCALTrigger2015::UserExec(Option_t * /*option*/){
92  if(!fGeometry){
93  fGeometry = AliEMCALGeometry::GetInstance();
94  if(!fGeometry)
95  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
96  }
97 
98  fClusterContainer = static_cast<TClonesArray *>(fInputEvent->FindListObject(fClusterContainerName.Data()));
99  fPatchContainer = static_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
100 
101  std::vector<TString> triggerclassesSelected;
102 
103  TString classes = fInputEvent->GetFiredTriggerClasses();
104 
105  TString beamdirs[4] = {"B", "A", "C", "E"},
106  triggerclasses[6] = {"INT7", "INT8", "EMC7", "EMC8", "DMC7", "DMC8"};
107  for(TString *trgit = triggerclasses; trgit < triggerclasses + sizeof(triggerclasses)/sizeof(TString); ++ trgit){
108  for(TString *beamit = beamdirs; beamit < beamdirs + sizeof(beamdirs)/sizeof(TString); ++beamit){
109  if(classes.Contains(Form("C%s-%s-NOPF-CENT", trgit->Data(), beamit->Data())))
110  triggerclassesSelected.push_back(Form("%s%s", trgit->Data(), beamit->Data()));
111 
112  }
113  }
114 
115  if(!triggerclassesSelected.size()) return;
116 
117  const AliVVertex *spdvertex = fInputEvent->GetPrimaryVertexSPD();
118  if(!spdvertex) return;
119  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit < triggerclassesSelected.end(); ++trgit){
120  fHistos->FillTH1(Form("hVertexDistBefore%s", trgit->Data()), spdvertex->GetZ());
121  }
122  if(spdvertex->GetNContributors() < 1) return;
123  if(InputEvent()->IsPileupFromSPD(5, 0.8, 3., 2., 5.)) return;
124  if(TMath::Abs(spdvertex->GetZ()) > 10) return;
125  int ntrack(0);
126  for(int itrk = 0; itrk < InputEvent()->GetNumberOfTracks(); itrk++){
127  AliVTrack *trk = static_cast<AliVTrack *>(InputEvent()->GetTrack(itrk));
128  if(!(trk->GetStatus() & AliVTrack::kITSpureSA)) continue;
129  if(TMath::Abs(trk->Pt()) > 1.) ntrack++;
130  }
131  if(ntrack < 3) return;
132 
133  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit < triggerclassesSelected.end(); ++trgit){
134  fHistos->FillTH1(Form("hEventCount%s", trgit->Data()), 1.);
135  fHistos->FillTH1(Form("hVertexDistAfter%s", trgit->Data()), spdvertex->GetZ());
136  }
137 
138  // Loop over uncalibrated clusters
139  AliVCluster *clust = nullptr;
140  for(int icls = 0; icls < fInputEvent->GetNumberOfCaloClusters(); icls++){
141  clust = fInputEvent->GetCaloCluster(icls);
142  if(!clust->IsEMCAL()) continue;
143  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
144  ProcessCluster(*trgit, clust, false);
145  }
146  }
147 
148  // Loop over calibrated clusters
149  if(fClusterContainer){
150  for(TIter clustit = TIter(fClusterContainer).Begin(); clustit != TIter::End(); ++clustit){
151  clust = dynamic_cast<AliVCluster *>(*clustit);
152  if(!clust) continue;
153  if(!clust->IsEMCAL()) continue;
154  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
155  ProcessCluster(*trgit, clust, true);
156  }
157  }
158  }
159 
160  // Loop over trigger patches
161  if(fPatchContainer){
162  for(TIter patchiter = TIter(fPatchContainer).Begin(); patchiter != TIter::End(); ++patchiter){
163  AliEmcalTriggerPatchInfo *patch = dynamic_cast<AliEmcalTriggerPatchInfo *>(*patchiter);
164  if(!patch) continue;
165  if(patch->IsOfflineSimple() && patch->IsGammaLowSimple()){
166  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
167  ProcessPatch(*trgit, patch, false);
168  }
169  } else if(!patch->IsOfflineSimple() && patch->IsLevel0()){
170  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
171  ProcessPatch(*trgit, patch, true);
172  }
173  }
174  }
175  }
176 
177  PostData(1, fHistos->GetListOfHistograms());
178 }
179 
180 void AliAnalysisTaskEMCALDCALTrigger2015::ProcessCluster(const TString &triggerclass, const AliVCluster * const clust, bool isCalib){
181  if(!clust->IsEMCAL()) return;
182  fHistos->FillTH1(Form("hClusterEnergy%s%s", isCalib ? "Calib" : "Uncalib", triggerclass.Data()), clust->E());
183  Double_t vertex[3];
184  fInputEvent->GetPrimaryVertexSPD()->GetXYZ(vertex);
185  TLorentzVector clustervec;
186  clust->GetMomentum(clustervec, vertex);
187  fHistos->FillTH2(Form("hClusterEnergyEta%s%s", isCalib ? "Calib" : "Uncalib", triggerclass.Data()), clustervec.Eta(), clust->E());
188  Int_t supermoduleID(-1);
189  if(fGeometry->SuperModuleNumberFromEtaPhi(clustervec.Eta(), clustervec.Phi(), supermoduleID)){
190  fHistos->FillTH1(Form("hClusterEnergySupermodule%s%s", isCalib ? "Calib" : "Uncalib", triggerclass.Data()), supermoduleID, clust->E());
191  fHistos->FillTH2(Form("hClusterEnergyEtaSupermodule%d%s%s", supermoduleID, isCalib ? "Calib" : "Uncalib", triggerclass.Data()), clustervec.Eta(), clust->E());
192  }
193 }
194 
195 void AliAnalysisTaskEMCALDCALTrigger2015::ProcessPatch(const TString &triggerclass, const AliEmcalTriggerPatchInfo * const patch, bool isOnline){
196  fHistos->FillTH1(Form("hPatchEnergy%s%s", isOnline ? "Online" : "Offline", triggerclass.Data()), patch->GetPatchE());
197  fHistos->FillTH2(Form("hPatchEnergyEta%s%s", isOnline ? "Online" : "Offline", triggerclass.Data()), patch->GetEtaCM(), patch->GetPatchE());
198  Int_t supermoduleID(-1);
199  if(fGeometry->SuperModuleNumberFromEtaPhi(patch->GetEtaCM(), patch->GetPhiCM(), supermoduleID)){
200  fHistos->FillTH1(Form("hPatchEnergySupermodule%s%s", isOnline ? "Online" : "Offline", triggerclass.Data()), supermoduleID, patch->GetPatchE());
201  fHistos->FillTH2(Form("hPatchEnergyEtaSupermodule%d%s%s", supermoduleID, isOnline ? "Online" : "Offline", triggerclass.Data()), patch->GetEtaCM(), patch->GetPatchE());
202  }
203 }
204 
205 void AliAnalysisTaskEMCALDCALTrigger2015::CreateEnergyBinning(TArrayD& binning) const {
206  std::vector<double> mybinning;
207  std::map<double,double> definitions;
208  definitions.insert(std::pair<double, double>(1, 0.05));
209  definitions.insert(std::pair<double, double>(2, 0.1));
210  definitions.insert(std::pair<double, double>(4, 0.2));
211  definitions.insert(std::pair<double, double>(7, 0.5));
212  definitions.insert(std::pair<double, double>(16, 1));
213  definitions.insert(std::pair<double, double>(32, 2));
214  definitions.insert(std::pair<double, double>(40, 4));
215  definitions.insert(std::pair<double, double>(50, 5));
216  definitions.insert(std::pair<double, double>(100, 10));
217  definitions.insert(std::pair<double, double>(200, 20));
218  double currentval = 0.;
219  mybinning.push_back(currentval);
220  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
221  double limit = id->first, binwidth = id->second;
222  while(currentval < limit){
223  currentval += binwidth;
224  mybinning.push_back(currentval);
225  }
226  }
227  binning.Set(mybinning.size());
228  int ib = 0;
229  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
230  binning[ib++] = *it;
231 }
232 
233 void AliAnalysisTaskEMCALDCALTrigger2015::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
234  double binwidth = (max-min)/static_cast<double>(nbins);
235  binning.Set(nbins+1);
236  binning[0] = min;
237  double currentlimit = min + binwidth;
238  for(int ibin = 0; ibin < nbins; ibin++){
239  binning[ibin+1] = currentlimit;
240  currentlimit += binwidth;
241  }
242 }
243 
244 
245 } /* namespace EMCalTriggerPtAnalysis */
Declarartion of class AliEMCalHistoContainer.
ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskEMCALDCALTrigger2015) namespace EMCalTriggerPtAnalysis
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
const Int_t nbins