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