Exemplo n.º 1
0
void PedestrianDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction> const & path,
        Route::TTimes & times, Route::TTurns & turns,
        vector<Junction> & routeGeometry,
        my::Cancellable const & cancellable)
{
    times.clear();
    turns.clear();
    routeGeometry.clear();

    if (path.size() <= 1)
        return;

    CalculateTimes(graph, path, times);

    vector<Edge> routeEdges;
    if (!ReconstructPath(graph, path, routeEdges, cancellable))
    {
        LOG(LDEBUG, ("Couldn't reconstruct path."));
        // use only "arrival" direction
        turns.emplace_back(path.size() - 1, turns::PedestrianDirection::ReachedYourDestination);
        return;
    }

    CalculateTurns(graph, routeEdges, turns, cancellable);
    routeGeometry = path;
}
Exemplo n.º 2
0
void readfile_fun(const Char_t* run_name,const Int_t numberOfFiles,const Char_t * outputname)
{


  srand(time(NULL));
  Int_t timewindow = 1000; // *10 ns
  Int_t startTime=time(NULL);
  Char_t filename[256];
  Int_t event_count=0;
  Int_t decays=0;
  //TFile *file=new TFile(runname);
  //TTree *T=(TTree*)file->Get("dchan");


  UInt_t lasttimelow;
  UInt_t lasttimehigh;

  UInt_t currenttimelow;
  UInt_t currenttimehigh;

  Double_t lastcompoundtime;
  Double_t currentcompoundtime;

  Double_t lasttime;
  Double_t currenttime;
  
  TChain *T= new TChain("dchan");
  

  Char_t dummy[256];
  Char_t dummy2[256];
  Char_t runname[256];

  Char_t cona[256];

  strcpy(dummy,run_name);

  sprintf(runname,"/events/e14066/rootdata/%s",dummy);

  cout<<runname<<endl;

  for(Int_t i=0;i<numberOfFiles;i++)
    {
      sprintf(filename,"%s-%d.root",runname,i);
      T->Add(filename);
      cout<<filename<<" attached to Chain"<<endl;
    }

  //Pointer to the DDAS Event
  DDASEvent *theDDASevent=new DDASEvent();
  T->SetBranchAddress("ddasevent",&theDDASevent);
  
  //Pointer to the BetaDecay
  BetaDecay *theBetaDecay=new BetaDecay();
	
  TFile *outFile=new TFile(outputname,"RECREATE");
  TTree *tree_out=new TTree("T","The Data Tree");
  
  Int_t filenumber;
  Int_t lastfilenumber=-1;

  tree_out->Branch("BetaDecay","BetaDecay",&theBetaDecay,32000,99);
  


  //ddaschannel *thechannel;
  
  //T->SetBranchAddress("dchan",&thechannel);
  
  T->SetBranchAddress("ddasevent",&theDDASevent);
  //Loop on entries
  Int_t nentries=T->GetEntries();
  //Int_t nentries=2;
  //Int_t nentries=5000000;
  cout<<nentries<<" in the ROOT file"<<endl;
  
  //BEGINNING OF EVENT LOOP
  for(Int_t ientry=0;ientry<nentries;ientry++)
    {
     if(ientry%100000==0)
	cout<<"."<<flush;
      
     T->GetEntry(ientry);
     if(DEBUG>0)
     cout<<"entries in the Event "<<theDDASevent->GetNEvents()<<endl;

     sprintf(cona,T->GetFile()->GetName());
     Char_t *pch=strchr(cona,'-');
     filenumber=atoi(pch+1);
     if(filenumber!=lastfilenumber){
       sprintf(dummy2,"%s-%02d_params.dat",dummy,filenumber);
       //cout<<dummy2<<endl;
       //ReadCalibrationParameters(dummy2);
       ReadCalibrationParameters("Calib_params_DPL.dat");
       lastfilenumber=filenumber; 
     }
     
 
    //for(Int_t j=0;j<theDDASevent->GetNEvents();j++){
  
      ddaschannel * thechannel=theDDASevent->GetData()[0];
     //cout<<cona<<" "<<pch+1<<" "<<filenumber<<endl;
      if(ientry==0){
	lasttime=thechannel->GetTime();
	lasttimelow=thechannel->timelow;
	lasttimehigh=thechannel->timehigh;
	lastcompoundtime=4294967296*lasttimehigh+lasttimelow;
	cout<<"First time:"<<lasttime<<" "<<lastcompoundtime<<endl;
      }

      //cout<<"Lasttime "<<lasttime<<endl;
      Double_t deltaT=0;

      if(thechannel->GetTime()<lasttime){

	cout<<endl;
	cout<<"****************PROBLEMS with time**************************"<<endl;
      }
      else{
	currenttimelow=thechannel->timelow;
	currenttimehigh=thechannel->timehigh;
	currentcompoundtime=4294967296*currenttimehigh+currenttimelow;
	//deltaT=thechannel->GetTime()-lasttime;
	deltaT=currentcompoundtime-lastcompoundtime;
	//cout<<"DeltaT "<<deltaT<<endl;
      }
      if(deltaT>timewindow){
	//cout<<"End of Event"<<endl;
	//ResetChannelList();
	//Here goes the Unpacker
	DDAS2Event(theBetaDecay,theDDASevent);
	//cout<<theBetaDecay->thepin1.energy<<"\t "<<theBetaDecay->theTac.pin01xfp<<endl;	
	SortPID(theBetaDecay);
 
	CalculateTimes(theBetaDecay);
	
	//Int_t flag=theCorrelator.Correlate(theBetaDecay);
	//if(flag==16){
	  //cout<<event_count<<" "<<flag<<endl;
	//decays++;
	//}
	tree_out->Fill();
	//here goes the sorting
	//SortPID(theBetaDecay);
	//Reset
	//ResetChannelList();
	//channellist.push_back(thechannel);
	event_count++;
	//if(theBetaDecay->thepin1.energy>0)
	  //cout<<"Before "<<theBetaDecay->thepin1.energy<<endl;
	lasttimelow=currenttimelow;
	lasttimehigh=currenttimehigh;
	lastcompoundtime=4294967296*lasttimehigh+lasttimelow;	
	//cout<<"After "<<theBetaDecay->thepin1.energy<<endl;
	}

      else{
         ;	
	//Accumulate the channel
	//cout<<"here"<<endl;
	//channellist.push_back(thechannel);
      }
     //}          
      //pid->Draw("zcol");
      //canvas->Update();
   
      }//END OF EVENT LOOP
	
	
  //pid->Draw("zcol");
  cout<<endl;
  tree_out->Write();
  cout<<"DONE!!"<<endl;
  
  //h2->Draw();
  
  cout<<endl;
  Int_t endTime=time(NULL);
  Int_t total_time= endTime-startTime;
  
  if(total_time<60)
    cout<<"Total running time "<<total_time<<" s."<<endl;
  else
    cout<<"Total running time "<<total_time/60<<" min."<<endl;
  cout<<"Number of events processed "<<event_count<<endl;
  cout<<"Number of buffers "<<nentries<<endl;
  cout<<"Number decays "<<decays<<endl;
  
  return;
}