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