AliPhysics  e59a9ba (e59a9ba)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <THistManager.h>
8 #include <TLorentzVector.h>
9 
10 #include "AliAnalysisUtils.h"
11 #include "AliEMCALGeometry.h"
12 #include "AliEMCALTriggerPatchInfo.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::fgkTriggerClasses[11] = {"INT7", "EMC7", "DMC7", "EJ1", "EJ2", "EG1", "EG2", "DJ1", "DJ2", "DG1", "DG2"};
33 const TString AliAnalysisTaskEMCALDCALTrigger2015::fgkBeamDirs[4] = {"A", "B", "C", "E"};
34 
35 AliAnalysisTaskEMCALDCALTrigger2015::AliAnalysisTaskEMCALDCALTrigger2015() :
36  AliAnalysisTaskSE(),
37  fHistos(nullptr),
38  fGeometry(nullptr),
39  fClusterContainer(nullptr),
40  fPatchContainer(nullptr)
41 {
42 }
43 
44 AliAnalysisTaskEMCALDCALTrigger2015::AliAnalysisTaskEMCALDCALTrigger2015(const char *name) :
45  AliAnalysisTaskSE(name),
46  fHistos(nullptr),
47  fGeometry(nullptr),
48  fClusterContainer(nullptr),
49  fPatchContainer(nullptr)
50 {
51  DefineOutput(1, TList::Class());
52 }
53 
54 void AliAnalysisTaskEMCALDCALTrigger2015::UserCreateOutputObjects(){
55  TArrayD energybinning, etabinning, supermodulebinning;
56  CreateEnergyBinning(energybinning);
57  CreateLinearBinning(etabinning, 100, -1, 1);
58  CreateLinearBinning(supermodulebinning, 20, -0.5, 19.5);
59 
60  fHistos = new THistManager("histos");
61  for(const TString *trgit = fgkTriggerClasses; trgit < fgkTriggerClasses + sizeof(fgkTriggerClasses)/sizeof(const TString); ++trgit){
62  for(const TString *beamit = fgkBeamDirs; beamit < fgkBeamDirs + sizeof(fgkBeamDirs)/sizeof(const TString); ++beamit){
63  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);
64  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.);
65  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.);
66  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);
67  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);
68  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);
69  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);
70  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);
71  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);
72  /*
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  */
80  for(int ism = 0; ism < 20; ism++){
81  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);
82  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);
83  /*
84  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);
85  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);
86  */
87  }
88  }
89  }
90 
91  PostData(1, fHistos->GetListOfHistograms());
92 }
93 
94 void AliAnalysisTaskEMCALDCALTrigger2015::UserExec(Option_t * /*option*/){
95  if(!fGeometry){
96  fGeometry = AliEMCALGeometry::GetInstance();
97  if(!fGeometry)
98  fGeometry = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
99  }
100 
101  fClusterContainer = static_cast<TClonesArray *>(fInputEvent->FindListObject(fClusterContainerName.Data()));
102  fPatchContainer = static_cast<TClonesArray *>(fInputEvent->FindListObject("EmcalTriggers"));
103 
104  std::vector<TString> triggerclassesSelected;
105 
106  TString classes = fInputEvent->GetFiredTriggerClasses();
107 
108  for(const TString *trgit = fgkTriggerClasses; trgit < fgkTriggerClasses + sizeof(fgkTriggerClasses)/sizeof(TString); ++ trgit){
109  for(const TString *beamit = fgkBeamDirs; beamit < fgkBeamDirs + sizeof(fgkBeamDirs)/sizeof(TString); ++beamit){
110  if(classes.Contains(Form("%s-%s", trgit->Data(), beamit->Data())))
111  triggerclassesSelected.push_back(Form("%s%s", trgit->Data(), beamit->Data()));
112 
113  }
114  }
115 
116  if(!triggerclassesSelected.size()) return;
117 
118  const AliVVertex *spdvertex = fInputEvent->GetPrimaryVertexSPD();
119  if(!spdvertex) return;
120  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit < triggerclassesSelected.end(); ++trgit){
121  fHistos->FillTH1(Form("hVertexDistBefore%s", trgit->Data()), spdvertex->GetZ());
122  }
123  /*
124  if(spdvertex->GetNContributors() < 1) return;
125  if(InputEvent()->IsPileupFromSPD(5, 0.8, 3., 2., 5.)) return;
126  if(TMath::Abs(spdvertex->GetZ()) > 10) return;
127  int ntrack(0);
128  for(int itrk = 0; itrk < InputEvent()->GetNumberOfTracks(); itrk++){
129  AliVTrack *trk = static_cast<AliVTrack *>(InputEvent()->GetTrack(itrk));
130  if(!(trk->GetStatus() & AliVTrack::kITSpureSA)) continue;
131  if(TMath::Abs(trk->Pt()) > 1.) ntrack++;
132  }
133  if(ntrack < 3) return;
134  */
135 
136  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit < triggerclassesSelected.end(); ++trgit){
137  fHistos->FillTH1(Form("hEventCount%s", trgit->Data()), 1.);
138  fHistos->FillTH1(Form("hVertexDistAfter%s", trgit->Data()), spdvertex->GetZ());
139  }
140 
141  // Loop over uncalibrated clusters
142  AliVCluster *clust = nullptr;
143  for(int icls = 0; icls < fInputEvent->GetNumberOfCaloClusters(); icls++){
144  clust = fInputEvent->GetCaloCluster(icls);
145  if(!clust->IsEMCAL()) continue;
146  if(clust->GetIsExotic()) continue;
147  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
148  ProcessCluster(*trgit, clust, false);
149  }
150  }
151 
152  // Loop over calibrated clusters
153  if(fClusterContainer){
154  for(TIter clustit = TIter(fClusterContainer).Begin(); clustit != TIter::End(); ++clustit){
155  clust = dynamic_cast<AliVCluster *>(*clustit);
156  if(!clust) continue;
157  if(!clust->IsEMCAL()) continue;
158  if(clust->GetIsExotic()) continue;
159  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
160  ProcessCluster(*trgit, clust, true);
161  }
162  }
163  }
164 
165  // Loop over trigger patches
166  /*
167  if(fPatchContainer){
168  for(TIter patchiter = TIter(fPatchContainer).Begin(); patchiter != TIter::End(); ++patchiter){
169  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(*patchiter);
170  if(!patch) continue;
171  if(patch->IsOfflineSimple() && patch->IsGammaLowSimple()){
172  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
173  ProcessPatch(*trgit, patch, false);
174  }
175  } else if(!patch->IsOfflineSimple() && patch->IsLevel0()){
176  for(std::vector<TString>::iterator trgit = triggerclassesSelected.begin(); trgit != triggerclassesSelected.end(); ++trgit){
177  ProcessPatch(*trgit, patch, true);
178  }
179  }
180  }
181  }
182  */
183  PostData(1, fHistos->GetListOfHistograms());
184 }
185 
186 void AliAnalysisTaskEMCALDCALTrigger2015::ProcessCluster(const TString &triggerclass, const AliVCluster * const clust, bool isCalib){
187  if(!clust->IsEMCAL()) return;
188  double energy = clust->GetNonLinCorrEnergy();
189  fHistos->FillTH1(Form("hClusterEnergy%s%s", isCalib ? "Calib" : "Uncalib", triggerclass.Data()), energy);
190  Double_t vertex[3];
191  fInputEvent->GetPrimaryVertexSPD()->GetXYZ(vertex);
192  TLorentzVector clustervec;
193  clust->GetMomentum(clustervec, vertex);
194  fHistos->FillTH2(Form("hClusterEnergyEta%s%s", isCalib ? "Calib" : "Uncalib", triggerclass.Data()), clustervec.Eta(), energy);
195  Int_t supermoduleID(-1);
196  if(fGeometry->SuperModuleNumberFromEtaPhi(clustervec.Eta(), clustervec.Phi(), supermoduleID)){
197  fHistos->FillTH1(Form("hClusterEnergySupermodule%s%s", isCalib ? "Calib" : "Uncalib", triggerclass.Data()), supermoduleID, energy);
198  fHistos->FillTH2(Form("hClusterEnergyEtaSupermodule%d%s%s", supermoduleID, isCalib ? "Calib" : "Uncalib", triggerclass.Data()), clustervec.Eta(), energy);
199  }
200 }
201 
202 
203 void AliAnalysisTaskEMCALDCALTrigger2015::ProcessPatch(const TString &triggerclass, const AliEMCALTriggerPatchInfo * const patch, bool isOnline){
204  fHistos->FillTH1(Form("hPatchEnergy%s%s", isOnline ? "Online" : "Offline", triggerclass.Data()), patch->GetPatchE());
205  fHistos->FillTH2(Form("hPatchEnergyEta%s%s", isOnline ? "Online" : "Offline", triggerclass.Data()), patch->GetEtaCM(), patch->GetPatchE());
206  Int_t supermoduleID(-1);
207  if(fGeometry->SuperModuleNumberFromEtaPhi(patch->GetEtaCM(), patch->GetPhiCM(), supermoduleID)){
208  fHistos->FillTH1(Form("hPatchEnergySupermodule%s%s", isOnline ? "Online" : "Offline", triggerclass.Data()), supermoduleID, patch->GetPatchE());
209  fHistos->FillTH2(Form("hPatchEnergyEtaSupermodule%d%s%s", supermoduleID, isOnline ? "Online" : "Offline", triggerclass.Data()), patch->GetEtaCM(), patch->GetPatchE());
210  }
211 }
212 
213 void AliAnalysisTaskEMCALDCALTrigger2015::CreateEnergyBinning(TArrayD& binning) const {
214  std::vector<double> mybinning;
215  std::map<double,double> definitions;
216  definitions.insert(std::pair<double, double>(1, 0.05));
217  definitions.insert(std::pair<double, double>(2, 0.1));
218  definitions.insert(std::pair<double, double>(4, 0.2));
219  definitions.insert(std::pair<double, double>(7, 0.5));
220  definitions.insert(std::pair<double, double>(16, 1));
221  definitions.insert(std::pair<double, double>(32, 2));
222  definitions.insert(std::pair<double, double>(40, 4));
223  definitions.insert(std::pair<double, double>(50, 5));
224  definitions.insert(std::pair<double, double>(100, 10));
225  definitions.insert(std::pair<double, double>(200, 20));
226  double currentval = 0.;
227  mybinning.push_back(currentval);
228  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
229  double limit = id->first, binwidth = id->second;
230  while(currentval < limit){
231  currentval += binwidth;
232  mybinning.push_back(currentval);
233  }
234  }
235  binning.Set(mybinning.size());
236  int ib = 0;
237  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
238  binning[ib++] = *it;
239 }
240 
241 void AliAnalysisTaskEMCALDCALTrigger2015::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
242  double binwidth = (max-min)/static_cast<double>(nbins);
243  binning.Set(nbins+1);
244  binning[0] = min;
245  double currentlimit = min + binwidth;
246  for(int ibin = 0; ibin < nbins; ibin++){
247  binning[ibin+1] = currentlimit;
248  currentlimit += binwidth;
249  }
250 }
251 
252 
253 } /* namespace EMCalTriggerPtAnalysis */
energy
ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskEMCALDCALTrigger2015) namespace EMCalTriggerPtAnalysis
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
const Int_t nbins