AliPhysics  c7b8e89 (c7b8e89)
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  // Hist for counting clusters
91  fHistManager.CreateTH1("NClusters","NClusters;N_{cluster}; counts",300,0,300);
92 
93  // loop over trigger types
94  for (Int_t i = 0; i < kNTriggerTypes; i++) {
95  histname = TString::Format("fHistClusEnergy_Trig_%s",fTriggerNames[i].Data());
96  title = histname + ";#it{E}_{cluster} (GeV); counts";
97  fHistManager.CreateTH1(histname.Data(),title.Data(),nPtBins,0,fMaxPt);
98  }
99 
101 }
102 
108  if (!fCaloClusters)
109  {
110  fCaloClusters = (TClonesArray*)GetClusterContainer(0);
111  }
112 
113  return kTRUE;
114 }
115 
121  // Loop over patches, identify which trigger conditions are met
122  DoPatchLoop();
123 
124  // Loop over clusters
125  DoClusterLoop();
126  return kTRUE;
127 }
128 
134  TString ClusterContName = "caloClusters";
135 
136  // Get the pointer to the existing analysis manager via the static access method
137  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
138  if (!mgr) {
139  ::Error("AliEmcalTriggerSimQATask", "No analysis manager to connect to.");
140  return 0;
141  }
142 
143  // Check the analysis type using the event handlers connected to the analysis manager
144  AliVEventHandler *evhand = mgr->GetInputEventHandler();
145  if (!evhand) {
146  ::Error("AliEmcalTriggerSimQATask", "This task requires an input event handler");
147  return 0;
148  }
149 
150  // Init the task and set settings
151  TString taskName("AliEmcalTriggerSimQATask");
152  AliEmcalTriggerSimQATask * eTask = new AliEmcalTriggerSimQATask(taskName);
153  eTask->AddClusterContainer(ClusterContName);
154 
155  mgr->AddTask(eTask);
156  // Create containers for input/output
157  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
158  mgr->ConnectInput(eTask, 0, cinput1);
159 
160  TString commonoutput(Form("%s", AliAnalysisManager::GetCommonFileName()));
161 
162  TString contOutName(Form("%s_histos", taskName.Data()));
163  mgr->ConnectOutput(eTask, 1, mgr->CreateContainer(contOutName, TList::Class(), AliAnalysisManager::kOutputContainer, commonoutput.Data()));
164 
165  return eTask;
166 }
167 
169  fEventTriggerBits = 0x0; // Reset
170  fTriggerPatches = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerPatchesName));
171 
172  if (!fTriggerPatches) return;
173 
174  Int_t nPatches = fTriggerPatches->GetEntries();
175 
176  for (Int_t i = 0; i < nPatches; i++) {
177  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
178  if (!patch) continue;
179  if (patch->GetADCAmp() < fMinAmplitude) continue;
180  if (patch->IsLevel0()) fEventTriggerBits |= 0x1 << kL0;
181  if (patch->IsGammaLow()) fEventTriggerBits |= 0x1 << kEG1;
182  if (patch->IsGammaHigh()) fEventTriggerBits |= 0x1 << kEG2;
183  if (patch->IsJetLow()) fEventTriggerBits |= 0x1 << kEJ1;
184  if (patch->IsJetHigh()) fEventTriggerBits |= 0x1 << kEJ2;
185  }
186 }
187 
189  TString histname;
190 
192  if (!clusters) {
193  AliError("Cluster Container Not Found");
194  return ;
195  }
196  Int_t nClusters = clusters->GetNClusters();
197  fHistManager.FillTH1("NClusters",nClusters);
198 
199  // Cycle over clusters
200  for (Int_t i = 0; i < nClusters; i++) {
201  AliVCluster * cluster = (AliVCluster *) clusters->GetAcceptCluster(i);
202  if (!cluster) continue;
203  for (Int_t j = 0; j < kNTriggerTypes; j++) {
204  // Check if this event had this trigger
205  if (fTriggerTypes[j] < 0) {
206  if (fEventTriggerBits != 0) continue; // Classify no trigger as mininum bias
207  }
208  else if (!(fEventTriggerBits & (0x1 << fTriggerTypes[j]))) {
209  continue;
210  }
211 
212  histname = TString::Format("fHistClusEnergy_Trig_%s",fTriggerNames[j].Data());
213  fHistManager.FillTH1(histname,cluster->E());
214  }
215  }
216 }
217 
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
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)
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