00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015 #include "TClass.h"
00016
00017 #include "Algorithm/AlgHandle.h"
00018 #include "MessageService/MsgService.h"
00019 #include "RecoBase/CandEvent.h"
00020 #include "RecoBase/CandEventHandle.h"
00021 #include "RecoBase/CandShowerHandle.h"
00022 #include "RecoBase/CandSliceHandle.h"
00023 #include "RecoBase/CandTrackHandle.h"
00024
00025 ClassImp(CandEvent)
00026
00027
00028 CVSID("$Id: CandEvent.cxx,v 1.15 2006/05/01 20:34:39 musser Exp $");
00029
00030 #include "Candidate/CandBase.tpl"
00031
00032
00033 CandEvent::CandEvent() :
00034 fPrimaryShower(0)
00035 , fPrimaryTrack(0)
00036 , fContained(0)
00037 , fEnergy(0.)
00038 {
00039 }
00040
00041
00042 CandEvent::CandEvent(AlgHandle &ah) :
00043 CandReco(ah)
00044 , fPrimaryShower(0)
00045 , fPrimaryTrack(0)
00046 ,fContained(0)
00047 , fEnergy(0.)
00048 {
00049
00050
00051
00052
00053
00054
00055 }
00056
00057
00058 CandEvent::CandEvent(AlgHandle &ah, CandHandle &ch, CandContext &cx) :
00059 CandReco(ah)
00060 , fPrimaryShower(0)
00061 , fPrimaryTrack(0)
00062 , fContained(0)
00063 , fEnergy(0.)
00064 {
00065 CreateLocalHandle();
00066
00067
00068 {
00069 CandEventHandle csh(this);
00070 ch = csh;
00071 }
00072 ah.RunAlg(ch, cx);
00073 }
00074
00075
00076 CandEvent::CandEvent(const CandEvent &rhs) :
00077 CandReco(rhs)
00078 , fPrimaryShower(0)
00079 , fPrimaryTrack(0)
00080 , fContained(rhs.fContained)
00081 , fEnergy(rhs.fEnergy)
00082 {
00083
00084
00085
00086
00087 if (rhs.fPrimaryShower)
00088 fPrimaryShower = (rhs.fPrimaryShower)->DupHandle();
00089
00090 if (rhs.fPrimaryTrack)
00091 fPrimaryTrack = (rhs.fPrimaryTrack)->DupHandle();
00092
00093
00094 CandHandle *ch;
00095 TIter shwiter(&rhs.fShowerList);
00096 while ((ch = dynamic_cast<CandHandle *>(shwiter())))
00097 fShowerList.Add(ch->DupHandle());
00098 TIter trkiter(&rhs.fTrackList);
00099 while ((ch = dynamic_cast<CandHandle *>(trkiter())))
00100 fTrackList.Add(ch->DupHandle());
00101 }
00102
00103
00104 CandEvent::~CandEvent()
00105 {
00106
00107
00108
00109
00110 delete fPrimaryShower;
00111 delete fPrimaryTrack;
00112
00113 fShowerList.Delete();
00114 fTrackList.Delete();
00115 }
00116
00117
00118 void CandEvent::CreateLocalHandle()
00119 {
00120 SetLocalHandle(new CandEventHandle(this));
00121 }
00122
00123
00124 CandEvent *CandEvent::Dup() const
00125 {
00126
00127
00128
00129
00130
00131 CandEvent *cb = new CandEvent(*this);
00132 cb->CreateLocalHandle();
00133 TIter iterdau = GetDaughterIterator();
00134 CandHandle *dau;
00135 while ((dau=(CandHandle *) iterdau())) cb->AddDaughterLink(*dau);
00136 return cb;
00137 }
00138
00139
00140 Bool_t CandEvent::IsEquivalent(const TObject *rhs) const
00141 {
00142 Bool_t result = true;
00143 if (!CandBase::IsEquivalent(rhs)) result = false;
00144 TestDisplayCandBanner("CandEvent");
00145 const CandEvent* rCnd = dynamic_cast<const CandEvent*>(rhs);
00146 if (rCnd == NULL) return false;
00147
00148 result = TestTObjArrayCandHandleDup("fShowerList",
00149 this->fShowerList,
00150 rCnd->fShowerList) && result;
00151 result = TestTObjArrayCandHandleDup("fTrackList",
00152 this->fTrackList,
00153 rCnd->fTrackList) && result;
00154 result = TestCandHandleDup("fPrimaryShower",
00155 this->fPrimaryShower,
00156 rCnd->fPrimaryShower) && result;
00157 result = TestCandHandleDup("fPrimaryTrack",
00158 this->fPrimaryTrack,
00159 rCnd->fPrimaryTrack) && result;
00160 result = TestEquality("fEnergy", this->fEnergy,
00161 rCnd->fEnergy) && result;
00162 result = TestEquality("fContained", this->fContained,
00163 rCnd->fContained) && result;
00164
00165 return result;
00166 }
00167
00168
00169 CandEventHandle CandEvent::MakeCandidate(AlgHandle &ah, CandContext &cx)
00170 {
00171 CandEventHandle csh;
00172 new CandEvent(ah, csh, cx);
00173 return csh;
00174 }
00175
00176
00177 std::ostream& CandEvent::FormatToOStream(std::ostream& os,
00178 Option_t *option) const
00179 {
00180 CandBase::FormatToOStream(os,option);
00181
00182 TString opt(option);
00183 if (!opt.Contains("v0")) {
00184 const TString& indent = GetIndentString();
00185 os << " Energy " << fEnergy << " Contained " << fContained << endl;
00186 os << indent << GetDataIndent() << "Primary:" << endl;
00187 IncIndent();
00188 if (fPrimaryShower) fPrimaryShower->Print("nd0");
00189 if (fPrimaryTrack) fPrimaryTrack->Print("nd0");
00190 DecIndent();
00191
00192 }
00193 return os;
00194 }
00195
00196
00197 void CandEvent::Streamer(TBuffer &R__b)
00198 {
00199
00200
00201 if (R__b.IsReading()) {
00202 UInt_t R__s, R__c;
00203 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00204 CandEvent::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
00205 if (R__v < 2) {
00206 if (fPrimaryShower) fPrimaryShower = fPrimaryShower->DupHandle();
00207 if (fPrimaryTrack) fPrimaryTrack = fPrimaryTrack->DupHandle();
00208
00209
00210 CandHandle *ch;
00211 TIter shwiter(&fShowerList);
00212 while ((ch = dynamic_cast<CandHandle *>(shwiter())))
00213 fShowerList.AddAt(ch->DupHandle(), fShowerList.IndexOf(ch));
00214 TIter trkiter(&fTrackList);
00215 while ((ch = dynamic_cast<CandHandle *>(trkiter())))
00216 fTrackList.AddAt(ch->DupHandle(), fTrackList.IndexOf(ch));
00217 }
00218 }
00219 else {
00220 CandEvent::Class()->WriteBuffer(R__b, this);
00221 }
00222 }
00223
00224