Line data Source code
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 0 : EvtIdSet::EvtIdSet(const EvtId name1) {
29 0 : _numInList=1;
30 0 : _list=new EvtId[_numInList];
31 :
32 0 : _list[0]=name1;
33 0 : }
34 :
35 0 : EvtIdSet::EvtIdSet(const std::string name1){
36 0 : _numInList=1;
37 0 : _list=new EvtId[_numInList];
38 :
39 0 : _list[0]=EvtPDL::getId(name1);
40 0 : }
41 :
42 :
43 : EvtIdSet::EvtIdSet(const EvtId name1,
44 0 : const EvtId name2){
45 0 : _numInList=2;
46 0 : _list=new EvtId[_numInList];
47 :
48 0 : _list[0]=name1;
49 0 : _list[1]=name2;
50 0 : }
51 :
52 :
53 : EvtIdSet::EvtIdSet(const std::string name1,
54 0 : const std::string name2){
55 0 : _numInList=2;
56 0 : _list=new EvtId[_numInList];
57 :
58 0 : _list[0]=EvtPDL::getId(name1);
59 0 : _list[1]=EvtPDL::getId(name2);
60 0 : }
61 :
62 :
63 : EvtIdSet::EvtIdSet(const EvtId name1,
64 : const EvtId name2,
65 0 : const EvtId name3){
66 0 : _numInList=3;
67 0 : _list=new EvtId[_numInList];
68 :
69 0 : _list[0]=name1;
70 0 : _list[1]=name2;
71 0 : _list[2]=name3;
72 :
73 0 : }
74 :
75 :
76 : EvtIdSet::EvtIdSet(const std::string name1,
77 : const std::string name2,
78 0 : const std::string name3){
79 0 : _numInList=3;
80 0 : _list=new EvtId[_numInList];
81 :
82 0 : _list[0]=EvtPDL::getId(name1);
83 0 : _list[1]=EvtPDL::getId(name2);
84 0 : _list[2]=EvtPDL::getId(name3);
85 0 : }
86 :
87 :
88 : EvtIdSet::EvtIdSet(const EvtId name1,
89 : const EvtId name2,
90 : const EvtId name3,
91 0 : const EvtId name4){
92 0 : _numInList=4;
93 0 : _list=new EvtId[_numInList];
94 :
95 0 : _list[0]=name1;
96 0 : _list[1]=name2;
97 0 : _list[2]=name3;
98 0 : _list[3]=name4;
99 0 : }
100 :
101 :
102 : EvtIdSet::EvtIdSet(const std::string name1,
103 : const std::string name2,
104 : const std::string name3,
105 0 : const std::string name4){
106 0 : _numInList=4;
107 0 : _list=new EvtId[_numInList];
108 :
109 0 : _list[0]=EvtPDL::getId(name1);
110 0 : _list[1]=EvtPDL::getId(name2);
111 0 : _list[2]=EvtPDL::getId(name3);
112 0 : _list[3]=EvtPDL::getId(name4);
113 0 : }
114 :
115 :
116 : EvtIdSet::EvtIdSet(const EvtId name1,
117 : const EvtId name2,
118 : const EvtId name3,
119 : const EvtId name4,
120 0 : const EvtId name5){
121 0 : _numInList=5;
122 0 : _list=new EvtId[_numInList];
123 :
124 0 : _list[0]=name1;
125 0 : _list[1]=name2;
126 0 : _list[2]=name3;
127 0 : _list[3]=name4;
128 0 : _list[4]=name5;
129 0 : }
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 0 : const std::string name5){
137 0 : _numInList=5;
138 0 : _list=new EvtId[_numInList];
139 :
140 0 : _list[0]=EvtPDL::getId(name1);
141 0 : _list[1]=EvtPDL::getId(name2);
142 0 : _list[2]=EvtPDL::getId(name3);
143 0 : _list[3]=EvtPDL::getId(name4);
144 0 : _list[4]=EvtPDL::getId(name5);
145 0 : }
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 0 : const EvtId name6){
154 0 : _numInList=6;
155 0 : _list=new EvtId[_numInList];
156 :
157 0 : _list[0]=name1;
158 0 : _list[1]=name2;
159 0 : _list[2]=name3;
160 0 : _list[3]=name4;
161 0 : _list[4]=name5;
162 0 : _list[5]=name6;
163 0 : }
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 0 : const std::string name6){
172 0 : _numInList=6;
173 0 : _list=new EvtId[_numInList];
174 :
175 0 : _list[0]=EvtPDL::getId(name1);
176 0 : _list[1]=EvtPDL::getId(name2);
177 0 : _list[2]=EvtPDL::getId(name3);
178 0 : _list[3]=EvtPDL::getId(name4);
179 0 : _list[4]=EvtPDL::getId(name5);
180 0 : _list[5]=EvtPDL::getId(name6);
181 0 : }
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 0 : const EvtId name7){
191 0 : _numInList=7;
192 0 : _list=new EvtId[_numInList];
193 :
194 0 : _list[0]=name1;
195 0 : _list[1]=name2;
196 0 : _list[2]=name3;
197 0 : _list[3]=name4;
198 0 : _list[4]=name5;
199 0 : _list[5]=name6;
200 0 : _list[6]=name7;
201 0 : }
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 0 : const std::string name7){
211 0 : _numInList=7;
212 0 : _list=new EvtId[_numInList];
213 :
214 0 : _list[0]=EvtPDL::getId(name1);
215 0 : _list[1]=EvtPDL::getId(name2);
216 0 : _list[2]=EvtPDL::getId(name3);
217 0 : _list[3]=EvtPDL::getId(name4);
218 0 : _list[4]=EvtPDL::getId(name5);
219 0 : _list[5]=EvtPDL::getId(name6);
220 0 : _list[6]=EvtPDL::getId(name7);
221 0 : }
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 0 : const EvtId name8){
232 0 : _numInList=8;
233 0 : _list=new EvtId[_numInList];
234 :
235 0 : _list[0]=name1;
236 0 : _list[1]=name2;
237 0 : _list[2]=name3;
238 0 : _list[3]=name4;
239 0 : _list[4]=name5;
240 0 : _list[5]=name6;
241 0 : _list[6]=name7;
242 0 : _list[7]=name8;
243 0 : }
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 0 : const std::string name8){
254 0 : _numInList=8;
255 0 : _list=new EvtId[_numInList];
256 :
257 0 : _list[0]=EvtPDL::getId(name1);
258 0 : _list[1]=EvtPDL::getId(name2);
259 0 : _list[2]=EvtPDL::getId(name3);
260 0 : _list[3]=EvtPDL::getId(name4);
261 0 : _list[4]=EvtPDL::getId(name5);
262 0 : _list[5]=EvtPDL::getId(name6);
263 0 : _list[6]=EvtPDL::getId(name7);
264 0 : _list[7]=EvtPDL::getId(name8);
265 0 : }
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 0 : const EvtId name9){
277 0 : _numInList=9;
278 0 : _list=new EvtId[_numInList];
279 :
280 0 : _list[0]=name1;
281 0 : _list[1]=name2;
282 0 : _list[2]=name3;
283 0 : _list[3]=name4;
284 0 : _list[4]=name5;
285 0 : _list[5]=name6;
286 0 : _list[6]=name7;
287 0 : _list[7]=name8;
288 0 : _list[8]=name9;
289 0 : }
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 0 : const std::string name9){
301 0 : _numInList=9;
302 0 : _list=new EvtId[_numInList];
303 :
304 0 : _list[0]=EvtPDL::getId(name1);
305 0 : _list[1]=EvtPDL::getId(name2);
306 0 : _list[2]=EvtPDL::getId(name3);
307 0 : _list[3]=EvtPDL::getId(name4);
308 0 : _list[4]=EvtPDL::getId(name5);
309 0 : _list[5]=EvtPDL::getId(name6);
310 0 : _list[6]=EvtPDL::getId(name7);
311 0 : _list[7]=EvtPDL::getId(name8);
312 0 : _list[8]=EvtPDL::getId(name9);
313 0 : }
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 0 : const EvtId name10){
326 0 : _numInList=10;
327 0 : _list=new EvtId[_numInList];
328 :
329 0 : _list[0]=name1;
330 0 : _list[1]=name2;
331 0 : _list[2]=name3;
332 0 : _list[3]=name4;
333 0 : _list[4]=name5;
334 0 : _list[5]=name6;
335 0 : _list[6]=name7;
336 0 : _list[7]=name8;
337 0 : _list[8]=name9;
338 0 : _list[9]=name10;
339 0 : }
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 0 : const std::string name10){
352 0 : _numInList=10;
353 0 : _list=new EvtId[_numInList];
354 :
355 0 : _list[0]=EvtPDL::getId(name1);
356 0 : _list[1]=EvtPDL::getId(name2);
357 0 : _list[2]=EvtPDL::getId(name3);
358 0 : _list[3]=EvtPDL::getId(name4);
359 0 : _list[4]=EvtPDL::getId(name5);
360 0 : _list[5]=EvtPDL::getId(name6);
361 0 : _list[6]=EvtPDL::getId(name7);
362 0 : _list[7]=EvtPDL::getId(name8);
363 0 : _list[8]=EvtPDL::getId(name9);
364 0 : _list[9]=EvtPDL::getId(name10);
365 0 : }
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 0 : const EvtId name11){
379 0 : _numInList=11;
380 0 : _list=new EvtId[_numInList];
381 :
382 0 : _list[0]=name1;
383 0 : _list[1]=name2;
384 0 : _list[2]=name3;
385 0 : _list[3]=name4;
386 0 : _list[4]=name5;
387 0 : _list[5]=name6;
388 0 : _list[6]=name7;
389 0 : _list[7]=name8;
390 0 : _list[8]=name9;
391 0 : _list[9]=name10;
392 0 : _list[10]=name11;
393 0 : }
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 0 : const std::string name11){
407 0 : _numInList=11;
408 0 : _list=new EvtId[_numInList];
409 :
410 0 : _list[0]=EvtPDL::getId(name1);
411 0 : _list[1]=EvtPDL::getId(name2);
412 0 : _list[2]=EvtPDL::getId(name3);
413 0 : _list[3]=EvtPDL::getId(name4);
414 0 : _list[4]=EvtPDL::getId(name5);
415 0 : _list[5]=EvtPDL::getId(name6);
416 0 : _list[6]=EvtPDL::getId(name7);
417 0 : _list[7]=EvtPDL::getId(name8);
418 0 : _list[8]=EvtPDL::getId(name9);
419 0 : _list[9]=EvtPDL::getId(name10);
420 0 : _list[10]=EvtPDL::getId(name11);
421 0 : }
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 0 : const EvtId name12){
436 0 : _numInList=12;
437 0 : _list=new EvtId[_numInList];
438 :
439 0 : _list[0]=name1;
440 0 : _list[1]=name2;
441 0 : _list[2]=name3;
442 0 : _list[3]=name4;
443 0 : _list[4]=name5;
444 0 : _list[5]=name6;
445 0 : _list[6]=name7;
446 0 : _list[7]=name8;
447 0 : _list[8]=name9;
448 0 : _list[9]=name10;
449 0 : _list[10]=name11;
450 0 : _list[11]=name12;
451 0 : }
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 0 : const std::string name12){
466 0 : _numInList=12;
467 0 : _list=new EvtId[_numInList];
468 :
469 0 : _list[0]=EvtPDL::getId(name1);
470 0 : _list[1]=EvtPDL::getId(name2);
471 0 : _list[2]=EvtPDL::getId(name3);
472 0 : _list[3]=EvtPDL::getId(name4);
473 0 : _list[4]=EvtPDL::getId(name5);
474 0 : _list[5]=EvtPDL::getId(name6);
475 0 : _list[6]=EvtPDL::getId(name7);
476 0 : _list[7]=EvtPDL::getId(name8);
477 0 : _list[8]=EvtPDL::getId(name9);
478 0 : _list[9]=EvtPDL::getId(name10);
479 0 : _list[10]=EvtPDL::getId(name11);
480 0 : _list[11]=EvtPDL::getId(name12);
481 0 : }
482 :
483 :
484 0 : EvtIdSet::EvtIdSet(const EvtIdSet& set1){
485 :
486 0 : _numInList=set1.sizeOfSet();
487 0 : _list=new EvtId[_numInList];
488 : int i;
489 0 : for (i=0;i<_numInList;i++){
490 0 : _list[i]=set1.getElem(i);
491 : }
492 :
493 0 : }
494 0 : EvtIdSet::EvtIdSet(const EvtIdSet& set1, const EvtIdSet& set2){
495 :
496 0 : _numInList=set1.sizeOfSet();
497 0 : _list=new EvtId[_numInList];
498 : int i;
499 0 : for (i=0;i<_numInList;i++){
500 0 : _list[i]=set1.getElem(i);
501 : }
502 : //then just append the second list.
503 0 : this->append(set2);
504 :
505 0 : }
506 :
507 : int EvtIdSet::contains(const EvtId id){
508 :
509 : int i;
510 0 : for (i=0;i<_numInList;i++){
511 0 : if ( _list[i] == id ) return 1;
512 : }
513 :
514 0 : return 0;
515 0 : }
516 :
517 : int EvtIdSet::contains(const std::string nm){
518 :
519 : int i;
520 0 : for (i=0;i<_numInList;i++){
521 0 : if ( _list[i] == EvtPDL::getId(nm) ) return 1;
522 : }
523 :
524 0 : return 0;
525 0 : }
526 :
527 :
528 : void EvtIdSet::append(const EvtIdSet set1){
529 :
530 0 : int combLen=_numInList+set1.sizeOfSet();
531 : int uniqueLen=0;
532 : EvtId *combSet;
533 :
534 0 : combSet=new EvtId[combLen];
535 :
536 : int i;
537 0 : for (i=0;i<combLen;i++){
538 0 : if ( i>=_numInList ) {
539 :
540 : //check that there are no overlaps between lists
541 : int j;
542 : int isUnique=1;
543 0 : for (j=0;j<_numInList;j++){
544 0 : if ( _list[j]==set1.getElem(i-_numInList) ) {
545 : isUnique=0;
546 0 : }
547 : }
548 0 : if ( isUnique==1 ) {
549 0 : combSet[uniqueLen]=set1.getElem(i-_numInList);
550 0 : uniqueLen+=1;
551 0 : }
552 0 : }
553 : else{
554 0 : combSet[uniqueLen]=_list[i];
555 0 : uniqueLen+=1;
556 : }
557 :
558 0 : delete _list;
559 0 : _list=new EvtId[uniqueLen];
560 :
561 0 : _numInList=uniqueLen;
562 0 : for (i=0;i<_numInList;i++){
563 0 : _list[i]=combSet[i];
564 : }
565 :
566 0 : delete combSet;
567 :
568 : }
569 0 : }
570 :
571 0 : int EvtIdSet::sizeOfSet() const { return _numInList;}
572 :
573 0 : EvtId EvtIdSet::getElem(const int i) const { return _list[i];}
574 :
575 :
576 :
577 :
578 :
579 :
580 :
581 :
|