Beispiel #1
0
void drawFocalPlane(TString infile="../build/hits.root", Double_t r1 = 48.8, Double_t r2 = 29.1, Int_t it1=0, Int_t it2=0, Double_t energy=3){
  gSystem->Load("../build/libprtdirclib.so");
  PrtInit(infile,0);
  gStyle->SetOptStat(0);

  Double_t radiatorL(1250); //bar
  // Double_t radiatorL(1224.9); //plate
  TVector3 res;
  TH2F *hFp1 = new TH2F("hFp1",Form("r_{1}=%2.2f    r_{2}=%2.2f;x, [cm];y, [cm]",r1,r2),500,0,50,500,0,30 );
  TH2F *hFp2 = new TH2F("hFp2",Form("r_{1}=%2.2f    r_{2}=%2.2f;z, [cm];y, [cm]",r1,r2),500,-30,30,500,-30,50 );

  PrtHit hit[2];
  Int_t nevents = fCh->GetEntries();
  Int_t count(0);
  for (Int_t ievent=0; ievent<nevents; ievent++){
    PrtNextEvent(ievent,1000);
    Int_t nhits = prt_event->GetHitSize(); //fEvent->GetHitSize();
    if(nhits!=2) continue;
    for(Int_t h=0; h<nhits; h++) hit[h] = prt_event->GetHit(h); //fEvent->GetHit(h);
    Double_t d = findVertex(hit[0].GetGlobalPos(),hit[0].GetMomentum().Unit(),hit[1].GetGlobalPos(),hit[1].GetMomentum().Unit(), &res);
    if(d<1){
      Double_t x = -(res.X()+radiatorL/2.)/10.;
      if(x>6){
	hFp1->Fill(x,res.Z()/10.);
	hFp2->Fill(res.Y()/10.,res.Z()/10.);
      }
      count++;
    }
  } 
  Double_t eff = 100*count/(Double_t)nevents;

  TString senergy = "";
    if(energy>-1){
      Double_t m = 1, cm = 0.01, nanometer = 0.000000001, GeV = 1000000000;
      Double_t LambdaE = 2.0 * 3.14159265358979323846 * 1.973269602e-16 * m * GeV;
      Double_t lam = LambdaE/(energy*nanometer);

      senergy = Form("   E=%2.2f [eV] / #lambda=%2.0f [nm]",energy,lam);
    }
  hFp1->SetTitle(Form("r_{1}=%2.2f    r_{2}=%2.2f   #varepsilon=%2.0f",r1,r2,eff)+senergy);
  canvasAdd(Form("fp_%d_%d",it1,it2),800,500);
  hFp1->Draw("colz");
  canvasAdd(Form("fp2_%d_%d",it1,it2),600,800);
  hFp2->Draw("colz");
  //canvasSave(0,"drawFocalPlane.C",1,"fp");
  
}
Beispiel #2
0
void drawLoad(TString infile="../build/hits.root"){
  gStyle->SetOptStat(0);
  fSavePath = "load";
  
  PrtInit(infile,0); //digi
  
  TH2F* hHits = new TH2F("hHits",";x, [mm];y, [mm]",500,-40,350,500,-100,100);
  Int_t angle(0), step(0);
  Double_t test(0);
  PrtHit fHit;
  for (Int_t ievent=0; ievent<fCh->GetEntries(); ievent++){
    PrtNextEvent(ievent,1000);
    if(ievent==0){
      angle = fEvent->GetAngle() + 0.01;
      test = fEvent->GetTest1();
      fInfo +=  fEvent->PrintInfo();
    }
    for(Int_t h=0; h<fEvent->GetHitSize(); h++){
      fHit = fEvent->GetHit(h);
      Int_t mcpid = fHit.GetMcpId();
      Int_t pixid = fHit.GetPixelId()-1;
      TVector3 pos = fHit.GetGlobalPos();
      
      Double_t time = fHit.GetLeadTime();
      hHits->Fill(pos.X(),pos.Y());
    }
  }
  
  canvasAdd(Form("load_%d",angle),800,500);
  hHits->SetStats(0);
  hHits->GetXaxis()->SetTitleOffset(0.85);
  hHits->GetYaxis()->SetTitleOffset(0.85);
  hHits->GetXaxis()->SetTitleSize(0.05);
  hHits->GetYaxis()->SetTitleSize(0.05);
  //hHits->SetTitle(Form("#theta_{track} = %d#circ",angle));
  hHits->Draw("colz");
  drawPrism(prismShift,0);
  canvasSave(1,0);
}
Beispiel #3
0
void da_scan(TString inFile = "r_spr.root", TString outFile="c_spr.root"){

  fSavePath = "data/mirror_old_ng";

  TChain ch("dirc"); ch.Add(inFile);
  Double_t cangle,spr,trr,nph,par1,par2,par3,par4,par5,par6,test1,test2,theta,phi; 
  
  TGraph *gSpr = new TGraph();
  TGraph *gNph = new TGraph();
  TGraph *gTrr = new TGraph();

  ch.SetBranchAddress("spr",&spr);
  ch.SetBranchAddress("trr",&trr);
  ch.SetBranchAddress("nph",&nph);
  ch.SetBranchAddress("cangle",&cangle);
  //  ch.SetBranchAddress("par4",&par4);
  ch.SetBranchAddress("par5",&par5);
  ch.SetBranchAddress("par6",&par6);
  ch.SetBranchAddress("test1",&test1);
  ch.SetBranchAddress("test2",&test2);
  ch.SetBranchAddress("theta",&theta);
  ch.SetBranchAddress("phi",&phi);
  
  Int_t nent = ch.GetEntries();
  std::cout<<"# entries  "<< nent <<std::endl;
  std::cout<<"infor  "<< ch.GetTree()->GetTitle()<<std::endl;
  
  for (Int_t i = 0; i < nent; i++) {
    ch.GetEvent(i);
    gSpr->SetPoint(i,theta,TMath::Abs(spr));
    gNph->SetPoint(i,theta,nph);
    gTrr->SetPoint(i,theta,TMath::Abs(trr));
  }
  gSpr->Sort();
  gNph->Sort();
  gTrr->Sort();

  gSpr->SetLineColor(38);
  gNph->SetLineColor(38);
  gTrr->SetLineColor(38);
  gSpr->SetMarkerStyle(20);
  gNph->SetMarkerStyle(20);
  gTrr->SetMarkerStyle(20);
  gSpr->SetMarkerSize(0.7);
  gNph->SetMarkerSize(0.7);
  gTrr->SetMarkerSize(0.7);
  gNph->GetYaxis()->SetRangeUser(0,140);
  gSpr->GetYaxis()->SetRangeUser(0,14);
  gTrr->GetYaxis()->SetRangeUser(0,2);

  gSpr->GetYaxis()->SetTitle("SPR [mrad]");
  gNph->GetYaxis()->SetTitle("multiplicity [#]");
  gTrr->GetYaxis()->SetTitle("#sigma_{#theta_{C} tr} [mrad]");
  
  gSpr->GetXaxis()->SetLabelSize(0.05);
  gSpr->GetXaxis()->SetTitleSize(0.06);
  gSpr->GetXaxis()->SetTitleOffset(0.84);

  gTrr->GetXaxis()->SetLabelSize(0.05);
  gTrr->GetXaxis()->SetTitleSize(0.06);
  gTrr->GetXaxis()->SetTitleOffset(0.84);

  gNph->GetXaxis()->SetLabelSize(0.05);
  gNph->GetXaxis()->SetTitleSize(0.06);
  gNph->GetXaxis()->SetTitleOffset(0.84);

  gSpr->GetYaxis()->SetLabelSize(0.05);
  gSpr->GetYaxis()->SetTitleSize(0.06);
  gSpr->GetYaxis()->SetTitleOffset(0.7);

  gTrr->GetYaxis()->SetLabelSize(0.05);
  gTrr->GetYaxis()->SetTitleSize(0.06);
  gTrr->GetYaxis()->SetTitleOffset(0.7);

  gNph->GetYaxis()->SetLabelSize(0.05);
  gNph->GetYaxis()->SetTitleSize(0.06);
  gNph->GetYaxis()->SetTitleOffset(0.7);


  gSpr->GetXaxis()->SetTitle("#theta_{track} [#circ]");
  gNph->GetXaxis()->SetTitle("#theta_{track} [#circ]");
  gTrr->GetXaxis()->SetTitle("#theta_{track} [#circ]");

  TFile *file = new TFile(outFile,"RECREATE");
  TCanvas* c1 = new TCanvas("c1","c1",800,500);c1->SetBottomMargin(0.12);
  gSpr->Draw("APL");
  canvasAdd(c1);
  TCanvas* c2 = new TCanvas("c2","c2",800,500);c2->SetBottomMargin(0.12);
  gNph->Draw("APL");
  canvasAdd(c2);
  TCanvas* c3 = new TCanvas("c3","c3",800,500);c3->SetBottomMargin(0.12);
  gTrr->Draw("APL");
  canvasAdd(c3);

  canvasSave(0,1);
   
  file->cd();
  c1->Write();
  c2->Write();
  c3->Write();
  file->Close();
  
}
Beispiel #4
0
void addcanvases(){
  fSavePath = "data/perfLL";
  const Int_t narr = 20;
  gStyle->SetOptStat(0); 
  gStyle->SetOptTitle(0); 

  TFile *f1 = TFile::Open("c_l3.root");
  TIter next1(f1->GetListOfKeys());
  TKey *key1;
  Int_t it1 = 0;
  TCanvas *carr1[narr];

  while((key1 = (TKey*)next1())) {
    TClass *cl = gROOT->GetClass(key1->GetClassName());
    if (!cl->InheritsFrom("TCanvas")) continue;
    carr1[it1] = (TCanvas*)key1->ReadObj();
    it1++;
  }

  TFile *f2 = TFile::Open("c_l0.root");
  TIter next2(f2->GetListOfKeys());
  TKey *key2;
  Int_t it2 = 0;
  TCanvas *carr2[narr];

  while ((key2 = (TKey*)next2())) {
    TClass *cl = gROOT->GetClass(key2->GetClassName());
    if (!cl->InheritsFrom("TCanvas")) continue;
    carr2[it2] = (TCanvas*)key2->ReadObj();
    it2++;
  }

  TLegend *leg = new TLegend(0.2,0.7,0.5,0.9);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);


  for(Int_t i=0; i<it2; i++){
    carr1[i]->Draw();
    //leg->AddEntry( carr1[i],"3x3 full coverage","l");
    //leg->Draw();
    canvasAdd(carr1[i]);
    TIter next(carr2[i]->GetListOfPrimitives());
    TObject *obj;

    while((obj = next())){
      // if(obj->InheritsFrom("TH1F")){
      // 	TH1F *h = (TH1F*)obj;
      // 	std::cout<<"name "<< h->GetName() <<std::endl;      
      // 	h->SetLineStyle(7);
      // 	h->SetLineWidth(2);
      //   h->Draw("same");
      // }
      if(obj->InheritsFrom("TGraph")){
	TGraph *h = (TGraph*)obj;
	std::cout<<"name "<< h->GetName() <<std::endl;      
	h->SetLineColor(32);
	h->SetMarkerColor(2);
	//	h->SetLineWidth(2);
        h->Draw("same PL");
	// leg->AddEntry(h,"6.5x6.5 MCP PMTs coverage","lp");
	// leg->Draw();
      }

    }
  }
  std::cout<<"save all  " <<std::endl;
  
  canvasSave(0,1);
}