StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StRichPidTraits.cxx
1 /***************************************************************************
2  *
3  * $Id: StRichPidTraits.cxx,v 2.7 2002/02/19 23:21:30 ullrich Exp $
4  *
5  * Author: Matt Horsley, Sep 2000
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StRichPidTraits.cxx,v $
13  * Revision 2.7 2002/02/19 23:21:30 ullrich
14  * Added copy constructor and assignment operator. New destructor.
15  *
16  * Revision 2.6 2001/05/30 17:45:54 perev
17  * StEvent branching
18  *
19  * Revision 2.5 2001/04/05 04:00:53 ullrich
20  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
21  *
22  * Revision 2.4 2001/02/22 21:05:00 lasiuk
23  * add production version, associated MIP, dca residual 3Vectors
24  *
25  * Revision 2.3 2000/11/25 11:53:36 lasiuk
26  * initialize data members in c'tor
27  *
28  * Revision 2.2 2000/11/01 16:46:59 lasiuk
29  * Keep the StRichPid as the owner (use a StSPtrVec)
30  * also check the pdg encoded number now
31  *
32  * Revision 2.1 2000/09/28 10:54:46 ullrich
33  * Initial Revision.
34  *
35  ***************************************************************************/
36 #include "TClass.h"
37 #include "StRichPidTraits.h"
38 
39 static const char rcsid[] = "$Id: StRichPidTraits.cxx,v 2.7 2002/02/19 23:21:30 ullrich Exp $";
40 
41 ClassImp(StRichPidTraits)
42 
44  : StTrackPidTraits(kRichId), mId(0), mProbability(0) {
45  mThePids.clear();
46  mThePids.resize(0);
47  mRichSpectra = 0;
48 }
49 
50 StRichPidTraits::~StRichPidTraits() {delete mRichSpectra;}
51 
52 StRichPidTraits::StRichPidTraits(const StRichPidTraits& t)
53 {
54  mRichSpectra = 0;
55  *this = t;
56 }
57 
59 StRichPidTraits::operator=(const StRichPidTraits& t)
60 {
61  if (this != &t) {
62  mThePids = t.mThePids;
63  mProductionVersion = t.mProductionVersion;
64  mId = t.mId;
65  mProbability = t.mProbability;
66  mAssociatedMip = t.mAssociatedMip;
67  mMipResidual = t.mMipResidual;
68  mRefitResidual = t.mRefitResidual;
69  mSigned3dDca = t.mSigned3dDca;
70  mSigned2dDca = t.mSigned2dDca;
71  if (mRichSpectra) delete mRichSpectra;
72  if (t.mRichSpectra)
73  mRichSpectra = new StRichSpectra(*t.mRichSpectra);
74  else
75  mRichSpectra = 0;
76  }
77  return *this;
78 }
79 
80 
81 StRichPid*
82 StRichPidTraits::getPid(StParticleDefinition* part) {
83 
84  for (size_t index=0;index<mThePids.size();index++) {
85 
86  if ( (mThePids[index]->getRingType()==part) ||
87  (mThePids[index]->getParticleNumber() == part->pdgEncoding()) ) {
88  return mThePids[index];
89  }
90 
91  }
92  return 0;
93 }
94 
95 
96 const StRichPid*
97 StRichPidTraits::getPid(StParticleDefinition* part) const {
98 
99  for (size_t index=0;index<mThePids.size();index++) {
100 
101  if ( (mThePids[index]->getRingType()==part) ||
102  (mThePids[index]->getParticleNumber() == part->pdgEncoding()) ) {
103  return mThePids[index];
104  }
105 
106  }
107  return 0;
108 }
109 
110 ostream&
111 operator<<(ostream& os, const StRichPidTraits& t)
112 {
113  return (os << "StrichPidTraits::> #Pids= " << t.getAllPids().size()
114  << "\n\tProduction Version: " << t.productionVersion()
115  << "\n\tAssociated Mip: " << t.associatedMip()
116  << "\n\tMip Residual: " << t.mipResidual()
117  << "\n\tRefit Residual: " << t.refitResidual()
118  << "\n\tid " << t.id()
119  << "\n\tprobability " << t.probability());
120 }
121 
122 void
123 StRichPidTraits::Streamer(TBuffer &R__b)
124 {
125  // Stream an object of class .
126 
127  if (R__b.IsReading()) {
128  UInt_t R__s, R__c;
129  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
130  if (R__v > 1) {
131  Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
132  return;
133  }
134  //====process old versions before automatic schema evolution
135  StTrackPidTraits::Streamer(R__b);
136  mThePids.Streamer(R__b);
137  R__b >> mProductionVersion;
138  R__b >> mId;
139  R__b >> mProbability;
140 
141 // R__b >> mAssociatedMip;
142  R__b >> (StRichHit*&)mAssociatedMip;
143 
144  mMipResidual.Streamer(R__b);
145  mRefitResidual.Streamer(R__b);
146  R__b >> mSigned3dDca;
147  R__b >> mSigned2dDca;
148 
149 
150  R__b.CheckByteCount(R__s, R__c, Class());
151  //====end of old versions
152 
153  } else {
154  Class()->WriteBuffer(R__b,this);
155  }
156 }
157