]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/Tracks/AliEMCalTriggerBinningFactory.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / Tracks / AliEMCalTriggerBinningFactory.cxx
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  */
21 #include "AliEMCalTriggerBinningComponent.h"
22 #include "AliEMCalTriggerBinningFactory.h"
23 #include <map>
24 #include <vector>
25 #include <TMath.h>
26 #include <TArrayD.h>
27
28 namespace EMCalTriggerPtAnalysis {
29
30 //______________________________________________________________________________
31 AliEMCalTriggerBinningFactory::AliEMCalTriggerBinningFactory() {
32   /*
33    * Default constructor, nothing to do
34    */
35 }
36
37
38 //______________________________________________________________________________
39 void AliEMCalTriggerBinningFactory::Create(AliEMCalTriggerBinningComponent* const data) {
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 }
63
64 //______________________________________________________________________________
65 void AliEMCalTriggerBinningFactory::CreateDefaultPtBinning(TArrayD &binning) const{
66   /*
67    * Creating the default pt binning.
68    *
69    * @param binning: Array where to store the results.
70    */
71   std::vector<double> mybinning;
72   std::map<double,double> definitions;
73   definitions.insert(std::pair<double,double>(2.5, 0.1));
74   definitions.insert(std::pair<double,double>(7., 0.25));
75   definitions.insert(std::pair<double,double>(15., 0.5));
76   definitions.insert(std::pair<double,double>(25., 1.));
77   definitions.insert(std::pair<double,double>(40., 2.5));
78   definitions.insert(std::pair<double,double>(50., 5.));
79   definitions.insert(std::pair<double,double>(100., 10.));
80   double currentval = 0;
81   for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
82     double limit = id->first, binwidth = id->second;
83     while(currentval < limit){
84       currentval += binwidth;
85       mybinning.push_back(currentval);
86     }
87   }
88   binning.Set(mybinning.size());
89   int ib = 0;
90   for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
91     binning[ib++] = *it;
92 }
93
94 //______________________________________________________________________________
95 void AliEMCalTriggerBinningFactory::CreateDefaultZVertexBinning(TArrayD &binning) const {
96   /*
97    * Creating default z-Vertex binning.
98    *
99    * @param binning: Array where to store the results.
100    */
101   std::vector<double> mybinning;
102   double currentval = -10;
103   mybinning.push_back(currentval);
104   while(currentval < 10.){
105     currentval += 5.;
106     mybinning.push_back(currentval);
107   }
108   binning.Set(mybinning.size());
109   int ib = 0;
110   for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
111     binning[ib++] = *it;
112 }
113
114 //______________________________________________________________________________
115 void AliEMCalTriggerBinningFactory::CreateDefaultEtaBinning(TArrayD& binning) const {
116   /*
117    * Creating default z-Vertex binning.
118    *
119    * @param binning: Array where to store the results.
120    */
121   std::vector<double> mybinning;
122   double currentval = -0.8;
123   mybinning.push_back(currentval);
124   while(currentval < 0.8){
125     currentval += 0.1;
126     mybinning.push_back(currentval);
127   }
128   binning.Set(mybinning.size());
129   int ib = 0;
130   for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
131     binning[ib++] = *it;
132 }
133
134 //______________________________________________________________________________
135 void AliEMCalTriggerBinningFactory::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
136   /*
137    * Create any kind of linear binning from given ranges and stores it in the binning array.
138    *
139    * @param binning: output array
140    * @param nbins: Number of bins
141    * @param min: lower range
142    * @param max: upper range
143    */
144   double binwidth = (max-min)/static_cast<double>(nbins);
145   binning.Set(nbins+1);
146   binning[0] = min;
147   double currentlimit = min + binwidth;
148   for(int ibin = 0; ibin < nbins; ibin++){
149     binning[ibin+1] = currentlimit;
150     currentlimit += binwidth;
151   }
152 }
153
154 } /* namespace EMCalTriggerPtAnalysis */