AliPhysics  vAN-20150427 (e6e7aad)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalTriggerClusterAnalysisComponent.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 <map>
16 #include <string>
17 #include <vector>
18 
19 #include <TAxis.h>
20 #include <TClonesArray.h>
21 #include <TLorentzVector.h>
22 
23 #include "AliLog.h"
24 #include "AliVCluster.h"
25 #include "AliVEvent.h"
26 
31 
35 
36 namespace EMCalTriggerPtAnalysis {
37 
41 AliEMCalTriggerClusterAnalysisComponent::AliEMCalTriggerClusterAnalysisComponent() :
43  fEnergyRange(),
44  fTriggerMethod(kTriggerString)
45 {
46 }
47 
54  fEnergyRange(),
55  fTriggerMethod(kTriggerString)
56 {
57  fEnergyRange.SetLimits(0., 1000.);
58 }
59 
65 
66  // Create trigger definitions
67  std::map<std::string, std::string> triggerCombinations;
68  const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
69  "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
70  "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
71  // Define names and titles for different triggers in the histogram container
72  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
73  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
74  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
75  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
76  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
77  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
78  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
79  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
80  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
81  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
82  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
83 
84  // Create axis definitions
85  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
86  *etabinning = fBinning->GetBinning("eta"),
87  *phibinning = fBinning->GetBinning("phi"),
88  *vertexbinning = fBinning->GetBinning("zvertex");
89  /*
90  ptbinning->Print();
91  etabinning->Print();
92  phibinning->Print();
93  vertexbinning->Print();
94  */
95 
96  const TAxis *clusteraxes[5] = {
97  DefineAxis("energy", ptbinning),
98  DefineAxis("eta", etabinning),
99  DefineAxis("phi", phibinning),
100  DefineAxis("zvertex", vertexbinning),
101  DefineAxis("mbtrigger", 2, -0.5, 1.5)
102  };
103 
104  // Build histograms
105  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
106  const std::string name = it->first, &title = it->second;
107  fHistos->CreateTHnSparse(Form("hClusterCalibHist%s", name.c_str()), Form("Calib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
108  fHistos->CreateTHnSparse(Form("hClusterUncalibHist%s", name.c_str()), Form("Uncalib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
109  }
110 
111  for(int iaxis = 0; iaxis < 5; iaxis++) delete clusteraxes[iaxis];
112 }
113 
119 
120  // First loop over uncalibrated clusters
121  AliDebug(1, Form("Number of calibrated clusters: %d", data->GetClusterContainer()->GetEntries()));
122 
123  AliVCluster *clust(NULL);
124  AliVEvent *recEv = data->GetRecEvent();
125  std::vector<std::string> triggerNames;
126  this->GetMachingTriggerNames(triggerNames, fTriggerMethod);
127  for(int iclust = 0; iclust < recEv->GetNumberOfCaloClusters(); iclust++){
128  clust = recEv->GetCaloCluster(iclust);
129  if(!clust->IsEMCAL()) continue;
130  if(!fEnergyRange.IsInRange(clust->E())) continue;
131  for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
132  FillHistogram(Form("hClusterUncalibHist%s", name->c_str()), clust, recEv, fTriggerDecision->IsMinBias());
133  }
134 
135  // Loop also over calibrated clusters
136  if(!data->GetClusterContainer())
137  printf("Cluster container not found \n");
138  TIter clusterIter(data->GetClusterContainer());
139  while((clust = dynamic_cast<AliVCluster *>(clusterIter()))){
140  if(!clust->IsEMCAL()) continue;
141  if(!fEnergyRange.IsInRange(clust->E())) continue;
142  for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
143  FillHistogram(Form("hClusterCalibHist%s", name->c_str()), clust, recEv, fTriggerDecision->IsMinBias());
144  }
145 }
146 
154 void AliEMCalTriggerClusterAnalysisComponent::FillHistogram(const TString& histname, const AliVCluster* clust, AliVEvent *ev, Bool_t inMB) {
155  TLorentzVector vec;
156  double xyz[3];
157  ev->GetPrimaryVertex()->GetXYZ(xyz);
158  clust->GetMomentum(vec, xyz);
159  double infs[5] = {clust->E(), vec.Eta(), vec.Phi(), xyz[2], inMB ? 1. : 0.};
160  fHistos->FillTHnSparse(histname.Data(), infs);
161 }
162 
163 
164 } /* namespace EMCalTriggerPtAnalysis */
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Declaration of class AliEMCalTriggerAnaTriggerDecision, a container for trigger decision in EMCAL-tri...
void FillHistogram(const TString &histname, const AliVCluster *clust, AliVEvent *ev, Bool_t inMB)
void GetMachingTriggerNames(std::vector< std::string > &triggernames, ETriggerMethod_t usePatches)
AliCutValueRange< double > fEnergyRange
Allowed energy range for the cluster.
TAxis * DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning)
void FillTHnSparse(const char *name, const double *x, double weight=1.)
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
AliEMCalHistoContainer * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaTriggerDecision * fTriggerDecision
Trigger decision handler.
Analysis component for EMCAL clusters.
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
Base class for analysis components in the analysis of EMCAL-triggered events.
Declaration of the classes AliEMCalTriggerBinningComponent and AliEMCalTriggerBinningDimension.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.