BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtCyclic3.cc
Go to the documentation of this file.
2/*******************************************************************************
3 * Project: BaBar detector at the SLAC PEP-II B-factory
4 * Package: EvtGenBase
5 * File: $Id: EvtCyclic3.cc,v 1.1.1.2 2007/10/26 05:03:14 pingrg Exp $
6 * Author: Alexei Dvoretskii, [email protected], 2001-2002
7 *
8 * Copyright (C) 2002 Caltech
9 *******************************************************************************/
10
11#include <assert.h>
12#include <string.h>
13#include <iostream>
15using std::ostream;
16
17using namespace EvtCyclic3;
18
19
21{
22 if(p == ABC) return i;
23 else if(p == BCA) {
24 if(i == A) return C;
25 else if(i == B) return A;
26 else if(i == C) return B;
27 }
28 else if(p == BCA) {
29 if(i == A) return C;
30 else if(i == B) return A;
31 else if(i == C) return B;
32 }
33 else if(p == CAB) {
34 if(i == A) return B;
35 else if(i == B) return C;
36 else if(i == C) return A;
37 }
38 else if(p == CBA) {
39 if(i == A) return C;
40 else if(i == B) return B;
41 else if(i == C) return A;
42 }
43 else if(p == BAC) {
44 if(i == A) return B;
45 else if(i == B) return A;
46 else if(i == C) return C;
47 }
48 else if(p == ACB) {
49 if(i == A) return A;
50 else if(i == B) return C;
51 else if(i == C) return B;
52 }
53 return A;
54}
55
57{
58 assert(i1 != i2 && i2 != i3 && i3 != i1);
59 if(i1 == A) return (i2 == B) ? ABC : ACB;
60 if(i1 == B) return (i2 == C) ? BCA : BAC;
61 if(i1 == C) return (i2 == A) ? CAB : CBA;
62 return ABC;
63}
64
65
67{
68 Index i1 = permute(permute(A,i),p);
69 Index i2 = permute(permute(B,i),p);
70 Index i3 = permute(permute(C,i),p);
71
72 return permutation(i1,i2,i3);
73}
74
76{
77 Index i1 = permute(first(i),p);
78 Index i2 = permute(second(i),p);
79 return combine(i1,i2);
80}
81
82
84{
85 assert(0<=i && i<=2);
86 switch(i) {
87 case 0: return BC;
88 case 1: return CA;
89 case 2: return AB;
90 }
91 assert(0); return AB; // should never get here
92}
93
94
95
97{
98 switch(i) {
99 case A: return C;
100 case B: return A;
101 case C: return B;
102 }
103 assert(0); return A; // should never get here
104}
105
106
108{
109 switch(i) {
110 case A: return B;
111 case B: return C;
112 case C: return A;
113 }
114 assert(0); return A; // should never get here
115}
116
117
119{
120 assert(i != j);
121 switch(i) {
122 case A:
123 switch(j) {
124 case B: return C;
125 case C: return B;
126 default: assert(0);
127 }
128 case B:
129 switch(j) {
130 case C: return A;
131 case A: return C;
132 default: assert(0);
133 }
134 case C:
135 switch(j) {
136 case A: return B;
137 case B: return A;
138 default: assert(0);
139 }
140 }
141 assert(0); return A; // should never get here
142}
143
144
145// Index-to-pair conversions
146
148{
149 switch(i) {
150 case A: return BC;
151 case B: return CA;
152 case C: return AB;
153 }
154 assert(0); return AB; // should never get here
155}
156
157
159{
160 return other(other(i,j));
161}
162
163
164// Pair-to-pair conversions
165
167{
168 Pair ret = CA;
169 if(i == BC) ret = AB;
170 else
171 if(i == CA) ret = BC;
172
173 return ret;
174}
175
177{
178 Pair ret = BC;
179 if(i == BC) ret = CA;
180 else
181 if(i == CA) ret = AB;
182
183 return ret;
184}
185
187{
188 return combine(other(i),other(j));
189}
190
191
192// Pair-to-index conversions
193
194
196{
197 switch(i) {
198 case BC: return B;
199 case CA: return C;
200 case AB: return A;
201 }
202 assert(0); return A; // should never get here
203}
204
205
207{
208 switch(i) {
209 case BC: return C;
210 case CA: return A;
211 case AB: return B;
212 }
213 assert(0); return A; // should never get here
214}
215
216
218{
219 switch(i) {
220 case BC: return A;
221 case CA: return B;
222 case AB: return C;
223 }
224 assert(0); return A; // should never get here
225}
226
227
229{
230 return other(other(i,j));
231}
232
233
235{
236 if(strcmp(str,"A")) return A;
237 else if(strcmp(str,"B")) return B;
238 else if(strcmp(str,"C")) return C;
239 else assert(0);
240}
241
242
244{
245 if(!strcmp(str,"AB") || !strcmp(str,"BA")) return AB;
246 else if(!strcmp(str,"BC") || !strcmp(str,"CB")) return BC;
247 else if(!strcmp(str,"CA") || !strcmp(str,"AC")) return CA;
248 else assert(0);
249}
250
251
253{
254 switch(i) {
255 case A: return "A";
256 case B: return "B";
257 case C: return "C";
258 }
259 assert(0); return 0; // sngh
260}
261
262
264{
265 switch(i) {
266 case BC: return "BC";
267 case CA: return "CA";
268 case AB: return "AB";
269 }
270 assert(0); return 0; // sngh
271}
272
274{
275 if(p == ABC) return "ABC";
276 if(p == BCA) return "BCA";
277 if(p == CAB) return "CAB";
278 if(p == CBA) return "CBA";
279 if(p == BAC) return "BAC";
280 if(p == ACB) return "ACB";
281 return "???";
282}
283
284char* EvtCyclic3::append(const char* str, EvtCyclic3::Index i)
285{
286 // str + null + 1 character
287 char* s = new char[strlen(str)+2];
288 strcpy(s,str);
289 strcat(s,c_str(i));
290
291 return s;
292}
293
294char* EvtCyclic3::append(const char* str, EvtCyclic3::Pair i)
295{
296 // str + null + 2 characters
297 char* s = new char[strlen(str)+3];
298 strcpy(s,str);
299 strcat(s,c_str(i));
300
301 return s;
302}
303
304
305ostream& operator<<(ostream& os, EvtCyclic3::Index i)
306{
307 switch(i) {
308 case A: { os << "A"; return os; }
309 case B: { os << "B"; return os; }
310 case C: { os << "C"; return os; }
311 }
312 assert(0); return os; // should never get here
313}
314
315
316ostream& operator<<(ostream& os, EvtCyclic3::Pair i)
317{
318 switch(i) {
319 case BC: { os << "BC"; return os; }
320 case CA: { os << "CA"; return os; }
321 case AB: { os << "AB"; return os; }
322 }
323 assert(0); return os; // should never get here
324}
325
326
327
328
ostream & operator<<(ostream &os, EvtCyclic3::Index i)
Definition: EvtCyclic3.cc:305
XmlRpcServer s
Definition: HelloServer.cpp:11
Index permute(Index i, Perm p)
Definition: EvtCyclic3.cc:20
Index next(Index i)
Definition: EvtCyclic3.cc:107
Index strToIndex(const char *str)
Definition: EvtCyclic3.cc:234
Perm permutation(Index i1, Index i2, Index i3)
Definition: EvtCyclic3.cc:56
char * append(const char *str, EvtCyclic3::Index i)
Definition: EvtCyclic3.cc:284
Index common(Pair i, Pair j)
Definition: EvtCyclic3.cc:228
Pair strToPair(const char *str)
Definition: EvtCyclic3.cc:243
Pair combine(Index i, Index j)
Definition: EvtCyclic3.cc:158
Index second(Pair i)
Definition: EvtCyclic3.cc:206
Pair i2pair(int i)
Definition: EvtCyclic3.cc:83
Index prev(Index i)
Definition: EvtCyclic3.cc:96
char * c_str(Index i)
Definition: EvtCyclic3.cc:252
Index other(Index i, Index j)
Definition: EvtCyclic3.cc:118
Index first(Pair i)
Definition: EvtCyclic3.cc:195