AliPhysics  v5-06-11-01 (156c7f3)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalTriggerBinningFactory.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 /*
16  * Create default binning and initalise the binning component with this. In case
17  * users already defined a binning, do not overwrite this.
18  *
19  * Author: Markus Fasel
20  */
23 #include <map>
24 #include <vector>
25 #include <TMath.h>
26 #include <TArrayD.h>
27 
28 namespace EMCalTriggerPtAnalysis {
29 
30 //______________________________________________________________________________
32  /*
33  * Default constructor, nothing to do
34  */
35 }
36 
37 
38 //______________________________________________________________________________
40  /*
41  * Initialise binning component with default binning
42  *
43  * @param data: the binning component to be initialised
44  */
45  TArrayD binLimits;
46  if(!data->GetBinning("pt")){
47  CreateDefaultPtBinning(binLimits);
48  data->SetBinning("pt", binLimits);
49  }
50  if(!data->GetBinning("eta")){
51  CreateDefaultEtaBinning(binLimits);
52  data->SetBinning("eta", binLimits);
53  }
54  if(!data->GetBinning("phi")){
55  CreateLinearBinning(binLimits, 100, 0, 2*TMath::Pi());
56  data->SetBinning("phi", binLimits);
57  }
58  if(!data->GetBinning("zvertex")){
59  CreateDefaultZVertexBinning(binLimits);
60  data->SetBinning("zvertex", binLimits);
61  }
62  if(!data->GetBinning("centrality")){
63  CreateLinearBinning(binLimits, 5, 0., 100.);
64  data->SetBinning("centrality", binLimits);
65  }
66 }
67 
68 //______________________________________________________________________________
70  /*
71  * Creating the default pt binning.
72  *
73  * @param binning: Array where to store the results.
74  */
75  std::vector<double> mybinning;
76  std::map<double,double> definitions;
77  definitions.insert(std::pair<double,double>(2.5, 0.1));
78  definitions.insert(std::pair<double,double>(7., 0.25));
79  definitions.insert(std::pair<double,double>(15., 0.5));
80  definitions.insert(std::pair<double,double>(25., 1.));
81  definitions.insert(std::pair<double,double>(40., 2.5));
82  definitions.insert(std::pair<double,double>(50., 5.));
83  definitions.insert(std::pair<double,double>(100., 10.));
84  definitions.insert(std::pair<double, double>(200., 20.));
85  double currentval = 0;
86  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
87  double limit = id->first, binwidth = id->second;
88  while(currentval < limit){
89  currentval += binwidth;
90  mybinning.push_back(currentval);
91  }
92  }
93  binning.Set(mybinning.size());
94  int ib = 0;
95  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
96  binning[ib++] = *it;
97 }
98 
99 //______________________________________________________________________________
101  /*
102  * Creating default z-Vertex binning.
103  *
104  * @param binning: Array where to store the results.
105  */
106  std::vector<double> mybinning;
107  double currentval = -10;
108  mybinning.push_back(currentval);
109  while(currentval < 10.){
110  currentval += 5.;
111  mybinning.push_back(currentval);
112  }
113  binning.Set(mybinning.size());
114  int ib = 0;
115  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
116  binning[ib++] = *it;
117 }
118 
119 //______________________________________________________________________________
121  /*
122  * Creating default z-Vertex binning.
123  *
124  * @param binning: Array where to store the results.
125  */
126  std::vector<double> mybinning;
127  double currentval = -0.8;
128  mybinning.push_back(currentval);
129  while(currentval < 0.8){
130  currentval += 0.1;
131  mybinning.push_back(currentval);
132  }
133  binning.Set(mybinning.size());
134  int ib = 0;
135  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
136  binning[ib++] = *it;
137 }
138 
139 //______________________________________________________________________________
140 void AliEMCalTriggerBinningFactory::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
141  /*
142  * Create any kind of linear binning from given ranges and stores it in the binning array.
143  *
144  * @param binning: output array
145  * @param nbins: Number of bins
146  * @param min: lower range
147  * @param max: upper range
148  */
149  double binwidth = (max-min)/static_cast<double>(nbins);
150  binning.Set(nbins+1);
151  binning[0] = min;
152  double currentlimit = min + binwidth;
153  for(int ibin = 0; ibin < nbins; ibin++){
154  binning[ibin+1] = currentlimit;
155  currentlimit += binwidth;
156  }
157 }
158 
159 } /* namespace EMCalTriggerPtAnalysis */
void SetBinning(const char *dimname, int nbins, double *binning)
void Create(AliEMCalTriggerBinningComponent *const data)
void CreateLinearBinning(TArrayD &binning, int nbins, double min, double max) const
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const