AliPhysics  vAN-20150827 (3e81cbb)
 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 {
45 }
46 
53  fEnergyRange()
54 {
55  fEnergyRange.SetLimits(0., 1000.);
56 }
57 
63 
64  // Create trigger definitions
65  std::map<std::string, std::string> triggerCombinations;
66  GetAllTriggerNamesAndTitles(triggerCombinations);
67 
68  // Create axis definitions
69  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
70  *etabinning = fBinning->GetBinning("eta"),
71  *phibinning = fBinning->GetBinning("phi"),
72  *vertexbinning = fBinning->GetBinning("zvertex");
73  /*
74  ptbinning->Print();
75  etabinning->Print();
76  phibinning->Print();
77  vertexbinning->Print();
78  */
79 
80  const TAxis *clusteraxes[5] = {
81  DefineAxis("energy", ptbinning),
82  DefineAxis("eta", etabinning),
83  DefineAxis("phi", phibinning),
84  DefineAxis("zvertex", vertexbinning),
85  DefineAxis("mbtrigger", 2, -0.5, 1.5)
86  };
87 
88  // Build histograms
89  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
90  const std::string name = it->first, &title = it->second;
91  fHistos->CreateTHnSparse(Form("hClusterCalibHist%s", name.c_str()), Form("Calib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
92  fHistos->CreateTHnSparse(Form("hClusterUncalibHist%s", name.c_str()), Form("Uncalib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
93  }
94 
95  for(int iaxis = 0; iaxis < 5; iaxis++) delete clusteraxes[iaxis];
96 }
97 
103 
104  // First loop over uncalibrated clusters
105  AliDebug(1, Form("Number of calibrated clusters: %d", data->GetClusterContainer()->GetEntries()));
106 
107  AliVCluster *clust(NULL);
108  AliVEvent *recEv = data->GetRecEvent();
109  std::vector<std::string> triggerNames;
110  GetMachingTriggerNames(triggerNames);
111  for(int iclust = 0; iclust < recEv->GetNumberOfCaloClusters(); iclust++){
112  clust = recEv->GetCaloCluster(iclust);
113  if(!clust->IsEMCAL()) continue;
114  if(!fEnergyRange.IsInRange(clust->E())) continue;
115  for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
116  FillHistogram(Form("hClusterUncalibHist%s", name->c_str()), clust, recEv, fTriggerClassManager->HasMinBiasTrigger());
117  }
118 
119  // Loop also over calibrated clusters
120  if(!data->GetClusterContainer())
121  printf("Cluster container not found \n");
122  TIter clusterIter(data->GetClusterContainer());
123  while((clust = dynamic_cast<AliVCluster *>(clusterIter()))){
124  if(!clust->IsEMCAL()) continue;
125  if(!fEnergyRange.IsInRange(clust->E())) continue;
126  for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
127  FillHistogram(Form("hClusterCalibHist%s", name->c_str()), clust, recEv, fTriggerClassManager->HasMinBiasTrigger());
128  }
129 }
130 
138 void AliEMCalTriggerClusterAnalysisComponent::FillHistogram(const TString& histname, const AliVCluster* clust, AliVEvent *ev, Bool_t inMB) {
139  TLorentzVector vec;
140  double xyz[3];
141  ev->GetPrimaryVertex()->GetXYZ(xyz);
142  clust->GetMomentum(vec, xyz);
143  double infs[5] = {clust->E(), vec.Eta(), vec.Phi(), xyz[2], inMB ? 1. : 0.};
144  fHistos->FillTHnSparse(histname.Data(), infs);
145 }
146 
147 
148 } /* namespace EMCalTriggerPtAnalysis */
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
void FillHistogram(const TString &histname, const AliVCluster *clust, AliVEvent *ev, Bool_t inMB)
const char * title
Definition: MakeQAPdf.C:26
void GetMachingTriggerNames(std::vector< std::string > &triggernames) const
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.)
Declaration of a management class for trigger classes.
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
AliEMCalHistoContainer * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaClassManager * fTriggerClassManager
Global trigger class manager.
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.
Simple event container within the high- track analysis.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.