// #include "TROOT.h" // #include "TSystem.h" // #include "TStyle.h" // #include "TCanvas.h" // #include "TPad.h" // #include "TH1.h" // #include "TH2.h" // #include "TF1.h" // #include "TFile.h" // #include "TTree.h" // #include "TClonesArray.h" // #include "TVector3.h" // #include "TMath.h" // #include "TChain.h" // #include // #include // #include "prt/PrtHit.h" // #include "prt/PrtEvent.h" TH2D* hist[9]; #include "save.C" TCanvas* c2 = new TCanvas("c2","c2",900,600); void drawMcpanim(TString path = ".", TString name = ""){ Int_t saveflag = -1; TString info = "hits"; path = createDir("rdata", info, saveflag); 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); gSystem->Load("../build/libprtlib.so"); //gStyle->SetOptStat(0); Int_t referenceTime; Int_t referenceChannel; // TH2F *hist1 = new TH2F("name","name",500,-3,19,500,-10,10 ); TH2F *hist1 = new TH2F("hHist","",500,-2,32,500,-10,10 ); hist1->GetXaxis()->SetTitle("x, [cm]"); hist1->GetYaxis()->SetTitle("y, [cm]"); hist1->GetXaxis()->SetTitleOffset(1.15); hist1->GetYaxis()->SetTitleOffset(1.2); TH2F *hVertex = new TH2F("hVertex","",5000,-2,2, 1000,-10,10 ); hist1->SetStats(0); hVertex->SetStats(0); TH1F *hTime[4]; for(Int_t i=0; i<4; i++){ hTime[i] = new TH1F(Form("id - %d", i),Form("id%d", i),500,0,25); hTime[i]->SetLineColor(i+1); } Int_t startInd = 0; for(int i=0; i<9;i++){ hist[i] = new TH2D( Form("mcp - %d", i+startInd),Form("%d", i+startInd),8,0.,8.,8,0.,8.); hist[i]->SetStats(0); hist[i]->GetXaxis()->SetNdivisions(10); hist[i]->GetYaxis()->SetNdivisions(10); hist[i]->GetXaxis()->SetLabelOffset(100); hist[i]->GetYaxis()->SetLabelOffset(100); hist[i]->GetXaxis()->SetTickLength(1); hist[i]->GetYaxis()->SetTickLength(1); hist[i]->GetXaxis()->SetAxisColor(15); hist[i]->GetYaxis()->SetAxisColor(15); // hist[i]->SetLineColor(ci); } PrtEvent* fEvent = 0; PrtHit hit; TChain *ch = new TChain("data"); ch->Add("../build/hits0.root"); // ch->Add("/SAT/hera/had1/dervish/data/prt/iii/hits*.root"); // ch->Add("../data/hitsIL100k.root"); ch->SetBranchAddress("PrtEvent", &fEvent); std::cout<<"ch->GetEntries() "<< ch->GetEntries()<GetEntries(); ievent++){ ch->GetEntry(ievent); if(ievent%100==0) cout<<"Event # "<GetHitSize(); h++){ hit = fEvent->GetHit(h); // std::cout<<"x "<Fill(hit.GetLocalPos().X(),hit.GetLocalPos().Y()); // if(hit.GetPixelId()/8==7 && hit.GetPixelId()%8 ==0) //if(hit.GetMcpId() ==6) Double_t time = hit.GetLeadTime(0); if(time(i-1)*200){ //hist[hit.GetMcpId()-startInd]->Fill((hit.GetPixelId()-startInd)/8, (hit.GetPixelId()-startInd)%8); hist1->Fill(hit.GetGlobalPos().X()/10.,hit.GetGlobalPos().Y()/10.); } // if(hit.GetNreflectionsInPrizm() < 5) for(Int_t k=0; k<4; k++){ hTime[k]->Fill(hit.GetLeadTime(k)/1000.); } } } c2->cd(); hist1->SetTitle(Form("%f ns",i*0.2)); hist1->Draw("colz"); c2->Modified(); c2->Update(); save(c2,path,Form("animtime_%d",i),info,saveflag); hist1->Reset(); } int tmax, max=0; for(int i=0; i<9;i++){ tmax = hist[i]->GetMaximum(); if(maxSetFillColor(kCyan-5); //pads[padi]->SetFrameFillColor(ci); pads[padi]->SetMargin(0.04,0.04,0.04,0.04); pads[padi]->Draw(); padi++; } } for(int i=0; i<9;i++){ pads[i]->cd(); hist[i]->Draw("col"); hist[i]->SetMaximum(max); } Int_t nofe = hist1->GetEntries(); std::cout<<"nofe "<SetTitle(Form("%d hits",nofe)); hist1->GetXaxis()->SetTitle("x, [cm]"); hist1->GetYaxis()->SetTitle("y, [cm]"); hist1->GetXaxis()->SetTitleOffset(1.15); hist1->GetYaxis()->SetTitleOffset(1.2); hist1->Draw("colz"); TGaxis::SetMaxDigits(3); gStyle->SetOptStat(111); TCanvas* c3 = new TCanvas("c3","c3",900,400); for(Int_t i=0; i<4; i++){ hTime[i]->SetTitle(0); hTime[i]->GetXaxis()->SetTitle("time, [ns]"); hTime[i]->GetYaxis()->SetTitle("entries, [#]"); hTime[i]->GetXaxis()->SetTitleSize(0.05); hTime[i]->GetYaxis()->SetTitleSize(0.05); hTime[i]->GetXaxis()->SetTitleOffset(0.85); hTime[i]->GetYaxis()->SetTitleOffset(0.45); if(i==0) hTime[i]->Draw(); //else hTime[i]->Draw("same"); } TCanvas* c4 = new TCanvas("c4","c4",900,600); TPad *pad1 = new TPad("pad1", "The pad 60% of the height", 0.7,0, 1.0,1.0, 0); TPad *pad2 = new TPad("pad2", "The pad 40% of the height", 0,0.0, 0.7,1.0, 0); pad1->Draw(); pad2->Draw(); pad2->cd(); hist1->Draw("colz"); pad1->cd(); hVertex->GetXaxis()->SetTitle("y, [mm]"); hVertex->GetYaxis()->SetTitle("z, [mm]"); hVertex->Draw("colz"); c1->Print(path+"/digi"+name+".png"); c2->Print(path+"/sim"+name+".png"); c3->Print(path+"/time"+name+".png"); }