Beispiel #1
0
bool EventQueue::Run()
{
  bool bRet = false;

  while (GetRun())
  {
	bRet = true;

	boost::shared_ptr<Task> pTask = Dequeue();
	boost::shared_ptr<Event> pEvent = boost::static_pointer_cast<Event>(pTask);
	if (NULL == pTask)
	//
	// CRITICAL SECTION BEGIN
	//
	{
	  MutexHandler oMH(GetMutex());
	  GetMutex().Wait(5000);
	}
	//
	// CRITICAL SECTION END
	//
	else if (NULL == pEvent)
	{
	  elog(ERROR, "Unable to cast task for some reason.\n");
	}
	else
	{
	  GetEventHandler()->HandleEvent(pEvent);
	}
  }

  return bRet;

}
Beispiel #2
0
float GetReso(int icent, int ihar, int isub){
    TString str1, str2;
    TFile *fin;
    int nrun = GetTotalRun();
    if(nrun<0) exit("Empty run list file!");
    int iharE;
    if(nhar==1) iharE=1;
    int n = ihar+1.0+iharE;

     ofstream fout;
        if(isub==1){
         str1 = "FVTX1S";
         str2 = "BBCS";
        }
        else if(isub==7){
         str1 = "FVTX2S";
         str2 = "BBCS";
        }
        else return -9999;
        TH1F* hEPR1 = new TH1F(Form("hEPR1_%d_%d_%d",icent,ihar,isub),Form("hEPR1_%d_%d_%d",icent,ihar,isub),220,-1.1,1.1);
        TH1F* hEPR2 = new TH1F(Form("hEPR2_%d_%d_%d",icent,ihar,isub),Form("hEPR2_%d_%d_%d",icent,ihar,isub),220,-1.1,1.1);
        TH1F* hEPR3 = new TH1F(Form("hEPR3_%d_%d_%d",icent,ihar,isub),Form("hEPR3_%d_%d_%d",icent,ihar,isub),220,-1.1,1.1);
        cout<<"Calculating Resolution..."<<endl;
        for(int irun=0;irun<nrun;irun++){
        // cout<<"cent = "<<icent<<"; n = "<<n<<" ;run = "<<irun<<" of total "<<nrun<<" runs"<<endl;
         //fin = TFile::Open(Form("/phenix/plhf/xuq/phenix/flow/pAu/work/output_vn.root"));
         fin = TFile::Open(Form("Run15pAu200MinBias/output_fvtxwithcntEP_%d.root",GetRun(irun)));
         if(!GoodRun(icent,ihar,isub,irun)) continue;
         TH1F* hEPR1temp = (TH1F*)fin->Get(Form("EPR%s%s_%d_%d","CNT",str1.Data(),icent,ihar));
         TH1F* hEPR2temp = (TH1F*)fin->Get(Form("EPR%s%s_%d_%d","CNT",str2.Data(),icent,ihar));
         TH1F* hEPR3temp = (TH1F*)fin->Get(Form("EPR%s%s_%d_%d",str1.Data(),str2.Data(),icent,ihar));
         if(!hEPR3temp)
         hEPR3temp = (TH1F*)fin->Get(Form("EPR%s%s_%d_%d",str2.Data(),str1.Data(),icent,ihar));

         hEPR1->Add(hEPR1temp);
         hEPR2->Add(hEPR2temp);
         hEPR3->Add(hEPR3temp);
         fin->Close();
        }
        if(hEPR1->GetMean()*hEPR2->GetMean()/hEPR3->GetMean()>0){
            float reso = sqrt(hEPR1->GetMean()*hEPR3->GetMean()/hEPR2->GetMean());
            return reso;
        }
        else return -9999;
}
Beispiel #3
0
void DumpRecenterParv2(){
    TString pro = "Pro104";
    int taxi = 8583;
    TFile *fin;
    int nrun = GetTotalRun();
    if(nrun<0) exit("Empty run list file!");

    TFile *fout = new TFile(Form("Recentering.root"),"Recreate");
    TVectorD vecmean;
    TVectorD vecrms;
    vecmean.ResizeTo(ncent*nbbcz*nhar*nsub*nxy);
    vecrms.ResizeTo(ncent*nbbcz*nhar*nsub*nxy);
    for(int irun=0;irun<nrun;irun++){
     cout<<irun<<" of total "<<nrun<<" runs"<<endl;
     int RunNumber=GetRun(irun);
     fin = TFile::Open(Form("Run15pAu200MinBias/output_fvtxwithcntrecenter_%d.root",RunNumber));
     //ofstream fout(Form("Calibration/%s/Recentering_%d.dat",dataset.Data(),GetRun(irun)));
     for(int icent=0;icent<ncent;icent++){
      for(int ibbcz=0;ibbcz<nbbcz;ibbcz++){
       for(int ihar=0;ihar<nhar;ihar++){
        for(int isub=0;isub<nsub;isub++){
         for(int ixy=0;ixy<nxy;ixy++){
             TH1F* q = (TH1F*)fin->Get(Form("q_%d_%d_%d_%d_%d",icent,ibbcz,ihar,isub,ixy));
             float mean = q->GetMean();
             float rms = q->GetRMS();
             vecmean[icent*nbbcz*nhar*nsub*nxy+ibbcz*nhar*nsub*nxy+ihar*nsub*nxy+isub*nxy+ixy] = mean;
             vecrms[icent*nbbcz*nhar*nsub*nxy+ibbcz*nhar*nsub*nxy+ihar*nsub*nxy+isub*nxy+ixy] = rms;
         }
        }
       }
      }
     }
    fout->cd();
    vecmean.Write(Form("mean_%d",RunNumber));
    vecrms.Write(Form("rms_%d",RunNumber));
    fin->Close();
    }
}
Beispiel #4
0
float GoodRun(int icent, int ihar, int isub, int irun){
    float pi = acos(-1);
    TF1 *fun = new TF1("fun","pol0",-pi,pi);
    TString str;
    TFile *fin;

     ofstream fout;
        if(isub==1){
         str = "FVTX1S";
        }
        else if(isub==2){
         str = "FVTX2S";
        }
        else return -9999;
         fin = TFile::Open(Form("Run15pAu200MinBias/output_fvtxwithcntEP_%d.root",GetRun(irun)));
        TH1F* hpsi = new TH1F("psi","psi",100,-pi,pi);
        for(int ibbcz=0;ibbcz<nbbcz;ibbcz++){
          hpsitemp = (TH1F*)fin->Get(Form("psi_%d_%d_%d_%d",icent,ibbcz,ihar,isub));
          hpsi->Add(hpsitemp);
        }
      if(hpsi->GetEntries()>10000){
	hpsi->SetMarkerStyle(20);
	hpsi->SetMarkerSize(0.6);
	hpsi->SetMarkerColor(4);
	hpsi->SetMinimum(10);
	hpsi->Fit("fun","QR0");
	float par=fun->GetParameter(0);
	hpsi->SetMaximum(1.5*par);
	//hpsi->Draw();
        fin->Close();
	return fun->GetChisquare()/fun->GetNDF();
      }
      else{
        fin->Close();
        return -9999;
      }
    }
Beispiel #5
0
void Getvn(){
    TString str;
    TFile *fin;
    int nrun = GetTotalRun();
    if(nrun<0) exit("Empty run list file!");

     ofstream fout, fout1, fout2;
     int iharE=0;
     if(nhar==1) iharE=1;
     for(int icent=0;icent<ncent;icent++){
      for(int ihar=0;ihar<nhar;ihar++){
       for(int isub=0;isub<nsub;isub++){
        int n = ihar+1.0+iharE;
        if(isub==1)
         str = "FVTX1S";
        else if(isub==2)
         str = "FVTX2S";
        else continue;
         fout1.open(Form("Run15pAu200MinBias/res%d_%d_%s.dat",n,icent,str.Data())); //using str as event plane detector
         fout2.open(Form("Run15pAu200MinBias/psi%d_%d_%s.dat",n,icent,str.Data())); //using str as event plane detector
         float reso = 1.;//GetReso(icent,ihar,isub);
         fout1<<reso<<endl;
         TH2F* hvobs = new TH2F(Form("hvobs_%d_%d_%d",icent,ihar,isub),Form("hvobs_%d_%d_%d",icent,ihar,isub),60,0,6,220,-1.1,1.1);
         TH2F* hvobssq = new TH2F(Form("hvobssq_%d_%d_%d",icent,ihar,isub),Form("hvobssq_%d_%d_%d",icent,ihar,isub),60,0,6,220,-1.1,1.1);
        for(int irun=0;irun<nrun;irun++){
         fout2<<GetRun(irun)<<" "<<GoodRun(icent,ihar,isub,irun)<<endl;
        }
        for(int iphi=0;iphi<nphi;iphi++){
         string phistr = (iphi==0)?"east":"west";
         fout.open(Form("Run15pAu200MinBias/v%d_%d_%s_%s.dat",n,icent,phistr.c_str(),str.Data())); //using str as event plane detector
        for(int irun=0;irun<nrun;irun++){
        // cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<irun<<endl;
         fin = TFile::Open(Form("Run15pAu200MinBias/output_fvtxwithcntEP_%d.root",GetRun(irun)));
         if(!(GoodRun(icent,ihar,isub,irun)>0.2 && GoodRun(icent,ihar,isub,irun)<3.0)){
         cout<<"cent = "<<icent<<"; n = "<<n<<" ;isub = "<<str<<" ;run = "<<GetRun(irun)<<" is bad run!"<<endl;
        continue;
         }
         TH2F* hvobstemp = (TH2F*)fin->Get(Form("vobs%s_%d_%d_%d",str.Data(),icent,ihar,iphi));
         TH2F* hvobssqtemp = (TH2F*)fin->Get(Form("vobs%ssq_%d_%d_%d",str.Data(),icent,ihar,iphi));
         hvobs->Add(hvobstemp);
         hvobssq->Add(hvobssqtemp);
         fin->Close();
        }
            TH1F* ptProj = (TH1F*)hvobs->ProjectionX(Form("hptProj"),0,-1);
         for(int ipt=0;ipt<npt-1;ipt++){
            TH1F* hvobsProj = (TH1F*)hvobs->ProjectionY(Form("hvobsProj_%d",ipt),hvobs->GetXaxis()->FindBin(ptbin[ipt]),hvobs->GetXaxis()->FindBin(ptbin[ipt+1]));
            TH1F* hvobssqProj = (TH1F*)hvobssq->ProjectionY(Form("hvobssqProj_%d",ipt),hvobs->GetXaxis()->FindBin(ptbin[ipt]),hvobs->GetXaxis()->FindBin(ptbin[ipt+1]));
            float vobs = hvobsProj->GetMean();
            float Ntracks = hvobsProj->GetEntries();
            float vobssq = hvobsProj->GetMean();
            float v = vobs/reso;
            float verr = sqrt(vobssq/reso/reso-(v*v))/sqrt(Ntracks);
            ptProj->GetXaxis()->SetRangeUser(ptbin[ipt],ptbin[ipt+1]);
            float pt = ptProj->GetMean();
            fout<<pt<<" "<<v<<" "<<" "<<verr<<endl;
         }
        fout.close();
         }
        fout1.close();
        fout2.close();
        }
        }
     }
}
Beispiel #6
0
void TrOccDB::Info(int verbosity) {
  Init();
  printf("TrOccDB::Info-V Run: %10d\n",GetRun());
  for (TrOccIt ladocc=fTrOccHwIdMap.begin(); ladocc!=fTrOccHwIdMap.end(); ++ladocc)
    (*ladocc).second->Info(verbosity);
}
Beispiel #7
0
int CInterpreter::GetID( char *id_name )
{
	int		id;

	id = FindSymbol( id_name, m_IDKeywords );

	if ( id == -1 )
		return Error("'%s' : unknown identifier", id_name);

	//FIXME: Function pointers would be awfully nice.. but not inside a class!  Weee!!

	switch (id)
	{
	
	//Affect takes control of an entity

	case ID_AFFECT:
		return GetAffect();
		break;

	//Wait for a specified amount of time

	case ID_WAIT:
		return GetWait();
		break;

	//Generic set call

	case ID_SET:
		return GetSet();
		break;

	case ID_LOOP:
		return GetLoop();
		break;

	case ID_PRINT:
		return GetPrint();
		break;

	case ID_USE:
		return GetUse();
		break;

	case ID_FLUSH:
		return GetFlush();
		break;
		
	case ID_RUN:
		return GetRun();
		break;

	case ID_KILL:
		return GetKill();
		break;

	case ID_REMOVE:
		return GetRemove();
		break;

	case ID_CAMERA:
		return GetCamera();
		break;

	case ID_SOUND:
		return GetSound();
		break;

	case ID_MOVE:
		return GetMove();
		break;

	case ID_ROTATE:
		return GetRotate();
		break;

	case ID_IF:
		return GetIf();
		break;

	case ID_ELSE:
		//return Error("syntax error : else without matching if");
		return GetElse();	//FIXME: Protect this call so that floating else's aren't allowed
		break;

	case ID_GET:
		return Error("syntax error : illegal use of \"get\"");
		break;

	case ID_TAG:
		return Error("syntax error : illegal use of \"tag\"");
		break;

	case ID_TASK:
		return GetTask();
		break;

	case ID_DO:
		return GetDo();
		break;

	case ID_DECLARE:
		return GetDeclare();
		break;

	case ID_FREE:
		return GetFree();
		break;

	case ID_REM:
		GetRem();
		break;

	case ID_DOWAIT:
		GetDoWait();
		break;

	case ID_SIGNAL:
		GetSignal();
		break;

	case ID_WAITSIGNAL:
		GetWaitSignal();
		break;

	case ID_PLAY:
		GetPlay();	//Bad eighties slang joke...  yeah, it's not really funny, I know...
		break;

		//Local variable types
	case TK_FLOAT:
	case TK_INT:
	case TK_STRING:
	case TK_VECTOR:
		GetVariable( id );
		break;

	//Unknown ID

	default:
	case -1:
		return Error("'%s' : unknown identifier", id_name);
		break;
	}

	return true;
}