#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "/home/wxz/Downloads/allpix-squared-v1.4/src/objects/DepositedCharge.hpp" #include "/home/wxz/Downloads/allpix-squared-v1.4/src/objects/MCParticle.hpp" #include "/home/wxz/Downloads/allpix-squared-v1.4/src/objects/MCTrack.hpp" #include "/home/wxz/Downloads/allpix-squared-v1.4/src/objects/PropagatedCharge.hpp" #include "/home/wxz/Downloads/allpix-squared-v1.4/src/objects/PixelCharge.hpp" #include "/home/wxz/Downloads/allpix-squared-v1.4/src/objects/SensorCharge.hpp" //readpc2d.C //function: read the propagated charge objects from root file and create a series of propagated charge distribution images in 2d view //file: pointer to the TFile object to be read //detector: name of the branch to be read // void readpc2d(TFile* file,std::string detector) { //prepare to read tree from file TTree* PropagatedCharge_tree=static_cast(file->Get("PropagatedCharge")); TBranch* PropagatedCharge_branch=PropagatedCharge_tree->FindBranch(detector.c_str()); std::vector propagated_charges; PropagatedCharge_branch->SetObject(&propagated_charges); TCanvas* cpc_2d=new TCanvas("cpc_2d","",800,600); TCanvas* cpc_1d=new TCanvas("cpc_1d","",800,600); gROOT->cd(); TNtuple* npc=new TNtuple("n","n","x:y:z:charge"); npc->SetMarkerStyle(20); npc->SetMarkerSize(0.1); unsigned long pc_total_charge_count=0; for(int i=0;i<10;i++)//PropagatedCharge_tree->GetEntries();++i) { PropagatedCharge_tree->GetEntry(i); float x,y,z; //local position unsigned long q; //charge unsigned long pc_event_charge_count=0; for(auto& propagated_charge:propagated_charges) { x=propagated_charge->getLocalPosition().X(); y=propagated_charge->getLocalPosition().Y(); z=propagated_charge->getLocalPosition().Z(); q=propagated_charge->getCharge(); npc->Fill(x*1000.0,y*1000.0,z*1000.0,q);//convert to um pc_total_charge_count+=q; pc_event_charge_count+=q; } cpc_2d->cd(); npc->Draw("y:x"); TH2F* htemp=(TH2F*)gPad->GetPrimitive("htemp"); htemp->GetXaxis()->SetLimits(-1000,1000); //std::cout<<"sigma x:"<GetStdDev(1)<<" sigma y:"<GetStdDev(2)<<"mean :"<GetMean(1)<GetMean(2)<GetMean(3)<GetXaxis()->SetTitle("x [um]"); htemp->GetXaxis()->SetTitleOffset(1.5); //htemp->GetXaxis()->SetTitleSize(0.05); htemp->GetXaxis()->SetLabelSize(0.04); htemp->GetYaxis()->SetLimits(-1000,1000); htemp->GetYaxis()->SetTitle("y [um]"); htemp->GetYaxis()->SetTitleOffset(1.5); //htemp->GetYaxis()->SetTitleSize(0.05); htemp->GetYaxis()->SetLabelSize(0.04); std::string pc_2d="image/propagated_charge/pc_distribution_2d_"+std::to_string(i)+".png"; cpc_2d->SaveAs(pc_2d.c_str()); } //std::cout<<"The total number of propageted charge entries is "<Draw("z:x:y:charge");//when Draw() is called ,a temp object is generated //TH3F* h3temp=(TH3F*)gPad->GetPrimitive("htemp"); //std::string pc_3d="image/general/pc_distribution_3d_"+std::to_string(PropagatedCharge_tree->GetEntries())+".png"; //cpc_3d->SaveAs(pc_3d.c_str()); //cpc_2d->cd(); //npc_2d->Draw("y:x"); //std::string pc_2d="image/general/pc_distribution_2d_"+std::to_string(PropagatedCharge_tree->GetEntries())+".png"; //cpc_2d->SaveAs(pc_2d.c_str()); cpc_1d->cd(); npc->Draw("x"); TH1F* h1=(TH1F*)gPad->GetPrimitive("htemp"); std::cout<<"sigma x:"<GetStdDev(1)<GetEntries())+".png"; //cpc_1d->SaveAs(pc_x.c_str()); //npc->Draw("y"); //std::string pc_y="image/propagated_charge/pc_distribution_y_"+std::to_string(PropagatedCharge_tree->GetEntries())+".png"; //cpc_1d->SaveAs(pc_y.c_str()); return; }