AliPhysics  d84cbc0 (d84cbc0)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <THnSparse.h>
22 #include <THistManager.h>
23 
24 #include "AliVEvent.h"
25 #include "AliVVertex.h"
26 
31 
35 
36 namespace EMCalTriggerPtAnalysis {
37 
41 AliEMCalTriggerEventCounterAnalysisComponent::AliEMCalTriggerEventCounterAnalysisComponent():
43 {
44 }
45 
51 {
52 }
53 
59 
60  // Create trigger definitions
61  std::map<std::string, std::string> triggerCombinations;
62  GetAllTriggerNamesAndTitles(triggerCombinations);
63 
64  if(fComponentDebugLevel > 0){
65  std::cout << "Event counter component - Found the following triggers:" << std::endl;
66  for(std::map<std::string, std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); it++){
67  std::cout << it->first << ", " << it->second << std::endl;
68  }
69  }
70 
71  AliEMCalTriggerBinningDimension *vertexbinning = fBinning->GetBinning("zvertex");
72 
73  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
74  const std::string name = it->first, &title = it->second;
75  // Create event-based histogram
76  fHistos->CreateTH1(Form("hEventHist%s", name.c_str()), Form("Event-based data for %s events; pileup rejection; z_{V} (cm)", title.c_str()), vertexbinning->GetNumberOfBins(), vertexbinning->GetBinLimits());
77  }
78 
79  // Make correlation histogram for different trigger classes
80  const TAxis **triggeraxis = new const TAxis *[triggerCombinations.size()];
81  memset(triggeraxis, 0, sizeof(const TAxis *) * triggerCombinations.size());
82  const char *binlabels[2] = {"OFF", "ON"};
83  TAxis *mytrgaxis = new TAxis[triggerCombinations.size()];
84  std::map<std::string, std::string>::iterator trgiter = triggerCombinations.begin();
85  for(int itrg = 0; itrg < triggerCombinations.size(); ++itrg){
86  DefineAxis(mytrgaxis[itrg], trgiter->first.c_str(), trgiter->first.c_str(), 2, -0.5, 1.5, binlabels);
87  triggeraxis[itrg] = mytrgaxis+itrg;
88  trgiter++;
89  }
90  fHistos->CreateTHnSparse("hEventTriggers", "Trigger type per event", triggerCombinations.size(), triggeraxis);
91  delete[] mytrgaxis;
92  delete[] triggeraxis;
93 }
94 
101  if(!fTriggerClassManager) return;
102 
103  double vz = data->GetRecEvent()->GetPrimaryVertex()->GetZ();
104  TArrayD triggerCorrelation(fTriggerClassManager->GetAllTriggerClasses()->GetEntries());
105  memset(triggerCorrelation.GetArray(), 0, sizeof(double) * triggerCorrelation.GetSize());
106 
107  std::vector<std::string> triggernames;
108  this->GetMachingTriggerNames(triggernames);
109 
110  THnSparse *correlationhist = dynamic_cast<THnSparse *>(fHistos->FindObject("hEventTriggers"));
111  for(std::vector<std::string>::iterator it = triggernames.begin(); it != triggernames.end(); it++){
112  fHistos->FillTH1(Form("hEventHist%s", it->c_str()) ,vz);
113  if(correlationhist){
114  int idim = FindAxis(correlationhist, it->c_str());
115  if(idim >= 0) triggerCorrelation[idim] = 1.;
116  }
117  }
118  if(correlationhist) correlationhist->Fill(triggerCorrelation.GetArray());
119 }
120 
133  const char* title, int nbins, double min, double max,
134  const char** labels) const {
135  axis.Set(nbins, min, max);
136  axis.SetName(name);
137  axis.SetTitle(title);
138  if(labels){
139  for(int ib = 1; ib <= axis.GetNbins(); ++ib)
140  axis.SetBinLabel(ib, labels[ib-1]);
141  }
142 }
143 
145  Int_t naxis = hist->GetNdimensions();
146  Int_t result = -1;
147  for(int idim = 0; idim < naxis; idim++){
148  if(!TString(hist->GetAxis(idim)->GetName()).CompareTo(title)){
149  result = idim;
150  break;
151  }
152  }
153  return result;
154 }
155 
156 } /* namespace EMCalTriggerPtAnalysis */
const char * title
Definition: MakeQAPdf.C:26
void GetMachingTriggerNames(std::vector< std::string > &triggernames) const
Declaration of a management class for trigger classes.
TObject * FindObject(const char *name) const
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="")
THistManager * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaClassManager * fTriggerClassManager
Global trigger class manager.
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Base class for analysis components in the analysis of EMCAL-triggered events.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
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="")
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.