]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskPtEMCalTrigger.cxx
Allow swapping the sign of eta in case of asymmetric collision systems
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskPtEMCalTrigger.cxx
CommitLineData
46f589c2 1/**************************************************************************
2 * Copyright(c) 1998-2007, 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/*
17 * Analysis task of the pt analysis on EMCal-triggered events
18 *
19 * Author: Markus Fasel
20 */
21
22#include <map>
23#include <cstring>
24#include <iostream>
25#include <memory>
26#include <vector>
27#include <string>
28#include <sstream>
29
bf1cb6ad 30#include <TClonesArray.h>
46f589c2 31#include <TDirectory.h>
32#include <TH1.h>
33#include <THashList.h>
eed93770 34#include <TList.h>
46f589c2 35#include <TKey.h>
36#include <TMath.h>
37#include <TObjArray.h>
38#include <TString.h>
39
bf1cb6ad 40#include "AliESDCaloCluster.h"
46f589c2 41#include "AliESDEvent.h"
42#include "AliESDInputHandler.h"
43#include "AliESDtrack.h"
44#include "AliESDVertex.h"
45
46#include "AliEMCalHistoContainer.h"
47#include "AliAnalysisTaskPtEMCalTrigger.h"
48
49ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskPtEMCalTrigger)
50
51namespace EMCalTriggerPtAnalysis {
52
53 //______________________________________________________________________________
54 AliAnalysisTaskPtEMCalTrigger::AliAnalysisTaskPtEMCalTrigger():
55 AliAnalysisTaskSE(),
56 fResults(NULL),
57 fHistos(NULL),
4c61ea4f 58 fListTrackCuts(NULL),
59 fEtaRange(),
60 fPtRange()
46f589c2 61 {
62 /*
63 * Dummy constructor, initialising the values with default (NULL) values
64 */
65 }
66
67 //______________________________________________________________________________
68 AliAnalysisTaskPtEMCalTrigger::AliAnalysisTaskPtEMCalTrigger(const char *name):
69 AliAnalysisTaskSE(name),
70 fResults(NULL),
71 fHistos(NULL),
4c61ea4f 72 fListTrackCuts(NULL),
73 fEtaRange(),
710e1b95 74 fPtRange(),
75 fSwapEta(kFALSE)
46f589c2 76 {
77 /*
78 * Main constructor, setting default values for eta and zvertex cut
79 */
80 DefineOutput(1, TList::Class());
81
82 fListTrackCuts = new TList;
83 fListTrackCuts->SetOwner(false);
84
85 // Set default cuts
86 fEtaRange.SetLimits(-0.8, 0.8);
bf9501c1 87 fPtRange.SetLimits(0.15, 100.);
46f589c2 88
89 }
90
91 //______________________________________________________________________________
92 AliAnalysisTaskPtEMCalTrigger::~AliAnalysisTaskPtEMCalTrigger(){
93 /*
94 * Destructor, deleting output
95 */
96 //if(fTrackSelection) delete fTrackSelection;
97 if(fHistos) delete fHistos;
98 if(fListTrackCuts) delete fListTrackCuts;
99 }
100
101 //______________________________________________________________________________
102 void AliAnalysisTaskPtEMCalTrigger::UserCreateOutputObjects(){
103 /*
104 * Create the list of output objects and define the histograms.
105 * Also adding the track cuts to the list of histograms.
106 */
107 fResults = new TList;
108 fResults->SetOwner();
109
110 fHistos = new AliEMCalHistoContainer("PtEMCalTriggerHistograms");
111 fHistos->ReleaseOwner();
112
113 std::map<std::string, std::string> triggerCombinations;
bf1cb6ad 114 const char *triggernames[12] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh", "EMCGLow", "NoEMCal", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly", "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"},
f9e83256 115 *bitnames[4] = {"CINT7", "EMC7", "kEMCEGA", "kEMCEJE"};
46f589c2 116 // Define axes for the trigger correlation histogram
117 const TAxis *triggeraxis[5]; memset(triggeraxis, 0, sizeof(const TAxis *) * 5);
f9e83256 118 const TAxis *bitaxes[4]; memset(bitaxes, 0, sizeof(TAxis *) * 4);
46f589c2 119 const char *binlabels[2] = {"OFF", "ON"};
f9e83256 120 TAxis mytrgaxis[5], mybitaxis[4];
46f589c2 121 for(int itrg = 0; itrg < 5; ++itrg){
122 DefineAxis(mytrgaxis[itrg], triggernames[itrg], triggernames[itrg], 2, -0.5, 1.5, binlabels);
123 triggeraxis[itrg] = mytrgaxis+itrg;
f9e83256 124 if(itrg < 4){
125 DefineAxis(mybitaxis[itrg], bitnames[itrg], bitnames[itrg], 2, -0.5, 1.5, binlabels);
126 bitaxes[itrg] = mybitaxis+itrg;
127 }
46f589c2 128 }
129 // Define names and titles for different triggers in the histogram container
130 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
131 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
132 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
f9e83256 133 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
134 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
bf1cb6ad 135 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "non-EMCal-triggered events"));
136 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "jet and gamma triggered events (high threshold)"));
137 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively gamma-triggered events (high threshold)"));
138 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "exclusively jet-triggered events (high threshold)"));
139 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "jet and gamma triggered events (low threshold)"));
140 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively gamma-triggered events (low threshold)"));
141 triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[11], "exclusively-triggered events (low threshold)"));
46f589c2 142 // Define axes for the pt histogram
143 // Dimensions:
144 // 1. pt
145 // 2. eta
146 // 3. phi
147 // 4. vertex
148 // 5. pileup (0 = all events, 1 = after pileup rejection)
149 // 6. track cuts (0 = no cuts; 1 = after std cuts)
150 TArrayD ptbinning, zvertexBinning, etabinning, pileupaxis(3);
151 pileupaxis[0] = -0.5; pileupaxis[1] = 0.5; pileupaxis[2] = 1.5;
152 CreateDefaultPtBinning(ptbinning);
153 CreateDefaultZVertexBinning(zvertexBinning);
154 CreateDefaultEtaBinning(etabinning);
155 TAxis htrackaxes[6];
156 DefineAxis(htrackaxes[0], "pt", "p_{t} (GeV/c)", ptbinning);
157 DefineAxis(htrackaxes[1], "eta", "#eta", etabinning);
eed93770 158 DefineAxis(htrackaxes[2], "phi", "#phi", 20, 0, 2 * TMath::Pi());
46f589c2 159 DefineAxis(htrackaxes[3], "zvertex", "z_{V} (cm)", zvertexBinning);
160 DefineAxis(htrackaxes[4], "pileup", "Pileup rejection", 2, -0.5, 1.5);
161 DefineAxis(htrackaxes[5], "trackcuts", "Track Cuts", (fListTrackCuts ? fListTrackCuts->GetEntries() : 0) + 1, -0.5, (fListTrackCuts ? fListTrackCuts->GetEntries() : 0) + 0.5);
162 const TAxis *trackaxes[6];
163 for(int iaxis = 0; iaxis < 6; ++iaxis) trackaxes[iaxis] = htrackaxes + iaxis;
bf1cb6ad 164 TAxis hclusteraxes[3];
165 DefineAxis(hclusteraxes[0], "energy", "E (GeV)", ptbinning);
166 DefineAxis(hclusteraxes[1], "zvertex", "z_{V} (cm)", zvertexBinning);
167 DefineAxis(hclusteraxes[2], "pileup", "Pileup rejection", 2, -0.5, 1.5);
168 const TAxis *clusteraxes[3];
169 for(int iaxis = 0; iaxis < 3; ++iaxis) clusteraxes[iaxis] = hclusteraxes + iaxis;
46f589c2 170 try{
171 for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
172 const std::string name = it->first, &title = it->second;
173 // Create event-based histogram
174 fHistos->CreateTH2(Form("hEventHist%s", name.c_str()), Form("Event-based data for %s events; pileup rejection; z_{V} (cm)", title.c_str()), pileupaxis, zvertexBinning);
175 // Create track-based histogram
176 fHistos->CreateTHnSparse(Form("hTrackHist%s", name.c_str()), Form("Track-based data for %s events", title.c_str()), 6, trackaxes);
bf1cb6ad 177 // Create cluster-based histogram (Uncalibrated and calibrated clusters)
178 fHistos->CreateTHnSparse(Form("hClusterCalibHist%s", name.c_str()), Form("Calib. cluster-based histogram for %s events", title.c_str()), 3, clusteraxes);
179 fHistos->CreateTHnSparse(Form("hClusterUncalibHist%s", name.c_str()), Form("Uncalib. cluster-based histogram for %s events", title.c_str()), 3, clusteraxes);
46f589c2 180 }
181 fHistos->CreateTHnSparse("hEventTriggers", "Trigger type per event", 5, triggeraxis);
f9e83256 182 fHistos->CreateTHnSparse("hEventsTriggerbit", "Trigger bits for the different events", 4, bitaxes);
46f589c2 183 } catch (HistoContainerContentException &e){
184 std::stringstream errormessage;
185 errormessage << "Creation of histogram failed: " << e.what();
186 AliError(errormessage.str().c_str());
187 }
188 fResults->Add(fHistos->GetListOfHistograms());
189 if(fListTrackCuts && fListTrackCuts->GetEntries()){
190 TIter cutIter(fListTrackCuts);
191 AliESDtrackCuts *cutObject(NULL);
192 while((cutObject = dynamic_cast<AliESDtrackCuts *>(cutIter()))){
193 cutObject->DefineHistograms();
194 fResults->Add(cutObject);
195 }
196 }
197 PostData(1, fResults);
198 }
199
200 //______________________________________________________________________________
201 void AliAnalysisTaskPtEMCalTrigger::UserExec(Option_t* /*option*/){
202 /*
203 * Runs the event loop
204 *
205 * @param option: Additional options
206 */
46f589c2 207 // Common checks: Have SPD vertex and primary vertex from tracks, and both need to have at least one contributor
208 AliESDEvent *esd = static_cast<AliESDEvent *>(fInputEvent);
209 const AliESDVertex *vtxTracks = esd->GetPrimaryVertex(),
210 *vtxSPD = esd->GetPrimaryVertexSPD();
211 if(!(vtxTracks && vtxSPD)) return;
212 if(vtxTracks->GetNContributors() < 1 || vtxSPD->GetNContributors() < 1) return;
213
f9e83256 214 double triggers[5]; memset(triggers, 0, sizeof(double) * 5);
215 double triggerbits[4]; memset(triggerbits, 0, sizeof(double) * 4);
216 if(fInputHandler->IsEventSelected() & AliVEvent::kINT7){
46f589c2 217 triggers[0] = 1.;
f9e83256 218 triggerbits[0] = 1.;
219 }
46f589c2 220
f9e83256 221 // check triggerbits
46f589c2 222 if(fInputHandler->IsEventSelected() & AliVEvent::kEMC7){
f9e83256 223 triggerbits[1] = 1.;
224 }
225 if(fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA){
226 triggerbits[2] = 1.;
227 }
228 if(fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE){
229 triggerbits[3] = 1.;
46f589c2 230 }
f9e83256 231 try{
232 fHistos->FillTHnSparse("hEventsTriggerbit", triggerbits);
233 } catch(HistoContainerContentException &e) {
234 std::stringstream errormessage;
235 errormessage << "Filling of histogram failed: " << e.what();
236 AliError(errormessage.str().c_str());
237 }
238
239 std::vector<std::string> triggerstrings;
240 // EMCal-triggered event, distinguish types
241 TString trgstr(fInputEvent->GetFiredTriggerClasses());
242 if(trgstr.Contains("EJ1")){
243 triggerstrings.push_back("EMCJHigh");
244 triggers[1] = 1;
bf1cb6ad 245 if(trgstr.Contains("EG1"))
246 triggerstrings.push_back("EMCHighBoth");
247 else
248 triggerstrings.push_back("EMCHighJetOnly");
f9e83256 249 }
250 if(trgstr.Contains("EJ2")){
251 triggerstrings.push_back("EMCJLow");
252 triggers[2] = 1;
bf1cb6ad 253 if(trgstr.Contains("EG2"))
254 triggerstrings.push_back("EMCLowBoth");
255 else
256 triggerstrings.push_back("EMCLowJetOnly");
f9e83256 257 }
258 if(trgstr.Contains("EG1")){
259 triggerstrings.push_back("EMCGHigh");
260 triggers[3] = 1;
bf1cb6ad 261 if(!trgstr.Contains("EJ1"))
262 triggerstrings.push_back("EMCHighGammaOnly");
f9e83256 263 }
264 if(trgstr.Contains("EG2")){
265 triggerstrings.push_back("EMCGLow");
266 triggers[4] = 1;
bf1cb6ad 267 if(!trgstr.Contains("EJ2"))
268 triggerstrings.push_back("EMCLowGammaOnly");
f9e83256 269 }
270
46f589c2 271 try{
272 fHistos->FillTHnSparse("hEventTriggers", triggers);
273 } catch (HistoContainerContentException &e){
274 std::stringstream errormessage;
275 errormessage << "Filling of histogram failed: " << e.what();
276 AliError(errormessage.str().c_str());
277 }
278
279 // apply event selection: Combine the Pileup cut from SPD with the other pA Vertex selection cuts.
280 bool isPileupEvent = esd->IsPileupFromSPD();
281 isPileupEvent = isPileupEvent || (TMath::Abs(vtxTracks->GetZ() - vtxSPD->GetZ()) > 0.5);
282 double covSPD[6]; vtxSPD->GetCovarianceMatrix(covSPD);
283 isPileupEvent = isPileupEvent || (TString(vtxSPD->GetTitle()).Contains("vertexer:Z") && TMath::Sqrt(covSPD[5]) > 0.25);
284
285 // Fill event-based histogram
286 const double &zv = vtxTracks->GetZ();
287 if(triggers[0]) FillEventHist("MinBias", zv, isPileupEvent);
288 if(!triggerstrings.size()) // Non-EMCal-triggered
289 FillEventHist("NoEMCal", zv, isPileupEvent);
290 else{
291 // EMCal-triggered events
292 for(std::vector<std::string>::iterator it = triggerstrings.begin(); it != triggerstrings.end(); ++it)
293 FillEventHist(it->c_str(), zv, isPileupEvent);
294 }
295
296 AliESDtrack *track(NULL);
297 // Loop over all tracks (No cuts applied)
298 for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
299 track = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(itrk));
bf9501c1 300 if(!fEtaRange.IsInRange(track->Eta())) continue;
301 if(!fPtRange.IsInRange(track->Pt())) continue;
46f589c2 302 if(triggers[0]) FillTrackHist("MinBias", track, zv, isPileupEvent, 0);
303 if(!triggerstrings.size()) // Non-EMCal-triggered
304 FillTrackHist("NoEMCal", track, zv, isPileupEvent, 0);
305 else {
306 // EMCal-triggered events
307 for(std::vector<std::string>::iterator it = triggerstrings.begin(); it != triggerstrings.end(); ++it)
308 FillTrackHist(it->c_str(), track, zv, isPileupEvent, 0);
309 }
310 }
311
312 // Now apply track selection cuts
313 // allow for several track selections to be tested at the same time
314 // each track selection gets a different cut ID starting from 1
315 // cut ID 0 is reserved for the case of no cuts
316 if(fListTrackCuts && fListTrackCuts->GetEntries()){
317 for(int icut = 0; icut < fListTrackCuts->GetEntries(); icut++){
318 AliESDtrackCuts *trackSelection = static_cast<AliESDtrackCuts *>(fListTrackCuts->At(icut));
319 std::auto_ptr<TObjArray> acceptedTracks(trackSelection->GetAcceptedTracks(esd));
320 TIter trackIter(acceptedTracks.get());
321 while((track = dynamic_cast<AliESDtrack *>(trackIter()))){
322 if(!fEtaRange.IsInRange(track->Eta())) continue;
bf9501c1 323 if(!fPtRange.IsInRange(track->Pt())) continue;
46f589c2 324 if(triggers[0]) FillTrackHist("MinBias", track, zv, isPileupEvent, icut + 1);
325 if(!triggerstrings.size()) // Non-EMCal-triggered
326 FillTrackHist("NoEMCal", track, zv, isPileupEvent, icut + 1);
327 else {
328 // EMCal-triggered events
329 for(std::vector<std::string>::iterator it = triggerstrings.begin(); it != triggerstrings.end(); ++it)
330 FillTrackHist(it->c_str(), track, zv, isPileupEvent, icut + 1);
331 }
332 }
333 }
334 }
bf1cb6ad 335
336 // Next step we loop over the (uncalibrated) emcal clusters and fill histograms with the cluster energy
337 for(int icl = 0; icl < fInputEvent->GetNumberOfCaloClusters(); icl++){
338 const AliVCluster *clust = fInputEvent->GetCaloCluster(icl);
339 if(!clust->IsEMCAL()) continue;
340 if(triggers[0]) FillClusterHist("MinBias", clust, false, zv, isPileupEvent);
341 if(!triggerstrings.size()) // Non-EMCal-triggered
342 FillClusterHist("NoEMCal", clust, false, zv, isPileupEvent);
343 else{
344 for(std::vector<std::string>::iterator it = triggerstrings.begin(); it != triggerstrings.end(); ++it){
345 FillClusterHist(it->c_str(), clust, false, zv, isPileupEvent);
346 }
347 }
348 }
349
350 TClonesArray *calibratedClusters = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject("EmcCaloClusters"));
351 if(calibratedClusters){
352 for(int icl = 0; icl < calibratedClusters->GetEntries(); icl++){
353 const AliVCluster *clust = dynamic_cast<const AliVCluster *>((*calibratedClusters)[icl]);
354 if(!clust->IsEMCAL()) continue;
355 if(triggers[0]) FillClusterHist("MinBias", clust, true, zv, isPileupEvent);
356 if(!triggerstrings.size()) // Non-EMCal-triggered
357 FillClusterHist("NoEMCal", clust, true, zv, isPileupEvent);
358 else{
359 for(std::vector<std::string>::iterator it = triggerstrings.begin(); it != triggerstrings.end(); ++it){
360 FillClusterHist(it->c_str(), clust, true, zv, isPileupEvent);
361 }
362 }
363 }
364 }
365
46f589c2 366 PostData(1, fResults);
367 }
368
369 //______________________________________________________________________________
370 void AliAnalysisTaskPtEMCalTrigger::CreateDefaultPtBinning(TArrayD &binning) const{
371 /*
372 * Creating the default pt binning.
373 *
374 * @param binning: Array where to store the results.
375 */
376 std::vector<double> mybinning;
377 std::map<double,double> definitions;
378 definitions.insert(std::pair<double,double>(2.5, 0.1));
379 definitions.insert(std::pair<double,double>(7., 0.25));
380 definitions.insert(std::pair<double,double>(15., 0.5));
381 definitions.insert(std::pair<double,double>(25., 1.));
382 definitions.insert(std::pair<double,double>(40., 2.5));
383 definitions.insert(std::pair<double,double>(60., 5.));
384 definitions.insert(std::pair<double,double>(100., 5.));
385 double currentval = 0;
386 for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
387 double limit = id->first, binwidth = id->second;
388 while(currentval <= limit){
389 currentval += binwidth;
390 mybinning.push_back(currentval);
391 }
392 }
393 binning.Set(mybinning.size());
394 int ib = 0;
395 for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
396 binning[ib++] = *it;
397 }
398
399 //______________________________________________________________________________
400 void AliAnalysisTaskPtEMCalTrigger::CreateDefaultZVertexBinning(TArrayD &binning) const {
401 /*
402 * Creating default z-Vertex binning.
403 *
404 * @param binning: Array where to store the results.
405 */
406 std::vector<double> mybinning;
407 double currentval = -40;
408 mybinning.push_back(currentval);
409 while(currentval <= 40.){
eed93770 410 currentval += 1.;
46f589c2 411 mybinning.push_back(currentval);
412 }
413 binning.Set(mybinning.size());
414 int ib = 0;
415 for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
416 binning[ib++] = *it;
417 }
418
419 //______________________________________________________________________________
420 void AliAnalysisTaskPtEMCalTrigger::CreateDefaultEtaBinning(TArrayD& binning) const {
421 /*
422 * Creating default z-Vertex binning.
423 *
424 * @param binning: Array where to store the results.
425 */
426 std::vector<double> mybinning;
427 double currentval = -0.8;
428 mybinning.push_back(currentval);
429 while(currentval <= 0.8){
eed93770 430 currentval += 0.1;
46f589c2 431 mybinning.push_back(currentval);
432 }
433 binning.Set(mybinning.size());
434 int ib = 0;
435 for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
436 binning[ib++] = *it;
437 }
438
439 //______________________________________________________________________________
440 void AliAnalysisTaskPtEMCalTrigger::DefineAxis(TAxis& axis, const char* name,
441 const char* title, const TArrayD& binning, const char** labels) {
442 /*
443 * Define an axis with a given binning
444 *
445 * @param axis: Axis to be defined
446 * @param name: Name of the axis
447 * @param title: Title of the axis
448 * @param binning: axis binning
449 * @param labels (@optional): array of bin labels
450 */
451 axis.Set(binning.GetSize()-1, binning.GetArray());
452 axis.SetName(name);
453 axis.SetTitle(title);
454 if(labels){
455 for(int ib = 1; ib <= axis.GetNbins(); ++ib)
5da6b0c2 456 axis.SetBinLabel(ib, labels[ib-1]);
46f589c2 457 }
458 }
459
460 //______________________________________________________________________________
461 void AliAnalysisTaskPtEMCalTrigger::DefineAxis(TAxis& axis, const char* name,
462 const char* title, int nbins, double min, double max,
463 const char** labels) {
464 /*
465 * Define an axis with number of bins from min to max
466 *
467 * @param axis: Axis to be defined
468 * @param name: Name of the axis
469 * @param title: Title of the axis
470 * @param nbins: Number of bins
471 * @param min: lower limit of the axis
472 * @param max: upper limit of the axis
473 * @param labels (@optional): array of bin labels
474 */
475 axis.Set(nbins, min, max);
476 axis.SetName(name);
477 axis.SetTitle(title);
478 if(labels){
479 for(int ib = 1; ib <= axis.GetNbins(); ++ib)
5da6b0c2 480 axis.SetBinLabel(ib, labels[ib-1]);
46f589c2 481 }
482 }
483
484 //______________________________________________________________________________
485 void AliAnalysisTaskPtEMCalTrigger::FillEventHist(const char* trigger,
486 double vz, bool isPileup) {
487 /*
488 * Fill event-based histogram
489 *
490 * @param trigger: name of the trigger configuration to be processed
491 * @param vz: z-position of the vertex
492 * @param isPileup: signalises if the event is flagged as pileup event
493 */
494 char histname[1024];
495 sprintf(histname, "hEventHist%s", trigger);
496 try{
60284bec 497 fHistos->FillTH2(histname, 0., vz);
46f589c2 498 } catch (HistoContainerContentException &e){
499 std::stringstream errormessage;
500 errormessage << "Filling of histogram failed: " << e.what();
501 AliError(errormessage.str().c_str());
502 }
503 if(!isPileup){
504 try{
60284bec 505 fHistos->FillTH2(histname, 1., vz);
46f589c2 506 } catch(HistoContainerContentException &e){
507 std::stringstream errormessage;
508 errormessage << "Filling of histogram failed: " << e.what();
509 AliError(errormessage.str().c_str());
510 }
511 }
512 }
513
514 //______________________________________________________________________________
515 void AliAnalysisTaskPtEMCalTrigger::FillTrackHist(const char* trigger,
516 const AliESDtrack* track, double vz, bool isPileup, int cut) {
517 /*
518 * Fill track-based histogram with corresponding information
519 *
520 * @param trigger: name of the trigger
521 * @param track: ESD track selected
522 * @param vz: z-position of the vertex
523 * @param isPileup: flag event as pileup event
524 * @param cut: id of the cut (0 = no cut)
525 */
710e1b95 526 double etasign = fSwapEta ? -1. : 1.;
527 double data[6] = {track->Pt(), etasign * track->Eta(), track->Phi(), vz, 0, static_cast<double>(cut)};
46f589c2 528 char histname[1024];
529 sprintf(histname, "hTrackHist%s", trigger);
530 try{
531 fHistos->FillTHnSparse(histname, data);
532 } catch (HistoContainerContentException &e){
533 std::stringstream errormessage;
534 errormessage << "Filling of histogram failed: " << e.what();
535 AliError(errormessage.str().c_str());
536 }
537 if(!isPileup){
538 data[4] = 1;
539 try{
540 fHistos->FillTHnSparse(histname, data);
541 } catch (HistoContainerContentException &e){
542 std::stringstream errormessage;
543 errormessage << "Filling of histogram failed: " << e.what();
544 AliError(errormessage.str().c_str());
545 }
546 }
547 }
548
bf1cb6ad 549 //______________________________________________________________________________
550 void AliAnalysisTaskPtEMCalTrigger::FillClusterHist(const char* trigger,
551 const AliVCluster* clust, bool isCalibrated, double vz, bool isPileup) {
552 /*
553 * Fill cluster-based histogram with corresponding information
554 *
555 * @param trigger: name of the trigger
556 * @param cluster: the EMCal cluster information
557 * @param vz: z-position of the vertex
558 * @param isPileup: flag event as pileup event
559 */
560 double data[3] = {clust->E(), vz, 0};
561 char histname[1024];
562 sprintf(histname, "hCluster%sHist%s", isCalibrated ? "Calib" : "Uncalib", trigger);
563 try{
564 fHistos->FillTHnSparse(histname, data);
565 } catch (HistoContainerContentException &e){
566 std::stringstream errormessage;
567 errormessage << "Filling of histogram failed: " << e.what();
568 AliError(errormessage.str().c_str());
569 }
570 if(!isPileup){
571 data[2] = 1.;
572 try{
573 fHistos->FillTHnSparse(histname, data);
574 } catch (HistoContainerContentException &e){
575 std::stringstream errormessage;
576 errormessage << "Filling of histogram failed: " << e.what();
577 AliError(errormessage.str().c_str());
578 }
579 }
580 }
46f589c2 581
bf1cb6ad 582}