1 //--------------------------------------------------------------------------
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.
8 // Copyright Information: See EvtGen/COPYRIGHT
9 // Copyright (C) 1998 Caltech, UCSB
13 // Description: Class for particle Id used in EvtGen.
15 // Modification history:
17 // DJL Jan 4, 2000 Module created
19 //------------------------------------------------------------------------
21 #include "EvtGenBase/EvtPatches.hh"
23 #include "EvtGenBase/EvtIdSet.hh"
24 #include "EvtGenBase/EvtPDL.hh"
28 EvtIdSet::EvtIdSet(const EvtId name1) {
30 _list=new EvtId[_numInList];
35 EvtIdSet::EvtIdSet(const std::string name1){
37 _list=new EvtId[_numInList];
39 _list[0]=EvtPDL::getId(name1);
43 EvtIdSet::EvtIdSet(const EvtId name1,
46 _list=new EvtId[_numInList];
53 EvtIdSet::EvtIdSet(const std::string name1,
54 const std::string name2){
56 _list=new EvtId[_numInList];
58 _list[0]=EvtPDL::getId(name1);
59 _list[1]=EvtPDL::getId(name2);
63 EvtIdSet::EvtIdSet(const EvtId name1,
67 _list=new EvtId[_numInList];
76 EvtIdSet::EvtIdSet(const std::string name1,
77 const std::string name2,
78 const std::string name3){
80 _list=new EvtId[_numInList];
82 _list[0]=EvtPDL::getId(name1);
83 _list[1]=EvtPDL::getId(name2);
84 _list[2]=EvtPDL::getId(name3);
88 EvtIdSet::EvtIdSet(const EvtId name1,
93 _list=new EvtId[_numInList];
102 EvtIdSet::EvtIdSet(const std::string name1,
103 const std::string name2,
104 const std::string name3,
105 const std::string name4){
107 _list=new EvtId[_numInList];
109 _list[0]=EvtPDL::getId(name1);
110 _list[1]=EvtPDL::getId(name2);
111 _list[2]=EvtPDL::getId(name3);
112 _list[3]=EvtPDL::getId(name4);
116 EvtIdSet::EvtIdSet(const EvtId name1,
122 _list=new EvtId[_numInList];
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){
138 _list=new EvtId[_numInList];
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);
148 EvtIdSet::EvtIdSet(const EvtId name1,
155 _list=new EvtId[_numInList];
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){
173 _list=new EvtId[_numInList];
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);
184 EvtIdSet::EvtIdSet(const EvtId name1,
192 _list=new EvtId[_numInList];
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){
212 _list=new EvtId[_numInList];
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);
224 EvtIdSet::EvtIdSet(const EvtId name1,
233 _list=new EvtId[_numInList];
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){
255 _list=new EvtId[_numInList];
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);
268 EvtIdSet::EvtIdSet(const EvtId name1,
278 _list=new EvtId[_numInList];
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){
302 _list=new EvtId[_numInList];
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);
316 EvtIdSet::EvtIdSet(const EvtId name1,
327 _list=new EvtId[_numInList];
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){
353 _list=new EvtId[_numInList];
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);
368 EvtIdSet::EvtIdSet(const EvtId name1,
380 _list=new EvtId[_numInList];
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){
408 _list=new EvtId[_numInList];
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);
424 EvtIdSet::EvtIdSet(const EvtId name1,
437 _list=new EvtId[_numInList];
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){
467 _list=new EvtId[_numInList];
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);
484 EvtIdSet::EvtIdSet(const EvtIdSet& set1){
486 _numInList=set1.sizeOfSet();
487 _list=new EvtId[_numInList];
489 for (i=0;i<_numInList;i++){
490 _list[i]=set1.getElem(i);
494 EvtIdSet::EvtIdSet(const EvtIdSet& set1, const EvtIdSet& set2){
496 _numInList=set1.sizeOfSet();
497 _list=new EvtId[_numInList];
499 for (i=0;i<_numInList;i++){
500 _list[i]=set1.getElem(i);
502 //then just append the second list.
507 int EvtIdSet::contains(const EvtId id){
510 for (i=0;i<_numInList;i++){
511 if ( _list[i] == id ) return 1;
517 int EvtIdSet::contains(const std::string nm){
520 for (i=0;i<_numInList;i++){
521 if ( _list[i] == EvtPDL::getId(nm) ) return 1;
528 void EvtIdSet::append(const EvtIdSet set1){
530 int combLen=_numInList+set1.sizeOfSet();
534 combSet=new EvtId[combLen];
537 for (i=0;i<combLen;i++){
538 if ( i>=_numInList ) {
540 //check that there are no overlaps between lists
543 for (j=0;j<_numInList;j++){
544 if ( _list[j]==set1.getElem(i-_numInList) ) {
549 combSet[uniqueLen]=set1.getElem(i-_numInList);
554 combSet[uniqueLen]=_list[i];
559 _list=new EvtId[uniqueLen];
561 _numInList=uniqueLen;
562 for (i=0;i<_numInList;i++){
571 int EvtIdSet::sizeOfSet() const { return _numInList;}
573 EvtId EvtIdSet::getElem(const int i) const { return _list[i];}