18 void plot(TGraph* Dist,
const sinfo& surface_info,
const std::string&
name){
20 std::string out_name = name+
"/"+surface_info.
name+
"/"+surface_info.
name+
"_"+surface_info.
idname;
21 gSystem->Exec( Form(
"mkdir %s", (name+
"/"+surface_info.
name).c_str()) );
23 TCanvas *
c =
new TCanvas(
"c",
"dist",1200,1200);
24 c->SetRightMargin(0.14);
25 c->SetTopMargin(0.14);
26 c->SetLeftMargin(0.14);
27 c->SetBottomMargin(0.14);
32 TText *vol =
new TText(.1,.95,surface_info.
name.c_str());
33 TText *
surface =
new TText(.1,.9,surface_info.
id.c_str());
34 TText *surface_z =
new TText(.1,.85,(
"Z = " +
to_string(surface_info.
pos)).c_str() );
35 TText *surface_r =
new TText(.1,.85,(
"R = " +
to_string(surface_info.
pos)).c_str() );
42 if(surface_info.
type == 2){
52 line_pos->SetLineColor(kRed);
53 line_pos->Draw(
"Same");
57 if(surface_info.
type == 1){
67 line_pos->SetLineColor(kRed);
68 line_pos->Draw(
"Same");
71 c->Print( (out_name+
"_Dist.pdf").c_str());
86 const std::pair<std::vector<float>,std::vector<float>>& surface_pos,
const sinfo& surface_info){
88 if(surface_info.
type != -1){
89 TGraph * Dist =
new TGraph(surface_pos.first.size(), &surface_pos.second[0], &surface_pos.first[0]);
91 Dist->GetXaxis()->SetTitle(
"Z [mm]");
92 Dist->GetYaxis()->SetTitle(
"R [mm]");
99 void Fill(std::map<uint64_t,TGraph*>& surface_hist, std::map<uint64_t,sinfo>& surface_info,
100 const std::string& input_file,
const std::string& json_surface_file,
const int& nbprocess){
103 std::map<std::string,std::string> surface_name;
105 if(json_surface_file !=
""){
106 std::ifstream lfile(json_surface_file.c_str());
112 std::map<uint64_t,std::pair<std::vector<float>,std::vector<float>>> surface_pos;
115 TFile *tfile =
new TFile(input_file.c_str());
116 TTree *
tree = (TTree*)tfile->Get(
"material-tracks");
118 std::vector<float> *mat_x = 0;
119 std::vector<float> *mat_y = 0;
120 std::vector<float> *mat_z = 0;
122 std::vector<uint64_t> *sur_id = 0;
123 std::vector<int32_t> *sur_type = 0;
124 std::vector<float> *sur_x = 0;
125 std::vector<float> *sur_y = 0;
126 std::vector<float> *sur_z = 0;
127 std::vector<float> *sur_range_min = 0;
128 std::vector<float> *sur_range_max = 0;
130 tree->SetBranchAddress(
"mat_x",&mat_x);
131 tree->SetBranchAddress(
"mat_y",&mat_y);
132 tree->SetBranchAddress(
"mat_z",&mat_z);
134 tree->SetBranchAddress(
"sur_id",&sur_id);
135 tree->SetBranchAddress(
"sur_type",&sur_type);
136 tree->SetBranchAddress(
"sur_x",&sur_x);
137 tree->SetBranchAddress(
"sur_y",&sur_y);
138 tree->SetBranchAddress(
"sur_z",&sur_z);
139 tree->SetBranchAddress(
"sur_range_min",&sur_range_min);
140 tree->SetBranchAddress(
"sur_range_max",&sur_range_max);
143 if(nentries > nbprocess && nbprocess != -1) nentries = nbprocess;
146 if(nentries > 10000){
148 std::cout <<
"Number of event reduced to 10000" << std::endl;
151 for (Long64_t i=0;i<
nentries; i++) {
152 if(i%1000==0) std::cout <<
"processed " << i <<
" events out of " << nentries << std::endl;
156 for(
int j=0; j<mat_x->size(); j++ ){
159 if(sur_type->at(j) == -1)
continue;
162 if(surface_hist.find(sur_id->at(j))==surface_hist.end()){
166 if(sur_type->at(j) == 1){
167 pos = sqrt(sur_x->at(j)*sur_x->at(j)+sur_y->at(j)*sur_y->at(j));
169 if(sur_type->at(j) == 2){
172 Initialise_info(surface_info[sur_id->at(j)], surface_name, sur_id->at(j), sur_type->at(j),
pos, sur_range_min->at(j), sur_range_max->at(j));
175 surface_pos[sur_id->at(j)].first.push_back(sqrt(mat_y->at(j)*mat_y->at(j)+mat_x->at(j)*mat_x->at(j)));
176 surface_pos[sur_id->at(j)].second.push_back(mat_z->at(j));
181 for (
auto pos_it = surface_pos.begin(); pos_it != surface_pos.end(); pos_it++){
182 Initialise_hist(surface_hist[pos_it->first], pos_it->second, surface_info[pos_it->first]);
196 gStyle->SetOptStat(0);
197 gStyle->SetOptTitle(0);
199 std::map<uint64_t,TGraph*> surface_hist;
200 std::map<uint64_t,sinfo> surface_info;
201 Fill(surface_hist, surface_info, input_file, json_surface_file, nbprocess);
202 for (
auto hist_it = surface_hist.begin(); hist_it != surface_hist.end(); hist_it++){
204 plot(hist_it->second, surface_info[hist_it->first],
name);