AliPhysics  a3be53f (a3be53f)
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] = {kNTr, 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 fMaxADCValue = 1024;
98  Double_t nADCBins = 512;
99 
100 
101  // Hist for counting clusters
102  fHistManager.CreateTH1("NClusters","NClusters;N_{cluster}; counts",300,0,300);
103 
104  // loop over trigger types
105  for (Int_t i = 0; i < kNTriggerTypes; i++) {
106  histname = TString::Format("fHistClusEnergy_Trig_%s",fTriggerNames[i].Data());
107  title = histname + ";#it{E}_{cluster} (GeV); counts";
108  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
109  }
110 
111  for (Int_t i = 0; i < kNTriggerTypes; i++) {
112  histname = TString::Format("fHistClusEtaPhi_Trig_%s",fTriggerNames[i].Data());
113  title = histname + ";#eta_{cluster};#phi_{cluster};counts";
114  fHistManager.CreateTH2(histname.Data(),title.Data(),nEtaBins,fMinEta,fMaxEta,nPhiBins,fMinPhi,fMaxPhi);
115  }
116 
117  // Only make patch histgrams for L1 patches:
118  for (Int_t i = 1; i < kNTriggerTypes; i++) {
119  histname = TString::Format("fHistPatchEnergy_Trig_%s",fTriggerNames[i].Data());
120  title = histname + ";#it{E}_{patch} (GeV); counts";
121  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
122  }
123 
124  for (Int_t i = 1; i < kNTriggerTypes; i++) {
125  histname = TString::Format("fHistPatchOnlineADCAmp_Trig_%s",fTriggerNames[i].Data());
126  title = histname + ";#it{E}_{patch} (ADC); counts";
127  fHistManager.CreateTH1(histname.Data(),title.Data(),nADCBins,0,fMaxADCValue);
128  }
129 
131 }
132 
138  if (!fCaloClusters)
139  {
140  fCaloClusters = (TClonesArray*)GetClusterContainer(0);
141  }
142 
143  return kTRUE;
144 }
145 
151  // Loop over patches, identify which trigger conditions are met
152  DoPatchLoop();
153 
154  // Loop over clusters
155  DoClusterLoop();
156  return kTRUE;
157 }
158 
164  TString ClusterContName = "caloClusters";
165 
166  // Get the pointer to the existing analysis manager via the static access method
167  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
168  if (!mgr) {
169  ::Error("AliEmcalTriggerSimQATask", "No analysis manager to connect to.");
170  return 0;
171  }
172 
173  // Check the analysis type using the event handlers connected to the analysis manager
174  AliVEventHandler *evhand = mgr->GetInputEventHandler();
175  if (!evhand) {
176  ::Error("AliEmcalTriggerSimQATask", "This task requires an input event handler");
177  return 0;
178  }
179 
180  // Init the task and set settings
181  TString taskName("AliEmcalTriggerSimQATask");
182  AliEmcalTriggerSimQATask * eTask = new AliEmcalTriggerSimQATask(taskName);
183  eTask->AddClusterContainer(ClusterContName);
184 
185  mgr->AddTask(eTask);
186  // Create containers for input/output
187  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
188  mgr->ConnectInput(eTask, 0, cinput1);
189 
190  TString commonoutput(Form("%s", AliAnalysisManager::GetCommonFileName()));
191 
192  TString contOutName(Form("%s_histos", taskName.Data()));
193  mgr->ConnectOutput(eTask, 1, mgr->CreateContainer(contOutName, TList::Class(), AliAnalysisManager::kOutputContainer, commonoutput.Data()));
194 
195  return eTask;
196 }
197 
199  fEventTriggerBits = 0x0; // Reset
200  fTriggerPatches = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerPatchesName));
201 
202  if (!fTriggerPatches) return;
203 
204  Int_t nPatches = fTriggerPatches->GetEntries();
205 
206  for (Int_t i = 0; i < nPatches; i++) {
207  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
208  if (!patch) continue;
209  if (patch->GetADCAmp() < fMinAmplitude) continue;
210  if (patch->IsLevel0()) {
211  fEventTriggerBits |= 0x1 << kL0;
212  fHistManager.FillTH1("fHistPatchEnergy_Trig_L0",patch->GetPatchE());
213  fHistManager.FillTH1("fHistPatchOnlineADCAmp_Trig_L0",patch->GetADCAmp());
214  }
215  if (patch->IsGammaLow()) {
216  fEventTriggerBits |= 0x1 << kEG1;
217  fHistManager.FillTH1("fHistPatchEnergy_Trig_EG1",patch->GetPatchE());
218  fHistManager.FillTH1("fHistPatchOnlineADCAmp_Trig_EG1",patch->GetADCAmp());
219  }
220  if (patch->IsGammaHigh()) {
221  fEventTriggerBits |= 0x1 << kEG2;
222  fHistManager.FillTH1("fHistPatchEnergy_Trig_EG2",patch->GetPatchE());
223  fHistManager.FillTH1("fHistPatchOnlineADCAmp_Trig_EG2",patch->GetADCAmp());
224  }
225  if (patch->IsJetLow()) {
226  fEventTriggerBits |= 0x1 << kEJ1;
227  fHistManager.FillTH1("fHistPatchEnergy_Trig_EJ1",patch->GetPatchE());
228  fHistManager.FillTH1("fHistPatchOnlineADCAmp_Trig_EJ1",patch->GetADCAmp());
229  }
230  if (patch->IsJetHigh()) {
231  fEventTriggerBits |= 0x1 << kEJ2;
232  fHistManager.FillTH1("fHistPatchEnergy_Trig_EJ2",patch->GetPatchE());
233  fHistManager.FillTH1("fHistPatchOnlineADCAmp_Trig_EJ2",patch->GetADCAmp());
234  }
235  }
236 }
237 
239  TString histname;
240 
242  if (!clusters) {
243  AliError("Cluster Container Not Found");
244  return ;
245  }
246  Int_t nClusters = clusters->GetNClusters();
247  fHistManager.FillTH1("NClusters",nClusters);
248 
249  // Cycle over clusters
250  for (Int_t i = 0; i < nClusters; i++) {
251  AliVCluster * cluster = (AliVCluster *) clusters->GetAcceptCluster(i);
252  if (!cluster) continue;
253  for (Int_t j = 0; j < kNTriggerTypes; j++) {
254  // Check if this event had this trigger
255  if (fTriggerTypes[j] < 0) {
256  if (fEventTriggerBits != 0) continue; // Classify no trigger as mininum bias
257  }
258  else if (!(fEventTriggerBits & (0x1 << fTriggerTypes[j]))) {
259  continue;
260  }
261 
262  // Get Cluster vector
263  TLorentzVector vCluster;
264  clusters->GetMomentum(vCluster,cluster);
265  Double_t fPhi = vCluster.Phi();
266  if (fPhi < 0) fPhi+=2*TMath::Pi();
267 
268  histname = TString::Format("fHistClusEnergy_Trig_%s",fTriggerNames[j].Data());
269  fHistManager.FillTH1(histname,cluster->E());
270  histname = TString::Format("fHistClusEtaPhi_Trig_%s",fTriggerNames[j].Data());
271  fHistManager.FillTH1(histname,vCluster.Eta(),fPhi);
272  }
273  }
274 }
275 
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
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
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