AliPhysics  e59a9ba (e59a9ba)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <THistManager.h>
22 #include <TLorentzVector.h>
23 
24 #include "AliLog.h"
25 #include "AliVCluster.h"
26 #include "AliVEvent.h"
27 
32 
36 
37 namespace EMCalTriggerPtAnalysis {
38 
42 AliEMCalTriggerClusterAnalysisComponent::AliEMCalTriggerClusterAnalysisComponent() :
44  fEnergyRange()
45 {
46 }
47 
54  fEnergyRange()
55 {
56  fEnergyRange.SetLimits(0., 1000.);
57 }
58 
64 
65  // Create trigger definitions
66  std::map<std::string, std::string> triggerCombinations;
67  GetAllTriggerNamesAndTitles(triggerCombinations);
68 
69  // Create axis definitions
70  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
71  *etabinning = fBinning->GetBinning("eta"),
72  *phibinning = fBinning->GetBinning("phi"),
73  *vertexbinning = fBinning->GetBinning("zvertex");
74  /*
75  ptbinning->Print();
76  etabinning->Print();
77  phibinning->Print();
78  vertexbinning->Print();
79  */
80 
81  const TAxis *clusteraxes[5] = {
82  DefineAxis("energy", ptbinning),
83  DefineAxis("eta", etabinning),
84  DefineAxis("phi", phibinning),
85  DefineAxis("zvertex", vertexbinning),
86  DefineAxis("mbtrigger", 2, -0.5, 1.5)
87  };
88 
89  // Build histograms
90  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
91  const std::string name = it->first, &title = it->second;
92  fHistos->CreateTHnSparse(Form("hClusterCalibHist%s", name.c_str()), Form("Calib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
93  fHistos->CreateTHnSparse(Form("hClusterUncalibHist%s", name.c_str()), Form("Uncalib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
94  }
95 
96  for(int iaxis = 0; iaxis < 5; iaxis++) delete clusteraxes[iaxis];
97 }
98 
104 
105  // First loop over uncalibrated clusters
106  AliDebug(1, Form("Number of calibrated clusters: %d", data->GetClusterContainer()->GetEntries()));
107 
108  AliVCluster *clust(NULL);
109  AliVEvent *recEv = data->GetRecEvent();
110  std::vector<std::string> triggerNames;
111  GetMachingTriggerNames(triggerNames);
112  for(int iclust = 0; iclust < recEv->GetNumberOfCaloClusters(); iclust++){
113  clust = recEv->GetCaloCluster(iclust);
114  if(!clust->IsEMCAL()) continue;
115  if(!fEnergyRange.IsInRange(clust->E())) continue;
116  for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
117  FillHistogram(Form("hClusterUncalibHist%s", name->c_str()), clust, recEv, fTriggerClassManager->HasMinBiasTrigger());
118  }
119 
120  // Loop also over calibrated clusters
121  if(!data->GetClusterContainer())
122  printf("Cluster container not found \n");
123  TIter clusterIter(data->GetClusterContainer());
124  while((clust = dynamic_cast<AliVCluster *>(clusterIter()))){
125  if(!clust->IsEMCAL()) continue;
126  if(!fEnergyRange.IsInRange(clust->E())) continue;
127  for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
128  FillHistogram(Form("hClusterCalibHist%s", name->c_str()), clust, recEv, fTriggerClassManager->HasMinBiasTrigger());
129  }
130 }
131 
139 void AliEMCalTriggerClusterAnalysisComponent::FillHistogram(const TString& histname, const AliVCluster* clust, AliVEvent *ev, Bool_t inMB) {
140  TLorentzVector vec;
141  double xyz[3];
142  ev->GetPrimaryVertex()->GetXYZ(xyz);
143  clust->GetMomentum(vec, xyz);
144  double infs[5] = {clust->E(), vec.Eta(), vec.Phi(), xyz[2], inMB ? 1. : 0.};
145  fHistos->FillTHnSparse(histname.Data(), infs);
146 }
147 
148 
149 } /* namespace EMCalTriggerPtAnalysis */
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)
Declaration of a management class for trigger classes.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
THistManager * 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.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Simple event container within the high- track analysis.
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.