AliPhysics  64f4410 (64f4410)
AliEMCalTriggerEventCounterAnalysisComponent.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2014, 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 #include <iostream>
16 #include <map>
17 #include <string>
18 
19 #include <TArrayD.h>
20 #include <TAxis.h>
21 #include <TBinning.h>
22 #include <THnSparse.h>
23 #include <THistManager.h>
24 
25 #include "AliVEvent.h"
26 #include "AliVVertex.h"
27 
32 
36 
37 namespace EMCalTriggerPtAnalysis {
38 
42 AliEMCalTriggerEventCounterAnalysisComponent::AliEMCalTriggerEventCounterAnalysisComponent():
44 {
45 }
46 
52 {
53 }
54 
60 
61  // Create trigger definitions
62  std::map<std::string, std::string> triggerCombinations;
63  GetAllTriggerNamesAndTitles(triggerCombinations);
64 
65  if(fComponentDebugLevel > 0){
66  std::cout << "Event counter component - Found the following triggers:" << std::endl;
67  for(std::map<std::string, std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); it++){
68  std::cout << it->first << ", " << it->second << std::endl;
69  }
70  }
71 
72  const TBinning *vertexbinning = fBinning->GetBinning("zvertex");
73 
74  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
75  const std::string name = it->first, &title = it->second;
76  // Create event-based histogram
77  fHistos->CreateTH1(Form("hEventHist%s", name.c_str()), Form("Event-based data for %s events; pileup rejection; z_{V} (cm)", title.c_str()), *vertexbinning);
78  }
79 
80  // Make correlation histogram for different trigger classes
81  const TAxis **triggeraxis = new const TAxis *[triggerCombinations.size()];
82  memset(triggeraxis, 0, sizeof(const TAxis *) * triggerCombinations.size());
83  const char *binlabels[2] = {"OFF", "ON"};
84  TAxis *mytrgaxis = new TAxis[triggerCombinations.size()];
85  std::map<std::string, std::string>::iterator trgiter = triggerCombinations.begin();
86  for(int itrg = 0; itrg < triggerCombinations.size(); ++itrg){
87  DefineAxis(mytrgaxis[itrg], trgiter->first.c_str(), trgiter->first.c_str(), 2, -0.5, 1.5, binlabels);
88  triggeraxis[itrg] = mytrgaxis+itrg;
89  trgiter++;
90  }
91  fHistos->CreateTHnSparse("hEventTriggers", "Trigger type per event", triggerCombinations.size(), triggeraxis);
92  delete[] mytrgaxis;
93  delete[] triggeraxis;
94 }
95 
102  if(!fTriggerClassManager) return;
103 
104  double vz = data->GetRecEvent()->GetPrimaryVertex()->GetZ();
105  TArrayD triggerCorrelation(fTriggerClassManager->GetAllTriggerClasses()->GetEntries());
106  memset(triggerCorrelation.GetArray(), 0, sizeof(double) * triggerCorrelation.GetSize());
107 
108  std::vector<std::string> triggernames;
109  this->GetMachingTriggerNames(triggernames);
110 
111  THnSparse *correlationhist = dynamic_cast<THnSparse *>(fHistos->FindObject("hEventTriggers"));
112  for(std::vector<std::string>::iterator it = triggernames.begin(); it != triggernames.end(); it++){
113  fHistos->FillTH1(Form("hEventHist%s", it->c_str()) ,vz);
114  if(correlationhist){
115  int idim = FindAxis(correlationhist, it->c_str());
116  if(idim >= 0) triggerCorrelation[idim] = 1.;
117  }
118  }
119  if(correlationhist) correlationhist->Fill(triggerCorrelation.GetArray());
120 }
121 
134  const char* title, int nbins, double min, double max,
135  const char** labels) const {
136  axis.Set(nbins, min, max);
137  axis.SetName(name);
138  axis.SetTitle(title);
139  if(labels){
140  for(int ib = 1; ib <= axis.GetNbins(); ++ib)
141  axis.SetBinLabel(ib, labels[ib-1]);
142  }
143 }
144 
146  Int_t naxis = hist->GetNdimensions();
147  Int_t result = -1;
148  for(int idim = 0; idim < naxis; idim++){
149  if(!TString(hist->GetAxis(idim)->GetName()).CompareTo(title)){
150  result = idim;
151  break;
152  }
153  }
154  return result;
155 }
156 
157 } /* namespace EMCalTriggerPtAnalysis */
const char * title
Definition: MakeQAPdf.C:27
void GetMachingTriggerNames(std::vector< std::string > &triggernames) const
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
Declaration of a management class for trigger classes.
TObject * FindObject(const char *name) const
Find an object inside the container.
int Int_t
Definition: External.C:63
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
THistManager * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaClassManager * fTriggerClassManager
Global trigger class manager.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Base class for analysis components in the analysis of EMCAL-triggered events.
Analysis of high- tracks in triggered events.
Simple event container within the high- track analysis.
const Int_t nbins
void DefineAxis(TAxis &axis, const char *name, const char *title, int nbins, double min, double max, const char **labels) const
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.