FairRoot/PandaRoot
Functions
time_based_studies.C File Reference
#include <iostream>
#include <TCanvas.h>
#include <TApplication.h>
#include <TROOT.h>
#include <TChain.h>
#include <TStyle.h>
#include <TGaxis.h>
#include <TColor.h>
#include <TClonesArray.h>
#include <TH1.h>
#include <TH2.h>
#include <PndLmdDim.h>
#include <PndMCTrack.h>
#include <PndSdsMCPoint.h>

Go to the source code of this file.

Functions

void Root_Appearance ()
 
double last_percent (-1.)
 
void DrawProgressBar (int len, double percent)
 
int time_based_studies ()
 
int main ()
 

Function Documentation

void DrawProgressBar ( int  len,
double  percent 
)

Definition at line 209 of file time_based_studies.C.

References i, and last_percent().

Referenced by time_based_studies().

209  {
210  if ((int) (last_percent * 100) == (int) (percent * 100))
211  return;
212  //cout << " drawing " << endl;
213  cout << "\x1B[2K"; // Erase the entire current line.
214  cout << "\x1B[0E"; // Move to the beginning of the current line.
215  string progress;
216  for (int i = 0; i < len; ++i) {
217  if (i < static_cast<int> (len * percent)) {
218  progress += "=";
219  } else {
220  progress += " ";
221  }
222  }
223  cout << "[" << progress << "] " << (static_cast<int> (100 * percent))
224  << "%";
225  flush( cout); // Required.
226  last_percent = percent;
227 }
Int_t i
Definition: run_full.C:25
double last_percent(-1.)
double last_percent ( 1.)

Referenced by DrawProgressBar().

int main ( void  )

Definition at line 32 of file time_based_studies.C.

References Root_Appearance(), and time_based_studies().

32  {
34  TApplication myapp("myapp", 0, 0);
36  myapp.Run();
37  return 0;
38 }
int time_based_studies()
void Root_Appearance()
void Root_Appearance ( )

Definition at line 177 of file time_based_studies.C.

References Double_t.

Referenced by main().

177  {
178  TPad foo; // never remove this line :-)))
179  if(1){
180  gROOT->SetStyle("Plain");
181  const Int_t NRGBs = 5;
182  const Int_t NCont = 255;
183  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
184  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
185  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
186  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
187  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
188  gStyle->SetNumberContours(NCont);
189  gStyle->SetTitleFont(10*13+2,"xyz");
190  gStyle->SetTitleSize(0.06, "xyz");
191  gStyle->SetTitleOffset(1,"xy");
192  gStyle->SetTitleOffset(1.3,"z");
193  gStyle->SetLabelFont(10*13+2,"xyz");
194  gStyle->SetLabelSize(0.06,"xyz");
195  gStyle->SetLabelOffset(0.009,"xyz");
196  gStyle->SetPadBottomMargin(0.2);
197  gStyle->SetPadTopMargin(0.15);
198  gStyle->SetPadLeftMargin(0.15);
199  gStyle->SetPadRightMargin(0.20);
200  gStyle->SetOptTitle(0);
201  gStyle->SetOptStat(0);
202  gROOT->ForceStyle();
203  gStyle->SetFrameFillColor(0);
204  gStyle->SetFrameFillStyle(0);
205  TGaxis::SetMaxDigits(3);
206  }
207 }
Double_t
int time_based_studies ( )

Definition at line 40 of file time_based_studies.C.

References DrawProgressBar(), PndLmdDim::Get_instance(), PndLmdDim::Get_sensor_by_id(), PndSdsMCPoint::GetPosition(), PndSdsMCPoint::GetSensorID(), nEvents, nHits, PndLmdDim::Transform_global_to_lmd_local(), and tsim.

Referenced by main().

40  {
41  cout << " lmd time based studies " << endl;
42  TCanvas* canvas = new TCanvas("canvas", "canvas", 600, 600);
43  canvas->Divide(2,2);
44 
45  // load the MC File
46  TChain tMC("pndsim");
47  tMC.Add("./Lumi_MC_0.root");
48 
49  //--- assign MC info -----------------------------------------------------
50  TClonesArray* true_tracks = new TClonesArray("PndMCTrack");
51  tMC.SetBranchAddress("MCTrack", &true_tracks); //True Track to compare
52 
53  TClonesArray* true_points = new TClonesArray("PndSdsMCPoint");
54  tMC.SetBranchAddress("LMDPoint", &true_points); //True Points to compare
55 
56  // get the lmd dim help class
58 
59  // setup histograms
60  /*
61  TH1F* hist_eloss_total = new TH1F("hist_eloss_total", "energy deposit in 50#mum x 2cm x2cm sensors", 200, 0, 60);
62  TH1F* hist_eloss = new TH1F("hist_eloss", "energy deposit scaled to 1#mum", 200, 0, 1200);
63  hist_eloss_total->SetXTitle("E_{dep} [keV]");
64  hist_eloss->SetXTitle("E_{dep} [eV]");
65 
66  TH2* plane3_hits = new TH2F("plane3_hits", "hits on plane 3", 200, -10, 10, 200, -10, 10); //lmddim.Get_histogram_Plane(0, 0);
67  plane3_hits->SetXTitle("X [cm]");
68  plane3_hits->SetYTitle("Y [cm]");
69  plane3_hits->SetZTitle("# hits");
70  TH2Poly* plane3_Edep = lmddim.Get_histogram_Plane(3, 0);
71  plane3_Edep->SetNameTitle("plane3_Edep", "E dep on plane 3");
72  plane3_Edep->SetZTitle("E_{dep} [J]");
73  TH2Poly* plane3_rate = lmddim.Get_histogram_Plane(3, 0);
74  plane3_rate->SetNameTitle("plane3_rate", "rate on plane 3");
75  plane3_rate->SetZTitle("rate [kHz]");
76  TH2Poly* plane3_rad = lmddim.Get_histogram_Plane(3, 0);
77  plane3_rad->SetNameTitle("plane3_rad", "IEL dose on plane 3");
78  plane3_rad->SetZTitle("IEL dose [Gy/a]");
79 */
80  // read events and analyze
81  int nEvents = tMC.GetEntries();
82  int nEvents_counted(0);
83  int nhitstotal(0);
84 
85  cout << " reading " << nEvents << " Events " << endl;
86  for (Int_t j = 0; j < nEvents ; j++) {
87  nEvents_counted++;
88  DrawProgressBar(50, (j + 1) / ((double) nEvents));
89  tMC.GetEntry(j);
90 
91  int nHits = true_points->GetEntriesFast();
92  int nSdsHits = 0;
93  for (Int_t iHit = 0; iHit < nHits; iHit++) {
94  PndSdsMCPoint* mcpoint = (PndSdsMCPoint*) true_points->At(iHit);
95  //if (mcpoint->GetTrackID() < 0) continue;
96  // cout << mcpoint->GetEnergyLoss() << endl;
97  //hist_eloss_total->Fill(mcpoint->GetEnergyLoss()*1.e6); // in keV
98  //hist_eloss->Fill(mcpoint->GetEnergyLoss()*1.e9/50.); // in eV
99 
100  int sensID = mcpoint->GetSensorID();
101  int ihalf, iplane, imodule, iside, idie, isensor;
102  lmddim.Get_sensor_by_id(sensID, ihalf, iplane, imodule, iside, idie, isensor);
103  TVector3 hit_pos = mcpoint->GetPosition();
104  TVector3 hit_pos_lmd = lmddim.Transform_global_to_lmd_local(hit_pos, false);
105 
106  nhitstotal++;
107 
108  cout << mcpoint->GetTime() << endl;
109  //cout << mcpoint->Get << endl << endl;
110 
111  if (iplane == 3 && iside == 0){
112  //plane3_hits->Fill(hit_pos_lmd.X(), hit_pos_lmd.Y());
113  //plane3_rate->Fill(hit_pos_lmd.X(), hit_pos_lmd.Y());
114  //plane3_Edep->Fill(hit_pos_lmd.X(), hit_pos_lmd.Y(), mcpoint->GetEnergyLoss()*1.e9*1.602e-19); // in J
115  //plane3_rad->Fill(hit_pos_lmd.X(), hit_pos_lmd.Y(), mcpoint->GetEnergyLoss()*1.e9*1.602e-19); // in J
116  }
117 /*
118  if (mcpoint->GetTrackID() < 0) continue;
119  PndMCTrack *mctrk = (PndMCTrack*) true_tracks->At(
120  mcpoint->GetTrackID());
121  if (mctrk->IsGeneratorCreated()) { // take only anti-protons from the generator
122  if (mcpoint) {
123  TVector3 _mcpoint((mcpoint->GetPosition())); // position at the sensor entrance
124  TVector3 _mctrack(mcpoint->GetPx(), mcpoint->GetPy(),
125  mcpoint->GetPz()); // momentum of the track at the entrance
126 
127  TVector3 momMC = mctrk->GetMomentum(); // momentum in the primary vertex
128  TVector3 posMC = mctrk->GetStartVertex(); // position of the primary vertex
129  }
130  } */
131  }
132  }
133  // cross section for N generated events at 1.5 GeV/c momentum was
134  // sigm_coul = 36.683 mbarn
135  // sigm_had_el = 25.3021 mbarn
136  // sigm_inel = 62.71 mbarn according to Anastasias note
137  // -> sig_total = 124.63 mbarn or 124.63 x 10-27 cm^-2
138  double sig_total = 124.63e-27;//62e-27;//124.63e-27; // cm^2
139  // the mean instantanious luminosity at high luminosity mode is 1.6 x 10^32
140  // but we use here for reference 1 x 10^32 which can be scaled easily to any other number
141  double lumi_ref = 1e32; // cm^-2 s^-1
142  // therefore we simulated an interaction rate of
143  double rate_total = sig_total * lumi_ref; // 1/s or Hz
144  cout << "\n The total rate at 1.5 GeV/c and " << lumi_ref << " mean luminosity to normalize to is " << rate_total << " Hz" << endl;
145  // The simulated time scale is then
146  double tsim = nEvents_counted / rate_total; // s
147  cout << nEvents_counted << " events correspond to a real time of " << tsim << " s " << endl;
148  /*
149  plane3_rate->Scale(1./tsim*1e-3); // in kHz
150  //plane3_rate->SetMaximum(150);
151  cout << " total rate of " << nhitstotal << " hits is " << nhitstotal/tsim*1e-6 << "MHz" << endl;
152  plane3_rad->Scale(1./tsim*60.*60.*24.*365.*0.5/(2.33e-3*(2*2*50.e-4))); // 50% duty cycle over a year and normalized to the mass in kg of one sensor
153  //canvas->cd(1);
154  plane3_Edep->Draw("colz");
155  //hist_eloss_total->Draw();
156  //canvas->cd(2);
157  plane3_hits->Draw("colz");
158  canvas->Print("MC_hit_distr_1_5_plane_3_side_0.pdf");
159  canvas->Print("MC_hit_distr_1_5_plane_3_side_0.root");
160  hist_eloss->Draw();
161  canvas->Print("MC_IEL_distrib_1_5.pdf");
162  canvas->Print("MC_IEL_distrib_1_5.root");
163  //canvas->cd(3);
164  plane3_rate->Draw("colz");
165  cout << " max rate is " << plane3_rate->GetBinContent(plane3_rate->GetMaximumBin()) << " kHz" << endl;
166  canvas->Print("MC_hit_rate_1_5_plane_3_side_0.pdf");
167  canvas->Print("MC_hit_rate_1_5_plane_3_side_0.root");
168  //canvas->cd(4);
169  plane3_rad->Draw("colz");
170  cout << " max dose is " << plane3_rad->GetBinContent(plane3_rad->GetMaximumBin()) << " Gy" << endl;
171  canvas->Print("MC_IEL_dose_1_5_plane_3_side_0.pdf");
172  canvas->Print("MC_IEL_does_1_5_plane_3_side_0.root");
173  */
174  return 0;
175 }
void DrawProgressBar(int len, double percent)
TVector3 Transform_global_to_lmd_local(const TVector3 &point, bool isvector=false, bool aligned=true)
Definition: PndLmdDim.cxx:3113
Int_t GetSensorID() const
Definition: PndSdsMCPoint.h:89
int nHits
Definition: RiemannTest.C:16
void Get_sensor_by_id(const int sensor_id, int &ihalf, int &iplane, int &imodule, int &iside, int &idie, int &isensor)
Definition: PndLmdDim.h:526
Int_t nEvents
Definition: hit_dirc.C:11
TVector3 GetPosition() const
Definition: PndSdsMCPoint.h:90
static PndLmdDim & Get_instance()
Definition: PndLmdDim.cxx:242