]>
Commit | Line | Data |
---|---|---|
da0e9ce3 | 1 | //-------------------------------------------------------------------------- |
2 | // | |
3 | // Environment: | |
4 | // This software is part of the EvtGen package developed jointly | |
5 | // for the BaBar and CLEO collaborations. If you use all or part | |
6 | // of it, please give an appropriate acknowledgement. | |
7 | // | |
8 | // Copyright Information: See EvtGen/COPYRIGHT | |
9 | // Copyright (C) 1998 Caltech, UCSB | |
10 | // | |
11 | // Module: EvtId.cc | |
12 | // | |
13 | // Description: Class for particle Id used in EvtGen. | |
14 | // | |
15 | // Modification history: | |
16 | // | |
17 | // DJL Jan 4, 2000 Module created | |
18 | // | |
19 | //------------------------------------------------------------------------ | |
20 | // | |
21 | #include "EvtGenBase/EvtPatches.hh" | |
22 | ||
23 | #include "EvtGenBase/EvtIdSet.hh" | |
24 | #include "EvtGenBase/EvtPDL.hh" | |
25 | #include <iostream> | |
26 | #include <string> | |
27 | ||
28 | EvtIdSet::EvtIdSet(const EvtId name1) { | |
29 | _numInList=1; | |
30 | _list=new EvtId[_numInList]; | |
31 | ||
32 | _list[0]=name1; | |
33 | } | |
34 | ||
35 | EvtIdSet::EvtIdSet(const std::string name1){ | |
36 | _numInList=1; | |
37 | _list=new EvtId[_numInList]; | |
38 | ||
39 | _list[0]=EvtPDL::getId(name1); | |
40 | } | |
41 | ||
42 | ||
43 | EvtIdSet::EvtIdSet(const EvtId name1, | |
44 | const EvtId name2){ | |
45 | _numInList=2; | |
46 | _list=new EvtId[_numInList]; | |
47 | ||
48 | _list[0]=name1; | |
49 | _list[1]=name2; | |
50 | } | |
51 | ||
52 | ||
53 | EvtIdSet::EvtIdSet(const std::string name1, | |
54 | const std::string name2){ | |
55 | _numInList=2; | |
56 | _list=new EvtId[_numInList]; | |
57 | ||
58 | _list[0]=EvtPDL::getId(name1); | |
59 | _list[1]=EvtPDL::getId(name2); | |
60 | } | |
61 | ||
62 | ||
63 | EvtIdSet::EvtIdSet(const EvtId name1, | |
64 | const EvtId name2, | |
65 | const EvtId name3){ | |
66 | _numInList=3; | |
67 | _list=new EvtId[_numInList]; | |
68 | ||
69 | _list[0]=name1; | |
70 | _list[1]=name2; | |
71 | _list[2]=name3; | |
72 | ||
73 | } | |
74 | ||
75 | ||
76 | EvtIdSet::EvtIdSet(const std::string name1, | |
77 | const std::string name2, | |
78 | const std::string name3){ | |
79 | _numInList=3; | |
80 | _list=new EvtId[_numInList]; | |
81 | ||
82 | _list[0]=EvtPDL::getId(name1); | |
83 | _list[1]=EvtPDL::getId(name2); | |
84 | _list[2]=EvtPDL::getId(name3); | |
85 | } | |
86 | ||
87 | ||
88 | EvtIdSet::EvtIdSet(const EvtId name1, | |
89 | const EvtId name2, | |
90 | const EvtId name3, | |
91 | const EvtId name4){ | |
92 | _numInList=4; | |
93 | _list=new EvtId[_numInList]; | |
94 | ||
95 | _list[0]=name1; | |
96 | _list[1]=name2; | |
97 | _list[2]=name3; | |
98 | _list[3]=name4; | |
99 | } | |
100 | ||
101 | ||
102 | EvtIdSet::EvtIdSet(const std::string name1, | |
103 | const std::string name2, | |
104 | const std::string name3, | |
105 | const std::string name4){ | |
106 | _numInList=4; | |
107 | _list=new EvtId[_numInList]; | |
108 | ||
109 | _list[0]=EvtPDL::getId(name1); | |
110 | _list[1]=EvtPDL::getId(name2); | |
111 | _list[2]=EvtPDL::getId(name3); | |
112 | _list[3]=EvtPDL::getId(name4); | |
113 | } | |
114 | ||
115 | ||
116 | EvtIdSet::EvtIdSet(const EvtId name1, | |
117 | const EvtId name2, | |
118 | const EvtId name3, | |
119 | const EvtId name4, | |
120 | const EvtId name5){ | |
121 | _numInList=5; | |
122 | _list=new EvtId[_numInList]; | |
123 | ||
124 | _list[0]=name1; | |
125 | _list[1]=name2; | |
126 | _list[2]=name3; | |
127 | _list[3]=name4; | |
128 | _list[4]=name5; | |
129 | } | |
130 | ||
131 | ||
132 | EvtIdSet::EvtIdSet(const std::string name1, | |
133 | const std::string name2, | |
134 | const std::string name3, | |
135 | const std::string name4, | |
136 | const std::string name5){ | |
137 | _numInList=5; | |
138 | _list=new EvtId[_numInList]; | |
139 | ||
140 | _list[0]=EvtPDL::getId(name1); | |
141 | _list[1]=EvtPDL::getId(name2); | |
142 | _list[2]=EvtPDL::getId(name3); | |
143 | _list[3]=EvtPDL::getId(name4); | |
144 | _list[4]=EvtPDL::getId(name5); | |
145 | } | |
146 | ||
147 | ||
148 | EvtIdSet::EvtIdSet(const EvtId name1, | |
149 | const EvtId name2, | |
150 | const EvtId name3, | |
151 | const EvtId name4, | |
152 | const EvtId name5, | |
153 | const EvtId name6){ | |
154 | _numInList=6; | |
155 | _list=new EvtId[_numInList]; | |
156 | ||
157 | _list[0]=name1; | |
158 | _list[1]=name2; | |
159 | _list[2]=name3; | |
160 | _list[3]=name4; | |
161 | _list[4]=name5; | |
162 | _list[5]=name6; | |
163 | } | |
164 | ||
165 | ||
166 | EvtIdSet::EvtIdSet(const std::string name1, | |
167 | const std::string name2, | |
168 | const std::string name3, | |
169 | const std::string name4, | |
170 | const std::string name5, | |
171 | const std::string name6){ | |
172 | _numInList=6; | |
173 | _list=new EvtId[_numInList]; | |
174 | ||
175 | _list[0]=EvtPDL::getId(name1); | |
176 | _list[1]=EvtPDL::getId(name2); | |
177 | _list[2]=EvtPDL::getId(name3); | |
178 | _list[3]=EvtPDL::getId(name4); | |
179 | _list[4]=EvtPDL::getId(name5); | |
180 | _list[5]=EvtPDL::getId(name6); | |
181 | } | |
182 | ||
183 | ||
184 | EvtIdSet::EvtIdSet(const EvtId name1, | |
185 | const EvtId name2, | |
186 | const EvtId name3, | |
187 | const EvtId name4, | |
188 | const EvtId name5, | |
189 | const EvtId name6, | |
190 | const EvtId name7){ | |
191 | _numInList=7; | |
192 | _list=new EvtId[_numInList]; | |
193 | ||
194 | _list[0]=name1; | |
195 | _list[1]=name2; | |
196 | _list[2]=name3; | |
197 | _list[3]=name4; | |
198 | _list[4]=name5; | |
199 | _list[5]=name6; | |
200 | _list[6]=name7; | |
201 | } | |
202 | ||
203 | ||
204 | EvtIdSet::EvtIdSet(const std::string name1, | |
205 | const std::string name2, | |
206 | const std::string name3, | |
207 | const std::string name4, | |
208 | const std::string name5, | |
209 | const std::string name6, | |
210 | const std::string name7){ | |
211 | _numInList=7; | |
212 | _list=new EvtId[_numInList]; | |
213 | ||
214 | _list[0]=EvtPDL::getId(name1); | |
215 | _list[1]=EvtPDL::getId(name2); | |
216 | _list[2]=EvtPDL::getId(name3); | |
217 | _list[3]=EvtPDL::getId(name4); | |
218 | _list[4]=EvtPDL::getId(name5); | |
219 | _list[5]=EvtPDL::getId(name6); | |
220 | _list[6]=EvtPDL::getId(name7); | |
221 | } | |
222 | ||
223 | ||
224 | EvtIdSet::EvtIdSet(const EvtId name1, | |
225 | const EvtId name2, | |
226 | const EvtId name3, | |
227 | const EvtId name4, | |
228 | const EvtId name5, | |
229 | const EvtId name6, | |
230 | const EvtId name7, | |
231 | const EvtId name8){ | |
232 | _numInList=8; | |
233 | _list=new EvtId[_numInList]; | |
234 | ||
235 | _list[0]=name1; | |
236 | _list[1]=name2; | |
237 | _list[2]=name3; | |
238 | _list[3]=name4; | |
239 | _list[4]=name5; | |
240 | _list[5]=name6; | |
241 | _list[6]=name7; | |
242 | _list[7]=name8; | |
243 | } | |
244 | ||
245 | ||
246 | EvtIdSet::EvtIdSet(const std::string name1, | |
247 | const std::string name2, | |
248 | const std::string name3, | |
249 | const std::string name4, | |
250 | const std::string name5, | |
251 | const std::string name6, | |
252 | const std::string name7, | |
253 | const std::string name8){ | |
254 | _numInList=8; | |
255 | _list=new EvtId[_numInList]; | |
256 | ||
257 | _list[0]=EvtPDL::getId(name1); | |
258 | _list[1]=EvtPDL::getId(name2); | |
259 | _list[2]=EvtPDL::getId(name3); | |
260 | _list[3]=EvtPDL::getId(name4); | |
261 | _list[4]=EvtPDL::getId(name5); | |
262 | _list[5]=EvtPDL::getId(name6); | |
263 | _list[6]=EvtPDL::getId(name7); | |
264 | _list[7]=EvtPDL::getId(name8); | |
265 | } | |
266 | ||
267 | ||
268 | EvtIdSet::EvtIdSet(const EvtId name1, | |
269 | const EvtId name2, | |
270 | const EvtId name3, | |
271 | const EvtId name4, | |
272 | const EvtId name5, | |
273 | const EvtId name6, | |
274 | const EvtId name7, | |
275 | const EvtId name8, | |
276 | const EvtId name9){ | |
277 | _numInList=9; | |
278 | _list=new EvtId[_numInList]; | |
279 | ||
280 | _list[0]=name1; | |
281 | _list[1]=name2; | |
282 | _list[2]=name3; | |
283 | _list[3]=name4; | |
284 | _list[4]=name5; | |
285 | _list[5]=name6; | |
286 | _list[6]=name7; | |
287 | _list[7]=name8; | |
288 | _list[8]=name9; | |
289 | } | |
290 | ||
291 | ||
292 | EvtIdSet::EvtIdSet(const std::string name1, | |
293 | const std::string name2, | |
294 | const std::string name3, | |
295 | const std::string name4, | |
296 | const std::string name5, | |
297 | const std::string name6, | |
298 | const std::string name7, | |
299 | const std::string name8, | |
300 | const std::string name9){ | |
301 | _numInList=9; | |
302 | _list=new EvtId[_numInList]; | |
303 | ||
304 | _list[0]=EvtPDL::getId(name1); | |
305 | _list[1]=EvtPDL::getId(name2); | |
306 | _list[2]=EvtPDL::getId(name3); | |
307 | _list[3]=EvtPDL::getId(name4); | |
308 | _list[4]=EvtPDL::getId(name5); | |
309 | _list[5]=EvtPDL::getId(name6); | |
310 | _list[6]=EvtPDL::getId(name7); | |
311 | _list[7]=EvtPDL::getId(name8); | |
312 | _list[8]=EvtPDL::getId(name9); | |
313 | } | |
314 | ||
315 | ||
316 | EvtIdSet::EvtIdSet(const EvtId name1, | |
317 | const EvtId name2, | |
318 | const EvtId name3, | |
319 | const EvtId name4, | |
320 | const EvtId name5, | |
321 | const EvtId name6, | |
322 | const EvtId name7, | |
323 | const EvtId name8, | |
324 | const EvtId name9, | |
325 | const EvtId name10){ | |
326 | _numInList=10; | |
327 | _list=new EvtId[_numInList]; | |
328 | ||
329 | _list[0]=name1; | |
330 | _list[1]=name2; | |
331 | _list[2]=name3; | |
332 | _list[3]=name4; | |
333 | _list[4]=name5; | |
334 | _list[5]=name6; | |
335 | _list[6]=name7; | |
336 | _list[7]=name8; | |
337 | _list[8]=name9; | |
338 | _list[9]=name10; | |
339 | } | |
340 | ||
341 | ||
342 | EvtIdSet::EvtIdSet(const std::string name1, | |
343 | const std::string name2, | |
344 | const std::string name3, | |
345 | const std::string name4, | |
346 | const std::string name5, | |
347 | const std::string name6, | |
348 | const std::string name7, | |
349 | const std::string name8, | |
350 | const std::string name9, | |
351 | const std::string name10){ | |
352 | _numInList=10; | |
353 | _list=new EvtId[_numInList]; | |
354 | ||
355 | _list[0]=EvtPDL::getId(name1); | |
356 | _list[1]=EvtPDL::getId(name2); | |
357 | _list[2]=EvtPDL::getId(name3); | |
358 | _list[3]=EvtPDL::getId(name4); | |
359 | _list[4]=EvtPDL::getId(name5); | |
360 | _list[5]=EvtPDL::getId(name6); | |
361 | _list[6]=EvtPDL::getId(name7); | |
362 | _list[7]=EvtPDL::getId(name8); | |
363 | _list[8]=EvtPDL::getId(name9); | |
364 | _list[9]=EvtPDL::getId(name10); | |
365 | } | |
366 | ||
367 | ||
368 | EvtIdSet::EvtIdSet(const EvtId name1, | |
369 | const EvtId name2, | |
370 | const EvtId name3, | |
371 | const EvtId name4, | |
372 | const EvtId name5, | |
373 | const EvtId name6, | |
374 | const EvtId name7, | |
375 | const EvtId name8, | |
376 | const EvtId name9, | |
377 | const EvtId name10, | |
378 | const EvtId name11){ | |
379 | _numInList=11; | |
380 | _list=new EvtId[_numInList]; | |
381 | ||
382 | _list[0]=name1; | |
383 | _list[1]=name2; | |
384 | _list[2]=name3; | |
385 | _list[3]=name4; | |
386 | _list[4]=name5; | |
387 | _list[5]=name6; | |
388 | _list[6]=name7; | |
389 | _list[7]=name8; | |
390 | _list[8]=name9; | |
391 | _list[9]=name10; | |
392 | _list[10]=name11; | |
393 | } | |
394 | ||
395 | ||
396 | EvtIdSet::EvtIdSet(const std::string name1, | |
397 | const std::string name2, | |
398 | const std::string name3, | |
399 | const std::string name4, | |
400 | const std::string name5, | |
401 | const std::string name6, | |
402 | const std::string name7, | |
403 | const std::string name8, | |
404 | const std::string name9, | |
405 | const std::string name10, | |
406 | const std::string name11){ | |
407 | _numInList=11; | |
408 | _list=new EvtId[_numInList]; | |
409 | ||
410 | _list[0]=EvtPDL::getId(name1); | |
411 | _list[1]=EvtPDL::getId(name2); | |
412 | _list[2]=EvtPDL::getId(name3); | |
413 | _list[3]=EvtPDL::getId(name4); | |
414 | _list[4]=EvtPDL::getId(name5); | |
415 | _list[5]=EvtPDL::getId(name6); | |
416 | _list[6]=EvtPDL::getId(name7); | |
417 | _list[7]=EvtPDL::getId(name8); | |
418 | _list[8]=EvtPDL::getId(name9); | |
419 | _list[9]=EvtPDL::getId(name10); | |
420 | _list[10]=EvtPDL::getId(name11); | |
421 | } | |
422 | ||
423 | ||
424 | EvtIdSet::EvtIdSet(const EvtId name1, | |
425 | const EvtId name2, | |
426 | const EvtId name3, | |
427 | const EvtId name4, | |
428 | const EvtId name5, | |
429 | const EvtId name6, | |
430 | const EvtId name7, | |
431 | const EvtId name8, | |
432 | const EvtId name9, | |
433 | const EvtId name10, | |
434 | const EvtId name11, | |
435 | const EvtId name12){ | |
436 | _numInList=12; | |
437 | _list=new EvtId[_numInList]; | |
438 | ||
439 | _list[0]=name1; | |
440 | _list[1]=name2; | |
441 | _list[2]=name3; | |
442 | _list[3]=name4; | |
443 | _list[4]=name5; | |
444 | _list[5]=name6; | |
445 | _list[6]=name7; | |
446 | _list[7]=name8; | |
447 | _list[8]=name9; | |
448 | _list[9]=name10; | |
449 | _list[10]=name11; | |
450 | _list[11]=name12; | |
451 | } | |
452 | ||
453 | ||
454 | EvtIdSet::EvtIdSet(const std::string name1, | |
455 | const std::string name2, | |
456 | const std::string name3, | |
457 | const std::string name4, | |
458 | const std::string name5, | |
459 | const std::string name6, | |
460 | const std::string name7, | |
461 | const std::string name8, | |
462 | const std::string name9, | |
463 | const std::string name10, | |
464 | const std::string name11, | |
465 | const std::string name12){ | |
466 | _numInList=12; | |
467 | _list=new EvtId[_numInList]; | |
468 | ||
469 | _list[0]=EvtPDL::getId(name1); | |
470 | _list[1]=EvtPDL::getId(name2); | |
471 | _list[2]=EvtPDL::getId(name3); | |
472 | _list[3]=EvtPDL::getId(name4); | |
473 | _list[4]=EvtPDL::getId(name5); | |
474 | _list[5]=EvtPDL::getId(name6); | |
475 | _list[6]=EvtPDL::getId(name7); | |
476 | _list[7]=EvtPDL::getId(name8); | |
477 | _list[8]=EvtPDL::getId(name9); | |
478 | _list[9]=EvtPDL::getId(name10); | |
479 | _list[10]=EvtPDL::getId(name11); | |
480 | _list[11]=EvtPDL::getId(name12); | |
481 | } | |
482 | ||
483 | ||
484 | EvtIdSet::EvtIdSet(const EvtIdSet& set1){ | |
485 | ||
486 | _numInList=set1.sizeOfSet(); | |
487 | _list=new EvtId[_numInList]; | |
488 | int i; | |
489 | for (i=0;i<_numInList;i++){ | |
490 | _list[i]=set1.getElem(i); | |
491 | } | |
492 | ||
493 | } | |
494 | EvtIdSet::EvtIdSet(const EvtIdSet& set1, const EvtIdSet& set2){ | |
495 | ||
496 | _numInList=set1.sizeOfSet(); | |
497 | _list=new EvtId[_numInList]; | |
498 | int i; | |
499 | for (i=0;i<_numInList;i++){ | |
500 | _list[i]=set1.getElem(i); | |
501 | } | |
502 | //then just append the second list. | |
503 | this->append(set2); | |
504 | ||
505 | } | |
506 | ||
507 | int EvtIdSet::contains(const EvtId id){ | |
508 | ||
509 | int i; | |
510 | for (i=0;i<_numInList;i++){ | |
511 | if ( _list[i] == id ) return 1; | |
512 | } | |
513 | ||
514 | return 0; | |
515 | } | |
516 | ||
517 | int EvtIdSet::contains(const std::string nm){ | |
518 | ||
519 | int i; | |
520 | for (i=0;i<_numInList;i++){ | |
521 | if ( _list[i] == EvtPDL::getId(nm) ) return 1; | |
522 | } | |
523 | ||
524 | return 0; | |
525 | } | |
526 | ||
527 | ||
528 | void EvtIdSet::append(const EvtIdSet set1){ | |
529 | ||
530 | int combLen=_numInList+set1.sizeOfSet(); | |
531 | int uniqueLen=0; | |
532 | EvtId *combSet; | |
533 | ||
534 | combSet=new EvtId[combLen]; | |
535 | ||
536 | int i; | |
537 | for (i=0;i<combLen;i++){ | |
538 | if ( i>=_numInList ) { | |
539 | ||
540 | //check that there are no overlaps between lists | |
541 | int j; | |
542 | int isUnique=1; | |
543 | for (j=0;j<_numInList;j++){ | |
544 | if ( _list[j]==set1.getElem(i-_numInList) ) { | |
545 | isUnique=0; | |
546 | } | |
547 | } | |
548 | if ( isUnique==1 ) { | |
549 | combSet[uniqueLen]=set1.getElem(i-_numInList); | |
550 | uniqueLen+=1; | |
551 | } | |
552 | } | |
553 | else{ | |
554 | combSet[uniqueLen]=_list[i]; | |
555 | uniqueLen+=1; | |
556 | } | |
557 | ||
558 | delete _list; | |
559 | _list=new EvtId[uniqueLen]; | |
560 | ||
561 | _numInList=uniqueLen; | |
562 | for (i=0;i<_numInList;i++){ | |
563 | _list[i]=combSet[i]; | |
564 | } | |
565 | ||
566 | delete combSet; | |
567 | ||
568 | } | |
569 | } | |
570 | ||
571 | int EvtIdSet::sizeOfSet() const { return _numInList;} | |
572 | ||
573 | EvtId EvtIdSet::getElem(const int i) const { return _list[i];} | |
574 | ||
575 | ||
576 | ||
577 | ||
578 | ||
579 | ||
580 | ||
581 |