AliPhysics  09a22ae (09a22ae)
AliEmcalTriggerSimQATask.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2018, 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 
16 #include <TClonesArray.h>
17 #include <THashList.h>
18 
19 #include <AliVEventHandler.h>
20 #include <AliAnalysisManager.h>
21 #include <AliClusterContainer.h>
22 #include <AliEMCALTriggerPatchInfo.h>
23 
25 
27 ClassImp(AliEmcalTriggerSimQATask);
29 
34 fTriggerPatchesName("EmcalTriggers"),
35 fTriggerPatches(0),
36 fMinAmplitude(0),
37 fPtBinWidth(0.5),
38 fMaxPt(120),
39 fEventTriggerBits(0x0),
40 fHistManager("AliEmcalTriggerSimQATask")
41 {}
42 
48 fTriggerPatchesName("EmcalTriggers"),
50 fMinAmplitude(0),
51 fPtBinWidth(0.5),
52 fMaxPt(120),
54 fHistManager(name)
55 {
57 
58  // Initializing array in CINT-compatible way
59  EventEMCALTriggerType_t fTriggerTypesValues[kNTriggerTypes] = {kMB, kEL0, kEG1, kEG2, kEJ1, kEJ2};
60  memcpy (fTriggerTypes,fTriggerTypesValues,sizeof(fTriggerTypes));
61 }
62 
63 
68 
69 }
70 
71 
77 }
78 
84 
85  TString histname;
86  TString title;
87 
88  Int_t nPtBins = TMath::CeilNint(fMaxPt/fPtBinWidth);
89 
90  Double_t fMinEta = -0.7;
91  Double_t fMaxEta = 0.7;
92  Double_t fMinPhi = 0;
93  Double_t fMaxPhi = 2*TMath::Pi();
94  Int_t nEtaBins = 96;
95  Int_t nPhiBins = 208;
96 
97  Double_t fMinCol = 0;
98  Double_t fMaxCol = 48;
99  Double_t fMinRow = 0;
100  Double_t fMaxRow = 104;
101  Int_t nCol = 48;
102  Int_t nRow = 104;
103 
104  Double_t fMaxADCValue = 1024;
105  Double_t nADCBins = 512;
106 
107 
108  // Hist for counting clusters
109  fHistManager.CreateTH1("NClusters","NClusters;N_{cluster}; counts",300,0,300);
110 
111  // loop over trigger types
112  for (Int_t i = 0; i < kNTriggerTypes; i++) {
113  histname = TString::Format("fHistClusEnergy_Trig_%s",fTriggerNames[i].Data());
114  title = histname + ";#it{E}_{cluster} (GeV); counts";
115  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
116  }
117 
118  for (Int_t i = 0; i < kNTriggerTypes; i++) {
119  histname = TString::Format("fHistClusEtaPhi_Trig_%s",fTriggerNames[i].Data());
120  title = histname + ";#eta_{cluster};#phi_{cluster};counts";
121  fHistManager.CreateTH2(histname.Data(),title.Data(),nEtaBins,fMinEta,fMaxEta,nPhiBins,fMinPhi,fMaxPhi);
122  }
123 
124  // Only make patch histgrams for L1 patches:
125  for (Int_t i = 1; i < kNTriggerTypes; i++) {
126  histname = TString::Format("fHistPatchEnergy_Trig_%s",fTriggerNames[i].Data());
127  title = histname + ";#it{E}_{patch} (GeV); counts";
128  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
129  }
130 
131  for (Int_t i = 1; i < kNTriggerTypes; i++) {
132  histname = TString::Format("fHistPatchOnlineADCAmp_Trig_%s",fTriggerNames[i].Data());
133  title = histname + ";#it{E}_{patch} (ADC); counts";
134  fHistManager.CreateTH1(histname.Data(),title.Data(),nADCBins,0,fMaxADCValue);
135  }
136 
137  for (Int_t i = 1; i < kNTriggerTypes; i++) {
138  histname = TString::Format("fHistPatchColRow_Trig_%s",fTriggerNames[i].Data());
139  title = histname + ";Col;Row;counts";
140  fHistManager.CreateTH2(histname.Data(),title.Data(),nCol,fMinCol,fMaxCol,nRow,fMinRow,fMaxRow);
141  }
142  // Patch Geometric Centers
143  for (Int_t i = 1; i < kNTriggerTypes; i++) {
144  histname = TString::Format("fHistPatchEtaPhiGeo_Trig_%s",fTriggerNames[i].Data());
145  title = histname + ";#eta_{patch};#phi_{patch};counts";
146  fHistManager.CreateTH2(histname.Data(),title.Data(),nEtaBins,fMinEta,fMaxEta,nPhiBins,fMinPhi,fMaxPhi);
147  }
148 
150 }
151 
157  if (!fCaloClusters)
158  {
159  fCaloClusters = (TClonesArray*)GetClusterContainer(0);
160  }
161 
162  return kTRUE;
163 }
164 
170  // Loop over patches, identify which trigger conditions are met
171  DoPatchLoop();
172 
173  // Loop over clusters
174  DoClusterLoop();
175  return kTRUE;
176 }
177 
183  TString ClusterContName = "caloClusters";
184 
185  // Get the pointer to the existing analysis manager via the static access method
186  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
187  if (!mgr) {
188  ::Error("AliEmcalTriggerSimQATask", "No analysis manager to connect to.");
189  return 0;
190  }
191 
192  // Check the analysis type using the event handlers connected to the analysis manager
193  AliVEventHandler *evhand = mgr->GetInputEventHandler();
194  if (!evhand) {
195  ::Error("AliEmcalTriggerSimQATask", "This task requires an input event handler");
196  return 0;
197  }
198 
199  // Init the task and set settings
200  TString taskName("AliEmcalTriggerSimQATask");
201  AliEmcalTriggerSimQATask * eTask = new AliEmcalTriggerSimQATask(taskName);
202  eTask->AddClusterContainer(ClusterContName);
203 
204  mgr->AddTask(eTask);
205  // Create containers for input/output
206  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
207  mgr->ConnectInput(eTask, 0, cinput1);
208 
209  TString commonoutput(Form("%s", AliAnalysisManager::GetCommonFileName()));
210 
211  TString contOutName(Form("%s_histos", taskName.Data()));
212  mgr->ConnectOutput(eTask, 1, mgr->CreateContainer(contOutName, TList::Class(), AliAnalysisManager::kOutputContainer, commonoutput.Data()));
213 
214  return eTask;
215 }
216 
218  fEventTriggerBits = 0x0; // Reset
219  fTriggerPatches = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerPatchesName));
220 
221  if (!fTriggerPatches) return;
222 
223  Int_t nPatches = fTriggerPatches->GetEntries();
224 
225  for (Int_t i = 0; i < nPatches; i++) {
226  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
227  if (!patch) continue;
228  if (patch->GetADCAmp() < fMinAmplitude) continue;
229  if (patch->IsLevel0()) {
230  fEventTriggerBits |= 0x1 << kL0;
231  FillPatchHistograms(patch,1);
232  }
233  if (patch->IsGammaLow()) {
234  fEventTriggerBits |= 0x1 << kEG1;
235  FillPatchHistograms(patch,2);
236  }
237  if (patch->IsGammaHigh()) {
238  fEventTriggerBits |= 0x1 << kEG2;
239  FillPatchHistograms(patch,3);
240  }
241  if (patch->IsJetLow()) {
242  fEventTriggerBits |= 0x1 << kEJ1;
243  FillPatchHistograms(patch,4);
244  }
245  if (patch->IsJetHigh()) {
246  fEventTriggerBits |= 0x1 << kEJ2;
247  FillPatchHistograms(patch,5);
248  }
249  }
250 }
251 
252 void AliEmcalTriggerSimQATask::FillPatchHistograms(AliEMCALTriggerPatchInfo * patch, Int_t i) {
253  fHistManager.FillTH1(Form("fHistPatchEnergy_Trig_%s",fTriggerNames[i].Data()),patch->GetPatchE());
254  fHistManager.FillTH1(Form("fHistPatchOnlineADCAmp_Trig_%s",fTriggerNames[i].Data()),patch->GetADCAmp());
255  fHistManager.FillTH2(Form("fHistPatchColRow_Trig_%s",fTriggerNames[i].Data()),patch->GetColStart(),patch->GetRowStart());
256  fHistManager.FillTH2(Form("fHistPatchEtaPhiGeo_Trig_%s",fTriggerNames[i].Data()),patch->GetEtaGeo(),patch->GetPhiGeo());
257 }
258 
259 
261  TString histname;
262 
264  if (!clusters) {
265  AliError("Cluster Container Not Found");
266  return ;
267  }
268  Int_t nClusters = clusters->GetNClusters();
269  fHistManager.FillTH1("NClusters",nClusters);
270 
271  // Cycle over clusters
272  for (Int_t i = 0; i < nClusters; i++) {
273  AliVCluster * cluster = (AliVCluster *) clusters->GetAcceptCluster(i);
274  if (!cluster) continue;
275  for (Int_t j = 0; j < kNTriggerTypes; j++) {
276  // Check if this event had this trigger
277  if (fTriggerTypes[j] < 0) {
278  // This is Minimum Bias, so accept all events
279  }
280  else if (!(fEventTriggerBits & (0x1 << fTriggerTypes[j]))) {
281  continue;
282  }
283 
284  // Get Cluster vector
285  TLorentzVector vCluster;
286  clusters->GetMomentum(vCluster,cluster);
287  Double_t fPhi = vCluster.Phi();
288  if (fPhi < 0) fPhi+=2*TMath::Pi();
289 
290  histname = TString::Format("fHistClusEnergy_Trig_%s",fTriggerNames[j].Data());
291  fHistManager.FillTH1(histname,cluster->E());
292  histname = TString::Format("fHistClusEtaPhi_Trig_%s",fTriggerNames[j].Data());
293  fHistManager.FillTH1(histname,vCluster.Eta(),fPhi);
294  }
295  }
296 }
297 
double Double_t
Definition: External.C:58
const char * title
Definition: MakeQAPdf.C:27
Base task in the EMCAL framework.
EventEMCALTriggerType_t fTriggerTypes[kNTriggerTypes]
Trigger type array.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
Float_t fMaxPt
Histogram pt limit.
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
const Int_t nPtBins
Float_t fPtBinWidth
Histogram pt bin width.
TClonesArray * fCaloClusters
!clusters
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
void FillPatchHistograms(AliEMCALTriggerPatchInfo *patch, Int_t i)
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
Int_t fMinAmplitude
Minimum trigger patch amplitude.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
Int_t fEventTriggerBits
! Variable storing trigger bits for entire event, set by DoPatchLoop()
AliVCluster * GetAcceptCluster(Int_t i) const
Int_t GetNClusters() const
const TString fTriggerNames[kNTriggerTypes]
EMCAL Level0 trigger.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TString fTriggerPatchesName
name of input trigger array
static AliEmcalTriggerSimQATask * AddTaskEmcalTriggerSimQA()
THistManager fHistManager
Histogram Manager.
AliEmcalList * fOutput
!output list
void SetMakeGeneralHistograms(Bool_t g)
Bool_t GetMomentum(TLorentzVector &mom, const AliVCluster *vc, Double_t mass) const
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
void UserCreateOutputObjects()
Main initialization function on the worker.
EMCAL trigger simulation QA Task Produces QA histograms for the simulated EMCAL trigger in MC...
bool Bool_t
Definition: External.C:53
Container structure for EMCAL clusters.
TClonesArray * fTriggerPatches
! trigger array in