Пример #1
0
Position
MSPerson::MSPersonStage_Driving::getPosition(SUMOTime /* now */) const {
    if (myVehicle != 0) {
        /// @bug this fails while vehicle is driving across a junction
        return myVehicle->getEdge()->getLanes()[0]->getShape().positionAtOffset(myVehicle->getPositionOnLane());
    }
    return getEdgePosition(myWaitingEdge, myWaitingPos, SIDEWALK_OFFSET);
}
Пример #2
0
Position
MSPerson::MSPersonStage_Driving::getPosition(SUMOTime /* now */) const {
    if (isWaiting4Vehicle()) {
        if (myStopWaitPos != Position::INVALID) {
            return myStopWaitPos;
        }
        return getEdgePosition(myWaitingEdge, myWaitingPos, MSPModel::SIDEWALK_OFFSET);
    }
    return myVehicle->getPosition();
}
Пример #3
0
Position
MSPerson::MSPersonStage_Waiting::getPosition(SUMOTime /* now */) const {
    return getEdgePosition(&myDestination, myStartPos, SIDEWALK_OFFSET);
}
Пример #4
0
Position
MSPerson::MSPersonStage_Walking::getPosition(SUMOTime now) const {
    const MSEdge* e = getEdge(now);
    SUMOReal off = STEPS2TIME(now - myLastEntryTime);
    return getEdgePosition(e, myCurrentBeginPos + myCurrentLength / myCurrentDuration * off, SIDEWALK_OFFSET);
}
Пример #5
0
Position
MSPerson::MSPersonStage_Waiting::getPosition(SUMOTime /* now */) const {
    return getEdgePosition(&myDestination, myArrivalPos, MSPModel::SIDEWALK_OFFSET);
}
Пример #6
0
void AnalysisBase::findBeamRegionAndAlign(int iPass){

  cout << "==================================================================" << endl;
  cout << "findBeamRegionAndAlign(): Determining Fiducial Region, Pass = "******"==================================================================" << endl;

  double dxWindow = dxWin;
  if(iPass == 1) dxWindow = 1000.0;
  if(iPass == 2) dxWindow = 1.0;

  TH1F* hthx = new TH1F("hthx","#theta_{X}",1000,-5.0,5.0);
  TH1F* hthy = new TH1F("hthy","#theta_{Y}",1000,-5.0,5.0);
  TH1F* hx = new TH1F("hx","Y position of matched cluster",800,-40.0,40.0);
  TH1F* hxdut = new TH1F("hxdut","Y position of matched cluster",800,-40.0,40.0);
  TH1F* hs = new TH1F("hs","Strip number of matched cluster",512,0,512.0);
  TH1F* hy = new TH1F("hy","Y position of matched cluster",800,-10.0,10.0);
  TH1F* hw = new TH1F("hw","#DeltaX",20000,-100.0,100.0);
  TH1F* hn = new TH1F("hn","#DeltaX",4000,-2.0,2.0);
  TH1F* hnn = new TH1F("hnn","#DeltaX",400,-0.2,0.2);
  TH2F* hxy = new TH2F("hxy","Y_{trk} vs X_{trk}, with cluster",640,-8,8.0,640,-8,8);
  TProfile *ht = new TProfile("ht","Cluster Charge vs TDC time",12,0,12,100,1000);
  TProfile *hzrot = new TProfile("hzrot","#DeltaX vs Y_{trk} at DUT",1600,-8,8,-1.0,1.0);
  TH2F* hca = new TH2F("hca","Y_{trk} vs X_{trk}, with found cluster",160,-8,8.0,320,-8,8);
  TH2F* hcf = new TH2F("hcf","Y_{trk} vs X_{trk}, with found cluster",160,-8,8.0,320,-8,8);
  
  hca->Sumw2();
  hcf->Sumw2();
  
  int istrip;
  double nomStrip=0, detStrip = 0;
  Long64_t nbytes = 0, nb = 0;
  Int_t nentries = fChain->GetEntriesFast();
  for (Long64_t jentry=0; jentry<max(nentries,200000);jentry++) {
    Long64_t ientry = LoadTree(jentry);
    //if(jentry%1000==0) cout << "At entry = " << jentry << endl;
    
    if (ientry < 0) break;
    nb = fChain->GetEntry(jentry);   nbytes += nb;
    if(n_tp3_tracks > 1) continue;      

    for(int k=0; k<n_tp3_tracks; k++){
      bool goodTime = (clustersTDC >= tdcLo && clustersTDC < tdcHi);
      goodTime = clustersTDC>1.0;
      if(!goodTime) continue;
      double x_trk = vec_trk_tx->at(k)*z_DUT+vec_trk_x->at(k);
      double y_trk = vec_trk_ty->at(k)*z_DUT+vec_trk_y->at(k);

      transformTrackToDUTFrame(k, x_trk, y_trk, nomStrip, detStrip);

      double tx = 1000*vec_trk_tx->at(k);
      double ty = 1000*vec_trk_ty->at(k);

      double x_trk0 = x_trk;

      for(int j=0; j<min(clusterNumberPerEvent,10); j++){
        if(clustersPosition[j] < 0.1) continue;
        if(polarity*clustersCharge[j] < kClusterChargeMin) continue;
        bool goodHit = (clustersPosition[j]>iLo && clustersPosition[j]<iHi);
        istrip = clustersSeedPosition[j];
        if(badStrips[istrip]==0) continue; // exclude bad strips

        double x_dut = getDUTHitPosition(j);

        x_trk = x_trk0;

        double dx = x_dut - x_trk;
        hn->Fill(dx);
        hnn->Fill(dx);

        hca->Fill(x_trk,y_trk);
        if(fabs(dx)<dxWindow || iPass==1) {
          if(goodHit) {
            hx->Fill(x_trk);
            hxdut->Fill(x_dut);
            hs->Fill(clustersPosition[j]);
            hy->Fill(y_trk);
            hthx->Fill(tx);
            hthy->Fill(ty);
            hw->Fill(dx);     
            hxy->Fill(x_trk,y_trk);
            ht->Fill(clustersTDC+0.1,polarity*clustersCharge[j]);
            hzrot->Fill(y_trk,dx);
            hcf->Fill(x_trk,y_trk);
          } 
        }
      }
    }
  }

  //hnn->Draw();

  if(iPass==4) {
    findCutoutRegion(hcf);
  }else {  

    float xmin=0,xmax=0,ymin=0,ymax=0,txmin=0,txmax=0,tymin=0,tymax=0;

    getRange(hthx,txmin,txmax,0.05,2);
    getRange(hthy,tymin,tymax,0.05,2);
    //getRange(hx,xmin,xmax,0.05,2);
    getRange(hy,ymin,ymax,0.2,2);

    // Use strip numbers to get xMin and xMax, since dead strips make holes in xpos plot
    xmin = getEdgePosition(iHi);
    xmax = getEdgePosition(iLo);
    
    xMin = xmin;
    xMax = xmax;
    yMin = ymin;
    yMax = ymax;
    txMin = txmin;
    txMax = txmax;
    tyMin = tymin;
    tyMax = tymax;

    // 
    
    float xlo = 0, xhi=0;
    if(iPass==1) getRange(hw,xlo,xhi,0.1,1);
    if(iPass==2) getRange(hn,xlo,xhi,0.1,1);
    if(iPass==3) getRange(hn,xlo,xhi,0.1,1);
    if(iPass>3) getRange(hnn,xlo,xhi,0.2,1);
    double XOFF = (xhi + xlo)/2.0;
    xOff = xOff - XOFF;
    double x_ave = (xMax + xMin)/2.0;
    double y_ave = (yMax + yMin)/2.0;
    xGloOff = xGloOff - x_ave;
    if(iPass<=4) yGloOff = yGloOff - y_ave;
    
    // Check/correct for z rotation
    if(iPass==3 && correctForZRotation){
      cout << "Checking for z-rotation" << endl;
      TF1* p1 = new TF1("p1","[0]+[1]*x",yMin,yMax);
      p1->SetParameters(0.0,0.0001);
      hzrot->Fit(p1,"0R");
      double rz = p1->GetParameter(1);
      cout << "=======================================================================" << endl;
      cout << "==> Updating z rotation angle from " << Rz << " to " << Rz-rz << " mrad" << endl;    
      Rz = Rz - rz;
      delete p1;
    }
    
    
    float lo = 0, hi = 0;
    getTDCBins(ht,lo,hi);
    tdcLo = lo;
    tdcHi = hi;
    cout << "=================================================================" << endl;
    cout << "====> TDC Range updated to be from " << tdcLo << " -- " << tdcHi << std::endl;
    cout << "=================================================================" << endl;
    cout << "====> Fiducial regions, xLo, xHi (Strip numbers) = " << iLo << " " << iHi << endl;
    cout << "====> Fiducial regions, xLo, xHi (pos in mm) = " << xMin << " " << xMax << " mm " << endl;
    cout << "====> Fiducial regions, yLo, yHi (pos in mm) = " << yMin << " " << yMax << " mm " << endl;
    cout << "====> Fiducial regions, thxLo, thxHi (pos in mrad) = " << txMin << " " << txMax << " mrad" << endl;
    cout << "====> Fiducial regions, thyLo, thxHi (pos in mrad) = " << tyMin << " " << tyMax << " mrad" << endl;
    cout << "=================================================================" << endl;   
    cout << "====> Shifting sensor by dX = " << XOFF << " mm " << ", new xOff = " << xOff << endl;
    cout << "====> Global X, Y shifts: " << x_ave << " " << y_ave << endl;
    cout << "====> New global x,y = " << xGloOff << " " << yGloOff << endl;
    
  }
  
  //if(iPass==1) hw->Draw();  // for debugging   
  //if(iPass==2) hy->Draw();

  //return;
  

  delete hxdut;
  delete hthx;
  delete hthy;
  delete hx;
  delete hy;
  delete hxy;
  delete hw;
  delete hn;
  delete hnn;
  delete hs;
  delete ht;
  delete hzrot;
  delete hcf;
  delete hca;
  
   
  return;
  

}