AliPhysics  9b6b435 (9b6b435)
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  EventEMCALTriggerType_t fTriggerTypesValues[kNTriggerTypes] = {kMB, kEL0, kDL0, kEG1, kDG1, kEG2, kDG2, kEJ1, kDJ1, kEJ2, kDJ2};
61  memcpy (fTriggerTypes,fTriggerTypesValues,sizeof(fTriggerTypes));
62 }
63 
64 
69 
70 }
71 
72 
78 }
79 
85 
86  TString histname;
87  TString title;
88 
89  Int_t nPtBins = TMath::CeilNint(fMaxPt/fPtBinWidth);
90 
91  Double_t fMinEta = -0.7;
92  Double_t fMaxEta = 0.7;
93  Double_t fMinPhi = 0;
94  Double_t fMaxPhi = 2*TMath::Pi();
95  Int_t nEtaBins = 96;
96  Int_t nPhiBins = 208;
97 
98  Double_t fMinCol = 0;
99  Double_t fMaxCol = 48;
100  Double_t fMinRow = 0;
101  Double_t fMaxRow = 104;
102  Int_t nCol = 48;
103  Int_t nRow = 104;
104 
105  Double_t fMaxADCValue = 1024;
106  Double_t nADCBins = 512;
107 
108 
109  // Hist for counting clusters
110  fHistManager.CreateTH1("NClusters","NClusters;N_{cluster}; counts",300,0,300);
111 
112  // loop over trigger types
113  for (Int_t i = 0; i < kNTriggerTypes; i++) {
114  // Clusters in the EMCal (not including DCal)
115  histname = TString::Format("fHistEMCalClusEnergy_Trig_%s",fTriggerNames[i].Data());
116  title = histname + ";#it{E}_{cluster} (GeV); counts";
117  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
118  // Clusters in the DCal
119  histname = TString::Format("fHistDCalClusEnergy_Trig_%s",fTriggerNames[i].Data());
120  title = histname + ";#it{E}_{cluster} (GeV); counts";
121  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
122  }
123 
124  for (Int_t i = 0; i < kNTriggerTypes; i++) {
125  histname = TString::Format("fHistClusEtaPhi_Trig_%s",fTriggerNames[i].Data());
126  title = histname + ";#eta_{cluster};#phi_{cluster};counts";
127  fHistManager.CreateTH2(histname.Data(),title.Data(),nEtaBins,fMinEta,fMaxEta,nPhiBins,fMinPhi,fMaxPhi);
128  }
129 
130  for (Int_t i = 1; i < kNTriggerTypes; i++) {
131  histname = TString::Format("fHistPatchEnergy_Trig_%s",fTriggerNames[i].Data());
132  title = histname + ";#it{E}_{patch} (GeV); counts";
133  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
134  }
135 
136  for (Int_t i = 1; i < kNTriggerTypes; i++) {
137  histname = TString::Format("fHistPatchOnlineADCAmp_Trig_%s",fTriggerNames[i].Data());
138  title = histname + ";#it{E}_{patch} (ADC); counts";
139  fHistManager.CreateTH1(histname.Data(),title.Data(),nADCBins,0,fMaxADCValue);
140  }
141 
142  for (Int_t i = 1; i < kNTriggerTypes; i++) {
143  histname = TString::Format("fHistPatchColRow_Trig_%s",fTriggerNames[i].Data());
144  title = histname + ";Col;Row;counts";
145  fHistManager.CreateTH2(histname.Data(),title.Data(),nCol,fMinCol,fMaxCol,nRow,fMinRow,fMaxRow);
146  }
147  // Patch Geometric Centers
148  for (Int_t i = 1; i < kNTriggerTypes; i++) {
149  histname = TString::Format("fHistPatchEtaPhiGeo_Trig_%s",fTriggerNames[i].Data());
150  title = histname + ";#eta_{patch};#phi_{patch};counts";
151  fHistManager.CreateTH2(histname.Data(),title.Data(),nEtaBins,fMinEta,fMaxEta,nPhiBins,fMinPhi,fMaxPhi);
152  }
153 
155 }
156 
162  if (!fCaloClusters)
163  {
164  fCaloClusters = (TClonesArray*)GetClusterContainer(0);
165  }
166 
167  return kTRUE;
168 }
169 
175  // Loop over patches, identify which trigger conditions are met
176  DoPatchLoop();
177 
178  // Loop over clusters
179  DoClusterLoop();
180  return kTRUE;
181 }
182 
188  TString ClusterContName = "caloClusters";
189 
190  // Get the pointer to the existing analysis manager via the static access method
191  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
192  if (!mgr) {
193  ::Error("AliEmcalTriggerSimQATask", "No analysis manager to connect to.");
194  return 0;
195  }
196 
197  // Check the analysis type using the event handlers connected to the analysis manager
198  AliVEventHandler *evhand = mgr->GetInputEventHandler();
199  if (!evhand) {
200  ::Error("AliEmcalTriggerSimQATask", "This task requires an input event handler");
201  return 0;
202  }
203 
204  // Init the task and set settings
205  TString taskName("AliEmcalTriggerSimQATask");
206  AliEmcalTriggerSimQATask * eTask = new AliEmcalTriggerSimQATask(taskName);
207  eTask->AddClusterContainer(ClusterContName);
208 
209  mgr->AddTask(eTask);
210  // Create containers for input/output
211  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
212  mgr->ConnectInput(eTask, 0, cinput1);
213 
214  TString commonoutput(Form("%s", AliAnalysisManager::GetCommonFileName()));
215 
216  TString contOutName(Form("%s_histos", taskName.Data()));
217  mgr->ConnectOutput(eTask, 1, mgr->CreateContainer(contOutName, TList::Class(), AliAnalysisManager::kOutputContainer, commonoutput.Data()));
218 
219  return eTask;
220 }
221 
223  fEventTriggerBits = 0x0; // Reset
224  fTriggerPatches = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerPatchesName));
225 
226  if (!fTriggerPatches) return;
227 
228  Int_t nPatches = fTriggerPatches->GetEntries();
229 
230  for (Int_t i = 0; i < nPatches; i++) {
231  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
232  if (!patch) continue;
233  if (patch->GetADCAmp() < fMinAmplitude) continue;
234  Bool_t fIsDCal = patch->IsDCalPHOS();
235  // In Trigger Types array, DCal Triggers are 1 more than the EMCal Trigger type
236  Int_t fTriggerInt = 0;
237  if (patch->IsLevel0()) {
238  fTriggerInt = kEL0 + fIsDCal;
239  fEventTriggerBits |= 0x1 << fTriggerInt;
240  FillPatchHistograms(patch,fTriggerInt);
241  }
242  if (patch->IsGammaHigh()) {
243  fTriggerInt = kEG1 + fIsDCal;
244  fEventTriggerBits |= 0x1 << fTriggerInt;
245  FillPatchHistograms(patch,fTriggerInt);
246  }
247  if (patch->IsGammaLow()) {
248  fTriggerInt = kEG2 + fIsDCal;
249  fEventTriggerBits |= 0x1 << fTriggerInt;
250  FillPatchHistograms(patch,fTriggerInt);
251  }
252  if (patch->IsJetHigh()) {
253  fTriggerInt = kEJ1 + fIsDCal;
254  fEventTriggerBits |= 0x1 << fTriggerInt;
255  FillPatchHistograms(patch,fTriggerInt);
256  }
257  if (patch->IsJetLow()) {
258  fTriggerInt = kEJ2 + fIsDCal;
259  fEventTriggerBits |= 0x1 << fTriggerInt;
260  FillPatchHistograms(patch,fTriggerInt);
261  }
262  }
263 }
264 
265 void AliEmcalTriggerSimQATask::FillPatchHistograms(AliEMCALTriggerPatchInfo * patch, Int_t i) {
266  fHistManager.FillTH1(Form("fHistPatchEnergy_Trig_%s",fTriggerNames[i+1].Data()),patch->GetPatchE());
267  fHistManager.FillTH1(Form("fHistPatchOnlineADCAmp_Trig_%s",fTriggerNames[i+1].Data()),patch->GetADCAmp());
268  fHistManager.FillTH2(Form("fHistPatchColRow_Trig_%s",fTriggerNames[i+1].Data()),patch->GetColStart(),patch->GetRowStart());
269  fHistManager.FillTH2(Form("fHistPatchEtaPhiGeo_Trig_%s",fTriggerNames[i+1].Data()),patch->GetEtaGeo(),patch->GetPhiGeo());
270 }
271 
272 
274  TString histname;
275 
277  if (!clusters) {
278  AliError("Cluster Container Not Found");
279  return ;
280  }
281  Int_t nClusters = clusters->GetNClusters();
282  fHistManager.FillTH1("NClusters",nClusters);
283 
284  // Cycle over clusters
285  for (Int_t i = 0; i < nClusters; i++) {
286  AliVCluster * cluster = (AliVCluster *) clusters->GetAcceptCluster(i);
287  if (!cluster) continue;
288  for (Int_t j = 0; j < kNTriggerTypes; j++) {
289  // Check if this event had this trigger
290  if (fTriggerTypes[j] < 0) {
291  // This is Minimum Bias, so accept all events
292  }
293  else if (!(fEventTriggerBits & (0x1 << fTriggerTypes[j]))) {
294  continue;
295  }
296 
297  // Get Cluster vector
298  TLorentzVector vCluster;
299  clusters->GetMomentum(vCluster,cluster);
300  Double_t fPhi = vCluster.Phi();
301  if (fPhi < 0) fPhi+=2*TMath::Pi();
302 
303  // Split Cluster spectra into EMCal, DCal
304  Bool_t isDCal = (fPhi > 4.); // Lazy check
305  if (isDCal) {
306  histname = TString::Format("fHistDCalClusEnergy_Trig_%s",fTriggerNames[j].Data());
307  } else {
308  histname = TString::Format("fHistEMCalClusEnergy_Trig_%s",fTriggerNames[j].Data());
309  }
310  fHistManager.FillTH1(histname,cluster->E());
311 // histname = TString::Format("fHistClusEnergy_Trig_%s",fTriggerNames[j].Data());
312 // fHistManager.FillTH1(histname,cluster->E());
313  histname = TString::Format("fHistClusEtaPhi_Trig_%s",fTriggerNames[j].Data());
314  fHistManager.FillTH1(histname,vCluster.Eta(),fPhi);
315  }
316  }
317 }
318 
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]
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)
Enable general histograms.
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