ATLAS Offline Software
CaloId.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LArCafJobs/CaloId.h"
6 
7 #include "TH2.h"
8 #include "TProfile2D.h"
9 #include "TMath.h"
10 #include <vector>
11 
12 using namespace LArSamples;
13 
14 
15 TString Id::str(CaloId id)
16 {
17  switch (id) {
18  case FCAL_C : return "FCAL_C";
19  case HEC_C : return "HEC_C";
20  case EMEC_OUTER_C : return "EMEC_OUTER_C";
21  case EMEC_INNER_C : return "EMEC_INNER_C";
22  case EMEC_C : return "EMEC_C";
23  case EMB_C : return "EMB_C";
24  case UNKNOWN_CALO : return "UNKNOWN_CALO";
25  case EMB_A : return "EMB_A";
26  case EMEC_INNER_A : return "EMEC_INNER_A";
27  case EMEC_OUTER_A : return "EMEC_OUTER_A";
28  case EMEC_A : return "EMEC_A";
29  case HEC_A : return "HEC_A";
30  case FCAL_A : return "FCAL_A";
31 
32  case EMB : return "EMB";
33  case EMEC : return "EMEC";
34  case EMEC_OUTER : return "EMEC_OUTER";
35  case EMEC_INNER : return "EMEC_INNER";
36  case HEC : return "HEC";
37  case FCAL : return "FCAL";
38  case EM : return "EM";
39  case PRECISION_EM : return "PRECISION_EM";
40  }
41 
42  return "UNKNOWN_CALO";
43 }
44 
45 CaloId Id::caloId(const TString& str)
46 {
47  if (str == "FCAL_C") return FCAL_C;
48  if (str == "HEC_C") return HEC_C;
49  if (str == "EMEC_OUTER_C") return EMEC_OUTER_C;
50  if (str == "EMEC_INNER_C") return EMEC_INNER_C;
51  if (str == "EMEC_C") return EMEC_C;
52  if (str == "EMB_C") return EMB_C;
53  if (str == "UNKNOWN_CALO") return UNKNOWN_CALO;
54  if (str == "EMB_A") return EMB_A;
55  if (str == "EMEC_INNER_A") return EMEC_INNER_A;
56  if (str == "EMEC_OUTER_A") return EMEC_OUTER_A;
57  if (str == "EMEC_A") return EMEC_A;
58  if (str == "HEC_A") return HEC_A;
59  if (str == "FCAL_A") return FCAL_A;
60 
61  if (str == "EMB") return EMB;
62  if (str == "EMEC") return EMEC;
63  if (str == "EMEC_OUTER") return EMEC_OUTER;
64  if (str == "EMEC_INNER") return EMEC_INNER;
65  if (str == "HEC") return HEC;
66  if (str == "FCAL") return FCAL;
67  if (str == "EM") return EM;
68  if (str == "PRECISION_EM") return PRECISION_EM;
69 
70  return UNKNOWN_CALO;
71 }
72 
73 
75 {
76  switch (id) {
77  case FCAL_C : return FCAL;
78  case HEC_C : return HEC;
79  case EMEC_OUTER_C : return EMEC;
80  case EMEC_INNER_C : return EMEC;
81  case EMEC_C : return EMEC;
82  case EMB_C : return EMB;
83  case UNKNOWN_CALO : return UNKNOWN_CALO;
84  case EMB_A : return EMB;
85  case EMEC_OUTER_A : return EMEC;
86  case EMEC_INNER_A : return EMEC;
87  case EMEC_A : return EMEC;
88  case HEC_A : return HEC;
89  case FCAL_A : return FCAL;
90 
91  case EMB : return EMB;
92  case EMEC : return EMEC;
93  case EMEC_OUTER : return EMEC;
94  case EMEC_INNER : return EMEC;
95  case HEC : return HEC;
96  case FCAL : return FCAL;
97  case EM : return EM;
98  case PRECISION_EM : return PRECISION_EM;
99  }
100 
101  return UNKNOWN_CALO;
102 }
103 
104 
105 TString Id::str(PartitionId id)
106 {
107  switch (id) {
108  case EMB_C_PARTITION : return "EMB_C_PARTITION";
109  case EMB_A_PARTITION : return "EMB_A_PARTITION";
110  case EMEC_C_PARTITION : return "EMEC_C_PARTITION";
111  case EMEC_A_PARTITION : return "EMEC_A_PARTITION";
112  case UNKNOWN_PARTITION: return "UNKNOWN_PARTITION";
113  case HEC_C_PARTITION : return "HEC_C_PARTITION";
114  case HEC_A_PARTITION : return "HEC_A_PARTITION";
115  case FCAL_C_PARTITION : return "FCAL_C_PARTITION";
116  case FCAL_A_PARTITION : return "FCAL_A_PARTITION";
117  }
118 
119  return "UNKNOWN_PARTITION";
120 }
121 
122 
124 {
125  if (str == "FCAL_C_PARTITION") return FCAL_C_PARTITION;
126  if (str == "HEC_C_PARTITION") return HEC_C_PARTITION;
127  if (str == "EMEC_C_PARTITION") return EMEC_C_PARTITION;
128  if (str == "EMB_C_PARTITION") return EMB_C_PARTITION;
129  if (str == "UNKNOWN_PARTITION") return UNKNOWN_PARTITION;
130  if (str == "EMB_A_PARTITION") return EMB_A_PARTITION;
131  if (str == "EMEC_A_PARTITION") return EMEC_A_PARTITION;
132  if (str == "HEC_A_PARTITION") return HEC_A_PARTITION;
133  if (str == "FCAL_A_PARTITION") return FCAL_A_PARTITION;
134 
135  return UNKNOWN_PARTITION;
136 }
137 
138 
140 {
141  switch (id) {
142  case FCAL_C_PARTITION : return FCAL;
143  case HEC_C_PARTITION : return HEC;
144  case EMEC_C_PARTITION : return EMEC;
145  case EMB_C_PARTITION : return EMB;
146  case UNKNOWN_PARTITION : return UNKNOWN_CALO;
147  case EMB_A_PARTITION : return EMB;
148  case EMEC_A_PARTITION : return EMEC;
149  case HEC_A_PARTITION : return HEC;
150  case FCAL_A_PARTITION : return FCAL;
151  }
152 
153  return UNKNOWN_CALO;
154 }
155 
156 
158 {
159  switch (id) {
160  case FCAL_C : return FCAL_C_PARTITION;
161  case HEC_C : return HEC_C_PARTITION;
162  case EMEC_OUTER_C : return EMEC_C_PARTITION;
163  case EMEC_INNER_C : return EMEC_C_PARTITION;
164  case EMEC_C : return EMEC_C_PARTITION;
165  case EMB_C : return EMB_C_PARTITION;
166  case UNKNOWN_CALO : return UNKNOWN_PARTITION;
167  case EMB_A : return EMB_A_PARTITION;
168  case EMEC_INNER_A : return EMEC_A_PARTITION;
169  case EMEC_OUTER_A : return EMEC_A_PARTITION;
170  case EMEC_A : return EMEC_A_PARTITION;
171  case HEC_A : return HEC_A_PARTITION;
172  case FCAL_A : return FCAL_A_PARTITION;
173 
174  case EMB : return UNKNOWN_PARTITION;
175  case EMEC : return UNKNOWN_PARTITION;
176  case EMEC_OUTER : return UNKNOWN_PARTITION;
177  case EMEC_INNER : return UNKNOWN_PARTITION;
178  case HEC : return UNKNOWN_PARTITION;
179  case FCAL : return UNKNOWN_PARTITION;
180  case EM : return UNKNOWN_PARTITION;
181  case PRECISION_EM : return UNKNOWN_PARTITION;
182  }
183 
184  return UNKNOWN_PARTITION;
185 }
186 
187 
188 bool Id::matchCalo(CaloId id, CaloId idSpec)
189 {
190  if (id == idSpec) return true;
191  if (idSpec == EMB && (id == EMB_A || id == EMB_C)) return true;
192  if (idSpec == EMEC && (matchCalo(id, EMEC_A) || matchCalo(id, EMEC_C))) return true;
193  if (idSpec == EMEC_A && (id == EMEC_INNER_A || id == EMEC_OUTER_A)) return true;
194  if (idSpec == EMEC_C && (id == EMEC_INNER_C || id == EMEC_OUTER_C)) return true;
195  if (idSpec == EMEC_OUTER && (id == EMEC_OUTER_A || id == EMEC_OUTER_C)) return true;
196  if (idSpec == EMEC_INNER && (id == EMEC_INNER_A || id == EMEC_INNER_C)) return true;
197  if (idSpec == HEC && (id == HEC_A || id == HEC_C)) return true;
198  if (idSpec == FCAL && (id == FCAL_A || id == FCAL_C)) return true;
199  if (idSpec == EM && (matchCalo(id, EMB) || matchCalo(id, EMEC))) return true;
200  if (idSpec == PRECISION_EM && (matchCalo(id, EMB) || matchCalo(id, EMEC_OUTER))) return true;
201 
202  return false;
203 }
204 
205 
206 short Id::sign(CaloId id)
207 {
208  switch (id) {
209  case FCAL_C : return -1;
210  case HEC_C : return -1;
211  case EMEC_OUTER_C : return -1;
212  case EMEC_INNER_C : return -1;
213  case EMEC_C : return -1;
214  case EMB_C : return -1;
215  case UNKNOWN_CALO : return 0;
216  case EMB_A : return +1;
217  case EMEC_INNER_A : return +1;
218  case EMEC_OUTER_A : return +1;
219  case EMEC_A : return +1;
220  case HEC_A : return +1;
221  case FCAL_A : return +1;
222 
223  case EMB : return 0;
224  case EMEC : return 0;
225  case EMEC_OUTER : return 0;
226  case EMEC_INNER : return 0;
227  case HEC : return 0;
228  case FCAL : return 0;
229  case EM : return 0;
230  case PRECISION_EM : return 0;
231  }
232 
233  return 0;
234 }
235 
237 {
238  switch (id) {
239  case FCAL_C : return FCAL_A;
240  case HEC_C : return HEC_A;
241  case EMEC_OUTER_C : return EMEC_OUTER_A;
242  case EMEC_INNER_C : return EMEC_INNER_A;
243  case EMEC_C : return EMEC_A;
244  case EMB_C : return EMB_A;
245  case UNKNOWN_CALO : return UNKNOWN_CALO;
246  case EMB_A : return EMB_C;
247  case EMEC_INNER_A : return EMEC_INNER_C;
248  case EMEC_OUTER_A : return EMEC_OUTER_C;
249  case EMEC_A : return EMEC_C;
250  case HEC_A : return HEC_C;
251  case FCAL_A : return FCAL_C;
252 
253  case EMB : return EMB;
254  case EMEC : return EMEC;
255  case EMEC_OUTER : return EMEC_OUTER;
256  case EMEC_INNER : return EMEC_INNER;
257  case HEC : return HEC;
258  case FCAL : return FCAL;
259  case EM : return EM;
260  case PRECISION_EM : return PRECISION_EM;
261  }
262 
263  return UNKNOWN_CALO;
264 }
265 
CaloId.h
LArSamples::HEC_C_PARTITION
@ HEC_C_PARTITION
Definition: CaloId.h:31
LArSamples::HEC
@ HEC
Definition: CaloId.h:26
LArSamples::Id::matchCalo
static bool matchCalo(CaloId id, CaloId idSpec)
Definition: CaloId.cxx:188
LArSamples::Id::partition
static PartitionId partition(CaloId id)
Definition: CaloId.cxx:157
LArSamples::UNKNOWN_PARTITION
@ UNKNOWN_PARTITION
Definition: CaloId.h:31
LArSamples::Id::summary
static CaloId summary(CaloId id)
Definition: CaloId.cxx:74
LArSamples::Id::str
static TString str(CaloId id)
Definition: CaloId.cxx:15
LArSamples::FCAL_C
@ FCAL_C
Definition: CaloId.h:22
LArSamples::EMEC_A_PARTITION
@ EMEC_A_PARTITION
Definition: CaloId.h:30
LArSamples::EMEC_INNER
@ EMEC_INNER
Definition: CaloId.h:25
LArSamples
Definition: AbsShape.h:24
LArSamples::Id::partitionId
static PartitionId partitionId(const TString &str)
Definition: CaloId.cxx:123
LArSamples::HEC_A
@ HEC_A
Definition: CaloId.h:24
LArSamples::EMB_A_PARTITION
@ EMB_A_PARTITION
Definition: CaloId.h:30
LArSamples::FCAL_A
@ FCAL_A
Definition: CaloId.h:24
LArSamples::Id::caloId
static CaloId caloId(const TString &str)
Definition: CaloId.cxx:45
LArSamples::PRECISION_EM
@ PRECISION_EM
Definition: CaloId.h:26
LArSamples::EMEC_OUTER_C
@ EMEC_OUTER_C
Definition: CaloId.h:22
LArSamples::EMEC
@ EMEC
Definition: CaloId.h:25
LArSamples::FCAL_A_PARTITION
@ FCAL_A_PARTITION
Definition: CaloId.h:31
LArSamples::EMB
@ EMB
Definition: CaloId.h:25
LArSamples::EMB_C
@ EMB_C
Definition: CaloId.h:22
LArSamples::FCAL_C_PARTITION
@ FCAL_C_PARTITION
Definition: CaloId.h:31
LArSamples::EMEC_OUTER
@ EMEC_OUTER
Definition: CaloId.h:25
LArSamples::EMEC_C_PARTITION
@ EMEC_C_PARTITION
Definition: CaloId.h:30
LArSamples::EM
@ EM
Definition: CaloId.h:26
LArSamples::PartitionId
PartitionId
Definition: CaloId.h:29
LArSamples::EMB_C_PARTITION
@ EMB_C_PARTITION
Definition: CaloId.h:30
LArSamples::UNKNOWN_CALO
@ UNKNOWN_CALO
Definition: CaloId.h:23
LArSamples::EMEC_OUTER_A
@ EMEC_OUTER_A
Definition: CaloId.h:24
LArSamples::HEC_A_PARTITION
@ HEC_A_PARTITION
Definition: CaloId.h:31
LArSamples::CaloId
CaloId
Definition: CaloId.h:21
LArSamples::FCAL
@ FCAL
Definition: CaloId.h:26
LArSamples::EMEC_A
@ EMEC_A
Definition: CaloId.h:25
LArSamples::EMEC_INNER_C
@ EMEC_INNER_C
Definition: CaloId.h:22
LArSamples::HEC_C
@ HEC_C
Definition: CaloId.h:22
LArSamples::EMB_A
@ EMB_A
Definition: CaloId.h:24
str
Definition: BTagTrackIpAccessor.cxx:11
LArSamples::EMEC_INNER_A
@ EMEC_INNER_A
Definition: CaloId.h:24
LArSamples::Id::mirror
static CaloId mirror(CaloId id)
Definition: CaloId.cxx:236
LArSamples::EMEC_C
@ EMEC_C
Definition: CaloId.h:25
LArSamples::Id::sign
static short sign(CaloId id)
Definition: CaloId.cxx:206