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 || surface_info.
type == 4){
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,
101 std::map<std::string,std::string> surface_name;
102 std::map<uint64_t,std::pair<std::vector<float>,std::vector<float>>> surface_pos;
105 TFile *
tfile =
new TFile(input_file.c_str());
106 TTree *
tree = (TTree*)tfile->Get(
"material-tracks");
108 std::vector<float> *mat_x = 0;
109 std::vector<float> *mat_y = 0;
110 std::vector<float> *mat_z = 0;
112 std::vector<uint64_t> *sur_id = 0;
113 std::vector<int32_t> *sur_type = 0;
114 std::vector<float> *sur_x = 0;
115 std::vector<float> *sur_y = 0;
116 std::vector<float> *sur_z = 0;
117 std::vector<float> *sur_range_min = 0;
118 std::vector<float> *sur_range_max = 0;
120 tree->SetBranchAddress(
"mat_x",&mat_x);
121 tree->SetBranchAddress(
"mat_y",&mat_y);
122 tree->SetBranchAddress(
"mat_z",&mat_z);
124 tree->SetBranchAddress(
"sur_id",&sur_id);
125 tree->SetBranchAddress(
"sur_type",&sur_type);
126 tree->SetBranchAddress(
"sur_x",&sur_x);
127 tree->SetBranchAddress(
"sur_y",&sur_y);
128 tree->SetBranchAddress(
"sur_z",&sur_z);
129 tree->SetBranchAddress(
"sur_range_min",&sur_range_min);
130 tree->SetBranchAddress(
"sur_range_max",&sur_range_max);
132 int nentries = tree->GetEntries();
133 if(nentries > nbprocess && nbprocess != -1) nentries = nbprocess;
136 if(nentries > 10000){
138 std::cout <<
"Number of event reduced to 10000" << std::endl;
141 for (Long64_t
i=0;
i<nentries;
i++) {
142 if(
i%1000==0) std::cout <<
"processed " <<
i <<
" events out of " << nentries << std::endl;
146 for(
int j=0;
j<mat_x->size();
j++ ){
149 if(sur_type->at(
j) == -1)
continue;
152 if(surface_hist.find(sur_id->at(
j))==surface_hist.end()){
156 if(sur_type->at(
j) == 1){
157 pos = sqrt(sur_x->at(
j)*sur_x->at(
j)+sur_y->at(
j)*sur_y->at(
j));
159 if(sur_type->at(
j) == 2 || sur_type->at(
j) == 4){
162 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));
165 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)));
166 surface_pos[sur_id->at(
j)].second.push_back(mat_z->at(
j));
171 for (
auto pos_it = surface_pos.begin(); pos_it != surface_pos.end(); pos_it++){
172 Initialise_hist(surface_hist[pos_it->first], pos_it->second, surface_info[pos_it->first]);
184 gStyle->SetOptStat(0);
185 gStyle->SetOptTitle(0);
187 std::map<uint64_t,TGraph*> surface_hist;
188 std::map<uint64_t,sinfo> surface_info;
190 for (
auto hist_it = surface_hist.begin(); hist_it != surface_hist.end(); hist_it++){
192 plot(hist_it->second, surface_info[hist_it->first],
name);