19 void plot(std::vector<TH2F*> Map, std::vector<int> detectors,
const std::string&
name){
21 std::string sVol =
"Detector volumes :";
22 for(
auto const& det: detectors) {
26 TText *vol =
new TText(.1, .95, sVol.c_str());
29 TCanvas *
c1 =
new TCanvas(
"c1",
"mat_X0",1200,1200);
30 c1->SetRightMargin(0.14);
31 c1->SetTopMargin(0.14);
32 c1->SetLeftMargin(0.14);
33 c1->SetBottomMargin(0.14);
36 c1->Print( (name+
"X0.pdf").c_str());
38 TH2F *Unit_Map = (TH2F*) Map[2]->Clone();
39 Unit_Map->Divide(Map[2]);
40 TCanvas *
c2 =
new TCanvas(
"c2",
"mat_X0/eta", 1200, 1200);
41 c2->SetRightMargin(0.14);
42 c2->SetTopMargin(0.14);
43 c2->SetLeftMargin(0.14);
44 c2->SetBottomMargin(0.14);
45 TH1D *Proj_eta = Map[0]->ProjectionX();
46 Proj_eta->Divide(Unit_Map->ProjectionX());
47 Proj_eta->GetYaxis()->SetTitle(
"X0");
48 Proj_eta->SetMarkerStyle(7);
49 Proj_eta->Draw(
"HIST PC");
50 c2->Print( (name+
"X0_eta.pdf").c_str());
51 TCanvas *
c3 =
new TCanvas(
"c3",
"mat_X0/phi", 1200, 1200);
52 c3->SetRightMargin(0.14);
53 c3->SetTopMargin(0.14);
54 c3->SetLeftMargin(0.14);
55 c3->SetBottomMargin(0.14);
56 TH1D *Proj_phi = Map[0]->ProjectionY();
57 Proj_phi->Divide(Unit_Map->ProjectionY());
58 Proj_phi->GetYaxis()->SetTitle(
"X0");
59 Proj_phi->SetMarkerStyle(7);
60 Proj_phi->Draw(
"HIST PC");
61 c3->Print( (name+
"X0_phi.pdf").c_str());
79 Map_X0 =
new TH2F(
"Map_X0_detector",
"Map_X0_detector",
80 100,-6,6,50,-3.2,3.2);
81 Map_L0 =
new TH2F(
"Map_L0_detector",
"Map_L0_detector",
82 100,-6,6,50,-3.2,3.2);
83 Map_scale =
new TH2F(
"Map_Scale_detector",
"Map_Scale_detector",
84 100,-6,6,50,-3.2,3.2);
85 Map_X0->GetXaxis()->SetTitle(
"Eta");
86 Map_X0->GetYaxis()->SetTitle(
"Phi");
87 Map_X0->GetZaxis()->SetTitle(
"X0");
88 Map_L0->GetXaxis()->SetTitle(
"Eta");
89 Map_L0->GetYaxis()->SetTitle(
"Phi");
90 Map_L0->GetZaxis()->SetTitle(
"L0");
91 std::vector<TH2F*> v_hist;
92 v_hist.push_back(Map_X0);
93 v_hist.push_back(Map_L0);
94 v_hist.push_back(Map_scale);
95 detector_hist = v_hist;
100 void Fill(std::vector<TH2F*>& detector_hist,
const std::string& input_file, std::vector<int> detectors,
const int& nbprocess){
106 TFile *tfile =
new TFile(input_file.c_str());
107 TTree *tree = (TTree*)tfile->Get(
"material-tracks");
112 std::vector<float> *mat_X0 = 0;
113 std::vector<float> *mat_L0 = 0;
114 std::vector<float> *mat_x = 0;
115 std::vector<float> *mat_y = 0;
116 std::vector<float> *mat_step_length = 0;
118 std::vector<uint64_t> *sur_id = 0;
119 std::vector<int32_t> *sur_type = 0;
121 std::vector<uint64_t> *vol_id = 0;
123 tree->SetBranchAddress(
"v_phi",&v_phi);
124 tree->SetBranchAddress(
"v_eta",&v_eta);
125 tree->SetBranchAddress(
"t_X0",&t_X0);
126 tree->SetBranchAddress(
"mat_X0",&mat_X0);
127 tree->SetBranchAddress(
"mat_L0",&mat_L0);
128 tree->SetBranchAddress(
"mat_step_length",&mat_step_length);
130 tree->SetBranchAddress(
"sur_id",&sur_id);
131 tree->SetBranchAddress(
"sur_type",&sur_type);
133 tree->SetBranchAddress(
"vol_id",&vol_id);
135 int nentries = tree->GetEntries();
136 if(nentries > nbprocess && nbprocess != -1) nentries = nbprocess;
138 for (Long64_t i=0;i<nentries; i++) {
139 if(i%10000==0) std::cout <<
"processed " << i <<
" events out of " << nentries << std::endl;
146 for(
int j=0; j<mat_X0->size()-1; j++ ){
150 if(sur_id->at(j) != 0){
153 else if(vol_id->at(j) != 0){
158 if(std::find(detectors.begin(), detectors.end(), ID.
volume()) != detectors.end()) {
159 matX0 += mat_step_length->at(j) / mat_X0->at(j);
160 matL0 += mat_step_length->at(j) / mat_L0->at(j);
164 if (matX0 != 0 && matL0 != 0){
165 detector_hist[0]->Fill(v_eta, v_phi, matX0);
166 detector_hist[1]->Fill(v_eta, v_phi, matL0);
167 detector_hist[2]->Fill(v_eta, v_phi);
170 detector_hist[0]->Divide(detector_hist[2]);
171 detector_hist[1]->Divide(detector_hist[2]);
180 std::vector<int> detectors = vector<int>(),
int nbprocess = -1,
181 std::string
name =
"") {
182 gStyle->SetOptStat(0);
183 gStyle->SetOptTitle(0);
185 std::vector<TH2F*> detector_hist;
187 Fill(detector_hist, input_file, detectors, nbprocess);
188 plot(detector_hist, detectors,
name);