#include "save.C" void drawLut(){ Int_t saveflag = 1; TString info = "Look-up table plots"; TString path = createDir("rdata", info, saveflag); gSystem->Load("../build/libprtlib.so"); gInterpreter->GenerateDictionary("vector","TVector3.h"); TString inFile = "../data/lut.root"; TString outFile = "res.root"; const Int_t NRGBs = 5; const Int_t NCont = 255; Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); TFile* f = new TFile(inFile); TTree *t=(TTree *) f->Get("prtlut") ; TClonesArray* fLut =new TClonesArray("PrtLutNode"); t->SetBranchAddress("LUT",&fLut); t->GetEntry(0); const Int_t nbins=15; TH1F * histNode = new TH1F("LutNode","Node vs Multiplicity",30000,0,30000); const Int_t nn=50; TH1F * hTime[nn]; TH2F * hHitMap[nn]; for(Int_t i=0; iSetStats(0); hTime[i]->SetLineColor(i+2); if (i>2) hTime[i]->SetLineColor(i+3); hTime[i]->GetXaxis()->SetTitle("time, [ps]"); hTime[i]->GetYaxis()->SetTitle("entries, [#]"); hHitMap[i] = new TH2F(Form("hHitsMap_%d",i),"",500,-2,32,500,-10,10 ); hHitMap[i]->GetXaxis()->SetTitle("x, [cm]"); hHitMap[i]->GetYaxis()->SetTitle("y, [cm]"); } hTime[9]->SetLineColor(1); const int nmcp = 15; const int npix = 64; TH1F * hPTime[nmcp][npix]; for(Int_t m=0; mSetStats(0); hPTime[m][p]->SetLineColor(1); hPTime[m][p]->GetXaxis()->SetTitle("time, [ps]"); hPTime[m][p]->GetYaxis()->SetTitle("entries, [#]"); } } TH2F *hDigi[15]; for(int p=0; p<3*5;p++){ hDigi[p] = new TH2F( Form("mcp%d", p),Form("mcp%d", p),8,0.,8.,8,0.,8.); hDigi[p]->SetStats(0); hDigi[p]->SetTitle(0); hDigi[p]->GetXaxis()->SetNdivisions(10); hDigi[p]->GetYaxis()->SetNdivisions(10); hDigi[p]->GetXaxis()->SetLabelOffset(100); hDigi[p]->GetYaxis()->SetLabelOffset(100); hDigi[p]->GetXaxis()->SetTickLength(1); hDigi[p]->GetYaxis()->SetTickLength(1); hDigi[p]->GetXaxis()->SetAxisColor(15); hDigi[p]->GetYaxis()->SetAxisColor(15); } TH1F * hRefl = new TH1F("hRefl","Number of reflections",10,0,10); hRefl->GetXaxis()->SetTitle("reflections, [#]"); hRefl->GetYaxis()->SetTitle("entries, [#]"); TVector3 dir1, dir2; Int_t minindex; Double_t angle, minangle; for (Int_t inode=0; inodeGetEntriesFast(); inode++){ if(inode%1000==0) cout<<"Node # "<At(inode); Int_t size = node->Entries(); if(size < 1) continue; for(int i=0; iGetHitPos(i); Int_t nrefl = node->GetNRefl(i); hHitMap[nrefl]->Fill(pos.X()/10.,pos.Y()/10.); hHitMap[9]->Fill(pos.X()/10.,pos.Y()/10.); int detid = node->GetDetectorId(); int mcpid = detid/100; int pixid = detid%100; //std::cout<<"detid "<Fill(pixid/8, pixid%8); dir1 = node->GetEntry(i); hPTime[mcpid][pixid]->Fill(node->GetTime(i)); hTime[nrefl]->Fill(node->GetTime(i)); hTime[9]->Fill(node->GetTime(i)); hRefl->Fill(nrefl); Double_t pathId = node->GetPathId(i); } } TCanvas* c = new TCanvas("c","c",0,0,800,500); hHitMap[9]->Draw("colz"); save(c,path,"lut_map",info,saveflag); TCanvas* c1 = new TCanvas("c1","c1",0,0,800,500); hTime[9]->Draw(); leg = new TLegend(0.6,0.5,0.85,0.85); leg->SetFillColor(0); leg->SetBorderSize(0); for(Int_t i=0; i<6; i++){ hTime[i]->Draw("same"); leg->AddEntry(hTime[i],Form("%d reflections",i),"l"); } leg->Draw(); save(c1,path,"lut_time",info,saveflag); c1->cd(); hRefl->Draw(); save(c1,path,"lut_refl",info,saveflag); TCanvas* c2 = new TCanvas("c2","c2",0,0,800,500); TPad * pp = new TPad("P","T",0.06,0.135,0.93,0.865); pp->SetFillStyle(0); pp->Draw(); pp->cd(); Int_t nrow = 3, ncol = 5; TPad* pads[15]; float tbw, tbh, bw = 0.02, bh = 0.01, shift = 0,shiftw=-0.02; float tbw = bw, tbh = bh; int padi = 0; for(int ii=0; iiSetFillColor(kCyan-8); pads[padi]->SetMargin(0.04,0.04,0.04,0.04); pads[padi]->Draw(); padi++; } } int tmax, max=0; for(int p=0; pGetMaximum(); if(maxcd(); hDigi[p]->Draw("col"); hDigi[p]->SetMaximum(max); hDigi[p]->SetMinimum(0); for(Int_t i=1; i<=8; i++){ for(Int_t j=1; j<=8; j++){ int weight = (int)((double)(hDigi[p]->GetBinContent(i,j))/(double)max *255); if(weight > 0) data += Form("%d,%d,%d\n", p, (i-1)*8+j-1, weight); } } } c2->Modified(); c2->Update(); writeInfo("data.csv", data); TCanvas* c4 = new TCanvas("c4","c4",0,0,800,400); for(Int_t m=0; mDraw(); //c4->Modified(); // c4->Update(); // c4->WaitPrimitive(); save(c4,path,Form("time_mcp%dpix%d",m,p),info,saveflag); } } }