////////////////////////////////////////////////////////////////////////// // // // TCandList // // // // Container class for TCandidates // // // // Author List: // // Marcel Kunze, RUB, Feb. 99 // // Copyright (C) 1999-2001, Ruhr-University Bochum. // // // ////////////////////////////////////////////////////////////////////////// #include #include "RhoBase/TCandList.h" #include "RhoBase/TFactory.h" #include "RhoBase/TCandidate.h" #include "RhoBase/VAbsPidSelector.h" #include "RhoBase/VAbsVertexSelector.h" ClassImp(TCandList) #include using namespace std; TCandList::TCandList(const char *name, UInt_t capacity) : TNamed(name,name), fFast(kFALSE) { fOwnList = new TObjArray(capacity); } // Perform a deep copy TCandList::TCandList(TCandList& l) { fFast = l.fFast; Cleanup(); const Int_t n = l.GetNumberOfTracks(); for (int i=0;iClear(); } void TCandList::SetNumberOfTracks(Int_t n) { cerr << "TCandList::SetNumberOfTracks is deprecated" << endl; } Int_t TCandList::GetNumberOfTracks() const { return fOwnList->GetLast()+1; } void TCandList::Put(const TCandidate& c, Int_t i ) { TCandidate *newCand = TFactory::Instance()->NewCandidate(c); if (i<0) fOwnList->Add(newCand); else (*fOwnList)[i] = newCand; } void TCandList::InsertAt(Int_t i, const TCandidate& c) { fOwnList->AddAtAndExpand((TObject*)&c,i); Put(c,i); } TCandidate* TCandList::Get(Int_t i) { if (i >= GetNumberOfTracks()) return 0; return (TCandidate*) (fOwnList->UncheckedAt(i)); } TCandidate* TCandList::GetConst(Int_t i) const { if (i >= GetNumberOfTracks()) return 0; return (TCandidate*) (fOwnList->UncheckedAt(i)); } // Compare the marker and remove corresponding entry (MK,12/99) // This allows to remove objects in several lists Int_t TCandList::Remove(TCandidate& c ) { Int_t nRemoved = 0; Int_t n = GetNumberOfTracks(); for (Int_t i=0;iEquals(c)) { fOwnList->RemoveAt(i); nRemoved++; } } fOwnList->Compress(); return nRemoved; } Int_t TCandList::RemoveFamily(TCandidate& c ) { Int_t nRemoved = 0; Int_t n = GetNumberOfTracks(); for (Int_t i=0;iOverlaps(c)) { fOwnList->RemoveAt(i); nRemoved++; } } fOwnList->Compress(); return nRemoved; } Int_t TCandList::RemoveClones() { Int_t nRemoved = 0; Int_t n = GetNumberOfTracks(); for (Int_t i=0;iEquals(*c)) { fOwnList->RemoveAt(j); nRemoved++; } } } fOwnList->Compress(); return nRemoved; } Int_t TCandList::OccurrencesOf(TCandidate& c ) { Int_t nCand = 0; const Int_t n = GetNumberOfTracks(); for (Int_t i=0;iEquals(c)) nCand++; } return nCand; } Double_t TCandList::GetTotalEnergy(Double_t emin) { Double_t e = 0.0; const Int_t n = GetNumberOfTracks(); for (Int_t i=0;iEnergy(); if (energy > emin) e += energy; } return e; } TVector3 TCandList::GetTotalMomentum(Double_t pmin) { TVector3 p(0.0,0.0,0.0); const Int_t n = GetNumberOfTracks(); for (Int_t i=0;iP3(); if (p3.Mag() > pmin) p = p + p3; } return p; } void TCandList::Boost(const TVector3& p ) { const Int_t n = GetNumberOfTracks(); for (Int_t i=0;iBoost(p); } } void TCandList::PrintOn(std::ostream& o) const { const Int_t n = GetNumberOfTracks(); o << "content: " << n << " entries." << endl; if ( n!=0 ) { for (Int_t i=0;iGetMarker()!=0 ) fOwnList->RemoveAt(i); } fOwnList->Compress(); } // Makes now a deep copy rather than just cpoying pointers (MK,12/99) void TCandList::operator =(const TCandList& l ) { fFast = l.fFast; Cleanup(); const Int_t n = l.GetNumberOfTracks(); for (int i=0;iAccept(l1[i1],l2[i2]); if (!nearby) continue; TCandidate c(vl,charge); c.SetCovP4(l1[i1].P4Cov()+l2[i2].P4Cov()); c.SetMarker(l1[i1].GetMarker(0)|l2[i2].GetMarker(0),0); c.SetMarker(l1[i1].GetMarker(1)|l2[i2].GetMarker(1),1); c.SetMarker(l1[i1].GetMarker(2)|l2[i2].GetMarker(2),2); c.SetMarker(l1[i1].GetMarker(3)|l2[i2].GetMarker(3),3); c.AddDaughterLinkSimple(&(l1[i1])); c.AddDaughterLinkSimple(&(l2[i2])); if (selector!=0) { c.SetPosition(selector->GetVertex()); c.SetVect(selector->GetMomentum()); c.SetEnergy(c.E()); } Put(c); } } /* const Int_t endpos1 = l1.GetNumberOfTracks(); const Int_t endpos2 = l2.GetNumberOfTracks(); if ( &l1==&l2 ) { //combination of a list with itself for (Int_t comb_i=0;comb_iAccept(l1[comb_i],l2[comb_k]); if (nearby) { //fill list with new candidate TCandidate c(vl,charge); c.SetMarker(l1[comb_i].GetMarker(0)|l2[comb_k].GetMarker(0),0); c.SetMarker(l1[comb_i].GetMarker(1)|l2[comb_k].GetMarker(1),1); c.SetMarker(l1[comb_i].GetMarker(2)|l2[comb_k].GetMarker(2),2); c.SetMarker(l1[comb_i].GetMarker(3)|l2[comb_k].GetMarker(3),3); c.SetCovP4(l1[comb_i].P4Cov()+l2[comb_k].P4Cov()); //cout <<"TCandList:"<GetVertex()); c.SetVect(selector->GetMomentum()); c.SetEnergy(c.E()); } // *************** modified by K Goetzen c.AddDaughterLinkSimple(&(l1[comb_i])); c.AddDaughterLinkSimple(&(l2[comb_k])); // **************** Put(c); } } } } } else { //combination of 2 different lists for (Int_t comb_i=0;comb_iAccept(l1[comb_i],l2[comb_k]); if (nearby) { //fill list with new candidate TCandidate c(vl,charge); c.SetMarker(l1[comb_i].GetMarker(0)|l2[comb_k].GetMarker(0),0); c.SetMarker(l1[comb_i].GetMarker(1)|l2[comb_k].GetMarker(1),1); c.SetMarker(l1[comb_i].GetMarker(2)|l2[comb_k].GetMarker(2),2); c.SetMarker(l1[comb_i].GetMarker(3)|l2[comb_k].GetMarker(3),3); c.SetCovP4(l1[comb_i].P4Cov()+l2[comb_k].P4Cov()); if (selector!=0){ c.SetPosition(selector->GetVertex()); c.SetVect(selector->GetMomentum()); c.SetEnergy(c.E()); } // *************** modified by K Goetzen c.AddDaughterLinkSimple(&(l1[comb_i])); c.AddDaughterLinkSimple(&(l2[comb_k])); // **************** Put(c); } } } } } */ } void TCandList::CombineAndAppend( TCandList& l1, TCandList& l2, TCandList& l3) { TLorentzVector vl; Double_t charge; const int len1=l1.GetLength(); const int len2=l2.GetLength(); const int len3=l3.GetLength(); int i1,i2,i3; int st2,st3; for (i1=0; i1Accept(*c)) fOwnList->RemoveAt(i); } fOwnList->Compress(); } // Non-destructive selection void TCandList::Select(TCandList& l, VAbsPidSelector* pidmgr) { Cleanup(); const Int_t n = l.GetNumberOfTracks(); for (Int_t i=0;iAccept(*c)) { Put(*c); } } } void TCandList::Append(TCandList& l, VAbsPidSelector* pidmgr) { const Int_t n = l.GetNumberOfTracks(); for (Int_t i=0;iAccept(*c)) { Put(*c); } } }