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_X0",1200,1200);
35 c1->SetRightMargin(0.14);
36 c1->SetTopMargin(0.14);
37 c1->SetLeftMargin(0.14);
38 c1->SetBottomMargin(0.14);
43 c1->Print( (out_name+
"_X0.pdf").c_str());
54 if(surface_info.
type == 1){
56 TText *vol =
new TText(.1,.95,surface_info.
name.c_str());
58 TText *
surface =
new TText(.1,.9,surface_info.
id.c_str());
60 TText *surface_r =
new TText(.1,.85,(
"R = " +
to_string(surface_info.
pos)).c_str() );
62 TCanvas *c1 =
new TCanvas(
"c1",
"mat_X0",1200,1200);
63 c1->SetRightMargin(0.14);
64 c1->SetTopMargin(0.14);
65 c1->SetLeftMargin(0.14);
66 c1->SetBottomMargin(0.14);
71 c1->Print( (out_name+
"_X0.pdf").c_str());
86 const sinfo& surface_info){
93 if(surface_info.
type == 1){
94 Map_X0 =
new TH2F((
"Map_X0_"+surface_info.
idname).c_str(),(
"Map_X0_"+surface_info.
idname).c_str(),
96 Map_L0 =
new TH2F((
"Map_L0_"+surface_info.
idname).c_str(),(
"Map_L0_"+surface_info.
idname).c_str(),
98 Map_scale =
new TH2F((
"Map_scale_"+surface_info.
idname).c_str(),(
"Map_scale_"+surface_info.
idname).c_str(),
100 Map_X0->GetXaxis()->SetTitle(
"Eta");
101 Map_X0->GetYaxis()->SetTitle(
"Phi");
102 Map_X0->GetZaxis()->SetTitle(
"X0");
103 Map_L0->GetXaxis()->SetTitle(
"Eta");
104 Map_L0->GetYaxis()->SetTitle(
"Phi");
105 Map_L0->GetZaxis()->SetTitle(
"L0");
108 if(surface_info.
type == 2 || surface_info.
type == 4){
109 Map_X0 =
new TH2F((
"Map_X0_"+surface_info.
idname).c_str(),(
"Map_X0_"+surface_info.
idname).c_str(),
111 Map_L0 =
new TH2F((
"Map_L0_"+surface_info.
idname).c_str(),(
"Map_L0_"+surface_info.
idname).c_str(),
113 Map_scale =
new TH2F((
"Map_scale_"+surface_info.
idname).c_str(),(
"Map_scale_"+surface_info.
idname).c_str(),
115 Map_X0->GetXaxis()->SetTitle(
"X [mm]");
116 Map_X0->GetYaxis()->SetTitle(
"Y [mm]");
117 Map_X0->GetZaxis()->SetTitle(
"X0");
118 Map_L0->GetXaxis()->SetTitle(
"X [mm]");
119 Map_L0->GetYaxis()->SetTitle(
"Y [mm]");
120 Map_L0->GetZaxis()->SetTitle(
"L0");
122 std::vector<TH2F*> v_hist;
123 v_hist.push_back(Map_X0);
124 v_hist.push_back(Map_L0);
125 v_hist.push_back(Map_scale);
126 surface_hist = v_hist;
131 void Fill(std::map<uint64_t,std::vector<TH2F*>>& surface_hist, std::map<uint64_t,sinfo>& surface_info,
134 std::map<std::string,std::string> surface_name;
136 std::map<uint64_t,float> surface_weight;
139 TFile *
tfile =
new TFile(input_file.c_str());
140 TTree *
tree = (TTree*)tfile->Get(
"material-tracks");
144 std::vector<float> *mat_X0 = 0;
145 std::vector<float> *mat_L0 = 0;
146 std::vector<float> *mat_step_length = 0;
148 std::vector<uint64_t> *sur_id = 0;
149 std::vector<int32_t> *sur_type = 0;
150 std::vector<float> *sur_x = 0;
151 std::vector<float> *sur_y = 0;
152 std::vector<float> *sur_z = 0;
153 std::vector<float> *sur_range_min = 0;
154 std::vector<float> *sur_range_max = 0;
156 tree->SetBranchAddress(
"v_phi",&v_phi);
157 tree->SetBranchAddress(
"v_eta",&v_eta);
158 tree->SetBranchAddress(
"mat_X0",&mat_X0);
159 tree->SetBranchAddress(
"mat_L0",&mat_L0);
160 tree->SetBranchAddress(
"mat_step_length",&mat_step_length);
162 tree->SetBranchAddress(
"sur_id",&sur_id);
163 tree->SetBranchAddress(
"sur_type",&sur_type);
164 tree->SetBranchAddress(
"sur_x",&sur_x);
165 tree->SetBranchAddress(
"sur_y",&sur_y);
166 tree->SetBranchAddress(
"sur_z",&sur_z);
167 tree->SetBranchAddress(
"sur_range_min",&sur_range_min);
168 tree->SetBranchAddress(
"sur_range_max",&sur_range_max);
170 int nentries = tree->GetEntries();
171 if(nentries > nbprocess && nbprocess != -1) nentries = nbprocess;
173 for (Long64_t
i=0;
i<nentries;
i++) {
174 if(
i%10000==0) std::cout <<
"processed " <<
i <<
" events out of " << nentries << std::endl;
178 for (
auto weight_it = surface_weight.begin(); weight_it != surface_weight.end(); weight_it++){
179 weight_it->second = 0;
182 for(
int j=0;
j<mat_X0->size();
j++ ){
185 if(sur_type->at(
j) == -1)
continue;
187 if(surface_hist.find(sur_id->at(
j))==surface_hist.end()){
189 if(sur_type->at(
j) == 1){
190 pos = sqrt(sur_x->at(
j)*sur_x->at(
j)+sur_y->at(
j)*sur_y->at(
j));
192 if(sur_type->at(
j) == 2 || sur_type->at(
j) == 4){
195 surface_weight[sur_id->at(
j)] = 0;
196 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));
200 surface_weight[sur_id->at(
j)]++;
204 for(
int j=0;
j<mat_X0->size();
j++ ){
207 if(sur_type->at(
j) == -1)
continue;
209 if(sur_type->at(
j) == 1){
210 surface_hist[sur_id->at(
j)][0]->Fill(v_eta, v_phi, (mat_step_length->at(
j)/mat_X0->at(
j)));
211 surface_hist[sur_id->at(
j)][1]->Fill(v_eta, v_phi, (mat_step_length->at(
j)/mat_L0->at(
j)));
212 surface_hist[sur_id->at(
j)][2]->Fill(v_eta, v_phi, (1/surface_weight[sur_id->at(
j)]));
214 if(sur_type->at(
j) == 2 || sur_type->at(
j) == 4){
215 surface_hist[sur_id->at(
j)][0]->Fill(sur_x->at(
j), sur_y->at(
j), (mat_step_length->at(
j)/mat_X0->at(
j)));
216 surface_hist[sur_id->at(
j)][1]->Fill(sur_x->at(
j), sur_y->at(
j), (mat_step_length->at(
j)/mat_L0->at(
j)));
217 surface_hist[sur_id->at(
j)][2]->Fill(sur_x->at(
j), sur_y->at(
j), (1/surface_weight[sur_id->at(
j)]));
222 for (
auto hist_it = surface_hist.begin(); hist_it != surface_hist.end(); hist_it++){
223 hist_it->second[0]->Divide(hist_it->second[2]);
224 hist_it->second[1]->Divide(hist_it->second[2]);
234 gStyle->SetOptStat(0);
235 gStyle->SetOptTitle(0);
237 std::map<uint64_t,std::vector<TH2F*>> surface_hist;
238 std::map<uint64_t,sinfo> surface_info;
241 for (
auto hist_it = surface_hist.begin(); hist_it != surface_hist.end(); hist_it++){
242 plot(hist_it->second, surface_info[hist_it->first],
name);
243 for (
auto hist : hist_it->second){
246 hist_it->second.clear();