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); }
void Render(uint frameTimeMS, double canvasWidth, double canvasHeight, const TConfig& config) { uint bottom = config.top + config.height; const double scaleMin = 0.5; const double scaleMax = 1.7; const double rotationMaximum = 0.5;// 0 - 1=90 deg. const double rotationSpeedX = 0.15; const double rotationSpeedY = 0.09; const double opacityMin = 0.3; const double opacityMax = 0.65; const double twinkleSpeed = 0.09; const double twinkleThreshold = 0.93; // these two will adjust the twinkle effect. it affects opacity of the square, and the color. both of these are 0-1. const double maxTwinkleOpacity = 0.5; const double twinkleBrightness = 0.5; if(config.xflip) { squareFieldXFlip(canvasWidth / 2); } else { canvasSave(); } // when modulating envelopes, how much does x/y dimension affect the // envelope progression? // values 0-20 will be plasma-like; higher can start to look more sharp / twinkly double dimensionMult = 20; int previousRowWidth = -1; int rowWidth = -1; for(uint y = config.top; y < bottom; y += config.blockSizeY) { uint iy = (y - config.top) / config.blockSizeY; previousRowWidth = rowWidth; rowWidth = config.RowWidth(y, config.top, bottom, canvasWidth, canvasHeight); if(previousRowWidth == -1) previousRowWidth = rowWidth; uint right = config.left + rowWidth; for(uint x = config.left; x < rowWidth; x += config.blockSizeX) { uint ix = (x - config.left) / config.blockSizeX; //squareFieldRenderSquare(0.5, 0.5, 0.5, 0.5, 0xff00ff, 0.5, 8); bool isOdd = ((ix & 1) == (iy & 1));// checkerboard if(!config.oddFillEnabled && isOdd) continue; if(!config.evenFillEnabled && !isOdd) continue; const TheModColorMixingTable<ColorMixingSteps>& fillColorTable(isOdd ? config.oddColorTable : config.evenColorTable); double xalphaVary = (config.opacityXEnv.height((dimensionMult * x) + frameTimeMS) + 1) / 2; double yalphaVary = (config.opacityYEnv.height((dimensionMult * y) + frameTimeMS) + 1) / 2; double userAlpha = config.Opacity(x, y, config.top, bottom, config.left, right, previousRowWidth, rowWidth, ix, iy); double aa = 1.0;// anti-alias damping if(((x - config.left) + config.blockSizeX) > rowWidth) { // "big" anti-alias this block. aa = double(rowWidth - (x - config.left)) / config.blockSizeX; } double alpha = xalphaVary * yalphaVary * aa; // now scale alpha to opacityMin / Max double opacity = opacityMin + (alpha * (opacityMax - opacityMin)); double blockScale = (scaleMin + ((scaleMax - scaleMin) * alpha * userAlpha)); double thisBlockSizeX = blockScale * config.blockSizeX; // this is actually incorrect; for a true grid use blockSizeX / Y, but this gives a cool effect that things are sorta wavy / bulgy double xtrans = (double)x + ((double)thisBlockSizeX / 2); double ytrans = (double)y + ((double)config.blockSizeY / 2); double twinkleFactor = CachedRandEnvelope(ix, iy, twinkleSpeed).factor(frameTimeMS); TheModColor fillStyle; double finalOpacity; if(twinkleFactor < twinkleThreshold) { finalOpacity = opacity * userAlpha; fillStyle = fillColorTable.c1; } else { // scale it to 0-1 twinkleFactor = (twinkleFactor - twinkleThreshold) / (1.0 - twinkleThreshold); double twinkleOpacity = twinkleFactor * maxTwinkleOpacity; finalOpacity = (1.0 - (opacity * userAlpha)) * twinkleOpacity; finalOpacity += (opacity * userAlpha); fillStyle = fillColorTable.GetColor(twinkleFactor * twinkleBrightness); } double rotation = 2.0 * pi() * finalOpacity; squareFieldRenderSquare(finalOpacity, xtrans, ytrans, rotation, fillStyle, -(thisBlockSizeX / 2), thisBlockSizeX); }// X }// Y canvasRestore(); }
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(); }
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); }