void Obstacle::render(GameData &data) { if (obsType == COLUMN) data.renderModel(GameData::COLUMN_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f); else if (obsType == BARREL) data.renderModel(GameData::BARREL_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f); if (DEBUG) renderBoundingCilinder(); }
/** * calculate Position of hit in the lab frame using the X/Y detector cluster positions in channel numbers. * The way to calculate the cluster position can be selected by the mode varibale. * * @param cor coordinate in which the calculation is made * @param plane which plane no is used * @param xCluster * @param yCluster * @param mode * @return value of calculated position */ Float_t TTrack::getPostionInLabFrame(TPlaneProperties::enumCoordinate cor,UInt_t plane,TCluster xCluster,TCluster yCluster,bool cmnCorrected, TCluster::calculationMode_t mode,TH1F* histo){ if(xCluster.size()<=0||yCluster.size()<=0) return N_INVALID; if(TPlaneProperties::isSiliconPlane(plane) && (mode != TCluster::corEta||histo==0)) cerr<<"Silicon Plane "<<plane<<" but wrong mode or histo==0: "<<mode<<" "<<histo<<endl; Float_t xOffMeas = this->getXOffset(plane); Float_t yOffMeas = this->getYOffset(plane); Float_t xPhiOff = this->getPhiXOffset(plane); Float_t yPhiOff = this->getPhiYOffset(plane); UInt_t detX = plane*2; UInt_t detY = plane*2+1; Float_t xMeasMetric = inMetricDetectorSpace(detX,xCluster.getPosition(cmnCorrected,mode,getEtaIntegral(detX))); Float_t yMeasMetric = inMetricDetectorSpace(detY,yCluster.getPosition(cmnCorrected,mode,getEtaIntegral(detY))); // get gradients of straight lines Float_t m_x = xPhiOff==0?0:1./TMath::Tan(xPhiOff);//cotan Float_t m_y = TMath::Tan(-1.*yPhiOff);//tan //take Position in the detecor frame at y_det = 0 and convert it into the lab frame Float_t x_x = xOffMeas + TMath::Cos(xPhiOff)*xMeasMetric; Float_t y_x = (-1.)*TMath::Sin(xPhiOff)*xMeasMetric; //take y Position in the dector frame at x_det = 0 and convert it into the lab frame Float_t x_y = TMath::Sin(yPhiOff)*yMeasMetric; Float_t y_y = yOffMeas+TMath::Cos(yPhiOff)*yMeasMetric; //out of slope and position we can calculate the offset Float_t b_x = xPhiOff==0?xOffMeas+xMeasMetric:y_x-m_x*x_x; Float_t b_y = y_y-m_y*x_y; //find interception of both straight liness Float_t x = (b_y-b_x)/(m_x-m_y); if (xPhiOff==0) x = xOffMeas+xMeasMetric; Float_t xPosition = x; Float_t yPosition = m_y*x+b_y; if(m_y!=m_y){ cerr<<"There was a problem with m_y! Please have a look. yPhiOff: "<<yPhiOff<<endl; exit(-1); } if(m_x!=m_x){ cerr<<"There was a problem with m_y! Please have a look. xPhiOff: "<<xPhiOff<<endl; exit(-1); } if(verbosity&&(xPosition==-1||yPosition==-1)){ cout<<" Meas: "<<xMeasMetric<<"/"<<yMeasMetric<<"\toff: "<<xOffMeas<<"/"<<yOffMeas<<"\tphi"<<xPhiOff<<"/"<<yPhiOff<<endl; cout<<"X:"<<mode<<" "<<xCluster.getPosition(cmnCorrected,mode,histo)<<endl; xCluster.Print(2); cout<<"Y: "<<endl; yCluster.Print(2); } switch(cor){ case TPlaneProperties::X_COR: return xPosition;break; case TPlaneProperties::Y_COR: return yPosition;break; case TPlaneProperties::Z_COR: return getZPosition(plane);break; default: return N_INVALID; } }
/* Render */ void MediKitObject::render(GameData &data) { if (isPickedUp()) return; data.renderModel(GameData::MEDIKIT_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f); if (DEBUG) renderBoundingCilinder(); }
/** * @brief predicts the Position calculated by a linear fit out of all planes in vecRefPlanes * In Order to be able to calculate the right sigma the subject Plane is set to z_subject = 0 * all other distances to the planes are set to the difference. * This must be done in order to calculate the sigma correctly: * sigma_b and sigma_m are correlated to each other in order to make it easy as possible we set the * subjectplane to z=0 such that sigma_prediction**2 = sigma_b**2 since the term sigma_m**2*zPos**2 * is equal to zero * @param subjectPlane Plane where the Position should be predicted * @param vecRefPlanes Planes used for the prediction * @param mode the way how the position should be calculated, e.g. Eta corrected * @param bPrint show output? * @return PositionPrediction object which contains all Informations of the prediction. */ TPositionPrediction* TTrack::predictPosition(UInt_t subjectPlane, vector<UInt_t> vecRefPlanes,bool cmnCorrection, TCluster::calculationMode_t mode,bool bPrint) { if(mode!=TCluster::corEta) cout<<"[TTrack::predictPosition] strange mode: "<<mode<<endl; Float_t zPosSubjectPlane = getZPosition(subjectPlane); Float_t sigma_z= alignment->getZResolution(subjectPlane);//todo linFitX->ClearPoints(); linFitY->ClearPoints(); if(event==NULL){ cerr<<"TTrack:predictPosition no ReferencePlanes are defined...event =NULL"<<endl; TPositionPrediction* prediction=0; return prediction; } if(vecRefPlanes.size()==0){ cerr<<"TTrack:predictPosition no ReferencePlanes are defined...vecRefSize=0"<<endl; TPositionPrediction *prediction=0; return prediction; } if(vecRefPlanes.size()==1){ if(verbosity>10||bPrint) cout<<"TTrack::predictPosition with 1 refPlane"<<endl; //todo anpassen so dass sigmas da drin reinkommen... TPositionPrediction *prediction=new TPositionPrediction(zPosSubjectPlane,sigma_z, getXPositionMetric(vecRefPlanes.at(0),cmnCorrection,mode), 0.,0., getYPositionMetric(vecRefPlanes.at(0),cmnCorrection,mode),0.,0.,0,0); return prediction; } vector<Double_t> zPosVec;//todo add xsigma ysigma if(bPrint)cout<<"Prediction of Track in Plane "<<subjectPlane<<" with "<<vecRefPlanes.size()<<" Planes:"<<endl; bool lastPredictionValid=true; for(UInt_t pl=0;pl<vecRefPlanes.size();pl++){ UInt_t plane=vecRefPlanes.at(pl); zPosVec.clear(); Float_t zPos = alignment->GetZOffset(plane)-zPosSubjectPlane; zPosVec.push_back(zPos); Float_t xPos = (Double_t)getXPositionMetric(plane,cmnCorrection,mode,getEtaIntegral(pl*2)); Float_t yPos = (Double_t)getYPositionMetric(plane,cmnCorrection,mode,getEtaIntegral(pl*2+1)); if((xPos==-1||yPos==-1)&&(verbosity||bPrint)){ cout<<"Problem with Plane "<<plane<<" "<<xPos<<" "<<yPos<<endl; event->Print(1); } Float_t xRes = this->alignment->getXResolution(plane); Float_t yRes = this->alignment->getYResolution(plane); linFitX->AddPoint(&zPosVec.at(0),xPos,xRes);//todo anpassen des SIGMA linFitY->AddPoint(&zPosVec.at(0),yPos,yRes);//todo anpassen des sigma 0.001 if(xPos==-1||yPos==-1) lastPredictionValid = false; if(verbosity>10||bPrint) cout<<"\tAdd in Plane "<<plane<<" "<<xPos<<"+/-"<<alignment->getXResolution(plane)<<" / "<<yPos<<"+/-"<<alignment->getYResolution(plane)<<" / "<<getZPosition(plane)<<endl; } linFitX->Eval(); linFitY->Eval(); linFitX->Chisquare(); linFitY->Chisquare(); // pair<Float_t,Float_t> result = getPredictedHitPosition(zPos,mx,bx,sigma_z,sigma_mx,sigma_bx) Float_t zPos = 0;//zPosSubjectPlane;//alignment->GetZOffset(subjectPlane); Float_t mx = linFitX->GetParameter(1); Float_t sigma_mx = linFitX->GetParError(1); Float_t bx = linFitX->GetParameter(0); Float_t sigma_bx = linFitX->GetParError(0); Float_t my = linFitY->GetParameter(1); Float_t sigma_my = linFitY->GetParError(1); Float_t by = linFitY->GetParameter(0); Float_t sigma_by = linFitY->GetParError(0); Float_t xChi2 = linFitX->GetChisquare()/(linFitX->GetNpoints()-linFitX->GetNumberFreeParameters()); Float_t yChi2 = linFitY->GetChisquare()/(linFitY->GetNpoints()-linFitY->GetNumberFreeParameters()); if(verbosity>10){ cout<<"\tParameters:\n\t mx: "<<mx<<" +/- "<<sigma_mx<<"\tbx: "<<bx<<" +/- "<<sigma_bx<<"\tzPos:"<<zPos<<endl; cout<<"\t my: "<<my<<" +/- "<<sigma_my<<"\tby: "<<by<<" +/- "<<sigma_by<<"\tzPos:"<<zPos<<endl; cout<<"\tNDFx: "<<linFitX->GetNumberFreeParameters()<<"\t"<<"\tNDFy: "<<linFitY->GetNumberFreeParameters()<<endl; cout<<"\t chi2x:"<<xChi2<<"\tchi2y:"<<yChi2<<endl; } pair<Float_t,Float_t> xprediction = this->getPredictedHitPosition(zPos,mx,bx,sigma_z,sigma_mx,sigma_bx); pair<Float_t,Float_t> yprediction = this->getPredictedHitPosition(zPos,my,by,sigma_z,sigma_my,sigma_by); // Float_t xPos = mx*zPos+bx; // Float_t yPos = my*zPos+by; // Float_t xSigma = (zPos*sigma_mx)*(zPos*sigma_mx)+(mx*sigma_z)*(mx*sigma_z)+(sigma_bx*sigma_bx); // xSigma = TMath::Sqrt(xSigma); // Float_t ySigma = (zPos*sigma_my)*(zPos*sigma_my)+(my*sigma_z)*(my*sigma_z)+(sigma_by*sigma_by); // ySigma = TMath::Sqrt(ySigma); Float_t xPhi = TMath::ATan(mx); Float_t yPhi = TMath::ATan(my); zPos=zPosSubjectPlane; TPositionPrediction* prediction=new TPositionPrediction(zPos,sigma_z,xprediction.first,xprediction.second,xChi2,yprediction.first,yprediction.second,yChi2,xPhi,yPhi); if(!lastPredictionValid)prediction->setValid(false); if(verbosity>10||bPrint) cout<<"\tPrediction of Plane "<<subjectPlane<<" with "<<vecRefPlanes.size()<<" Planes for ZPosition: "<<zPos<<endl; if(verbosity>10||bPrint) cout<<"\t X: "<<xprediction.first<<" +/- "<<xprediction.second<<" with a Chi^2 of "<<xChi2<<" "<<linFitX->GetNpoints()<<endl; if(verbosity>10||bPrint) cout<<"\t Y: "<<yprediction.first<<" +/- "<<yprediction.second<<" with a Chi^2 of "<<yChi2<<" "<<linFitY->GetNpoints()<<"\n"<<endl; return prediction; }