/* * PndTrackCollection.cxx * * Created on: Jul 28, 2016 * Author: kibellus */ #include PndTrackCollection::PndTrackCollection() { fLines = new vector(); } PndTrackCollection::~PndTrackCollection() { } void PndTrackCollection::add(PndLineApproximation l,Bool_t skewed){ if(l.getLine().getRating()==-1)return; //copy hits vector newHits; vector oldHits = l.getHits(); for(int i=0;ipush_back(l); //refit if(fLines->size()==1)fCurrLine=(*fLines)[0].getLine(); if(fLines->size()>1 && skewed){ refitAllHits(); } else if(fLines->size()>1){ vector hits = l.getHits(); for(int i=0;iSetDetectorID(h->GetDetectorID()); h2->SetTubeID(h->GetTubeID()); h2->SetChamberID(h->GetChamberID()); h2->SetLayerID(h->GetLayerID()); h2->SetXYZ(h->GetX(),h->GetY(),h->GetZ()); h2->SetIsochrone(h->GetIsochrone()); h2->SetIsochroneError(h->GetIsochroneError()); h2->SetRefIndex(h->GetRefIndex()); h2->SetEntryNr(h->GetEntryNr()); return h2; } void PndTrackCollection::refitAllHits(){ //get all hits vector allHits; for(int i=0;isize();i++){ vector hits = (*fLines)[i].getHits(); for(int j=0;jsize();i++){ PndLineApproximation a = (*fLines)[i]; PndPlane p(a.getLine(),0); PndPlane p2(fCurrLine.getP1(),fCurrLine.getDir(),TVector3(1,0,0)); PndLine newLine = p.getIntersection(p2); (*fLines)[i].setLine(newLine); } } void PndTrackCollection::refitHit(PndLine &l,PndFtsHit* hit){ TVector3 base = l.getP1(); TVector3 dir = l.getDir(); Double_t lamp = (hit->GetZ()-base[2])/dir[2]; TVector3 p = base+lamp*dir; hit->SetY(p[1]); } PndTrack PndTrackCollection::getPndTrack(map orgHits){ std::cout<<"PndTrackCollection::getPndTrack(): lines array size = "<size()<size() < 2) PndLine first = (*fLines)[0].getLine(); PndLine last = (*fLines)[fLines->size()-1].getLine(); TVector3 v(1,1,1); // for "variances" TVector3 di(1,0,0); // for "detector plane" TVector3 dj(0,1,0); // for "detector plane" //this is not right to put a momentum of "3" and charge "+1", I'll fix that [r.k.'16] //FairTrackParP tp1(first.getP1(),3 * first.getDir().Unit(), v, v, 1, v, v, v); //FairTrackParP tp2(last.getP1(),3 * last.getDir().Unit(), v, v, 1, v, v, v); TVector3 mom1=first.getDir().Unit(); TVector3 mom2=last.getDir().Unit(); int q = scaleToMomentum(first.getP1(),mom1,last.getP1(),mom2); // If q==0 we implicitly have unaltered "momentum" vectors. std::cout<<"PndTrackCollection::getPndTrack(): after: m1("<= 0 ) ? 1. : -1. ; double sign2=( mom2.Z() >= 0 ) ? 1. : -1. ; TVector2 d1(sign1*mom1.Z(),sign1*mom1.X()); TVector2 d2(sign2*mom2.Z(),sign2*mom2.X()); std::cout<<"PndTrackCollection::scaleToMomentum(): before: m1("< 0 ) ? 1 : -1 ; // FIXME right direction?? int q = ( mom2.X() > mom1.X() ) ? 1 : -1 ; if (0.==mom1.Z()) return q; double t1 = (pos1.Z() - fZBegin) / mom1.Z(); if (0.==mom2.Z()) return q; double t2 = (pos2.Z() - fZEnd) / mom2.Z(); TVector2 T1=x1+t1*d1; TVector2 T2=x2+t2*d2; // Second is the intersection between the tangents if (0.==d2.X()) return q; double tmp1=d2.Y() - d1.Y()*d1.X()/d2.X(); if (0.==tmp1) return q; double k2 = ( d1.Y()*(x2.X()-x1.X()) + x1.Y() - x2.Y() ) / tmp1; TVector2 A=x2+k2*d2; // Third we get an average AT distance as we don't trust the Begin/End positions double AT= 0.5*( (A-T1).Mod() + (A-T2).Mod() ); double sph=sin(0.5*dphi); if (0.==sph) return q; double R=AT*sqrt(1+1/(sph*sph)); // Fourth is getting the momentum magnitude double B=1.; //Double_t po[3], BB[3]; //po[0] = hitXLabSys; //po[1] = hitYLabSys; //po[2] = hitZLabSys; //fField->GetFieldValue(po, BB); //return value in KG (G3) //By = BB[1] / 10.; // By is y-component of magnetic field in Tesla double c=0.00299792458; //B[T], R[cm] and p[GeV/c] double pt=B*c*R; double tmpm1=mom1.X()*mom1.X()+mom1.Z()*mom1.Z(); if (0.==tmpm1) return q; double scale1=pt/sqrt(tmpm1); double tmpm2=mom2.X()*mom2.X()+mom2.Z()*mom2.Z(); if (0.==tmpm2) return q; double scale2=pt/sqrt(tmpm2); // We're fine now. Let's put the output. mom1=sign1*scale1*mom1; mom2=sign2*scale2*mom2; std::cout<<"PndTrackCollection::scaleToMomentum(): dphi="<