FairRoot/PandaRoot
sandbox.C
Go to the documentation of this file.
1 #include<TString.h>
2 #include<TH1.h>
3 #include<TH2.h>
4 #include<sstream>
5 #include<iostream>
6 #include<vector>
7 #include<map>
8 #include<TVectorT.h>
9 #include<TCanvas.h>
10 #include<TApplication.h>
11 #include<TChain.h>
12 #include<TROOT.h>
13 #include<TSystem.h>
14 #include<TClonesArray.h>
15 #include<TRotation.h>
16 #include<TFile.h>
17 #include<TGaxis.h>
18 #include<PndMCTrack.h>
19 #include<PndSdsMCPoint.h>
20 #include<PndLmdDim.h>
21 #include<FairRunAna.h>
22 #include<FairGeane.h>
23 #include<FairRtdbRun.h>
24 #include<FairRuntimeDb.h>
25 #include<FairParRootFileIo.h>
26 #include<TGeoVolume.h>
27 #include<TGraph.h>
28 #include<TF1.h>
29 #include <algorithm>
30 #include<fstream>
31 #include<TStyle.h>
32 #include<TGaxis.h>
33 #include<TColor.h>
34 #include<TFile.h>
35 #include<FairGeoLoader.h>
36 #include<FairGeoInterface.h>
37 #include<FairGeoBuilder.h>
38 #include<FairGeoPcon.h>
39 #include<FairGeoMedia.h>
40 #include<TGeoManager.h>
41 #include <TImage.h>
42 #include <TLine.h>
43 #include <stdlib.h>
44 #include <TPolyLine.h>
45 
46 using namespace std;
47 
48 // some design constants
49 const int nplanes(120);
50 
51 double last_percent(-1.);
52 // draw a progress bar only when the length changes significantly
53 void DrawProgressBar(int len, double percent);
54 
55 /*
56 void Check_particle_path() {
57  cout << " analysis tool vers. 1.4 " << endl;
58 
59  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
60  gSystem->Load("libSds");
61  gSystem->Load("libSdsReco");
62  gSystem->Load("libLmd");
63  gSystem->Load("libLmdReco");
64  gSystem->Load("libLmdTrk");
65 
66  TPad foo; // never remove this line :-)))
67  if(1){
68  gROOT->SetStyle("Plain");
69  const Int_t NRGBs = 5;
70  const Int_t NCont = 255;
71  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
72  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
73  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
74  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
75  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
76  gStyle->SetNumberContours(NCont);
77  gStyle->SetTitleFont(10*13+2,"xyz");
78  gStyle->SetTitleSize(0.06, "xyz");
79  gStyle->SetTitleOffset(0.8,"y");
80  gStyle->SetTitleOffset(1.3,"z");
81  gStyle->SetLabelFont(10*13+2,"xyz");
82  gStyle->SetLabelSize(0.06,"xyz");
83  gStyle->SetLabelOffset(0.009,"xyz");
84  gStyle->SetPadBottomMargin(0.16);
85  gStyle->SetPadTopMargin(0.16);
86  gStyle->SetPadLeftMargin(0.10);
87  gStyle->SetPadRightMargin(0.10);
88  gStyle->SetOptTitle(1);
89  gStyle->SetOptStat(1);
90  gROOT->ForceStyle();
91  gStyle->SetFrameFillColor(0);
92  gStyle->SetFrameFillStyle(0);
93  TGaxis::SetMaxDigits(3);
94  }
95 
96  // ------------------------------------------------------------------------
97 
98  TString storePath = ".";
99  TString startEvent = "";
100  // ---- Input files --------------------------------------------------------
101  TString simMC = storePath + "/Lumi_MC";
102  simMC += startEvent;
103  simMC += ".root";
104  TChain tMC("pndsim");
105  tMC.Add(simMC);
106 
107  TString DigiFile = storePath + "/Lumi_digi";
108  DigiFile += startEvent;
109  DigiFile += ".root";
110  TChain tdigiHits("pndsim");
111  tdigiHits.Add(DigiFile);
112 
113  // ---- Output file ----------------------------------------------------------------
114  TString fakefile = storePath + "/fake";
115  fakefile += startEvent;
116  fakefile += ".root";
117 
118  // ---- Output file ----------------------------------------------------------------
119  TString out = storePath + "/beampipe_results";
120  out += startEvent;
121  out += ".root";
122  TFile *output_histfile = new TFile(out, "RECREATE");
123  // ---------------------------------------------------------------------------------
124 
125  // Parameter file << needed for geane back tracking
126  TString parFile = storePath+"/Lumi_Params";
127  parFile += startEvent;
128  parFile += ".root";
129 
130  // ----- Reconstruction run -------------------------------------------
131  FairRunAna *fRun = new FairRunAna();
132  fRun->SetInputFile(simMC);
133  fRun->AddFriend(DigiFile);
134  //fRun->AddFriend(RecoFile);
135  //fRun->AddFriend(CandFile);
136  //fRun->AddFriend(TrkFile);
137  fRun->SetOutputFile(fakefile);
138  // ------------------------------------------------------------------------
139 
140  // ----- Parameter database --------------------------------------------
141  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
142  FairParRootFileIo* parInput1 = new FairParRootFileIo(kTRUE);
143  parInput1->open(parFile.Data());
144  rtdb->setFirstInput(parInput1);
145 
146  //--- MC info -----------------------------------------------------------------
147  TClonesArray* true_tracks = new TClonesArray("PndMCTrack");
148  tMC.SetBranchAddress("MCTrack", &true_tracks); //True Track to compare
149 
150  TClonesArray* true_points = new TClonesArray("PndSdsMCPoint");
151  tMC.SetBranchAddress("LMDPoint", &true_points); //True Points to compare
152 
153  //----------------------------------------------------------------------------------
154 
155  // histograms per plane
156  //TH2* hist_xy [nplanes];
157  //TH1* hist_theta_in [nplanes];
158 
159  TH2* hist_xz = new TH2F("hist_xz", "hist_xz", 150, 0, 150, 1000, -40, 40);
160  TH2* hist_yz = new TH2F("hist_yz", "hist_yz", 150, 0, 150, 1000, -40, 40);
161  TH2* hist_dxdz_z = new TH2F("hist_dxdz_z", "hist_dxdz_z", 150, 0, 150,
162  60000, -1e-3, 51.e-3);
163  TH2* hist_dydz_z = new TH2F("hist_dydz_z", "hist_dydz_z", 150, 0, 150,
164  1000, -5e-3, 5e-3);
165  TH2* hist_mom_z = new TH2F("hist_mom_z", "hist_mom_z", 150, 0, 150,
166  3000, -1.e-5, 1.e-5);
167  TH1* hist_n_events = new TH1F("hist_n_events", "hist_n_events", 150, 0, 150);
168 
169  //TCanvas temp_canvas("temp_canvas", "canvas for initialization", 100, 100);
170  //temp_canvas.cd();
171  // loop over planes
172  //cout << " constructing histograms for " << nplanes << " planes with " << nsensors_per_plane << " sensors per plane " << endl;
173 
174  int nEvents = tMC.GetEntries();
175  cout << " reading " << nEvents << " Events " << endl;
176  // store the x and z measurements for a later fit of a graph
177  vector<double> pos_x;
178  vector<double> pos_z;
179  map<int,int> hits_z; // count the hits per plane
180  map<int,TH2*> hists_ang_acceptance; // angular acceptance as a function of z
181  map<int,TH2*>::iterator hists_ang_acceptance_it, hists_ang_acceptance_itnorm;
182  // create the histogram to normalize to.
183  hists_ang_acceptance[-1] = new TH2F("hists_ang_acceptance", "generated angular distribution",200, -10, 10, 200, -10, 10);//, 200, 2., 10., 150., -3.141, 3.141);
184  hists_ang_acceptance_itnorm = hists_ang_acceptance.find(-1);
185  // optionally read existing values in order to create a mean graph
186  // for several scenarios. If you want to combine values, put the
187  // x_z_values_out.dat into the next folder to analyze and name it
188  // there as x_z_values_in.dat
189  ifstream x_z_values_in("x_z_values_in.dat");
190  if (nEvents <= 1000 && x_z_values_in.is_open()){
191  cout << " ************ reading x_z_values_in.dat ************ " << endl;
192  double x, z;
193  int nlines(0);
194  while(x_z_values_in.good()){
195  x_z_values_in >> x >> z;
196  if (x_z_values_in.good()){
197  pos_x.push_back(x);
198  pos_z.push_back(z);
199  nlines++;
200  } else break;
201  }
202  x_z_values_in.close();
203  cout << " read " << nlines << " lines "<< endl;
204  }
205 
206  for (Int_t j = 0; j < nEvents ; j++) {
207  DrawProgressBar(50, (j + 1) / ((double) nEvents));
208  tMC.GetEntry(j);
209  tdigiHits.GetEntry(j);
210  const int nParticles = true_tracks->GetEntriesFast();
211 
212  int npbar = 0;
213  for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
214  // if(nParticles!=4) continue;
215  PndMCTrack *mctrk = (PndMCTrack*) true_tracks->At(iParticle);
216  Int_t mcID = mctrk->GetPdgCode();
217  if (mctrk->IsGeneratorCreated()) {//mcID == -2212) {
218  npbar++;
219  // if(nParticles!=4) cout<<"For event #"<<j<<" mcID="<<mcID<<endl;
220  TVector3 momMC = mctrk->GetMomentum();
221  hists_ang_acceptance[-1]->Fill(momMC.X()/momMC.Z()*1e3, momMC.Y()/momMC.Z()*1e3);
222  //hists_ang_acceptance[-1]->Fill(MomMC.Theta()*1e3, MomMC.Phi());
223  }
224  }
225  if (0 && npbar != 1)
226  cout << "found " << npbar << " anti-protons" << endl;
227 
228  int nHits = true_points->GetEntriesFast();
229  int nSdsHits = 0;
230  for (Int_t iHit = 0; iHit < nHits; iHit++) {
231  PndSdsMCPoint* mcpoint = (PndSdsMCPoint*) true_points->At(iHit);
232  if (mcpoint->GetTrackID() < 0) continue;
233  PndMCTrack *mctrk = (PndMCTrack*) true_tracks->At(
234  mcpoint->GetTrackID());
235  if (mctrk->IsGeneratorCreated()) { // take only anti-protons from the generator
236  if (mcpoint) {
237  TVector3 _mcpoint((mcpoint->GetPosition())); // position at the sensor entrance
238  TVector3 _mctrack(mcpoint->GetPx(), mcpoint->GetPy(),
239  mcpoint->GetPz()); // momentum of the track at the entrance
240 
241  TVector3 momMC = mctrk->GetMomentum(); // momentum in the primary vertex
242  TVector3 posMC = mctrk->GetStartVertex(); // position of the primary vertex
243 
244  //det_id = mcpoint->GetDetectorID(); // store the detector id
245  //sens_id = mcpoint->GetSensorID(); // store the sensor id
246  // calculate the plane and sensor on this plane
247  int plane = mcpoint->GetSensorID();
248 
249  if (plane < 0 || plane >= nplanes) {
250  cout
251  << " warning: calculated plane or sensor is wrong: plane "
252  << plane << endl;
253  } else {
254  // is it an unknown plane so far?
255  if (hists_ang_acceptance.find(plane) == hists_ang_acceptance.end()){
256  stringstream hist_name;
257  stringstream hist_title;
258  hist_name << "hists_ang_acceptance_plane_" << plane;
259  hist_title << "angular acceptance at z = " << plane*10. << " cm " << endl;
260  hists_ang_acceptance[plane] = new TH2F(hist_name.str().c_str(), hist_title.str().c_str(),
261  200, -10, 10, 200, -10, 10);//200, 2., 10., 150., -3.141, 3.141);
262  }
263  hists_ang_acceptance[plane]->Fill(momMC.X()/momMC.Z()*1e3, momMC.Y()/momMC.Z()*1e3);//(momMC.Theta()*1e3, momMC.Phi());
264  if (j < 1000){
265  pos_x.push_back(_mcpoint.X());
266  pos_z.push_back(_mcpoint.Z());
267  }
268  hist_xz->Fill(plane, _mcpoint.X());
269  hist_yz->Fill(plane, _mcpoint.Y());
270  hist_dxdz_z->Fill(plane, _mctrack.X() / _mctrack.Z());
271  hist_dydz_z->Fill(plane, _mctrack.Y() / _mctrack.Z());
272  hist_mom_z->Fill(plane, (_mctrack.Mag()-momMC.Mag())/momMC.Mag());
273  //hist_xy [plane] ->Fill(x_in,y_in);
274  //hist_theta_in [plane] ->Fill(ptheta_in);
275  hits_z[plane]++;
276  }
277  nSdsHits++;
278  }
279  }
280  }
281  if (0 && nHits > 0)
282  cout << "found " << nHits << " hit(s) with " << nSdsHits
283  << " sds hit(s)" << endl;
284  }
285 
286  ofstream x_z_values_out("x_z_values_out.dat");
287  if (nEvents <= 1000 && x_z_values_out.is_open()){
288  cout << " ************ writing x_z_values_out.dat ************ " << endl;
289  for (unsigned int iline = 0; iline < pos_x.size(); iline++){
290  x_z_values_out << pos_x[iline] << " " << pos_z[iline] << "\n";
291  }
292  x_z_values_out.close();
293  cout << " wrote " << pos_x.size() << " lines "<< endl;
294  }
295 
296  //std::sort(pos_x.begin(), pos_x.end());
297  //std::sort(pos_z.begin(), pos_z.end());
298  TGraph* graph_x_z = new TGraph( pos_x.size(), (double*)&pos_z[0], (double*)&pos_x[0]);
299  graph_x_z->SetNameTitle("graph_x_z","x over z hits");
300  //graph_x_z->SetMarkerStyle(4);
301  graph_x_z->SetLineWidth(0);
302  TF1* func_beampipe = new TF1("func_beampipe", function_beampipe, 0., pos_z[pos_z.size()-1], 3);
303  // par[0]: where bending starts (dipole region)
304  // par[1]: the bending radius
305  // par[2]: the bending angle
306  func_beampipe->SetParameters(361., 6000., 40.e-3);
307  func_beampipe->SetParNames(
308  "bending start [cm] ",
309  "bending radius [cm] ",
310  "bend by phi [rad] ");
311  func_beampipe->FixParameter(2,40.0e-3);
312  func_beampipe->FixParameter(0,361.);
313  func_beampipe->FixParameter(1,5720.);
314  gStyle->SetOptFit(111);
315 
316  TGaxis::SetMaxDigits(3);
317  TCanvas* canvas1 = new TCanvas("canvas1", "x over z hits", 1200, 800);
318  //canvas1->Divide(2,2);
319  canvas1->cd(0);
320  //hist_xz->Draw("COLZ");
321  graph_x_z->Draw("AP");
322  graph_x_z->Fit(func_beampipe);
323  graph_x_z->GetXaxis()->SetTitle("z [cm]");
324  graph_x_z->GetYaxis()->SetTitle("x [cm]");
325  func_beampipe->Draw("same");
326  cout << " x displacement at 11 m is " << func_beampipe->Eval(1100.) << endl;
327  gPad->Update();
328  //func_beampipe->Draw("same");
329  canvas1->Print("beampipe_results.png");
330  // create residual distribution
331  TCanvas* canvas6 = new TCanvas("canvas6", "residuals", 1200, 800);
332  TH2F* hist_res_x_z = new TH2F("hist_res_x_z", "residuals of x over z fit", 150, 0, 1500, 100, -0.1, 0.1);
333  for (unsigned int iz = 0; iz < pos_z.size(); iz++){
334  hist_res_x_z->Fill(pos_z[iz], pos_x[iz]-func_beampipe->Eval(pos_z[iz]));
335  }
336  hist_res_x_z->Draw("COLZ");
337  hist_res_x_z->GetXaxis()->SetTitle("x [cm]");
338  hist_res_x_z->GetYaxis()->SetTitle("x - x_{fit} [cm]");
339  canvas6->Print("beampipe_results.ps(");
340 
341  TCanvas* canvas2 = new TCanvas("canvas2", "canvas2", 1200, 800);
342  //canvas2->Divide(2,2);Double_t function_beampipe(Double_t *x, Double_t *par)
343  {
344  double pos_z = x[0];
345  double result = 0.;
346  double end_seg_upstream = par[0]; // where bending starts with
347  double r_bend = par[1]; // a radius
348  double phi_bend = par[2]; // and the angle of the circle path
349  // the rest is fully determined
350  double end_seg_bend = end_seg_upstream+sin(phi_bend)*r_bend;
351  // the first straight part
352  if (pos_z < end_seg_upstream){
353  result = 0.;
354  }
355  // bending part is a part of a circle
356  if (end_seg_upstream <= pos_z && pos_z < end_seg_bend){
357  result = r_bend - cos(atan((pos_z-end_seg_upstream)/r_bend))*r_bend;
358  }
359  // straight part behind the dipole is a tangent to the circle
360  if (end_seg_bend <= pos_z){
361  result = (pos_z - end_seg_upstream - tan(phi_bend/2.)*r_bend)*tan(phi_bend);
362  }
363  return result;
364  }
365  canvas2->cd(0);
366  hist_yz->Draw("COLZ");
367  canvas2->Print("beampipe_results.ps(");
368  TCanvas* canvas3 = new TCanvas("canvas3", "canvas3", 1200, 800);
369  //canvas3->Divide(2,2);
370  canvas3->cd(0);
371  hist_dxdz_z->Draw("COLZ");
372  canvas3->Print("beampipe_results.ps(");
373  hist_dxdz_z->GetYaxis()->SetRangeUser(40.e-3, 40.05e-3);
374  hist_dxdz_z->Draw("COLZ");
375  canvas3->Print("beampipe_results.ps(");
376  TCanvas* canvas4 = new TCanvas("canvas4", "canvas4", 1200, 800);
377  //canvas4->Divide(2,2);
378  canvas4->cd(0);
379  hist_dydz_z->Draw("COLZ");
380  canvas4->Print("beampipe_results.ps(");
381  TCanvas* canvas5 = new TCanvas("canvas5", "canvas5", 1200, 800);
382  //canvas5->Divide(2,2);
383  canvas5->cd(0);
384  hist_mom_z->Draw("COLZ");
385  canvas5->Print("beampipe_results.ps(");
386  TCanvas* canvas7 = new TCanvas("canvas6", "canvas6", 1200, 400);
387  gPad->SetLeftMargin(0.1);
388  gPad->SetRightMargin(0.05);
389  canvas7->cd(0);
390  // check the acceptance of the beam pipe as a function of z
391  // normalize to the plane before
392  map<int, int>::iterator hits_z_it, hits_z_it_next;
393  for (hits_z_it = hits_z.begin(); hits_z_it != hits_z.end(); hits_z_it++){
394  hits_z_it_next = hits_z_it;
395  hits_z_it_next++;
396  if (hits_z_it_next == hits_z.end()) break;
397  if (hits_z_it->second == 0) continue;
398  if (hits_z_it_next->first != hits_z_it->first+1){
399  cout << " sorry, entries are not sorted! " << hits_z_it_next->first << " != " << hits_z_it->first << " +1 "<< endl;
400  continue;
401  }
402  hist_n_events->Fill(hits_z_it_next->first, ((double)hits_z_it_next->second)/((double)hits_z_it->second));
403  }
404  hist_n_events->GetXaxis()->SetTitle("z [dm]");
405  hist_n_events->GetYaxis()->SetTitle("relative acceptance");
406  hist_n_events->Draw("hist text");
407  canvas7->Print("beampipe_results.ps(");
408 
409  TCanvas* canvas8 = new TCanvas("canvas8", "canvas8", 800, 400);
410  canvas8->Divide(2,1);
411  canvas8->cd(1);
412  gPad->SetLeftMargin(0.16);
413  gPad->SetRightMargin(0.16);
414  canvas8->cd(1);
415  hists_ang_acceptance_itnorm->second->GetXaxis()->SetTitle("dX/dZ x 10^{3}");
416  hists_ang_acceptance_itnorm->second->GetYaxis()->SetTitle("dY/dZ x 10^{3}");
417  hists_ang_acceptance_itnorm->second->Draw("COLZ");
418  canvas8->cd(2);
419  gPad->SetLeftMargin(0.16);
420  gPad->SetRightMargin(0.16);
421  system("rm beampipe_acceptance*.gif");
422 
423  if (1){
424  TImage *img = TImage::Open("/home/jasinski/bin/pandaroot/macro/lmd/Promme/beampipe.png");
425  int width = 1000;
426  double pic_width = img->GetWidth();
427  int height = floor(img->GetHeight()*width/pic_width);
428  TCanvas* canvas = new TCanvas("canvas_acceptance", "canvas_acceptance", width, height*2);
429  gPad->Range(0, 0, width, height*2.);
430  canvas->Divide(1,2);
431  canvas->cd(1);
432  gPad->Range(0, 0., 1., 1.);
433  canvas->cd(2);
434  gPad->Range(0, 0, width, height);
435  double factor = 1./(-460.-1294.); // inserting ranges of the beampipe
436  double ratio = height/(double)width;
437  TPolyLine *arc = Get_PolyLine_circle(0,0,8);
438  arc->SetLineColor(3);
439  arc->SetLineWidth(2);
440  // check the acceptance of the beam pipe as a function of z
441  // normalize to the plane -1
442  for (hists_ang_acceptance_it = hists_ang_acceptance.begin();
443  hists_ang_acceptance_it != hists_ang_acceptance.end();
444  hists_ang_acceptance_it++){\
445  if (hists_ang_acceptance_it == hists_ang_acceptance_itnorm){
446  continue;
447  }
448  canvas->cd(1);
449  gPad->Clear();
450  img->Draw("xxx");
451  double x = factor*(hists_ang_acceptance_it->first*10. - 1294.);
452  cout << "drawing x = " << hists_ang_acceptance_it->first*10. << " cm at " << x << endl;
453  TLine line(x, 0., x, 1.);
454  line.SetLineColor(2);
455  line.SetLineWidth(2);
456  line.Draw();
457  gPad->Update();
458  hists_ang_acceptance_it->second->Divide(hists_ang_acceptance_itnorm->second);
459  hists_ang_acceptance_it->second->SetMaximum(1.);
460  hists_ang_acceptance_it->second->GetXaxis()->SetTitle("dX/dZ x 10^{3}");
461  hists_ang_acceptance_it->second->GetYaxis()->SetTitle("dY/dZ x 10^{3}");
462  if (x-ratio/2. > 0){
463  canvas->cd(2);
464  TPad clonepad("insertpad","insertpad",x-ratio/2.,0.,x+ratio/2.,1., 0, 1, 1);
465  clonepad.Draw();
466  clonepad.cd();
467  gPad->SetLeftMargin(0.16);
468  gPad->SetRightMargin(0.16);
469  hists_ang_acceptance_it->second->Draw("COLZ");
470  gPad->Update();
471  //sleep(1);
472  //canvas->Print("beampipe_results.ps(");
473  canvas->Print("beampipe_acceptance.gif+");
474  }
475  canvas8->cd(2);
476  hists_ang_acceptance_it->second->Draw("COLZ");
477  arc->Draw();
478  canvas8->Update();
479  //canvas->Print("beampipe_results.ps(");
480  canvas8->Print("beampipe_acceptance_hists.gif+");
481  }
482  }
483  canvas8->Clear();
484 
485  canvas8->Print("beampipe_results.ps)");
486 
487 
488  // convert to pdf
489  cout << "converting to pdf " << system("ps2pdf beampipe_results.ps")
490  << endl;
491  cout << "deleting ps file " << system("rm beampipe_results.ps") << endl;
492 
493  output_histfile->Write();
494 
495  output_histfile->Close();
496 }*/
497 
498 void DrawProgressBar(int len, double percent) {
499  if ((int) (last_percent * 100) == (int) (percent * 100))
500  return;
501  //cout << " drawing " << endl;
502  cout << "\x1B[2K"; // Erase the entire current line.
503  cout << "\x1B[0E"; // Move to the beginning of the current line.
504  string progress;
505  for (int i = 0; i < len; ++i) {
506  if (i < static_cast<int> (len * percent)) {
507  progress += "=";
508  } else {
509  progress += " ";
510  }
511  }
512  cout << "[" << progress << "] " << (static_cast<int> (100 * percent))
513  << "%";
514  flush( cout); // Required.
515  last_percent = percent;
516 }
517 
518 #include"TH2Poly.h"
519 #include"TRandom.h"
520 int main() {
521  TApplication myapp("myapp", 0, 0);
522  //Check_particle_path();
523  PndLmdDim* lmddim = PndLmdDim::Instance();
525  TH2Poly* hist1 = lmddim->Get_histogram_Plane(0,0,true, true, false);
526  TH2Poly* hist2 = lmddim->Get_histogram_Plane(0,1,true, true, false);
527  cout << " creating hist sensor " << endl;
528  TH2Poly* hist_sens_1 = lmddim->Get_histogram_Sensor(0,0,3,0,0,0,true, true);
529  TH2Poly* hist_mod_1 = lmddim->Get_histogram_Moduleside(1,3,1,0,true, true, true);
530  cout << " done " << endl;
531  for (int i=0; i < 10000000; i++){
532  double x = gRandom->Uniform(-10., 10.);
533  double y = gRandom->Uniform(-10., 10.);
534  hist1->Fill(x,y);
535  hist2->Fill(x,y);
536  hist_sens_1->Fill(x,y);
537  hist_mod_1->Fill(x,y);
538  DrawProgressBar(50, (i + 1) / ((double) 1000000));
539  }
540  TCanvas canvas("canvas", "canvas", 1000, 1000);
541  canvas.Divide(2,2);
542  canvas.cd(1);
543  hist1->Draw("COLZ");
544  canvas.cd(2);
545  hist2->Draw("COLZ");
546  canvas.cd(3);
547  //hist_sens_1->Draw("alp");
548  hist_sens_1->Draw("COLZ");
549  canvas.cd(4);
550  hist_mod_1->Draw("COLZ");
551  myapp.Run();
552  return 0;
553 }
const int nplanes(120)
double last_percent(-1.)
int main(int argc, char **argv)
TH2Poly * Get_histogram_Plane(int iplane, int iside, bool aligned=true, bool lmd_frame=true, bool pixel_subdivision=false)
Definition: PndLmdDim.cxx:3658
TH2Poly * Get_histogram_Sensor(int ihalf, int iplane, int imodule, int iside, int idie, int isensor, bool aligned=true, bool lmd_frame=true)
Definition: PndLmdDim.cxx:3721
Int_t i
Definition: run_full.C:25
static PndLmdDim * Instance()
Definition: PndLmdDim.cxx:249
void DrawProgressBar(int len, double percent)
TH1D * hist2
Definition: hist-t7.C:82
TH2Poly * Get_histogram_Moduleside(int ihalf, int iplane, int imodule, int iside, bool aligned=true, bool lmd_frame=true, bool pixel_subdivision=true)
Definition: PndLmdDim.cxx:3689
void Read_transformation_matrices(string filename="", bool aligned=true, int version_number=geometry_version)
Definition: PndLmdDim.cxx:1515
Double_t x
Double_t y
TH1D * hist1
Definition: hist-t7.C:80