22 gSystem->Exec( Form(
"mkdir %s", (name+
"/"+surface_info.
name).c_str()) );
25 if(surface_info.
type == 2 || surface_info.
type == 4){
27 TText *vol =
new TText(.1,.95,surface_info.
name.c_str());
29 TText *
surface =
new TText(.1,.9,surface_info.
id.c_str());
31 TText *surface_z =
new TText(.1,.85,(
"Z = " +
to_string(surface_info.
pos)).c_str() );
34 TCanvas *c1 =
new TCanvas(
"c1",
"mat_R",1200,1200);
35 c1->SetRightMargin(0.14);
36 c1->SetTopMargin(0.14);
37 c1->SetLeftMargin(0.14);
38 c1->SetBottomMargin(0.14);
39 Map[0]->Draw(
"P HIST");
43 c1->Print( (out_name+
"_R.pdf").c_str());
46 TCanvas *
c2 =
new TCanvas(
"c2",
"mat_Phi",1200,1200);
47 c2->SetRightMargin(0.14);
48 c2->SetTopMargin(0.14);
49 c2->SetLeftMargin(0.14);
50 c2->SetBottomMargin(0.14);
51 Map[1]->Draw(
"P HIST");
55 c2->Print( (out_name+
"_Phi.pdf").c_str());
67 if(surface_info.
type == 1){
69 TText *vol =
new TText(.1,.95,surface_info.
name.c_str());
71 TText *
surface =
new TText(.1,.9,surface_info.
id.c_str());
73 TText *surface_r =
new TText(.1,.85,(
"R = " +
to_string(surface_info.
pos)).c_str() );
75 TCanvas *c1 =
new TCanvas(
"c1",
"mat_Z",1200,1200);
76 c1->SetRightMargin(0.14);
77 c1->SetTopMargin(0.14);
78 c1->SetLeftMargin(0.14);
79 c1->SetBottomMargin(0.14);
80 Map[0]->Draw(
"P HIST");
84 c1->Print( (out_name+
"_Z.pdf").c_str());
87 TCanvas *
c2 =
new TCanvas(
"c2",
"mat_Phi",1200,1200);
88 c2->SetRightMargin(0.14);
89 c2->SetTopMargin(0.14);
90 c2->SetLeftMargin(0.14);
91 c2->SetBottomMargin(0.14);
92 Map[1]->Draw(
"P HIST");
96 c2->Print( (out_name+
"_Phi.pdf").c_str());
112 const sinfo& surface_info){
117 TH1F * Map_scale_Phi;
119 if(surface_info.
type == 1){
120 Map =
new TH1F((
"Map_"+surface_info.
idname).c_str(),(
"Map_"+surface_info.
idname).c_str(),
122 Map_Phi =
new TH1F((
"Map_Phi_"+surface_info.
idname).c_str(),(
"Map_Phi_"+surface_info.
idname).c_str(),
124 Map_scale =
new TH1F((
"Map_scale_"+surface_info.
idname).c_str(),(
"Map_scale_"+surface_info.
idname).c_str(),
126 Map_scale_Phi =
new TH1F((
"Map_scale_Phi_"+surface_info.
idname).c_str(),(
"Map_scale_Phi_"+surface_info.
idname).c_str(),
128 Map->GetXaxis()->SetTitle(
"Z [mm]");
129 Map->GetYaxis()->SetTitle(
"X0");
130 Map_Phi->GetXaxis()->SetTitle(
"Phi");
131 Map_Phi->GetYaxis()->SetTitle(
"X0");
134 if(surface_info.
type == 2 || surface_info.
type == 4){
135 Map =
new TH1F((
"Map_"+surface_info.
idname).c_str(),(
"Map_"+surface_info.
idname).c_str(),
137 Map_Phi =
new TH1F((
"Map_Phi_"+surface_info.
idname).c_str(),(
"Map_Phi_"+surface_info.
idname).c_str(),
139 Map_scale =
new TH1F((
"Map_scale_"+surface_info.
idname).c_str(),(
"Map_scale_"+surface_info.
idname).c_str(),
141 Map_scale_Phi =
new TH1F((
"Map_scale_Phi_"+surface_info.
idname).c_str(),(
"Map_scale_Phi_"+surface_info.
idname).c_str(),
143 Map->GetXaxis()->SetTitle(
"R [mm]");
144 Map->GetYaxis()->SetTitle(
"X0");
145 Map_Phi->GetXaxis()->SetTitle(
"Phi");
146 Map_Phi->GetYaxis()->SetTitle(
"X0");
149 Map->SetMarkerStyle(20);
150 Map_Phi->SetMarkerStyle(20);
152 std::vector<TH1F*> v_hist;
153 v_hist.push_back(Map);
154 v_hist.push_back(Map_Phi);
155 v_hist.push_back(Map_scale);
156 v_hist.push_back(Map_scale_Phi);
157 surface_hist = v_hist;
162 void Fill(std::map<uint64_t,std::vector<TH1F*>>& surface_hist, std::map<uint64_t,sinfo>& surface_info,
164 std::map<std::string,std::string> surface_name;
165 std::map<uint64_t,float> surface_weight;
168 TFile *
tfile =
new TFile(input_file.c_str());
169 TTree *
tree = (TTree*)tfile->Get(
"material-tracks");
173 std::vector<float> *mat_X0 = 0;
174 std::vector<float> *mat_L0 = 0;
175 std::vector<float> *mat_step_length = 0;
177 std::vector<uint64_t> *sur_id = 0;
178 std::vector<int32_t> *sur_type = 0;
179 std::vector<float> *sur_x = 0;
180 std::vector<float> *sur_y = 0;
181 std::vector<float> *sur_z = 0;
182 std::vector<float> *sur_range_min = 0;
183 std::vector<float> *sur_range_max = 0;
185 tree->SetBranchAddress(
"v_phi",&v_phi);
186 tree->SetBranchAddress(
"v_eta",&v_eta);
187 tree->SetBranchAddress(
"mat_X0",&mat_X0);
188 tree->SetBranchAddress(
"mat_L0",&mat_L0);
189 tree->SetBranchAddress(
"mat_step_length",&mat_step_length);
191 tree->SetBranchAddress(
"sur_id",&sur_id);
192 tree->SetBranchAddress(
"sur_type",&sur_type);
193 tree->SetBranchAddress(
"sur_x",&sur_x);
194 tree->SetBranchAddress(
"sur_y",&sur_y);
195 tree->SetBranchAddress(
"sur_z",&sur_z);
196 tree->SetBranchAddress(
"sur_range_min",&sur_range_min);
197 tree->SetBranchAddress(
"sur_range_max",&sur_range_max);
199 int nentries = tree->GetEntries();
200 if(nentries > nbprocess && nbprocess != -1) nentries = nbprocess;
202 for (Long64_t
i=0;
i<nentries;
i++) {
203 if(
i%10000==0) std::cout <<
"processed " <<
i <<
" events out of " << nentries << std::endl;
207 for (
auto weight_it = surface_weight.begin(); weight_it != surface_weight.end(); weight_it++){
208 weight_it->second = 0;
211 for(
int j=0;
j<mat_X0->size();
j++ ){
214 if(sur_type->at(
j) == -1)
continue;
216 if(surface_hist.find(sur_id->at(
j))==surface_hist.end()){
219 if(sur_type->at(
j) == 1){
220 pos = sqrt(sur_x->at(
j)*sur_x->at(
j)+sur_y->at(
j)*sur_y->at(
j));
222 if(sur_type->at(
j) == 2 || sur_type->at(
j) == 4){
226 surface_weight[sur_id->at(
j)] = 0;
227 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));
231 surface_weight[sur_id->at(
j)]++;
235 for(
int j=0;
j<mat_X0->size();
j++ ){
238 if(sur_type->at(
j) == -1)
continue;
240 if(sur_type->at(
j) == 1){
241 surface_hist[sur_id->at(
j)][0]->Fill(sur_z->at(
j), (mat_step_length->at(
j)/mat_X0->at(
j)));
242 surface_hist[sur_id->at(
j)][1]->Fill(v_phi, (mat_step_length->at(
j)/mat_L0->at(
j)));
243 surface_hist[sur_id->at(
j)][2]->Fill(sur_z->at(
j), (1/surface_weight[sur_id->at(
j)]));
244 surface_hist[sur_id->at(
j)][3]->Fill(v_phi, (1/surface_weight[sur_id->at(
j)]));
246 if(sur_type->at(
j) == 2 || sur_type->at(
j) == 4){
247 surface_hist[sur_id->at(
j)][0]->Fill(sqrt(sur_x->at(
j)*sur_x->at(
j)+sur_y->at(
j)*sur_y->at(
j)), (mat_step_length->at(
j)/mat_X0->at(
j)));
248 surface_hist[sur_id->at(
j)][1]->Fill(v_phi, (mat_step_length->at(
j)/mat_L0->at(
j)));
249 surface_hist[sur_id->at(
j)][2]->Fill(sqrt(sur_x->at(
j)*sur_x->at(
j)+sur_y->at(
j)*sur_y->at(
j)), (1/surface_weight[sur_id->at(
j)]));
250 surface_hist[sur_id->at(
j)][3]->Fill(v_phi, (1/surface_weight[sur_id->at(
j)]));
255 for (
auto hist_it = surface_hist.begin(); hist_it != surface_hist.end(); hist_it++){
256 hist_it->second[0]->Divide(hist_it->second[2]);
257 hist_it->second[1]->Divide(hist_it->second[3]);
267 gStyle->SetOptStat(0);
268 gStyle->SetOptTitle(0);
270 std::map<uint64_t,std::vector<TH1F*>> surface_hist;
271 std::map<uint64_t,sinfo> surface_info;
274 for (
auto hist_it = surface_hist.begin(); hist_it != surface_hist.end(); hist_it++){
275 plot(hist_it->second, surface_info[hist_it->first],
name);
276 for (
auto hist : hist_it->second){
279 hist_it->second.clear();